public static void Run(object script)
        {
            var mainViewModel = new MainViewModel(script);
            var mainWindow    = new Views.MainWindow(mainViewModel);

            mainWindow.Show();
        }
예제 #2
0
        private void Login(object obj)
        {
            if (string.IsNullOrEmpty(Username))
            {
                Messenger.ShowMessage("Моля, въведете потребителско име!", MessageType.Warning);
                return;
            }
            if (Password == null || Password.Length == 0)
            {
                Messenger.ShowMessage("Моля, въведете парола!", MessageType.Warning);
                return;
            }

            var user = accountService.Login(username, password);

            if (user != null)
            {
                var loginWindow = Application.Current.Windows.OfType <Window>().SingleOrDefault();
                if (loginWindow != null)
                {
                    var mainWindow = new Views.MainWindow(user)
                    {
                        DataContext = new MainWindowViewModel(user)
                    };
                    mainWindow.Show();
                    loginWindow.Close();
                }
            }
            else
            {
                Messenger.ShowMessage("Невалидни данни!", MessageType.Error);
            }
        }
예제 #3
0
        public MainWindow()
        {
            mainWindow = new Views.MainWindow();

            mainWindow.btnRegister.Click += (sender, e) =>
            {
                Hide();
                register = new Register(this);
                register.Show();
            };

            mainWindow.btnSignIn.Click += (sender, e) =>
            {
                Hide();
                signin = new SignIn(this);
                signin.Show();
            };

            mainWindow.btnExit.Click += (sender, e) =>
            {
                if (MessageBox.Show("Bạn muốn thoát ứng dụng ?", "Confirm", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    Application.Current.Shutdown();
                }
            };
        }
예제 #4
0
 public NotifyIconWrapper(Views.MainWindow mainWindos)
 {
     InitializeComponent();
     this.Display.Click += this.Display_Click;
     this._mainWindow = mainWindos;
     this._mainWindow.Activate();
 }
예제 #5
0
        protected override void OnExecuted(EventArgs e)
        {
            base.OnExecuted(e);

            ComponentTemplateParentVM designVM = new ComponentTemplateParentVM(_gameVM);

            Views.MainWindow mw = (Views.MainWindow)Application.Instance.MainForm.Content;
            mw.AddOrSelectTabPanel("Component Template", new Views.ComponentTemplateDesigner.ComponentTemplateDesignerParentView(designVM));
        }
예제 #6
0
        //https://stackoverflow.com/questions/624367/how-to-handle-wndproc-messages-in-wpf
        public static void Initialize(Views.MainWindow main)
        {
            if (!(PresentationSource.FromVisual(main) is HwndSource source))
            {
                throw new ArgumentNullException(nameof(main), @"Can't found a handle to the main window. Application stopping.");
            }

            source.AddHook(WndProc);
        }
예제 #7
0
        protected override void OnExecuted(EventArgs e)
        {
            base.OnExecuted(e);

            ShipDesignVM designVM = ShipDesignVM.Create(_gameVM);

            Views.MainWindow mw = (Views.MainWindow)Application.Instance.MainForm.Content;
            mw.AddOrSelectTabPanel("Ship Design", new Views.ShipDesignView(designVM));
        }
예제 #8
0
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
 {
     switch (connectionId)
     {
     case 1:
         this.Window = ((Views.MainWindow)(target));
         return;
     }
     this._contentLoaded = true;
 }
예제 #9
0
        protected override void OnExecuted(EventArgs e)
        {
            base.OnExecuted(e);

            LogViewerVM vm = new LogViewerVM(_gameVM);

            Views.MainWindow mw        = (Views.MainWindow)Application.Instance.MainForm.Content;
            Views.LogViewer  logPannel = new Views.LogViewer();
            logPannel.DataContext = vm;
            mw.AddOrSelectTabPanel("Event Log", logPannel);
        }
예제 #10
0
        protected override void OnExecuted(EventArgs e)
        {
            base.OnExecuted(e);

            var vm = _gameVM;

            Views.MainWindow mw = (Views.MainWindow)Application.Instance.MainForm.Content;
            Views.NetMessages.NetMessagesView messageView = new Views.NetMessages.NetMessagesView();
            messageView.DataContext = vm;
            mw.AddOrSelectTabPanel("Net Messages", messageView);
        }
예제 #11
0
 private void CheckUser(object obj)
 {
     obj    = new string[] { Username, Password };
     IsAuth = AuthModelP.CheckUser(obj);
     if (IsAuth == true)
     {
         Views.MainWindow mainView = new Views.MainWindow();
         mainView.Show();
         ((App)Application.Current).AuthV.Close();
     }
 }
예제 #12
0
        protected override void OnExecuted(EventArgs e)
        {
            base.OnExecuted(e);

            EntityVM entityVM = new EntityVM(_gameVM);

            Views.MainWindow mw = (Views.MainWindow)Application.Instance.MainForm.Content;
            var entityView      = new Views.EntityGenericView();

            entityView.DataContext = entityVM;
            mw.AddOrSelectTabPanel("Entity View", entityView);
        }
예제 #13
0
        protected override void OnExecuted(EventArgs e)
        {
            base.OnExecuted(e);

            SystemInfoVM sysinfoVM = new SystemInfoVM(_gameVM);

            Views.MainWindow mw = (Views.MainWindow)Application.Instance.MainForm.Content;
            var view            = new Views.SystemInfoView();

            view.DataContext = sysinfoVM;
            mw.AddOrSelectTabPanel("System Info", view);
        }
예제 #14
0
 public void ShowWindow()
 {
     if (_mainWindow == null)
     {
         _mainWindow = new Views.MainWindow {
             DataContext = _viewModel
         };
         _mainWindow.Closing      += MainWindow_Closing;
         _mainWindow.StateChanged += MainWindow_StateChanged;
         _mainWindow.Show();
     }
 }
예제 #15
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            MainViewModel ViewModel = new MainViewModel();
            var window = new Views.MainWindow
            {
                DataContext = ViewModel
            };

            window.ShowDialog();
        }
