public DesignerItemViewModelBase(int id, IDiagramViewModel parent, double left, double top) : base(id, parent) { this.left = left; this.top = top; Init(); }
public DesignerItemViewModel(IDiagramViewModel diagram, ComponentBase component) : base(diagram) { Component = component; Init(); }
public ActivityItemViewModel(IDiagramViewModel parent) : base(parent) { Settings = new ObservableCollection <SettingInfo>(); visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService; ShowDataChangeWindowCommand = new SimpleCommand(ExecuteShowDataChangeWindowCommand); this.ShowConnectors = false; }
protected override void OnMouseDown(MouseButtonEventArgs e) { base.OnMouseDown(e); if (this.DataContext is DesignerItemViewModelBase) { initialDragPoint = e.GetPosition(this); Mouse.SetCursor(Cursors.SizeAll); e.Handled = true; } else { if (e.LeftButton == MouseButtonState.Pressed) { //if we are source of event, we are rubberband selecting if (e.Source == this) { // in case that this click is the start for a // drag operation we cache the start point rubberbandSelectionStartPoint = e.GetPosition(this); IDiagramViewModel vm = (this.DataContext as IDiagramViewModel); if (!(Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))) { vm.ClearSelectedItemsCommand.Execute(null); } e.Handled = true; } } } }
private void UpdateSelection() { IDiagramViewModel vm = (designerCanvas.DataContext as IDiagramViewModel); Rect rubberBand = new Rect(startPoint.Value, endPoint.Value); ItemsControl itemsControl = GetParent <ItemsControl>(typeof(ItemsControl), designerCanvas); foreach (SelectableDesignerItemViewModelBase item in vm.Items) { if (item is SelectableDesignerItemViewModelBase) { DependencyObject container = itemsControl.ItemContainerGenerator.ContainerFromItem(item); Rect itemRect = VisualTreeHelper.GetDescendantBounds((Visual)container); Rect itemBounds = ((Visual)container).TransformToAncestor(designerCanvas).TransformBounds(itemRect); if (rubberBand.Contains(itemBounds)) { item.IsSelected = true; } else { if (!(Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))) { item.IsSelected = false; } } } } }
public DesignerItemViewModelBase(int id, IDiagramViewModel parent, double left, double top, double itemWidth, double itemHeight) : base(id, parent) { this.left = left; this.top = top; this.itemWidth = itemWidth; this.itemHeight = itemHeight; Init(); }
/// <summary> /// Start the drag operation. /// </summary> private void Start() { diagramDesigner = DiagramHelper.GetDiagramDesigner(this); diagramDesignerVM = diagramDesigner.DataContext as IDiagramViewModel; selectedItems = new List<DiagramDesignerItem>(); selectedItemsVM = new List<IDiagramItemViewModel>(); List<ISelectable> selection = diagramDesigner.SelectionService.CurrentSelection; foreach (ISelectable item in selection) { if (item is DiagramDesignerItem) if (!(item as DiagramDesignerItem).IsDiagramLink) { selectedItems.Add(item as DiagramDesignerItem); } } // create control to display on the drag adorner Canvas canvas = new Canvas(); foreach (DiagramDesignerItem item in selectedItems) { IDiagramItemViewModel designerItem = item.DataContext as IDiagramItemViewModel; if (designerItem == null) continue; selectedItemsVM.Add(designerItem); Rectangle r = new Rectangle(); r.Stroke = new SolidColorBrush(Colors.Black); r.StrokeDashArray = new DoubleCollection(); r.StrokeDashArray.Add(3); r.StrokeDashArray.Add(6); r.StrokeThickness = 1.0; r.Width = item.ActualWidth; r.Height = item.ActualHeight; r.Margin = new System.Windows.Thickness(designerItem.AbsoluteLocation.X, designerItem.AbsoluteLocation.Y, 0, 0); canvas.Children.Add(r); } // create drag adorner if (diagramDesigner != null) { AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(diagramDesigner); if (adornerLayer != null) { this.dragAdorner = new DragAdorner(diagramDesigner, canvas, false, 1.0); if (this.dragAdorner != null) { adornerLayer.Add(this.dragAdorner); //e.Handled = true; } } } //e.Handled = false; }
public NodeDesignerItemViewModel(int id, IDiagramViewModel parent, double left, double top, string businessObj, string nodeType, string key, string desc) : base(id, parent, left, top) { BusinessObj = businessObj; NodeType = nodeType; Key = key; Desc = desc; init(); }
/// <summary> /// Initializes a new instance of the <see cref="FunctionExpressionNode"/> class. /// </summary> /// <param name="diagramViewModel">The diagram view model.</param> /// <param name="expressionObject">The expression object.</param> /// <exception cref="System.ArgumentNullException">expressionObject</exception> public FunctionExpressionNode(IDiagramViewModel diagramViewModel, FunctionExpression expressionObject) : base(expressionObject) { if (expressionObject == null) throw new ArgumentNullException("expressionObject"); _diagramViewModel = diagramViewModel; IsValidFunc = n => true; UpdateAction = n => { }; ConnectorOut = new ExpressionConnectorViewModel(new ExpressionConnector(ConnectorType.Out, expressionObject.ConnectorOut), _diagramViewModel); }
public NodeDesignerItemViewModel(NodeDesignerItem item, IDiagramViewModel parent) : base(item.Id, parent, item.Left, item.Top) { Value = item.Value; //Id = item.Id; BusinessObj = item.BusinessObj; NodeType = item.NodeType; Key = item.Key; Desc = item.Desc; init(); }
/// <summary> /// Initializes a new instance of the <see cref="OneInTwoOutExpressionNode"/> class. /// </summary> /// <param name="diagramViewModel"> /// The diagram view model. /// </param> /// <param name="expressionObject"> /// The expression object. /// </param> /// <exception cref="ArgumentNullException"> /// The <paramref name="expressionObject"/> parameter is null. /// </exception> public OneInTwoOutExpressionNode(IDiagramViewModel diagramViewModel, OneInTwoOutExpression expressionObject) : base(expressionObject) { if (expressionObject == null) throw new ArgumentNullException("expressionObject"); _diagramViewModel = diagramViewModel; ConnectorIn = new ExpressionConnectorViewModel(new ExpressionConnector(ConnectorType.In, expressionObject.ConnectorIn), _diagramViewModel); Connector1Out = new ExpressionConnectorViewModel(new ExpressionConnector(ConnectorType.Out, expressionObject.Connector1Out), _diagramViewModel); Connector2Out = new ExpressionConnectorViewModel(new ExpressionConnector(ConnectorType.Out, expressionObject.Connector2Out), _diagramViewModel); }
public ConverterExpressionNode(IDiagramViewModel diagramViewModel, ConverterExpression expressionObject) : base(expressionObject) { if (expressionObject == null) throw new ArgumentNullException("expressionObject"); _diagramViewModel = diagramViewModel; IsValidFunc = n => true; UpdateAction = n => { }; ConnectorIn = new ExpressionConnectorViewModel(new ExpressionConnector(ConnectorType.In, expressionObject.ConnectorIn), _diagramViewModel); ConnectorOut = new ExpressionConnectorViewModel(new ExpressionConnector(ConnectorType.Out, expressionObject.ConnectorOut), _diagramViewModel); RaisePropertyChanged("ConvertDirection"); }
static void Fe_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { SelectableDesignerItemViewModelBase selectableDesignerItemViewModelBase = (SelectableDesignerItemViewModelBase)((FrameworkElement)sender).DataContext; if (selectableDesignerItemViewModelBase != null) { if ((Keyboard.Modifiers & (ModifierKeys.Shift | ModifierKeys.Control)) != ModifierKeys.None) { if ((Keyboard.Modifiers & (ModifierKeys.Shift)) != ModifierKeys.None) { selectableDesignerItemViewModelBase.IsSelected = !selectableDesignerItemViewModelBase.IsSelected; } if ((Keyboard.Modifiers & (ModifierKeys.Control)) != ModifierKeys.None) { selectableDesignerItemViewModelBase.IsSelected = !selectableDesignerItemViewModelBase.IsSelected; } } else if (!selectableDesignerItemViewModelBase.IsSelected) { foreach (SelectableDesignerItemViewModelBase item in selectableDesignerItemViewModelBase.Parent.SelectedItems) { if (item is IDiagramViewModel) { IDiagramViewModel tmp = (IDiagramViewModel)item; foreach (SelectableDesignerItemViewModelBase gItem in tmp.Items) { gItem.IsSelected = false; } } if (selectableDesignerItemViewModelBase.Parent is SelectableDesignerItemViewModelBase) { SelectableDesignerItemViewModelBase tmp = (SelectableDesignerItemViewModelBase)selectableDesignerItemViewModelBase.Parent; tmp.IsSelected = false; } item.IsSelected = false; } if (selectableDesignerItemViewModelBase is IDiagramViewModel) { IDiagramViewModel tmp = (IDiagramViewModel)selectableDesignerItemViewModelBase; foreach (SelectableDesignerItemViewModelBase gItem in tmp.Items) { gItem.IsSelected = false; } } selectableDesignerItemViewModelBase.Parent.SelectedItems.Clear(); selectableDesignerItemViewModelBase.IsSelected = true; } } }
/// <summary> /// Dragging has started, see if VM is IDiagramLinkViewModel and notify of moving start. /// </summary> void DragThumb_DragStarted(object sender, DragStartedEventArgs e) { diagramDesigner = DiagramHelper.GetDiagramDesigner(this); diagramDesignerVM = diagramDesigner.DataContext as IDiagramViewModel; selectedItem = null; selectedItemVM = null; edgePointVM = this.DataContext as IEdgePointViewModel; List <ISelectable> selection = diagramDesigner.SelectionService.CurrentSelection; if (selection.Count == 1) { foreach (ISelectable item in selection) { if (item is DiagramDesignerItem) { if ((item as DiagramDesignerItem).IsDiagramLink) { selectedItem = item as DiagramDesignerItem; } } } // create control to display on the drag adorner dragCanvas = new Canvas(); IDiagramLinkViewModel designerItem = selectedItem.DataContext as IDiagramLinkViewModel; selectedItemVM = designerItem; AddLinkAnchorAndShape(new PointD(designerItem.StartEdgePoint.X, designerItem.StartEdgePoint.Y), new PointD(designerItem.EndEdgePoint.X, designerItem.EndEdgePoint.Y)); // create drag adorner if (diagramDesigner != null && selectedItemVM != null && selectedItem != null && edgePointVM != null) { AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(diagramDesigner); if (adornerLayer != null) { this.dragAdorner = new DragAdorner(diagramDesigner, dragCanvas, false, 1.0); if (this.dragAdorner != null) { adornerLayer.Add(this.dragAdorner); e.Handled = true; } } } } e.Handled = false; }
private void LoadPerstistDesignerItems(IDiagramItem wholeDiagramToLoad, IDiagramViewModel diagramViewModel) { //load diagram items foreach (DiagramItemData diagramItemData in wholeDiagramToLoad.DesignerItems) { if (diagramItemData.ItemType == typeof(PersistDesignerItem)) { PersistDesignerItem persistedDesignerItem = databaseAccessService.FetchPersistDesignerItem(diagramItemData.ItemId); PersistDesignerItemViewModel persistDesignerItemViewModel = new PersistDesignerItemViewModel(persistedDesignerItem.Id, diagramViewModel, persistedDesignerItem.Left, persistedDesignerItem.Top, persistedDesignerItem.ItemWidth, persistedDesignerItem.ItemHeight, persistedDesignerItem.HostUrl); diagramViewModel.Items.Add(persistDesignerItemViewModel); } if (diagramItemData.ItemType == typeof(SettingsDesignerItem)) { SettingsDesignerItem settingsDesignerItem = databaseAccessService.FetchSettingsDesignerItem(diagramItemData.ItemId); SettingsDesignerItemViewModel settingsDesignerItemViewModel = new SettingsDesignerItemViewModel(settingsDesignerItem.Id, diagramViewModel, settingsDesignerItem.Left, settingsDesignerItem.Top, settingsDesignerItem.ItemWidth, settingsDesignerItem.ItemHeight, settingsDesignerItem.Setting1); diagramViewModel.Items.Add(settingsDesignerItemViewModel); } if (diagramItemData.ItemType == typeof(GroupDesignerItem)) { GroupDesignerItem groupDesignerItem = databaseAccessService.FetchGroupingDesignerItem(diagramItemData.ItemId); GroupingDesignerItemViewModel groupingDesignerItemViewModel = new GroupingDesignerItemViewModel(groupDesignerItem.Id, diagramViewModel, groupDesignerItem.Left, groupDesignerItem.Top, groupDesignerItem.ItemWidth, groupDesignerItem.ItemHeight); if (groupDesignerItem.DesignerItems != null && groupDesignerItem.DesignerItems.Count > 0) { LoadPerstistDesignerItems(groupDesignerItem, groupingDesignerItemViewModel); } diagramViewModel.Items.Add(groupingDesignerItemViewModel); } } //load connection items foreach (int connectionId in wholeDiagramToLoad.ConnectionIds) { Connection connection = databaseAccessService.FetchConnection(connectionId); DesignerItemViewModelBase sourceItem = GetConnectorDataItem(diagramViewModel, connection.SourceId, connection.SourceType); ConnectorOrientation sourceConnectorOrientation = GetOrientationForConnector(connection.SourceOrientation); FullyCreatedConnectorInfo sourceConnectorInfo = GetFullConnectorInfo(connection.Id, sourceItem, sourceConnectorOrientation); DesignerItemViewModelBase sinkItem = GetConnectorDataItem(diagramViewModel, connection.SinkId, connection.SinkType); ConnectorOrientation sinkConnectorOrientation = GetOrientationForConnector(connection.SinkOrientation); FullyCreatedConnectorInfo sinkConnectorInfo = GetFullConnectorInfo(connection.Id, sinkItem, sinkConnectorOrientation); ConnectorViewModel connectionVM = new ConnectorViewModel(connection.Id, diagramViewModel, sourceConnectorInfo, sinkConnectorInfo); diagramViewModel.Items.Add(connectionVM); } }
/// <summary> /// Dragging has started, see if VM is IDiagramLinkViewModel and notify of moving start. /// </summary> void DragThumb_DragStarted(object sender, DragStartedEventArgs e) { diagramDesigner = DiagramHelper.GetDiagramDesigner(this); diagramDesignerVM = diagramDesigner.DataContext as IDiagramViewModel; selectedItem = null; selectedItemVM = null; edgePointVM = this.DataContext as IEdgePointViewModel; List<ISelectable> selection = diagramDesigner.SelectionService.CurrentSelection; if (selection.Count == 1) { foreach (ISelectable item in selection) { if (item is DiagramDesignerItem) if ((item as DiagramDesignerItem).IsDiagramLink) { selectedItem = item as DiagramDesignerItem; } } // create control to display on the drag adorner dragCanvas = new Canvas(); IDiagramLinkViewModel designerItem = selectedItem.DataContext as IDiagramLinkViewModel; selectedItemVM = designerItem; AddLinkAnchorAndShape(new PointD(designerItem.StartEdgePoint.X, designerItem.StartEdgePoint.Y), new PointD(designerItem.EndEdgePoint.X, designerItem.EndEdgePoint.Y)); // create drag adorner if (diagramDesigner != null && selectedItemVM != null && selectedItem != null && edgePointVM != null) { AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(diagramDesigner); if (adornerLayer != null) { this.dragAdorner = new DragAdorner(diagramDesigner, dragCanvas, false, 1.0); if (this.dragAdorner != null) { adornerLayer.Add(this.dragAdorner); e.Handled = true; } } } } e.Handled = false; }
private void SavePersistDesignerItem(IDiagramItem wholeDiagramToSave, IDiagramViewModel diagramViewModel) { //Save all PersistDesignerItemViewModel foreach (var persistItemVM in diagramViewModel.Items.OfType <PersistDesignerItemViewModel>()) { PersistDesignerItem persistDesignerItem = new PersistDesignerItem(persistItemVM.Id, persistItemVM.Left, persistItemVM.Top, persistItemVM.ItemWidth, persistItemVM.ItemHeight, persistItemVM.HostUrl); persistItemVM.Id = databaseAccessService.SavePersistDesignerItem(persistDesignerItem); wholeDiagramToSave.DesignerItems.Add(new DiagramItemData(persistDesignerItem.Id, typeof(PersistDesignerItem))); } //Save all SettingsDesignerItemViewModel foreach (var settingsItemVM in diagramViewModel.Items.OfType <SettingsDesignerItemViewModel>()) { SettingsDesignerItem settingsDesignerItem = new SettingsDesignerItem(settingsItemVM.Id, settingsItemVM.Left, settingsItemVM.Top, settingsItemVM.ItemWidth, settingsItemVM.ItemHeight, settingsItemVM.Setting1); settingsItemVM.Id = databaseAccessService.SaveSettingDesignerItem(settingsDesignerItem); wholeDiagramToSave.DesignerItems.Add(new DiagramItemData(settingsDesignerItem.Id, typeof(SettingsDesignerItem))); } //Save all GroupingDesignerItemViewModel foreach (var groupingItemVM in diagramViewModel.Items.OfType <GroupingDesignerItemViewModel>()) { GroupDesignerItem groupDesignerItem = new GroupDesignerItem(groupingItemVM.Id, groupingItemVM.Left, groupingItemVM.Top, groupingItemVM.ItemWidth, groupingItemVM.ItemHeight); if (groupingItemVM.Items != null && groupingItemVM.Items.Count > 0) { SavePersistDesignerItem(groupDesignerItem, groupingItemVM); } groupingItemVM.Id = databaseAccessService.SaveGroupingDesignerItem(groupDesignerItem); wholeDiagramToSave.DesignerItems.Add(new DiagramItemData(groupDesignerItem.Id, typeof(GroupDesignerItem))); } //Save all connections which should now have their Connection.DataItems filled in with correct Ids foreach (var connectionVM in diagramViewModel.Items.OfType <ConnectorViewModel>()) { FullyCreatedConnectorInfo sinkConnector = connectionVM.SinkConnectorInfo as FullyCreatedConnectorInfo; Connection connection = new Connection( connectionVM.Id, connectionVM.SourceConnectorInfo.DataItem.Id, GetOrientationFromConnector(connectionVM.SourceConnectorInfo.Orientation), GetTypeOfDiagramItem(connectionVM.SourceConnectorInfo.DataItem), sinkConnector.DataItem.Id, GetOrientationFromConnector(sinkConnector.Orientation), GetTypeOfDiagramItem(sinkConnector.DataItem)); connectionVM.Id = databaseAccessService.SaveConnection(connection); wholeDiagramToSave.ConnectionIds.Add(connectionVM.Id); } }
/// <summary> /// Constructor /// </summary> /// <param name="designer">Diagram designer.</param> /// <param name="sourceConnector">Source item of the relationship.</param> /// <param name="startPoint">Start point.</param> public DiagramConnectorAdorner(DiagramDesigner designer, DiagramConnector sourceConnector, Point startPoint) : base(designer) { this.diagramDesigner = designer; if (this.diagramDesigner.DataContext is IDiagramViewModel) diagramDesignerVM = this.diagramDesigner.DataContext as IDiagramViewModel; this.sourceConnector = sourceConnector; this.startPoint = startPoint; sourceItem = sourceConnector.DiagramItem; //if (sourceConnector.DiagramItem is ISelectable) // this.sourceElement = (sourceConnector.DiagramItem as ISelectable).SelectedData; drawingPen = new Pen(Brushes.LightSlateGray, 1); drawingPen.LineJoin = PenLineJoin.Round; this.Cursor = Cursors.Cross; }
private DesignerItemViewModelBase GetConnectorDataItem(IDiagramViewModel diagramViewModel, int conectorDataItemId, Type connectorDataItemType) { DesignerItemViewModelBase dataItem = null; if (connectorDataItemType == typeof(PersistDesignerItem)) { dataItem = diagramViewModel.Items.OfType <PersistDesignerItemViewModel>().Single(x => x.Id == conectorDataItemId); } if (connectorDataItemType == typeof(SettingsDesignerItem)) { dataItem = diagramViewModel.Items.OfType <SettingsDesignerItemViewModel>().Single(x => x.Id == conectorDataItemId); } if (connectorDataItemType == typeof(GroupDesignerItem)) { dataItem = diagramViewModel.Items.OfType <GroupingDesignerItemViewModel>().Single(x => x.Id == conectorDataItemId); } return(dataItem); }
/// <summary> /// Constructor /// </summary> /// <param name="designer">Diagram designer.</param> /// <param name="sourceConnector">Source item of the relationship.</param> /// <param name="startPoint">Start point.</param> public DiagramConnectorAdorner(DiagramDesigner designer, DiagramConnector sourceConnector, Point startPoint) : base(designer) { this.diagramDesigner = designer; if (this.diagramDesigner.DataContext is IDiagramViewModel) { diagramDesignerVM = this.diagramDesigner.DataContext as IDiagramViewModel; } this.sourceConnector = sourceConnector; this.startPoint = startPoint; sourceItem = sourceConnector.DiagramItem; //if (sourceConnector.DiagramItem is ISelectable) // this.sourceElement = (sourceConnector.DiagramItem as ISelectable).SelectedData; drawingPen = new Pen(Brushes.LightSlateGray, 1); drawingPen.LineJoin = PenLineJoin.Round; this.Cursor = Cursors.Cross; }
protected SelectableDesignerItemViewModelBase(int id, IDiagramViewModel parent) { Id = id; Parent = parent; Init(); }
public SettingsDesignerItemViewModel(int id, IDiagramViewModel parent, double left, double top, double itemWidth, double itemHeight, string setting1) : base(id, parent, left, top, itemWidth, itemHeight) { this.Setting1 = setting1; Init(); }
public ConnectorViewModel(FullyCreatedConnectorInfo sourceConnectorInfo, ConnectorInfoBase sinkConnectorInfo, IDiagramViewModel parent) : base(_currentConnectorId, parent) { if (sinkConnectorInfo != null && sinkConnectorInfo.Orientation != ConnectorOrientation.None) { _currentConnectorId++; } Init(sourceConnectorInfo, sinkConnectorInfo); }
/// <summary> /// Adds the field node. /// </summary> /// <param name="item">The item.</param> /// <param name="diagramViewModel">The diagram view model.</param> private static void AddFieldNode(DestinationFieldList item, IDiagramViewModel diagramViewModel) { var dfl = new DestinationFieldsExpressionNode(diagramViewModel, item); diagramViewModel.Items.Add(new NodeViewModel<DestinationFieldsExpressionNode, ExpressionConnection>(dfl, diagramViewModel)); }
protected SelectableDesignerItemViewModelBase(IDiagramViewModel diagram) { Diagram = diagram; }
/// <summary> /// Start the drag operation. /// </summary> private void Start() { if (direction == null) { if (base.VerticalAlignment == System.Windows.VerticalAlignment.Top) { if (base.HorizontalAlignment == System.Windows.HorizontalAlignment.Left) { direction = DiagramItemsResizeDirection.LeftTop; } else if (base.HorizontalAlignment == System.Windows.HorizontalAlignment.Stretch) { direction = DiagramItemsResizeDirection.Top; } else { direction = DiagramItemsResizeDirection.RightTop; } } else if (base.VerticalAlignment == System.Windows.VerticalAlignment.Bottom) { if (base.HorizontalAlignment == System.Windows.HorizontalAlignment.Left) { direction = DiagramItemsResizeDirection.LeftBottom; } else if (base.HorizontalAlignment == System.Windows.HorizontalAlignment.Stretch) { direction = DiagramItemsResizeDirection.Bottom; } else { direction = DiagramItemsResizeDirection.RightBottom; } } else { if (base.HorizontalAlignment == System.Windows.HorizontalAlignment.Left) { direction = DiagramItemsResizeDirection.Left; } else { direction = DiagramItemsResizeDirection.Right; } } } diagramDesigner = DiagramHelper.GetDiagramDesigner(this); diagramDesignerVM = diagramDesigner.DataContext as IDiagramViewModel; selectedItems = new List <DiagramDesignerItem>(); selectedItemsVM = new List <IDiagramItemViewModel>(); List <ISelectable> selection = diagramDesigner.SelectionService.CurrentSelection; foreach (ISelectable item in selection) { if (item is DiagramDesignerItem) { if (!(item as DiagramDesignerItem).IsDiagramLink) { selectedItems.Add(item as DiagramDesignerItem); } } } // create control to display on the drag adorner dragCanvas = new Canvas(); foreach (DiagramDesignerItem item in selectedItems) { if (item.DataContext is IDiagramItemViewModel) { selectedItemsVM.Add(item.DataContext as IDiagramItemViewModel); } Rectangle r = new Rectangle(); r.Stroke = new SolidColorBrush(Colors.Black); r.StrokeDashArray = new DoubleCollection(); r.StrokeDashArray.Add(3); r.StrokeDashArray.Add(6); r.StrokeThickness = 1.0; r.Width = item.ActualWidth; r.Height = item.ActualHeight; r.Margin = new System.Windows.Thickness(item.AbsoluteLocation.X, item.AbsoluteLocation.Y, 0, 0); dragCanvas.Children.Add(r); } // create drag adorner if (diagramDesigner != null) { AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(diagramDesigner); if (adornerLayer != null) { this.dragAdorner = new DragAdorner(diagramDesigner, dragCanvas, false, 1.0); if (this.dragAdorner != null) { adornerLayer.Add(this.dragAdorner); //e.Handled = true; } } } //e.Handled = false; }
/// <summary> /// Start the drag operation. /// </summary> private void Start() { diagramDesigner = DiagramHelper.GetDiagramDesigner(this); diagramDesignerVM = diagramDesigner.DataContext as IDiagramViewModel; selectedItems = new List <DiagramDesignerItem>(); selectedItemsVM = new List <IDiagramItemViewModel>(); List <ISelectable> selection = diagramDesigner.SelectionService.CurrentSelection; foreach (ISelectable item in selection) { if (item is DiagramDesignerItem) { if (!(item as DiagramDesignerItem).IsDiagramLink) { selectedItems.Add(item as DiagramDesignerItem); } } } // create control to display on the drag adorner Canvas canvas = new Canvas(); foreach (DiagramDesignerItem item in selectedItems) { IDiagramItemViewModel designerItem = item.DataContext as IDiagramItemViewModel; if (designerItem == null) { continue; } selectedItemsVM.Add(designerItem); Rectangle r = new Rectangle(); r.Stroke = new SolidColorBrush(Colors.Black); r.StrokeDashArray = new DoubleCollection(); r.StrokeDashArray.Add(3); r.StrokeDashArray.Add(6); r.StrokeThickness = 1.0; r.Width = item.ActualWidth; r.Height = item.ActualHeight; r.Margin = new System.Windows.Thickness(designerItem.AbsoluteLocation.X, designerItem.AbsoluteLocation.Y, 0, 0); canvas.Children.Add(r); } // create drag adorner if (diagramDesigner != null) { AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(diagramDesigner); if (adornerLayer != null) { this.dragAdorner = new DragAdorner(diagramDesigner, canvas, false, 1.0); if (this.dragAdorner != null) { adornerLayer.Add(this.dragAdorner); //e.Handled = true; } } } //e.Handled = false; }
/// <summary> /// Adds the fields as connectors. /// </summary> /// <param name="diagramViewModel">The diagram view model.</param> /// <param name="expressionObject">The expression object.</param> private void AddFieldsAsConnectors(IDiagramViewModel diagramViewModel, SourceFieldList expressionObject) { ConnectorsOut.Clear(); foreach (var node in expressionObject.Fields.OrderBy(x => x.Name)) { var connector = new ExpressionConnectorViewModel(new ExpressionConnector(ConnectorType.Out, node), diagramViewModel); ConnectorsOut.Add(connector); ExpandSubconnectors(connector, false, true); } }
/// <summary> /// Adds the field node. /// </summary> /// <param name="item">The item.</param> /// <param name="diagramViewModel">The diagram view model.</param> private static void AddFieldNode(FunctionExpression item, IDiagramViewModel diagramViewModel) { var dfl = new FunctionExpressionNode(diagramViewModel, item); diagramViewModel.Items.Add(new NodeViewModel<FunctionExpressionNode, ExpressionConnection>(dfl, diagramViewModel)); }
public SelectableDesignerItemViewModelBase(int id, IDiagramViewModel parent) { this.Id = id; this.Parent = parent; Init(); }
public ConnectionViewModel(IDiagramViewModel diagram, FullyCreatedConnectorInfo sourceConnectorInfo, FullyCreatedConnectorInfo sinkConnectorInfo) : base(diagram) { Init(sourceConnectorInfo, sinkConnectorInfo); }
/// <summary> /// Initializes a new instance of the <see cref="FormatValueExpressionNode"/> class. /// </summary> /// <param name="diagramViewModel"> /// The diagram view model. /// </param> /// <param name="expressionObject"> /// The expression object. /// </param> /// <exception cref="ArgumentNullException"> /// The <paramref name="expressionObject"/> parameter is null. /// </exception> public FormatValueExpressionNode(IDiagramViewModel diagramViewModel, FormatValueExpression expressionObject) : base(diagramViewModel, expressionObject) { _diagramViewModel = diagramViewModel; }
protected DesignerItemViewModelBase(int id, IDiagramViewModel parent, double left, double top) : base(id, parent) { _left = left; _top = top; Init(); }
/// <summary> /// Initializes a new instance of the <see cref="DestinationFieldsExpressionNode"/> class. /// </summary> /// <param name="diagramViewModel">The diagram view model.</param> /// <param name="expressionObject">The expression object.</param> /// <exception cref="System.ArgumentNullException">expressionObject</exception> public DestinationFieldsExpressionNode(IDiagramViewModel diagramViewModel, DestinationFieldList expressionObject) : base(expressionObject) { if (expressionObject == null) throw new ArgumentNullException("expressionObject"); _diagramViewModel = diagramViewModel; _connectorsIn.CollectionChanged += ConnectorsInCollectionChanged; IsValidFunc = n => true; UpdateAction = n => { }; foreach (var node in expressionObject.Fields) { var connector = new ExpressionConnectorViewModel(new ExpressionConnector(ConnectorType.In, node), diagramViewModel); ConnectorsIn.Add(connector); ExpandSubconnectors(connector, false, true); //ConnectorsIn.Add(new ExpressionConnectorViewModel(new ExpressionConnector(ConnectorType.In, node), diagramViewModel)); } }
public GroupingDesignerItemViewModel(int id, IDiagramViewModel parent, double left, double top) : base(id, parent, left, top) { Init(); }
/// <summary> /// Initializes a new instance of the <see cref="SourceFieldsExpressionNode"/> class. /// </summary> /// <param name="diagramViewModel">The diagram view model.</param> /// <param name="expressionObject">The expression object.</param> public SourceFieldsExpressionNode(IDiagramViewModel diagramViewModel, SourceFieldList expressionObject) : base(expressionObject) { _diagramViewModel = diagramViewModel; _connectorsOut.CollectionChanged += ConnectorsOutCollectionChanged; IsValidFunc = n => true; UpdateAction = n => { }; AddFieldsAsConnectors(diagramViewModel, expressionObject); }
public ConnectionValidator(IDiagramViewModel diagram, IMappingExpressionValidator expressionValidator, IExpressionNodeFactory expressionNodeFactory) { if (diagram == null) throw new ArgumentNullException("diagram"); if (expressionValidator == null) throw new ArgumentNullException("expressionValidator"); if (expressionNodeFactory == null) throw new ArgumentNullException("expressionNodeFactory"); _diagram = diagram; _expressionValidator = expressionValidator; _expressionNodeFactory = expressionNodeFactory; }
public DesignerItemViewModelBase(IDiagramViewModel parent, string imagePath = null) : base(_currentId++, parent) { ImagePath = imagePath; Init(); }
/// <summary> /// Initializes a new instance of the <see cref="ExpressionConnectorViewModel"/> class. /// </summary> /// <param name="diagramViewModel">The diagram view model.</param> public ExpressionConnectorViewModel(IDiagramViewModel diagramViewModel) { _diagramViewModel = diagramViewModel; }
public ConnectorViewModel(int id, IDiagramViewModel parent, FullyCreatedConnectorInfo sourceConnectorInfo, FullyCreatedConnectorInfo sinkConnectorInfo, Node left, Node right) : base(id,parent) { Init(sourceConnectorInfo, sinkConnectorInfo); Component = new CircuitSimulator.Component(left, right, DiagramViewModel.ZERO_RESISTANCE, 0); }
public GroupingDesignerItemViewModel(int id, IDiagramViewModel parent, double left, double top, double itemWidth, double itemHeight) : base(id, parent, left, top, itemWidth, itemHeight) { Init(); }
/// <summary> /// Translates to expression objects. /// </summary> /// <param name="expressionObjects">The expression objects.</param> /// <param name="diagramViewModel">The diagram view model.</param> /// <exception cref="System.ArgumentNullException"> /// diagramViewModel /// or /// expressionObjects /// </exception> public static void TranslateToExpressionObjects(IList<IExpressionObjectBase> expressionObjects, IDiagramViewModel diagramViewModel) { if (diagramViewModel == null) throw new ArgumentNullException("diagramViewModel"); if (expressionObjects == null) throw new ArgumentNullException("expressionObjects"); foreach (var diagramItem in diagramViewModel.Items) { if (diagramItem is INodeViewModel) { var exprObj = diagramItem.Item as ExpressionNodeBase; if (exprObj != null) { var obj = exprObj.ExpressionObject; expressionObjects.Add(obj); } } var connectionViewModel = diagramItem as IConnectionViewModel; if (connectionViewModel != null) { var obj = new Connection(); obj.Source = new ConnectorOut(obj) { Id = connectionViewModel.Source.Item.Id }; obj.Sink = new ConnectorIn(obj) { Id = connectionViewModel.Destination.Item.Id }; expressionObjects.Add(obj); } } }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (SourceConnector != null) { if (e.LeftButton == MouseButtonState.Pressed) { Point currentPoint = e.GetPosition(this); partialConnection.SinkConnectorInfo = new PartCreatedConnectionInfo(currentPoint); HitTesting(currentPoint); } } else { // if mouse button is not pressed we have no drag operation, ... if (e.LeftButton != MouseButtonState.Pressed) { rubberbandSelectionStartPoint = null; initialDragPoint = null; } if (this.initialDragPoint.HasValue && this.DataContext is DesignerItemViewModelBase) { Mouse.SetCursor(Cursors.SizeAll); DesignerItemViewModelBase item = (DesignerItemViewModelBase)this.DataContext; double minLeft = double.MaxValue; double minTop = double.MaxValue; Point currentPoint = e.GetPosition(this); IDiagramViewModel designerCanvas = item.Parent as IDiagramViewModel; Rect rekt = PointHelper.GetBoundingRectangle(designerCanvas.Items, 10); double left = item.Left; double top = item.Top; minLeft = double.IsNaN(left) ? 0 : Math.Min(left, minLeft); minTop = double.IsNaN(top) ? 0 : Math.Min(top, minTop); double deltaHorizontal = Math.Max(-minLeft, currentPoint.X - initialDragPoint.Value.X); double deltaVertical = Math.Max(-minTop, currentPoint.Y - initialDragPoint.Value.Y); item.Left += deltaHorizontal; item.Top += deltaVertical; if (item.Parent is IDiagramViewModel && item.Parent is DesignerItemViewModelBase) { DesignerItemViewModelBase groupItem = (DesignerItemViewModelBase)item.Parent; if (item.Left + item.ItemWidth >= groupItem.ItemWidth) { item.Left = groupItem.ItemWidth - item.ItemWidth; } if (item.Top + item.ItemHeight >= groupItem.ItemHeight) { item.Top = groupItem.ItemHeight - item.ItemHeight; } } e.Handled = true; } else { // ... but if mouse button is pressed and start // point value is set we do have one if (this.rubberbandSelectionStartPoint.HasValue) { // create rubberband adorner AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null) { RubberbandAdorner adorner = new RubberbandAdorner(this, rubberbandSelectionStartPoint); if (adorner != null) { adornerLayer.Add(adorner); } } } } } e.Handled = true; }
/// <summary> /// Translates to diagram. /// </summary> /// <param name="objects">The objects.</param> /// <param name="diagramViewModel">The diagram view model.</param> public static void TranslateToDiagram(ICollection<IExpressionObjectBase> objects, IDiagramViewModel diagramViewModel) { // restore all nodes first (non-connection), we will wire connections later foreach (var expression in from o in objects where !(o is IConnection) select o) { var sourceFieldList = expression as SourceFieldList; if (sourceFieldList != null) { AddFieldNode(sourceFieldList, diagramViewModel); continue; } var destinationFieldList = expression as DestinationFieldList; if (destinationFieldList != null) { AddFieldNode(destinationFieldList, diagramViewModel); continue; } var constantExpression = expression as ConstantExpression; if (constantExpression != null) { AddFieldNode(constantExpression, diagramViewModel); continue; } var converterExpression = expression as ConverterExpression; if (converterExpression != null) { AddFieldNode(converterExpression, diagramViewModel); continue; } var formatValueExpression = expression as FormatValueExpression; if (formatValueExpression != null) { AddFieldNode(formatValueExpression, diagramViewModel); continue; } var functionExpression = expression as FunctionExpression; if (functionExpression != null) { AddFieldNode(functionExpression, diagramViewModel); continue; } var oneInOneOutExpression = expression as OneInOneOutExpression; if (oneInOneOutExpression != null) { AddFieldNode(oneInOneOutExpression, diagramViewModel); continue; } var oneInTwoOutExpression = expression as OneInTwoOutExpression; if (oneInTwoOutExpression != null) { AddFieldNode(oneInTwoOutExpression, diagramViewModel); continue; } var twoInOneOutExpression = expression as TwoInOneOutExpression; if (twoInOneOutExpression != null) { AddFieldNode(twoInOneOutExpression, diagramViewModel); continue; } var conditionExpression = expression as ConditionExpression; if (conditionExpression != null ) { AddFieldNode(conditionExpression, diagramViewModel); continue; } var threeInOneOutExpression = expression as ThreeInOneOutExpression; if (threeInOneOutExpression != null) { AddFieldNode(threeInOneOutExpression, diagramViewModel); continue; } var fourInOneOutExpression = expression as FourInOneOutExpression; if (fourInOneOutExpression != null) { AddFieldNode(fourInOneOutExpression, diagramViewModel); continue; } var fiveInOneOutExpression = expression as FiveInOneOutExpression; if (fiveInOneOutExpression != null ) { AddFieldNode(fiveInOneOutExpression, diagramViewModel); continue; } var sixInOneOutExpression = expression as SixInOneOutExpression; if (sixInOneOutExpression != null) { AddFieldNode(sixInOneOutExpression, diagramViewModel); } } // restore connections foreach (var connection in from o in objects where (o is IConnection) select o) { AddConnection((Connection)connection, diagramViewModel); } }
/// <summary> /// Start the drag operation. /// </summary> private void Start() { if (direction == null) { if (base.VerticalAlignment == System.Windows.VerticalAlignment.Top) { if (base.HorizontalAlignment == System.Windows.HorizontalAlignment.Left) direction = DiagramItemsResizeDirection.LeftTop; else if (base.HorizontalAlignment == System.Windows.HorizontalAlignment.Stretch) direction = DiagramItemsResizeDirection.Top; else direction = DiagramItemsResizeDirection.RightTop; } else if (base.VerticalAlignment == System.Windows.VerticalAlignment.Bottom) { if (base.HorizontalAlignment == System.Windows.HorizontalAlignment.Left) direction = DiagramItemsResizeDirection.LeftBottom; else if (base.HorizontalAlignment == System.Windows.HorizontalAlignment.Stretch) direction = DiagramItemsResizeDirection.Bottom; else direction = DiagramItemsResizeDirection.RightBottom; } else { if (base.HorizontalAlignment == System.Windows.HorizontalAlignment.Left) direction = DiagramItemsResizeDirection.Left; else direction = DiagramItemsResizeDirection.Right; } } diagramDesigner = DiagramHelper.GetDiagramDesigner(this); diagramDesignerVM = diagramDesigner.DataContext as IDiagramViewModel; selectedItems = new List<DiagramDesignerItem>(); selectedItemsVM = new List<IDiagramItemViewModel>(); List<ISelectable> selection = diagramDesigner.SelectionService.CurrentSelection; foreach (ISelectable item in selection) { if (item is DiagramDesignerItem) if (!(item as DiagramDesignerItem).IsDiagramLink) { selectedItems.Add(item as DiagramDesignerItem); } } // create control to display on the drag adorner dragCanvas = new Canvas(); foreach (DiagramDesignerItem item in selectedItems) { if (item.DataContext is IDiagramItemViewModel) selectedItemsVM.Add(item.DataContext as IDiagramItemViewModel); Rectangle r = new Rectangle(); r.Stroke = new SolidColorBrush(Colors.Black); r.StrokeDashArray = new DoubleCollection(); r.StrokeDashArray.Add(3); r.StrokeDashArray.Add(6); r.StrokeThickness = 1.0; r.Width = item.ActualWidth; r.Height = item.ActualHeight; r.Margin = new System.Windows.Thickness(item.AbsoluteLocation.X, item.AbsoluteLocation.Y, 0, 0); dragCanvas.Children.Add(r); } // create drag adorner if (diagramDesigner != null) { AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(diagramDesigner); if (adornerLayer != null) { this.dragAdorner = new DragAdorner(diagramDesigner, dragCanvas, false, 1.0); if (this.dragAdorner != null) { adornerLayer.Add(this.dragAdorner); //e.Handled = true; } } } //e.Handled = false; }
private static void AddFieldNode(FormatValueExpression item, IDiagramViewModel diagramViewModel) { var node = new FormatValueExpressionNode(diagramViewModel, item); diagramViewModel.Items.Add(new NodeViewModel<FormatValueExpressionNode, ExpressionConnection>(node, diagramViewModel)); }
/// <summary> /// Adds the field node. /// </summary> /// <param name="item">The item.</param> /// <param name="diagramViewModel">The diagram view model.</param> private static void AddFieldNode(SourceFieldList item, IDiagramViewModel diagramViewModel) { var sfl = new SourceFieldsExpressionNode(diagramViewModel, item); diagramViewModel.Items.Add(new NodeViewModel<SourceFieldsExpressionNode, ExpressionConnection>(sfl, diagramViewModel)); }
/// <summary> /// Adds the field node. /// </summary> /// <param name="item">The item.</param> /// <param name="diagramViewModel">The diagram view model.</param> private static void AddFieldNode(SixInOneOutExpression item, IDiagramViewModel diagramViewModel) { var node = new SixInOneOutExpressionNode(diagramViewModel, item); diagramViewModel.Items.Add(new NodeViewModel<SixInOneOutExpressionNode, ExpressionConnection>(node, diagramViewModel)); }
/// <summary> /// Initializes a new instance of the <see cref="ExpressionConnectorViewModel"/> class. /// </summary> /// <param name="item">The item.</param> /// <param name="diagramViewModel">The diagram view model.</param> public ExpressionConnectorViewModel(ExpressionConnector item, IDiagramViewModel diagramViewModel) { _item = item; _diagramViewModel = diagramViewModel; }
public ConnectorViewModel(int id, IDiagramViewModel parent, FullyCreatedConnectorInfo sourceConnectorInfo, FullyCreatedConnectorInfo sinkConnectorInfo) : base(id,parent) { Init(sourceConnectorInfo, sinkConnectorInfo); }
public ConnectorViewModel(int id, IDiagramViewModel parent, FullyCreatedConnectorInfo sourceConnectorInfo, FullyCreatedConnectorInfo sinkConnectorInfo) : base(id, parent) { Init(sourceConnectorInfo, sinkConnectorInfo); }
public PersistDesignerItemViewModel(int id, IDiagramViewModel parent, double left, double top, double itemWidth, double itemHeight, string hostUrl) : base(id, parent, left, top, itemWidth, itemHeight) { this.HostUrl = hostUrl; Init(); }