예제 #1
0
 static void RaiseFocusChanged(IInputElement oldElement, IInputElement newElement)
 {
     if (FocusChanged != null)
     {
         FocusChanged.Invoke(null, new ValueChangedEventArgs <IInputElement>(oldElement, newElement));
     }
 }
예제 #2
0
        public void NextControl()
        {
            if (Count == 0)
            {
                return;
            }

            var currentControl = _selectedControl;

            this[_selectedControl].HasFocus = false;

            do
            {
                _selectedControl++;

                if (_selectedControl == Count)
                {
                    _selectedControl = 0;
                }

                if (this[_selectedControl].TabStop && this[_selectedControl].Enabled)
                {
                    FocusChanged?.Invoke(this[_selectedControl], EventArgs.Empty);
                    break;
                }
            } while (currentControl != _selectedControl);

            this[_selectedControl].HasFocus = true;
        }
예제 #3
0
 void entryFocused(object sender, FocusEventArgs e)
 {
     if (e.IsFocused)
     {
         FocusChanged?.Invoke();
     }
 }
예제 #4
0
 private void activate(bool active)
 {
     if (active != this.activated)
     {
         this.activated = active;
         if (activated)
         {
             if (Activated != null)
             {
                 Activated.Invoke(this);
             }
         }
         else
         {
             if (Deactivated != null)
             {
                 Deactivated.Invoke(this);
             }
         }
         if (FocusChanged != null)
         {
             FocusChanged.Invoke(this);
         }
     }
 }
예제 #5
0
            public void OnAudioFocusChange(AudioFocus focusChange)
            {
                print("AUDIOFOCUS CHANGED:::: " + focusChange.ToString() + "|" + (int)focusChange);
                switch (focusChange)
                {
                case AudioFocus.GainTransient:
                    FocusChanged?.Invoke(this, true);
                    break;

                case AudioFocus.LossTransient:
                    FocusChanged?.Invoke(this, false);
                    break;

                case AudioFocus.Loss:
                    FocusChanged?.Invoke(this, false);
                    break;

                case AudioFocus.GainTransientExclusive:
                    FocusChanged?.Invoke(this, true);
                    break;

                case AudioFocus.Gain:
                    FocusChanged?.Invoke(this, true);
                    break;
                }
            }
예제 #6
0
 internal void _fireFocusChanged()
 {
     Focused = !Focused;
     if (FocusChanged != null)
     {
         FocusChanged.Invoke(this);
     }
 }
 public SearchReplaceControl()
 {
     InitializeComponent();
     _initHeight              = Height;
     cbSearchText.GotFocus   += (s, e) => FocusChanged?.Invoke(this, true);
     cbSearchText.LostFocus  += (s, e) => FocusChanged?.Invoke(this, false);
     cbReplaceText.GotFocus  += (s, e) => FocusChanged?.Invoke(this, true);
     cbReplaceText.LostFocus += (s, e) => FocusChanged?.Invoke(this, false);
 }
예제 #8
0
 private void ButtonPanel_GotFocus(object sender, EventArgs e)
 {
     // Unfortunately the event is raised here after the button when the button is focused
     if (GUIUtilities.CurrentFocus == null || !this.Controls.Contains(GUIUtilities.CurrentFocus))
     {
         GUIUtilities.CurrentFocus = this;
     }
     FocusChanged?.Invoke();
 }
예제 #9
0
 protected virtual void OnFocusChanged(FocusEvent focused, GLBaseControl ctrl)   // focused elements or parents up to GLForm gets this as well
 {
     this.focused = focused == FocusEvent.Focused;
     if (InvalidateOnFocusChange)
     {
         Invalidate();
     }
     FocusChanged?.Invoke(this, focused, ctrl);
 }
예제 #10
0
 private void ColourPanel_LostFocus(object sender, EventArgs e)
 {
     if (this.DesignMode)
     {
         return;
     }
     FocusChanged?.Invoke();
     GUIUtilities.CurrentFocus = null;
 }
