private void Ipanel_MouseDown(object sender, MouseEventArgs e) { PanelNoTheme p = sender as PanelNoTheme; ExtCheckBox cb = controllist[(int)p.Tag].checkbox; cb.CheckState = cb.CheckState == CheckState.Unchecked ? CheckState.Checked : CheckState.Unchecked; }
private ControlSet AddItem(string tag, string text, Image img = null, string exclusive = null, bool disableuncheck = false) { ControlSet c = new ControlSet(); panelscroll.SuspendLayout(); c.tag = tag; c.exclusivetags = exclusive; c.disableuncheck = disableuncheck; ExtCheckBox cb = new ExtCheckBox(); cb.BackColor = this.BackColor; cb.CheckBoxColor = this.CheckBoxColor; cb.CheckBoxInnerColor = this.CheckBoxInnerColor; cb.CheckColor = this.CheckColor; cb.MouseOverColor = this.MouseOverColor; cb.FlatStyle = FlatStyle; cb.TickBoxReductionRatio = TickBoxReductionRatio; cb.CheckedChanged += CheckedIconListBoxForm_CheckedChanged; c.checkbox = cb; panelscroll.Controls.Add(cb); Label lb = new Label() { AutoSize = false, // don't autosize here, it seems to take forever. Text = (string)text, Tag = controllist.Count, ForeColor = this.ForeColor, TextAlign = ContentAlignment.MiddleLeft, }; lb.MouseDown += Text_MouseDown; c.label = lb; panelscroll.Controls.Add(lb); if (img != null) { PanelNoTheme ipanel = new PanelNoTheme() { BackgroundImage = img, Tag = controllist.Count, BackgroundImageLayout = ImageLayout.Stretch, }; ipanel.MouseDown += Ipanel_MouseDown; c.icon = ipanel; panelscroll.Controls.Add(ipanel); } panelscroll.ResumeLayout(); return(c); }
public void AddItem(string tag, string text, Image img = null) { ControlSet c = new ControlSet(); c.tag = tag; ExtCheckBox cb = new ExtCheckBox(); cb.BackColor = this.BackColor; cb.CheckBoxColor = this.CheckBoxColor; cb.CheckBoxInnerColor = this.CheckBoxInnerColor; cb.CheckColor = this.CheckColor; cb.MouseOverColor = this.MouseOverColor; cb.FlatStyle = FlatStyle; cb.TickBoxReductionSize = TickBoxReductionSize; cb.CheckedChanged += CheckedIconListBoxForm_CheckedChanged; cb.Tag = controllist.Count; c.checkbox = cb; panelscroll.Controls.Add(cb); Label lb = new Label() { Text = (string)text, Tag = controllist.Count, Font = this.Font, ForeColor = this.ForeColor, TextAlign = ContentAlignment.MiddleLeft, }; lb.MouseDown += Text_MouseDown; c.label = lb; panelscroll.Controls.Add(lb); panelscroll.Controls.Add(lb); if (img != null) { PanelNoTheme ipanel = new PanelNoTheme() { BackgroundImage = img, Tag = controllist.Count, BackgroundImageLayout = ImageLayout.Stretch, }; ipanel.MouseDown += Ipanel_MouseDown; c.icon = ipanel; panelscroll.Controls.Add(ipanel); } controllist.Add(c); }
void Display() { if (ImageList == null) { return; } //System.Diagnostics.Debug.WriteLine("Mode " + tdm); if (StripMode != StripModeType.ListSelection && imagepanels == null && ImageList != null) // on first entry.. { imagepanels = new PanelNoTheme[ImageList.Length]; for (int inp = 0; inp < imagepanels.Length; inp++) { imagepanels[inp] = new PanelNoTheme() { BackgroundImage = ImageList[inp], Tag = inp, BackgroundImageLayout = ImageLayout.Stretch, Visible = false, Size = pimageSelectedIcon.Size, }; imagepanels[inp].Click += TabIconClicked; imagepanels[inp].MouseEnter += MouseEnterPanelObjects; imagepanels[inp].MouseLeave += MouseLeavePanelObjects; if (ShowPopOut) { imagepanels[inp].ContextMenuStrip = contextMenuStrip1; } if (TextList != null) { toolTip1.SetToolTip(imagepanels[inp], TextList[inp]); toolTip1.ShowAlways = true; // if not, it never appears } panelStrip.Controls.Add(imagepanels[inp]); } } int tabno = 0; bool showselectionicon = true; // set up for compressed mode.. bool showtext = true; bool showpopouticon = false; bool showlistselection = false; int tabfieldspacing = Font.ScalePixels(8); int xpos = pimageSelectedIcon.Width + tabfieldspacing; // start here bool arrowson = false; if (StripMode == StripModeType.ListSelection) // in list mode { if (tdm != TabDisplayMode.Compressed) // values are Compressed.. Expanded.. ExpandedInList { if (ShowPopOut) { showselectionicon = false; // swap what is shown.. showpopouticon = true; } showlistselection = true; xpos += pimageListSelection.Width + tabfieldspacing; // space on for allowing panel selector } } else if (tdm != TabDisplayMode.Compressed) // show icons.. { for (; tabno < tabdisplaystart; tabno++) { imagepanels[tabno].Visible = false; } // don't trust extButtonDrawnHelp.Visible - we all know that does not get set until its redrawn. use another decision to decide on width int stoppoint = DisplayRectangle.Width - Spacing - (CurrentControl != null && HelpAction != null ? extButtonDrawnHelp.Width : 0); // stop here int spaceforarrowsandoneicon = panelArrowLeft.Width + Spacing + imagepanels[0].Width + Spacing + panelArrowRight.Width; if (xpos + spaceforarrowsandoneicon > stoppoint || tdm == TabDisplayMode.ExpandedFixed) // no space at all or fixed open { xpos = 0; // turn off titles, use all the space showselectionicon = false; } int tabtotalwidth = 0; for (int ip = 0; ip < imagepanels.Length; ip++) { tabtotalwidth += imagepanels[ip].Width + Spacing * 2; // do it now due to the internal scaling due to fonts // System.Diagnostics.Debug.WriteLine("Image panel size " + ip + " w " + imagepanels[ip].Width + " width " + Images[ip].Width); } tabtotalwidth -= Spacing * 2; // don't count last spacing. if (xpos + tabtotalwidth > stoppoint) // if total tab width (icon space icon..) too big { panelArrowLeft.Location = new Point(xpos, 4); xpos += panelArrowLeft.Width + Spacing; // move over allowing space for left and spacing stoppoint -= panelArrowRight.Width + Spacing; // allow space for right arrow plus padding arrowson = true; } tabsvisibleonscreen = 0; for (; tabno < imagepanels.Length && xpos < stoppoint - ImageList[tabno].Width; tabno++) { // if its soo tight, may display nothing, thats okay imagepanels[tabno].Location = new Point(xpos, 3); xpos += imagepanels[tabno].Width + Spacing * 2; imagepanels[tabno].Visible = true; tabsvisibleonscreen++; if (SelectedBackColor != Color.Transparent) { imagepanels[tabno].BackColor = (tabno == selectedindex) ? SelectedBackColor : Color.Transparent; } //System.Diagnostics.Debug.WriteLine("Tab " + tabno + " Col " + imagepanels[tabno].BackColor); } if (arrowson) { panelArrowRight.Location = new Point(xpos, 4); } if (tdm == TabDisplayMode.ExpandedFixed) { showtext = true; } else { if (ShowPopOut && showselectionicon) { showselectionicon = false; showpopouticon = true; } showtext = false; } } if (imagepanels != null) { for (; tabno < imagepanels.Length; tabno++) { imagepanels[tabno].Visible = false; } } panelStrip.SuspendLayout(); // important to suspend layout otherwise we get popping //System.Diagnostics.Debug.WriteLine(this.Name + " seli" + showselectionicon + " showp " + showpopouticon + " text" + showtext + " lists " + showlistselection); pimageListSelection.Size = pimagePopOutIcon.Size = pimageSelectedIcon.Size; // duplicate size across so panelstrip does not resize pimageSelectedIcon.Visible = showselectionicon; pimagePopOutIcon.Location = pimageSelectedIcon.Location; // same position, mutually exclusive pimagePopOutIcon.Visible = showpopouticon; pimageListSelection.Location = new Point(pimageSelectedIcon.Right + tabfieldspacing, pimageSelectedIcon.Top); pimageListSelection.Visible = showlistselection; labelTitle.Location = new Point(xpos + tabfieldspacing, labelTitle.Top); labelTitle.Visible = showtext; labelControlText.Location = new Point(labelTitle.Right + tabfieldspacing, labelTitle.Top); labelControlText.Visible = showtext; //System.Diagnostics.Debug.WriteLine("Panel " + panelStrip.Size + " " + pimageListSelection.Size + " " + pimagePopOutIcon.Size + " " + panelStrip.AutoSize); panelArrowRight.Visible = panelArrowLeft.Visible = arrowson; panelStrip.ResumeLayout(); }