Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
 // *** 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();
     }
 }
Exemplo n.º 5
0
 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);
 }
Exemplo n.º 6
0
 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);
 }
Exemplo n.º 7
0
        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;
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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));
            }
        }
Exemplo n.º 10
0
        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));
            }
        }
Exemplo n.º 11
0
        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);
            }
        }
Exemplo n.º 12
0
        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;
        }
Exemplo n.º 13
0
        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);
                };
            }
        }
Exemplo n.º 14
0
        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);
                }
            }
        }
Exemplo n.º 15
0
 public OutlineButtonInvertedWidgetStyle(ColorContexts colorContext)
     : base(colorContext)
 {
 }
Exemplo n.º 16
0
 public ButtonWidgetStyle(ColorContexts colorContext)
 {
     ColorContext = colorContext;
 }
Exemplo n.º 17
0
 public ButtonHoverWidgetStyle(ColorContexts colorContext) : base(colorContext)
 {
 }
Exemplo n.º 18
0
        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);
            }
        }
Exemplo n.º 19
0
        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;
             ***/
        }
Exemplo n.º 20
0
 public ButtonDisabledWidgetStyle(ColorContexts colorContext) : base(colorContext)
 {
 }
Exemplo n.º 21
0
 public static Color GetContextDisabledBorderColor(ColorContexts colorContext)
 {
     return(CurrentTheme.GetContextBorderColor(colorContext).Lerp(Color.LightGray, 0.75));
 }
Exemplo n.º 22
0
 public static Color GetContextDisabledForeColor(ColorContexts colorContext)
 {
     return(CurrentTheme.GetContextForeColor(colorContext).Lerp(Color.Gray, 0.5));
 }
Exemplo n.º 23
0
        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);
        }
Exemplo n.º 24
0
        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;
        }
Exemplo n.º 25
0
 public static Color GetContextHoverColor(ColorContexts colorContext)
 {
     return(CurrentTheme.GetContextColor(colorContext).Lerp(Color.White, 0.25));
 }
Exemplo n.º 26
0
 public ButtonPressedWidgetStyle(ColorContexts colorContext) : base(colorContext)
 {
 }
Exemplo n.º 27
0
 public Button(string name, string text, ColorContexts colorContext) : this(name, text, (char)0, colorContext)
 {
 }
Exemplo n.º 28
0
 public NotificationWidgetStyle(ColorContexts colorContext)
 {
     ColorContext = colorContext;
 }
Exemplo n.º 29
0
 public static Color GetContextForeColor(ColorContexts colorContext)
 {
     return(CurrentTheme.GetContextForeColor(colorContext));
 }