예제 #1
0
파일: Node.cs 프로젝트: ivan-symets/viper
        public Node NextStep(ConnectionLine line)
        {
            CurrenNode = line.GetNextNode(CurrenNode, this);
            Node Common = AddNode(CurrenNode);

            if (Common == null)
            {
                return(ParallelPath.Find());
            }
            return(Common);
        }
예제 #2
0
        public override PathInfo GetFormula(ConnectionLine invoker, PathInfo path)
        {
            if (InputLine == null)
            {
                throw new Exception(String.Format(Properties.Resources.ErrorInputModule, Name));
            }

            if (OutputLine == null)
            {
                throw new Exception(String.Format(Properties.Resources.ErrorOutputModule, Name));
            }


            foreach (var uiElement in Path.AllDeletedObjects)
            {
                if (uiElement.GetType().Name == "ConnectionLine")
                {
                    var line = (uiElement as ConnectionLine);

                    if (InputLine.Name == line.Name)
                    {
                        InputLine = null;
                    }

                    if (OutputLine.Name == line.Name)
                    {
                        OutputLine = null;
                    }
                }
            }


            bool isAnd = path.IsM2MConnection;
            var  rez   = Name;

            if (invoker == InputLine)
            {
                rez += OutputLine.GetFormula(this, path);
            }
            if (invoker == OutputLine)
            {
                rez += InputLine.GetFormula(this, path);
            }
            if (isAnd)
            {
                path.Formula = " AND " + rez;
            }
            else
            {
                path.Formula = rez;
            }

            return(path);
        }
예제 #3
0
        internal Node GetNextNode(ConnectionLine invoker, PathFinder path)
        {
            if (invoker == InputLine)
            {
                return(OutputLine.GetNextNode(this, path));
            }
            if (invoker == OutputLine)
            {
                return(InputLine.GetNextNode(this, path));
            }

            return(null);
        }
예제 #4
0
        public void RemoveLineConnection(ConnectionLine connectionLine, UIElement removeInitElement)
        {
            if (connectionLine.Element1?.GetType() == typeof(Module))
            {
                var element1 = connectionLine.Element1 as Module;

                if (element1.OutputLine == connectionLine)
                {
                    element1.OutputLine = null;
                }
                else if (element1.InputLine == connectionLine)
                {
                    element1.InputLine = null;
                }
            }
            else if (connectionLine.Element1?.GetType() == typeof(Node))
            {
                var element1 = connectionLine.Element1 as Node;

                if ((removeInitElement.GetType() != typeof(Node)) || (removeInitElement.GetType() == typeof(Node) && (removeInitElement as Node) != element1))
                {
                    element1.ConnectionLines.Remove(connectionLine);
                }
            }

            if (connectionLine.Element2?.GetType() == typeof(Module))
            {
                var element2 = connectionLine.Element2 as Module;

                if (element2.OutputLine == connectionLine)
                {
                    element2.OutputLine = null;
                }
                else if (element2.InputLine == connectionLine)
                {
                    element2.InputLine = null;
                }
            }
            else if (connectionLine.Element2?.GetType() == typeof(Node))
            {
                var element2 = connectionLine.Element2 as Node;

                if ((removeInitElement.GetType() != typeof(Node)) || (removeInitElement.GetType() == typeof(Node) && (removeInitElement as Node) != element2))
                {
                    element2.ConnectionLines.Remove(connectionLine);
                }
            }
        }
예제 #5
0
파일: Node.cs 프로젝트: ivan-symets/viper
        public Node Find()
        {
            ConnectionLine line = null;

            foreach (var item in CurrenNode.ConnectionLines)
            {
                if (!PasedLines.Contains(item) && !Schema.CheckedList.Contains(item))
                {
                    line = item; break;
                }
            }
            if (line != null)
            {
                return(NextStep(line));
            }
            return(null);
        }
