### MetroStyleManager Usage and Cloning Source: https://context7.com/dennismagno/metroframework-modern-ui/llms.txt Illustrates manual instantiation and configuration of MetroStyleManager, including setting the owner, style, and theme. It also shows how to clone a manager for a child form and dynamically switch accent colors at runtime. ```csharp using MetroFramework.Components; // Typically added via designer; manual usage: MetroStyleManager manager = new MetroStyleManager(); manager.Owner = myMetroForm; manager.Style = MetroColorStyle.Orange; manager.Theme = MetroThemeStyle.Dark; // Clone the manager for a child form (preserves style/theme) MetroStyleManager childManager = manager.Clone(childForm) as MetroStyleManager; // Dynamically switch accent color at runtime manager.Style = MetroColorStyle.Teal; // All Metro controls on the form repaint immediately // Available MetroColorStyle values: // Default, Black, White, Silver, Blue, Green, Lime, Teal, // Orange, Brown, Pink, Magenta, Purple, Red, Yellow, Custom ``` -------------------------------- ### Configure MetroForm Appearance and StyleManager Source: https://context7.com/dennismagno/metroframework-modern-ui/llms.txt Demonstrates how to configure a MetroForm's appearance, including text, style, theme, shadow type, and size. It also shows how to attach a MetroStyleManager to propagate theme changes to all child controls. ```csharp using MetroFramework.Forms; using MetroFramework.Components; public class MainForm : MetroForm { private MetroStyleManager styleManager; public MainForm() { // Configure form appearance this.Text = "My Application"; this.Style = MetroColorStyle.Blue; this.Theme = MetroThemeStyle.Light; this.ShadowType = MetroFormShadowType.DropShadow; this.Resizable = true; this.Movable = true; this.DisplayHeader = true; this.TextAlign = MetroFormTextAlign.Left; this.BorderStyle = MetroFormBorderStyle.None; this.Size = new System.Drawing.Size(800, 600); // Attach a StyleManager to propagate theme to all child controls styleManager = new MetroStyleManager(this.components); styleManager.Owner = this; styleManager.Style = MetroColorStyle.Blue; styleManager.Theme = MetroThemeStyle.Dark; // BackImage support: image auto-inverts for Dark theme this.BackImage = Image.FromFile("logo.png"); this.BackMaxSize = 64; this.BackLocation = BackLocation.TopRight; this.ApplyImageInvert = true; } private void ToggleDarkMode() { // Changing StyleManager cascades to all Metro controls on the form styleManager.Theme = MetroThemeStyle.Dark; styleManager.Update(); } } ``` -------------------------------- ### Create and Manage MetroTabControl Source: https://context7.com/dennismagno/metroframework-modern-ui/llms.txt Demonstrates how to create a MetroTabControl, add pages, and dynamically hide, show, disable, and enable tabs. Ensure MetroFramework.Controls is imported. ```csharp using MetroFramework.Controls; MetroTabControl tabs = new MetroTabControl(); tabs.Style = MetroColorStyle.Blue; tabs.Theme = MetroThemeStyle.Light; tabs.FontSize = MetroTabControlSize.Medium; tabs.FontWeight = MetroTabControlWeight.Light; tabs.UseStyleColors = true; // active tab text in accent color MetroTabPage page1 = new MetroTabPage { Text = "Overview" }; MetroTabPage page2 = new MetroTabPage { Text = "Settings" }; MetroTabPage page3 = new MetroTabPage { Text = "Advanced" }; tabs.TabPages.Add(page1); tabs.TabPages.Add(page2); tabs.TabPages.Add(page3); // Disable a tab (grayed, non-selectable) tabs.DisableTab(page3); bool enabled = tabs.IsTabEnable(page3); // true means it IS in the disabled list // Hide a tab entirely (remembers original index) tabs.HideTab(page2); bool hidden = tabs.IsTabHidden(page2); // true // Restore hidden tab at its original position tabs.ShowTab(page2); // Re-enable a disabled tab tabs.EnableTab(page3); ``` -------------------------------- ### Configure MetroProgressBar with Different Styles and Progress Simulation Source: https://context7.com/dennismagno/metroframework-modern-ui/llms.txt Configure MetroProgressBar for continuous or marquee modes, with or without a percentage label. Includes a timer to simulate progress updates and demonstrates accessing computed properties. ```csharp using MetroFramework.Controls; using System.Windows.Forms; MetroProgressBar bar = new MetroProgressBar(); bar.Style = MetroColorStyle.Green; bar.Theme = MetroThemeStyle.Light; bar.Minimum = 0; bar.Maximum = 100; bar.Value = 0; bar.ProgressBarStyle = ProgressBarStyle.Continuous; bar.HideProgressText = false; // show "42%" inside bar bar.TextAlign = ContentAlignment.MiddleRight; bar.FontSize = MetroProgressBarSize.Medium; bar.FontWeight = MetroProgressBarWeight.Light; // Simulate progress System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer { Interval = 100 }; timer.Tick += (s, e) => { if (bar.Value < bar.Maximum) bar.Value += 5; else { timer.Stop(); Console.WriteLine($"Done: {bar.ProgressPercentText}"); // "100%" } }; timer.Start(); // Marquee mode — indeterminate progress bar.ProgressBarStyle = ProgressBarStyle.Marquee; // Stops automatically when bar.Value == bar.Maximum ``` -------------------------------- ### Animate Control Movement with MoveAnimation Source: https://context7.com/dennismagno/metroframework-modern-ui/llms.txt Demonstrates using MoveAnimation from MetroFramework.Animation to slide controls into position with easing transitions. Import MetroFramework.Animation and MetroFramework.Controls. ```csharp using MetroFramework.Animation; using MetroFramework.Controls; using System.Drawing; MetroPanel panel = new MetroPanel { Location = new Point(300, 60) }; // Animate a panel sliding into position MoveAnimation moveAnim = new MoveAnimation(); moveAnim.AnimationCompleted += (s, e) => { Console.WriteLine("Slide-in complete."); }; // Start(control, targetLocation, transitionType, durationMs) moveAnim.Start(panel, new Point(20, 60), TransitionType.EaseInOutCubic, 15); // Check state bool running = moveAnim.IsRunning; bool completed = moveAnim.IsCompleted; // Cancel mid-animation moveAnim.Cancel(); // Available TransitionType values: // Linear, EaseInQuad, EaseOutQuad, EaseInOutQuad, // EaseInCubic, EaseOutCubic, EaseInOutCubic, // EaseInQuart, EaseInExpo, EaseOutExpo ``` -------------------------------- ### Configure MetroToggle Switch with Status Labels Source: https://context7.com/dennismagno/metroframework-modern-ui/llms.txt Set up a MetroToggle switch, enabling the display of localized 'On'/'Off' status labels. The preferred size depends on whether DisplayStatus is enabled. ```csharp using MetroFramework.Controls; MetroToggle toggle = new MetroToggle(); toggle.Style = MetroColorStyle.Blue; toggle.Theme = MetroThemeStyle.Light; toggle.DisplayStatus = true; // show "On" / "Off" label toggle.FontSize = MetroLinkSize.Small; toggle.FontWeight = MetroLinkWeight.Regular; toggle.Checked = false; toggle.CheckedChanged += (s, e) => { bool isOn = toggle.Checked; Console.WriteLine($"Toggle is now: {(isOn ? "ON" : "OFF")}"); // toggle.Text returns localized "On"/"Off" automatically }; // Preferred size when DisplayStatus = true → Width = 80 // Preferred size when DisplayStatus = false → Width = 50 System.Drawing.Size preferred = toggle.GetPreferredSize(System.Drawing.Size.Empty); ``` -------------------------------- ### Create and Configure MetroScrollBar Source: https://context7.com/dennismagno/metroframework-modern-ui/llms.txt Instantiate a MetroScrollBar, set its orientation, style, theme, and scroll range. Attach a scroll event handler to log the current value. This control can be embedded into MetroPanel. ```csharp using MetroFramework.Controls; using System.Windows.Forms; MetroScrollBar scrollBar = new MetroScrollBar(); scrollBar.Orientation = MetroScrollOrientation.Vertical; scrollBar.Style = MetroColorStyle.Blue; scrollBar.Theme = MetroThemeStyle.Light; scrollBar.Minimum = 0; scrollBar.Maximum = 200; scrollBar.Value = 0; scrollBar.LargeChange = 20; scrollBar.SmallChange = 5; scrollBar.ScrollbarSize = 12; // thickness in pixels scrollBar.Scroll += (s, e) => { Console.WriteLine($"ScrollBar value: {scrollBar.Value}"); }; // MetroPanel exposes integrated scrollbars: MetroPanel panel = new MetroPanel(); panel.VerticalScrollbar = true; panel.HorizontalScrollbar = false; panel.AutoScroll = true; ``` -------------------------------- ### Show and Manage MetroTaskWindow Notifications Source: https://context7.com/dennismagno/metroframework-modern-ui/llms.txt Illustrates how to use the MetroTaskWindow singleton to display floating, always-on-top notifications. Import MetroFramework.Forms and MetroFramework.Controls. ```csharp using MetroFramework.Forms; using MetroFramework.Controls; // Build any content control MetroLabel statusLabel = new MetroLabel { Text = "Processing in background…", FontSize = MetroLabelSize.Medium }; // Show for 10 seconds with auto-close MetroTaskWindow.ShowTaskWindow( parent: this, // IWin32Window; inherits theme/style title: "Background Task", userControl: statusLabel, secToClose: 10 // 0 = stays open until ForceClose() ); // Check visibility if (MetroTaskWindow.IsVisible()) { // Pause the countdown MetroTaskWindow.CancelAutoClose(); } // Programmatically close at any time MetroTaskWindow.ForceClose(); // Without auto-close (stays open until ForceClose) UserControl myPanel = new UserControl(); MetroTaskWindow.ShowTaskWindow("My Task", myPanel); ``` -------------------------------- ### Configure MetroButton with Custom Styles and States Source: https://context7.com/dennismagno/metroframework-modern-ui/llms.txt Customize MetroButton appearance with Style, Theme, FontSize, FontWeight, and Highlight mode. Use CustomPaintBackground for advanced visual overrides. ```csharp using MetroFramework.Controls; MetroButton btn = new MetroButton(); btn.Text = "Save"; btn.Style = MetroColorStyle.Green; btn.Theme = MetroThemeStyle.Light; btn.FontSize = MetroButtonSize.Medium; btn.FontWeight = MetroButtonWeight.Bold; btn.Highlight = true; // double accent border when idle btn.DisplayFocus = true; // dotted focus rectangle btn.UseStyleColors = true; // text rendered in accent color btn.Size = new System.Drawing.Size(120, 36); btn.Click += (s, e) => { // Custom background painting hook }; // Custom paint override example btn.CustomPaintBackground += (s, e) => { e.Graphics.Clear(System.Drawing.Color.DarkSlateGray); }; ``` -------------------------------- ### MetroTaskWindow Source: https://context7.com/dennismagno/metroframework-modern-ui/llms.txt A singleton, always-on-top floating window that can host custom controls and optionally auto-close after a specified duration. ```APIDOC ## MetroTaskWindow — Floating task notification window `MetroTaskWindow` is a singleton-pattern, always-on-top floating window that docks near the system taskbar. It can host any `Control` as its content and optionally auto-closes after a countdown shown as a progress stripe across the top edge. ```csharp using MetroFramework.Forms; using MetroFramework.Controls; // Build any content control MetroLabel statusLabel = new MetroLabel { Text = "Processing in background…", FontSize = MetroLabelSize.Medium }; // Show for 10 seconds with auto-close MetroTaskWindow.ShowTaskWindow( parent: this, // IWin32Window; inherits theme/style title: "Background Task", userControl: statusLabel, secToClose: 10 // 0 = stays open until ForceClose() ); // Check visibility if (MetroTaskWindow.IsVisible()) { // Pause the countdown MetroTaskWindow.CancelAutoClose(); } // Programmatically close at any time MetroTaskWindow.ForceClose(); // Without auto-close (stays open until ForceClose) UserControl myPanel = new UserControl(); MetroTaskWindow.ShowTaskWindow("My Task", myPanel); ``` ``` -------------------------------- ### Display MetroMessageBox Dialogs Source: https://context7.com/dennismagno/metroframework-modern-ui/llms.txt Shows how to use the static MetroMessageBox class to display various modal message dialogs. Import MetroFramework and System.Windows.Forms. ```csharp using MetroFramework; using System.Windows.Forms; // Simple notification DialogResult r1 = MetroMessageBox.Show(this, "File saved successfully."); // With title and custom height DialogResult r2 = MetroMessageBox.Show(this, "Are you sure?", "Confirm", 180); // Full overload with buttons and icon DialogResult r3 = MetroMessageBox.Show( owner: this, message: "The operation failed.\nPlease try again.", title: "Error", buttons: MessageBoxButtons.RetryCancel, icon: MessageBoxIcon.Error, defaultbutton: MessageBoxDefaultButton.Button1, height: 220 ); if (r3 == DialogResult.Retry) { // retry logic } // Confirmation dialog DialogResult r4 = MetroMessageBox.Show( this, "Delete selected items?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (r4 == DialogResult.Yes) { /* delete */ } ``` -------------------------------- ### Animation System Source: https://context7.com/dennismagno/metroframework-modern-ui/llms.txt Provides animation capabilities with classes like MoveAnimation, ExpandAnimation, and ColorBlendAnimation, supporting various easing transitions. ```APIDOC ## Animation System — MoveAnimation and easing transitions The `MetroFramework.Animation` namespace provides an `AnimationBase`-derived system with `MoveAnimation`, `ExpandAnimation`, and `ColorBlendAnimation`. Easing curves include Linear, EaseInQuad, EaseOutQuad, EaseInOutCubic, EaseInExpo, EaseOutExpo, and others. ```csharp using MetroFramework.Animation; using MetroFramework.Controls; using System.Drawing; MetroPanel panel = new MetroPanel { Location = new Point(300, 60) }; // Animate a panel sliding into position MoveAnimation moveAnim = new MoveAnimation(); moveAnim.AnimationCompleted += (s, e) => { Console.WriteLine("Slide-in complete."); }; // Start(control, targetLocation, transitionType, durationMs) moveAnim.Start(panel, new Point(20, 60), TransitionType.EaseInOutCubic, 15); // Check state bool running = moveAnim.IsRunning; bool completed = moveAnim.IsCompleted; // Cancel mid-animation moveAnim.Cancel(); // Available TransitionType values: // Linear, EaseInQuad, EaseOutQuad, EaseInOutQuad, // EaseInCubic, EaseOutCubic, EaseInOutCubic, // EaseInQuart, EaseInExpo, EaseOutExpo ``` ``` -------------------------------- ### Apply Metro Theme to Standard Controls with MetroStyleExtender Source: https://context7.com/dennismagno/metroframework-modern-ui/llms.txt Use MetroStyleExtender to apply Metro BackColor and ForeColor to standard WinForms controls that do not natively implement IMetroControl. Ensure the extender inherits its style from a StyleManager. ```csharp using MetroFramework.Components; using System.Windows.Forms; // Create the extender (usually added via designer) MetroStyleExtender extender = new MetroStyleExtender(); extender.StyleManager = styleManager; // inherit style from manager // Opt a standard Label into Metro theming Label stdLabel = new Label { Text = "Standard Label" }; extender.SetApplyMetroTheme(stdLabel, true); // Check if a control is being themed bool isThemed = extender.GetApplyMetroTheme(stdLabel); // true // Remove a control from Metro theming extender.SetApplyMetroTheme(stdLabel, false); // The extender only targets controls that are NOT already IMetroControl/IMetroForm // IExtenderProvider.CanExtend returns false for MetroButton, MetroLabel, etc. ``` -------------------------------- ### MetroMessageBox Source: https://context7.com/dennismagno/metroframework-modern-ui/llms.txt A static utility class for displaying modal message dialogs with Metro styling, offering various overloads similar to the standard MessageBox API. ```APIDOC ## MetroMessageBox — Metro-styled modal message dialog `MetroMessageBox` is a static utility class providing multiple `Show()` overloads matching the standard `MessageBox` API. The dialog is positioned centered vertically relative to its owner form and plays the appropriate system sound for the given `MessageBoxIcon`. ```csharp using MetroFramework; using System.Windows.Forms; // Simple notification DialogResult r1 = MetroMessageBox.Show(this, "File saved successfully."); // With title and custom height DialogResult r2 = MetroMessageBox.Show(this, "Are you sure?", "Confirm", 180); // Full overload with buttons and icon DialogResult r3 = MetroMessageBox.Show( owner: this, message: "The operation failed.\nPlease try again.", title: "Error", buttons: MessageBoxButtons.RetryCancel, icon: MessageBoxIcon.Error, defaultbutton: MessageBoxDefaultButton.Button1, height: 220 ); if (r3 == DialogResult.Retry) { // retry logic } // Confirmation dialog DialogResult r4 = MetroMessageBox.Show( this, "Delete selected items?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (r4 == DialogResult.Yes) { /* delete */ } ``` ``` -------------------------------- ### MetroTabControl Source: https://context7.com/dennismagno/metroframework-modern-ui/llms.txt Manages a collection of MetroTabPage objects, providing methods to dynamically show, hide, enable, and disable tabs. ```APIDOC ## MetroTabControl — Metro-styled tab container `MetroTabControl` renders flat, text-only tabs with a colored bottom underline on the selected tab. It adds `HideTab` / `ShowTab` for dynamic tab visibility, `DisableTab` / `EnableTab` for per-tab disabling, and supports RTL mirroring via `IsMirrored`. ```csharp using MetroFramework.Controls; MetroTabControl tabs = new MetroTabControl(); tabs.Style = MetroColorStyle.Blue; tabs.Theme = MetroThemeStyle.Light; tabs.FontSize = MetroTabControlSize.Medium; tabs.FontWeight = MetroTabControlWeight.Light; tabs.UseStyleColors = true; // active tab text in accent color MetroTabPage page1 = new MetroTabPage { Text = "Overview" }; MetroTabPage page2 = new MetroTabPage { Text = "Settings" }; MetroTabPage page3 = new MetroTabPage { Text = "Advanced" }; tabs.TabPages.Add(page1); tabs.TabPages.Add(page2); tabs.TabPages.Add(page3); // Disable a tab (grayed, non-selectable) tabs.DisableTab(page3); bool enabled = tabs.IsTabEnable(page3); // true means it IS in the disabled list // Hide a tab entirely (remembers original index) tabs.HideTab(page2); bool hidden = tabs.IsTabHidden(page2); // true // Restore hidden tab at its original position tabs.ShowTab(page2); // Re-enable a disabled tab tabs.EnableTab(page3); ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.