private void OperatorItemImageChanged(object sender, EventArgs e) { IOperator op = (IOperator)sender; IOperatorShapeInfo operatorShapeInfo = this.operatorShapeInfoMapping.GetByFirst(op); operatorShapeInfo.Icon = new Bitmap(op.ItemImage); }
private void AddParameter(IOperator op, IParameter param) { this.parameterOperatorMapping.Add(param, op); IValueParameter opParam = param as IValueParameter; if (opParam != null && typeof(IOperator).IsAssignableFrom(param.DataType)) { this.RegisterOperatorParameterEvents(opParam); IOperatorShapeInfo shapeInfoFrom = this.operatorShapeInfoMapping.GetByFirst(op); shapeInfoFrom.AddConnector(param.Name); if (opParam.Value != null) { if (!this.operatorShapeInfoMapping.ContainsFirst((IOperator)opParam.Value)) { this.AddOperator((IOperator)opParam.Value); } IOperatorShapeInfo shapeInfoTo = this.operatorShapeInfoMapping.GetByFirst((IOperator)opParam.Value); this.connectionInfos.Add(new ConnectionInfo(shapeInfoFrom, param.Name, shapeInfoTo, OperatorShapeInfoFactory.PredecessorConnector)); } } else { this.RegisterParameterEvents(param); } }
private void OperatorGraphView_DragDrop(object sender, DragEventArgs e) { if (e.Effect != DragDropEffects.None) { IOperator op = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) as IOperator; if (e.Effect.HasFlag(DragDropEffects.Copy)) { op = (IOperator)op.Clone(); } IOperatorShapeInfo shapeInfo = OperatorShapeInfoFactory.CreateOperatorShapeInfo(op); Point mouse = new Point(MousePosition.X, MousePosition.Y); Point screen = this.graphVisualizationInfoView.PointToScreen(new Point(0, 0)); Point control = new Point(mouse.X - screen.X, mouse.Y - screen.Y); PointF worldPoint = this.graphVisualizationInfoView.Controller.View.ViewToWorld(control); if (worldPoint.X < 0) { worldPoint.X = 0; } if (worldPoint.Y < 0) { worldPoint.Y = 0; } shapeInfo.Location = Point.Round(worldPoint); this.VisualizationInfo.AddShapeInfo(op, shapeInfo); } }
private void OperatorNameChanged(object sender, EventArgs e) { IOperator op = (IOperator)sender; IOperatorShapeInfo operatorShapeInfo = this.operatorShapeInfoMapping.GetByFirst(op); operatorShapeInfo.Title = op.Name; }
public override void RemoveConnectionInfo(IConnectionInfo connectionInfo) { IOperatorShapeInfo shapeInfo = (IOperatorShapeInfo)connectionInfo.From; IOperator op = this.operatorShapeInfoMapping.GetBySecond(shapeInfo); IValueParameter param = (IValueParameter)op.Parameters[connectionInfo.ConnectorFrom]; param.Value = null; }
public static void UpdateShape(IOperatorShapeInfo operatorShapeInfo, OperatorShape operatorShape) { operatorShape.Title = operatorShapeInfo.Title; operatorShape.Subtitle = operatorShapeInfo.TypeName; operatorShape.Color = operatorShapeInfo.Color; operatorShape.LineColor = operatorShapeInfo.LineColor; operatorShape.LineWidth = operatorShapeInfo.LineWidth; operatorShape.Icon = operatorShapeInfo.Icon; operatorShape.Collapsed = operatorShapeInfo.Collapsed; int i = 0; int j = 0; //remove old connectors and skip correct connectors List <string> oldConnectorNames = operatorShape.AdditionalConnectorNames.ToList(); while (i < operatorShapeInfo.Connectors.Count() && j < oldConnectorNames.Count) { if (operatorShapeInfo.Connectors.ElementAt(i) == OperatorShapeInfoFactory.SuccessorConnector || operatorShapeInfo.Connectors.ElementAt(i) == OperatorShapeInfoFactory.PredecessorConnector) { i++; } else if (oldConnectorNames[j] == OperatorShapeInfoFactory.SuccessorConnector || oldConnectorNames[j] == OperatorShapeInfoFactory.PredecessorConnector) { j++; } else if (operatorShapeInfo.Connectors.ElementAt(i) != oldConnectorNames[j]) { operatorShape.RemoveConnector(oldConnectorNames[j]); j++; } else { i++; j++; } } //remove remaining old connectors for (; j < oldConnectorNames.Count; j++) { operatorShape.RemoveConnector(oldConnectorNames[j]); } //add new connectors except successor and connector for (; i < operatorShapeInfo.Connectors.Count(); i++) { if (operatorShapeInfo.Connectors.ElementAt(i) != OperatorShapeInfoFactory.SuccessorConnector && operatorShapeInfo.Connectors.ElementAt(i) != OperatorShapeInfoFactory.PredecessorConnector) { operatorShape.AddConnector(operatorShapeInfo.Connectors.ElementAt(i)); } } operatorShape.UpdateLabels(operatorShapeInfo.Labels); }
public static void UpdateShapeInfo(IOperatorShapeInfo operatorShapeInfo, OperatorShape operatorShape) { operatorShapeInfo.Title = operatorShape.Title; operatorShapeInfo.TypeName = operatorShape.Subtitle; operatorShapeInfo.Color = operatorShape.Color; operatorShapeInfo.LineColor = operatorShape.LineColor; operatorShapeInfo.LineWidth = operatorShape.LineWidth; operatorShapeInfo.Icon = operatorShape.Icon; operatorShapeInfo.Collapsed = operatorShape.Collapsed; }
public override void RemoveShapeInfo(IShapeInfo shapeInfo) { IOperatorShapeInfo opShapeInfo = (IOperatorShapeInfo)shapeInfo; if (this.operatorShapeInfoMapping.ContainsSecond(opShapeInfo)) { IOperator op = this.operatorShapeInfoMapping.GetBySecond(opShapeInfo); this.operatorGraph.Operators.Remove(op); } }
private void breakPointToolStripMenuItem_Click(object sender, EventArgs e) { IOperatorShapeInfo shapeInfo = this.shapeContextMenu.Tag as IOperatorShapeInfo; if (shapeInfo != null) { IOperator op = this.VisualizationInfo.GetOperatorForShapeInfo(shapeInfo); op.Breakpoint = !op.Breakpoint; } }
public override void AddConnectionInfo(IConnectionInfo connectionInfo) { IOperatorShapeInfo shapeInfo = (IOperatorShapeInfo)connectionInfo.From; IOperator op = this.operatorShapeInfoMapping.GetBySecond(shapeInfo); IOperatorShapeInfo shapeInfoTo = (IOperatorShapeInfo)connectionInfo.To; IOperator opTo = this.operatorShapeInfoMapping.GetBySecond(shapeInfoTo); IValueParameter param = (IValueParameter)op.Parameters.Where(p => p.Name == connectionInfo.ConnectorFrom).SingleOrDefault(); if (param != null) { param.Value = opTo; } }
private void shapeContextMenu_Opening(object sender, System.ComponentModel.CancelEventArgs e) { IOperatorShapeInfo shapeInfo = this.shapeContextMenu.Tag as IOperatorShapeInfo; if (shapeInfo != null) { IOperator op = this.VisualizationInfo.GetOperatorForShapeInfo(shapeInfo); this.initialToolStripMenuItem.Checked = this.Content.InitialOperator == op; this.initialToolStripMenuItem.Enabled = !ReadOnly && !Locked; this.breakPointToolStripMenuItem.Checked = op.Breakpoint; this.breakPointToolStripMenuItem.Enabled = !Locked; } }
private void initialOperatorToolStripMenuItem_Click(object sender, EventArgs e) { IOperatorShapeInfo shapeInfo = this.shapeContextMenu.Tag as IOperatorShapeInfo; if (this.VisualizationInfo.InitialShape == shapeInfo) { this.VisualizationInfo.InitialShape = null; } else { this.VisualizationInfo.InitialShape = shapeInfo; } }
private void UpdateParameterLabels(IOperator op) { IEnumerable <IParameter> parameters = op.Parameters.Where(p => !(p is IValueParameter && typeof(IOperator).IsAssignableFrom(p.DataType))); IOperatorShapeInfo operatorShapeInfo = this.operatorShapeInfoMapping.GetByFirst(op); if (parameters.Count() > 0) { operatorShapeInfo.UpdateLabels(parameters.Select(p => p.ToString())); } else { operatorShapeInfo.UpdateLabels(new List <string>()); } }
public void AddShapeInfo(IOperator op, IOperatorShapeInfo shapeInfo) { this.RegisterOperatorEvents(op); this.operatorParameterCollectionMapping.Add(op, op.Parameters); this.operatorShapeInfoMapping.Add(op, shapeInfo); this.shapeInfos.Add(shapeInfo); foreach (IParameter param in op.Parameters) { this.AddParameter(op, param); } this.operatorGraph.Operators.Add(op); }
private void RemoveOperator(IOperator op) { this.DeregisterOperatorEvents(op); foreach (IParameter param in op.Parameters) { this.RemoveParameter(op, param); } IOperatorShapeInfo shapeInfo = this.operatorShapeInfoMapping.GetByFirst(op); this.operatorParameterCollectionMapping.RemoveByFirst(op); this.operatorShapeInfoMapping.RemoveByFirst(op); this.shapeInfos.Remove(shapeInfo); }
private void Controller_OnMouseDown(object sender, MouseEventArgs e) { if (e.Clicks >= 2) { IShape shape = this.graphVisualizationInfoView.Controller.Model.GetShapeAt(e.Location); if (shape != null) { IOperatorShapeInfo shapeInfo = shape.Tag as IOperatorShapeInfo; if (shapeInfo != null) { IOperator op = this.VisualizationInfo.GetOperatorForShapeInfo(shapeInfo); IOperatorGraphOperator graphOp = op as IOperatorGraphOperator; Control c = this; BreadcrumbViewHost vh; do { c = c.Parent; vh = c as BreadcrumbViewHost; } while ((vh == null || !vh.EnableBreadcrumbs) && c != null); if (graphOp != null && vh != null) { vh.AddBreadcrumbs(vh.Content); vh.AddBreadcrumb(graphOp.Name, graphOp.OperatorGraph); vh.Content = graphOp.OperatorGraph; vh.ReadOnly = ReadOnly; vh.Locked = Locked; } else { IContentView view = MainFormManager.MainForm.ShowContent(op); if (view != null) { view.ReadOnly = ReadOnly; view.Locked = Locked; } } HandledMouseEventArgs eventArgs = e as HandledMouseEventArgs; if (eventArgs != null) { eventArgs.Handled = true; } } } } }
private void openViewToolStripMenuItem_Click(object sender, EventArgs e) { IOperatorShapeInfo shapeInfo = this.shapeContextMenu.Tag as IOperatorShapeInfo; if (shapeInfo != null) { IOperator op = this.VisualizationInfo.GetOperatorForShapeInfo(shapeInfo); IContentView view = MainFormManager.MainForm.ShowContent(op); if (view != null) { view.ReadOnly = this.ReadOnly; view.Locked = this.Locked; } } }
private void AddOperator(IOperator op) { if (!this.operatorShapeInfoMapping.ContainsFirst(op)) { this.RegisterOperatorEvents(op); IOperatorShapeInfo shapeInfo = OperatorShapeInfoFactory.CreateOperatorShapeInfo(op); this.operatorParameterCollectionMapping.Add(op, op.Parameters); this.operatorShapeInfoMapping.Add(op, shapeInfo); this.shapeInfos.Add(shapeInfo); foreach (IParameter param in op.Parameters) { this.AddParameter(op, param); } } }
private void OperatorBreakpointChanged(object sender, EventArgs e) { IOperator op = (IOperator)sender; IOperatorShapeInfo operatorShapeInfo = this.operatorShapeInfoMapping.GetByFirst(op); if (op.Breakpoint) { operatorShapeInfo.LineColor = Color.Red; operatorShapeInfo.LineWidth = 2; } else { operatorShapeInfo.LineColor = Color.Black; operatorShapeInfo.LineWidth = 1; } }
public static OperatorShape CreateShape(IOperatorShapeInfo shapeInfo) { OperatorShape shape = new OperatorShape(); shape.Tag = shapeInfo; shape.Location = shapeInfo.Location; shape.Title = shapeInfo.Title; shape.Subtitle = shapeInfo.TypeName; shape.Color = shapeInfo.Color; shape.LineColor = shapeInfo.LineColor; shape.LineWidth = shapeInfo.LineWidth; shape.Icon = shapeInfo.Icon; shape.Collapsed = shapeInfo.Collapsed; foreach (string connectorName in shapeInfo.Connectors) if (connectorName != OperatorShapeInfoFactory.SuccessorConnector && connectorName != OperatorShapeInfoFactory.PredecessorConnector) shape.AddConnector(connectorName); shape.UpdateLabels(shapeInfo.Labels); return shape; }
private void RemoveParameter(IOperator op, IParameter param) { IValueParameter opParam = param as IValueParameter; if (opParam != null && typeof(IOperator).IsAssignableFrom(param.DataType)) { this.DeregisterOperatorParameterEvents(opParam); IOperatorShapeInfo shapeInfo = this.operatorShapeInfoMapping.GetByFirst(op); this.connectionInfos.RemoveWhere(c => c.From == shapeInfo && c.ConnectorFrom == param.Name); this.connectionInfos.RemoveWhere(c => c.To == shapeInfo && c.ConnectorTo == param.Name); shapeInfo.RemoveConnector(param.Name); } else { this.DeregisterParameterEvents(param); } this.parameterOperatorMapping.Remove(param); }
private void Controller_SelectionChanged(object sender, EventArgs e) { this.detailsViewHost.ViewType = null; this.detailsViewHost.Content = null; CollectionBase <IDiagramEntity> selectedObjects = this.graphVisualizationInfoView.Controller.Model.Selection.SelectedItems; if (selectedObjects.Count == 1) { IShape shape = selectedObjects[0] as IShape; if (shape != null) { IOperatorShapeInfo shapeInfo = shape.Tag as IOperatorShapeInfo; IOperator op = this.VisualizationInfo.GetOperatorForShapeInfo(shapeInfo); this.detailsViewHost.Content = op; } } IConnector connector = this.graphVisualizationInfoView.Controller.Model.Selection.Connector; if (connector != null) { IShape shape = connector.Parent as IShape; string connectorName = connector.Name; if (shape == null) { shape = connector.AttachedTo.Parent as IShape; //connection connector selected connectorName = connector.AttachedTo.Name; } if (shape != null) { IOperatorShapeInfo shapeInfo = shape.Tag as IOperatorShapeInfo; IOperator op = this.VisualizationInfo.GetOperatorForShapeInfo(shapeInfo); if (connectorName != "Predecessor") { IParameter parameter = op.Parameters.Where(p => p.Name == connectorName).First(); this.detailsViewHost.ViewType = null; this.detailsViewHost.Content = parameter; } } } }
private void UpdateInitialShape() { IOperatorShapeInfo old = this.oldInitialShape as OperatorShapeInfo; if (old != null) { old.Color = oldInitialShapeColor; } OperatorShapeInfo newInitialShapeInfo = this.InitialShape as OperatorShapeInfo; if (newInitialShapeInfo != null) { oldInitialShapeColor = newInitialShapeInfo.Color; newInitialShapeInfo.Color = Color.LightGreen; } oldInitialShape = this.InitialShape; this.OnInitialShapeChanged(); }
public static void UpdateShape(IOperatorShapeInfo operatorShapeInfo, OperatorShape operatorShape) { operatorShape.Title = operatorShapeInfo.Title; operatorShape.Subtitle = operatorShapeInfo.TypeName; operatorShape.Color = operatorShapeInfo.Color; operatorShape.LineColor = operatorShapeInfo.LineColor; operatorShape.LineWidth = operatorShapeInfo.LineWidth; operatorShape.Icon = operatorShapeInfo.Icon; operatorShape.Collapsed = operatorShapeInfo.Collapsed; int i = 0; int j = 0; //remove old connectors and skip correct connectors List<string> oldConnectorNames = operatorShape.AdditionalConnectorNames.ToList(); while (i < operatorShapeInfo.Connectors.Count() && j < oldConnectorNames.Count) { if (operatorShapeInfo.Connectors.ElementAt(i) == OperatorShapeInfoFactory.SuccessorConnector || operatorShapeInfo.Connectors.ElementAt(i) == OperatorShapeInfoFactory.PredecessorConnector) i++; else if (oldConnectorNames[j] == OperatorShapeInfoFactory.SuccessorConnector || oldConnectorNames[j] == OperatorShapeInfoFactory.PredecessorConnector) j++; else if (operatorShapeInfo.Connectors.ElementAt(i) != oldConnectorNames[j]) { operatorShape.RemoveConnector(oldConnectorNames[j]); j++; } else { i++; j++; } } //remove remaining old connectors for (; j < oldConnectorNames.Count; j++) operatorShape.RemoveConnector(oldConnectorNames[j]); //add new connectors except successor and connector for (; i < operatorShapeInfo.Connectors.Count(); i++) if (operatorShapeInfo.Connectors.ElementAt(i) != OperatorShapeInfoFactory.SuccessorConnector && operatorShapeInfo.Connectors.ElementAt(i) != OperatorShapeInfoFactory.PredecessorConnector) operatorShape.AddConnector(operatorShapeInfo.Connectors.ElementAt(i)); operatorShape.UpdateLabels(operatorShapeInfo.Labels); }
private void opParam_ValueChanged(object sender, EventArgs e) { IValueParameter opParam = (IValueParameter)sender; if (this.parameterOperatorMapping.ContainsKey(opParam)) { IOperator op = this.parameterOperatorMapping[opParam]; IOperatorShapeInfo shapeInfoFrom = this.operatorShapeInfoMapping.GetByFirst(op); KeyValuePair <IOperatorShapeInfo, string> connectionFrom = new KeyValuePair <IOperatorShapeInfo, string>(shapeInfoFrom, opParam.Name); this.connectionInfos.RemoveWhere(c => c.From == shapeInfoFrom && c.ConnectorFrom == opParam.Name); if (opParam.Value != null) { if (!this.operatorShapeInfoMapping.ContainsFirst((IOperator)opParam.Value)) { this.AddOperator((IOperator)opParam.Value); } IOperatorShapeInfo shapeInfoTo = this.operatorShapeInfoMapping.GetByFirst((IOperator)opParam.Value); base.AddConnectionInfo(new ConnectionInfo(shapeInfoFrom, opParam.Name, shapeInfoTo, OperatorShapeInfoFactory.PredecessorConnector)); } } }
private OperatorGraphVisualizationInfo(OperatorGraphVisualizationInfo original, Cloner cloner) : base(original, cloner) { operatorShapeInfoMapping = new BidirectionalLookup <IOperator, IOperatorShapeInfo>(); operatorParameterCollectionMapping = new BidirectionalLookup <IOperator, IKeyedItemCollection <string, IParameter> >(); parameterOperatorMapping = new Dictionary <IParameter, IOperator>(); operatorGraph = cloner.Clone(original.operatorGraph); RegisterOperatorGraphEvents(); oldInitialShape = cloner.Clone(original.oldInitialShape); oldInitialShapeColor = original.oldInitialShapeColor; foreach (KeyValuePair <IOperator, IOperatorShapeInfo> pair in original.operatorShapeInfoMapping.FirstEnumerable) { IOperator op = cloner.Clone(pair.Key); IOperatorShapeInfo shapeInfo = cloner.Clone(pair.Value); RegisterOperatorEvents(op); operatorParameterCollectionMapping.Add(op, op.Parameters); operatorShapeInfoMapping.Add(op, shapeInfo); } foreach (IOperator oper in operatorShapeInfoMapping.FirstValues) { foreach (IParameter param in oper.Parameters) { parameterOperatorMapping.Add(param, oper); IValueParameter opParam = param as IValueParameter; if (opParam != null && typeof(IOperator).IsAssignableFrom(param.DataType)) { RegisterOperatorParameterEvents(opParam); } else { RegisterParameterEvents(param); } } } }
public static OperatorShape CreateShape(IOperatorShapeInfo shapeInfo) { OperatorShape shape = new OperatorShape(); shape.Tag = shapeInfo; shape.Location = shapeInfo.Location; shape.Title = shapeInfo.Title; shape.Subtitle = shapeInfo.TypeName; shape.Color = shapeInfo.Color; shape.LineColor = shapeInfo.LineColor; shape.LineWidth = shapeInfo.LineWidth; shape.Icon = shapeInfo.Icon; shape.Collapsed = shapeInfo.Collapsed; foreach (string connectorName in shapeInfo.Connectors) { if (connectorName != OperatorShapeInfoFactory.SuccessorConnector && connectorName != OperatorShapeInfoFactory.PredecessorConnector) { shape.AddConnector(connectorName); } } shape.UpdateLabels(shapeInfo.Labels); return(shape); }
public IOperator GetOperatorForShapeInfo(IOperatorShapeInfo shapeInfo) { return this.operatorShapeInfoMapping.GetBySecond(shapeInfo); }
public IOperator GetOperatorForShapeInfo(IOperatorShapeInfo shapeInfo) { return(this.operatorShapeInfoMapping.GetBySecond(shapeInfo)); }
public void AddShapeInfo(IOperator op, IOperatorShapeInfo shapeInfo) { this.RegisterOperatorEvents(op); this.operatorParameterCollectionMapping.Add(op, op.Parameters); this.operatorShapeInfoMapping.Add(op, shapeInfo); this.shapeInfos.Add(shapeInfo); foreach (IParameter param in op.Parameters) this.AddParameter(op, param); this.operatorGraph.Operators.Add(op); }