using Resources;
using SmartCoalApplication.Actions;
using SmartCoalApplication.Annotation.Enum;
using SmartCoalApplication.Base;
using SmartCoalApplication.Base.CommTool;
using SmartCoalApplication.Base.Enum;
using SmartCoalApplication.Base.MeasureModel;
using SmartCoalApplication.Base.SettingModel;
using SmartCoalApplication.Core;
using SmartCoalApplication.Core.CustomControl;
using SmartCoalApplication.Core.DbOpreate.DbModel;
using SmartCoalApplication.Rule;
using SmartCoalApplication.SystemLayer;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Windows.Forms;
namespace SmartCoalApplication
{
internal class AppWorkspace : UserControl, ISnapObstacleHost, IAppWorkspaceForSurfaceBox
{
///
/// 顶部菜单和工具栏
///
public PdnToolBar toolBar;
///
/// 底部公用工具栏
///
private PanelBottom panelBottom;
///
/// 主界面左侧的快捷工具栏
///
public ToolsControl toolsPanel;
///
/// 包含DocumentWorkspace集合的panel
///
public Panel workspacePanel;
///
/// 底部状态栏
///
private PdnStatusBar statusBar;
///
/// 当前激活的工作空间
///
private DocumentWorkspace activeDocumentWorkspace;
///
/// 如果添加了新的工作空间,并且该工作空间没有被修改,则将其删除
///
private DocumentWorkspace initialWorkspace;
///
/// 工作空间集合,打开的图像
///
private List documentWorkspaces = new List();
///
/// 保存了许多可浮动的窗口,为了统一管理,供外部调用
///
private WorkspaceWidgets widgets;
///
/// 最近打开的文件
///
private MostRecentFiles mostRecentFiles = null;
///
/// 最近打开的文件的最大默认数量
///
private const int defaultMostRecentFilesMax = 8;
///
/// 锁定扩缩标记
///
public bool isLockZoom = false;
///
/// 锁定扩缩的百分比
///
public double lockScaleRatio = 0;
///
/// 测量连续绘制
///
public bool continuousDrawingMeasure = false;
///
/// 标记连续绘制
///
public bool continuousDrawingLabel = false;
///
/// 测量连续绘制
///
public bool continuousDrawingView = false;
///
/// 要删除的工作空间位置(避免批量保存有修改的图片时关闭的工作空间位置与for循环顺序不一致)
///
public int toRemoveDocumentWorkspaceIndex = -1;
private SnapObstacleController snapObstacle;
private bool addedToSnapManager = false;
private int ignoreUpdateSnapObstacle = 0;
public DrawToolType activeTool = DrawToolType.Pointer;
///
/// 结果页面标尺信息
///
public double unitNum = 1;
public string aliasName;
public int decimalPlaces = 2;
///
/// 标尺标定窗口
///
private RuleListForm ruleListForm;
public void ResetFloatingForms()
{
ResetFloatingForm(Widgets.RuleListForm);
}
public void ResetFloatingForm(FloatingToolForm ftf)
{
SnapManager sm = SnapManager.FindMySnapManager(this);
if (ftf == Widgets.RuleListForm)
{
sm.ParkObstacle(Widgets.RuleListForm, this, HorizontalSnapEdge.Bottom, VerticalSnapEdge.Left);
}
else
{
throw new ArgumentException();
}
}
public PanelBottom PanelBottom
{
get
{
return this.panelBottom;
}
}
///
/// 单位改变事件
///
public event EventHandler UnitsChanged;
protected virtual void OnUnitsChanged()
{
if (UnitsChanged != null)
{
UnitsChanged(this, EventArgs.Empty);
}
}
public MeasurementUnit Units
{
get
{
return Program.instance.measurementUnit;
}
set
{
//this.widgets.ViewConfigStrip.Units = value;
}
}
protected override void OnLayout(LayoutEventArgs levent)
{
base.OnLayout(levent);
}
protected override void OnLocationChanged(EventArgs e)
{
base.OnLocationChanged(e);
}
protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged(e);
}
protected override void OnEnabledChanged(EventArgs e)
{
base.OnEnabledChanged(e);
}
protected override void OnVisibleChanged(EventArgs e)
{
base.OnVisibleChanged(e);
}
public PdnToolBar ToolBar
{
get
{
return this.toolBar;
}
}
public MostRecentFiles MostRecentFiles
{
get
{
if (this.mostRecentFiles == null)
{
this.mostRecentFiles = new MostRecentFiles(defaultMostRecentFilesMax);
}
return this.mostRecentFiles;
}
}
private void DocumentWorkspace_DocumentChanging(object sender, EventArgs e)
{
UI.SuspendControlPainting(this);
}
private void DocumentWorkspace_DocumentChanged(object sender, EventArgs e)
{
UpdateDocInfoInStatusBar();
this.UpdatePixelTracking();
UI.ResumeControlPainting(this);
Invalidate(true);
}
private void CoordinatesToStrings(int x, int y, out string xString, out string yString, out string unitsString)
{
this.activeDocumentWorkspace.Document.CoordinatesToStrings(this.Units, x, y, out xString, out yString, out unitsString);
}
///
/// 更新右下角坐标信息
///
///
///
private void UpdateCursorInfoInStatusBar(int cursorX, int cursorY)
{
SuspendLayout();
if (this.activeDocumentWorkspace == null ||
this.activeDocumentWorkspace.Document == null)
{
this.statusBar.CursorInfoText = string.Empty;
}
else
{
string xString;
string yString;
string units;
CoordinatesToStrings(cursorX, cursorY, out xString, out yString, out units);
string cursorText = string.Format(
CultureInfo.InvariantCulture,
PdnResources.GetString("StatusBar.CursorInfo.Format"),
xString,
units,
yString,
units);
//this.statusBar.CursorInfoText = cursorText;
}
ResumeLayout(false);
}
///
/// 更新底部状态栏的文字等
/// 需要修改为显示标尺相关的信息
///
public void UpdateDocInfoInStatusBar()
{
if (this.activeDocumentWorkspace != null)
{
if (this.activeDocumentWorkspace.xmlSaveModel == null)
{
if (Program.instance.ruleDB != null)
{
this.statusBar.ImageInfoStatusText = Program.instance.ruleDB.ruler_name;
this.statusBar.CursorInfoText = Math.Round(Program.instance.rules[(MeasurementUnit)Program.instance.ruleDB.ruler_units], 4) + InvariantData.unitsDictionary[(int)((MeasurementUnit)(Enum.ToObject(typeof(MeasurementUnit), Program.instance.ruleDB.ruler_units)))].ToString() + "/" + PdnResources.GetString("Menu.Pixel.text");
}
else {
this.statusBar.ImageInfoStatusText = PdnResources.GetString("Menu.Unselectedruler.Text");
this.statusBar.CursorInfoText = PdnResources.GetString("Menu.Defaultis1micron/pixel.Text");
}
}
else
{
//选中图片是否有配置文件
if ((ExistenceXML() && this.activeDocumentWorkspace.xmlSaveModel.pixel_length != 0) || (this.activeDocumentWorkspace != null && this.activeDocumentWorkspace.xmlSaveModel != null && this.activeDocumentWorkspace.xmlSaveModel.pixel_length != 0))
{
this.statusBar.ImageInfoStatusText = this.activeDocumentWorkspace.xmlSaveModel.ruler_name;
double unitLength = (double)(this.activeDocumentWorkspace.xmlSaveModel.physical_length / (decimal)this.activeDocumentWorkspace.xmlSaveModel.pixel_length);
this.statusBar.CursorInfoText = Math.Round(unitLength, 4) + InvariantData.unitsDictionary[(int)((MeasurementUnit)(Enum.ToObject(typeof(MeasurementUnit), this.activeDocumentWorkspace.xmlSaveModel.ruler_units)))].ToString() + "/" + PdnResources.GetString("Menu.Pixel.text");
}
else
{
this.statusBar.ImageInfoStatusText = Program.instance.ruleDB.ruler_name;
this.statusBar.CursorInfoText = Math.Round(Program.instance.rules[(MeasurementUnit)Program.instance.ruleDB.ruler_units], 4) + InvariantData.unitsDictionary[(int)((MeasurementUnit)(Enum.ToObject(typeof(MeasurementUnit), Program.instance.ruleDB.ruler_units)))].ToString() + "/" + PdnResources.GetString("Menu.Pixel.text");
}
}
}
}
///
/// 更新像素跟踪的图像
///
private void UpdatePixelTracking()
{
}
[Browsable(false)]
public WorkspaceWidgets Widgets
{
get
{
return this.widgets;
}
}
public DocumentWorkspace ActiveDocumentWorkspace
{
get
{
return this.activeDocumentWorkspace;
}
set
{
if (value != this.activeDocumentWorkspace)
{
if (value != null &&
this.documentWorkspaces.IndexOf(value) == -1)
{
throw new ArgumentException("DocumentWorkspace was not created with AddNewDocumentWorkspace");
}
bool focused = false;
if (this.activeDocumentWorkspace != null)
{
focused = this.activeDocumentWorkspace.Focused;
}
UI.SuspendControlPainting(this);
OnActiveDocumentWorkspaceChanging();
this.activeDocumentWorkspace = value;
OnActiveDocumentWorkspaceChanged();
UI.ResumeControlPainting(this);
Refresh();
if (value != null)
{
value.Focus();
}
}
}
}
private void ActiveDocumentWorkspace_FirstInputAfterGotFocus(object sender, EventArgs e)
{
//this.toolBar.DocumentStrip.EnsureItemFullyVisible(this.toolBar.DocumentStrip.SelectedDocumentIndex);
}
public DocumentWorkspace[] DocumentWorkspaces
{
get
{
return this.documentWorkspaces.ToArray();
}
}
public SnapObstacle SnapObstacle
{
get
{
if (this.snapObstacle == null)
{
this.snapObstacle = new SnapObstacleController(
this.Name,
Rectangle.Empty,
SnapRegion.Interior,
true);
this.snapObstacle.EnableSave = false;
PdnBaseForm pdbForm = FindForm() as PdnBaseForm;
pdbForm.Moving += new MovingEventHandler(ParentForm_Moving);
pdbForm.Move += new EventHandler(ParentForm_Move);
pdbForm.ResizeEnd += new EventHandler(ParentForm_ResizeEnd);
pdbForm.Layout += new LayoutEventHandler(ParentForm_Layout);
pdbForm.SizeChanged += new EventHandler(ParentForm_SizeChanged);
UpdateSnapObstacle();
}
return this.snapObstacle;
}
}
private void ParentForm_Move(object sender, EventArgs e)
{
UpdateSnapObstacle();
}
private void ParentForm_SizeChanged(object sender, EventArgs e)
{
UpdateSnapObstacle();
}
private void ParentForm_Layout(object sender, LayoutEventArgs e)
{
UpdateSnapObstacle();
}
private void ParentForm_ResizeEnd(object sender, EventArgs e)
{
UpdateSnapObstacle();
}
private void ParentForm_Moving(object sender, MovingEventArgs e)
{
UpdateSnapObstacle();
}
private void AppWorkspace_Shown(object sender, EventArgs e)
{
UpdateSnapObstacle();
}
private void SuspendUpdateSnapObstacle()
{
++this.ignoreUpdateSnapObstacle;
}
private void ResumeUpdateSnapObstacle()
{
--this.ignoreUpdateSnapObstacle;
}
///
/// 更新快照
///
private void UpdateSnapObstacle()
{
if (this.ignoreUpdateSnapObstacle > 0)
{
return;
}
if (this.snapObstacle == null)
{
return;
}
if (!this.addedToSnapManager)
{
SnapManager sm = SnapManager.FindMySnapManager(this);
if (sm != null)
{
SnapObstacle so = this.SnapObstacle;
if (!this.addedToSnapManager)
{
sm.AddSnapObstacle(this.SnapObstacle);
this.addedToSnapManager = true;
FindForm().Shown += new EventHandler(AppWorkspace_Shown);
}
}
}
if (this.snapObstacle != null)
{
Rectangle clientRect;
if (ActiveDocumentWorkspace != null)
{
clientRect = ActiveDocumentWorkspace.VisibleViewRectangle;
}
else
{
clientRect = this.workspacePanel.ClientRectangle;
}
Rectangle screenRect = this.workspacePanel.RectangleToScreen(clientRect);
this.snapObstacle.SetBounds(screenRect);
this.snapObstacle.Enabled = this.Visible && this.Enabled;
try
{
//this.ActiveDocumentWorkspace.PanelBottom.documentStrip.Width = screenRect.Width - this.ActiveDocumentWorkspace.PanelBottom.locationX;
}
catch (Exception)
{
// throw;
}
}
}
public DocumentWorkspace AddNewDocumentWorkspace()
{
if (this.initialWorkspace != null)
{
if (this.initialWorkspace.Document == null || !this.initialWorkspace.Document.Dirty)
{
RemoveDocumentWorkspace(this.initialWorkspace);
this.initialWorkspace = null;
}
}
DocumentWorkspace dw = new DocumentWorkspace(this);
dw.AppWorkspace = this;
dw.activeTool = this.activeTool;
this.documentWorkspaces.Add(dw);
this.toolBar.DocumentStrip.AddDocumentWorkspace(dw);
return dw;
}
public void RemoveDocumentWorkspace(DocumentWorkspace documentWorkspace)
{
int dwIndex = this.documentWorkspaces.IndexOf(documentWorkspace);
if (dwIndex == -1)
{
throw new ArgumentException("DocumentWorkspace was not created with AddNewDocumentWorkspace");
}
bool removingCurrentDW;
if (this.ActiveDocumentWorkspace == documentWorkspace)
{
removingCurrentDW = true;
}
else
{
removingCurrentDW = false;
}
if (removingCurrentDW)
{
if (this.documentWorkspaces.Count == 1)
{
this.ActiveDocumentWorkspace = null;
}
else if (dwIndex == 0)
{
this.ActiveDocumentWorkspace = this.documentWorkspaces[1];
}
else
{
this.ActiveDocumentWorkspace = this.documentWorkspaces[dwIndex - 1];
}
}
this.documentWorkspaces.Remove(documentWorkspace);
this.toolBar.DocumentStrip.RemoveDocumentWorkspace(documentWorkspace);
if (this.initialWorkspace == documentWorkspace)
{
this.initialWorkspace = null;
}
// Clean up the DocumentWorkspace
Document document = documentWorkspace.Document;
documentWorkspace.Document = null;
document.Dispose();
documentWorkspace.Dispose();
documentWorkspace = null;
}
public event EventHandler ActiveDocumentWorkspaceChanging;
protected virtual void OnActiveDocumentWorkspaceChanging()
{
SuspendUpdateSnapObstacle();
if (ActiveDocumentWorkspaceChanging != null)
{
ActiveDocumentWorkspaceChanging(this, EventArgs.Empty);
}
if (this.activeDocumentWorkspace != null)
{
this.activeDocumentWorkspace.FirstInputAfterGotFocus +=
ActiveDocumentWorkspace_FirstInputAfterGotFocus;
this.activeDocumentWorkspace.RulersEnabledChanged -= this.DocumentWorkspace_RulersEnabledChanged;
this.activeDocumentWorkspace.DocumentMouseEnter -= this.DocumentMouseEnterHandler;
this.activeDocumentWorkspace.DocumentMouseLeave -= this.DocumentMouseLeaveHandler;
this.activeDocumentWorkspace.DocumentMouseMove -= this.DocumentMouseMoveHandler;
this.activeDocumentWorkspace.DocumentMouseDown -= this.DocumentMouseDownHandler;
this.activeDocumentWorkspace.Scroll -= this.DocumentWorkspace_Scroll;
this.activeDocumentWorkspace.Layout -= this.DocumentWorkspace_Layout;
this.activeDocumentWorkspace.DocumentClick -= this.DocumentClick;
this.activeDocumentWorkspace.DocumentMouseUp -= this.DocumentMouseUpHandler;
this.activeDocumentWorkspace.DocumentKeyPress -= this.DocumentKeyPress;
this.activeDocumentWorkspace.DocumentKeyUp -= this.DocumenKeyUp;
this.activeDocumentWorkspace.DocumentKeyDown -= this.DocumentKeyDown;
this.activeDocumentWorkspace.StatusChanged -= OnDocumentWorkspaceStatusChanged;
this.activeDocumentWorkspace.DocumentChanging -= DocumentWorkspace_DocumentChanging;
this.activeDocumentWorkspace.DocumentChanged -= DocumentWorkspace_DocumentChanged;
this.activeDocumentWorkspace.Visible = false;
this.activeDocumentWorkspace.ToolChanging -= this.ToolChangingHandler;
this.activeDocumentWorkspace.ToolChanged -= this.ToolChangedHandler;
this.activeDocumentWorkspace.ActiveTool = this.activeTool;
}
ResumeUpdateSnapObstacle();
UpdateSnapObstacle();
//if (this.activeDocumentWorkspace != null)
//{
// if (!this.activeDocumentWorkspace.ContinuousDrawingMeasure
// && this.activeDocumentWorkspace.activeTool >= DrawToolType.MeasureLine && this.activeDocumentWorkspace.activeTool <= DrawToolType.MeasureThreePointArc)
// this.activeDocumentWorkspace.activeTool = DrawToolType.Pointer;
// if (!this.activeDocumentWorkspace.ContinuousDrawingLabel
// && this.activeDocumentWorkspace.activeTool >= DrawToolType.DrawRectangle && this.activeDocumentWorkspace.activeTool <= DrawToolType.DrawPrestoredRuler)
// this.activeDocumentWorkspace.activeTool = DrawToolType.Pointer;
// this.SetTopLeftCheckState();
// this.UpdateBottomButtonSelectionStatus();
//}
}
public event EventHandler ActiveDocumentWorkspaceChanged;
protected virtual void OnActiveDocumentWorkspaceChanged()
{
SuspendUpdateSnapObstacle();
if (this.activeDocumentWorkspace != null)
{
this.activeDocumentWorkspace.SuspendLayout();
this.activeDocumentWorkspace.BackColor = System.Drawing.SystemColors.ControlDark;
this.activeDocumentWorkspace.Dock = System.Windows.Forms.DockStyle.Fill;
this.activeDocumentWorkspace.PanelAutoScroll = true;
this.activeDocumentWorkspace.RulersEnabled = Settings.CurrentUser.GetBoolean(SettingNames.Rulers, true);
this.activeDocumentWorkspace.TabIndex = 0;
this.activeDocumentWorkspace.TabStop = false;
this.activeDocumentWorkspace.RulersEnabledChanged += this.DocumentWorkspace_RulersEnabledChanged;
this.activeDocumentWorkspace.DocumentMouseEnter += this.DocumentMouseEnterHandler;
this.activeDocumentWorkspace.DocumentMouseLeave += this.DocumentMouseLeaveHandler;
this.activeDocumentWorkspace.DocumentMouseMove += this.DocumentMouseMoveHandler;
this.activeDocumentWorkspace.DocumentMouseDown += this.DocumentMouseDownHandler;
this.activeDocumentWorkspace.Scroll += this.DocumentWorkspace_Scroll;
this.activeDocumentWorkspace.DocumentClick += this.DocumentClick;
this.activeDocumentWorkspace.DocumentMouseUp += this.DocumentMouseUpHandler;
this.activeDocumentWorkspace.DocumentKeyPress += this.DocumentKeyPress;
this.activeDocumentWorkspace.DocumentKeyUp += this.DocumenKeyUp;
this.activeDocumentWorkspace.DocumentKeyDown += this.DocumentKeyDown;
if (this.workspacePanel.Controls.Contains(this.activeDocumentWorkspace))
{
this.activeDocumentWorkspace.Visible = true;
}
else
{
this.activeDocumentWorkspace.Dock = DockStyle.Fill;
this.workspacePanel.Controls.Add(this.activeDocumentWorkspace);
}
this.activeDocumentWorkspace.Layout += this.DocumentWorkspace_Layout;
this.activeDocumentWorkspace.AppWorkspace = this;
this.activeDocumentWorkspace.StatusChanged += OnDocumentWorkspaceStatusChanged;
this.activeDocumentWorkspace.DocumentChanging += DocumentWorkspace_DocumentChanging;
this.activeDocumentWorkspace.DocumentChanged += DocumentWorkspace_DocumentChanged;
this.activeDocumentWorkspace.ToolChanging += this.ToolChangingHandler;
this.activeDocumentWorkspace.ToolChanged += this.ToolChangedHandler;
this.toolBar.DocumentStrip.SelectDocumentWorkspace(this.activeDocumentWorkspace);
//处理底部缩放百分比的trackbar和textbox
this.SetZoonTrackValue(this.activeDocumentWorkspace.ScaleFactor);
this.activeDocumentWorkspace.ResumeLayout();
this.activeDocumentWorkspace.PerformLayout();
this.activeDocumentWorkspace.FirstInputAfterGotFocus += ActiveDocumentWorkspace_FirstInputAfterGotFocus;
//更新信息
this.UpdateDocInfoInStatusBar();
}
if (ActiveDocumentWorkspaceChanged != null)
{
ActiveDocumentWorkspaceChanged(this, EventArgs.Empty);
}
ResumeUpdateSnapObstacle();
UpdateSnapObstacle();
UpdateStatusBarContextStatus();
}
public void SetTopLeftCheckState()
{
if (this.toolBar != null && this.activeDocumentWorkspace != null)
{
this.toolBar.RefreshBtnSelect(this.Widgets.RuleListForm.Visible, "SubRulerCalibration");
this.toolsPanel.RefreshBtnSelect(this.Widgets.RuleListForm.Visible, "SubRulerCalibration");
this.activeDocumentWorkspace.ContinuousDrawingMeasure = this.continuousDrawingMeasure;
this.activeDocumentWorkspace.ContinuousDrawingLabel = this.continuousDrawingLabel;
this.toolBar.RefreshBtnSelect(this.activeDocumentWorkspace.ContinuousDrawingMeasure, "ContinuousDrawingMeasure");
this.toolsPanel.RefreshBtnSelect(this.activeDocumentWorkspace.ContinuousDrawingMeasure, "ContinuousDrawingMeasure");
this.toolBar.RefreshBtnSelect(this.activeDocumentWorkspace.ContinuousDrawingLabel, "ContinuousDrawingLabel");
this.toolsPanel.RefreshBtnSelect(this.activeDocumentWorkspace.ContinuousDrawingLabel, "ContinuousDrawingLabel");
this.toolBar.RefreshBtnSelect(this.activeDocumentWorkspace.GridLineEnabled, "GridLine");
this.toolsPanel.RefreshBtnSelect(this.activeDocumentWorkspace.GridLineEnabled, "GridLine");
this.toolBar.RefreshBtnSelect(this.activeDocumentWorkspace.RulersEnabled, "ViewRuler");
this.toolsPanel.RefreshBtnSelect(this.activeDocumentWorkspace.RulersEnabled, "ViewRuler");
this.toolBar.RefreshBtnSelect(this.activeDocumentWorkspace.ContinuousBinaryAction, "ContinuousOperation");
this.toolsPanel.RefreshBtnSelect(this.activeDocumentWorkspace.ContinuousBinaryAction, "ContinuousOperation");
this.toolBar.RefreshBtnSelect(this.activeDocumentWorkspace.ActualSize, "ActualSize");
this.toolsPanel.RefreshBtnSelect(this.activeDocumentWorkspace.ActualSize, "ActualSize");
this.toolBar.RefreshBtnSelect(this.activeDocumentWorkspace.SuitableSize, "ZoomToWindow");
this.toolsPanel.RefreshBtnSelect(this.activeDocumentWorkspace.SuitableSize, "ZoomToWindow");
this.toolBar.RefreshBtnSelect(this.activeDocumentWorkspace.SuitableWidth, "ZoomToWidth");
this.toolsPanel.RefreshBtnSelect(this.activeDocumentWorkspace.SuitableWidth, "ZoomToWidth");
this.toolBar.RefreshBtnSelect(this.activeDocumentWorkspace.SuitableHeight, "ZoomToHeight");
this.toolsPanel.RefreshBtnSelect(this.activeDocumentWorkspace.SuitableHeight, "ZoomToHeight");
this.toolBar.RefreshBtnSelect(this.activeDocumentWorkspace.LockZoom, "LockZoom");
this.toolsPanel.RefreshBtnSelect(this.activeDocumentWorkspace.LockZoom, "LockZoom");
this.toolBar.RefreshBtnSelect(this.activeDocumentWorkspace.FixedMultiple, "FixedMultiple");
this.toolsPanel.RefreshBtnSelect(this.activeDocumentWorkspace.FixedMultiple, "FixedMultiple");
if (!this.activeDocumentWorkspace.DeleteFieldOfView)
this.activeDocumentWorkspace.MergeFieldOfView = true;
this.toolBar.RefreshBtnSelect(this.activeDocumentWorkspace.MergeFieldOfView, "MergeFieldOfView");
this.toolsPanel.RefreshBtnSelect(this.activeDocumentWorkspace.MergeFieldOfView, "MergeFieldOfView");
this.toolBar.RefreshBtnSelect(this.activeDocumentWorkspace.DeleteFieldOfView, "DeleteFieldOfView");
this.toolsPanel.RefreshBtnSelect(this.activeDocumentWorkspace.DeleteFieldOfView, "DeleteFieldOfView");
}
}
public AppWorkspace(Form form)
{
SuspendLayout();
InitializeComponent();
InitializeFloatingForms();
this.toolBar.AppWorkspace = this;
this.widgets = new WorkspaceWidgets(this);
this.widgets.StatusBarProgress = this.statusBar;
this.widgets.DocumentStrip = this.toolBar.DocumentStrip;
this.Widgets.RuleListForm = this.ruleListForm;
this.toolBar.DocumentStrip.RelinquishFocus += RelinquishFocusHandler;
this.toolBar.DocumentStrip.RelinquishFocus += OnToolStripRelinquishFocus;
this.toolBar.DocumentStrip.DocumentClicked += DocumentStrip_DocumentTabClicked;
this.toolBar.DocumentStrip.DocumentListChanged += DocumentStrip_DocumentListChanged;
ResumeLayout();
PerformLayout();
this.InitializeBottomEvent();
}
private void DocumentStrip_DocumentListChanged(object sender, EventArgs e)
{
bool enableThem = (this.widgets.DocumentStrip.DocumentCount != 0);
this.widgets.RuleListForm.Enabled = enableThem;
UpdateDocInfoInStatusBar();
UpdateCursorInfoInStatusBar(0, 0);
}
private void InitializeFloatingForms()
{
// RuleListForm
ruleListForm = new RuleListForm(this);
ruleListForm.RelinquishFocus += RelinquishFocusHandler;
ruleListForm.ProcessCmdKeyEvent += OnToolFormProcessCmdKeyEvent;
}
public event CmdKeysEventHandler ProcessCmdKeyEvent;
private bool OnToolFormProcessCmdKeyEvent(object sender, ref Message msg, Keys keyData)
{
if (ProcessCmdKeyEvent != null)
{
return ProcessCmdKeyEvent(sender, ref msg, keyData);
}
else
{
return false;
}
}
public void SaveSettings()
{
this.MostRecentFiles.SaveMruList();
}
protected override void OnLoad(EventArgs e)
{
if (this.ActiveDocumentWorkspace != null)
{
this.ActiveDocumentWorkspace.Select();
}
base.OnLoad(e);
}
private void RelinquishFocusHandler(object sender, EventArgs e)
{
this.Focus();
}
private void InitializeComponent()
{
this.panelBottom = new PanelBottom();
this.toolBar = new PdnToolBar(this);
this.statusBar = new PdnStatusBar();
this.toolsPanel = new ToolsControl(this);
this.workspacePanel = new Panel();
this.workspacePanel.SuspendLayout();
this.statusBar.SuspendLayout();
this.SuspendLayout();
//
// panelBottom
//
this.panelBottom.Height = 30;
this.panelBottom.Dock = DockStyle.Bottom;
//
// toolBar
//
this.toolBar.Name = "toolBar";
this.toolBar.Dock = DockStyle.Top;
//
// statusBar
//
this.statusBar.Name = "statusBar";
//
// toolsPanel
//
this.toolsPanel.Width = 50;
this.toolsPanel.Dock = DockStyle.Left;
//
// workspacePanel
//
this.workspacePanel.Name = "workspacePanel";
this.workspacePanel.Dock = DockStyle.Fill;
//
// AppWorkspace
//
this.Controls.Add(this.workspacePanel);
this.Controls.Add(this.panelBottom);
this.Controls.Add(this.toolsPanel);
this.Controls.Add(this.statusBar);
this.Controls.Add(this.toolBar);
this.Name = "AppWorkspace";
this.Size = new System.Drawing.Size(872, 640);
this.workspacePanel.ResumeLayout(false);
this.statusBar.ResumeLayout(false);
this.statusBar.PerformLayout();
this.ResumeLayout(false);
}
private void DocumentStrip_DocumentTabClicked(
object sender,
EventArgs> e)
{
switch (e.Data.Second)
{
case DocumentClickAction.Select:
this.ActiveDocumentWorkspace = e.Data.First;
break;
case DocumentClickAction.Close:
CloseWorkspaceAction cwa = new CloseWorkspaceAction(e.Data.First);
PerformAction(cwa);
break;
default:
throw new NotImplementedException("Code for DocumentClickAction." + e.Data.Second.ToString() + " not implemented");
}
Update();
}
private void OnToolStripMouseWheel(object sender, MouseEventArgs e)
{
if (this.activeDocumentWorkspace != null)
{
this.activeDocumentWorkspace.PerformMouseWheel((Control)sender, e);
}
}
private void OnToolStripRelinquishFocus(object sender, EventArgs e)
{
if (this.activeDocumentWorkspace != null)
{
this.activeDocumentWorkspace.Focus();
}
}
private void DocumentMouseEnterHandler(object sender, EventArgs e)
{
}
private void DocumentMouseLeaveHandler(object sender, EventArgs e)
{
}
private void DocumentMouseUpHandler(object sender, MouseEventArgs e)
{
}
private void DocumentMouseDownHandler(object sender, MouseEventArgs e)
{
}
private void DocumentMouseMoveHandler(object sender, MouseEventArgs e)
{
UpdateCursorInfoInStatusBar(e.X, e.Y);
}
private void DocumentClick(object sender, EventArgs e)
{
}
private void DocumentKeyPress(object sender, KeyPressEventArgs e)
{
}
private void DocumentKeyDown(object sender, KeyEventArgs e)
{
}
private void DocumenKeyUp(object sender, KeyEventArgs e)
{
}
public void PerformAction(AppWorkspaceAction performMe)
{
Update();
using (new WaitCursorChanger(this))
{
performMe.PerformAction(this);
}
Update();
}
private void ToolChangingHandler(object sender, EventArgs e)
{
UI.SuspendControlPainting(this.toolBar);
}
private void ToolChangedHandler(object sender, EventArgs e)
{
UpdateStatusBarContextStatus();
UI.ResumeControlPainting(this.toolBar);
this.toolBar.Refresh();
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
}
private void DocumentWorkspace_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e)
{
OnScroll(e);
}
private void DocumentWorkspace_Layout(object sender, LayoutEventArgs e)
{
}
/*private void DocumentWorkspace_ZoomBasisChanged(object sender, EventArgs e)
{
if (this.toolBar.ViewConfigStrip.ZoomBasis != this.ActiveDocumentWorkspace.ZoomBasis)
{
this.toolBar.ViewConfigStrip.ZoomBasis = this.ActiveDocumentWorkspace.ZoomBasis;
}
}*/
private void DocumentWorkspace_RulersEnabledChanged(object sender, EventArgs e)
{
PerformLayout();
}
public void ViewConfigStrip_UnitsChanged(object sender, EventArgs e)
{
if (this.activeDocumentWorkspace != null)
{
this.activeDocumentWorkspace.Units = this.Units;
}
UpdateDocInfoInStatusBar();
this.statusBar.CursorInfoText = string.Empty;
OnUnitsChanged();
}
public event EventHandler StatusChanged;
private void OnStatusChanged()
{
if (StatusChanged != null)
{
StatusChanged(this, EventArgs.Empty);
}
}
private void OnDocumentWorkspaceStatusChanged(object sender, EventArgs e)
{
OnStatusChanged();
UpdateStatusBarContextStatus();
}
private void UpdateStatusBarContextStatus()
{
if (ActiveDocumentWorkspace != null)
{
this.statusBar.ContextStatusText = this.activeDocumentWorkspace.StatusText;
this.statusBar.ContextStatusImage = this.activeDocumentWorkspace.StatusIcon;
}
else
{
this.statusBar.ContextStatusText = string.Empty;
this.statusBar.ContextStatusImage = null;
}
}
public bool CreateBlankDocumentInNewWorkspace(Size size, MeasurementUnit dpuUnit, double dpu, bool isInitial)
{
DocumentWorkspace dw1 = this.activeDocumentWorkspace;
if (dw1 != null)
{
dw1.SuspendRefresh();
}
try
{
Document untitled = new Document(size.Width, size.Height);
untitled.DpuUnit = dpuUnit;
untitled.DpuX = dpu;
untitled.DpuY = dpu;
using (new WaitCursorChanger(this))
{
bool focused = false;
if (this.ActiveDocumentWorkspace != null && this.ActiveDocumentWorkspace.Focused)
{
focused = true;
}
untitled.surface = new Surface(new Size(size.Width, size.Height));
untitled.surface.Clear(ColorBgra.FromBgra(255, 255, 255, 255));
DocumentWorkspace dw = this.AddNewDocumentWorkspace();
this.Widgets.DocumentStrip.LockDocumentWorkspaceDirtyValue(dw, false);
dw.SuspendRefresh();
try
{
dw.Document = untitled;
}
catch (OutOfMemoryException)
{
Utility.ErrorBox(this, PdnResources.GetString("NewImageAction.Error.OutOfMemory"));
RemoveDocumentWorkspace(dw);
untitled.Dispose();
return false;
}
this.ActiveDocumentWorkspace = dw;
dw.SetDocumentSaveOptions(null);
dw.Document.Dirty = false;
dw.ResumeRefresh();
if (isInitial)
{
this.initialWorkspace = dw;
}
if (focused)
{
this.ActiveDocumentWorkspace.Focus();
}
this.Widgets.DocumentStrip.UnlockDocumentWorkspaceDirtyValue(dw);
}
}
finally
{
if (dw1 != null)
{
dw1.ResumeRefresh();
}
}
return true;
}
public bool OpenFilesInNewWorkspace(string[] fileNames)
{
if (IsDisposed)
{
return false;
}
bool result = true;
foreach (string fileName in fileNames)
{
result &= OpenFileInNewWorkspace(fileName);
if (!result)
{
break;
}
}
return result;
}
#region 标尺相关
///
/// 刷新标尺列表
///
public void RefueshRuleList()
{
if (this.widgets.RuleListForm != null)
{
this.widgets.RuleListForm.InitListViewData();
}
}
///
/// 激活理论比例尺
///
public void ActivateTemporaryRuler()
{
if (this.widgets.RuleListForm != null)
{
this.widgets.RuleListForm.ActivateTemporaryRuler();
}
}
///
/// 设置当前选中标尺
///
///
public void SetActiveRulerIndex(int index)
{
if (this.widgets.RuleListForm != null)
{
this.widgets.RuleListForm.SetActiveRulerIndex(index);
}
}
///
/// 刷新当前选中的标尺-编辑后使用
///
public void RefreshActiveRuler()
{
if (this.widgets.RuleListForm != null)
{
this.widgets.RuleListForm.RefreshActiveRuler();
}
}
#endregion
public bool OpenFileInNewWorkspace(string fileName)
{
return OpenFileInNewWorkspace(fileName, true);
}
///
/// 需要修改
/// (1)判断是否有同名的xml文件,有则读取并处理
/// (2)判断是否识别其它标尺,有则读取
///
///
///
///
public bool OpenFileInNewWorkspace(string fileName, bool addToMruList)
{
if (fileName == null)
{
throw new ArgumentNullException("fileName");
}
if (fileName.Length == 0)
{
throw new ArgumentOutOfRangeException("fileName.Length == 0");
}
PdnBaseForm.UpdateAllForms();
Document document;
this.widgets.StatusBarProgress.ResetProgressStatusBar();
ProgressEventHandler progressCallback =
delegate (object sender, ProgressEventArgs e)
{
this.widgets.StatusBarProgress.SetProgressStatusBar(e.Percent);
};
document = DocumentWorkspace.LoadDocument(this, fileName, progressCallback);
this.widgets.StatusBarProgress.EraseProgressStatusBar();
if (document == null)
{
this.Cursor = Cursors.Default;
}
else
{
using (new WaitCursorChanger(this))
{
DocumentWorkspace dw = AddNewDocumentWorkspace();
Widgets.DocumentStrip.LockDocumentWorkspaceDirtyValue(dw, false);
try
{
dw.Document = document;
}
catch (OutOfMemoryException)
{
Utility.ErrorBox(this, PdnResources.GetString("LoadImage.Error.OutOfMemoryException"));
RemoveDocumentWorkspace(dw);
document.Dispose();
return false;
}
//判断是否存在xml,进行读取
PicConfigModel configModel = null;
try
{
string path = Path.GetDirectoryName(fileName);
string xmlPath = path + "\\" + Path.GetFileNameWithoutExtension(fileName) + ".xml";
//如果xml存在
if (System.IO.File.Exists(xmlPath))
{
configModel = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(xmlPath, FileMode.Open));
dw.RuleAttribute(configModel);
}
//如果不存在,则判断
//(1)是否自动添加ZEN标尺
//(2)是否自动添加AxioVision标尺
else
{
dw.xmlSaveModel = Program.instance.ruleDB;
dw.InitRulerInfo();
}
}
catch (Exception)
{
}
dw.SetDocumentSaveOptions(fileName);
this.ActiveDocumentWorkspace = dw;
document.Dirty = false;
Widgets.DocumentStrip.UnlockDocumentWorkspaceDirtyValue(dw);
}
if (document != null)
{
if (isLockZoom && lockScaleRatio > 0)
{
ActiveDocumentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
ActiveDocumentWorkspace.ScaleFactor = ScaleFactor.FromDouble(lockScaleRatio);
}
else
{
ActiveDocumentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
}
}
if (addToMruList)
{
ActiveDocumentWorkspace.AddToMruList();
}
}
if (ActiveDocumentWorkspace != null)
{
ActiveDocumentWorkspace.Focus();
}
return document != null;
}
#region 底部公共按钮
///
/// 初始化底部按钮的各种事件
///
private void InitializeBottomEvent()
{
//缩小按钮
this.PanelBottom.zoomOutButton.Click += new EventHandler(ZoomOutButton_Click);
//放大按钮
this.PanelBottom.zoomInButton.Click += new EventHandler(zoomInButton_Click);
//放大缩小拖动条事件
this.PanelBottom.trackBar.ValueChanged += new EventHandler(PanelBottom_trackBar_ValueChanged);
//缩放缩小倍数的改变事件
this.PanelBottom.textBox.TextChanged += new EventHandler(PanelBottom_textBox_ValueChanged);
}
public void SetZoonTrackValue(ScaleFactor newValue)
{
this.panelBottom.trackBar.Maximum = 6200;// (int)(ScaleFactor.MaxValue.Ratio * 100);
if (newValue != null)
{
this.PanelBottom.trackBar.ValueChanged -= this.PanelBottom_trackBar_ValueChanged;
double v = newValue.Ratio * 100;
if (v <= 100)
{
this.PanelBottom.trackBar.Value = (int)(31 * v);
}
else
{
double x = 3100 + newValue.Ratio * 100;
if (x > 6200) x = 6200;
this.PanelBottom.trackBar.Value = (int)x;
}
this.PanelBottom.trackBar.ValueChanged += new EventHandler(this.PanelBottom_trackBar_ValueChanged);
}
//设置底部缩放比例的百分比textbox的值
this.PanelBottom.textBox.TextChanged -= new EventHandler(PanelBottom_textBox_ValueChanged);
this.PanelBottom.textBox.Text = newValue.ToString();
this.PanelBottom.textBox.TextChanged += new EventHandler(PanelBottom_textBox_ValueChanged);
}
///
/// 最佳
///
///
///
private void BestButton_Click(object sender, MouseEventArgs e)
{
}
///
/// 从直方图更新选中状态
///
///
public void MaxMinBest(bool best, bool maxMin, bool origin, bool gamma45)
{
this.activeDocumentWorkspace.best = best;
this.activeDocumentWorkspace.maxMin = maxMin;
this.activeDocumentWorkspace.origin = origin;
this.activeDocumentWorkspace.gamma45 = gamma45;
}
///
/// 最大最小
///
///
///
private void MaxMinButton_Click(object sender, MouseEventArgs e)
{
}
///
/// 原始状态
///
///
///
private void OriginButton_Click(object sender, MouseEventArgs e)
{
}
///
/// 伽马0.45
///
///
///
private void Gamma45Button_Click(object sender, MouseEventArgs e)
{
}
///
/// 更新底部按钮选中状态
///
public void UpdateBottomButtonSelectionStatus()
{
if (this.ActiveDocumentWorkspace == null)
return;
}
///
/// 底部快捷栏 辅助线
///
///
///
private void AuxiliaryLineButton_Click(object sender, MouseEventArgs e)
{
}
///
/// 水平镜像
///
///
///
public void HorizontalMirroringButton_Click(object sender, EventArgs e)
{
}
///
/// 垂直镜像
///
///
///
public void VerticalMirrorButton_Click(object sender, EventArgs e)
{
}
///
/// 中心镜像
///
///
///
public void CenterMirrorButton_Click(object sender, EventArgs e)
{
}
///
/// 底部快捷栏 缩小事件
///
///
///
private void ZoomOutButton_Click(object sender, EventArgs e)
{
if (this.ActiveDocumentWorkspace != null)
{
this.ActiveDocumentWorkspace.ZoomOut();
this.activeDocumentWorkspace.ActualSize = false;
this.activeDocumentWorkspace.SuitableSize = false;
this.activeDocumentWorkspace.SuitableHeight = false;
this.activeDocumentWorkspace.SuitableWidth = false;
this.SetTopLeftCheckState();
this.UpdateBottomButtonSelectionStatus();
}
}
///
/// 底部快捷栏 放大事件
///
///
///
private void zoomInButton_Click(object sender, EventArgs e)
{
if (this.ActiveDocumentWorkspace != null)
{
this.ActiveDocumentWorkspace.ZoomIn();
this.activeDocumentWorkspace.ActualSize = false;
this.activeDocumentWorkspace.SuitableSize = false;
this.activeDocumentWorkspace.SuitableHeight = false;
this.activeDocumentWorkspace.SuitableWidth = false;
this.SetTopLeftCheckState();
this.UpdateBottomButtonSelectionStatus();
}
}
///
/// 底部方法缩小拖动条事件
///
///
///
private void PanelBottom_trackBar_ValueChanged(object sender, EventArgs e)
{
if (this.activeDocumentWorkspace != null)
{
this.activeDocumentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
if (this.PanelBottom.trackBar.Tag == null)
{
int v = this.PanelBottom.trackBar.Value;
if (this.PanelBottom.trackBar.Value <= 3100)
{
this.PanelBottom.trackBar.SmallChange = 31;
v = this.PanelBottom.trackBar.Value / 31;
}
else
{
this.PanelBottom.trackBar.SmallChange = 100;
v = 100 + this.PanelBottom.trackBar.Value - 3100;
}
this.activeDocumentWorkspace.ScaleFactor = new ScaleFactor(v, 100);
this.PanelBottom.trackBar.Tag = this.PanelBottom.trackBar.Value;
}
else
{
int oldValue = (int)this.PanelBottom.trackBar.Tag;
if (oldValue != this.PanelBottom.trackBar.Value)
{
int v = this.PanelBottom.trackBar.Value;
if (this.PanelBottom.trackBar.Value <= 3100)
{
this.PanelBottom.trackBar.SmallChange = 31;
v = this.PanelBottom.trackBar.Value / 31;
}
else
{
this.PanelBottom.trackBar.SmallChange = 100;
v = 100 + this.PanelBottom.trackBar.Value - 3100;
}
this.activeDocumentWorkspace.ScaleFactor = new ScaleFactor(v, 100);
this.PanelBottom.trackBar.Tag = this.PanelBottom.trackBar.Value;
}
}
}
}
private void PanelBottom_textBox_ValueChanged(object sender, EventArgs e)
{
int v;
if (!string.IsNullOrEmpty(this.PanelBottom.textBox.Text) &&
!this.PanelBottom.textBox.Text.Equals("%") &&
int.TryParse(this.PanelBottom.textBox.Text.Replace("%", ""), out v))
{
if (v > this.PanelBottom.trackBar.Maximum) v = this.PanelBottom.trackBar.Maximum;
if (v < this.PanelBottom.trackBar.Minimum) v = this.PanelBottom.trackBar.Minimum;
if (v <= 100)
{
this.PanelBottom.trackBar.Value = v;
}
else
{
int x = 3000 + v;
if (x > 6100) x = 6200;
this.PanelBottom.trackBar.Value = x;
}
}
}
private bool ExistenceXML()
{
if (this.activeDocumentWorkspace != null)
{
return true;
}
//获取图片路径
bool existenceXML = false;
if (this.activeDocumentWorkspace != null)
{
string fileName;
this.activeDocumentWorkspace.GetDocumentSaveOptions(out fileName);
if (fileName != null)
{
string path = Path.GetDirectoryName(fileName);
string xmlPath = path + "\\" + Path.GetFileNameWithoutExtension(fileName) + ".xml";
existenceXML = System.IO.File.Exists(xmlPath);
if (existenceXML)
{
}
}
}
return existenceXML;
}
public Dictionary getMeasureInfo()
{
if (this.ActiveDocumentWorkspace != null && this.ActiveDocumentWorkspace.rules != null && this.ActiveDocumentWorkspace.rules.Count > 0)
return this.ActiveDocumentWorkspace.rules;
else
return Program.instance.rules;
}
#endregion
#region [测量相关]
public DrawToolType GetDrawToolType()
{
return activeTool;
}
public void SetDrawToolType(DrawToolType t)
{
activeTool = t;
}
public void SetDrawNodes()
{
//if (this.measureListDialog != null)
// this.measureListDialog.SetDrawNodes(null, null);
}
public void RefreshListView()
{
//if (this.measureListDialog != null)
// this.measureListDialog.RefreshListView(null, null);
//this.Refresh();
}
///
/// 像素跟踪
/// 需要增加标记,在进行比如图像旋转等直接在当前
/// 面板进行图像大小变化操作的,需要停止像素跟踪,
/// 处理完成之后在恢复,否则可能会导致读取内存异常
///
///
public void SetImageAndData(Point location)
{
//if (this.pixelTrackingDialog != null)
//{
// this.pixelTrackingDialog.SetImageAndData(location);
//}
}
///
/// 获取系统当前选中单位及每单位像素值
///
/// 3位字符串数组,
/// 0:系统选中单位枚举字符串
/// 1:系统选中单位名称字符串
/// 2:系统选中单位符号字符串
/// 3:系统选中单位每单位像素长度
/// 4:系统选中单位每单位物理长度
///
public string[] GetPxPerUnit()
{
if (this.activeDocumentWorkspace != null)
return this.activeDocumentWorkspace.getRulerList();
else
{
string[] result = new string[5];
result[0] = Program.instance.measurementUnit.ToString();
result[1] = InvariantData.unitsDictionary[(int)Program.instance.measurementUnit];
result[2] = InvariantData.unitSymbolsDictionary[(int)Program.instance.measurementUnit];
result[3] = (Program.instance.rules[Program.instance.measurementUnit]).ToString();
result[4] = (Program.instance.rules[MeasurementUnit.Micron]).ToString();
return result;
}
}
///
/// 获取测量样式配置
///
///
public MeasureStyleModel GetMeasureStyleModel()
{
return Program.instance.measureStyleModel;
}
public void SetContinuousDrawingMeasure(bool value)
{
this.continuousDrawingMeasure = value;
SetTopLeftCheckState();
}
public void SetContinuousDrawingView(bool value)
{
this.continuousDrawingView = value;
}
///
/// 获取当前激活的图像工作空间的视场行为
/// 合并/剪切
///
///
public CombineMode GetCombineMode()
{
return this.ActiveDocumentWorkspace.CombineMode;
}
public RectangleF GetVisibleDocumentRectangleF()
{
return this.activeDocumentWorkspace.VisibleDocumentRectangleF;
}
public SizeF GetDocumentSize()
{
return this.activeDocumentWorkspace.Document.Size;
}
///
/// 更新命名的延续数字
///
public void UpdateContinueNum()
{
if (Program.instance.configModel != null)
{
ConfigModel configModel = Program.instance.configModel;
configModel.ContinueNum++;
string configXml = XmlSerializeHelper.XmlSerialize(configModel);
string filePath = Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\Config.xml";
FileOperationHelper.WriteStringToFile(configXml, filePath, FileMode.Create);
}
}
///
/// 获取测量区域样式配置
///
///
public MeasureAreaModel GetMeasureAreaModel()
{
return Program.instance.measureAreaModel;
}
#endregion
///
/// 递归查询树状数据
///
///
///
///
public void RecursionGetData(string id, List originalData, out MeasureMaintenanceTreeSpecificData data)
{
data = originalData.Where(m => m.MeasureMaintenanceTreeSpecificDataId.Equals(id)).FirstOrDefault();
if (data == null)
{
foreach (var item in originalData)
{
if (id.Equals("0")) {
break;
}
RecursionGetData(id, item.MeasureMaintenanceTreeSpecificSonDataList, out data);
if (data != null)
{
break;
}
}
}
}
///
/// 根据别名查询实际名称
///
///
///
///
public string getRealName(List originalData,string aliasName)
{
foreach (var item in originalData)
{
foreach (var item2 in item.MeasureMaintenanceTreeSpecificSonDataList)
{
var data = item2.MeasureMaintenanceTreeSpecificFormulaDataList.Where(m => m.FormulaParameterAliasName == aliasName).FirstOrDefault();
if (data == null)
{
continue;
}
return data.FormulaParameterName;
}
}
return string.Empty;
}
public void setUnitNum(double unit)
{
this.unitNum = unit;
}
public double getUnitNum()
{
return this.unitNum;
}
public string getAliasName()
{
return this.aliasName;
}
public void setAliasName(string name)
{
this.aliasName = name;
}
public int getDecimalPlaces()
{
return Program.instance.decimalPlaces;
}
}
}