public static void Run(object script) { var mainViewModel = new MainViewModel(script); var mainWindow = new Views.MainWindow(mainViewModel); mainWindow.Show(); }
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); } }
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(); } }; }
public NotifyIconWrapper(Views.MainWindow mainWindos) { InitializeComponent(); this.Display.Click += this.Display_Click; this._mainWindow = mainWindos; this._mainWindow.Activate(); }
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)); }
//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); }
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)); }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.Window = ((Views.MainWindow)(target)); return; } this._contentLoaded = true; }
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); }
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); }
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(); } }
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); }
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); }
public void ShowWindow() { if (_mainWindow == null) { _mainWindow = new Views.MainWindow { DataContext = _viewModel }; _mainWindow.Closing += MainWindow_Closing; _mainWindow.StateChanged += MainWindow_StateChanged; _mainWindow.Show(); } }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); MainViewModel ViewModel = new MainViewModel(); var window = new Views.MainWindow { DataContext = ViewModel }; window.ShowDialog(); }
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); }
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(); } } } }
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); }); }); }
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(); }
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(); }
public MainWindowService(MainWindow mainWindow) { _mainWindow = mainWindow; _mainWindow.Show(); }
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); } ; } } }
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)); }