private void ContentPin_Changed(object sender, bool isPined)
        {
            if (isPined)
            {
                PinPanel panel = (PinPanel)this.uxPopupContent.Child;

                this.uxPopupContent.Child = null;

                this.uxGridContent.Content = panel;
            }
            else
            {
                PinPanel panel = (PinPanel)this.uxGridContent.Content;

                this.uxGridContent.Content = null;

                this.uxPopupContent.Child = panel;

                this.uxPopupContent.IsOpen = true;

                this.DisplayMouseHover();
            }

            this.OnPinChanged?.Invoke(this, isPined);
        }
Esempio n. 2
0
        protected BaseElement(string name, int width, int height, Image picture, Action <object, MouseEventArgs> onMouseDown)
        {
            Width  = width;
            Height = height;

            parentPanel = new FlowLayoutPanel
            {
                BackColor   = Color.Red,
                Width       = this.Width,
                Height      = this.Height,
                BorderStyle = BorderStyle.FixedSingle,
                Parent      = this
            };

            Controls.Add(parentPanel);

            NameLabel = new Label
            {
                Text   = name,
                Width  = parentPanel.Width,
                Height = 20
            };
            NameLabel.Location = new Point(0, parentPanel.Height - NameLabel.Height);

            NameLabel.MouseDown += ElementMouseDown;

            ElementPictureBox = new PictureBox()
            {
                Width    = this.Width,
                Height   = this.Height - NameLabel.Height,
                Image    = picture,
                SizeMode = PictureBoxSizeMode.StretchImage
            };

            ElementPictureBox.MouseDown += ElementMouseDown;

            parentPanel.Controls.Add(ElementPictureBox);
            parentPanel.Controls.Add(NameLabel);

            this.OnMouseDownAction = onMouseDown;

            MouseDown += (o, mea) => OnMouseDownAction.Invoke(o, mea);

            pinPanel = new PinPanel()
            {
                Visible  = false,
                Enabled  = false,
                Location = new Point(0, NameLabel.Location.Y + NameLabel.Height)
            };

            Controls.Add(pinPanel);
        }
    private void OnClickPinPanel(object sender, EventArgs e)
    {
        PinPanel p = (PinPanel)sender;

        if (inputPins.Contains(p))
        {
            ClickedPinPanel?.Invoke(Array.IndexOf(inputPins, p), true);
        }
        else if (outputPins.Contains(p))
        {
            ClickedPinPanel?.Invoke(Array.IndexOf(inputPins, p), false);
        }
    }
 private void CreatePinPanels()
 {
     if (inputPins != null)
     {
         for (int i = 0; i < inputPins.Length; i++)
         {
             if (inputPins[i] != null && !inputPins[i].IsDisposed)
             {
                 inputPins[i].Dispose();
             }
         }
     }
     inputPins = new PinPanel[_NumberInputPins];
     for (int i = 0; i < inputPins.Length; i++)
     {
         inputPins[i]        = new PinPanel();
         inputPins[i].Click += OnClickPinPanel;
         this.Controls.Add(inputPins[i]);
     }
     if (outputPins != null)
     {
         for (int i = 0; i < outputPins.Length; i++)
         {
             if (outputPins[i] != null && !outputPins[i].IsDisposed)
             {
                 outputPins[i].Dispose();
             }
         }
     }
     outputPins = new PinPanel[_NumberOutputPins];
     for (int i = 0; i < outputPins.Length; i++)
     {
         outputPins[i]        = new PinPanel();
         outputPins[i].Click += OnClickPinPanel;
         this.Controls.Add(outputPins[i]);
     }
 }