public virtual Color GetContextColor(ColorContexts colorContext) { switch (colorContext) { case ColorContexts.Default: return(Colors.Base01); case ColorContexts.Active: return(Colors.Orange); case ColorContexts.Information: return(Colors.Blue); case ColorContexts.Success: return(Colors.Green); case ColorContexts.Warning: return(Colors.Yellow); case ColorContexts.Danger: return(Colors.Red); case ColorContexts.Question: return(Colors.Cyan); case ColorContexts.Outline: return(Color.Empty); default: return(Colors.Base01); } }
public DefaultButton(string name, string text, ColorContexts colorContext, char icon = (char)0, bool outLine = false) : base(name, text, icon, new ButtonWidgetStyle(colorContext)) { //IsMenu = true; if (outLine) { Styles.SetStyle(new OutlineButtonWidgetStyle(colorContext), WidgetStates.Default); Styles.SetStyle(new OutlineButtonInvertedWidgetStyle(colorContext), WidgetStates.Hover); Styles.SetStyle(new OutlineButtonWidgetStyle(colorContext), WidgetStates.Active); Styles.SetStyle(new OutlineButtonWidgetStyle(colorContext), WidgetStates.Selected); Styles.SetStyle(new OutlineButtonPressedWidgetStyle(colorContext), WidgetStates.Pressed); Styles.SetStyle(new OutlineButtonDisabledWidgetStyle(colorContext), WidgetStates.Disabled); } else { Styles.SetStyle(new SilverButtonActiveHoverWidgetStyle(), WidgetStates.Active); Styles.SetStyle(new SilverButtonActiveWidgetStyle(), WidgetStates.Selected); Styles.SetStyle(new SilverButtonPressedWidgetStyle(), WidgetStates.Pressed); Styles.SetStyle(new ButtonDisabledWidgetStyle(colorContext), WidgetStates.Disabled); //Styles.SetStyle (new ButtonHoverWidgetStyle (colorContext), WidgetStates.Hover); Styles.SetStyle(new ButtonHoverWidgetStyle(colorContext), WidgetStates.Custom1); Styles.SetStyle(new SilverButtonActiveHoverWidgetStyle(), WidgetStates.Custom2); } m_ColorContext = colorContext; HAlign = Alignment.Center; VAlign = Alignment.Center; }
protected void InitText(string message, ColorContexts colorContext) { Message = message; TW = new MultiLineTextWidget("message", message, new WidgetStyle(Color.Empty, Theme.GetContextForeColor(colorContext), Color.Empty)); TW.Padding = new Padding(16); TW.VAlign = Alignment.Center; TW.HAlign = Alignment.Center; this.OnLayout(CTX, CTX.Bounds); // Layout the text RectangleF bounds = ContentPanel.ClientRectangle; SizeF sz = TW.PreferredSize(CTX, bounds.Size); if (sz.Height > bounds.Height) { ScrollableContainer container = ContentPanel.AddChild(new ScrollableContainer("scroller")); container.ScrollBars = ScrollBars.Vertical; container.AutoScroll = true; TW.Dock = Docking.Top; container.AddChild(TW); } else { ContentPanel.AddChild(TW); } }
// *** Notifications public void ShowNotification(string message, ColorContexts context, char icon = (char)0, bool canClose = true, double autoCloseSeconds = 10) { try { MenuPanel.Notifications.AddNotification(message, context, icon, canClose, autoCloseSeconds); } catch (Exception ex) { ex.LogError(); } }
protected virtual void InitIconImage(char icon, ColorContexts colorContext) { IconText = new TextWidget("icon", Docking.Top, new EmptyWidgetStyle(), null, null); IconText.IconFont = CTX.FontManager.FontByTag(CommonFontTags.LargeIcons); IconText.Icon = icon; IconText.ForeColor = Color.White; ContentPanel.AddChild(IconText); }
protected virtual void InitIconImage(char icon, ColorContexts colorContext) { ImagePanelContainer = Controls.AddChild(new Panel("imagecontainer", Docking.Left, new BrightPanelWidgetStyle())); IconText = ImagePanelContainer.AddChild(new TextWidget("icon", Docking.Top, new EmptyWidgetStyle(), null, null)); IconText.SetIconFontByTag(CommonFontTags.LargeIcons); IconText.Icon = icon; IconText.Style.ForeColorBrush.Color = Theme.GetContextColor(colorContext); IconText.Padding = new Padding(6, 18, 6, 6); }
public Button(string name, string text, char icon = (char)0, ColorContexts colorContext = ColorContexts.Default) : this(name, text, icon, new ButtonWidgetStyle(colorContext)) { Styles.SetStyle(new ButtonHoverWidgetStyle(colorContext), WidgetStates.Hover); Styles.SetStyle(new ButtonPressedWidgetStyle(colorContext), WidgetStates.Pressed); Styles.SetStyle(new ButtonDisabledWidgetStyle(colorContext), WidgetStates.Disabled); m_ColorContext = colorContext; }
public CircleSlider(string name, ColorContexts context) : base(name, Docking.Fill, new CircleSliderWidgetStyle()) { ColorContext = context; Styles.SetStyle(new CircleSliderDisabledWidgetStyle(), WidgetStates.Disabled); Font = SummerGUIWindow.CurrentContext.FontManager.DefaultFont; Radius = 48; //Padding = new Padding (3); }
public virtual Color GetContextGradientColor(ColorContexts colorContext) { switch (colorContext) { case ColorContexts.Default: return(Colors.Base02); case ColorContexts.Outline: return(Color.Empty); default: return(GetContextColor(colorContext).Lerp(Color.Black, 0.15)); } }
public virtual Color GetContextBorderColor(ColorContexts colorContext) { switch (colorContext) { case ColorContexts.Default: return(Colors.Base03); case ColorContexts.Outline: return(Color.White); default: return(GetContextColor(colorContext).Lerp(Color.Black, 0.25)); } }
protected virtual void InitButtons(MessageBoxButtons buttons, ColorContexts colorContext) { DefaultButton btn = null; if (buttons.HasFlag(MessageBoxButtons.Continue)) { btn = new DefaultButton("continuebutton", "&Continue", colorContext, (char)0, true); btn.Click += (sender, eContinue) => OnContinue(); ButtonContainer.AddChild(btn); btn.Focus(); } if (buttons.HasFlag(MessageBoxButtons.Repeat)) { btn = new DefaultButton("repeatbutton", "&Repeat", colorContext, (char)0, true); btn.Click += (sender, eRepeat) => OnRepeat(); ButtonContainer.AddChild(btn); } if (buttons.HasFlag(MessageBoxButtons.Yes)) { btn = new DefaultButton("yesbutton", "&Yes", colorContext, (char)0, true); btn.Click += (sender, eYes) => OnYes(); ButtonContainer.AddChild(btn); btn.Focus(); } if (buttons.HasFlag(MessageBoxButtons.No)) { btn = new DefaultButton("nobutton", "&No", colorContext, (char)0, true); btn.Click += (sender, eNo) => OnNo(); ButtonContainer.AddChild(btn); } if (buttons.HasFlag(MessageBoxButtons.OK)) { btn = new DefaultButton("okbutton", "&OK", colorContext, (char)0, true); btn.Click += (sender, eOK) => OnOK(); ButtonContainer.AddChild(btn); btn.Focus(); } if (buttons.HasFlag(MessageBoxButtons.Cancel)) { btn = new DefaultButton("cancelbutton", "&Cancel", colorContext, (char)0, true); btn.Click += (sender, eCancel) => OnCancel(); ButtonContainer.AddChild(btn); } }
public MessageBoxOverlay(IGUIContext ctx, ColorContexts colorContext) : base("messagebox") { CTX = ctx; ColorContext = colorContext; CanFocus = true; ContentPanel = AddChild(new Panel("contents", Docking.Fill, new WidgetStyle(Theme.GetContextColor(colorContext), Theme.GetContextForeColor(colorContext), Color.Empty))); // panel ButtonContainer = ContentPanel.AddChild(new ButtonContainer("buttoncontainer", Docking.Bottom, new EmptyWidgetStyle())); ButtonContainer.FlexDirection = FlexDirections.RowCenter; }
public void AddNotification(string message, ColorContexts context, char icon = (char)0, bool canClose = true, double autoCloseSeconds = 0) { if (MaxNotifications <= 0) { return; } int number = 1; unchecked { number = Interlocked.Increment(ref NotificationCount); } NotificationWidget notify = null; try { notify = AddChild(new NotificationWidget("notification" + number.ToString(), message, context, icon, canClose, autoCloseSeconds)); while (Children.Count > 0 && Children.Count > MaxNotifications) { Widget tmp = Children.OfType <NotificationWidget>().OrderBy(c => c.Created).FirstOrDefault(); if (tmp != null) { RemoveNotification(tmp, false); } else { // just for the case .. this.LogWarning("Unable to remove a Notification."); break; } } } catch (Exception ex) { ex.LogError(); } finally { Update(true); } if (notify != null) { notify.Close += delegate { RemoveNotification(notify, true); }; } }
public virtual Color GetContextForeColor(ColorContexts colorContext) { switch (colorContext) { case ColorContexts.Default: return(Colors.Base3); case ColorContexts.Outline: return(Color.White); default: if (GetContextColor(colorContext).IsDark()) { return(Colors.Base3); } else { return(Colors.Base03); } } }
public OutlineButtonInvertedWidgetStyle(ColorContexts colorContext) : base(colorContext) { }
public ButtonWidgetStyle(ColorContexts colorContext) { ColorContext = colorContext; }
public ButtonHoverWidgetStyle(ColorContexts colorContext) : base(colorContext) { }
public NotificationWidget(string name, string text, ColorContexts notificationStyle, char icon = (char)0, bool canClose = true, double autoCloseSeconds = 0) : base(name, Docking.Top, new NotificationWidgetStyle(notificationStyle)) { Created = DateTime.Now; Text = AddChild(new MultiLineTextWidget("notificationText", text, Style)); Text.Padding = new Padding(8); Margin = new Padding(0, 1, 0, 0); NotificationStyle = notificationStyle; if (icon > 0) { Icon = icon; } else { switch (NotificationStyle) { case ColorContexts.Information: Icon = (char)FontAwesomeIcons.fa_info_circle; break; case ColorContexts.Danger: case ColorContexts.Warning: Icon = (char)FontAwesomeIcons.fa_warning; break; case ColorContexts.Success: Icon = (char)FontAwesomeIcons.fa_check; break; } } if (Icon > 0) { TextWidget TWI = AddChild(new TextWidget("notificationIcon", Docking.Left, Style, null, null)); TWI.Icon = Icon; TWI.ZIndex = 1; } CloseButtonVisible = canClose; if (CloseButtonVisible) { Button btnClose = AddChild(new Button("close", null, (char)FontAwesomeIcons.fa_close, notificationStyle)); btnClose.Dock = Docking.Right; btnClose.ZIndex = 1; btnClose.MaxSize = new SizeF(btnClose.MaxSize.Width, Int32.MaxValue); btnClose.Styles.OfType <ButtonWidgetStyle> ().ForEach(s => { s.ButtonStyle = ButtonStyles.Flat; s.Border = 0; }); btnClose.Click += delegate { OnClose(); }; } AutoCloseSeconds = autoCloseSeconds; if (AutoCloseSeconds > 0) { CloseTimer = new DelayedAction((int)(AutoCloseSeconds * 1000), OnClose); } }
public static DialogResults Show(string message, MessageBoxTypes msgType = MessageBoxTypes.Info, MessageBoxButtons buttons = MessageBoxButtons.OkCancel, SummerGUIWindow parent = null) { // *** Icon FontAwesomeIcons icon = FontAwesomeIcons.fa_anchor; ColorContexts colorContext = ColorContexts.Default; // init icon switch (msgType) { case MessageBoxTypes.Info: icon = FontAwesomeIcons.fa_info_circle; colorContext = ColorContexts.Information; break; case MessageBoxTypes.Success: icon = FontAwesomeIcons.fa_exclamation_circle; colorContext = ColorContexts.Success; break; case MessageBoxTypes.Warning: icon = FontAwesomeIcons.fa_warning; colorContext = ColorContexts.Warning; break; case MessageBoxTypes.Error: icon = FontAwesomeIcons.fa_times_circle; colorContext = ColorContexts.Danger; break; case MessageBoxTypes.Question: icon = FontAwesomeIcons.fa_question_circle; colorContext = ColorContexts.Question; break; case MessageBoxTypes.Help: icon = FontAwesomeIcons.fa_life_ring; colorContext = ColorContexts.Success; break; } MessageBoxOverlay box = new MessageBoxOverlay(parent, colorContext); box.InitIconImage((char)icon, colorContext); // *** Buttons box.InitButtons(buttons, colorContext); box.InitText(message.TrimRightLinebreaks() + "\n", colorContext); if (msgType == MessageBoxTypes.Error) { //box.InitCopyButton (); } box.Style.BackColorBrush.Color = Color.FromArgb(30, Color.DarkSlateGray); /*** ***/ box.Show(parent); box.Focus(); return(DialogResults.OK); /*** * if (box != null) * box.Dispose (); * return box.Result; ***/ }
public ButtonDisabledWidgetStyle(ColorContexts colorContext) : base(colorContext) { }
public static Color GetContextDisabledBorderColor(ColorContexts colorContext) { return(CurrentTheme.GetContextBorderColor(colorContext).Lerp(Color.LightGray, 0.75)); }
public static Color GetContextDisabledForeColor(ColorContexts colorContext) { return(CurrentTheme.GetContextForeColor(colorContext).Lerp(Color.Gray, 0.5)); }
public static DialogResults Show(string caption, string message, MessageBoxTypes msgType = MessageBoxTypes.Info, MessageBoxButtons buttons = MessageBoxButtons.OkCancel, SummerGUIWindow parent = null) { float scaling = 1; if (parent != null) { scaling = parent.ScaleFactor; } MessageBoxWindow box = new MessageBoxWindow("MsgBox", caption, (DefaultWidth * scaling).Ceil(), (DefaultHeight * scaling).Ceil(), parent); // *** Icon FontAwesomeIcons icon = FontAwesomeIcons.fa_anchor; ColorContexts colorContext = ColorContexts.Default; // init icon switch (msgType) { case MessageBoxTypes.Info: icon = FontAwesomeIcons.fa_info_circle; colorContext = ColorContexts.Information; break; case MessageBoxTypes.Success: icon = FontAwesomeIcons.fa_exclamation_circle; colorContext = ColorContexts.Success; break; case MessageBoxTypes.Warning: icon = FontAwesomeIcons.fa_warning; colorContext = ColorContexts.Warning; break; case MessageBoxTypes.Error: icon = FontAwesomeIcons.fa_times_circle; colorContext = ColorContexts.Danger; break; case MessageBoxTypes.Question: icon = FontAwesomeIcons.fa_question_circle; colorContext = ColorContexts.Question; break; case MessageBoxTypes.Help: icon = FontAwesomeIcons.fa_life_ring; colorContext = ColorContexts.Success; break; } box.InitIconImage((char)icon, colorContext); // *** Buttons box.InitButtons(buttons); box.InitText(message); if (msgType == MessageBoxTypes.Error) { box.InitCopyButton(); } box.ShowInTaskBar = false; box.Show(parent); if (box != null) { box.Dispose(); } return(box.Result); }
public ButtonTextBox(string name, char icon = (char)0, string buttonText = null, ColorContexts colorContext = ColorContexts.Default) : base(name) { Button = new Button("button", buttonText, colorContext); Button.IsMenu = false; Button.Icon = icon; Button.Padding = new Padding(8, 0, 8, 0); Button.MaxSize = TB.MaxSize; Button.MinSize = SizeF.Empty; AddChild(Button); TB.TextChanged += TB_TextChanged; AutoEnableButton = true; Button.Enabled = false; Button.CanFocus = true; CanFocus = true; }
public static Color GetContextHoverColor(ColorContexts colorContext) { return(CurrentTheme.GetContextColor(colorContext).Lerp(Color.White, 0.25)); }
public ButtonPressedWidgetStyle(ColorContexts colorContext) : base(colorContext) { }
public Button(string name, string text, ColorContexts colorContext) : this(name, text, (char)0, colorContext) { }
public NotificationWidgetStyle(ColorContexts colorContext) { ColorContext = colorContext; }
public static Color GetContextForeColor(ColorContexts colorContext) { return(CurrentTheme.GetContextForeColor(colorContext)); }