Пример #1
0
 private void Dispose(bool finalizing)
 {
     lock (this)
     {
         if (_isDisposed)
         {
             return;
         }
         _isDisposed = true;
         if (Closing != null)
         {
             Closing.Invoke(this, EventArgs.Empty);
         }
         if (_journalAppender != null)
         {
             _journalAppender.Dispose();
         }
         if (finalizing)
         {
             return;
         }
         //todo: bad dependency, use events instead
         Core.Config.Engines.Remove(this);
         if (_config.SnapshotBehavior == SnapshotBehavior.OnShutdown)
         {
             CreateSnapshot();
         }
         GC.SuppressFinalize(this);
     }
 }
Пример #2
0
 /// <summary>
 /// Raises the Closing event
 /// </summary>
 protected virtual void OnClosing()
 {
     if (Closing != null)
     {
         Closing.Invoke(this, new EventArgs());
     }
 }
Пример #3
0
 protected virtual void OnClosing(WindowClosingEventArgs e)
 {
     if (Closing != null)
     {
         Closing.Invoke(this, e);
     }
 }
Пример #4
0
 private void closing()
 {
     if (Closing != null)
     {
         Closing.Invoke(this);
     }
 }
Пример #5
0
 protected virtual void onClosing(DialogCancelEventArgs args)
 {
     if (Closing != null)
     {
         Closing.Invoke(this, args);
     }
 }
Пример #6
0
 internal void _fireWindowClosing()
 {
     if (Closing != null)
     {
         Closing.Invoke(this);
     }
 }
Пример #7
0
        /// <param name="e"></param>
        /// <summary>
        /// Handles the closing of the modal container control.
        /// </summary>
        protected virtual void OnClosing(WindowClosingEventArgs e)
        {
            if (Closing != null)
            {
                Closing.Invoke(this, e);
            }
//Close(ModalResult.Cancel);
        }
Пример #8
0
 public void Dispose()
 {
     Control.Dispose();
     GraphViewer.floatingTooltipControls.Remove(this);
     if (Closing != null)
     {
         Closing.Invoke(this, null);
     }
 }
Пример #9
0
        private void _closeButton_Click(object sender, RoutedEventArgs e)
        {
            if (Closing != null)
            {
                Closing.Invoke(this, null);
            }

            ((Panel)this.Parent).Children.Remove(this);
        }
Пример #10
0
 public void Invoke(string EventName, Game CurrentGame, EventArguments Args)
 {
     if (EventName == "Closing")
     {
         Closing.Invoke(CurrentGame, Args);
     }
     if (EventName == "KeyDown")
     {
         KeyDown.Invoke(CurrentGame, Args);
     }
     if (EventName == "KeyUp")
     {
         KeyUp.Invoke(CurrentGame, Args);
     }
     if (EventName == "KeyPress")
     {
         KeyPress.Invoke(CurrentGame, Args);
     }
     if (EventName == "Load")
     {
         Load.Invoke(CurrentGame, Args);
     }
     if (EventName == "MouseDown")
     {
         MouseDown.Invoke(CurrentGame, Args);
     }
     if (EventName == "MouseUp")
     {
         MouseUp.Invoke(CurrentGame, Args);
     }
     if (EventName == "MouseClick")
     {
         MouseClick.Invoke(CurrentGame, Args);
     }
     if (EventName == "MouseMove")
     {
         MouseMove.Invoke(CurrentGame, Args);
     }
     if (EventName == "MouseWheel")
     {
         MouseWheel.Invoke(CurrentGame, Args);
     }
     if (EventName == "RenderFrame")
     {
         RenderFrame.Invoke(CurrentGame, Args);
     }
     if (EventName == "Resize")
     {
         Resize.Invoke(CurrentGame, Args);
     }
     if (EventName == "TimerTick")
     {
         TimerTick.Invoke(CurrentGame, Args);
     }
 }
Пример #11
0
 public void Close()
 {
     if (Closing != null)
     {
         Closing.Invoke(this, new EventArgs() as MouseEventArgs);
     }
     if (_timerOpen != null)
     {
         _timerOpen.Stop();
     }
     MenuPopup.IsOpen = false;
     OpenMenuList.Remove(this);
 }