예제 #6
0
        protected override void OnPreviewMouseLeftButtonUp(System.Windows.Input.MouseButtonEventArgs e)
        {
            base.OnPreviewMouseLeftButtonUp(e);
            var canvas = schema;


            if (Mode == CreativeMode.Module)
            {
                for (var i = 0; i < ConfigurationHelper.CountDragingElement; i++)
                {
                    var module = new Module();
                    canvas.Children.Add(module);
                    if (Properties.Resources.Horizontal.Equals(ConfigurationHelper.CountDragingElementLine))
                    {
                        var a1 = Mouse.GetPosition(canvas).X + 275 * i;
                        var a2 = Mouse.GetPosition(canvas).Y;

                        Canvas.SetLeft(module, Mouse.GetPosition(canvas).X + 275 * i);
                        Canvas.SetTop(module, Mouse.GetPosition(canvas).Y);
                    }
                    else
                    {
                        Canvas.SetLeft(module, Mouse.GetPosition(canvas).X);
                        Canvas.SetTop(module, Mouse.GetPosition(canvas).Y + 175 * i);
                    }

                    Path.logFormElements.Add($"({DateTime.Now:H:mm:ss}) Added module: {module.Name}.");
                }
            }
            if (Mode == CreativeMode.Node)
            {
                for (var i = 0; i < ConfigurationHelper.CountDragingElement; i++)
                {
                    var node = new Node();
                    canvas.Children.Add(node);
                    if (Properties.Resources.Horizontal.Equals(ConfigurationHelper.CountDragingElementLine))
                    {
                        Canvas.SetLeft(node, Mouse.GetPosition(canvas).X + 275 * i);
                        Canvas.SetTop(node, Mouse.GetPosition(canvas).Y);
                    }
                    else
                    {
                        Canvas.SetLeft(node, Mouse.GetPosition(canvas).X);
                        Canvas.SetTop(node, Mouse.GetPosition(canvas).Y + 175 * i);
                    }


                    Path.logFormElements.Add($"({DateTime.Now:H:mm:ss}) Added node: {node.Name}.");
                }
            }
            if (Mode == CreativeMode.LineBegin)
            {
                var line = new ConnectionLine();
                canvas.Children.Add(line);
                if (e.OriginalSource is Node || e.OriginalSource is Module)
                {
                    line.Element1 = e.OriginalSource as DraggingElement;
                    Mode          = CreativeMode.LineEnd;
                    CreationLine  = line;
                }



                return;
            }
            if (Mode == CreativeMode.LineEnd)
            {
                if (e.OriginalSource is Node || e.OriginalSource is Module)
                {
                    Mode = CreativeMode.LineBegin;
                    CreationLine.Element2 = e.OriginalSource as DraggingElement;


                    Path.logFormElements.Add($"({DateTime.Now:H:mm:ss}) Con.: {CreationLine?.Element1.Name} to {CreationLine?.Element2.Name}.");
                }


                foreach (var builder in Lines.LineBuilders.Where(w => w.Line.Name == CreationLine.Name))
                {
                    builder.Points.Add(Mouse.GetPosition(canvas));
                }
            }
        }
예제 #7
0
파일: Node.cs 프로젝트: ivan-symets/viper
        public override PathInfo GetFormula(ConnectionLine l, PathInfo path)
        {
            if (IsStartNode && ConnectionLines.Count == 0)
            {
                throw new Exception(String.Format(Properties.Resources.ErrorStartNode, Name));
            }


            if (IsEndNode && ConnectionLines.Count == 0)
            {
                throw new Exception(String.Format(Properties.Resources.ErrorEndNode, Name));
            }


            if (ConnectionLines.Count <= 1 && !IsStartNode && !IsEndNode)
            {
                throw new Exception(String.Format(Properties.Resources.ErrorStartNode, Name));
            }

            var rez           = "";
            var pathInfoTable = new List <PathInfo>();

            foreach (var uiElement in Path.AllDeletedObjects)
            {
                if (uiElement.GetType().Name == "ConnectionLine")
                {
                    this.ConnectionLines = this.ConnectionLines.Where(w => w.Name != (uiElement as ConnectionLine).Name).ToList();
                }
            }

            Node endBranch = null;

            if (this.ConnectionLines.Count > 2 && this != path?.EndBranch)
            {
                endBranch = FindEndNode();
            }

            if (path == null || path.Start == null)
            {
                foreach (var line in ConnectionLines)
                {
                    if (!Schema.CheckedList.Contains(line))
                    {
                        PathInfo patrhInfo = new PathInfo()
                        {
                            Start     = this,
                            Parent    = this,
                            EndBranch = endBranch
                        };
                        line.GetFormula(this, patrhInfo);
                        pathInfoTable.Add(patrhInfo);
                    }
                }
            }
            else
            {
                path.End = this;
                return(path);
            }

            var newTable = new List <PathInfo>();

            for (int i = 0; i < pathInfoTable.Count; i++)
            {
                if (pathInfoTable[i].Formula == "")
                {
                    if (!pathInfoTable[i].End.IsEndNode)
                    {
                        pathInfoTable[i] = pathInfoTable[i].End.GetFormula(null, new PathInfo {
                            Parent = this
                        });
                    }
                    //pathInfoTable[i].Start.IsStartNode = true;
                }
            }

            string orString = "";

            foreach (PathInfo pathInfo in pathInfoTable)
            {
                if (pathInfo.Formula != "")
                {
                    rez     += orString + "(" + pathInfo.Formula + ")";
                    orString = " OR ";
                }
            }

            if (pathInfoTable.Count == 0)
            {
                return(new PathInfo()
                {
                    Formula = rez
                });
            }

            pathInfoTable = new List <PathInfo>()
            {
                new PathInfo()
                {
                    Start   = pathInfoTable[0].Start,
                    End     = pathInfoTable[0].End,
                    Formula = rez
                }
            };

            if (pathInfoTable.Count == 0)
            {
                pathInfoTable.Add(new PathInfo
                {
                    Formula = ""
                }
                                  );
            }

            if ((pathInfoTable[0].Formula != "") && pathInfoTable[0].End != null && !pathInfoTable[0].End.IsEndNode)
            {
                var end = pathInfoTable[0].End.GetFormula(null, new PathInfo {
                    Parent = this
                });
                pathInfoTable[0].Formula += end.ToString() != "" && end.ToString() != "()"? " AND (" + end + ")":"";
                pathInfoTable[0].End      = end.End;
            }
            return(pathInfoTable[0]);
        }
예제 #8
0
 public override PathInfo GetFormula(ConnectionLine invoker, PathInfo path)
 {
     throw new NotImplementedException();
 }