예제 #16
0
        private PlayerNotifier GetPlayerNotifier(Views.MainWindow mainWindow)
        {
            PlayerNotifier playerNotifier = null;
            //create the notifyicon (it's a resource declared in NotifyIconResources.xaml
            var notifyIcon = (TaskbarIcon)FindResource("NotifyIcon");

            if (notifyIcon == null)
            {
                return(null);
            }
            notifyIcon.Icon = Icons.Resources.Logo;
            var toast = new Toast(notifyIcon);
            var taskbarIconAdapter = new ToastDisplayer(toast);

            playerNotifier         = new PlayerNotifier(taskbarIconAdapter);
            notifyIcon.DataContext = mainWindow.ViewModel;
            return(playerNotifier);
        }
예제 #17
0
        private void Enter()
        {
            var start = new Views.MainWindow();

            start.Show();

            var windows = Application.Current?.Windows;

            if (!(windows is null))
            {
                foreach (Window currentWindow in Application.Current?.Windows)
                {
                    if (currentWindow.Title == "Login")
                    {
                        currentWindow.Close();
                    }
                }
            }
        }
예제 #18
0
        private void InitializeMainWindow()
        {
            _mainVm = new MainViewModel(ServiceLocator.Current.GetInstance <IEmployeesModelService>(),
                                        ServiceLocator.Current.GetInstance <IDepartmentModelService>());
            _mainwindow             = (Views.MainWindow)Shell;
            _mainwindow.DataContext = _mainVm;

            Application.Current.MainWindow = _mainwindow;
            Application.Current.MainWindow.Show();
            _mainwindow.Open();

            Task.Run(() =>
            {
                _initializedEvent.WaitOne();
                UiInvoker.Invoke(() =>
                {
                    ProcessCommandLineArgs(_cmdArgs);
                });
            });
        }
예제 #19
0
        private async void Application_Startup(object sender, StartupEventArgs e)
        {
            var startTime = DateTime.UtcNow;

            ShowSplashScreen();
            SetCurrentActivity("Initializing...");

            if (Settings.Default.IsFirstRun)
            {
                DoFirstRunActivities();
            }

            if (Settings.Default.CheckForUpdates)
            {
                CheckForUpdates();
            }

            await InitializeAsync();

            var endTime = DateTime.UtcNow;

            if (endTime - startTime < TimeSpan.FromSeconds(4))
            {
                // Does it seem cruel to force startup to take four seconds?
                // Well, otherwise, in a best-case startup scenario, the splash screen is visible
                //   for too short a time to fully perceive and the user may think they missed something
                //   important when it flashes by
                SetCurrentActivity("Initializing...");
                Thread.Sleep(endTime - startTime);
            }

            var mainWindow = new Views.MainWindow();

            this.MainWindow = mainWindow;

            HideSplashScreen();

            mainWindow.Show();
        }
