Beispiel #1
0
        // Constructor
        public AppSystem(IForegroundWindowHook fgHook, IWindowUpdateHook winHook, IMouseHook msHook)
        {
            _state = new InitialState();

            _stateContext = new AppStateContext
            {
                PathModeLocksToHandle = false,
                ForegroundHook        = fgHook,
                WindowHook            = winHook,
                MouseHook             = msHook,
                SetCurrentState       = (next) => SetCurrentState(next),
                SendLockStateChange   = () => LockStateChanged.Invoke(this, new Events.LockStateChangedEventArgs {
                    IsLocked = IsLocked
                }),
                SendPathChange = (path) => PathChanged.Invoke(this, new Events.PathChangedEventArgs {
                    Path = path
                }),
                SendTitleChange = (title) => TitleChanged.Invoke(this, new Events.TitleChangedEventArgs {
                    Title = title
                }),
                SendDimensionsChange = (dimensions) => DimensionsChanged.Invoke(this, new Events.DimensionsChangedEventArgs {
                    Dimensions = dimensions
                }),
                SendForegroundChange = (inForeground) => ForegroundChanged.Invoke(this, new Events.ForegroundStateChangedEventArgs {
                    InForeground = inForeground
                })
            };

            fgHook.ForegroundWindowChanged += ForegroundHook_ForegroundWindowChanged;
            winHook.WindowClosed           += WindowHook_WindowClosed;
            winHook.DimensionsChanged      += WindowHook_DimensionsChanged;
            winHook.TitleChanged           += WindowHook_TitleChanged;
        }
 public void SetDimensions(int width, int height)
 {
     if (Width != width || Height != height)
     {
         Width  = width;
         Height = height;
         DimensionsChanged?.Invoke();
     }
 }
Beispiel #3
0
 private void SendWindowDimensions(IntPtr handle)
 {
     NativeMethods.GetWindowRect(handle, out Win32Rect rect);
     DimensionsChanged?.Invoke(this, new DimensionsChangedEventArgs
     {
         Dimensions = new Dimensions
         {
             Left   = rect.Left,
             Top    = rect.Top,
             Right  = rect.Right,
             Bottom = rect.Bottom
         }
     });
 }
 public NavigableBuffer()
 {
     CursorX = new Property <int>((oldX, newX) => newX >= 0 && newX < Width.Value, x => { if (_raisePosChanged)
                                                                                          {
                                                                                              RaisePosChanged();
                                                                                          }
                                  });
     CursorY = new Property <int>((oldY, newY) => newY >= 0 && newY < Height.Value, y => { if (_raisePosChanged)
                                                                                           {
                                                                                               RaisePosChanged();
                                                                                           }
                                  });
     Width = new Property <int>(
         (oldW, newW) => {
         if (newW < 0)
         {
             return(false);
         }
         if (newW < oldW && CursorX.Value > newW)
         {
             CursorX.Value = newW;
         }
         Array.Resize(ref _buffer, newW * Height.Value);
         return(true);
     },
         w => DimensionsChanged?.Invoke(this, Tuple.Create(Width.Value, Height.Value))
         );
     Height = new Property <int>(
         (oldY, newY) => {
         if (newY < 0)
         {
             return(false);
         }
         if (newY < oldY && CursorY.Value > newY)
         {
             CursorY.Value = newY;
         }
         Array.Resize(ref _buffer, Width.Value * newY);
         return(true);
     },
         h => DimensionsChanged?.Invoke(this, Tuple.Create(Width.Value, Height.Value))
         );
     _buffer = new T[Width.Value * Height.Value];
 }
Beispiel #5
0
 public static void OnDimensionsChanged()
 {
     DimensionsChanged?.Invoke();
 }
Beispiel #6
0
 private static void OnDimensionsChanged()
 {
     DimensionsChanged?.Invoke();
 }