コード例 #1
0
        /// <summary>
        /// Adds a new license to the collection and makes it the selected license.
        /// </summary>
        private void AddLicense()
        {
            LicenseViewModel newLicense = new LicenseViewModel(new CWBozarth.LicenseManager.License());

            this.Licenses.Add(newLicense);
            this.SelectedLicense = newLicense;
        }
コード例 #2
0
        /// <summary>
        /// Restore the application settings.
        /// </summary>
        private void RestoreSettings()
        {
            if (!string.IsNullOrEmpty(Settings.Default.UtilityProgramExecutable))
            {
                CWBozarth.LicenseManager.UtilityProgram.Instance.Executable = new FileInfo(Settings.Default.UtilityProgramExecutable);
            }

            // This is both a hack and a solution. This is a hack in that if LicenseViewModel were serializable the
            // ObservableCollection could be sent directly to the settings. This is a solution in that storing the
            // License means the settings don't need to be updated if the UI aspects get redesigned. Although that
            // is only a minor benefit. Another benefit is that a license can be checked to see if the port and
            // host are defined before saving it.
            if (Settings.Default.Licenses != null)
            {
                foreach (CWBozarth.LicenseManager.License license in Settings.Default.Licenses)
                {
                    LicenseViewModel licenseViewModel = new LicenseViewModel(license);
                    this.Licenses.Add(licenseViewModel);

                    if (licenseViewModel.License.GetStatusCanExecute)
                    {
                        licenseViewModel.GetStatus();
                    }
                }
            }
        }