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
 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();
     }
 }
Пример #4
0
 public void ShowWindow()
 {
     if (_mainWindow == null)
     {
         _mainWindow = new Views.MainWindow {
             DataContext = _viewModel
         };
         _mainWindow.Closing      += MainWindow_Closing;
         _mainWindow.StateChanged += MainWindow_StateChanged;
         _mainWindow.Show();
     }
 }
Пример #5
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();
                    }
                }
            }
        }
Пример #6
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();
        }
Пример #7
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);
        }
Пример #8
0
 public void Show()
 {
     mainWindow.Show();
 }
 private void ShowMainWindow()
 {
     Views.MainWindow menu = new Views.MainWindow();
     menu.Show();
     CloseWindow();
 }
Пример #10
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);
                    }
                    ;
                }
            }
        }
Пример #11
0
 public MainWindowService(MainWindow mainWindow)
 {
     _mainWindow = mainWindow;
     _mainWindow.Show();
 }