小编Mei*_*. I的帖子

EMF 图像大小和分辨率因机器的缩放设置而异 - 在 C# 中创建时

我正在 C# 中创建 EMF 图像,缩放模式为 125%(请参阅文章底部更新的链接以更改 Windows 机器中的缩放模式)。无论代码中使用的 DPI 设置如何,图像大小和分辨率都会根据机器的缩放设置而变化。

        //Set the height and width of the EMF image
        int imageWidth = 1280;
        int imageHeight = 720;

        //Adjust the witdh for the screen resoultion 
        using (Graphics graphics = Graphics.FromHwnd(IntPtr.Zero))
        {
            imageWidth = (int)(imageWidth / 96.0 * graphics.DpiX);
            imageHeight = (int)(imageHeight / 96.0 * graphics.DpiY);
        }

        Image image = null;

        //Stream to create a EMF image
        MemoryStream stream = new MemoryStream();

        //Create graphics with bitmap and render the graphics in stream …
Run Code Online (Sandbox Code Playgroud)

c# system.drawing image windows-10

7
推荐指数
0
解决办法
525
查看次数

使用 Roslyn 拆分表达式语句

我正在开发一个可以重写CSharp代码的应用程序。我正在这样做Roslyn。我面临着一个问题splitting expressions

样板课

class Program
{
    static void Main(string[] args)
    {
        float floatVariable = 20;
        Int16 intVariable = 10;
        string str = "School";
        Console.Write(str + floatVariable.ToString() + intVariable.ToString()); // Facing problem with this statement
    }
}
Run Code Online (Sandbox Code Playgroud)

我正在使用的示例代码

string code = new StreamReader(classPath).ReadToEnd();
var syntaxTree = CSharpSyntaxTree.ParseText(code);
var syntaxRoot = syntaxTree.GetRoot();

//This will get the method and local variables declared inside the method
var MyMethods = syntaxRoot.DescendantNodes().OfType<MethodDeclarationSyntax>();
foreach (MethodDeclarationSyntax mds in MyMethods)
{
    syntaxTree = …
Run Code Online (Sandbox Code Playgroud)

c# visual-studio roslyn

5
推荐指数
1
解决办法
2937
查看次数

将警告消息记录在蛋糕脚本的文本文件中

我正在使用下面的蛋糕脚本来编译我的C#项目.PowerShell执行脚本时显示的警告消息很少.我喜欢在一个物理位置的文本文件中记录警告(例如:D:\WarningReport.txt).以下是我用来编译项目的蛋糕脚本任务.

Task("Build")
    .Does(() =>
{
    if(IsRunningOnWindows())
    {
      MSBuild("./src/Example.sln", settings =>
        settings.SetConfiguration(configuration));
    }
});
Run Code Online (Sandbox Code Playgroud)

我想添加如下的内容,

LogWarningMessagesTo("D:\WarningReportes.txt");
LogErrorMessagesTo("D:\ErrorReportes.txt");
Run Code Online (Sandbox Code Playgroud)

这该怎么做?

.net c# gitlab gitlab-ci cakebuild

4
推荐指数
1
解决办法
593
查看次数

Java Long.MAX_VALUE属性抛出"整数过大"异常!包括"L"

我正在使用Java SE开发工具包8更新25(64位).我已经阅读了The Java™Tutorials中的"原始数据类型"Java教程,根据此规范,long类型可以保持最大值(2到64的功率)-1,即18446744073709551615.

但是下面的代码会抛出"整数太大"错误消息.

public class SampleClass
{
    public static void main (String[] args)
    {        
        Long longMaxValue= 18446744073709551615L /* UInt64.MaxValue */;
    }
}
Run Code Online (Sandbox Code Playgroud)

此外,Long.Max_Value仅返回9223372036854775807.为什么?我需要将值18,446,744,073,709,551,615存储为java中的常量.我该怎么办?

任何帮助都会得到满足.

java primitive

0
推荐指数
1
解决办法
1847
查看次数