RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-390323

mounten1's questions

Martin Hope
mounten1
Asked: 2022-02-15 05:02:15 +0000 UTC

如何使用 ChromiumOptions 声明通用 ChromiumDriver?

  • 1

如何申报ChromiumDriver共同点ChromiumOptions?

试图这样做:

public Form1()
{
    //...
    options.AddArgument("headless");    
}

ChromeOptions options = new ChromeOptions();
ChromeDriver driver = new ChromeDriver(options);
//...

但是写了一个错误: CS0236 Инициализатор поля не может обращаться к нестатическому полю, методу или свойству "Form1.options".

c#
  • 1 个回答
  • 10 Views
Martin Hope
mounten1
Asked: 2021-12-27 05:15:54 +0000 UTC

从 ComboBox 中读取选定的文件。C#

  • 1

有void ReadFile(string path),还有一个代码将txt文件添加到combobox:

            string path = Application.StartupPath;
            var dir = new DirectoryInfo(path);
            var files = new List<string>();

            foreach (FileInfo file in dir.GetFiles("*.txt"))
            {
                files.Add(Path.GetFileName(file.FullName));
            }
            foreach (string str in files)
            {
                combobox.Items.Add(str);
            }

如何使选定的文件combobox能够指定为pathfor ReadFile?

像这样尝试过,但没有奏效:

 ReadFile(Application.StartupPath + "\\" + combobox.SelectedText);
c#
  • 2 个回答
  • 10 Views
Martin Hope
mounten1
Asked: 2021-11-29 03:47:51 +0000 UTC

将字符串转换为颜色

  • 0

可用的

string color = ColorPicker.Color.ToString();

(我使用Cyotek.Windows.Forms.ColorPicker)它
随后被保存到一个 txt 文件中。在 txt 文件中,我们有一行:Color [A=255, R=255, G=0, B=203]. 当我运行程序时,我阅读了这一行。

问题:

  1. 如何转换string为Color?
  2. 如何在转换过程中检查:Color [Empty]?

添加:

  1. 图书馆链接:https ://github.com/cyotek/Cyotek.Windows.Forms.ColorPicker
c#
  • 1 个回答
  • 10 Views
Martin Hope
mounten1
Asked: 2021-11-03 19:26:54 +0000 UTC

BackgroundWorker 未完全执行。C#

  • 1

是BackgroundWorker执行某个代码。完成后,它必须将变量写入label. 但它不会发生。然后我决定把代码拆成BackgroundWorker小块,执行完一段代码后,Console.WriteLine显示段数( ),只有8个,前7个是条件检查,最后一个是输出。然后当我编译程序时,我在输出中看到:

1
2
3
4
5
6
7

它与什么有关?

工人代码:

private void RegistryChecker_DoWork(object sender, DoWorkEventArgs e)
        {
            int CanOptimisated = 0;

            var printers = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RemoteComputer\NameSpace\{863aa9fd-42df-457b-8e4d-0de1b8015c60}");
            //var onedrive = Registry.LocalMachine;
            string unloaddlls = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer";
            string superfetch = @"SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters";
            string prioritycontrol = @"SYSTEM\CurrentControlSet\Control\PriorityControl";
            string disableexecuting = @"SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management";
            string enablesmartscreen = @"SOFTWARE\Policies\Microsoft\Windows\System";

            Console.WriteLine(1);
            try
            {
                printers.GetValue("");
                CanOptimisated++;
                guna2CheckBox1.Invoke(new Action(() =>
                {
                    guna2CheckBox1.Enabled = true;
                }));
            }
            catch
            {
                guna2CheckBox1.Invoke(new Action(() =>
                {
                    guna2CheckBox1.Enabled = false;
                }));
            }

            Console.WriteLine(2);
            if (CheckRegistry(unloaddlls, "AlwaysUnloadDll", "1") == true)
            {
                guna2CheckBox2.Invoke(new Action(() =>
                {
                    guna2CheckBox2.Enabled = false;
                }));
            }
            else
            {
                CanOptimisated++;
                guna2CheckBox2.Invoke(new Action(() =>
                {
                    guna2CheckBox2.Enabled = true;
                }));
            }

            Console.WriteLine(3);
            if (CheckRegistry(superfetch, "EnableSuperfetch", "0") == true)
            {
                guna2CheckBox4.Invoke(new Action(() =>
                {
                    guna2CheckBox4.Enabled = false;
                }));
            }
            else
            {
                CanOptimisated++;
                guna2CheckBox4.Invoke(new Action(() =>
                {
                    guna2CheckBox4.Enabled = true;
                }));
            }

            Console.WriteLine(4);
            if (CheckRegistry(superfetch, "EnablePrefetcher", "0") == true)
            {
                guna2CheckBox5.Invoke(new Action(() =>
                {
                    guna2CheckBox5.Enabled = false;
                }));
            }
            else
            {
                CanOptimisated++;
                guna2CheckBox5.Invoke(new Action(() =>
                {
                    guna2CheckBox5.Enabled = true;
                }));
            }

            Console.WriteLine(5);
            if (CheckRegistry(prioritycontrol, "Win32PrioritySeparation", "6") == true)
            {
                guna2CheckBox6.Invoke(new Action(() =>
                {
                    guna2CheckBox6.Enabled = false;
                }));
            }
            else
            {
                CanOptimisated++;
                guna2CheckBox6.Invoke(new Action(() =>
                {
                    guna2CheckBox6.Enabled = true;
                }));
            }

            Console.WriteLine(6);
            if (CheckRegistry(disableexecuting, "DisablePagingExecutive", "1") == true)
            {
                guna2CheckBox7.Invoke(new Action(() =>
                {
                    guna2CheckBox7.Enabled = false;
                }));
            }
            else
            {
                CanOptimisated++;
                guna2CheckBox7.Invoke(new Action(() =>
                {
                    guna2CheckBox7.Enabled = true;
                }));
            }

            Console.WriteLine(7);
            if (CheckRegistry(enablesmartscreen, "EnableSmartScreen", "0") == true)
            {
                guna2CheckBox8.Invoke(new Action(() =>
                {
                    guna2CheckBox8.Enabled = false;
                }));
            }
            else
            {
                CanOptimisated++;
                guna2CheckBox8.Invoke(new Action(() =>
                {
                    guna2CheckBox8.Enabled = true;
                }));
            }

            Console.WriteLine(8);

            label9.Invoke(new Action(() =>
            {
                label9.Text = CanOptimisated + " Пунктов";
            }));

        }

        bool CheckRegistry(string path, string nameValue, string value)
        {
            var path1 = Registry.LocalMachine.OpenSubKey(path);

            if (path1.GetValue(nameValue).ToString() == value)
            {
                path1.Close();
                return true;
            }
            else
            {
                path1.Close();
                return false;
            }
        }

