Пример #1
0
 private void InvokeUnhandledException(object sender, Exception exception)
 {
     if (exception != null)
     {
         UnhandledExceptionOccurred?.Invoke(sender, new UnhandledExceptionOccurredEventArgs(exception));
     }
 }
Пример #2
0
 public ApplicationLifecycleHelper()
 {
     Enabled = true;
     AppDomain.CurrentDomain.UnhandledException += (sender, eventArgs) =>
     {
         UnhandledExceptionOccurred?.Invoke(sender, new UnhandledExceptionOccurredEventArgs((Exception)eventArgs.ExceptionObject));
     };
 }
Пример #3
0
        private DockManager(Vector2 windowSize)
        {
            var window = new Window(new WindowOptions {
                ClientSize           = windowSize,
                FixedSize            = false,
                Title                = "Tangerine",
                MacWindowTabbingMode = MacWindowTabbingMode.Disallowed,
#if WIN
                Icon = new System.Drawing.Icon(new EmbeddedResource(AppIconPath, "Tangerine").GetResourceStream()),
#endif // WIN
            });

            window.UnhandledExceptionOnUpdate += e => UnhandledExceptionOccurred?.Invoke(e);
            SetDropHandler(window);
            MainWindowWidget = new ThemedInvalidableWindowWidget(window)
            {
                Id                = "MainWindow",
                Layout            = new VBoxLayout(),
                Size              = windowSize,
                RedrawMarkVisible = true
            };
            MainWindowWidget.WidgetContext.GestureManager = new HelpModeGestureManager(MainWindowWidget.WidgetContext);
            ToolbarArea = new Frame {
                Id           = "Toolbar",
                ClipChildren = ClipMethod.ScissorTest,
                Layout       = new VBoxLayout {
                    Spacing = 4
                },
                LayoutCell = new LayoutCell {
                    StretchY = 0
                },
            };
            DocumentArea = new Frame {
                ClipChildren = ClipMethod.ScissorTest,
            };
            DocumentAreaDropFilesGesture = new DropFilesGesture();
            DocumentArea.Gestures.Add(DocumentAreaDropFilesGesture);
            DocumentArea.CompoundPresenter.Add(new WidgetFlatFillPresenter(Color4.Gray));
            var windowPlacement = new WindowPlacement {
                Size         = windowSize,
                Position     = window.ClientPosition,
                WindowWidget = MainWindowWidget
            };

            DockHierarchy.Instance.Initialize(windowPlacement);
            window.Moved   += () => Model.WindowPlacements.First().Position = window.ClientPosition;
            window.Resized += (deviceRotated) => Model.WindowPlacements.First().Size = window.ClientSize;
            MainWindowWidget.AddChangeWatcher(
                () => MainWindowWidget.Window.State,
                value => Model.WindowPlacements[0].State = value);
            MainWindowWidget.Components.Add(new RequestedDockingComponent());
            MainWindowWidget.CompoundPostPresenter.Add(new DockingPresenter());
        }
        public ApplicationLifecycleHelper()
        {
            // Subscribe to Resuming and Suspending events.
            CoreApplication.Suspending += InvokeSuspended;

            // If the "LeavingBackground" event is present, use that for Resuming. Else, use CoreApplication.Resuming.
            if (ApiInformation.IsEventPresent(typeof(CoreApplication).FullName, "LeavingBackground"))
            {
                CoreApplication.LeavingBackground += InvokeResuming;

                // If the application has anything visible, then it has already started,
                // so invoke the resuming event immediately.
                HasStartedAndNeedsResume().ContinueWith(completedTask =>
                {
                    if (completedTask.Result)
                    {
                        InvokeResuming(null, EventArgs.Empty);
                    }
                });
            }
            else
            {
                // In versions of Windows 10 where the LeavingBackground event is unavailable, we condider this point to be
                // the start so invoke resuming (and subscribe to future resume events). If InvokeResuming were not called here,
                // the resuming event wouldn't be invoked until the *next* time the application is resumed, which is a problem
                // if the application is not currently suspended. The side effect is that regardless of whether UI is available
                // ever in the process, InvokeResuming will be called at least once (in the case where LeavingBackground isn't
                // available).
                CoreApplication.Resuming += InvokeResuming;
                InvokeResuming(null, EventArgs.Empty);
            }

            // Subscribe to unhandled errors events.
            CoreApplication.UnhandledErrorDetected += (sender, eventArgs) =>
            {
                try
                {
                    // Intentionally propagate exception to get the exception object that crashed the app.
                    eventArgs.UnhandledError.Propagate();
                }
                catch (Exception exception)
                {
                    UnhandledExceptionOccurred?.Invoke(sender, new UnhandledExceptionOccurredEventArgs(exception));

                    // Since UnhandledError.Propagate marks the error as Handled, rethrow in order to only Log and not Handle.
                    throw;
                }
            };
        }