예제 #11
0
 private void OnDownArrowPressed()
 {
     if (FocusNumber < 5 && !IsSubPanelActive)
     {
         FocusNumber += 2;
         FocusChanged?.Invoke(this, new FocusChangedEventArgs()
         {
             NewFocus = FocusNumber
         });
     }
 }
예제 #12
0
 private void OnRightArrowPressed()
 {
     if (FocusNumber % 2 == 1 && !IsSubPanelActive)
     {
         FocusNumber++;
         FocusChanged?.Invoke(this, new FocusChangedEventArgs()
         {
             NewFocus = FocusNumber
         });
     }
 }
예제 #13
0
 private void SampleRefreshIcon_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "TouchPoint")
     {
         TouchPoint = (Drawable as SampleDrawable).TouchPoint;
         PointChanged?.Invoke(this, EventArgs.Empty);
     }
     else if (e.PropertyName == "IsFocused")
     {
         IsDrawableFocused = (Drawable as SampleDrawable).IsFocused;
         FocusChanged?.Invoke(this, EventArgs.Empty);
     }
 }
예제 #14
0
        private void OnUpArrowPressed()
        {
            FocusNumber--;
            if (FocusNumber < 1)
            {
                FocusNumber = MaxStatTypes;
            }

            FocusChanged?.Invoke(this, new FocusChangedEventArgs()
            {
                NewFocus = FocusNumber
            });
        }
예제 #15
0
        private void OnDownArrowPressed()
        {
            FocusNumber++;
            if (FocusNumber > MaxStatTypes)
            {
                FocusNumber = 1;
            }

            FocusChanged?.Invoke(this, new FocusChangedEventArgs()
            {
                NewFocus = FocusNumber
            });
        }
        private void OnFocusChanged(IInputElement?focus)
        {
            var oldFocus = _focus;

            _focus = focus?.VisualRoot == Owner ? focus as Control : null;

            if (_focus != oldFocus)
            {
                var peer = _focus is object?
                           _focus == Owner ? this :
                           GetOrCreate(_focus) : null;
                FocusChanged?.Invoke(this, EventArgs.Empty);
            }
        }
예제 #17
0
 private void OnElementMouseDown(object sender, MouseEventArgs e)
 {
     if (sender != Focus)
     {
         var lastFocus = Focus;
         ChangeFocus(sender as FieldElement);
         FocusChanged?.Invoke(lastFocus, Focus);
     }
     if (e.Button == MouseButtons.Right)
     {
         elementMenu.Show(MousePosition);
     }
     else if (e.Button == MouseButtons.Left)
     {
         StartDrag();
     }
 }
예제 #18
0
        protected virtual void TriggerFocusChanged(Node newFocus)
        {
            if (newFocus == null)
            {
                return;
            }

            if (newFocus == _focusNode)
            {
                return;
            }

            var oldFocus = _focusNode;

            _focusNode = newFocus;
            UpdateFocusTree();
            FocusChanged?.Invoke(this, new FocusChangedEventArg(oldFocus, _focusNode));
        }
        public int HookProc(int code, IntPtr wParam, IntPtr lParam)
        {
            if (code == Win32Helper.HcbtSetfocus)
            {
                FocusChanged?.Invoke(this, new FocusChangeEventArgs(wParam, lParam));
            }
            else if (code == Win32Helper.HcbtActivate)
            {
                if (_insideActivateEvent.CanEnter)
                {
                    using (_insideActivateEvent.Enter())
                    {
                        //if (Activate != null)
                        //    Activate(this, new WindowActivateEventArgs(wParam));
                    }
                }
            }


            return(Win32Helper.CallNextHookEx(_windowHook, code, wParam, lParam));
        }
예제 #20
0
        public int HookProc(int code, IntPtr wParam, IntPtr lParam)
        {
            switch (code)
            {
            case 9:
                FocusChanged?.Invoke(this, new FocusChangeEventArgs(wParam, lParam));
                break;

            case 5:
                if (_insideActivateEvent.CanEnter)
                {
                    using (_insideActivateEvent.Enter())
                    {
                        //if (Activate != null)
                        //    Activate(this, new WindowActivateEventArgs(wParam));
                    }
                }
                break;
            }


            return(User32.CallNextHookEx(_windowHook, code, wParam, lParam));
        }