Пример #12
0
        async Task InternalCloseAsync(TimeSpan timeout)
        {
            State = CommunicationState.Closing;
            if (Closing != null)
            {
                Closing.Invoke(this, EventArgs.Empty);
            }
            await CloseAsync(timeout);

            State = CommunicationState.Closed;
            if (Closed != null)
            {
                Closed.Invoke(this, EventArgs.Empty);
            }
        }
Пример #13
0
 protected void OnClosing()
 {
     _isClosing = true;
     if (Closing != null)
     {
         Closing.Invoke();
     }
     if (_receiveSocketEvent != null)
     {
         //It is safe to call SocketAsyncEventArgs.Dispose() more than once
         _sendSocketEvent.Dispose();
         _receiveSocketEvent.Dispose();
     }
     else if (_socketStream != null)
     {
         _socketStream.Dispose();
     }
     //dereference to make the byte array GC-able as soon as possible
     _receiveBuffer = null;
 }
Пример #14
0
 /// <summary>
 /// Initializes this <see cref="Application"/> object's events.
 /// </summary>
 protected override void InitializeEvents() => Libui.OnShouldQuit(data =>
 {
     CloseEventArgs e = new CloseEventArgs();
     Closing.Invoke(this, e);
     return(e.Close);
 }, IntPtr.Zero);
Пример #15
0
        void close()
        {
            lock (This_)
            {
                BotCycle.Abort();

                if (This.items_xtw != null)
                {
                    This.items_xtw.WriteEndElement();
                    This.items_xtw.WriteEndDocument();
                    This.items_xtw.Close();
                }

                if (This.input_item_queue_name2input_item_queues.Count > 0)
                {
                    if (This.IsUnprocessedInputItem)
                    {
                        This.set_session_state(SessionState.ABORTED);
                    }
                    else if (This.IsItem2Restore)
                    {
                        This.set_session_state(SessionState.UNCOMPLETED);
                    }
                    else
                    {
                        This.set_session_state(SessionState.COMPLETED);
                    }
                }
                This.workflow_xtw.WriteEndElement();
                This.workflow_xtw.WriteEndDocument();
                This.workflow_xtw.Close();

                try
                {
                    CustomizationApi.SessionClosing();
                }
                catch (Exception e)
                {
                    LogMessage.Error(e);
                }

                try
                {
                    if (Closing != null)
                    {
                        Closing.Invoke();
                    }
                }
                catch (Exception e)
                {
                    LogMessage.Error(e);
                }

                InputItemQueue.Close();
                FileWriter.ClearSession();
                Cache.ClearSession();
                Proxies.ClearSession();
                WebRoutine.ClearSession();
                Log.Main.Write("Closing session.");
                Cliver.Log.ClearSession();

                This_ = null;
            }
        }
Пример #16
0
 public void Close() => Closing.Invoke();
 public void OnViewClosing()
 {
     Closing?.Invoke(this, EventArgs.Empty);
 }
Пример #18
0
        private void OnClosing()
        {
            WindowClosingEventArgs windowClosingEventArgs = new(this);

            Closing.Invoke(this, windowClosingEventArgs);
        }
Пример #19
0
 protected virtual void OnClosing(CancelEventArgs e)
 {
     Closing?.Invoke(this, e);
 }
Пример #20
0
 /// <summary>
 /// Invokes the Closing event.
 /// </summary>
 internal void DoClosing()
 {
     Closing.Invoke();
 }
 /// <summary>
 /// Application exit. Stop all routing and dispose of all controllers.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void MainWindowClosed(object sender, System.EventArgs e)
 {
     Closing?.Invoke(this, new EventArgs());
 }
Пример #22
0
 internal void Internal_OnClosing(ClosingReason reason, ref bool cancel)
 {
     Closing?.Invoke(reason, ref cancel);
 }
Пример #23
0
 private void RemoveBtn_Click(object sender, RoutedEventArgs e)
 {
     Closing?.Invoke(this, Module);
     Module.Close();
 }
Пример #24
0
 public void OnClosing()
 {
     Closing?.Invoke();
 }
