/// <summary> /// Does to resizing of the browser control buttons to scale for the current screen resolution (full screen). /// </summary> private void ResizeButtons() { RemoveHiddenButtons(); // remove the "disabled" buttons from their parent panel.. int spacing = 1920 / 100 + 1; // my screen width.. voodoo and/or hoodoo magic :-) int leftStart = Width - (pnButtons.Height * pnButtons.Controls.Count) - (pnButtons.Controls.Count * spacing); // Calculate the most left position for the browser control buttons leftStart /= 2; // some division for some reason foreach (Control ctrl in pnButtons.Controls) // Go thought the browser control buttons { if (ctrl.GetType() != typeof(Panel)) // We use Panel class instances as buttons.. { continue; // So, if not panel then do nothing.. } (ctrl as Panel).Top = 0; (ctrl as Panel).Width = pnButtons.Height; // The height is the correct value for width and height to make a square button (Panel) (ctrl as Panel).Height = pnButtons.Height; (ctrl as Panel).Left = leftStart + Convert.ToInt32((ctrl as Panel).Tag.ToString()) * pnButtons.Height + // pnButtons is anchored, so it will give us the correct height for the buttons Convert.ToInt32((ctrl as Panel).Tag.ToString()) * spacing; // add some space between the browser control buttons.. // The ordering of the buttons is indicated by their Tag value, so use it for calculation too.. } tlpPopDown.ColumnStyles[0].Width = leftStart / 2; // Span the right and left outer-most columns of the TableLayoutPanel.. tlpPopDown.ColumnStyles[tlpPopDown.ColumnCount - 1].Width = leftStart / 2; // .. UtilsMisc.ResizeFontWidthHeight(lbUrl); // Resize the labels fonts UtilsMisc.ResizeFontHeight(lbToolTip, true); // END: Resize the labels fonts }
/// <summary> /// Sets the button images (Panel) to indicate their enabled/disabled state.. /// </summary> private void SetButtonImages() { btnPlay.BackgroundImage = // play button image.. btnPlay.Enabled ? Properties.Resources.play : UtilsMisc.MakeGrayscale3(Properties.Resources.play); btnSeekStart.BackgroundImage = // jump to the beginning button image.. btnSeekStart.Enabled ? Properties.Resources.previous : UtilsMisc.MakeGrayscale3(Properties.Resources.previous); btnSeekEnd.BackgroundImage = // jump to the end button image.. btnSeekEnd.Enabled ? Properties.Resources.next : UtilsMisc.MakeGrayscale3(Properties.Resources.next); btnWindBackward.BackgroundImage = // jump to the end button image.. btnWindBackward.Enabled ? Properties.Resources.wind_back : UtilsMisc.MakeGrayscale3(Properties.Resources.wind_back); btnWindForward.BackgroundImage = // wind forward button image.. btnWindForward.Enabled ? Properties.Resources.wind_forward : UtilsMisc.MakeGrayscale3(Properties.Resources.wind_forward); btnSelectSubtitle.BackgroundImage = // wind forward button image.. btnSelectSubtitle.Enabled ? Properties.Resources.subtitle : UtilsMisc.MakeGrayscale3(Properties.Resources.subtitle); btnVolume.BackgroundImage = // volume button image.. btnVolume.Enabled ? (muted ? Properties.Resources.volume_off : Properties.Resources.volume) : UtilsMisc.MakeGrayscale3(Properties.Resources.volume); }
/// <summary> /// Sets the button images (Panel) to indicate their enabled/disabled state.. /// </summary> private void SetButtonImages() { btnBack.BackgroundImage = // browser back button image.. btnBack.Enabled ? Properties.Resources.back : UtilsMisc.MakeGrayscale3(Properties.Resources.back); btnForward.BackgroundImage = // browser forward button image.. btnForward.Enabled ? Properties.Resources.forward : UtilsMisc.MakeGrayscale3(Properties.Resources.forward); }
/// <summary> /// Sets the button images (Panel) to indicate their enabled/disabled state.. /// </summary> private void SetButtonImages() { btnPervious.BackgroundImage = // navigation back button image.. btnPervious.Enabled ? Properties.Resources.back : // the button is enabled.. UtilsMisc.MakeGrayscale3(Properties.Resources.back); // the button is disabled.. btnNext.BackgroundImage = // navigation forward button image.. btnNext.Enabled ? Properties.Resources.forward : // the button is enabled.. UtilsMisc.MakeGrayscale3(Properties.Resources.forward); // the button is disabled.. }
/// <summary> /// Initializes a new instance of the <see cref="FormDialogSelectCustomContent"/> class. /// </summary> public FormDialogSelectCustomContent() { InitializeComponent(); DBLangEngine.DBName = "lang.sqlite"; // Do the VPKSoft.LangLib == translation DBLangEngine.AddNameSpace("VPKSoft.ImageButton"); // no localization from a foreign name space.. DBLangEngine.AddNameSpace("VPKSoft.VisualListBox"); // no localization from a foreign name space.. if (VPKSoft.LangLib.Utils.ShouldLocalize() != null) { DBLangEngine.InitalizeLanguage("vamp.Messages", VPKSoft.LangLib.Utils.ShouldLocalize(), false); return; // After localization don't do anything more. } UtilsMisc.ScaleToFitScreen(this); // this dialog doesn't require much localization.. btOK.Text = DBLangEngine.GetMessage("msgOK", "OK|As in an OK button"); btCancel.Text = DBLangEngine.GetMessage("msgCancel", "Cancel|As in a Cancel button"); }
// resize/layout some content in the dialog when shown.. private void SelectCustomContentDialog_Shown(object sender, EventArgs e) { // if there is no given caption, resize the table layout panel accordingly.. if (textCaption == string.Empty) { lbCaption.Visible = false; tlpMain.RowStyles[0] = new RowStyle(SizeType.Percent, 0); tlpMain.RowStyles[1] = new RowStyle(SizeType.Percent, 90); tlpMain.RowStyles[2] = new RowStyle(SizeType.Percent, 10); } // if there is a given caption, resize the table layout panel accordingly.. else { lbCaption.Visible = true; tlpMain.RowStyles[0] = new RowStyle(SizeType.Percent, 10); tlpMain.RowStyles[1] = new RowStyle(SizeType.Percent, 80); tlpMain.RowStyles[2] = new RowStyle(SizeType.Percent, 10); UtilsMisc.ResizeFontHeight(lbCaption, true); // Resize the labels fonts } // END: Resize the labels fonts }
/// <summary> /// The constructor of the SelectSubtitleForm class. /// </summary> public FormSelectSubtitle() { InitializeComponent(); Controls.Add(tlpMain); DBLangEngine.DBName = "lang.sqlite"; // Do the VPKSoft.LangLib == translation DBLangEngine.AddNameSpace("VPKSoft.VisualFileBrowser"); // no localization from a foreign name space.. if (VPKSoft.LangLib.Utils.ShouldLocalize() != null) { DBLangEngine.InitalizeLanguage("vamp.Messages", VPKSoft.LangLib.Utils.ShouldLocalize(), false); return; // After localization don't do anything more. } UtilsMisc.ScaleToFitScreen(this); DBLangEngine.InitalizeLanguage("vamp.Messages"); btOK.Text = DBLangEngine.GetMessage("msgOK", "OK|As in an OK button"); btCancel.Text = DBLangEngine.GetMessage("msgCancel", "Cancel|As in a Cancel button"); }
// list the location(s) or URL(s) given to the control via an event subscribtion.. private void ListLocations(string debugWhoCalled) { SuspendLayout(); // do not "excessively" stress the (G)UI.. pnLocationList.SuspendLayout(); // AGAIN: do not "excessively" stress the (G)UI.. vsbVertical.Width = SystemInformation.VerticalScrollBarWidth; // make the visual scroll bar to the size of the automatic scroll bar.. // .. so it can be "hidden".. // clear the previously constructed controls and unsubscribe their event handlers.. ClearControls(false); // do show the backward and forward buttons only if a property requires a visibility.. tlpBackForward.Visible = BackForwardButtonsVisible; // do show the add button only if a property requires a visibility.. pnAddSomething.Visible = AddLocationButtonVisible; pnAddSomething.BackgroundImage = AddLocationButtonVisible ? AddItemButton : null; // assign the add "button" image if required (visible).. pnBack.BackgroundImage = BackForwardButtonsVisible ? BackButtonImage : null; // assign the backward "button" image if required (visible).. pnForward.BackgroundImage = BackForwardButtonsVisible ? ForwardButtonImage : null; // assign the forward "button" image if required (visible).. // if visibility is required set their sizes accordingly.. tlpMain.RowStyles[0] = BackForwardButtonsVisible ? new RowStyle(SizeType.Absolute, ItemMaxHeight) : // visibility - so the size must be of some value.. new RowStyle(SizeType.Absolute, 0.0f); // no visibility - so the size must of value of zero.. tlpMain.RowStyles[2] = AddLocationButtonVisible ? new RowStyle(SizeType.Absolute, ItemMaxHeight) : // visibility - so the size must be of some value.. new RowStyle(SizeType.Absolute, 0.0f); // no visibility - so the size must of value of zero.. int topPosition = 0; // this would be the top position of an item in the list of location(s) or URL(s).. do remember to increase! foreach (KeyValuePair <string, string> location in locationList) { // A TableLayoutPanel for an item TableLayoutPanel tableLayoutPanel = new TableLayoutPanel { RowCount = 1, // only one row is needed.. ColumnCount = 2 // two column are required.. }; // create the "base" control for an item in the list of (you know).. tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100.0f)); // as there is only one row is's size is 100%.. // if a delete item button is required the give it a reasonable size.. if (ShowDeleteButton) { tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100.0f)); } else // ..otherwise give it a useless size.. { tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 0.0f)); } // create a base for an item (TableLayoutPanel) based on the property of ItemMaxHeight's value.. tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, ItemMaxHeight)); // ..do create a column style for it.. tableLayoutPanel.Margin = new Padding(0); // no margins are required as the control is designed to serve in a full screen mode.. tableLayoutPanel.MaximumSize = new Size(pnLocationList.ClientSize.Width, ItemMaxHeight); // .. for layout safety, do add it a constraint.. tableLayoutPanel.Size = new Size(pnLocationList.ClientSize.Width, ItemMaxHeight); // do set the size for an item.. tableLayoutPanel.Location = new Point(0, topPosition); // .. and give it a "reasonable" position.. topPosition += ItemMaxHeight; // .. and align it to it's parent.. tableLayoutPanel.Tag = location.Value; // save an actual location to the control's tag.. tableLayoutPanel.BackColor = ItemBackgroundColor; // and now give them their given colors.. tableLayoutPanel.ForeColor = ItemForeColor; // A Label for an item.. Label label = new Label { Text = location.Value, // text should differ from it's actual location.. Tag = location.Key, // AGAIN: save an actual location to the control's tag.. BackColor = ItemBackgroundColor, // and now give them their given colors.. ForeColor = ItemForeColor, Dock = DockStyle.Fill, // dock the control to fill its given location.. Margin = new Padding(0) // no padding.. }; // .. so create a label.. // measure the font to fit the label using a long string of Unicode characters.. UtilsMisc.ResizeFontHeight(label, true, 0.5f, ItemMaxHeight); // add the label to it's parent tableLayoutPanel.Controls.Add(label, 0, 0); label.Parent = tableLayoutPanel; // subscribe to event handlers so the control can react to user input correctly.. label.MouseEnter += ItemMouseEnter; label.MouseLeave += ItemMouseLeave; label.Click += ItemClickHandler; // END: subscribe to event handlers so the control can react to user input correctly.. // A Panel for to act as a button for item's deletion if (ShowDeleteButton) // no need to create this if it's not visible { Panel panel = new Panel(); // create a panel to act as a button.. panel.SuspendLayout(); // do not "excessively" stress the (G)UI.. panel.Tag = location.Key; // just add the Tag and "Text" properties to the item's actual location.. panel.Text = location.Key; panel.BackColor = ItemBackgroundColor; // and now give "button" their given colors.. panel.ForeColor = ItemForeColor; panel.Dock = DockStyle.Fill; // dock can be set to fill, the column style should handle the rest.. panel.Margin = new Padding(0); // no padding.. panel.BackgroundImageLayout = ImageLayout.Zoom; // make the image to fit the panel.. panel.BackgroundImage = DeleteItemImage; // assign the image to the panel acting as a button.. tableLayoutPanel.Controls.Add(panel, 1, 0); // add the panel to it's parent (the item holder).. panel.Parent = tableLayoutPanel; // assign the correct parent for the panel.. panel.MouseEnter += ItemMouseEnter; // subscribe to event handlers so the control can react to user input correctly.. panel.MouseLeave += ItemMouseLeave; panel.Click += ItemClickHandler; // END: subscribe to event handlers so the control can react to user input correctly.. panel.ResumeLayout(); // do not "excessively" stress the (G)UI.. } pnLocationList.Controls.Add(tableLayoutPanel); // a location item is no ready to be added to the parent control.. tableLayoutPanel.Parent = pnLocationList; // .. give the item a parent.. } pnLocationList.ResumeLayout(); // no "excessively" (G)UI stressing isn't coming by the layout anymore.. ResumeLayout(); DoNoHScroll(); // hide horizontal scrolling.. }