Exemplo n.º 1
0
        public YAMLNode ExportYAML(IExportContainer container)
        {
            YAMLMappingNode node = new YAMLMappingNode();

            node.Add(NameName, Name);
            node.Add(NormalName, Normal.ExportYAML(container));
            node.Add(HoverName, Hover.ExportYAML(container));
            node.Add(ActiveName, Active.ExportYAML(container));
            node.Add(FocusedName, Focused.ExportYAML(container));
            node.Add(OnNormalName, OnNormal.ExportYAML(container));
            node.Add(OnHoverName, OnHover.ExportYAML(container));
            node.Add(OnActiveName, OnActive.ExportYAML(container));
            node.Add(OnFocusedName, OnFocused.ExportYAML(container));
            node.Add(BorderName, Border.ExportYAML(container));
            node.Add(MarginName, Margin.ExportYAML(container));
            node.Add(PaddingName, Padding.ExportYAML(container));
            node.Add(OverflowName, Overflow.ExportYAML(container));
            node.Add(FontName, Font.ExportYAML(container));
            node.Add(FontSizeName, FontSize);
            node.Add(FontStyleName, (int)FontStyle);
            node.Add(AlignmentName, (int)Alignment);
            node.Add(WordWrapName, WordWrap);
            node.Add(RichTextName, RichText);
            node.Add(TextClippingName, (int)TextClipping);
            node.Add(ImagePositionName, (int)ImagePosition);
            node.Add(ContentOffsetName, ContentOffset.ExportYAML(container));
            node.Add(FixedWidthName, FixedWidth);
            node.Add(FixedHeightName, FixedHeight);
            node.Add(StretchWidthName, StretchWidth);
            node.Add(StretchHeightName, StretchHeight);
            return(node);
        }
 /// <inheritdoc/>
 public override int GetHashCode()
 => Role.GetHashCode() ^
 Name.GetHashCode() ^
 Value.GetHashCode() ^
 Description.GetHashCode() ^
 KeyShortcuts.GetHashCode() ^
 RoleDescription.GetHashCode() ^
 ValueText.GetHashCode() ^
 AutoComplete.GetHashCode() ^
 HasPopup.GetHashCode() ^
 Orientation.GetHashCode() ^
 Disabled.GetHashCode() ^
 Expanded.GetHashCode() ^
 Focused.GetHashCode() ^
 Modal.GetHashCode() ^
 Multiline.GetHashCode() ^
 Multiselectable.GetHashCode() ^
 Readonly.GetHashCode() ^
 Required.GetHashCode() ^
 Selected.GetHashCode() ^
 Pressed.GetHashCode() ^
 Checked.GetHashCode() ^
 Level.GetHashCode() ^
 ValueMin.GetHashCode() ^
 ValueMax.GetHashCode() ^
 Children.GetHashCode();
Exemplo n.º 3
0
        public YAMLNode ExportYAML(IExportContainer container)
        {
            YAMLMappingNode node = new YAMLMappingNode();

            node.Add("m_Name", Name);
            node.Add("m_Normal", Normal.ExportYAML(container));
            node.Add("m_Hover", Hover.ExportYAML(container));
            node.Add("m_Active", Active.ExportYAML(container));
            node.Add("m_Focused", Focused.ExportYAML(container));
            node.Add("m_OnNormal", OnNormal.ExportYAML(container));
            node.Add("m_OnHover", OnHover.ExportYAML(container));
            node.Add("m_OnActive", OnActive.ExportYAML(container));
            node.Add("m_OnFocused", OnFocused.ExportYAML(container));
            node.Add("m_Border", Border.ExportYAML(container));
            node.Add("m_Margin", Margin.ExportYAML(container));
            node.Add("m_Padding", Padding.ExportYAML(container));
            node.Add("m_Overflow", Overflow.ExportYAML(container));
            node.Add("m_Font", Font.ExportYAML(container));
            node.Add("m_FontSize", FontSize);
            node.Add("m_FontStyle", (int)FontStyle);
            node.Add("m_Alignment", (int)Alignment);
            node.Add("m_WordWrap", WordWrap);
            node.Add("m_RichText", RichText);
            node.Add("m_TextClipping", (int)TextClipping);
            node.Add("m_ImagePosition", (int)ImagePosition);
            node.Add("m_ContentOffset", ContentOffset.ExportYAML(container));
            node.Add("m_FixedWidth", FixedWidth);
            node.Add("m_FixedHeight", FixedHeight);
            node.Add("m_StretchWidth", StretchWidth);
            node.Add("m_StretchHeight", StretchHeight);
            return(node);
        }
Exemplo n.º 4
0
 public void FocusNext()
 {
     Focused.RemoveFocus();
     Index = Index == Items.Count - 1 ? 0 : ++Index;
     Focused.Focus();
     Render.Update();
 }