예제 #21
0
        public Window(string title, int width, int height)
        {
            _title = title;
            Width  = width;
            Height = height;

            glfw.WindowHint(WindowHintBool.Visible, false);

            pWindowHandle = glfw.CreateWindow(width, height, _title, (Monitor *)IntPtr.Zero.ToPointer(), null);

            Load?.Invoke();

            _onMove = (window, x, y) =>
            {
                Move?.Invoke((x, y));
            };

            _onResize = (window, width, height) =>
            {
                Resize?.Invoke((width, height));
            };

            _onFramebufferResize = (window, width, height) =>
            {
                FramebufferResize?.Invoke((width, height));
            };

            _onClosing = window => Closing?.Invoke();

            _onFocusChanged = (window, isFocused) => FocusChanged?.Invoke(isFocused);

            _onMinimized = (window, isMinimized) =>
            {
                WindowState state;
                // If minimized, we immediately know what value the new WindowState is.
                if (isMinimized)
                {
                    state = WindowState.Minimized;
                }
                else
                {
                    // Otherwise, we have to query a few things to figure out out.
                    if (glfw.GetWindowAttrib(pWindowHandle, WindowAttributeGetter.Maximized))
                    {
                        state = WindowState.Maximized;
                    }
                    else if (glfw.GetWindowMonitor(pWindowHandle) != null)
                    {
                        state = WindowState.Fullscreen;
                    }
                    else
                    {
                        state = WindowState.Normal;
                    }
                }

                StateChanged?.Invoke(state);
            };

            _onMaximized = (window, isMaximized) =>
            {
                // Same here as in onMinimized.
                WindowState state;
                if (isMaximized)
                {
                    state = WindowState.Maximized;
                }
                else
                {
                    if (glfw.GetWindowAttrib(pWindowHandle, WindowAttributeGetter.Iconified))
                    {
                        state = WindowState.Minimized;
                    }
                    else if (glfw.GetWindowMonitor(pWindowHandle) != null)
                    {
                        state = WindowState.Fullscreen;
                    }
                    else
                    {
                        state = WindowState.Normal;
                    }
                }

                StateChanged?.Invoke(state);
            };

            _onFileDrop = (window, count, paths) =>
            {
                var arrayOfPaths = new string[count];

                if (count == 0 || paths == IntPtr.Zero)
                {
                    return;
                }

                for (var i = 0; i < count; i++)
                {
                    var p = Marshal.ReadIntPtr(paths, i * IntPtr.Size);
                    arrayOfPaths[i] = Marshal.PtrToStringAnsi(p);
                }

                FileDrop?.Invoke(arrayOfPaths);
            };


            glfw.SetWindowPosCallback(pWindowHandle, _onMove);
            glfw.SetWindowSizeCallback(pWindowHandle, _onResize);
            glfw.SetWindowCloseCallback(pWindowHandle, _onClosing);
            glfw.SetWindowFocusCallback(pWindowHandle, _onFocusChanged);
            glfw.SetWindowIconifyCallback(pWindowHandle, _onMinimized);
            glfw.SetWindowMaximizeCallback(pWindowHandle, _onMaximized);
            glfw.SetFramebufferSizeCallback(pWindowHandle, _onFramebufferResize);
            glfw.SetDropCallback(pWindowHandle, _onFileDrop);
        }
