using PaintDotNet.Annotation; using PaintDotNet.Annotation.Enum; using PaintDotNet.Annotation.FieldView; using PaintDotNet.DbOpreate.DbBll; using PaintDotNet.DbOpreate.DbModel; using System; using System.Drawing; using System.Windows.Forms; namespace PaintDotNet.FieldView { /// /// 修改视场 /// internal class ChangeViewDialog : FloatingToolForm//PdnBaseForm { #region 控件 private GroupBox groupBox2; private Label label1; private GroupBox groupBox3; private GroupBox groupBox4; private GroupBox groupBox5; private GroupBox groupBox6; private Label label2; private Label label3; private Label label4; private Label label5; private Label label6; private Label label7; private Label label8; private NumericUpDown nudActualHeightR; private NumericUpDown nudActualWidthR; private NumericUpDown nudCenterX; private NumericUpDown nudCenterY; private NumericUpDown nudActualHeightC; private NumericUpDown nudActualWidthC; private RadioButton rbtHeight; private RadioButton rbtWidth; private Label lblPixelWidth; private Label lblPixelHeight; #endregion /// /// 主工作控件 /// private AppWorkspace appWorkspace; /// /// 当前选中的视场 /// private DrawObject selectedObject; /// /// 旧中心点X坐标值 /// private int numericUpDown3Old; /// /// 旧中心点Y坐标值 /// private int numericUpDown4Old; /// /// 初始化标记 /// 1、用于第一次打开窗口时 /// 2、用于切换视场事件被触发时 /// private bool init = true; /// /// 单位 /// private string unit = ""; /// /// 放大倍数 /// private decimal m_scale = 1; public ChangeViewDialog(AppWorkspace appWorkspace) { this.appWorkspace = appWorkspace; this.unit = PdnResources.GetString("Menu.Micron.text"); /*if (Startup.instance.configModel.RulerId > 0) { this.unit = appWorkspace.GetPxPerUnit()[1]; } else { this.unit = PdnResources.GetString("Menu.Micron.text"); }*/ InitializeComponent(); InitializeLanguageText(); InitializeUnitText(); //this.appWorkspace.ActiveDocumentWorkspaceChanged this.selectedObject = this.appWorkspace.ActiveDocumentWorkspace.GraphicsList.SelectDrawObject; this.appWorkspace.ActiveDocumentWorkspace.GraphicsList.SelectChanged += this.graphicsList_SelectChanged; InitControl(); InitEvent(); } /// /// 初始化控件及其值 /// private void InitControl() { if (init && selectedObject != null) { m_scale = 1; if (this.appWorkspace.ActiveDocumentWorkspace.xmlSaveModel != null) { this.label2.Text = PdnResources.GetString("Menu.LabelAction.DrawGainNumber.Text") + ":" + this.appWorkspace.ActiveDocumentWorkspace.xmlSaveModel.gain_multiple; m_scale = this.appWorkspace.ActiveDocumentWorkspace.xmlSaveModel.gain_multiple; //mic_rulers rules = mic_rulers_BLL.FindDefault(Startup.instance.configModel.RulerId); //if (rules != null) //{ //this.label2.Text = PdnResources.GetString("Menu.LabelAction.DrawGainNumber.Text") + ":" + rules.gain_multiple; //} } else { this.label2.Text = PdnResources.GetString("Menu.ationrulcurrentlydefaultvalueis.Text"); } //this.unit = appWorkspace.GetPxPerUnit()[1]; InitializeUnitText(); DrawToolType type = selectedObject.drawToolType; this.rbtHeight.Checked = false; this.rbtWidth.Checked = false; this.nudActualHeightC.Enabled = false; this.nudActualWidthC.Enabled = false; switch (type) { case DrawToolType.ViewOval: hideCricleOrSquare(); this.label1.Text = PdnResources.GetString("Menu.ViewSetting.OvalView.Text"); this.label3.Text = PdnResources.GetString("Menu.verticalaxis.Text") + "(" + this.unit + ")"; this.label4.Text = PdnResources.GetString("Menu.horizontalaxis.Text") + "(" + this.unit + ")"; this.nudActualHeightR.Value = Convert.ToDecimal(selectedObject.Height * double.Parse(appWorkspace.GetPxPerUnit()[4])); this.nudActualWidthR.Value = Convert.ToDecimal(selectedObject.Width * double.Parse(appWorkspace.GetPxPerUnit()[4])); this.lblPixelHeight.Text = ScalePxPerUnit(selectedObject.Height).ToString("F2"); this.lblPixelWidth.Text = ScalePxPerUnit(selectedObject.Width).ToString("F2"); break; case DrawToolType.ViewCircle: showCricleOrSquare(); this.label1.Text = PdnResources.GetString("Menu.ViewSetting.RoundView.Text"); this.rbtHeight.Visible = true; this.rbtWidth.Visible = true; this.nudActualHeightC.Visible = true; this.nudActualWidthC.Visible = true; if (this.rbtHeight.Checked) this.nudActualHeightC.Enabled = true; if (this.rbtWidth.Checked) this.nudActualWidthC.Enabled = true; this.rbtHeight.Text = PdnResources.GetString("Menu.diameter.text") + "(" + this.unit + ")"; var width = Convert.ToDecimal(selectedObject.Rectangle.Width * double.Parse(appWorkspace.GetPxPerUnit()[4])); this.nudActualHeightC.Value = width; this.nudActualWidthC.Value = Math.Round((decimal)Math.PI * width * width / 4, 2); this.lblPixelHeight.Text = ScalePxPerUnit(selectedObject.Rectangle.Width).ToString("F2"); this.lblPixelWidth.Text = ScalePxPerUnit(selectedObject.Rectangle.Width).ToString("F2"); break; case DrawToolType.ViewRectangleEx: hideCricleOrSquare(); this.nudActualHeightR.Enabled = false; this.nudActualWidthR.Enabled = false; this.label1.Text = PdnResources.GetString("Menu.ViewSetting.RectangleExView.Text"); this.nudActualHeightR.Value = Convert.ToDecimal(selectedObject.Rectangle.Height * double.Parse(appWorkspace.GetPxPerUnit()[4])); this.nudActualWidthR.Value = Convert.ToDecimal(selectedObject.Rectangle.Width * double.Parse(appWorkspace.GetPxPerUnit()[4])); this.lblPixelHeight.Text = ScalePxPerUnit(selectedObject.Rectangle.Width).ToString("F2"); this.lblPixelWidth.Text = ScalePxPerUnit(selectedObject.Rectangle.Height).ToString("F2"); break; case DrawToolType.ViewRectangle: hideCricleOrSquare(); this.label1.Text = PdnResources.GetString("Menu.ViewSetting.RectangleView.Text"); this.nudActualHeightR.Value = Convert.ToDecimal(selectedObject.Height * double.Parse(appWorkspace.GetPxPerUnit()[4])); this.nudActualWidthR.Value = Convert.ToDecimal(selectedObject.Width * double.Parse(appWorkspace.GetPxPerUnit()[4])); this.lblPixelHeight.Text = ScalePxPerUnit(selectedObject.Height).ToString("F2"); this.lblPixelWidth.Text = ScalePxPerUnit(selectedObject.Width).ToString("F2"); break; case DrawToolType.ViewTriangle: hideCricleOrSquare(); this.label1.Text = PdnResources.GetString("Menu.ViewSetting.TriangleView.Text"); this.label3.Text = PdnResources.GetString("Menu.Verticalsidelength.Text") + "(" + this.unit + ")"; this.label4.Text = PdnResources.GetString("Menu.Horizontalsidelength.Text") + "(" + this.unit + ")"; this.nudActualHeightR.Value = Convert.ToDecimal(selectedObject.Height * double.Parse(appWorkspace.GetPxPerUnit()[4])); this.nudActualWidthR.Value = Convert.ToDecimal(selectedObject.Width * double.Parse(appWorkspace.GetPxPerUnit()[4])); this.lblPixelHeight.Text = ScalePxPerUnit(selectedObject.Height).ToString("F2"); this.lblPixelWidth.Text = ScalePxPerUnit(selectedObject.Width).ToString("F2"); break; case DrawToolType.ViewSquare: showCricleOrSquare(); this.label1.Text = PdnResources.GetString("Menu.ViewSetting.SquareView.Text"); this.rbtHeight.Visible = true; this.rbtWidth.Visible = true; this.nudActualHeightC.Visible = true; this.nudActualWidthC.Visible = true; if (this.rbtHeight.Checked) this.nudActualHeightC.Enabled = true; if (this.rbtWidth.Checked) this.nudActualWidthC.Enabled = true; this.rbtHeight.Text = PdnResources.GetString("Menu.Generalanalysis.Processmparison.Sidelength.text") + "(" + this.unit + ")"; this.nudActualHeightC.Value = Convert.ToDecimal(selectedObject.Rectangle.Width * double.Parse(appWorkspace.GetPxPerUnit()[4])); this.nudActualWidthC.Value = Math.Round(Convert.ToDecimal(selectedObject.Rectangle.Height * selectedObject.Rectangle.Height * double.Parse(appWorkspace.GetPxPerUnit()[4]) * double.Parse(appWorkspace.GetPxPerUnit()[4])), 2); this.lblPixelHeight.Text = ScalePxPerUnit(selectedObject.Rectangle.Height).ToString("F2"); this.lblPixelWidth.Text = ScalePxPerUnit(selectedObject.Rectangle.Width).ToString("F2"); break; case DrawToolType.ViewPolygon: hideCricleOrSquare(); this.label1.Text = PdnResources.GetString("Menu.ViewSetting.PolygonView.Text"); this.nudActualHeightR.Enabled = false; this.nudActualWidthR.Enabled = false; this.lblPixelHeight.Text = ""; this.lblPixelWidth.Text = ""; break; case DrawToolType.ViewTriangleEx: hideCricleOrSquare(); this.label1.Text = PdnResources.GetString("Menu.ViewSetting.TriangleExView.Text"); this.nudActualHeightR.Enabled = false; this.nudActualWidthR.Enabled = false; this.lblPixelHeight.Text = ""; this.lblPixelWidth.Text = ""; break; } this.nudCenterX.ValueChanged -= this.numericUpDown3_ValueChange; this.nudCenterY.ValueChanged -= this.numericUpDown4_ValueChange; int centerX = (int)(selectedObject.Rectangle.X + Math.Abs(selectedObject.Rectangle.Width / 2)); int centerY = (int)(selectedObject.Rectangle.Y + Math.Abs(selectedObject.Rectangle.Height / 2)); this.nudCenterX.Value = Math.Abs(centerX); this.nudCenterY.Value = Math.Abs(centerY); this.numericUpDown3Old = Math.Abs(centerX); this.numericUpDown4Old = Math.Abs(centerY); //this.numericUpDown3.ValueChanged += this.numericUpDown3_ValueChange); //this.numericUpDown4.ValueChanged += this.numericUpDown4_ValueChange); init = false; } } private double ScalePxPerUnit(double value) { return Math.Round(this.appWorkspace.ActiveDocumentWorkspace.ScaleFactor.Ratio * value * double.Parse(appWorkspace.GetPxPerUnit()[4]) * double.Parse(m_scale.ToString()), 10); } private void showCricleOrSquare() { this.rbtHeight.Visible = true; this.rbtWidth.Visible = true; this.nudActualHeightC.Visible = true; this.nudActualWidthC.Visible = true; this.nudActualHeightR.Visible = false; this.nudActualWidthR.Visible = false; } private void hideCricleOrSquare() { this.rbtHeight.Visible = false; this.rbtWidth.Visible = false; this.nudActualHeightC.Visible = false; this.nudActualWidthC.Visible = false; this.nudActualHeightR.Visible = true; this.nudActualWidthR.Visible = true; } private void disabledControl() { this.nudActualHeightR.Enabled = false; this.nudActualWidthR.Enabled = false; this.nudCenterX.Enabled = false; this.nudCenterY.Enabled = false; this.nudActualHeightC.Enabled = false; this.nudActualWidthC.Enabled = false; this.rbtHeight.Enabled = false; this.rbtWidth.Enabled = false; } private void enabledControl(DrawToolType drawToolType) { //如果是多边形或者任意三角形,没有边长什么的,所以不允许编辑 if (drawToolType != DrawToolType.ViewPolygon && drawToolType != DrawToolType.ViewTriangleEx) { this.nudActualHeightR.Enabled = true; this.nudActualWidthR.Enabled = true; } this.nudCenterX.Enabled = true; this.nudCenterY.Enabled = true; this.nudActualHeightC.Enabled = true; this.nudActualWidthC.Enabled = true; this.rbtHeight.Enabled = true; this.rbtWidth.Enabled = true; } /// /// 初始化事件 /// private void InitEvent() { this.selectedObject.PropertyChanged += this.selectedObject_PropertyChanged; this.nudActualHeightR.ValueChanged += this.numericUpDown1_ValueChange; this.nudActualWidthR.ValueChanged += this.numericUpDown2_ValueChange; this.nudCenterX.ValueChanged += this.numericUpDown3_ValueChange; this.nudCenterY.ValueChanged += this.numericUpDown4_ValueChange; this.nudActualHeightC.ValueChanged += this.numericUpDown5_ValueChange; this.nudActualWidthC.ValueChanged += this.numericUpDown6_ValueChange; this.nudCenterX.KeyUp += new KeyEventHandler(this.numericUpDown3_ValueChange); this.nudCenterY.KeyUp += new KeyEventHandler(this.numericUpDown4_ValueChange); } /// /// 注销事件 /// private void UnInitEvent() { this.selectedObject.PropertyChanged -= this.selectedObject_PropertyChanged; this.nudActualHeightR.ValueChanged -= this.numericUpDown1_ValueChange; this.nudActualWidthR.ValueChanged -= this.numericUpDown2_ValueChange; this.nudCenterX.ValueChanged -= this.numericUpDown3_ValueChange; this.nudCenterY.ValueChanged -= this.numericUpDown4_ValueChange; this.nudActualHeightC.ValueChanged -= this.numericUpDown5_ValueChange; this.nudActualWidthC.ValueChanged -= this.numericUpDown6_ValueChange; this.nudCenterX.KeyUp -= new KeyEventHandler(this.numericUpDown3_ValueChange); this.nudCenterY.KeyUp -= new KeyEventHandler(this.numericUpDown4_ValueChange); } /// /// 视场对象改变事件 /// /// /// private void graphicsList_SelectChanged(object sender, EventArgs e) { this.selectedObject = this.appWorkspace.ActiveDocumentWorkspace.GraphicsList.SelectDrawObject; if (selectedObject != null) { DrawClass drawClass = selectedObject.objectType; if (drawClass == DrawClass.View) { enabledControl(selectedObject.drawToolType); init = true; UnInitEvent(); InitControl(); InitEvent(); } else { disabledControl(); } } else { disabledControl(); } } /// /// 选中的视场的属性改变事件 /// /// /// private void selectedObject_PropertyChanged(object sender, EventArgs e) { //UnInitEvent(); InitControl(); //InitEvent(); } /// /// 椭圆:垂直轴 /// 矩形:高度 /// 三角形:垂直边长 /// 多边形:不可调整 /// /// /// private void numericUpDown1_ValueChange(object sender, EventArgs e) { if (this.selectedObject != null && !this.appWorkspace.ActiveDocumentWorkspace.mouseStatus) { this.nudActualWidthR.ValueChanged -= this.numericUpDown2_ValueChange; this.nudCenterX.ValueChanged -= this.numericUpDown3_ValueChange; this.nudCenterY.ValueChanged -= this.numericUpDown4_ValueChange; DrawToolType type = selectedObject.drawToolType; switch (type) { case DrawToolType.ViewOval: selectedObject.Height = (float)(this.nudActualHeightR.Value / decimal.Parse(appWorkspace.GetPxPerUnit()[4])); this.lblPixelHeight.Text = "" + Math.Round(this.appWorkspace.ActiveDocumentWorkspace.ScaleFactor.Ratio * selectedObject.Height * double.Parse(appWorkspace.GetPxPerUnit()[4]) * double.Parse(m_scale.ToString()), 2); this.lblPixelWidth.Text = "" + Math.Round(this.appWorkspace.ActiveDocumentWorkspace.ScaleFactor.Ratio * selectedObject.Width * double.Parse(appWorkspace.GetPxPerUnit()[4]) * double.Parse(m_scale.ToString()), 2); break; case DrawToolType.ViewRectangle: selectedObject.Height = (float)(this.nudActualHeightR.Value / decimal.Parse(appWorkspace.GetPxPerUnit()[4])); this.lblPixelHeight.Text = "" + Math.Round(this.appWorkspace.ActiveDocumentWorkspace.ScaleFactor.Ratio * selectedObject.Rectangle.Height * double.Parse(appWorkspace.GetPxPerUnit()[4]) * double.Parse(m_scale.ToString()), 2); this.lblPixelWidth.Text = "" + Math.Round(this.appWorkspace.ActiveDocumentWorkspace.ScaleFactor.Ratio * selectedObject.Rectangle.Width * double.Parse(appWorkspace.GetPxPerUnit()[4]) * double.Parse(m_scale.ToString()), 2); break; case DrawToolType.ViewTriangle: selectedObject.Height = double.Parse(this.nudActualHeightR.Value.ToString()) / double.Parse(appWorkspace.GetPxPerUnit()[4]); this.lblPixelHeight.Text = "" + Math.Round(this.appWorkspace.ActiveDocumentWorkspace.ScaleFactor.Ratio * selectedObject.Height * double.Parse(appWorkspace.GetPxPerUnit()[4]) * double.Parse(m_scale.ToString()), 2); this.lblPixelWidth.Text = "" + Math.Round(this.appWorkspace.ActiveDocumentWorkspace.ScaleFactor.Ratio * selectedObject.Width * double.Parse(appWorkspace.GetPxPerUnit()[4]) * double.Parse(m_scale.ToString()), 2); break; } this.selectedObject.Normalize(); this.appWorkspace.ActiveDocumentWorkspace.Refresh(); int centerX = (int)(selectedObject.Rectangle.X + Math.Abs(selectedObject.Rectangle.Width / 2)); int centerY = (int)(selectedObject.Rectangle.Y + Math.Abs(selectedObject.Rectangle.Height / 2)); this.nudCenterX.Value = Math.Abs(centerX); this.nudCenterY.Value = Math.Abs(centerY); this.numericUpDown3Old = Math.Abs(centerX); this.numericUpDown4Old = Math.Abs(centerY); this.nudActualWidthR.ValueChanged += this.numericUpDown2_ValueChange; this.nudCenterX.ValueChanged += this.numericUpDown3_ValueChange; this.nudCenterY.ValueChanged += this.numericUpDown4_ValueChange; } } /// /// 椭圆:水平轴 /// 矩形:宽度 /// 三角形:水平边长 /// 多边形:不可调整 /// /// /// private void numericUpDown2_ValueChange(object sender, EventArgs e) { var value = (sender as NumericUpDown).Value; if (this.selectedObject != null && !this.appWorkspace.ActiveDocumentWorkspace.mouseStatus) { this.nudActualHeightR.ValueChanged -= this.numericUpDown1_ValueChange; this.nudCenterX.ValueChanged -= this.numericUpDown3_ValueChange; this.nudCenterY.ValueChanged -= this.numericUpDown4_ValueChange; DrawToolType type = selectedObject.drawToolType; switch (type) { case DrawToolType.ViewOval: selectedObject.Width = (float)(value / decimal.Parse(appWorkspace.GetPxPerUnit()[4])); this.lblPixelHeight.Text = "" + Math.Round(this.appWorkspace.ActiveDocumentWorkspace.ScaleFactor.Ratio * selectedObject.Height * double.Parse(appWorkspace.GetPxPerUnit()[4]) * double.Parse(m_scale.ToString()), 2); this.lblPixelWidth.Text = "" + Math.Round(this.appWorkspace.ActiveDocumentWorkspace.ScaleFactor.Ratio * selectedObject.Width * double.Parse(appWorkspace.GetPxPerUnit()[4]) * double.Parse(m_scale.ToString()), 2); break; case DrawToolType.ViewRectangle: selectedObject.Width = (float)(double.Parse(this.nudActualWidthR.Value.ToString()) / double.Parse(appWorkspace.GetPxPerUnit()[4])); this.lblPixelHeight.Text = "" + Math.Round(this.appWorkspace.ActiveDocumentWorkspace.ScaleFactor.Ratio * selectedObject.Rectangle.Height * double.Parse(appWorkspace.GetPxPerUnit()[4]) * double.Parse(m_scale.ToString()), 2); this.lblPixelWidth.Text = "" + Math.Round(this.appWorkspace.ActiveDocumentWorkspace.ScaleFactor.Ratio * selectedObject.Rectangle.Width * double.Parse(appWorkspace.GetPxPerUnit()[4]) * double.Parse(m_scale.ToString()), 2); break; case DrawToolType.ViewTriangle: selectedObject.Width = double.Parse(this.nudActualWidthR.Value.ToString()) / double.Parse(appWorkspace.GetPxPerUnit()[4]); this.lblPixelHeight.Text = "" + Math.Round(this.appWorkspace.ActiveDocumentWorkspace.ScaleFactor.Ratio * selectedObject.Height * double.Parse(appWorkspace.GetPxPerUnit()[4]) * double.Parse(m_scale.ToString()), 2); this.lblPixelWidth.Text = "" + Math.Round(this.appWorkspace.ActiveDocumentWorkspace.ScaleFactor.Ratio * selectedObject.Width * double.Parse(appWorkspace.GetPxPerUnit()[4]) * double.Parse(m_scale.ToString()), 2); break; } this.selectedObject.Normalize(); this.appWorkspace.ActiveDocumentWorkspace.Refresh(); int centerX = (int)(selectedObject.Rectangle.X + Math.Abs(selectedObject.Rectangle.Width / 2)); int centerY = (int)(selectedObject.Rectangle.Y + Math.Abs(selectedObject.Rectangle.Height / 2)); this.nudCenterX.Value = Math.Abs(centerX); this.nudCenterY.Value = Math.Abs(centerY); this.numericUpDown3Old = Math.Abs(centerX); this.numericUpDown4Old = Math.Abs(centerY); this.nudActualHeightR.ValueChanged += this.numericUpDown1_ValueChange; this.nudCenterX.ValueChanged += this.numericUpDown3_ValueChange; this.nudCenterY.ValueChanged += this.numericUpDown4_ValueChange; } } /// /// 修改中心点x坐标的事件 /// /// /// private void numericUpDown3_ValueChange(object sender, EventArgs e) { if (this.selectedObject != null && !this.appWorkspace.ActiveDocumentWorkspace.mouseStatus) { if (this.numericUpDown3Old != (int)this.nudCenterX.Value) { int deltaX = (int)this.nudCenterX.Value - this.numericUpDown3Old; this.selectedObject.Move(deltaX, 0); /** Rectangle rectangle = this.selectedObject.Rectangle; rectangle.X = (int)this.numericUpDown3.Value; this.selectedObject.Rectangle = rectangle; **/ this.selectedObject.Normalize(); this.appWorkspace.ActiveDocumentWorkspace.Refresh(); this.numericUpDown3Old = (int)this.nudCenterX.Value; } } } /// /// 修改中心点y坐标的事件 /// /// /// private void numericUpDown4_ValueChange(object sender, EventArgs e) { if (this.selectedObject != null && !this.appWorkspace.ActiveDocumentWorkspace.mouseStatus) { if (this.numericUpDown4Old != (int)this.nudCenterY.Value) { int deltaY = (int)this.nudCenterY.Value - this.numericUpDown4Old; this.selectedObject.Move(0, deltaY); /** Rectangle rectangle = this.selectedObject.Rectangle; rectangle.Y = (int)this.numericUpDown4.Value; this.selectedObject.Rectangle = rectangle; **/ this.selectedObject.Normalize(); this.appWorkspace.ActiveDocumentWorkspace.Refresh(); this.numericUpDown4Old = (int)this.nudCenterY.Value; } } } /// /// 圆形:直径 /// 正方形:边长 /// /// /// private void numericUpDown5_ValueChange(object sender, EventArgs e) { if (!rbtHeight.Checked) return; if (this.selectedObject == null || this.appWorkspace.ActiveDocumentWorkspace.mouseStatus) return; this.nudCenterX.ValueChanged -= this.numericUpDown3_ValueChange; this.nudCenterY.ValueChanged -= this.numericUpDown4_ValueChange; DrawToolType type = selectedObject.drawToolType; switch (type) { case DrawToolType.ViewCircle: if (!this.rbtHeight.Checked) break; var circle = selectedObject as ViewCircle; float radius = (float)(nudActualHeightC.Value / decimal.Parse(appWorkspace.GetPxPerUnit()[4])); circle.Width = radius; this.nudActualWidthC.Value = (int)(Math.PI * (radius / 2) * (radius / 2)); this.lblPixelHeight.Text = ScalePxPerUnit(selectedObject.Width).ToString("F2"); this.lblPixelWidth.Text = ScalePxPerUnit(selectedObject.Width).ToString("F2"); break; case DrawToolType.ViewSquare: if (!this.rbtHeight.Checked) break; selectedObject.Width = (double)(this.nudActualHeightC.Value / decimal.Parse(appWorkspace.GetPxPerUnit()[4])); this.nudActualWidthC.Value = Convert.ToDecimal(Math.Round(selectedObject.Width * selectedObject.Width, 2)); this.lblPixelHeight.Text = ScalePxPerUnit(selectedObject.Width).ToString("F2"); this.lblPixelWidth.Text = ScalePxPerUnit(selectedObject.Width).ToString("F2"); break; } this.selectedObject.Normalize(); this.appWorkspace.ActiveDocumentWorkspace.Refresh(); int centerX = (int)(selectedObject.Rectangle.X + Math.Abs(selectedObject.Rectangle.Width / 2)); int centerY = (int)(selectedObject.Rectangle.Y + Math.Abs(selectedObject.Rectangle.Height / 2)); this.nudCenterX.Value = Math.Abs(centerX); this.nudCenterY.Value = Math.Abs(centerY); this.numericUpDown3Old = Math.Abs(centerX); this.numericUpDown4Old = Math.Abs(centerY); this.nudCenterX.ValueChanged += this.numericUpDown3_ValueChange; this.nudCenterY.ValueChanged += this.numericUpDown4_ValueChange; } /// /// 圆形:面积 /// 正方形:面积 /// /// /// private void numericUpDown6_ValueChange(object sender, EventArgs e) { if (!rbtWidth.Checked) return; if (this.selectedObject == null || this.appWorkspace.ActiveDocumentWorkspace.mouseStatus) return; this.nudCenterX.ValueChanged -= this.numericUpDown3_ValueChange; this.nudCenterY.ValueChanged -= this.numericUpDown4_ValueChange; DrawToolType type = selectedObject.drawToolType; switch (type) { case DrawToolType.ViewCircle: if (!this.rbtWidth.Checked) break; double radius = Math.Sqrt((double)this.nudActualWidthC.Value / Math.PI); this.nudActualHeightC.Value = (decimal)(radius * 2); selectedObject.Width = (float)((radius / double.Parse(appWorkspace.GetPxPerUnit()[4])) * 2); this.lblPixelHeight.Text = ScalePxPerUnit(selectedObject.Width).ToString("F2"); this.lblPixelWidth.Text = ScalePxPerUnit(selectedObject.Width).ToString("F2"); break; case DrawToolType.ViewSquare: if (!this.rbtWidth.Checked) break; double sidelength = Math.Sqrt((double)this.nudActualWidthC.Value); this.nudActualHeightC.Value = (decimal)(sidelength / double.Parse(appWorkspace.GetPxPerUnit()[4])); selectedObject.Width = (float)(sidelength / double.Parse(appWorkspace.GetPxPerUnit()[4])); this.lblPixelHeight.Text = ScalePxPerUnit(selectedObject.Width).ToString("F2"); this.lblPixelWidth.Text = ScalePxPerUnit(selectedObject.Width).ToString("F2"); break; } this.selectedObject.Normalize(); this.appWorkspace.ActiveDocumentWorkspace.Refresh(); int centerX = (int)(selectedObject.Rectangle.X + Math.Abs(selectedObject.Rectangle.Width / 2)); int centerY = (int)(selectedObject.Rectangle.Y + Math.Abs(selectedObject.Rectangle.Height / 2)); this.nudCenterX.Value = Math.Abs(centerX); this.nudCenterY.Value = Math.Abs(centerY); this.numericUpDown3Old = Math.Abs(centerX); this.numericUpDown4Old = Math.Abs(centerY); this.nudCenterX.ValueChanged += this.numericUpDown3_ValueChange; this.nudCenterY.ValueChanged += this.numericUpDown4_ValueChange; } private void InitializeLanguageText() { this.groupBox2.Text = PdnResources.GetString("Menu.view.text"); this.groupBox3.Text = PdnResources.GetString("Menu.Ruler.text"); this.groupBox4.Text = PdnResources.GetString("Menu.Edit.ActualSize.Text"); this.rbtWidth.Text = PdnResources.GetString("Menu.area.text"); this.groupBox5.Text = PdnResources.GetString("Menu.viewsetting.Modifyview.Visualsize.text"); this.groupBox6.Text = PdnResources.GetString("Menu.position.text"); this.label5.Text = PdnResources.GetString("Menu.viewsetting.Modifyview.Centerpoint.text") + "Y"; this.Text = PdnResources.GetString("Menu.ViewSetting.ModifyFieldOfView.Text"); this.rbtHeight.Text = PdnResources.GetString("Menu.diameter.text"); this.label6.Text = PdnResources.GetString("Menu.viewsetting.Modifyview.Centerpoint.text") + "X"; } private void InitializeComponent() { this.groupBox2 = new System.Windows.Forms.GroupBox(); this.label1 = new System.Windows.Forms.Label(); this.groupBox3 = new System.Windows.Forms.GroupBox(); this.label2 = new System.Windows.Forms.Label(); this.groupBox4 = new System.Windows.Forms.GroupBox(); this.nudActualWidthC = new System.Windows.Forms.NumericUpDown(); this.nudActualHeightC = new System.Windows.Forms.NumericUpDown(); this.rbtWidth = new System.Windows.Forms.RadioButton(); this.rbtHeight = new System.Windows.Forms.RadioButton(); this.nudActualWidthR = new System.Windows.Forms.NumericUpDown(); this.nudActualHeightR = new System.Windows.Forms.NumericUpDown(); this.label4 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.groupBox5 = new System.Windows.Forms.GroupBox(); this.lblPixelWidth = new System.Windows.Forms.Label(); this.lblPixelHeight = new System.Windows.Forms.Label(); this.label7 = new System.Windows.Forms.Label(); this.label8 = new System.Windows.Forms.Label(); this.groupBox6 = new System.Windows.Forms.GroupBox(); this.nudCenterY = new System.Windows.Forms.NumericUpDown(); this.nudCenterX = new System.Windows.Forms.NumericUpDown(); this.label5 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); this.groupBox4.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudActualWidthC)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudActualHeightC)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudActualWidthR)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudActualHeightR)).BeginInit(); this.groupBox5.SuspendLayout(); this.groupBox6.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudCenterY)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudCenterX)).BeginInit(); this.SuspendLayout(); // // groupBox2 // this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupBox2.Controls.Add(this.label1); this.groupBox2.Location = new System.Drawing.Point(13, 12); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(452, 47); this.groupBox2.TabIndex = 2; this.groupBox2.TabStop = false; this.groupBox2.Text = "视场"; // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(7, 22); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(41, 12); this.label1.TabIndex = 0; this.label1.Text = "label1"; // // groupBox3 // this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupBox3.Controls.Add(this.label2); this.groupBox3.Location = new System.Drawing.Point(13, 66); this.groupBox3.Name = "groupBox3"; this.groupBox3.Size = new System.Drawing.Size(452, 47); this.groupBox3.TabIndex = 3; this.groupBox3.TabStop = false; this.groupBox3.Text = "标尺"; // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(9, 21); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(41, 12); this.label2.TabIndex = 0; this.label2.Text = "label2"; // // groupBox4 // this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupBox4.Controls.Add(this.nudActualWidthC); this.groupBox4.Controls.Add(this.nudActualHeightC); this.groupBox4.Controls.Add(this.rbtWidth); this.groupBox4.Controls.Add(this.rbtHeight); this.groupBox4.Controls.Add(this.nudActualWidthR); this.groupBox4.Controls.Add(this.nudActualHeightR); this.groupBox4.Controls.Add(this.label4); this.groupBox4.Controls.Add(this.label3); this.groupBox4.Location = new System.Drawing.Point(13, 120); this.groupBox4.Name = "groupBox4"; this.groupBox4.Size = new System.Drawing.Size(452, 47); this.groupBox4.TabIndex = 4; this.groupBox4.TabStop = false; this.groupBox4.Text = "实际大小"; // // numericUpDown6 // this.nudActualWidthC.DecimalPlaces = 2; this.nudActualWidthC.Location = new System.Drawing.Point(335, 18); this.nudActualWidthC.Maximum = new decimal(new int[] { 214748364, 0, 0, 0}); this.nudActualWidthC.Minimum = new decimal(new int[] { 214748364, 0, 0, -2147483648}); this.nudActualWidthC.Name = "numericUpDown6"; this.nudActualWidthC.Size = new System.Drawing.Size(111, 21); this.nudActualWidthC.TabIndex = 14; // // numericUpDown5 // this.nudActualHeightC.DecimalPlaces = 2; this.nudActualHeightC.Location = new System.Drawing.Point(112, 18); this.nudActualHeightC.Maximum = new decimal(new int[] { 214748364, 0, 0, 0}); this.nudActualHeightC.Minimum = new decimal(new int[] { 214748364, 0, 0, -2147483648}); this.nudActualHeightC.Name = "numericUpDown5"; this.nudActualHeightC.Size = new System.Drawing.Size(111, 21); this.nudActualHeightC.TabIndex = 13; // // radioButton2 // this.rbtWidth.AutoSize = true; this.rbtWidth.Location = new System.Drawing.Point(236, 20); this.rbtWidth.Name = "radioButton2"; this.rbtWidth.Size = new System.Drawing.Size(14, 13); this.rbtWidth.TabIndex = 12; this.rbtWidth.TabStop = true; this.rbtWidth.UseVisualStyleBackColor = true; this.rbtWidth.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged_1); // // radioButton1 // this.rbtHeight.AutoSize = true; this.rbtHeight.Location = new System.Drawing.Point(11, 20); this.rbtHeight.Name = "radioButton1"; this.rbtHeight.Size = new System.Drawing.Size(14, 13); this.rbtHeight.TabIndex = 11; this.rbtHeight.TabStop = true; this.rbtHeight.UseVisualStyleBackColor = true; this.rbtHeight.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged_1); // // numericUpDown2 // this.nudActualWidthR.DecimalPlaces = 2; this.nudActualWidthR.Location = new System.Drawing.Point(335, 18); this.nudActualWidthR.Maximum = new decimal(new int[] { 214748364, 0, 0, 0}); this.nudActualWidthR.Minimum = new decimal(new int[] { 214748364, 0, 0, -2147483648}); this.nudActualWidthR.Name = "numericUpDown2"; this.nudActualWidthR.Size = new System.Drawing.Size(111, 21); this.nudActualWidthR.TabIndex = 10; // // numericUpDown1 // this.nudActualHeightR.DecimalPlaces = 2; this.nudActualHeightR.Location = new System.Drawing.Point(112, 18); this.nudActualHeightR.Maximum = new decimal(new int[] { 214748364, 0, 0, 0}); this.nudActualHeightR.Minimum = new decimal(new int[] { 214748364, 0, 0, -2147483648}); this.nudActualHeightR.Name = "numericUpDown1"; this.nudActualHeightR.Size = new System.Drawing.Size(111, 21); this.nudActualHeightR.TabIndex = 9; // // label4 // this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(236, 22); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(0, 12); this.label4.TabIndex = 7; // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(11, 22); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(0, 12); this.label3.TabIndex = 0; // // groupBox5 // this.groupBox5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupBox5.Controls.Add(this.lblPixelWidth); this.groupBox5.Controls.Add(this.lblPixelHeight); this.groupBox5.Controls.Add(this.label7); this.groupBox5.Controls.Add(this.label8); this.groupBox5.Location = new System.Drawing.Point(13, 173); this.groupBox5.Name = "groupBox5"; this.groupBox5.Size = new System.Drawing.Size(452, 47); this.groupBox5.TabIndex = 5; this.groupBox5.TabStop = false; this.groupBox5.Text = "视觉大小"; // // label10 // this.lblPixelWidth.AutoSize = true; this.lblPixelWidth.Location = new System.Drawing.Point(335, 22); this.lblPixelWidth.Name = "label10"; this.lblPixelWidth.Size = new System.Drawing.Size(47, 12); this.lblPixelWidth.TabIndex = 13; this.lblPixelWidth.Text = "label10"; // // label9 // this.lblPixelHeight.AutoSize = true; this.lblPixelHeight.Location = new System.Drawing.Point(110, 22); this.lblPixelHeight.Name = "label9"; this.lblPixelHeight.Size = new System.Drawing.Size(113, 12); this.lblPixelHeight.TabIndex = 12; this.lblPixelHeight.Text = "2225885.8888999988"; // // label7 // this.label7.AutoSize = true; this.label7.Location = new System.Drawing.Point(236, 22); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(47, 12); this.label7.TabIndex = 11; this.label7.Text = "liangge"; // // label8 // this.label8.AutoSize = true; this.label8.Location = new System.Drawing.Point(11, 22); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(29, 12); this.label8.TabIndex = 9; this.label8.Text = "yige"; // // groupBox6 // this.groupBox6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupBox6.Controls.Add(this.nudCenterY); this.groupBox6.Controls.Add(this.nudCenterX); this.groupBox6.Controls.Add(this.label5); this.groupBox6.Controls.Add(this.label6); this.groupBox6.Location = new System.Drawing.Point(13, 227); this.groupBox6.Name = "groupBox6"; this.groupBox6.Size = new System.Drawing.Size(452, 47); this.groupBox6.TabIndex = 6; this.groupBox6.TabStop = false; this.groupBox6.Text = "位置"; // // numericUpDown4 // this.nudCenterY.Location = new System.Drawing.Point(335, 17); this.nudCenterY.Maximum = new decimal(new int[] { 2147483646, 0, 0, 0}); this.nudCenterY.Name = "numericUpDown4"; this.nudCenterY.Size = new System.Drawing.Size(111, 21); this.nudCenterY.TabIndex = 12; // // numericUpDown3 // this.nudCenterX.Location = new System.Drawing.Point(112, 17); this.nudCenterX.Maximum = new decimal(new int[] { 2147483646, 0, 0, 0}); this.nudCenterX.Name = "numericUpDown3"; this.nudCenterX.Size = new System.Drawing.Size(111, 21); this.nudCenterX.TabIndex = 11; // // label5 // this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(236, 21); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(0, 12); this.label5.TabIndex = 11; // // label6 // this.label6.AutoSize = true; this.label6.Location = new System.Drawing.Point(11, 21); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(0, 12); this.label6.TabIndex = 9; // // ChangeViewDialog // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.ClientSize = new System.Drawing.Size(477, 288); this.Controls.Add(this.groupBox6); this.Controls.Add(this.groupBox5); this.Controls.Add(this.groupBox4); this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox2); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.MaximizeBox = false; this.Name = "ChangeViewDialog"; this.ShowInTaskbar = false; this.Text = "修改视场"; //this.TopMost = true; this.Controls.SetChildIndex(this.groupBox2, 0); this.Controls.SetChildIndex(this.groupBox3, 0); this.Controls.SetChildIndex(this.groupBox4, 0); this.Controls.SetChildIndex(this.groupBox5, 0); this.Controls.SetChildIndex(this.groupBox6, 0); this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); this.groupBox3.ResumeLayout(false); this.groupBox3.PerformLayout(); this.groupBox4.ResumeLayout(false); this.groupBox4.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudActualWidthC)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nudActualHeightC)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nudActualWidthR)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nudActualHeightR)).EndInit(); this.groupBox5.ResumeLayout(false); this.groupBox5.PerformLayout(); this.groupBox6.ResumeLayout(false); this.groupBox6.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudCenterY)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nudCenterX)).EndInit(); this.ResumeLayout(false); } private void InitializeUnitText() { this.rbtWidth.Text = PdnResources.GetString("Menu.area.text") + "(" + this.unit + ")"; this.rbtHeight.Text = PdnResources.GetString("Menu.height.text") + "(" + this.unit + ")"; this.label4.Text = PdnResources.GetString("Menu.width.text") + "(" + this.unit + ")"; this.label3.Text = PdnResources.GetString("Menu.height.text") + "(" + this.unit + ")"; this.label7.Text = PdnResources.GetString("Menu.width.text") + "(" + this.unit + ")"; this.label8.Text = PdnResources.GetString("Menu.height.text") + "(" + this.unit + ")"; } private void radioButton1_CheckedChanged_1(object sender, EventArgs e) { this.nudActualHeightC.Enabled = rbtHeight.Checked; } private void radioButton2_CheckedChanged_1(object sender, EventArgs e) { this.nudActualWidthC.Enabled = this.rbtWidth.Checked; } } }