CommonRotateControl.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using PaintDotNet.Base.SettingModel;
  11. using PaintDotNet.Camera;
  12. namespace PaintDotNet.ImageCollect
  13. {
  14. public partial class CommonRotateControl : UserControl
  15. {
  16. private ICamera m_camera => CameraManager.CurrentCamera;
  17. private CameraParamModel.ParameterSets _settings => CameraConfigs.Settings;
  18. private void InitializeLanguageText()
  19. {
  20. this.groupBox1.Text = PdnResources.GetString("Menu.Imagerotation.text");
  21. this.ckbHorizontal.Text = PdnResources.GetString("Menu.Imagerotation.Horizontal.text");
  22. this.ckbVertical.Text = PdnResources.GetString("Menu.Imagerotation.Vertical.text");
  23. var rotateArray = new string[] { PdnResources.GetString("Menu.original.text"), PdnResources.GetString("Menu.Edit.Rotate90CW.Text"), PdnResources.GetString("Menu.Rotate270degrees.Text") };
  24. imgRotateComboBox.Items.Clear();
  25. this.imgRotateComboBox.Items.AddRange(rotateArray);
  26. }
  27. public CommonRotateControl()
  28. {
  29. InitializeComponent();
  30. }
  31. public void Initialize()
  32. {
  33. InitializeLanguageText();
  34. imgRotateComboBox.MouseWheel += (s, e) => (e as HandledMouseEventArgs).Handled = true;
  35. imgRotateComboBox.SelectedIndex = _settings.Rotate;
  36. ckbHorizontal.Checked = _settings.Horizontal == 1;
  37. ckbVertical.Checked = _settings.Vertical == 1;
  38. }
  39. private void imgRotateComboBox_SelectedIndexChanged(object sender, EventArgs e)
  40. {
  41. try
  42. {
  43. m_camera.Rotate = imgRotateComboBox.SelectedIndex;
  44. _settings.Rotate = imgRotateComboBox.SelectedIndex;
  45. }
  46. catch (Exception ex)
  47. {
  48. imgRotateComboBox.SelectedIndex = _settings.Rotate;
  49. MessageBox.Show("本相机不支持该操作。");
  50. }
  51. }
  52. private void ckbHorizontal_Click(object sender, EventArgs e)
  53. {
  54. m_camera.HorizontalMirrored = ckbHorizontal.Checked;
  55. m_camera.VerticalMirrored = ckbVertical.Checked;
  56. _settings.Horizontal = ckbHorizontal.Checked ? 1 : 0;
  57. _settings.Vertical = ckbVertical.Checked ? 1 : 0;
  58. }
  59. }
  60. }