コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: zeondev/devdock
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            string settingsFile = File.ReadAllText(path);

            NewItemModal.Visibility = Visibility.Collapsed;
            if (!File.Exists(pathFolder))
            {
                Directory.CreateDirectory(pathFolder);
            }
            if (!File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\DevDock\settings.json") || string.IsNullOrEmpty(settingsFile))
            {
                string text = "{\"version\":\"" + currentver + "\",\"date\":\"" + DateTime.Today.ToShortDateString() + "\",\"apps\": []}";

                await File.WriteAllTextAsync(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\DevDock\settings.json", text);
            }
            else
            {
                DockInfo deserialized = JsonConvert.DeserializeObject <DockInfo>(settingsFile);
                currentDockInfo = deserialized;
                string newstr = JsonConvert.SerializeObject(deserialized);
                Dock_Refresh();
            }
            // double left = desktopWorkingArea.Right - this.Width;
            // double bottom = desktopWorkingArea.Bottom - 40;
            // 0.3b: removed all this
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: zeondev/devdock
 public bool Dock_AddItem(DockApps app)
 {
     try
     {
         string   settingsFile = File.ReadAllText(path);
         DockInfo deserialized = JsonConvert.DeserializeObject <DockInfo>(settingsFile);
         deserialized.Apps.Add(app);
         currentDockInfo = deserialized;
         string newstr = JsonConvert.SerializeObject(deserialized);
         MessageBox.Show(newstr);
         if (char.GetNumericValue(deserialized.Version[2]) > 3)
         {
             currentError = "Version " + deserialized.Version + " is higher than current version " + currentver + ", aborting";
             return(false);
         }
         MessageBox.Show("beginning for loop (before)");
         foreach (DockApps thisapp in currentDockInfo.Apps.ToArray())
         {
             MessageBox.Show(thisapp.Name + "\n" + thisapp.Icon + "\n" + thisapp.Path);
         }
         Dock_Refresh();
         MessageBox.Show("beginning for loop (after)");
         foreach (DockApps thisapp in currentDockInfo.Apps.ToArray())
         {
             MessageBox.Show(thisapp.Name + "\n" + thisapp.Icon + "\n" + thisapp.Path);
         }
         File.WriteAllText(path, newstr);
         return(true);
     }
     catch (Exception err)
     {
         MessageBox.Show("Oops! An unexpected error occured while reading from the settings file: " + err.Message);
         return(false);
     }
 }