Show() private méthode

private Show ( ) : void
Résultat void
Exemple #1
0
        internal void CreateToolStrip()
        {
            if (Enabled == false)
            {
                return;
            }

            if (dropDownItems.Count == 0)
            {
                return;
            }

            var dropDownBounds = new Rectangle(Point.Empty, Owner.Size);

            for (int i = 0; i < dropDownItems.Count; i++) // Reset items.
            {
                var item = dropDownItems[i];
                item.Unselect();

                var dropDownItem = item as ToolStripDropDownItem;
                if (dropDownItem == null)
                {
                    continue;
                }

                dropDownItem.ArrowImage = ApplicationResources.Images.DropDownRightArrow;
                dropDownItem.ArrowColor = Color.Black;
            }

            var direction = ToolStripDropDownDirection.Right;

            if (Owner.IsDropDown == false)
            {
                direction = ToolStripDropDownDirection.BelowRight;
            }

            dropDownToolStrip = userDropDown == null
                ? new ToolStripDropDownMenu()
                : userDropDown;
            dropDownToolStrip.OwnerItem = this;
            dropDownToolStrip.Items.AddRange(dropDownItems);
            dropDownToolStrip.selectedItem   = dropDownToolStrip.SelectNextToolStripItem(null, true);
            dropDownToolStrip.shouldFixWidth = true;
            dropDownToolStrip.direction      = direction;
            dropDownToolStrip.Location       = DropDownDirectionToDropDownBounds(direction, dropDownBounds).Location;
            dropDownToolStrip.Disposed      += DropDownToolStrip_Disposed;
            dropDownToolStrip.Show(dropDownToolStrip.Location);

            if (uwfDropDownCreated != null)
            {
                uwfDropDownCreated(dropDownToolStrip);
            }

            pressed = true;
        }
        public void Show(Point screenLocation)
        {
            ToolStripControlHost host = new ToolStripControlHost(this);
            ToolStripDropDown = new ToolStripDropDown();
            ToolStripDropDown.Items.Clear();
            ToolStripDropDown.Items.Add(host);

            ToolStripDropDown.Padding = Padding.Empty;
            ToolStripDropDown.Margin = Padding.Empty;
            host.Padding = Padding.Empty;
            host.Margin = Padding.Empty;

            ToolStripDropDown.Closed += new ToolStripDropDownClosedEventHandler(ToolStripDropDown_Closed);

            ToolStripDropDown.Show(screenLocation);
        }
Exemple #3
0
        public void Show(Point screenLocation)
        {
            ToolStripControlHost host = new ToolStripControlHost(this);

            ToolStripDropDown = new ToolStripDropDown();
            ToolStripDropDown.Items.Clear();
            ToolStripDropDown.Items.Add(host);

            ToolStripDropDown.Padding = Padding.Empty;
            ToolStripDropDown.Margin  = Padding.Empty;
            host.Padding = Padding.Empty;
            host.Margin  = Padding.Empty;

            ToolStripDropDown.Closed += new ToolStripDropDownClosedEventHandler(ToolStripDropDown_Closed);

            ToolStripDropDown.Show(screenLocation);
        }
Exemple #4
0
        private void SelectModel(object sender, EventArgs e)
        {
            // We want to pop up a small drop-down window with a
            // property grid that can be used to set all of the properties
            // in the ModelViewSettings object. This is a handy non-model
            // way to change the selected model

            var dropDownCtrl = new PropertyGrid();
            dropDownCtrl.SelectedObject = Object;
            dropDownCtrl.ToolbarVisible = false;
            dropDownCtrl.HelpVisible = false;

            var toolDrop = new ToolStripDropDown();
            var toolHost = new ToolStripControlHost(dropDownCtrl);
            toolHost.Margin = new Padding(0);
            toolDrop.Padding = new Padding(0);
            toolDrop.Items.Add(toolHost);

            // we don't have a way to know the ideal height of the drop down ctrl... just make a guess based on the text height
            toolHost.AutoSize = false;
            toolHost.Size = new Size(512, 8 * dropDownCtrl.Font.Height);

            toolDrop.Show(this, PointToClient(MousePosition));
        }
