private void OnDiagramConnectionManipulationStarted(object sender, ManipulationRoutedEventArgs e) { if (e.ManipulationStatus == Windows.Diagrams.Core.ManipulationStatus.Detaching) { e.Handled = true; } }
/// <summary> /// When linking nodes, adds source connector to the diagram's view model for information access. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MyDiagram_ConnectionManipulationStarted(object sender, ManipulationRoutedEventArgs e) { if (e.ManipulationStatus == ManipulationStatus.Attaching) { var connector = e.Connector as BaseConnector; if (connector != null && connector.DataContext is ConnectorViewModel) { var viewModel = connector.DataContext as ConnectorViewModel; if (viewModel.CanConnect()) { sourceConnector = connector; diagramViewModel.SourceConnector = viewModel; return; } else { viewModel.IsConnected = false; } } } sourceConnector = null; diagramViewModel.SourceConnector = null; diagramViewModel.TargetConnector = null; e.Handled = true; }
private void Diagram_ConnectionManipulationStarted(object sender, ManipulationRoutedEventArgs e) { if (e.Shape != null) { this.oldVertex = (e.Shape as RadDiagramShape).DataContext as Vertex; } else { this.oldVertex = null; } }
private void diagram_ConnectionManipulationCompleted_1(object sender, ManipulationRoutedEventArgs e) { ChooseConnectionType win = new ChooseConnectionType(); if (win.ShowDialog() == true) { var ConnectionContents = new ConnectionXML(); Window wind = null; switch (win.SelectedIndex) { case ConnectionTypes.eDecision: wind = new DecisionSettings(ConnectionContents); break; case ConnectionTypes.eChance: wind = new ChanceSettings(ConnectionContents); break; case ConnectionTypes.eBattle: wind = new BattleSettings(ConnectionContents); break; case ConnectionTypes.eCondition: wind = new ConditionSettings(ConnectionContents); break; case ConnectionTypes.eChanceRollback: { wind = new RollBackSettings(ConnectionContents); break; } case ConnectionTypes.eInventoryCondition: throw new ArgumentOutOfRangeException(); break; default: throw new ArgumentOutOfRangeException(); } ConnectionContents.Type = win.SelectedIndex; this.IgnoreSelection = true; if (wind != null && wind.ShowDialog() == true) { e.Connection.TargetCapType = CapType.Arrow1Filled; e.Connection.Content = ConnectionContents; return; } // this.IgnoreSelection = false; } this.diagram.RemoveConnection(e.Connection); }
/// <summary> /// When linking nodes, updates source's and target's data contexts. /// If linking is possible, updates target connector of diagram view model with target's view model. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MyDiagram_ConnectionManipulationCompleted(object sender, ManipulationRoutedEventArgs e) { if (sourceConnector != null && e.Connector != null && e.Connector != sourceConnector && e.ManipulationStatus == ManipulationStatus.Attaching) { var sourceConnectorViewModel = sourceConnector.DataContext as ConnectorViewModel; var targetConnector = e.Connector as BaseConnector; var targetConnectorViewModel = targetConnector.DataContext as ConnectorViewModel; if (targetConnectorViewModel.CanConnectTo(sourceConnectorViewModel)) { diagramViewModel.TargetConnector = targetConnectorViewModel; return; } } (sourceConnector.DataContext as ConnectorViewModel).IsConnected = false; sourceConnector = null; diagramViewModel.SourceConnector = null; diagramViewModel.TargetConnector = null; e.Handled = true; }
private void OnConnectionManipulationCompleted(object sender, ManipulationRoutedEventArgs e) { if (e.ManipulationPoint.Type != ManipulationPointType.Intermediate) e.Handled = e.Shape == null; }
private void NaviDiagram_ConnectionManipulationCompleted(object sender, ManipulationRoutedEventArgs e) { IShape source = null; IShape target = null; try { source = e.Connection.Source; target = e.Connector.Shape; RadDiagramConnection con = e.Connection as RadDiagramConnection; con.TargetCapType = CapType.Arrow2Filled; con.Stroke = new SolidColorBrush(Colors.Black); con.StrokeThickness = 2; con.Foreground = new SolidColorBrush(Colors.Black); con.IsEditable = false; } catch { } //소스가 null 이면 삭제 if (source == null) { e.Handled = true; return; } //타겟이 null 이면 삭제 if (target == null) { e.Handled = true; return; } //같은 포트에 연결 하였다면 삭제 if (source == target) { e.Handled = true; return; } //같은 지점을 target으로 잡으면 안된다. var checkdata = Navidiagram.Items.OfType <RadDiagramConnection>().Where(x => x.Target == target).ToList(); if (checkdata.Count >= 1) { e.Handled = true; return; } //목적지에서 다음 경로로 연결 할 수 없다. if (source is NaviShape) { NaviShape check = source as NaviShape; if (check.PointType == "2") { e.Handled = true; return; } } //시작지점이 중간 경로가 될 수 없다. if (target is NaviShape) { NaviShape check = target as NaviShape; if (check.PointType == "0") { e.Handled = true; return; } } //시작지점에서 커넥션이 1개만 있어야 한다. if (source is NaviShape) { NaviShape check = source as NaviShape; var cons = Navidiagram.Items.OfType <RadDiagramConnection>().Where(x => x.Source == check).ToList(); if (cons.Count == 1) { e.Handled = true; return; } } }