启动worker的方法:

 private void Form1_Load(object sender, EventArgs e)
        {
            guna2GradientCircleButton2.PerformClick();
            RegistryChecker.RunWorkerAsync();
        }
c#
  • 1 个回答
  • 10 Views
Martin Hope
mounten1
Asked: 2021-10-22 22:05:33 +0000 UTC

bat 文件无法正常工作。C#

  • 1

有一个 bat 文件可以更改LocalMachine. 我使用它是因为您Registry.LocalMachine不能在其中删除或创建部分。

bat文件代码:

reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RemoteComputer\NameSpace\{863aa9fd-42df-457b-8e4d-0de1b8015c60}" /f

并且有一个运行它的代码。但是有一个问题,当应用程序执行一个bat文件时,它会写:找不到注册表中指定的节或参数。如果 bat 文件是手动运行的,那么一切正常。该怎么办?

bat文件启动代码:

        System.Diagnostics.Process proc = new System.Diagnostics.Process();
        proc.StartInfo.FileName = "cmd.exe";
        proc.StartInfo.Arguments = "/k cd " + Application.StartupPath + "/Bin & -searchprinters.bat";
        proc.StartInfo.WorkingDirectory = @"C:\Programs";
        proc.Start();

问题的屏幕截图(在没有权限的情况下启动,但它有效):

执行bat文件

c#
  • 2 个回答
  • 10 Views
Martin Hope
mounten1
Asked: 2020-10-04 22:27:06 +0000 UTC

在列表框中显示 Windows 服务。C#

  • 0

如何显示windows服务单独列表?

试图这样做:

ServiceController[] scServices;
scServices = ServiceController.GetServices();
listbox1.Items.AddRange(scServices)

但是什么也没发生。

c#
  • 2 个回答
  • 10 Views
Martin Hope
mounten1
Asked: 2020-06-11 19:11:43 +0000 UTC

按钮样式。WPF

  • 0

我最近开始学习 WPF。我遇到了一个问题,当你指向按钮时,它会变成蓝色。我搜索了互联网并找到了解决问题的方法。我在按钮上做了一个样式。但问题是,按钮上的样式没有应用。PS 按钮内的元素具有透明背景。

风格:

 <Style x:Key = "TriggerStyle" TargetType = "Button">
     <Setter Property = "Foreground" Value = "Blue" />
     <Style.Triggers>
        <Trigger Property = "IsMouseOver" Value = "True">
            <Setter Property = "Foreground" Value = "Green" />
        </Trigger>
     </Style.Triggers>
 </Style>

按钮:

<DockPanel HorizontalAlignment="Left" Width="200" 
        ScrollViewer.VerticalScrollBarVisibility="Disabled" Background="#FF141414">
    <Button Content="Main" Height="45" VerticalAlignment="Top" Width="200" DockPanel.Dock="Top" 
        Style="{StaticResource ButtonSubMenu}" FontSize="22"/>
    <StackPanel Height="114" VerticalAlignment="Top" Width="200" Background="#FF232323">
        <Button Style="{StaticResource TriggerStyle}" Height="30" Background="#FF2D2D2D" 
            Foreground="White" HorizontalAlignment="Left" Width="200" VerticalAlignment="Center">
            <StackPanel  Orientation="Horizontal" Width="181" Height="30">
                <fa:ImageAwesome Icon="Terminal" Foreground="White" HorizontalAlignment="Right" 
              Width="26" StretchDirection="DownOnly" Height="22" Margin="0,4"/>
                <TextBlock Text="Console" FontSize="18" Margin="10,0,0,0" 
              HorizontalAlignment="Left"/>
            </StackPanel>
        </Button>
    </StackPanel>
</DockPanel>
wpf
  • 1 个回答
  • 10 Views
Martin Hope
mounten1
Asked: 2020-05-31 15:58:58 +0000 UTC

高度限制为 788 像素。视觉工作室

  • 0

我似乎无法在 Visual Studio 2019 社区中为表单设置大于 788 像素的高度。如果您尝试设置超过此值,它会重置为 788 像素。该怎么办?

visual-studio
  • 1 个回答
  • 10 Views
Martin Hope
mounten1
Asked: 2020-05-26 04:00:05 +0000 UTC

圆形 PictureBox 边缘

  • 0

请告诉我如何制作带有圆边 PictureBox 的课程。我正在使用 Winforms。

c#
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5