Exemplo n.º 1
0
        // TODO: consider moving this back to app.xaml.cs -- was chasing a jsonserializer problem that was hard to figure out...so moved it here.
        public void LoadOrCreateSettings()
        {
            bool settingsDirty      = false;
            var  settingsFolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "rrelyea\\devcommander");

            SettingsPath = Path.Combine(settingsFolderPath, "settings.json");
            if (File.Exists(SettingsPath))
            {
                var jsonString = File.ReadAllText(SettingsPath);
                Settings = JsonSerializer.Deserialize <DevCommanderSettings>(jsonString);
            }
            else
            {
                Settings      = new DevCommanderSettings();
                settingsDirty = true;
            }

            if (settingsDirty)
            {
                Directory.CreateDirectory(settingsFolderPath);
                var options = new JsonSerializerOptions()
                {
                    WriteIndented = true
                };
                var jsonString = JsonSerializer.Serialize(Settings);
                File.WriteAllText(SettingsPath, jsonString);
            }

            if (fileWatcher == null)
            {
                fileWatcher = new FileSystemWatcher(settingsFolderPath);
                fileWatcher.EnableRaisingEvents = true;
                fileWatcher.Changed            += FileWatcher_Changed;
            }
        }
Exemplo n.º 2
0
        public CloneRepoWindow(string selectedOrg, string selectedRepoName, Repo selectedRepo, DevCommanderSettings settings)
            : this()
        {
            SelectedOrg      = selectedOrg;
            SelectedRepoName = selectedRepoName;
            SelectedRepo     = selectedRepo;

            RepoUrl.Text            = SelectedOrg + SelectedRepoName;
            RepoRoots.ItemsSource   = settings.RepoRoots;
            RepoRoots.SelectedIndex = 0;
            localName.Text          = "\\" + SelectedRepoName;
        }