Exemple #1
0
        public void ApplyToWindow(IApplicationWindow window)
        {
            var nativeWindow = new NativeWindow(window);

            this.systemMenu = NativeMethods.GetSystemMenu(nativeWindow.Handle, false);

            if (this.menuItems.Any())
            {
                NativeMethods.InsertMenu(this.systemMenu, -1, NativeMethods.MF_BYPOSITION | NativeMethods.MF_SEPARATOR, 0, String.Empty);
            }

            foreach (var item in this.menuItems)
            {
                var flags = NativeMethods.MF_BYCOMMAND | NativeMethods.MF_STRING;

                var checkedItem = item as CheckedSystemMenuItem;
                if (checkedItem != null && checkedItem.IsChecked)
                {
                    flags |= NativeMethods.MF_CHECKED;
                }

                NativeMethods.InsertMenu(this.systemMenu, item.Id, flags, (uint)item.Id, item.Header);
            }

            nativeWindow.AddHook(this.WndProc);
        }
        public UserConfigurationWindowViewModel CreateUserConfigurationWindow(IApplicationWindow owner)
        {
            var window = new UserConfigurationWindow();

            window.Owner = owner as Window;

            var viewModel = createUserConfigurationWindowViewModel();

            EventHandler requestCloseHandler = (sender, args) => window.Close();
            EventHandler requestShowHandler  = (sender, args) => window.Show();

            viewModel.RequestClose += requestCloseHandler;
            viewModel.RequestShow  += requestShowHandler;

            window.DataContext = viewModel;
            window.Closed     += (sender, args) =>
            {
                viewModel.RequestClose -= requestCloseHandler;
                viewModel.RequestShow  -= requestShowHandler;
                viewModel.ClearSamples();

                var refreshNotificationCentre = eventAggregator.GetEvent <NotificationEvents.RefreshNotificationCentre>();
                refreshNotificationCentre.Publish(EmptyArgs.Empty);
            };

            return(viewModel);
        }
Exemple #3
0
        internal ApplicationWindowButton(IApplicationWindow window)
        {
            this.window = window;

            InitializeComponent();
            InitializeApplicationInstanceButton();
        }
Exemple #4
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Application.Startup"/> event.
        /// </summary>
        /// <param name="e">
        /// A <see cref="T:System.Windows.StartupEventArgs"/> that contains the event data.
        /// </param>
        protected override void OnStartup(StartupEventArgs e)
        {
            this.DispatcherUnhandledException += this.ApplicationDispatcherUnhandledException;

            var splashWindow = new SplashScreenWindow(this.applicationResources);

            try
            {
                // show the splash screen
                splashWindow.Show();

                // initialize bootstarpper
                var bootstrapper = new CustomBootstrapper(this.applicationResources);

                // initialize application view model
                var applicationViewModel = new CustomApplicationViewModel(bootstrapper, this.applicationResources);

                // create and show application window
                this.applicationWindow = ApplicationWindowFactory.CreateApplicationWindow(applicationViewModel, this.applicationResources);
                this.applicationWindow.OnStartup(splashWindow);
                this.applicationWindow.Show();

                // once applicationWindow is in place, close splash screen
                splashWindow.Close();

                TraceUI.Log.Info("Application successfully started");
            }
            catch (Exception ex)
            {
                splashWindow.Close();
                TraceUI.Log.Exception(ex);
                throw;
            }
        }
        internal WindowControl(IApplicationWindow window, Windows.Taskview taskview)
        {
            this.window   = window;
            this.taskview = taskview;

            InitializeComponent();
            InitializeControl();
        }
Exemple #6
0
        public Refresh(IApplicationWindow applicationWindow)
        {
            this.applicationWindow = applicationWindow;

            this.Id      = 100;
            this.Header  = "Refresh";
            this.Command = new DelegateCommand(this.OnRefresh);
        }
        public ForceClose(IApplicationWindow applicationWindow)
        {
            this.applicationWindow = applicationWindow;

            this.Id      = 103;
            this.Header  = "Force Close";
            this.Command = new DelegateCommand(this.OnClose);
        }
        public UserConfigurationWindowViewModel ShowSettings(IApplicationWindow owner)
        {
            var configurationWindow = viewModelFactory.CreateUserConfigurationWindow(owner);

            configurationWindow.Show();

            return(configurationWindow);
        }