예제 #22
0
        private static unsafe int OnMessage(UOMessage msg, int arg1, int arg2, int arg3, byte *data)
        {
            try
            {
                switch (msg)
                {
                case UOMessage.Ready:
                    Ready = true;
                    hooks.Send(UOMessage.ConnectionInfo, (int)ServerIP, ServerPort);
                    hooks.Send(UOMessage.GameSize, Width, Height);
                    OnInit();
                    break;

                case UOMessage.Connected:
                    Connected.Raise();
                    break;

                case UOMessage.Disconnecting:
                    Disconnecting.Raise();
                    break;

                case UOMessage.Closing:
                    Closing.Raise();
                    break;

                case UOMessage.Focus:
                    FocusChanged.Raise(arg1 != 0);
                    break;

                case UOMessage.Visibility:
                    VisibilityChanged.Raise(arg1 != 0);
                    break;

                case UOMessage.KeyDown:
                    UOKeyEventArgs keyArgs = new UOKeyEventArgs(arg1, arg2);
                    KeyDown.Raise(keyArgs);
                    if (keyArgs.Filter)
                    {
                        return(1);
                    }
                    break;

                case UOMessage.PacketToClient:
                    Packet toClient = new Packet(data, arg1);
                    PacketToClient.Raise(toClient);
                    if (toClient.Filter)
                    {
                        return(1);
                    }
                    if (toClient.Changed)
                    {
                        return(2);
                    }
                    break;

                case UOMessage.PacketToServer:
                    Packet toServer = new Packet(data, arg1);
                    PacketToServer.Raise(toServer);
                    if (toServer.Filter)
                    {
                        return(1);
                    }
                    if (toServer.Changed)
                    {
                        return(2);
                    }
                    break;
                }
            }
            catch (Exception ex) { OnException(ex); }
            return(0);
        }
예제 #23
0
 /// <summary>Triggers the FocusChanged event</summary>
 /// <param name="focusedControl">Control that has gotten the input focus</param>
 private void OnFocusChanged(GuiControl focusedControl)
 {
     FocusChanged?.Invoke(this, new ControlEventArgs(focusedControl));
 }
예제 #24
0
 private void OnFocusChanged(object sender, EventArgs e)
 {
     FocusChanged?.Invoke();
 }
예제 #25
0
        public override void Update()
        {
            if (Mouse.ButtonPressed(MouseButtons.Left))
            {
                var isFocused = IsMouseOver();
                if (isFocused != IsFocused)
                {
                    IsFocused = isFocused;
                    FocusChanged?.Invoke(this, new FocusChangedEventArgs(IsFocused));
                }

                if (IsFocused && Font.HitTest(Mouse.Position - Position, Text, ActualWidth, out int i))
                {
                    _cursorPos = i;
                }
            }

            if (!IsFocused)
            {
                return;
            }

            //Toggle cursor every half second
            _cursorTick += GameTime.UnscaledDeltaTime;
            if (_cursorTick >= .5f)
            {
                _showCursor = !_showCursor;
                _cursorTick = 0;
            }

            //Cursor navigation
            //Always show cursor when navigating
            if (_cursorPos > 0 && Keyboard.KeyPressed(Keys.Left))
            {
                _cursorPos--;
                _cursorTick = 0;
                _showCursor = true;
                HandleInputEvent(Keys.Left);
            }
            else if (_cursorPos < _text.Length && Keyboard.KeyPressed(Keys.Right))
            {
                _cursorPos++;
                _cursorTick = 0;
                _showCursor = true;
                HandleInputEvent(Keys.Right);
            }

            if (Keyboard.KeyPressed(Keys.Enter))
            {
                Enter?.Invoke(this, new EventArgs());
                HandleInputEvent(Keys.Enter);
            }

            //Text deletion
            if (Keyboard.KeyPressed(Keys.Backspace) && _cursorPos > 0)
            {
                _text = _text.Remove(_cursorPos - 1, 1);
                _cursorPos--;
                HandleInputEvent(Keys.Backspace);
            }
            if (Keyboard.KeyPressed(Keys.Delete) && _cursorPos < _text.Length)
            {
                _text = _text.Remove(_cursorPos, 1);
                HandleInputEvent(Keys.Delete);
            }

            //Text input
            var keys = Enum.GetValues(typeof(Keys));

            for (int i = 0; i < keys.Length; i++)
            {
                var k = (Keys)keys.GetValue(i);
                if (Keyboard.KeyPressed(k))
                {
                    var text = Keyboard.ToUnicode(k);
                    if (text != "\b")
                    {
                        _text       = _text.Insert(_cursorPos, text);
                        _cursorPos += text.Length;
                    }
                    HandleInputEvent(k);
                }
            }
        }
