Example #1
0
        private void LoadRegistryFile(string path)
        {
            this.LoadedFileName.Text = "...";
            this.SettingsList.Items.Clear();
            TextBlock?loadtext = new TextBlock();

            loadtext.Text = "LOADING...";
            this.SettingsList.Items.Add(loadtext);

            try
            {
                this.currentRegistryFile = path;
                if (this.AutoReload)
                {
                    this.WatchFile(this.currentRegistryFile);
                }

                Solutions solutions = Solutions.FromFile(this.ServiceProvider, this.currentRegistryFile);
                this.LoadedFileName.Text = "Loaded file " + this.currentRegistryFile;
                this.SettingsList.Items.Clear();
                foreach (var solution in solutions.All.Values)
                {
                    SolutionHeader header = new SolutionHeader(this, solution);
                    this.SettingsList.Items.Add(header);
                }

                Registry.SetValue(RegistryPath, "LastFile", this.currentRegistryFile, RegistryValueKind.String);
            }
            catch (Exception e)
            {
                this.LoadedFileName.Text = "ERROR";
                this.SettingsList.Items.Clear();
                TextBlock?feature = new TextBlock();
                feature.Text  = "AN ERROR HAS OCCURRED. TRY A DIFFERENT FILE\n\n";
                feature.Text += e.ToString();
                this.SettingsList.Items.Add(feature);
            }
        }
Example #2
0
        private async void LoadNewRegistry(object sender, RoutedEventArgs e)
        {
            var filedialog = new OpenFileDialog();

            filedialog.InitialDirectory = "Documents";
            filedialog.Filter           = "json files (*.json)|*.json|All files (*.*)|*.*";
            if (filedialog.ShowDialog() == true)
            {
                this.LoadedFileName.Text = "...";
                this.SettingsList.Items.Clear();
                var loadtext = new TextBlock();
                loadtext.Text = "LOADING...";
                this.SettingsList.Items.Add(loadtext);
                var manager = ServiceProvider.GetRequiredService <SettingsManager>();
                try
                {
                    await manager.Populate(filedialog.FileName);

                    this.LoadedFileName.Text = "Loaded file " + filedialog.FileName;
                    this.SettingsList.Items.Clear();
                    foreach (var solution in manager.SolutionsById)
                    {
                        SolutionHeader header = new SolutionHeader(this, manager, solution.Value);
                        SettingsList.Items.Add(header);
                    }
                }
                catch
                {
                    this.LoadedFileName.Text = "ERROR";
                    this.SettingsList.Items.Clear();
                    var feature = new TextBlock();
                    feature.Text = "AN ERROR HAS OCCURRED. TRY A DIFFERENT FILE";
                    this.SettingsList.Items.Add(feature);
                }
            }
        }