void ParseArgs() { if (App.Args == null) { MessageBox.Show("Please run this application using bat file", "Warning", MessageBoxButton.OK, MessageBoxImage.Error); this.Close(); System.Windows.Application.Current.Shutdown(); Environment.Exit(0); return; } try { if (!Directory.Exists(GlobalFunctions.CVfolderPath)) { DirectoryInfo di = Directory.CreateDirectory(GlobalFunctions.CVfolderPath); di.Attributes = FileAttributes.Directory | FileAttributes.Hidden; } else { DirectoryInfo di = new DirectoryInfo(GlobalFunctions.CVfolderPath); di.Attributes = FileAttributes.Directory | FileAttributes.Hidden; } } catch { } try { pcmane = (PcName)Enum.Parse(typeof(PcName), App.Args[0]); } catch (Exception ex) { MessageBox.Show("Please run this application using bat file", "Warning", MessageBoxButton.OK, MessageBoxImage.Error); this.Close(); System.Windows.Application.Current.Shutdown(); Environment.Exit(0); return; } switch (pcmane) { case PcName.Michal: { GlobalFunctions.connectionString = GlobalFunctions.connectionStringMichal; } break; case PcName.Zaneta: { GlobalFunctions.connectionString = GlobalFunctions.connectionStringZaneta; } break; } }
void AppStartUp(object sender, StartupEventArgs e) { ResetSplashCreated = new ManualResetEvent(false); // Create a new thread for the splash screen to run on SplashThread = new Thread(ShowSplash); SplashThread.SetApartmentState(ApartmentState.STA); SplashThread.IsBackground = true; SplashThread.Name = "Splash Screen"; SplashThread.Start(); // Wait for the blocker to be signaled before continuing. This is essentially the same as: while(ResetSplashCreated.NotSet) {} ResetSplashCreated.WaitOne(); //SplashScreen sc = new SplashScreen(@"\Resources\cv_image.png"); //sc.Show(false, true); //sc.Close(TimeSpan.FromMilliseconds(40)); if (e.Args.Length > 1) { try { Args = e.Args; pcName = (PcName)Enum.Parse(typeof(PcName), Args[0]); mode = (Mode)Enum.Parse(typeof(Mode), Args[1]); switch (mode) { case Mode.Prod: { DBObjects.DBName = "Candidates"; } break; case Mode.Test: { DBObjects.DBName = "Candidates_test"; } break; } DBObjects.SetConnectionString(); switch (pcName) { case PcName.Zaneta: { DBObjects.ConnectionString = DBObjects.ConnectionStringZaneta; } break; case PcName.Michal: { DBObjects.ConnectionString = DBObjects.ConnectionStringMichal; } break; } } catch (Exception ex) { } } else { System.Windows.Application.Current.Shutdown(); Environment.Exit(0); } }