示例#1
0
 /// <summary>
 /// Для исходящих
 /// </summary>
 public NodeSocket(NodeControl parentNode, Type nodeDataType)
     : this(parentNode, nodeDataType, SocketTypes.Output)
 {
     Passive = true;
 }
示例#2
0
文件: NodeLibrary.cs 项目: okeanz/IPS
 public NodeControlToken(NodeControl node)
 {
     Node = node;
 }
示例#3
0
        DockPanel InFieldPanel(ParameterInfo pInfo, NodeControl parent)
        {
            DockPanel dock = new DockPanel {
                MinWidth = 50, MinHeight = 25, Margin = new Thickness(5)
            };
            InField inField = pInfo.GetCustomAttribute <InField>();

            inField = inField == null ? new InField()
            {
                PVal = 0
            } : inField;

            dock.ContextMenu = DeactivateCM;

            if (pInfo.ParameterType == typeof(string) || pInfo.ParameterType == typeof(int) || pInfo.ParameterType == typeof(double))
            {
                var tb = new TextBox()
                {
                    MinWidth = 50, MinHeight = 25, Margin = new Thickness(0, 0, 2, 0)
                };
                ActiveElement = tb;
                var lb = new Label()
                {
                    Margin = new Thickness(2, 0, 0, 0), Content = string.Format("{0} [{1}]", pInfo.Name, inField.PVal), Foreground = Brushes.White
                };
                dock.Children.Add(tb);
                dock.Children.Add(lb);

                if (inField.PVal != null)
                {
                    tb.Text = inField.PVal.ToString();
                }
                tb.TextChanged += (a, b) =>
                {
                    parent.cbWindow.UpdateCurves(parent);
                    parent.cbWindow.UpdateProcess(parent);
                };
                dock.Tag = new Func <object>(() => { return(tb.Text); });
            }
            if (pInfo.ParameterType == typeof(float))
            {
                var tb1 = new TextBox()
                {
                    MinWidth = 25, MinHeight = 25, Margin = new Thickness(0, 0, 2, 0), Text = inField.Min.ToString()
                };
                var tb2 = new TextBox()
                {
                    MinWidth = 25, MinHeight = 25, Margin = new Thickness(0, 0, 2, 0), Text = inField.Max.ToString()
                };
                var sl = new Slider()
                {
                    Minimum = inField.Min, Maximum = inField.Max, MinWidth = 100, Value = Convert.ToDouble(inField.PVal), IsMoveToPointEnabled = true, AutoToolTipPlacement = System.Windows.Controls.Primitives.AutoToolTipPlacement.TopLeft, AutoToolTipPrecision = 2
                };
                var lb = new Label()
                {
                    Margin = new Thickness(2, 0, 0, 0), Content = string.Format("{0} [{1}] Val: {2}", pInfo.Name, inField.PVal, sl.Value), Foreground = Brushes.White
                };
                dock.Children.Add(tb1);
                dock.Children.Add(sl);
                dock.Children.Add(tb2);
                dock.Children.Add(lb);

                ActiveElement = sl;

                tb1.TextChanged += (a, b) =>
                {
                    float parse;
                    if (!float.TryParse(tb1.Text, out parse))
                    {
                        tb1.Foreground = Brushes.Red;
                        return;
                    }
                    tb1.Foreground = Brushes.Black;
                    sl.Minimum     = parse;
                    //parent.cbWindow.UpdateCurves(parent);
                    //parent.cbWindow.UpdateProcess(parent);
                };
                tb2.TextChanged += (a, b) =>
                {
                    float parse;
                    if (!float.TryParse(tb2.Text, out parse))
                    {
                        tb2.Foreground = Brushes.Red;
                        return;
                    }
                    tb2.Foreground = Brushes.Black;
                    sl.Maximum     = parse;
                    //parent.cbWindow.UpdateCurves(parent);
                    //parent.cbWindow.UpdateProcess(parent);
                };

                sl.PreviewMouseUp += (a, b) =>
                {
                    var val = Math.Round((decimal)sl.Value, 2);
                    lb.Content = string.Format("{0} [{1}] Val: {2}", pInfo.Name, inField.PVal, val);
                    if (KeyboardMods.ChainUpdate)
                    {
                        parent.cbWindow.UpdateCurves(parent);
                        parent.cbWindow.UpdateProcess(parent);
                    }
                    else
                    {
                        parent.Recalc();
                    }
                };
                sl.Tag = new Action(() =>
                {
                    lb.Content = string.Format("{0} [{1}] Val: {2}", pInfo.Name, inField.PVal, sl.Value);
                });

                dock.Tag = new Func <object>(() => { return(sl.Value); });
            }

            if (pInfo.ParameterType == typeof(System.Drawing.Bitmap))
            {
                var b = new Button()
                {
                    Width = 50, Height = 25, Content = "Load"
                };
                var lb = new Label()
                {
                    Margin = new Thickness(2, 0, 0, 0), Content = string.Format("{0}", pInfo.Name), Foreground = Brushes.White
                };
                dock.Tag = new Func <object>(() => { return(null); });
                b.Click += (x, y) =>
                {
                    OpenFileDialog ofd = new OpenFileDialog();
                    if (ofd.ShowDialog() == true)
                    {
                        if (System.IO.File.Exists(ofd.FileName))
                        {
                            System.Drawing.Bitmap bmp = null;
                            try
                            {
                                bmp = new System.Drawing.Bitmap(ofd.FileName);
                            }
                            catch (Exception e)
                            {
                                MessageBox.Show(e.Message);
                                return;
                            }
                            bmp.Tag    = ofd.FileName;
                            dock.Tag   = new Func <object>(() => { var lbmp = bmp; return(lbmp); });
                            lb.Content = string.Format("{0}: {1}\r\n({2}\\{3})", pInfo.Name, ofd.FileName, bmp.Size, System.IO.File.ReadAllBytes(ofd.FileName).Length / 1024 + "Kb");
                        }
                    }

                    parent.cbWindow.UpdateProcess(parent);
                };
                ActiveElement = b;
                dock.Children.Add(b);
                dock.Children.Add(lb);
            }
            if (pInfo.ParameterType == typeof(bool))
            {
                var cb = new ComboBox()
                {
                    Margin = new Thickness(0, 0, 2, 0)
                };
                var lb = new Label()
                {
                    Margin = new Thickness(2, 0, 0, 0), Content = string.Format("{0} [{1}]", pInfo.Name, inField.PVal), Foreground = Brushes.White
                };
                dock.Children.Add(cb);
                dock.Children.Add(lb);

                bool isTrue = true;

                if (inField.PVal != null)
                {
                    isTrue = (bool)inField.PVal;
                }

                cb.Items.Add(new ComboBoxItem()
                {
                    Content = "True", IsSelected = isTrue
                });
                cb.Items.Add(new ComboBoxItem()
                {
                    Content = "False", IsSelected = !isTrue
                });
                cb.SelectionChanged += (x, y) =>
                {
                    parent.cbWindow.UpdateProcess(parent);
                };
                ActiveElement = cb;
                dock.Tag      = new Func <object>(() => { return(Convert.ToBoolean((cb.SelectedItem as ComboBoxItem).Content)); });
            }
            if (pInfo.ParameterType.IsEnum)
            {
                var cb = new ComboBox()
                {
                    Margin = new Thickness(0, 0, 2, 0)
                };
                var lb = new Label()
                {
                    Margin = new Thickness(2, 0, 0, 0), Content = string.Format("{0} [{1}]", pInfo.Name, inField.PVal), Foreground = Brushes.White
                };
                dock.Children.Add(cb);
                dock.Children.Add(lb);

                var selected = inField.PVal;

                var enumNames = pInfo.ParameterType.GetEnumNames();
                if (selected != null)
                {
                    foreach (var name in enumNames)
                    {
                        cb.Items.Add(new ComboBoxItem()
                        {
                            Content = name, IsSelected = name == selected.ToString() ? true : false
                        });
                    }
                }
                else
                {
                    foreach (var name in enumNames)
                    {
                        cb.Items.Add(new ComboBoxItem()
                        {
                            Content = name
                        });
                    }
                    (cb.Items[0] as ComboBoxItem).IsSelected = true;
                }


                cb.SelectionChanged += (x, y) =>
                {
                    parent.cbWindow.UpdateProcess(parent);
                };
                ActiveElement = cb;
                dock.Tag      = new Func <object>(() => { return((string)(cb.SelectedItem as ComboBoxItem).Content); });
            }
            if (pInfo.ParameterType == typeof(System.Drawing.Brush))
            {
                var cb = new ComboBox()
                {
                    Margin = new Thickness(0, 0, 2, 0)
                };
                var lb = new Label()
                {
                    Margin = new Thickness(2, 0, 0, 0), Content = pInfo.Name, Foreground = Brushes.White
                };
                dock.Children.Add(lb);
                dock.Children.Add(cb);


                var names = typeof(Brushes).GetProperties().Select(x => x.Name).ToArray();

                var selected = inField.PVal == null ? names[0] : inField.PVal;

                foreach (var name in names)
                {
                    cb.Items.Add(new ComboBoxItem()
                    {
                        Content = name, IsSelected = name == selected.ToString() ? true : false
                    });
                }

                cb.SelectionChanged += (x, y) =>
                {
                    parent.cbWindow.UpdateProcess(parent);
                };
                ActiveElement = cb;
                dock.Tag      = new Func <object>(() => { return((string)(cb.SelectedItem as ComboBoxItem).Content); });
            }
            APanel = dock;
            return(dock);
        }
示例#4
0
文件: NodeLibrary.cs 项目: okeanz/IPS
        static NodeControl Code()
        {
            NodeControl node = new NodeControl();

            return(null);
        }