Example #1
0
        protected override void WndProc(ref System.Windows.Forms.Message m)
        {
            if (m.Msg == WM_LBUTTONUP)
            {
                ISelectionService selectionService = (ISelectionService)this.GetService(typeof(ISelectionService));
                Point             ptMouse          = this.Discover.PointToClient(Cursor.Position);
                DiscoverPane      discoverPane     = this.Discover.GetPaneAt(ptMouse.X, ptMouse.Y);

                if (discoverPane != null)
                {
                    object[] objs = new object[] { discoverPane };

                    this.Discover.SelectedPane = discoverPane;

                    this.Discover.Invalidate();

                    selectionService.SetSelectedComponents(objs, SelectionTypes.Primary);
                }
                else
                {
                    base.WndProc(ref m);
                }
            }
            else
            {
                base.WndProc(ref m);
            }
        }
Example #2
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);
            if (grip_is_ondrag == true)
            {
                this.Cursor = Cursors.Default;
            }
            grip_is_ondrag = false;



            DiscoverPane listedPane = this.GetListedPaneAt(e.Location);

            if (listedPane != null)
            {
                CancelEventArgs evt = new CancelEventArgs();

                evt.Cancel = false;

                OnDiscoverPaneChanging(evt);

                if (!evt.Cancel)
                {
                    this.SelectedPane = listedPane;

                    OnDiscoverPaneChanged(new EventArgs());
                }

                return;
            }

            DiscoverPane buttonPane = this.GetButtonPaneAt(e.Location);

            if (buttonPane != null && buttonPane.Listed)
            {
                CancelEventArgs evt = new CancelEventArgs();

                evt.Cancel = false;

                OnDiscoverPaneChanging(evt);

                if (!evt.Cancel)
                {
                    this.SelectedPane = buttonPane;

                    OnDiscoverPaneChanged(new EventArgs());
                }
            }

            if (this.ChewronRect.Contains(e.Location))
            {
                _ContextMenu.Show(this, e.Location);
            }

            this.PerformLayout();
        }
Example #3
0
        protected override void OnLayout(LayoutEventArgs levent)
        {
            base.OnLayout(levent);

            if (this.IsHandleCreated)
            {
                int h = this.GripperRect.Top;
                h -= this.HeaderRect.Bottom;

                Rectangle rect = new Rectangle(1, this.HeaderRect.Bottom,
                                               this.ClientSize.Width - 2, h);

                int i = 0;

                int count = 0;

                foreach (Control current in base.Controls)
                {
                    current.ClientSize = rect.Size;
                    current.Location   = rect.Location;

                    DiscoverPane pane = (DiscoverPane)current;

                    if (count < this.ShowPanes && this.ShowPanes > 0)
                    {
                        pane.ShowOnList = true;
                    }
                    else
                    {
                        pane.ShowOnList = false;
                    }

                    if (pane.ShowOnList)
                    {
                        int top = this.ListButtonHeight * (i + 1);

                        top = this.SwitchBarRect.Top - top;

                        Rectangle rc = new Rectangle(1, top,
                                                     this.ClientSize.Width - 2, this.ListButtonHeight);

                        pane.ListButtonRect = rc;

                        i++;
                    }
                    count++;
                }

                this.Invalidate();
            }
        }
Example #4
0
        private void addRemoveButtonCheckChanged(object sender, EventArgs e)
        {
            ToolStripMenuItem menuItem = (ToolStripMenuItem)sender;

            DiscoverPane pane = (DiscoverPane)menuItem.Tag;

            if (this.ShowPanes > 0 && pane.ShowOnList)
            {
                this.ShowPanes--;
            }

            pane.Listed = menuItem.Checked;

            this.PerformLayout();
        }
Example #5
0
        void add_nav_click(object sender, EventArgs e)
        {
            IDesignerHost           designerHost        = (IDesignerHost)this.GetService(typeof(IDesignerHost));
            IComponentChangeService componentService    = (IComponentChangeService)this.GetService(typeof(IComponentChangeService));
            DesignerTransaction     designerTransaction = designerHost.CreateTransaction("Add Discover Pane");

            componentService.OnComponentChanging(this.Control, TypeDescriptor.GetProperties(this.Control)["Controls"]);
            DiscoverPane discoverPane = (DiscoverPane)designerHost.CreateComponent(typeof(DiscoverPane));

            this.Control.Controls.Add(discoverPane);
            this.Discover.SelectedPane = discoverPane;
            this.Discover.ShowPanes++;
            componentService.OnComponentChanged(this.Control, TypeDescriptor.GetProperties(this.Control)["Controls"], null, null);
            designerTransaction.Commit();
        }