Exemple #5
0
        private void btnCustomMoleculeColumns_Click(object sender, EventArgs e)
        {
            var checkedListBox = new CheckedListBox {CheckOnClick = true};
            checkedListBox.ItemCheck += CheckedListBox_ItemCheck;
            checkedListBox.Items.Clear();
            foreach (DataGridViewColumn c in gridViewTransitionList.Columns)
            {
                checkedListBox.Items.Add(c.HeaderText, c.Visible);
            }
            checkedListBox.Height = checkedListBox.Items.Count * radioMolecule.Height * 12 / 10;
            checkedListBox.Width = radioMolecule.Width * 3;
            var controlHost = new ToolStripControlHost(checkedListBox)
            {
                Padding = Padding.Empty,
                Margin = Padding.Empty,
                AutoSize = false
            };

            var popup = new ToolStripDropDown {Padding = Padding.Empty};
            popup.Items.Add(controlHost);

            popup.Show(btnCustomMoleculeColumns.PointToScreen(new Point(0, -checkedListBox.Height)));
        }
Exemple #6
0
        private void ShowTooltip()
        {
            Point loc = Cursor.Position;
            Control child = this.GetChildAtPoint(this.PointToClient(loc));
            if (child is EvilDPSBar)
            {
                EvilDPSGraph g = GetGraphForBar(child);
                if (g.Samples.Count == 0)
                    return;
                ToolStripDropDown f = new ToolStripDropDown();
                f.Margin = Padding.Empty;
                f.Padding = Padding.Empty;
                ToolStripControlHost host = new ToolStripControlHost(g);
                host.Padding = Padding.Empty;
                host.Margin = Padding.Empty;
                f.Items.Add(host);
                f.Width = 300;
                f.Height = 80;
                g.Dock = DockStyle.Fill;
                host.Dock = DockStyle.Fill;
                g.Width = 300;
                g.Height = 80;
                f.Show(Cursor.Position);

                currentGraph = g;
            }
        }
        /// <summary>
        /// Shows this Popup on the specified location of the screen
        /// </summary>
        /// <param name="screenLocation"></param>
        public void Show(Point screenLocation)
        {
            var host = new ToolStripControlHost(this);
            ToolStripDropDown = new ToolStripDropDown();
            ToolStripDropDown.Items.Clear();
            ToolStripDropDown.Items.Add(host);

            ToolStripDropDown.Padding = Padding.Empty;
            ToolStripDropDown.Margin = Padding.Empty;
            host.Padding = Padding.Empty;
            host.Margin = Padding.Empty;

            ToolStripDropDown.Opening += ToolStripDropDown_Opening;
            ToolStripDropDown.Closing += ToolStripDropDown_Closing;
            ToolStripDropDown.Closed += ToolStripDropDown_Closed;
            ToolStripDropDown.Show(screenLocation);
            MouseWheel += ToolStripDropDown_MouseWheel;

            OnShowed(EventArgs.Empty);
        }