Exemplo n.º 5
0
 protected virtual void OnFocused()
 {
     if (Focused != null)
     {
         Focused.Invoke(this, System.EventArgs.Empty);
     }
 }
Exemplo n.º 6
0
        public override void Update(GameTime gameTime)
        {
            if (Enabled)
            {
                MiStandardControllerState newState = Controller.GetState();
                foreach (MiControl control in Controller.controls)
                {
                    if (oldState.IsReleased(control) && newState.IsPressed(control))
                    {
                        Game.ScriptEngine.ExecuteScript(Focused.RespondToInput(control));
                    }

                    if (oldState.IsPressed(control) && newState.IsPressed(control))
                    {
                        holdTimer[control]++;
                        if (holdTimer[control] > HOLD_REPEAT_INTERVAL)
                        {
                            holdTimer[control] = 0;
                            Game.ScriptEngine.ExecuteScript(Focused.RespondToInput(control));
                        }
                    }

                    if (newState.IsReleased(control))
                    {
                        holdTimer[control] = 0;
                    }
                }

                oldState = newState;
            }
        }
Exemplo n.º 7
0
        public void Read(AssetStream stream)
        {
            StyleName = stream.ReadStringAligned();
            Normal.Read(stream);
            Hover.Read(stream);
            Active.Read(stream);
            Focused.Read(stream);
            OnNormal.Read(stream);
            OnHover.Read(stream);
            OnActive.Read(stream);
            OnFocused.Read(stream);
            Border.Read(stream);
            Margin.Read(stream);
            Padding.Read(stream);
            Overflow.Read(stream);
            Font.Read(stream);
            FontSize  = stream.ReadInt32();
            FontStyle = stream.ReadInt32();
            Alignment = stream.ReadInt32();
            WordWrap  = stream.ReadBoolean();
            RichText  = stream.ReadBoolean();
            stream.AlignStream(AlignType.Align4);

            TextClipping  = stream.ReadInt32();
            ImagePosition = stream.ReadInt32();
            ContentOffset.Read(stream);
            FixedWidth    = stream.ReadSingle();
            FixedHeight   = stream.ReadSingle();
            StretchWidth  = stream.ReadBoolean();
            StretchHeight = stream.ReadBoolean();
            stream.AlignStream(AlignType.Align4);
        }
Exemplo n.º 8
0
 public void FocusPrevious()
 {
     Focused.RemoveFocus();
     Index = Index == 0 ? Items.Count - 1 : --Index;
     Focused.Focus();
     Render.Update();
 }
Exemplo n.º 9
0
        public void ShowScreen(ScreenType type)
        {
            if (FocusedType == type)
            {
                return;
            }

            if (type == ScreenType.EMPTY)
            {
                Focused.Hide();

                Focused     = null;
                FocusedType = ScreenType.EMPTY;

                return;
            }

            Focused?.Hide();

            if (!cachedScreens.ContainsKey(type))
            {
                createScreen(type);
            }

            FocusedType = type;
            Focused     = cachedScreens[type];
            Focused?.Show();
        }
 /// <inheritdoc/>
 public override int GetHashCode()
 => (Role ?? string.Empty).GetHashCode() ^
 (Name ?? string.Empty).GetHashCode() ^
 (Value ?? string.Empty).GetHashCode() ^
 (Description ?? string.Empty).GetHashCode() ^
 (Keyshortcuts ?? string.Empty).GetHashCode() ^
 (Roledescription ?? string.Empty).GetHashCode() ^
 (Valuetext ?? string.Empty).GetHashCode() ^
 Disabled.GetHashCode() ^
 Expanded.GetHashCode() ^
 Focused.GetHashCode() ^
 Modal.GetHashCode() ^
 Multiline.GetHashCode() ^
 Multiselectable.GetHashCode() ^
 Readonly.GetHashCode() ^
 Required.GetHashCode() ^
 Selected.GetHashCode() ^
 Checked.GetHashCode() ^
 Pressed.GetHashCode() ^
 Level.GetHashCode() ^
 Valuemin.GetHashCode() ^
 Valuemax.GetHashCode() ^
 (Autocomplete ?? string.Empty).GetHashCode() ^
 (Haspopup ?? string.Empty).GetHashCode() ^
 (Invalid ?? string.Empty).GetHashCode() ^
 (Orientation ?? string.Empty).GetHashCode() ^
 Children.GetHashCode();
