GrayModeControl.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using PaintDotNet.Camera;
  2. using PaintDotNet.ImageCollect;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows.Forms;
  9. namespace PaintDotNet.Preview2
  10. {
  11. public class GrayModeControl : UserControl
  12. {
  13. private RadioButton radioButton2;
  14. private RadioButton radioButton1;
  15. private GroupBox groupBox1;
  16. public GrayModeControl()
  17. {
  18. InitializeComponent();
  19. InitializeLanguageText();
  20. }
  21. private void InitializeComponent()
  22. {
  23. this.groupBox1 = new System.Windows.Forms.GroupBox();
  24. this.radioButton2 = new System.Windows.Forms.RadioButton();
  25. this.radioButton1 = new System.Windows.Forms.RadioButton();
  26. this.groupBox1.SuspendLayout();
  27. this.SuspendLayout();
  28. //
  29. // groupBox1
  30. //
  31. this.groupBox1.Controls.Add(this.radioButton2);
  32. this.groupBox1.Controls.Add(this.radioButton1);
  33. this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
  34. this.groupBox1.Location = new System.Drawing.Point(0, 8);
  35. this.groupBox1.Name = "groupBox1";
  36. this.groupBox1.Padding = new System.Windows.Forms.Padding(4);
  37. this.groupBox1.Size = new System.Drawing.Size(262, 47);
  38. this.groupBox1.TabIndex = 0;
  39. this.groupBox1.TabStop = false;
  40. this.groupBox1.Text = "黑白/彩色";
  41. //
  42. // radioButton2
  43. //
  44. this.radioButton2.AutoSize = true;
  45. this.radioButton2.BackColor = System.Drawing.Color.Transparent;
  46. this.radioButton2.Location = new System.Drawing.Point(121, 21);
  47. this.radioButton2.Name = "radioButton2";
  48. this.radioButton2.Size = new System.Drawing.Size(71, 16);
  49. this.radioButton2.TabIndex = 1;
  50. this.radioButton2.TabStop = true;
  51. this.radioButton2.Text = "彩色图像";
  52. this.radioButton2.UseVisualStyleBackColor = false;
  53. this.radioButton2.Click += new System.EventHandler(this.radioButton2_Click);
  54. //
  55. // radioButton1
  56. //
  57. this.radioButton1.AutoSize = true;
  58. this.radioButton1.BackColor = System.Drawing.Color.Transparent;
  59. this.radioButton1.Location = new System.Drawing.Point(7, 21);
  60. this.radioButton1.Name = "radioButton1";
  61. this.radioButton1.Size = new System.Drawing.Size(71, 16);
  62. this.radioButton1.TabIndex = 0;
  63. this.radioButton1.TabStop = true;
  64. this.radioButton1.Text = "黑白图像";
  65. this.radioButton1.UseVisualStyleBackColor = false;
  66. this.radioButton1.Click += new System.EventHandler(this.radioButton1_Click);
  67. //
  68. // GrayModeControl
  69. //
  70. this.Controls.Add(this.groupBox1);
  71. this.Name = "GrayModeControl";
  72. this.Padding = new System.Windows.Forms.Padding(0, 8, 0, 0);
  73. this.Size = new System.Drawing.Size(262, 55);
  74. this.groupBox1.ResumeLayout(false);
  75. this.groupBox1.PerformLayout();
  76. this.ResumeLayout(false);
  77. }
  78. private void InitializeLanguageText()
  79. {
  80. this.groupBox1.Text = PdnResources.GetString("ColorDisplayWidget.BlackAndWhiteIconBox.ToolTipText") + "/" + PdnResources.GetString("Preview2Setting.colour");
  81. this.radioButton2.Text = PdnResources.GetString("Preview2Setting.colour") +" " + PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.image.text");
  82. this.radioButton1.Text = PdnResources.GetString("ColorDisplayWidget.BlackAndWhiteIconBox.ToolTipText") + " " + PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.image.text");
  83. }
  84. public void Initialize()
  85. {
  86. radioButton1.Checked = CameraConfigs.Settings.Monochromatic == 1;
  87. radioButton2.Checked = CameraConfigs.Settings.Monochromatic == 0;
  88. }
  89. private void radioButton1_Click(object sender, EventArgs e)
  90. {
  91. CameraManager.CurrentCamera.GrayMode = 1;
  92. CameraConfigs.Settings.Monochromatic = 1;
  93. }
  94. private void radioButton2_Click(object sender, EventArgs e)
  95. {
  96. CameraManager.CurrentCamera.GrayMode = 0;
  97. CameraConfigs.Settings.Monochromatic = 0;
  98. }
  99. }
  100. }