Beispiel #1
0
        private void SaveSettings()
        {
            Obany.Preferences.Registry.PreferencesProviderConfiguration preferencesConfiguration = new Obany.Preferences.Registry.PreferencesProviderConfiguration();
            preferencesConfiguration.RegistryKey = Microsoft.Win32.Registry.CurrentUser;
            preferencesConfiguration.Root        = @"Software\" + _aboutData.CompanyNamePlain + @"\" + _aboutData.ProductName + @"\";

            Obany.Preferences.Model.IPreferencesProvider preferencesProvider = new Obany.Preferences.Registry.PreferencesProvider(preferencesConfiguration);

            preferencesProvider.SetBool("IsMaximized", this.WindowState == WindowState.Maximized ? true : false);
            preferencesProvider.SetDouble("WindowLeft", this.Left);
            preferencesProvider.SetDouble("WindowTop", this.Top);
            preferencesProvider.SetDouble("WindowWidth", this.Width);
            preferencesProvider.SetDouble("WindowHeight", this.Height);

            preferencesProvider.SetInt32("UpdateCount", _updateCount + 1);

            coreInterface.SaveSettings(preferencesProvider);
        }
Beispiel #2
0
        private void LoadSettings()
        {
            Obany.Preferences.Registry.PreferencesProviderConfiguration preferencesConfiguration = new Obany.Preferences.Registry.PreferencesProviderConfiguration();
            preferencesConfiguration.RegistryKey = Microsoft.Win32.Registry.CurrentUser;
            preferencesConfiguration.Root        = @"Software\" + _aboutData.CompanyNamePlain + @"\" + _aboutData.ProductName + @"\";

            Obany.Preferences.Model.IPreferencesProvider preferencesProvider = new Obany.Preferences.Registry.PreferencesProvider(preferencesConfiguration);

            double defWidth  = (System.Windows.SystemParameters.PrimaryScreenWidth - 20);
            double defHeight = (System.Windows.SystemParameters.PrimaryScreenHeight - 50);
            double defLeft   = 10;
            double defTop    = 10;

            bool maxim = preferencesProvider.GetBool("IsMaximized", false);

            this.Left   = preferencesProvider.GetDouble("WindowLeft", defLeft);
            this.Top    = preferencesProvider.GetDouble("WindowTop", defTop);
            this.Width  = preferencesProvider.GetDouble("WindowWidth", defWidth);
            this.Height = preferencesProvider.GetDouble("WindowHeight", defHeight);

            this.WindowState = maxim ? WindowState.Maximized : WindowState.Normal;
            this.ResizeMode  = maxim ? ResizeMode.NoResize : ResizeMode.CanResizeWithGrip;

            buttonMaximize.Visibility = maxim ? Visibility.Collapsed : Visibility.Visible;
            buttonRestore.Visibility  = maxim ? Visibility.Visible : Visibility.Collapsed;

            coreInterface.LoadSettings(preferencesProvider);

            if (_sendLicensing)
            {
                bool isRegistered = preferencesProvider.GetBool("IsRegistered", false);

                if (!isRegistered)
                {
                    System.Threading.ThreadPool.QueueUserWorkItem(delegate(object state)
                    {
                        License license            = new License();
                        license.ApplicationName    = _aboutData.ProductName;
                        license.ApplicationVersion = _aboutData.VersionStringFixed;
                        license.OS          = Environment.OSVersion.Platform.ToString();
                        license.OSVersion   = Environment.OSVersion.Version.ToString();
                        license.ServicePack = Environment.OSVersion.ServicePack;
                        license.DateTimeUtc = DateTime.Now.ToUniversalTime();
                        license.ProcessorId = Obany.Core.Logging.GetManagementInfo("Win32_Processor", "ProcessorId");
                        license.BiosSerial  = Obany.Core.Logging.GetManagementInfo("Win32_BIOS", "SerialNumber");
                        if (!string.IsNullOrEmpty(_vendorId))
                        {
                            license.OemHardwareId = string.Join(",", MainWindow.GetVendorProductIds(_vendorId).ToArray());
                        }

                        Obany.Communications.CommunicationsResult res = Obany.Communications.CommunicationsManager.Put(new Uri("http://support.shumbi.com/license/?product=" + _aboutData.ProductName + "&version=" + _aboutData.VersionStringFixed), null, "text/xml", Obany.Language.Xml.XmlHelper.BinarySerialize(license));

                        if (res.Status == Obany.Core.OperationStatus.Success)
                        {
                            if (res.BinaryResponse != null)
                            {
                                string resString = System.Text.Encoding.UTF8.GetString(res.BinaryResponse);

                                if (!string.IsNullOrEmpty(resString))
                                {
                                    if (resString.Trim() == "OK")
                                    {
                                        preferencesProvider.SetBool("IsRegistered", true);
                                    }
                                }
                            }
                        }
                    });
                }
            }

            _updateCount = preferencesProvider.GetInt32("UpdateCount", 0);
        }