예제 #20
0
        protected override void OnStartup(StartupEventArgs e)
        {
            SimpleIoc.Default.Register<IMapper, Mapper>();
            SimpleIoc.Default.Register<IWindowService, WindowService>();
            SimpleIoc.Default.Register<IFileService, FileService>();
            SimpleIoc.Default.Register<ITranslationService, TranslationService>();
            SimpleIoc.Default.Register<IComponentFactory, ComponentFactory>();
            SimpleIoc.Default.Register<EditMenuViewModel>();

            SimpleIoc.Default.Register(c =>
            {
                return new MainWindowViewModel(c.GetInstance<ToolbarViewModel>(), c.GetInstance<MainContentViewModel>());
            })
            .Register(c =>
            {
                return new ViewModelLocator(c.GetInstance<IMapper>());
            })
            .Register(c =>
            {
                return new MainContentViewModel(c.GetInstance<IWindowService>(), c.GetInstance<ITranslationService>());
            })
            .Register(c =>
            {
                return new ToolbarViewModel(c.GetInstance<FileMenuViewModel>(), c.GetInstance<EditMenuViewModel>());
            })
            .Register(c =>
            {
                return new FileMenuViewModel(c.GetInstance<IFileService>());
            });

            Resources.Add("ViewModelLocator", SimpleIoc.Default.GetInstance<ViewModelLocator>());

            MainWindow = new Views.MainWindow();
            MainWindow.Show();

            base.OnStartup(e);
        }
 private void ShowMainWindow()
 {
     Views.MainWindow menu = new Views.MainWindow();
     menu.Show();
     CloseWindow();
 }
예제 #22
0
 public MainWindowService(MainWindow mainWindow)
 {
     _mainWindow = mainWindow;
     _mainWindow.Show();
 }
예제 #23
0
        public void ActionAfterLogChecking(bool u, bool p)
        {
            //проерка логина и пароля для последующего открытия главного окна
            //сбрасываем красную границу
            foreach (Window window in App.Current.Windows)
            {
                if (window is Views.Authorization)
                {
                    (window as Views.Authorization).username.BorderThickness = new Thickness(0);
                    (window as Views.Authorization).password.BorderThickness = new Thickness(0);
                }
                ;
            }

            //если данные введены верно
            if (u && p)
            {
                Views.MainWindow main = new Views.MainWindow();
                main.Show();
                foreach (Window window in App.Current.Windows)
                {
                    // если окно - объект Authorization
                    if (window is Views.Authorization)
                    {
                        window.Close();
                    }
                }
            }
            //если неверный логин
            if (!u && p)
            {
                foreach (Window window in App.Current.Windows)
                {
                    if (window is Views.Authorization)
                    {
                        (window as Views.Authorization).username.BorderBrush     = Brushes.Red;
                        (window as Views.Authorization).username.BorderThickness = new Thickness(2);
                    }
                    ;
                }
            }
            //если неверный пароль
            if (u && !p)
            {
                foreach (Window window in App.Current.Windows)
                {
                    if (window is Views.Authorization)
                    {
                        (window as Views.Authorization).password.BorderBrush     = Brushes.Red;
                        (window as Views.Authorization).password.BorderThickness = new Thickness(2);
                    }
                    ;
                }
            }
            //если неверный и логин и пароль
            if (!u && !p)
            {
                foreach (Window window in App.Current.Windows)
                {
                    if (window is Views.Authorization)
                    {
                        (window as Views.Authorization).username.BorderBrush     = Brushes.Red;
                        (window as Views.Authorization).username.BorderThickness = new Thickness(2);
                        (window as Views.Authorization).password.BorderBrush     = Brushes.Red;
                        (window as Views.Authorization).password.BorderThickness = new Thickness(2);
                    }
                    ;
                }
            }
        }
예제 #24
0
 protected override void OnExecuted(EventArgs e)
 {
     base.OnExecuted(e);
     Views.MainWindow mw = (Views.MainWindow)Application.Instance.MainForm.Content;
     mw.AddOrSelectTabPanel("Colony View", new Views.ColonyScreenView(_gameVM));
 }