using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using PaintDotNet.Base.SettingModel; using PaintDotNet.Camera; using PaintDotNet.ImageCollect; namespace PaintDotNet.Preview2 { public partial class RotateControl : UserControl { public Action OnRotated; private ICamera m_camera => CameraManager.CurrentCamera; private CameraParamModel.ParameterSets _settings { get { return CameraConfigs.Settings; } } private void InitializeLanguageText() { this.groupBox1.Text = PdnResources.GetString("Menu.Imagerotation.text"); this.ckbHorizontal.Text = PdnResources.GetString("Menu.Imagerotation.Horizontal.text"); this.ckbVertical.Text = PdnResources.GetString("Menu.Imagerotation.Vertical.text"); var rotateArray = new string[] { PdnResources.GetString("Menu.original.text"), PdnResources.GetString("Menu.Edit.Rotate90CW.Text")/*, PdnResources.GetString("Menu.Edit.Rotate180.Text")*/, PdnResources.GetString("Menu.Rotate270degrees.Text") }; imgRotateComboBox.Items.Clear(); this.imgRotateComboBox.Items.AddRange(rotateArray); } public RotateControl() { InitializeComponent(); imgRotateComboBox.MouseWheel += ImgRotateComboBox_MouseWheel; } public void Initialize() { InitializeLanguageText(); UpdateDisplay(); } private void ImgRotateComboBox_MouseWheel(object sender, MouseEventArgs e) { var handle = e as HandledMouseEventArgs; handle.Handled = true; } private void imgRotateComboBox_SelectedIndexChanged(object sender, EventArgs e) { if (_settings.Rotate == imgRotateComboBox.SelectedIndex) return; try { m_camera.Rotate = imgRotateComboBox.SelectedIndex; _settings.Rotate = imgRotateComboBox.SelectedIndex; } catch { MessageBox.Show("该相机不支持该操作。"); imgRotateComboBox.SelectedIndex = _settings.Rotate; } OnRotated?.Invoke(); } private void ckbVertical_Click(object sender, EventArgs e) { _settings.Vertical = ckbVertical.Checked ? 1 : 0; m_camera.VerticalMirrored = ckbVertical.Checked; OnRotated?.Invoke(); } private void ckbHorizontal_Click(object sender, EventArgs e) { _settings.Horizontal = ckbHorizontal.Checked ? 1 : 0; m_camera.HorizontalMirrored = ckbHorizontal.Checked; OnRotated?.Invoke(); } public void UpdateDisplay() { imgRotateComboBox.SelectedIndex = _settings.Rotate==3?2: _settings.Rotate; ckbHorizontal.Checked = _settings.Horizontal > 0; ckbVertical.Checked = _settings.Vertical > 0; } } }