Example #6
0
        protected override void OnControlRemoved(ControlEventArgs e)
        {
            if (e.Control != null)
            {
                DiscoverPane pane = (DiscoverPane)e.Control;

                if (pane.Listed)
                {
                    if (this.ShowPanes > 0)
                    {
                        this.ShowPanes--;
                    }
                }
            }
            base.OnControlRemoved(e);
            this.PerformLayout();
            this.Invalidate();
        }
Example #7
0
        protected override void OnPaint(PaintEventArgs e)
        {
            bool rtlEnabled = this.RightToLeft == RightToLeft.Yes;

            _CurrentRender.DrawBackground(e.Graphics, this.ClientRectangle, this.BackColor);

            if (this.SelectedPane != null)
            {
                _CurrentRender.DrawHeader(e.Graphics, this.HeaderRect,
                                          this.SelectedPane.Text, _HeaderFont, null, rtlEnabled);
            }

            if (this.SwitchBarRect != Rectangle.Empty)
            {
                this._CurrentRender.DrawDiscoverContentPaneBackground(e.Graphics,
                                                                      this.SwitchBarRect, DrawItemState.None);
            }

            foreach (Control currentControl in base.Controls)
            {
                DiscoverPane currentPane = (DiscoverPane)currentControl;
                if ((currentPane.Listed && (currentPane.ButtonRect != Rectangle.Empty)) &&
                    (currentPane.ButtonRect.X >= 0))
                {
                    DrawItemState paneState = DrawItemState.None;
                    if (this._SelectedPane == currentPane)
                    {
                        paneState |= DrawItemState.HotLight;
                    }
                    else if (_MouseOverPane == currentPane)
                    {
                        paneState |= DrawItemState.HotLight;
                    }
                    if (this._boo && (this._SelectedPane == currentPane))
                    {
                        paneState |= DrawItemState.Selected;
                    }
                    if (this.SelectedPane == currentPane)
                    {
                        paneState |= DrawItemState.Checked;
                    }
                    if (!currentPane.Enabled)
                    {
                        paneState |= DrawItemState.Disabled;
                    }
                    if (currentPane.ShowOnList)//BOOOO
                    {
                        this._CurrentRender.DrawDiscoverContentPaneBackground(e.Graphics, currentPane.ListButtonRect, paneState);
                        this._CurrentRender.DrawDiscoverContentPane(e.Graphics, currentPane.ListButtonRect, paneState,
                                                                    currentPane, this.FooterFont, rtlEnabled);
                        continue;
                    }

                    if (CanShowButton(currentPane))
                    {
                        this._CurrentRender.DrawDiscoverFooterPaneBackground(e.Graphics, currentPane.ButtonRect, paneState);
                        this._CurrentRender.DrawDiscoverFooterPane(e.Graphics, currentPane.ButtonRect, paneState,
                                                                   currentPane, this.FooterFont);
                    }
                }
            }

            if (_DrawGripper)
            {
                this._CurrentRender.DrawGripper(e.Graphics, this.GripperRect);
            }

            if (_DrawChewron)
            {
                this._CurrentRender.DrawChevron(e.Graphics, this.ChewronRect, this.ForeColor);
            }
        }
Example #8
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);



            if (grip_is_ondrag)
            {
                if (this.ShowPanes < 0)
                {
                    this.ShowPanes = 0;
                    return;
                }
                int m = this.GripperRect.Bottom - this.GripperRect.Top;

                m = m / 2;

                Rectangle rcUp = new Rectangle(1, this.GripperRect.Top - this.ListButtonHeight,
                                               this.ClientSize.Width - 2, m + this.ListButtonHeight);

                Rectangle rcDown = new Rectangle(1, this.GripperRect.Bottom + this.ListButtonHeight,
                                                 this.ClientSize.Width - 2, m + this.ListButtonHeight);

                if (rcUp.Contains(e.Location) &&
                    (this.ShowPanes < ListedCount()))
                {
                    this.ShowPanes++;
                }
                else if (rcDown.Contains(e.Location))
                {
                    if (this.ShowPanes > 0)
                    {
                        this.ShowPanes--;
                    }
                }

                old_location = new Point(e.Location.X, this.GripperRect.Top + m);

                this.PerformLayout();
                return;
            }
            if (this.GripperRect.Contains(e.Location))
            {
                this.Cursor = Cursors.SizeNS;
                return;
            }

            DiscoverPane listedPane = this.GetListedPaneAt(e.Location);

            if (listedPane != null)
            {
                if (listedPane.ListButtonRect.Contains(e.Location))
                {
                    this.Cursor = Cursors.Hand;
                }
                else
                {
                    this.Cursor = Cursors.Default;
                }
            }
            else if (this.ChewronRect.Contains(e.Location))
            {
                this.Cursor = Cursors.Hand;
            }
            else
            {
                this.Cursor = Cursors.Default;

                DiscoverPane buttonpane = this.GetButtonPaneAt(e.Location);

                if (buttonpane != null)
                {
                    this.Cursor = Cursors.Hand;
                }

                _MouseOverPane = buttonpane;

                this.Invalidate(this.SwitchBarRect);
            }
        }
