//Load and close private void Window_Loaded(object sender, RoutedEventArgs e) { //Set up non existing folders if (!Directory.Exists(configPath)) Directory.CreateDirectory(configPath); if (!Directory.Exists(webFilesPath)) Directory.CreateDirectory(webFilesPath); if (!Directory.Exists(configPath + "\\connections")) Directory.CreateDirectory(configPath + "\\connections"); if (!Directory.Exists(configPath + "\\settings")) Directory.CreateDirectory(configPath + "\\settings"); //Set default theme acorp.WindowSSL ssl = new acorp.WindowSSL(); ssl.LoadWindowData(this, configPath + "\\settings\\main-win.txt"); dockingManager.Theme = new AvalonDock.Themes.MetroTheme(); //Load menu try { string[] xshdFiles = Directory.GetFiles(appStartPath + "\\hlight\\"); for (int i = 0; i < xshdFiles.Length - 1; i++) { MenuItem item = new MenuItem(); string fileType = xshdFiles[i].Split('\\')[(xshdFiles[i].Split( '\\').Length - 1)].Remove(xshdFiles[i].Split( '\\')[(xshdFiles[i].Split('\\').Length - 1)].Length - 5, 5); item.Header = fileType; item.Click += new RoutedEventHandler( delegate(object s, RoutedEventArgs earg) { AddDocument(fileType); }); newItem.Items.Add(item); } //Create directory if it doesn't exist if (!Directory.Exists(configPath + "\\connections")) Directory.CreateDirectory(configPath + "\\connections"); //Create directory if it doesn't exist if (!Directory.Exists(webFilesPath)) Directory.CreateDirectory(webFilesPath); //Load the encryption key from local file if (File.Exists(configPath + "\\key.n2c")) { StreamReader encR = new StreamReader(configPath + "\\key.n2c"); encryptionKey = encR.ReadLine(); encR.Close(); } else { StreamWriter encW = new StreamWriter(configPath + "\\key.n2c"); Random rand = new Random(); char[] randomLetters = new char[rand.Next(16,32)]; for (int i = 0; i < randomLetters.Length; i++) randomLetters[i] = Convert.ToChar(rand.Next(1, 255)); string tmpKey = new string(randomLetters); encW.WriteLine(tmpKey); encryptionKey = tmpKey; encW.Close(); } //Get connection files string[] connections = Directory.GetFiles(configPath + "\\connections\\"); for (int i = 0; i < connections.Length; i++) { if (connections[i].EndsWith(".n2c")) { string fPath = connections[i]; MenuItem item = new MenuItem(); item.Header = System.IO.Path.GetFileName(connections[i]).Replace(".n2c", ""); item.Click += new RoutedEventHandler( delegate(object s, RoutedEventArgs earg) { cbx_conn.Text = System.IO.Path.GetFileName(fPath).Replace(".n2c", ""); loadN2CFile(); }); menuFile.Items.Add(item); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } //Check and load arguments from command line string[] args = Environment.GetCommandLineArgs(); if (args.Length > 0) { Load(args.ToArray()); } /*if (args.Length < 2) { //Adds an empty document AddDocument("txt"); }*/ }
private void Window_Closed(object sender, EventArgs e) { //Clear the cache ClearCache(webFilesPath); // Save data acorp.WindowSSL ssl = new acorp.WindowSSL(); ssl.SaveWindowData(this, configPath + "\\settings\\main-win.txt"); }