Пример #5
0
        private void CreateFloatingWindow(WindowPlacement placement)
        {
            var window = new Window(new WindowOptions {
                FixedSize            = false,
                MacWindowTabbingMode = MacWindowTabbingMode.Disallowed,
#if WIN
                Icon = new System.Drawing.Icon(new EmbeddedResource(AppIconPath, "Tangerine").GetResourceStream()),
#endif
                Type = WindowType.Tool,
            });

            window.UnhandledExceptionOnUpdate += e => UnhandledExceptionOccurred?.Invoke(e);
            SetDropHandler(window);
            window.Closing += reason => {
                if (reason == CloseReason.MainWindowClosing)
                {
                    return(true);
                }

                var windowPlacement = Model.WindowPlacements.FirstOrDefault(p => p.WindowWidget?.Window == window);
                if (windowPlacement != null)
                {
                    windowPlacement.WindowWidget = null;
                    DockHierarchy.HideWindowPanels(windowPlacement);
                }
                return(true);
            };
            window.ClientSize = placement.Size;
            var windowWidget = new ThemedInvalidableWindowWidget(window)
            {
                Layout = new StackLayout(),
            };

            windowWidget.CompoundPostPresenter.Add(new WidgetBoundsPresenter(ColorTheme.Current.Docking.PanelTitleSeparator, 1));
            windowWidget.WidgetContext.GestureManager = new HelpModeGestureManager(windowWidget.WidgetContext);
            windowWidget.Components.Add(new RequestedDockingComponent());
            windowWidget.CompoundPostPresenter.Add(new DockingPresenter());
            windowWidget.AddChangeWatcher(() => windowWidget.Window.State, value => placement.State = value);
            placement.WindowWidget = windowWidget;
            window.ClientPosition  = placement.Position;
            window.Moved          += () => placement.Position = window.ClientPosition;
            window.Resized        += (deviceRotated) => placement.Size = window.ClientSize;
        }
Пример #6
0
 public ApplicationLifecycleHelper()
 {
     Enabled = true;
     try
     {
         CoreApplication.MainView.CoreWindow.Activated += InvokeStarted;
         if (CoreApplication.Views.Count > 0)
         {
             _started = true;
         }
     }
     catch (System.Runtime.InteropServices.COMException)
     {
         throw new MobileCenterException("Failed to initialize ApplicationLifecycleHelper; are you accessing Mobile Center from your App() constructor? Initialization should be done in OnLaunched()/OnStart().");
     }
     Application.Current.UnhandledException += (sender, eventArgs) =>
     {
         UnhandledExceptionOccurred?.Invoke(sender, new UnhandledExceptionOccurredEventArgs(eventArgs.Exception));
     };
 }
 // Internal for testing
 public void InvokeUnhandledException()
 {
     UnhandledExceptionOccurred?.Invoke(null, new UnhandledExceptionOccurredEventArgs(new Exception()));
 }
 internal void InvokeUnhandledExceptionOccurred(object sender, Exception exception)
 {
     UnhandledExceptionOccurred?.Invoke(sender, new UnhandledExceptionOccurredEventArgs(exception));
 }