Example #9
0
 private bool CanShowButton(DiscoverPane pane)
 {
     return(this.SwitchBarRect.IntersectsWith(pane.ButtonRect));
 }
        public void DrawDiscoverContentPane(System.Drawing.Graphics graphics, System.Drawing.Rectangle bounds, System.Windows.Forms.DrawItemState state, DiscoverPane pane, System.Drawing.Font font, bool rtl)
        {
            int num1 = 5;

            bounds.Inflate(-7, 0);
            Rectangle imgRect    = Rectangle.Empty;
            Rectangle rectangle2 = bounds;

            if (rtl)
            {
                if (pane.LargeImage != null)
                {
                    imgRect = new Rectangle(bounds.Right - pane.LargeImage.Width, (bounds.Top
                                                                                   + (bounds.Height / 2)) - (pane.LargeImage.Height / 2), pane.LargeImage.Width,
                                            pane.LargeImage.Height);
                    rectangle2.Width -= (pane.LargeImage.Width + num1);
                }
            }
            else if (pane.LargeImage != null)
            {
                imgRect = new Rectangle(bounds.Left, (bounds.Top + (bounds.Height / 2))
                                        - (pane.LargeImage.Height / 2), pane.LargeImage.Width, pane.LargeImage.Height);
                rectangle2.X     += (pane.LargeImage.Width + num1);
                rectangle2.Width -= (pane.LargeImage.Width + num1);
            }
            if (imgRect != Rectangle.Empty)
            {
                Image image1 = pane.LargeImage;
                if ((state & DrawItemState.Disabled) == DrawItemState.Disabled)
                {
                    graphics.DrawImage(image1, imgRect, 0, 0, image1.Width, image1.Height,
                                       GraphicsUnit.Pixel, new System.Drawing.Imaging.ImageAttributes()); //TODO:ImageAttributes
                }
                else
                {
                    graphics.DrawImage(image1, imgRect);
                }
            }
            using (StringFormat strFormat = new StringFormat(StringFormat.GenericTypographic))
            {
                strFormat.Trimming      = StringTrimming.EllipsisCharacter;
                strFormat.FormatFlags  |= StringFormatFlags.NoWrap;
                strFormat.LineAlignment = StringAlignment.Center;
                strFormat.HotkeyPrefix  = HotkeyPrefix.Show;
                if (rtl)
                {
                    strFormat.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
                }
                if ((state & DrawItemState.Disabled) == DrawItemState.Disabled)
                {
                    graphics.DrawString(pane.Text, font, SystemBrushes.ControlDark,
                                        (RectangleF)rectangle2, strFormat);
                }
                else
                {
                    using (SolidBrush stringBrush = new SolidBrush(((state & DrawItemState.Selected) ==
                                                                    DrawItemState.Selected) ? this.BorderColor : pane.ForeColor)) //TODO:this.BorderColor
                    {
                        graphics.DrawString(pane.Text, font, stringBrush, (RectangleF)rectangle2, strFormat);
                    }
                }
            }
        }
        public void DrawDiscoverFooterPane(System.Drawing.Graphics graphics, System.Drawing.Rectangle bounds, System.Windows.Forms.DrawItemState state, DiscoverPane pane, System.Drawing.Font font)
        {
            Rectangle imgBounds = new Rectangle((bounds.X + (bounds.Width / 2)) - 8,
                                                (bounds.Y + (bounds.Height / 2)) - 8, 0x10, 0x10);
            Image drawImage = (pane.SmallImage != null) ? pane.SmallImage : pane.LargeImage;

            if (drawImage != null)
            {
                if ((state & DrawItemState.Disabled) == DrawItemState.Disabled)
                {
                    graphics.DrawImage(drawImage, imgBounds, 0, 0, drawImage.Width, drawImage.Height, GraphicsUnit.Pixel,
                                       new System.Drawing.Imaging.ImageAttributes());//TODO: ImageAttributes
                }
                else
                {
                    graphics.DrawImage(drawImage, imgBounds);
                }
            }
        }