예제 #1
0
        // Главное окно передаётся во ViewModel
        // Свойство Basic делается public
        // Благодаря этому имеем доступ ко всем нужным свойствам отовсюду

        public MainWindow()
        {
            Basic = new BasicProps();

            // Окно входа
            StartAppWindow win = new StartAppWindow();
            bool? flagExit = win.ShowDialog();

            if (flagExit.Value == false) {
                Application.Current.Shutdown();
            } else {
                // Если пользователь вошёл успешно
                InitializeComponent();

                SplashScreen ss = new SplashScreen(@"Images\splashScreen.png");
                ss.Show(true, true);
                ss.Close(new TimeSpan(0, 0, 2));

                Basic.LoginData = new LoginData {
                    HostName = win.TextBoxHostName.Text,
                    Port = win.TextBoxPort.Text,
                    UserName = win.TextBoxUserName.Text
                };

                Basic.DataGridMain = (DataGrid)FindName("DataGridMain");

                DataContext = new ApplicationViewModel(this);
            } // if-else
        } // MainWindow
예제 #2
0
        private const int SPLASH_FADE_TIME    = 500;  // Miliseconds

        /// <summary>
        /// Override startup client
        /// </summary>
        protected override void OnStartup(StartupEventArgs e)
        {
            SplashScreen splash = new SplashScreen("splash.jpg");

            splash.Show(false, true);

            System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
            timer.Start();

            base.OnStartup(e);
            MainWindow main = new MainWindow();

            timer.Stop();
            int remainingTimeToShowSplash = MINIMUM_SPLASH_TIME - (int)timer.ElapsedMilliseconds;

            if (remainingTimeToShowSplash > 0)
            {
                System.Threading.Thread.Sleep(remainingTimeToShowSplash);
            }

            splash.Close(TimeSpan.FromMilliseconds(SPLASH_FADE_TIME));
            main.Show();
        }
예제 #3
0
 /// <summary>
 /// Shows the splash screen for a specific time and closes it afterwards
 /// DON'T CALL THIS EXPLICITLY
 /// </summary>
 private void SplashThread()
 {
     // Create a new SplashScreen object and shows it up
     SplashScreen splashScreen = new SplashScreen();
     splashScreen.Show();
     // Waits for the specific time
     Thread.Sleep(c_showSplashTime); // Default: 5000
     // Closes the splash screen
     splashScreen.Close();
 }