예제 #26
0
 private void OnInternalFocusChanged(object sender, EventArgs e)
 {
     OnFocusChanged(this, e);
     FocusChanged?.Invoke(this, e);
 }
예제 #27
0
 void OnFocus(object o, EventArgs args)
 {
     NotifyStateChange(StateType.Focused, widget.HasFocus);
     FocusChanged?.Invoke(this, widget.HasFocus);
 }
예제 #28
0
        public EditorState(IWin32Window window, string name, object tag, int tabIndex)
        {
            FilePath     = null;
            Name         = name;
            Tag          = tag;
            IsChanged    = false;
            FileEncoding = Encoding.UTF8;

            _styleNeededState = new StyleNeededState();

            _window  = window;
            TabIndex = tabIndex;

            _editor = new Scintilla();
            SetupEditor(_editor);

            _containerPanel      = new Panel();
            _containerPanel.Dock = DockStyle.Fill;
            _containerPanel.Controls.Add(_editor);

            _searchControl      = new SearchReplaceControl();
            _searchControl.Dock = DockStyle.Top;
            _containerPanel.Controls.Add(_searchControl);

            _searchControl.Search += (s, direction) =>
            {
                SearchText(_window, _searchControl.SearchText, direction, _searchControl.MatchCase, _searchControl.MatchWords, _searchControl.IsRegex, _searchControl.IsWrap);
            };
            _searchControl.Replace += (s, mode) =>
            {
                ReplaceText(_window, _searchControl.SearchText, _searchControl.ReplaceText, mode, _searchControl.MatchCase, _searchControl.MatchWords, _searchControl.IsRegex, _searchControl.IsWrap);
            };
            _searchControl.FocusChanged += (s, focused) =>
            {
                FocusChanged?.Invoke(this, focused);
            };
            _searchControl.Hide();

            _maxLineNumberCharLength = 0;
            _textChangedTimer        = new System.Windows.Forms.Timer()
            {
                Enabled = false, Interval = 250
            };
            _textChangedTimer.Tick += (s, e) =>
            {
                if (!_parseWorker.IsBusy)
                {
                    _textChangedTimer.Enabled = false;
                    ParseStarting?.Invoke(this);
                    _parseWorker.RunWorkerAsync(_editor.Text);
                }
            };
            _parseWorker = new BackgroundWorker();
            _parseWorker.WorkerSupportsCancellation = true;
            _parseWorker.DoWork += (s, e) =>
            {
                // @TODO(final): Support for incremental parsing, so only changes are applied
                string text = (string)e.Argument;
                Tokenize(text);
                Parse(text);
            };
            _parseWorker.RunWorkerCompleted += (s, e) =>
            {
                // @TODO(final): Dont colorize everything, just re-colorize the changes -> See "Support for continuous tokenization"
                if (_styleNeededState.Has > 0)
                {
                    _editor.Colorize(_styleNeededState.StartPos, _styleNeededState.EndPos);
                }
                else
                {
                    int firstLine = _editor.FirstVisibleLine;
                    int lastLine  = firstLine + _editor.LinesOnScreen;
                    int start     = _editor.Lines[firstLine].Index;
                    int end       = _editor.Lines[lastLine].Index;
                    _editor.Colorize(start, end);
                }
                ParseComplete?.Invoke(this);
            };
        }
예제 #29
0
 private void ButtonPanel_LostFocus(object sender, EventArgs e)
 {
     FocusChanged?.Invoke();
 }
예제 #30
0
 private void DelegateOnFocusChanged(SAPFEWSELib.GuiSession currentSession, GuiVComponent newFocusedControl)
 {
     FocusChanged?.Invoke(GetSession(), newFocusedControl);
 }