Пример #25
0
        protected virtual unsafe IntPtr AppWndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam)
        {
            const double wheelDelta = 120.0;
            uint         timestamp  = unchecked ((uint)GetMessageTime());

            RawInputEventArgs e = null;
            var shouldTakeFocus = false;

            switch ((WindowsMessage)msg)
            {
            case WindowsMessage.WM_ACTIVATE:
            {
                var wa = (WindowActivate)(ToInt32(wParam) & 0xffff);

                switch (wa)
                {
                case WindowActivate.WA_ACTIVE:
                case WindowActivate.WA_CLICKACTIVE:
                {
                    Activated?.Invoke();
                    break;
                }

                case WindowActivate.WA_INACTIVE:
                {
                    Deactivated?.Invoke();
                    break;
                }
                }

                return(IntPtr.Zero);
            }

            case WindowsMessage.WM_NCCALCSIZE:
            {
                if (ToInt32(wParam) == 1 && !HasFullDecorations || _isClientAreaExtended)
                {
                    return(IntPtr.Zero);
                }

                break;
            }

            case WindowsMessage.WM_CLOSE:
            {
                bool?preventClosing = Closing?.Invoke();
                if (preventClosing == true)
                {
                    return(IntPtr.Zero);
                }

                break;
            }

            case WindowsMessage.WM_DESTROY:
            {
                //Window doesn't exist anymore
                _hwnd = IntPtr.Zero;
                //Remove root reference to this class, so unmanaged delegate can be collected
                s_instances.Remove(this);
                Closed?.Invoke();

                _mouseDevice.Dispose();
                _touchDevice?.Dispose();
                //Free other resources
                Dispose();
                return(IntPtr.Zero);
            }

            case WindowsMessage.WM_DPICHANGED:
            {
                var dpi            = ToInt32(wParam) & 0xffff;
                var newDisplayRect = Marshal.PtrToStructure <RECT>(lParam);
                _scaling = dpi / 96.0;
                ScalingChanged?.Invoke(_scaling);
                SetWindowPos(hWnd,
                             IntPtr.Zero,
                             newDisplayRect.left,
                             newDisplayRect.top,
                             newDisplayRect.right - newDisplayRect.left,
                             newDisplayRect.bottom - newDisplayRect.top,
                             SetWindowPosFlags.SWP_NOZORDER |
                             SetWindowPosFlags.SWP_NOACTIVATE);
                return(IntPtr.Zero);
            }

            case WindowsMessage.WM_KEYDOWN:
            case WindowsMessage.WM_SYSKEYDOWN:
            {
                e = new RawKeyEventArgs(
                    WindowsKeyboardDevice.Instance,
                    timestamp,
                    _owner,
                    RawKeyEventType.KeyDown,
                    KeyInterop.KeyFromVirtualKey(ToInt32(wParam), ToInt32(lParam)),
                    WindowsKeyboardDevice.Instance.Modifiers);
                break;
            }

            case WindowsMessage.WM_MENUCHAR:
            {
                // mute the system beep
                return((IntPtr)((int)MenuCharParam.MNC_CLOSE << 16));
            }

            case WindowsMessage.WM_KEYUP:
            case WindowsMessage.WM_SYSKEYUP:
            {
                e = new RawKeyEventArgs(
                    WindowsKeyboardDevice.Instance,
                    timestamp,
                    _owner,
                    RawKeyEventType.KeyUp,
                    KeyInterop.KeyFromVirtualKey(ToInt32(wParam), ToInt32(lParam)),
                    WindowsKeyboardDevice.Instance.Modifiers);
                break;
            }

            case WindowsMessage.WM_CHAR:
            {
                // Ignore control chars
                if (ToInt32(wParam) >= 32)
                {
                    e = new RawTextInputEventArgs(WindowsKeyboardDevice.Instance, timestamp, _owner,
                                                  new string((char)ToInt32(wParam), 1));
                }

                break;
            }

            case WindowsMessage.WM_LBUTTONDOWN:
            case WindowsMessage.WM_RBUTTONDOWN:
            case WindowsMessage.WM_MBUTTONDOWN:
            case WindowsMessage.WM_XBUTTONDOWN:
            {
                shouldTakeFocus = ShouldTakeFocusOnClick;
                if (ShouldIgnoreTouchEmulatedMessage())
                {
                    break;
                }

                e = new RawPointerEventArgs(
                    _mouseDevice,
                    timestamp,
                    _owner,
                    (WindowsMessage)msg switch
                    {
                        WindowsMessage.WM_LBUTTONDOWN => RawPointerEventType.LeftButtonDown,
                        WindowsMessage.WM_RBUTTONDOWN => RawPointerEventType.RightButtonDown,
                        WindowsMessage.WM_MBUTTONDOWN => RawPointerEventType.MiddleButtonDown,
                        WindowsMessage.WM_XBUTTONDOWN =>
                        HighWord(ToInt32(wParam)) == 1 ?
                        RawPointerEventType.XButton1Down :
                        RawPointerEventType.XButton2Down
                    },
                    DipFromLParam(lParam), GetMouseModifiers(wParam));
                break;
            }
Пример #26
0
 private void Editor_Unloaded(object sender, RoutedEventArgs e)
 {
     Closing?.Invoke(sender, EventArgs.Empty);
 }
Пример #27
0
 protected virtual void OnClosing(SettingsClosingEventArgs e)
 {
     Closing?.Invoke(this, e);
 }
Пример #28
0
        private unsafe bool OnClosingEvent(IntPtr w, IntPtr ev, IntPtr userdata)
        {
            bool?preventClosing = Closing?.Invoke();

            return(preventClosing ?? false);
        }
Пример #29
0
 private void Window_Closing(object sender, CancelEventArgs e) => Closing.Invoke(this, e);
Пример #30
0
        protected virtual IntPtr WndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam)
        {
            bool unicode = UnmanagedMethods.IsWindowUnicode(hWnd);

            const double wheelDelta = 120.0;
            uint         timestamp  = unchecked ((uint)UnmanagedMethods.GetMessageTime());

            RawInputEventArgs e = null;

            WindowsMouseDevice.Instance.CurrentWindow = this;

            switch ((UnmanagedMethods.WindowsMessage)msg)
            {
            case UnmanagedMethods.WindowsMessage.WM_ACTIVATE:
                var wa = (UnmanagedMethods.WindowActivate)(ToInt32(wParam) & 0xffff);

                switch (wa)
                {
                case UnmanagedMethods.WindowActivate.WA_ACTIVE:
                case UnmanagedMethods.WindowActivate.WA_CLICKACTIVE:
                    Activated?.Invoke();
                    break;

                case UnmanagedMethods.WindowActivate.WA_INACTIVE:
                    Deactivated?.Invoke();
                    break;
                }

                return(IntPtr.Zero);

            case UnmanagedMethods.WindowsMessage.WM_CLOSE:
                bool?preventClosing = Closing?.Invoke();
                if (preventClosing == true)
                {
                    return(IntPtr.Zero);
                }
                break;

            case UnmanagedMethods.WindowsMessage.WM_DESTROY:
                //Window doesn't exist anymore
                _hwnd = IntPtr.Zero;
                //Remove root reference to this class, so unmanaged delegate can be collected
                s_instances.Remove(this);
                Closed?.Invoke();
                //Free other resources
                Dispose();
                return(IntPtr.Zero);

            case UnmanagedMethods.WindowsMessage.WM_DPICHANGED:
                var dpi            = ToInt32(wParam) & 0xffff;
                var newDisplayRect = Marshal.PtrToStructure <UnmanagedMethods.RECT>(lParam);
                Position = new Point(newDisplayRect.left, newDisplayRect.top);
                _scaling = dpi / 96.0;
                ScalingChanged?.Invoke(_scaling);
                return(IntPtr.Zero);

            case UnmanagedMethods.WindowsMessage.WM_KEYDOWN:
            case UnmanagedMethods.WindowsMessage.WM_SYSKEYDOWN:
                e = new RawKeyEventArgs(
                    WindowsKeyboardDevice.Instance,
                    timestamp,
                    RawKeyEventType.KeyDown,
                    KeyInterop.KeyFromVirtualKey(ToInt32(wParam)), WindowsKeyboardDevice.Instance.Modifiers);
                break;

            case UnmanagedMethods.WindowsMessage.WM_KEYUP:
            case UnmanagedMethods.WindowsMessage.WM_SYSKEYUP:
                e = new RawKeyEventArgs(
                    WindowsKeyboardDevice.Instance,
                    timestamp,
                    RawKeyEventType.KeyUp,
                    KeyInterop.KeyFromVirtualKey(ToInt32(wParam)), WindowsKeyboardDevice.Instance.Modifiers);
                break;

            case UnmanagedMethods.WindowsMessage.WM_CHAR:
                // Ignore control chars
                if (ToInt32(wParam) >= 32)
                {
                    e = new RawTextInputEventArgs(WindowsKeyboardDevice.Instance, timestamp,
                                                  new string((char)ToInt32(wParam), 1));
                }

                break;

            case UnmanagedMethods.WindowsMessage.WM_LBUTTONDOWN:
            case UnmanagedMethods.WindowsMessage.WM_RBUTTONDOWN:
            case UnmanagedMethods.WindowsMessage.WM_MBUTTONDOWN:
                e = new RawMouseEventArgs(
                    WindowsMouseDevice.Instance,
                    timestamp,
                    _owner,
                    msg == (int)UnmanagedMethods.WindowsMessage.WM_LBUTTONDOWN
                            ? RawMouseEventType.LeftButtonDown
                            : msg == (int)UnmanagedMethods.WindowsMessage.WM_RBUTTONDOWN
                                ? RawMouseEventType.RightButtonDown
                                : RawMouseEventType.MiddleButtonDown,
                    DipFromLParam(lParam), GetMouseModifiers(wParam));
                break;

            case UnmanagedMethods.WindowsMessage.WM_LBUTTONUP:
            case UnmanagedMethods.WindowsMessage.WM_RBUTTONUP:
            case UnmanagedMethods.WindowsMessage.WM_MBUTTONUP:
                e = new RawMouseEventArgs(
                    WindowsMouseDevice.Instance,
                    timestamp,
                    _owner,
                    msg == (int)UnmanagedMethods.WindowsMessage.WM_LBUTTONUP
                            ? RawMouseEventType.LeftButtonUp
                            : msg == (int)UnmanagedMethods.WindowsMessage.WM_RBUTTONUP
                                ? RawMouseEventType.RightButtonUp
                                : RawMouseEventType.MiddleButtonUp,
                    DipFromLParam(lParam), GetMouseModifiers(wParam));
                break;

            case UnmanagedMethods.WindowsMessage.WM_MOUSEMOVE:
                if (!_trackingMouse)
                {
                    var tm = new UnmanagedMethods.TRACKMOUSEEVENT
                    {
                        cbSize      = Marshal.SizeOf <UnmanagedMethods.TRACKMOUSEEVENT>(),
                        dwFlags     = 2,
                        hwndTrack   = _hwnd,
                        dwHoverTime = 0,
                    };

                    UnmanagedMethods.TrackMouseEvent(ref tm);
                }

                e = new RawMouseEventArgs(
                    WindowsMouseDevice.Instance,
                    timestamp,
                    _owner,
                    RawMouseEventType.Move,
                    DipFromLParam(lParam), GetMouseModifiers(wParam));

                break;

            case UnmanagedMethods.WindowsMessage.WM_MOUSEWHEEL:
                e = new RawMouseWheelEventArgs(
                    WindowsMouseDevice.Instance,
                    timestamp,
                    _owner,
                    PointToClient(PointFromLParam(lParam)),
                    new Vector(0, (ToInt32(wParam) >> 16) / wheelDelta), GetMouseModifiers(wParam));
                break;

            case UnmanagedMethods.WindowsMessage.WM_MOUSEHWHEEL:
                e = new RawMouseWheelEventArgs(
                    WindowsMouseDevice.Instance,
                    timestamp,
                    _owner,
                    PointToClient(PointFromLParam(lParam)),
                    new Vector(-(ToInt32(wParam) >> 16) / wheelDelta, 0), GetMouseModifiers(wParam));
                break;

            case UnmanagedMethods.WindowsMessage.WM_MOUSELEAVE:
                _trackingMouse = false;
                e = new RawMouseEventArgs(
                    WindowsMouseDevice.Instance,
                    timestamp,
                    _owner,
                    RawMouseEventType.LeaveWindow,
                    new Point(), WindowsKeyboardDevice.Instance.Modifiers);
                break;

            case UnmanagedMethods.WindowsMessage.WM_NCLBUTTONDOWN:
            case UnmanagedMethods.WindowsMessage.WM_NCRBUTTONDOWN:
            case UnmanagedMethods.WindowsMessage.WM_NCMBUTTONDOWN:
                e = new RawMouseEventArgs(
                    WindowsMouseDevice.Instance,
                    timestamp,
                    _owner,
                    msg == (int)UnmanagedMethods.WindowsMessage.WM_NCLBUTTONDOWN
                            ? RawMouseEventType.NonClientLeftButtonDown
                            : msg == (int)UnmanagedMethods.WindowsMessage.WM_NCRBUTTONDOWN
                                ? RawMouseEventType.RightButtonDown
                                : RawMouseEventType.MiddleButtonDown,
                    new Point(0, 0), GetMouseModifiers(wParam));
                break;

            case UnmanagedMethods.WindowsMessage.WM_PAINT:
                UnmanagedMethods.PAINTSTRUCT ps;

                if (UnmanagedMethods.BeginPaint(_hwnd, out ps) != IntPtr.Zero)
                {
                    var f = Scaling;
                    var r = ps.rcPaint;
                    Paint?.Invoke(new Rect(r.left / f, r.top / f, (r.right - r.left) / f, (r.bottom - r.top) / f));
                    UnmanagedMethods.EndPaint(_hwnd, ref ps);
                }

                return(IntPtr.Zero);

            case UnmanagedMethods.WindowsMessage.WM_SIZE:
                if (Resized != null &&
                    (wParam == (IntPtr)UnmanagedMethods.SizeCommand.Restored ||
                     wParam == (IntPtr)UnmanagedMethods.SizeCommand.Maximized))
                {
                    var clientSize = new Size(ToInt32(lParam) & 0xffff, ToInt32(lParam) >> 16);
                    Resized(clientSize / Scaling);
                }

                return(IntPtr.Zero);

            case UnmanagedMethods.WindowsMessage.WM_MOVE:
                PositionChanged?.Invoke(new Point((short)(ToInt32(lParam) & 0xffff), (short)(ToInt32(lParam) >> 16)));
                return(IntPtr.Zero);

            case UnmanagedMethods.WindowsMessage.WM_GETMINMAXINFO:

                MINMAXINFO mmi = Marshal.PtrToStructure <UnmanagedMethods.MINMAXINFO>(lParam);

                if (_minSize.Width > 0)
                {
                    mmi.ptMinTrackSize.X = (int)((_minSize.Width * Scaling) + BorderThickness.Left + BorderThickness.Right);
                }

                if (_minSize.Height > 0)
                {
                    mmi.ptMinTrackSize.Y = (int)((_minSize.Height * Scaling) + BorderThickness.Top + BorderThickness.Bottom);
                }

                if (!Double.IsInfinity(_maxSize.Width) && _maxSize.Width > 0)
                {
                    mmi.ptMaxTrackSize.X = (int)((_maxSize.Width * Scaling) + BorderThickness.Left + BorderThickness.Right);
                }

                if (!Double.IsInfinity(_maxSize.Height) && _maxSize.Height > 0)
                {
                    mmi.ptMaxTrackSize.Y = (int)((_maxSize.Height * Scaling) + BorderThickness.Top + BorderThickness.Bottom);
                }

                Marshal.StructureToPtr(mmi, lParam, true);
                return(IntPtr.Zero);

            case UnmanagedMethods.WindowsMessage.WM_DISPLAYCHANGE:
                (Screen as ScreenImpl)?.InvalidateScreensCache();
                return(IntPtr.Zero);
            }
#if USE_MANAGED_DRAG
            if (_managedDrag.PreprocessInputEvent(ref e))
            {
                return(UnmanagedMethods.DefWindowProc(hWnd, msg, wParam, lParam));
            }
#endif

            if (e != null && Input != null)
            {
                Input(e);

                if (e.Handled)
                {
                    return(IntPtr.Zero);
                }
            }

            return(UnmanagedMethods.DefWindowProc(hWnd, msg, wParam, lParam));
        }