コード例 #1
0
        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;
                        }
                    }
                }
            }
        }
コード例 #2
0
        // <summary>
        /// Iterates an operator graph so that it jumps from the intial operator to all other operators and yields each operator it touches.
        /// Cycles are detected and not iterated twice.
        /// </summary>
        /// <returns>An enumeration of all the operators that could be found.</returns>
        public virtual IEnumerable <IOperator> Iterate()
        {
            if (InitialOperator == null)
            {
                yield break;
            }

            var open    = new Stack <IOperator>();
            var visited = new HashSet <IOperator>();

            open.Push(InitialOperator);

            while (open.Any())
            {
                IOperator current = open.Pop();
                if (visited.Contains(current))
                {
                    continue;
                }
                visited.Add(current);

                IOperatorGraphOperator operatorGraphOperator = current as IOperatorGraphOperator;
                if (operatorGraphOperator != null)
                {
                    open.Push(operatorGraphOperator.OperatorGraph.InitialOperator);
                }

                foreach (var parameter in current.Parameters.OfType <IValueParameter>())
                {
                    if (!typeof(IOperator).IsAssignableFrom(parameter.DataType))
                    {
                        continue;
                    }
                    if (parameter.Value == null)
                    {
                        continue;
                    }

                    open.Push((IOperator)parameter.Value);
                }

                yield return(current);
            }
        }