Exemplo n.º 11
0
 public void ConfigureResourceDictionary(ResourceDictionary dictionary, string prefix)
 {
     TabFont.ConfigureResourceDictionary(dictionary, prefix + "Font");
     Default.ConfigureResourceDictionary(dictionary, prefix);
     Selected.ConfigureResourceDictionary(dictionary, prefix + "Selected");
     Focused.ConfigureResourceDictionary(dictionary, prefix + "Focused");
     UnreadCount.ConfigureResourceDictionary(dictionary, prefix + "UnreadCount");
 }
Exemplo n.º 12
0
        // TODO move keyboard handling into screen manager so basic functions aren't duplicated

        public void HandleInput()
        {
            //if (key == Keys.Back)
            //    currentGame.screenManager.FocusScreen(GameScreen.TITLE_MAINMENU);
            if (currentGame.IsActive)
            {
                Focused.HandleInput();
            }
        }
Exemplo n.º 13
0
 /// <summary>
 /// Performs a deep copy of this theme.
 /// </summary>
 /// <returns>A new instance of the theme.</returns>
 public ThemeStates Clone() => new ThemeStates()
 {
     Normal    = Normal.Clone(),
     Disabled  = Disabled.Clone(),
     MouseOver = MouseOver.Clone(),
     MouseDown = MouseDown.Clone(),
     Selected  = Selected.Clone(),
     Focused   = Focused.Clone(),
 };
Exemplo n.º 14
0
 public virtual object Clone() => new ListBoxItemTheme()
 {
     Normal    = Normal.Clone(),
     Disabled  = Disabled.Clone(),
     MouseOver = MouseOver.Clone(),
     MouseDown = MouseDown.Clone(),
     Selected  = Selected.Clone(),
     Focused   = Focused.Clone(),
 };
Exemplo n.º 15
0
        /// <summary>
        /// The callback of the Realized event.
        /// </summary>
        /// <since_tizen> preview </since_tizen>
        protected override void OnRealized()
        {
            base.OnRealized();
            _focused     = new SmartEvent(this, "focused");
            _focused.On += (s, e) => Focused?.Invoke(this, EventArgs.Empty);

            _unfocused     = new SmartEvent(this, "unfocused");
            _unfocused.On += (s, e) => Unfocused?.Invoke(this, EventArgs.Empty);
        }
Exemplo n.º 16
0
 public override object Clone() => new ListBoxItemColorTheme()
 {
     Normal    = Normal.Clone(),
     Disabled  = Disabled.Clone(),
     MouseOver = MouseOver.Clone(),
     MouseDown = MouseDown.Clone(),
     Selected  = Selected.Clone(),
     Focused   = Focused.Clone(),
 };
Exemplo n.º 17
0
 public void Focus()
 {
     if (IsFocused)
     {
         return;
     }
     IsFocused = true;
     Focused?.Invoke(this);
 }
Exemplo n.º 18
0
 /// <inheritdoc />
 public override ThemeBase Clone() => new DrawingSurfaceTheme()
 {
     Normal             = Normal.Clone(),
     Disabled           = Disabled.Clone(),
     MouseOver          = MouseOver.Clone(),
     MouseDown          = MouseDown.Clone(),
     Selected           = Selected.Clone(),
     Focused            = Focused.Clone(),
     UseNormalStateOnly = UseNormalStateOnly
 };
Exemplo n.º 19
0
        public void Render()
        {
            Focused?.Render();

            Chat.Render();
            Message.Render();
            Screen.Render();

            Text.Render();
        }
Exemplo n.º 20
0
 /// <inheritdoc />
 public override ThemeBase Clone() => new ProgressBarTheme()
 {
     Normal     = Normal.Clone(),
     Disabled   = Disabled.Clone(),
     MouseOver  = MouseOver.Clone(),
     MouseDown  = MouseDown.Clone(),
     Selected   = Selected.Clone(),
     Focused    = Focused.Clone(),
     Foreground = Foreground?.Clone(),
     Background = Background?.Clone()
 };
Exemplo n.º 21
0
 internal void FireFocused(bool focused)
 {
     if (focused)
     {
         Focused.Fire();
     }
     else
     {
         Unfocused.Fire();
     }
 }
Exemplo n.º 22
0
 public void OnKey(ConsoleKeyInfo key)
 {
     if (!(Focused?.ProcessKey(key) ?? false))
     {
         // focused input didn't handle the key, process here
         if (key.Key == ConsoleKey.Tab)
         {
             SwitchInput(key.Modifiers.HasFlag(ConsoleModifiers.Shift));
         }
     }
 }
Exemplo n.º 23
0
 /// <summary>
 /// Called when the context becomes focused or active. This will be
 /// called after startup and after resume and means that the context is
 /// open and ready to recieve input.
 /// </summary>
 private void focus()
 {
     if (Focused != null)
     {
         Focused.Invoke(this);
     }
     if (!String.IsNullOrEmpty(FocusAction))
     {
         runFinalAction(FocusAction);
     }
 }