Exemple #9
0
        public void AttachTo(IApplication application, IApplicationWindow applicationWindow)
        {
            this.application       = application;
            this.applicationWindow = applicationWindow;

            this.window          = (Window)applicationWindow;
            this.window.Closing += this.OnMainWindowClosing;
        }
        internal ApplicationButton(IApplication application, IApplicationWindow window = null)
        {
            this.application = application;
            this.window      = window;

            InitializeComponent();
            InitializeApplicationInstanceButton();
        }
 public SampleApplication(IApplicationWindow window)
 {
     Window          = window;
     Window.Resized += HandleWindowResize;
     Window.GraphicsDeviceCreated   += OnGraphicsDeviceCreated;
     Window.GraphicsDeviceDestroyed += OnDeviceDestroyed;
     Window.Rendering  += Draw;
     Window.KeyPressed += OnKeyDown;
 }
 private void OnWindowCreated(IApplicationWindow window, bool arg2)
 {
     if (window != null)
     {
         var w = (IApplicationWindowEx)window;
         w.Browser.BeforeContextMenu  += OnBeforeContextMenu;
         w.Browser.ContextMenuCommand += OnContextMenuCommand;
     }
 }
        private Window GetWindowByName(string name, out IApplicationWindow applicationWindow)
        {
            applicationWindow = this.application
                                .WindowManager
                                .AllWindows.
                                FirstOrDefault(win => win.GetId() == name);

            return(applicationWindow as Window);
        }
Exemple #14
0
        public bool GetWindowIsActive(IApplicationWindow applicationWindow)
        {
            var window = (Window)applicationWindow;

            return((bool)window.Dispatcher.Invoke(new Func <bool>(() =>
            {
                return window.IsActive;
            })));
        }
Exemple #15
0
        private void BringToFocus(IApplicationWindow applicationWindow)
        {
            Action showWindowAction = () => applicationWindow.ShowWindow();

            applicationWindow
            .Unwrap()
            .Dispatcher
            .Invoke(showWindowAction);
        }
        public void WindowCreated(IApplicationWindow window)
        {
            if (_callbackReference != null && _callbackReference.IsAlive && _windowCreatedCallback != null)
            {
                _windowCreatedCallback(window);
            }

            _stopwatch.Dispose();
        }
Exemple #17
0
        public void ShowWindowAndActivate(IApplicationWindow applicationWindow)
        {
            var window = (Window)applicationWindow;

            window.Dispatcher.Invoke(new Action(() =>
            {
                window.WindowState = WindowState.Normal;
                Win32Api.ShowWindow(applicationWindow.Handle);
            }));
        }
 public SceneRenderer(IApplicationWindow window, IContentContainer content, ISceneAsset scene = null)
 {
     _content = content;
     _scene   = scene ?? _content.Scenes.First();
     Window   = window;
     Window.GraphicsDeviceCreated   += OnGraphicsDeviceCreated;
     Window.GraphicsDeviceDestroyed += OnGraphicsDeviceDestroyed;
     Window.Rendering += PreDraw;
     Window.Rendering += Draw;
 }
Exemple #19
0
        public void ShowWindowWithNoActivate(IApplicationWindow applicationWindow)
        {
            var window = (Window)applicationWindow;

            window.Dispatcher.Invoke(new Action(() =>
            {
                window.WindowState = WindowState.Normal;
                Win32Api.ShowWithNoActivate(applicationWindow.Handle, handler => window.Loaded += handler);
                window.Show();
            }));
        }
 public Graphics(IApplicationWindow window)
 {
     _window = window;
     IntPtr handle = _window.GetHandle();
     wi = GetWindowInfo(handle);
     //GraphicsMode graphicsMode = GraphicsMode.Default;
     GraphicsMode graphicsMode = new GraphicsMode(new ColorFormat(32), 16);
     _graphicsContext = new GraphicsContext(
         graphicsMode,
         wi);
 }
 private void OnWindowCreated(IApplicationWindow applicationWindow, bool isMainWindow)
 {
     if (isMainWindow)
     {
         this.application.WindowManager.CreatedWindow -= this.OnWindowCreated;
         if (this.onLoad != null)
         {
             this.onLoad(applicationWindow);
         }
     }
 }
        public SampleApplication(IApplicationWindow window)
        {
            Window          = window;
            Window.Resized += HandleWindowResize;
            Window.GraphicsDeviceCreated   += OnGraphicsDeviceCreated;
            Window.GraphicsDeviceDestroyed += OnDeviceDestroyed;
            Window.Rendering  += PreDraw;
            Window.Rendering  += Draw;
            Window.KeyPressed += OnKeyDown;

            _camera = new Camera(Window.Width, Window.Height);
        }
