private void GraphEditCircuit() { if (CircuitsTreeView.SelectedItem == null) { return; } if (CircuitsTreeView.SelectedItem.GetType() == typeof(Circuit)) { var circuit = (Circuit)CircuitsTreeView.SelectedItem; var addCircuitWindow = new GraphicalConfigCircuit(circuit.Info) { Owner = this }; if (addCircuitWindow.ShowDialog() != true) { return; } circuit.FlushCircuitStyle(_zoomScale); CircuitsTreeView.ItemsSource = null; CircuitsTreeView.ItemsSource = _circuits; } else if (CircuitsTreeView.SelectedItem.GetType() == typeof(Dot)) { var dot = (Dot)CircuitsTreeView.SelectedItem; var editDotWindow = new GraphicalConfigDot(dot) { Owner = this }; editDotWindow.ShowDialog(); } }
//private void FlushSelectedCanvas(Point endPosition) //{ // _selectCanvas.Children.Clear(); // Canvas line1 = MyLine.DrawLine(2, 0, endPosition.Y - _startPosition.Y, 1, Colors.Red); // Canvas line2 = MyLine.DrawLine(2, 0, endPosition.Y - _startPosition.Y, 1, Colors.Red); // Canvas line3 = MyLine.DrawLine(2, endPosition.X - _startPosition.X, 0, 1, Colors.Red); // Canvas line4 = MyLine.DrawLine(2, endPosition.X - _startPosition.X, 0, 1, Colors.Red); // Canvas.SetLeft(line2, endPosition.X - _startPosition.X); // Canvas.SetTop(line4, endPosition.Y - _startPosition.Y); // _selectCanvas.Children.Add(line1); // _selectCanvas.Children.Add(line2); // _selectCanvas.Children.Add(line3); // _selectCanvas.Children.Add(line4); //} //private void Mask_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //{ // ZoomCanvas.MouseMove += image_MouseMove; // ZoomCanvas.MouseLeftButtonUp += Mask_MouseLeftButtonUp; // _startPosition = e.GetPosition(ZoomCanvas); // Canvas.SetLeft(_selectCanvas, e.GetPosition(ZoomCanvas).X); // Canvas.SetTop(_selectCanvas, e.GetPosition(ZoomCanvas).Y); //} //private void image_MouseMove(object sender, MouseEventArgs e) //{ // if (e.LeftButton == MouseButtonState.Pressed) // { // _selectCanvas.Opacity = 1; // FlushSelectedCanvas(e.GetPosition(ZoomCanvas)); // } // else // { // _selectCanvas.Opacity = 0; // ZoomCanvas.MouseMove -= image_MouseMove; // ZoomCanvas.MouseLeftButtonUp -= Mask_MouseLeftButtonUp; // } //} //private void Mask_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) //{ // Canvas board = sender as Canvas; // ZoomCanvas.MouseMove -= image_MouseMove; // ZoomCanvas.MouseLeftButtonUp -= Mask_MouseLeftButtonUp; // _selectCanvas.Opacity = 0; //} #endregion #region 回路 #region 添加 private void MenuAddCircuit_Click(object sender, RoutedEventArgs e) { var info = new CircuitInfo { ParentCableId = Cable.CableId, CircuitId = _circuits.Max(circuit => circuit.Info.CircuitId) + 1 }; info.Name = "回路" + info.CircuitId; var newCircuit = new GraphicalConfigCircuit(info) { Owner = this }; if (newCircuit.ShowDialog() == true) { GraphAddCircuit(newCircuit.CurCircuit); } }
private void BtnModifyAllStyle_Click(object sender, RoutedEventArgs e) { var info = new CircuitInfo { ParentCableId = Cable.CableId, Name = "回路" }; var newCircuit = new GraphicalConfigCircuit(info) { Owner = this }; if (newCircuit.ShowDialog() != true) { return; } foreach (var circuit in _circuits) { circuit.FlushCircuitStyle(newCircuit.CurCircuit, _zoomScale); } CircuitsTreeView.ItemsSource = null; CircuitsTreeView.ItemsSource = _circuits; }