Exemplo n.º 24
0
 /// <inheritdoc />
 public override ThemeBase Clone()
 {
     return(new DrawingSurfaceTheme()
     {
         Normal = Normal.Clone(),
         Disabled = Disabled.Clone(),
         MouseOver = MouseOver.Clone(),
         MouseDown = MouseDown.Clone(),
         Selected = Selected.Clone(),
         Focused = Focused.Clone(),
     });
 }
Exemplo n.º 25
0
        /// <summary>
        /// Starts rendering cycle and waits for shutdown
        /// </summary>
        public static void Start()
        {
            var pf       = Environment.OSVersion.Platform;
            var isUnix   = pf == PlatformID.Unix || pf == PlatformID.MacOSX || (int)pf == 128; // unix/macosx/mono linux
            var provider =
                isUnix
                    ? (INativeConsoleProvider) new UnixNativeConsoleProvider()
                    : new WindowsNativeConsoleProvider();

            if (Provider != null)
            {
                throw new ArgumentException("Already started");
            }
            Provider = provider;
            provider.Clear(_background);
            provider.KeyPressed += (o, e) =>
            {
                if (CanChangeFocus && e.Info.Key == ConsoleKey.Tab && e.Info.Modifiers == 0)
                {
                    _prevent = true;
                    FocusNext();
                    _prevent = false;
                    Refresh();
                    return;
                }
                if (CanChangeFocus && e.Info.Key == ConsoleKey.Tab && e.Info.Modifiers == ConsoleModifiers.Shift) // Can not intercept CTRL in Linux
                {
                    _prevent = true;
                    FocusNextWindow();
                    _prevent = false;
                    Refresh();
                    return;
                }
                _prevent = true;
                Focused?.OnKeyPressedInternal(e.Info);
                _prevent = false;
                Refresh();
            };
            provider.SizeChanged += (o, e) =>
            {
                _prevent = true;
                foreach (var window in Windows)
                {
                    window.OnSizeChangedInternal();
                }
                _prevent = false;
                Refresh();
            };
            _prevent = true;
            FocusNextWindow();
            _prevent = false;
            Refresh();
        }
Exemplo n.º 26
0
 /// <inheritdoc />
 public override ThemeBase Clone() => new ListBoxTheme((ScrollBarTheme)ScrollBarTheme.Clone())
 {
     Normal          = Normal.Clone(),
     Disabled        = Disabled.Clone(),
     MouseOver       = MouseOver.Clone(),
     MouseDown       = MouseDown.Clone(),
     Selected        = Selected.Clone(),
     Focused         = Focused.Clone(),
     BorderTheme     = BorderTheme?.Clone(),
     BorderLineStyle = (int[])BorderLineStyle?.Clone(),
     DrawBorder      = DrawBorder,
 };
Exemplo n.º 27
0
 /// <inheritdoc />
 public override ThemeBase Clone() => new LabelTheme()
 {
     Normal                 = Normal.Clone(),
     Disabled               = Disabled.Clone(),
     MouseOver              = MouseOver.Clone(),
     MouseDown              = MouseDown.Clone(),
     Selected               = Selected.Clone(),
     Focused                = Focused.Clone(),
     UseNormalStateOnly     = UseNormalStateOnly,
     DecoratorStrikethrough = DecoratorStrikethrough,
     DecoratorUnderline     = DecoratorUnderline
 };
Exemplo n.º 28
0
 /// <inheritdoc />
 public override ThemeBase Clone() => new ButtonTheme()
 {
     Normal            = Normal.Clone(),
     Disabled          = Disabled.Clone(),
     MouseOver         = MouseOver.Clone(),
     MouseDown         = MouseDown.Clone(),
     Selected          = Selected.Clone(),
     Focused           = Focused.Clone(),
     ShowEnds          = ShowEnds,
     EndCharacterLeft  = EndCharacterLeft,
     EndCharacterRight = EndCharacterRight
 };
        private void HandleFocusChange(object sender, FocusEventArgs e)
        {
            base.SetFocusChange(lblLabel, frmContainer, bxvLine);

            if (IsControlFocused)
            {
                Focused?.Invoke(this, e);
            }
            else
            {
                Unfocused?.Invoke(this, e);
            }
        }
Exemplo n.º 30
0
 protected override void KeyboardInput(InputEventArgs <TInput> args)
 {
     if (KeyboardAdapter.IsTab(args.Input))
     {
         var index = Controls.IndexOf(Focused) + 1;
         Focused           = Controls[index % Controls.Count];
         Focused.IsFocused = true;
     }
     else
     {
         Focused.NotifyKeyboardInput(args.Input);
     }
 }