/// <summary> /// 当在表格内选择元素时触发 /// </summary> /// <param name="sender">事件源</param> /// <param name="e">事件信息</param> private void DG_List_SelectionChanged(object sender, SelectionChangedEventArgs e) { // 若当前窗口为停靠状态,可能会覆盖到导航的位置, // 所以先将窗口固定,保证主界面的完整显示 if (!parent.MainWindow.LAFind.IsFloat && !parent.MainWindow.LAFind.IsDock) { LayoutSetting.AddDefaultDockWidthAnchorable( Properties.Resources.MainWindow_Search, parent.MainWindow.LAFind.AutoHideWidth.ToString()); LayoutSetting.AddDefaultDockHeighAnchorable( Properties.Resources.MainWindow_Search, parent.MainWindow.LAFind.AutoHideHeight.ToString()); parent.MainWindow.LAFind.ToggleAutoHide(); } // 未选择元素则不导航 if (DG_List.SelectedIndex < 0) { return; } // 导航到选择元素对应的位置 FindElement fele = items[DG_List.SelectedIndex]; BaseViewModel bvmodel = fele.BVModel; int x = bvmodel.X; int y = bvmodel.Y; string diagram = fele.Diagram; int network = int.Parse(fele.Network); NavigateToNetworkEventArgs _e = new NavigateToNetworkEventArgs(network, diagram, x, y); parent.NavigateToNetwork(_e); }
private void DG_List_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e) { if (!parent.MainWindow.LAErrorList.IsFloat && !parent.MainWindow.LAErrorList.IsDock) { LayoutSetting.AddDefaultDockWidthAnchorable( Properties.Resources.MainWindow_Error_List, parent.MainWindow.LAErrorList.AutoHideWidth.ToString()); LayoutSetting.AddDefaultDockHeighAnchorable( Properties.Resources.MainWindow_Error_List, parent.MainWindow.LAErrorList.AutoHideHeight.ToString()); parent.MainWindow.LAErrorList.ToggleAutoHide(); } if (DG_List.SelectedIndex < 0) { return; } ErrorReportElement inst = (ErrorReportElement)DG_List.SelectedItem; BaseViewModel bvmodel = inst.Prototype; int x = bvmodel.X; int y = bvmodel.Y; int network = int.Parse(inst.Network); string diagram = inst.Diagram; NavigateToNetworkEventArgs _e = new NavigateToNetworkEventArgs(network, diagram, x, y); parent.NavigateToNetwork(_e); }
private void DG_FList_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e) { if (!parent.MainWindow.LAErrorList.IsFloat && !parent.MainWindow.LAErrorList.IsDock) { LayoutSetting.AddDefaultDockWidthAnchorable( Properties.Resources.MainWindow_Error_List, parent.MainWindow.LAErrorList.AutoHideWidth.ToString()); LayoutSetting.AddDefaultDockHeighAnchorable( Properties.Resources.MainWindow_Error_List, parent.MainWindow.LAErrorList.AutoHideHeight.ToString()); parent.MainWindow.LAErrorList.ToggleAutoHide(); } if (DG_FList.SelectedIndex < 0) { return; } ErrorReportElement_FB ele = (ErrorReportElement_FB)DG_FList.SelectedItem; FuncBlockViewModel fbvmodel = ele.FBVModel; int line = ele.Line; int column = ele.Column; parent.NavigateToFuncBlock(fbvmodel, line, column); }
private void DG_List_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (!parent.MainWindow.LAReplace.IsFloat && !parent.MainWindow.LAReplace.IsDock) { LayoutSetting.AddDefaultDockWidthAnchorable( Properties.Resources.MainWindow_Replace, parent.MainWindow.LAReplace.AutoHideWidth.ToString()); LayoutSetting.AddDefaultDockHeighAnchorable( Properties.Resources.MainWindow_Replace, parent.MainWindow.LAReplace.AutoHideHeight.ToString()); parent.MainWindow.LAReplace.ToggleAutoHide(); } if (DG_List.SelectedIndex < 0) { return; } TextReplaceElement element = null; if (e.AddedItems.Count > 0) { element = (TextReplaceElement)(e.AddedItems[0]); } else if (e.RemovedItems.Count > 0) { element = (TextReplaceElement)(e.RemovedItems[0]); } else { return; } FuncBlockViewModel fbvmodel = element.FBVModel; int offset = element.Offset; int count = element.Word.Length; parent.NavigateToFuncBlock(fbvmodel, offset); fbvmodel.SetOffset(offset, count); }
void OnSplitterDragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e) { LayoutGridResizerControl splitter = sender as LayoutGridResizerControl; var rootVisual = this.FindVisualTreeRoot() as Visual; var trToWnd = TransformToAncestor(rootVisual); Vector transformedDelta = trToWnd.Transform(new Point(e.HorizontalChange, e.VerticalChange)) - trToWnd.Transform(new Point()); double delta; if (Orientation == System.Windows.Controls.Orientation.Horizontal) { delta = Canvas.GetLeft(_resizerGhost) - _initialStartPoint.X; } else { delta = Canvas.GetTop(_resizerGhost) - _initialStartPoint.Y; } int indexOfResizer = InternalChildren.IndexOf(splitter); var prevChild = InternalChildren[indexOfResizer - 1] as FrameworkElement; var nextChild = GetNextVisibleChild(indexOfResizer); var prevChildActualSize = prevChild.TransformActualSizeToAncestor(); var nextChildActualSize = nextChild.TransformActualSizeToAncestor(); var prevChildModel = (ILayoutPositionableElement)(prevChild as ILayoutControl).Model; var nextChildModel = (ILayoutPositionableElement)(nextChild as ILayoutControl).Model; if (Orientation == System.Windows.Controls.Orientation.Horizontal) { //Trace.WriteLine(string.Format("PrevChild From {0}", prevChildModel.DockWidth)); if (prevChildModel.DockWidth.IsStar) { prevChildModel.DockWidth = new GridLength(prevChildModel.DockWidth.Value * (prevChildActualSize.Width + delta) / prevChildActualSize.Width, GridUnitType.Star); } else { prevChildModel.DockWidth = new GridLength(prevChildModel.DockWidth.Value + delta, GridUnitType.Pixel); } //Trace.WriteLine(string.Format("PrevChild To {0}", prevChildModel.DockWidth)); //Trace.WriteLine(string.Format("NextChild From {0}", nextChildModel.DockWidth)); if (nextChildModel.DockWidth.IsStar) { nextChildModel.DockWidth = new GridLength(nextChildModel.DockWidth.Value * (nextChildActualSize.Width - delta) / nextChildActualSize.Width, GridUnitType.Star); } else { nextChildModel.DockWidth = new GridLength(nextChildModel.DockWidth.Value - delta, GridUnitType.Pixel); } //Trace.WriteLine(string.Format("NextChild To {0}", nextChildModel.DockWidth)); } else { //Trace.WriteLine(string.Format("PrevChild From {0}", prevChildModel.DockHeight)); if (prevChildModel.DockHeight.IsStar) { prevChildModel.DockHeight = new GridLength(prevChildModel.DockHeight.Value * (prevChildActualSize.Height + delta) / prevChildActualSize.Height, GridUnitType.Star); } else { prevChildModel.DockHeight = new GridLength(prevChildModel.DockHeight.Value + delta, GridUnitType.Pixel); } //Trace.WriteLine(string.Format("PrevChild To {0}", prevChildModel.DockHeight)); //Trace.WriteLine(string.Format("NextChild From {0}", nextChildModel.DockHeight)); if (nextChildModel.DockHeight.IsStar) { nextChildModel.DockHeight = new GridLength(nextChildModel.DockHeight.Value * (nextChildActualSize.Height - delta) / nextChildActualSize.Height, GridUnitType.Star); } else { nextChildModel.DockHeight = new GridLength(nextChildModel.DockHeight.Value - delta, GridUnitType.Pixel); } //Trace.WriteLine(string.Format("NextChild To {0}", nextChildModel.DockHeight)); } HideResizerOverlayWindow(); if (prevChildModel is LayoutAnchorablePane) { foreach (LayoutAnchorable anchor in ((LayoutAnchorablePane)(prevChildModel)).Children) { LayoutSetting.AddDefaultDockWidthAnchorable(anchor.Title, prevChildModel.DockWidth.ToString()); LayoutSetting.AddDefaultDockHeighAnchorable(anchor.Title, prevChildModel.DockHeight.ToString()); } } if (nextChildModel is LayoutAnchorablePane) { foreach (LayoutAnchorable anchor in ((LayoutAnchorablePane)(nextChildModel)).Children) { LayoutSetting.AddDefaultDockWidthAnchorable(anchor.Title, nextChildModel.DockWidth.ToString()); LayoutSetting.AddDefaultDockHeighAnchorable(anchor.Title, nextChildModel.DockHeight.ToString()); } } if (prevChildModel is LayoutAnchorable) { LayoutSetting.AddDefaultDockWidthAnchorable(((LayoutAnchorable)(prevChildModel)).Title, prevChildModel.DockWidth.ToString()); LayoutSetting.AddDefaultDockHeighAnchorable(((LayoutAnchorable)(prevChildModel)).Title, prevChildModel.DockHeight.ToString()); } if (nextChildModel is LayoutAnchorable) { LayoutSetting.AddDefaultDockWidthAnchorable(((LayoutAnchorable)(nextChildModel)).Title, nextChildModel.DockWidth.ToString()); LayoutSetting.AddDefaultDockHeighAnchorable(((LayoutAnchorable)(nextChildModel)).Title, nextChildModel.DockHeight.ToString()); } }