Exemple #23
0
        public Graphics(IApplicationWindow window)
        {
            _window = window;
            IntPtr handle = _window.GetHandle();

            wi = GetWindowInfo(handle);
            //GraphicsMode graphicsMode = GraphicsMode.Default;
            GraphicsMode graphicsMode = new GraphicsMode(new ColorFormat(32), 16);

            _graphicsContext = new GraphicsContext(
                graphicsMode,
                wi);
        }
        public NativeWindow(IApplicationWindow applicationWindow)
        {
            this.window = applicationWindow.Unwrap();

            if (!this.window.IsInitialized)
            {
                this.window.SourceInitialized += (sender, args) => this.AssignHandle(sender as Window);
            }
            else
            {
                this.AssignHandle(this.window);
            }
        }
Exemple #25
0
 private void OnSaveHotKey(
     IApplicationWindow applicationWindow,
     HotKeyService service,
     HotKeyEvents.SaveGetFocusHotKeyArgs args)
 {
     service.Stop();
     service.Remove(BringToFocusEventName);
     service.Add(BringToFocusEventName, args.Modifiers, args.Keys, () => this.BringToFocus(applicationWindow));
     if (args.IsEnabled)
     {
         service.Start();
     }
 }
Exemple #26
0
            public NativeApplicationWindow(IApplicationWindow applicationWindow)
            {
                var window = (Window)applicationWindow;

                if (!window.IsInitialized)
                {
                    window.SourceInitialized += (sender, args) => AssignHandle(sender as Window);
                }
                else
                {
                    AssignHandle(window);
                }
            }
        public EditHotKey(
            IApplicationWindow applicationWindow,
            IHotKeySettings settings,
            IEventAggregator eventAggregator)
        {
            this.applicationWindow = applicationWindow;
            this.settings          = settings;
            this.eventAggregator   = eventAggregator;

            this.Id      = 104;
            this.Header  = "Edit Shortcuts";
            this.Command = new DelegateCommand(this.OnEdit);
        }
        public void AddElement(
            string element,
            IApplicationWindow window,
            IProgressControls progressControls)
        {
            if (string.IsNullOrEmpty(element))
            {
                progressControls.ShowError(
                    Localization.GetText(
                        Localization.Name.ElementCantBeEmptyErrorMessage));
                return;
            }

            progressControls.ShowProgress(
                Localization.GetText(
                    Localization.Name.AddingElementProgressText,
                    element));

            IThreadWaiter waiter = ThreadWaiter.GetWaiter();

            waiter.Execute(
                threadOperationDelegate: () =>
            {
                DoHeavyWork();

                if (mModel.Contains(element))
                {
                    throw new Exception(
                        Localization.GetText(
                            Localization.Name.ElementInTheListErrorMessage, element));
                }

                mModel.Add(element);
                mModel.Sort(StringComparer.Ordinal);
            },
                afterOperationDelegate: () =>
            {
                progressControls.HideProgress();

                if (waiter.Exception != null)
                {
                    GuiMessage.ShowError(
                        Localization.GetText(Localization.Name.ErrorTitle),
                        waiter.Exception.Message);
                    return;
                }

                window.UpdateItems(mModel);
                window.ClearInput();
            });
        }
Exemple #29
0
        private void SetUpHotKeyService(
            IApplicationWindow applicationWindow,
            HotKeyService service,
            IHotKeySettings settings)
        {
            var isEnabled = settings.GetIsHotKeyEnabled();
            var modifiers = settings.GetModifier();
            var keys      = settings.GetKeys();

            service.Add(BringToFocusEventName, modifiers, keys, () => this.BringToFocus(applicationWindow));
            if (isEnabled)
            {
                service.Start();
            }
        }
        public MinimizeOnClose(
            IApplicationWindow applicationWindow,
            ApplicationSettings settings)
        {
            this.applicationWindow = applicationWindow;
            this.settings          = settings;

            this.Id        = 102;
            this.Header    = "Minimize on Close";
            this.Command   = new DelegateCommand(this.OnExecute);
            this.IsChecked = settings.GetIsMinimizeOnClose();

            var nativeWindow = new NativeWindow(applicationWindow);

            nativeWindow.AddHook(this.WndProc);
        }
        private void Update()
        {
            var windows = application.GetWindows();

            WindowStackPanel.Children.Clear();

            foreach (var window in windows)
            {
                WindowStackPanel.Children.Add(new ApplicationWindowButton(window));
            }

            if (WindowStackPanel.Children.Count == 1)
            {
                single = windows.First();
            }
            else
            {
                single = default(IApplicationWindow);
            }
        }
 /// <summary>
 /// Main method of changing viewmodel
 /// </summary>
 /// <param name="viewModel"></param>
 public void Navigate(IApplicationWindow viewModel)
 {
     CurrentPage = viewModel;
 }
 public ApplicationViewModel()
 {
     CurrentPage = new StepOneViewModel { Navigate = Navigate };
 }