Exemplo n.º 1
0
 private void Application_Startup(object sender, StartupEventArgs e)
 {
     if (!Directory.Exists(Constants.TRACKED_PROGRAMS_DIR) && !File.Exists(Constants.TRACKED_PROGRAMS_PATH))
     {
         FirstStartup firstStartupWindow = new FirstStartup();
         firstStartupWindow.Show();
         MessageBox.Show("Now, please, add programs in which you want to track your activity.", "First startup setup", MessageBoxButton.OK, MessageBoxImage.Information);
     }
     else
     {
         MainWindow mainWindow = new MainWindow();
         mainWindow.Show();
     }
 }
Exemplo n.º 2
0
        private void save_btn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (trackedProgramsList.Count != 0)
                {
                    if (!Directory.Exists(Constants.TRACKED_PROGRAMS_DIR))
                    {
                        Directory.CreateDirectory(Constants.TRACKED_PROGRAMS_DIR);
                    }

                    List<string> allLines = new List<string>();
                    foreach (var item in trackedProgramsList)
                    {
                        allLines.Add(item.GetNamePathInfo());
                    }

                    File.WriteAllLines(Constants.TRACKED_PROGRAMS_PATH, allLines);
                    
                    Application.Current.MainWindow.Close();
                    MainWindow mainWindow = new MainWindow();
                    mainWindow.Show();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("You must add at least one program to save the configuration.\nIf you dont want to save anything, just close the window.", "Error while saving", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            
        }