Beispiel #1
0
 private void NodeInitConnect(object obj)
 {
     if (StartLinkNode == null && obj is UcParameterOutput)
     {
         //ставим флаг для начала откисовки соеденияющей линии
         StartLinkNode = (Control)obj;
     }
     else
     {
         if (obj is UcРarameterInput && StartLinkNode != null) // соеденяем только с входами
         {
             UcРarameterInput  bufIn  = (UcРarameterInput)obj;
             UcParameterOutput bufOut = (UcParameterOutput)StartLinkNode;
             if (bufIn.TypeIN == null && bufOut.TypeOUT == null)
             {
                 Lines.Add(new ConnectionLine {
                     start = StartLinkNode, end = (Control)obj, TypeLine = TypesConnection.NextProcess
                 });
             }
             else if ((bufIn.TypeIN != null && bufOut.TypeOUT != null) && (bufIn.TypeIN == bufOut.TypeOUT || //Это прямые типы
                                                                           bufOut.TypeOUT.ToString().StartsWith((bufIn.TypeIN.ToString())))) //Это сравнение для out типы в конце добавляют &
             {
                 Lines.Add(new ConnectionLine {
                     start = StartLinkNode, end = (Control)obj, TypeLine = TypesConnection.DeliverData
                 });
             }
         }
         //скидываем флаг
         StartLinkNode = null;
     }
 }
Beispiel #2
0
        private void Rebuild()
        {
            if (cbMethod.SelectedIndex == -1)
            {
                SetupMinimalBodySize();
                lDescription.Text = "Нет описания";
                this.Size         = Body.Size;
            }
            else
            {
                MethodInfo method = ((ComboboxItem)cbMethod.SelectedItem).Value;
                MethodDescriptionAttribute methodDescriptor = method.GetCustomAttribute <MethodDescriptionAttribute>();
                if (methodDescriptor != null)
                {
                    lDescription.Text = methodDescriptor.MethodDescription;
                }
                else
                {
                    lDescription.Text = "Нет описания";
                }

                List <ParameterInfo> parameters = new List <ParameterInfo>(method.GetParameters());
                List <int>           widths     = new List <int>();
                int position = 0;
                foreach (ParameterInfo p in parameters)
                {
                    if (!p.IsOut)
                    {
                        UcРarameterInput input = new UcРarameterInput(p);
                        input.ConnectorActivated += InitConnect;
                        input.ConnectorDelete    += DeleteLink;
                        widths.Add(input.Size.Width);
                        input.Parent = this;
                        input.BringToFront();
                        ucControls.Add(input);
                    }
                    else
                    {
                        UcParameterOutput output = new UcParameterOutput(p);
                        output.ConnectorActivated += InitConnect;
                        widths.Add(output.Size.Width);
                        output.Parent = this;
                        output.BringToFront();
                        ucControls.Add(output);
                    }
                    position++;
                }

                if (method.ReturnType.Name != "Void")
                {
                    UcParameterOutput output = new UcParameterOutput(method.ReturnParameter);
                    output.ConnectorActivated += InitConnect;

                    output.Location = new Point(Body.Location.X + Body.Size.Width - output.delta, DELTA_TOP + position * CONNECTOR);
                    widths.Add(output.Size.Width);
                    output.Parent = this;
                    output.BringToFront();
                    ucControls.Add(output);
                }
                // Добавляем пустые сцеки

                UcРarameterInput enter = new UcРarameterInput();
                enter.ConnectorActivated += InitConnect;
                enter.ConnectorDelete    += DeleteLink;
                widths.Add(enter.Size.Width);
                enter.Parent = this;
                enter.BringToFront();
                ucControls.Add(enter);

                UcParameterOutput exit = new UcParameterOutput();
                exit.ConnectorActivated += InitConnect;
                widths.Add(exit.Size.Width);
                exit.Parent = this;
                exit.BringToFront();
                ucControls.Add(exit);

                //--------------------



                int MaxWidth = widths.Count > 0? widths.Max() + 20:20;

                SetupMinimalBodySize();

                Body.Size = new Size(MaxWidth <= Body.Size.Width? Body.Size.Width: MaxWidth,
                                     HEAD + CONNECTOR * (parameters.Count + (method.ReturnType.Name != "Void" ? 1 : 0) + 1));//+1 - место под void контроли

                int LeftPading  = 25;
                int Rightpading = 26;
                //if (method.ReturnType.Name != "Void"|| parameters.Find(x => x.IsOut) != null ) //Если есть контроли выходные
                //{
                //    Rightpading = 26;
                //}
                //if (parameters.Find(x => (!x.IsOut)) != null)
                //{
                //    LeftPading = 25;
                //}

                Body.Location = new Point(LeftPading, 0);
                this.Size     = new Size(Body.Size.Width + LeftPading + Rightpading, Body.Size.Height);

                position = 0;
                foreach (UserControl ctrl in ucControls)
                {
                    if (ctrl is UcParameterOutput)
                    {
                        if (position == ucControls.Count - 1)
                        {
                            //последний OUT контрол поднимаем на сточку вверх
                            ctrl.Location = new Point(Body.Location.X + Body.Size.Width - ((UcParameterOutput)ctrl).delta, DELTA_TOP + (position - 1) * CONNECTOR);
                        }
                        else
                        {
                            ctrl.Location = new Point(Body.Location.X + Body.Size.Width - ((UcParameterOutput)ctrl).delta, DELTA_TOP + position * CONNECTOR);
                        }
                    }
                    if (ctrl is UcРarameterInput)
                    {
                        ctrl.Location = new Point(Body.Location.X - ((UcРarameterInput)ctrl).delta, DELTA_TOP + position * CONNECTOR);
                    }
                    position++;
                }
            }
        }