Exemple #8
0
        public override bool OnClick(System.Windows.Forms.Control container, System.Windows.Forms.MouseEventArgs evnt, System.Drawing.Drawing2D.Matrix viewTransform)
		{
			base.OnClick(container, evnt, viewTransform);

            if (evnt.Button == System.Windows.Forms.MouseButtons.Left)
            {
                var basePts = new PointF[] { 
                    new PointF(Node.bounds.Left + GraphConstants.HorizontalSpacing, bounds.Top), 
                    new PointF(Node.bounds.Right + GraphConstants.HorizontalSpacing - GraphConstants.NodeExtraWidth, bounds.Bottom) };
                viewTransform.TransformPoints(basePts);

                var dropDownCtrl = new ListBox();
                dropDownCtrl.BorderStyle = BorderStyle.None;
                dropDownCtrl.Margin = new Padding(0);
                dropDownCtrl.Padding = new Padding(0);

                dropDownCtrl.DrawMode = DrawMode.OwnerDrawVariable;
                dropDownCtrl.DrawItem +=
                    (object sender, DrawItemEventArgs e) =>
                    {
                        var lb = sender as ListBox;
                        var item = lb.Items[e.Index];

                        bool selectedState = e.State != DrawItemState.None;

                        // We have to draw the background every item, because the control 
                        // background isn't refreshed on state changes
                        e.Graphics.FillRectangle(selectedState ? Brushes.Gray : BackgroundBrush, e.Bounds);
                        e.Graphics.DrawString(
                            item.ToString(), SystemFonts.MenuFont, selectedState ? Brushes.Black : Brushes.White,
                            e.Bounds, GraphConstants.LeftTextStringFormat);
                    };

                dropDownCtrl.MeasureItem +=
                    (object sender, MeasureItemEventArgs e) =>
                    {
                        var lb = sender as ListBox;
                        var item = lb.Items[e.Index];
                        var size = new Size(GraphConstants.MinimumItemWidth, GraphConstants.MinimumItemHeight);
                        var textSize = e.Graphics.MeasureString(
                            item.ToString(), SystemFonts.MenuFont,
                            size, GraphConstants.LeftMeasureTextStringFormat);
                        e.ItemWidth = (int)textSize.Width;
                        e.ItemHeight = (int)textSize.Height;
                    };

                dropDownCtrl.BackColor = Color.FromArgb(96, 96, 96);

                dropDownCtrl.Items.AddRange(Items);
                dropDownCtrl.SelectedIndex = SelectedIndex;
                
                var toolDrop = new ToolStripDropDown();
                var toolHost = new ToolStripControlHost(dropDownCtrl);
                toolHost.Margin = new Padding(0);
                toolDrop.Padding = new Padding(0);
                toolDrop.Items.Add(toolHost);

                // Unfortunately the AutoSize functionality for toolHost just doesn't
                // work with an owner draw list box... Perhaps MeasureItem isn't called
                // until the list box is first drawn -- but that is after the tool host
                // has done it's auto size
                toolHost.AutoSize = false;
                toolHost.Size = new Size((int)(basePts[1].X - basePts[0].X), dropDownCtrl.PreferredHeight + 20);
                
                dropDownCtrl.SelectedIndexChanged +=
                    (object sender, System.EventArgs e) =>
                    {
                        var lb = sender as ListBox;
                        if (lb != null)
                            SelectedIndex = lb.SelectedIndex;
                        toolDrop.Close();
                    };

                toolDrop.Show(container, new Point((int)basePts[0].X, (int)basePts[1].Y + 4));
                return true;
            }

            return false;
		}
Exemple #9
0
        /*
        protected internal override void Paint(Graphics gr)
        {
          if (MouseIsOver && m_Grid.ColumnResizeAllowed &&  m_Grid.m_RepositioningColumn==null)
        using(var br =  new LinearGradientBrush(Region, Color.Blue, Color.White, LinearGradientMode.ForwardDiagonal))
        {
          gr.FillRectangle(br, Region);
        }
        }
        */
        protected internal override void OnMouseClick(MouseEventArgs e)
        {
            // Right click on the right edge of a column - open the column picker
              if (e.Button == MouseButtons.Right)
              {
            if (!m_Grid.Columns.Any() || !m_Grid.ColumnHidingAllowed)
              return;

            var longestText     = new string('W', m_Grid.Columns.Max(c => c.Title.Length));
            var textSize        = TextRenderer.MeasureText(longestText, m_Grid.Font);
            int preferredHeight = (m_Grid.Columns.Count * textSize.Height) + 7;
            var checkedListBox  = new CheckedListBox()
            {
              CheckOnClick = true,
              Height       = (preferredHeight < 350) ? preferredHeight : 350,
              Width        = Math.Min(textSize.Width, m_Grid.Width),
            };
            checkedListBox.ItemCheck += (sender, ea) =>
            {
              var column = m_Grid.Columns.FirstOrDefault(c => c.Title.Equals(checkedListBox.Items[ea.Index].ToString()));
              if (column == null) return;
              if (m_Grid.Columns.Count(c => c.Visible) > 1 || ea.NewValue == CheckState.Checked)
            column.Visible = ea.NewValue == CheckState.Checked;
              else
            ea.NewValue = ea.CurrentValue;
            };

            foreach (var c in m_Grid.Columns)
              checkedListBox.Items.Add(c.Title, c.Visible);

            var controlHost = new ToolStripControlHost(checkedListBox)
            {
              Padding  = Padding.Empty,
              Margin   = Padding.Empty,
              AutoSize = false
            };

            // The following permits handling of custom actions such as applying themes
            // to the newly created control:
            m_Grid.Controls.Add(checkedListBox);

            var popup = new ToolStripDropDown() {Padding = Padding.Empty};
            popup.Items.Add(controlHost);
            popup.Disposed += (sender, args) => m_Grid.Controls.Remove(checkedListBox); // This removes checkedListBox from m_Grid.Controls

            popup.Show(m_Grid.PointToScreen(e.Location));
              }

              base.OnMouseClick(e);
        }