コード例 #1
0
ファイル: SettingsService.cs プロジェクト: Powerino73/paradox
        /// <summary>
        /// Creates a new settings profile.
        /// </summary>
        /// <param name="setAsCurrent">If <c>true</c>, the created profile will also be set as <see cref="CurrentProfile"/>.</param>
        /// <param name="parent">The parent profile of the settings to create. If <c>null</c>, a default profile will be used.</param>
        /// <returns>A new instance of the <see cref="SettingsProfile"/> class.</returns>
        public static SettingsProfile CreateSettingsProfile(bool setAsCurrent, SettingsProfile parent = null)
        {
            var profile = new SettingsProfile(parent ?? DefaultProfile);
            ProfileList.Add(profile);
            if (setAsCurrent)
                CurrentProfile = profile;

            return profile;
        }
コード例 #2
0
ファイル: SettingsService.cs プロジェクト: Powerino73/paradox
        private static void ChangeCurrentProfile(SettingsProfile oldProfile, SettingsProfile newProfile)
        {
            if (oldProfile == null) throw new ArgumentNullException("oldProfile");
            if (newProfile == null) throw new ArgumentNullException("newProfile");
            currentProfile = newProfile;

            foreach (var key in SettingsKeys)
            {
                object oldValue;
                oldProfile.GetValue(key.Key, out oldValue, true, false);
                object newValue;
                newProfile.GetValue(key.Key, out newValue, true, false);
                var oldList = oldValue as IList;
                var newList = newValue as IList;

                bool isDifferent;
                if (oldList != null && newList != null)
                {
                    isDifferent = oldList.Count != newList.Count;
                    for (int i = 0; i < oldList.Count && !isDifferent; ++i)
                    {
                        if (!Equals(oldList[i], newList[i]))
                            isDifferent = true;
                    }
                }
                else
                {
                    isDifferent = !Equals(oldValue, newValue);
                }
                if (isDifferent)
                {
                    newProfile.NotifyEntryChanged(key.Key);
                }
            }

            // Changes have been notified, empty the list of modified settings.
            newProfile.ValidateSettingsChanges();
        }
 public static Task PersistAsync(SettingsProfile profile)
 {
     return(OfflineSettingsProfileStorageStrategy.PersistAsync(profile));
 }
コード例 #4
0
ファイル: Settings.cs プロジェクト: nelsont/FTPbox
        /// <summary>
        /// Puts data from Profile Class to the Profiles list
        /// and then saves the Profiles list to the config file
        /// </summary>
        public static void SaveProfile()
        {
            var def = new SettingsProfile
                {
                    Account =
                        {
                            Host = Profile.Host,
                            Username = Profile.Username,
                            Password = (!Profile.AskForPassword) ? Common.Encrypt(Profile.Password) : string.Empty,
                            Port = Profile.Port,
                            Protocol = Profile.Protocol,
                            FtpsMethod = Profile.FtpsInvokeMethod,
                            FtpSecurityProtocol = Profile.SecurityProtocol,
                            SyncFrequency = Profile.SyncFrequency,
                            SyncMethod = Profile.SyncingMethod
                        },
                    Paths =
                        {
                            Remote = Profile.RemotePath,
                            Local = Profile.LocalPath,
                            Parent = Profile.HttpPath
                        },
                    Log =
                        {
                            Items = Common.FileLog.Files.ToArray(),
                            Folders = Common.FileLog.Folders.ToArray()
                        },
                    Ignored =
                        {
                            Folders = Common.IgnoreList.FolderList.ToArray(),
                            Extensions = Common.IgnoreList.ExtensionList.ToArray(),
                            Dotfiles = Common.IgnoreList.IgnoreDotFiles,
                            Tempfiles = Common.IgnoreList.IgnoreTempFiles
                        }
                };

            if (settingsGeneral.DefaultProfile >= Profiles.Count)
                Profiles.Add(def);
            else
                Profiles[settingsGeneral.DefaultProfile] = def;

            string config_prof = JsonConvert.SerializeObject(Profiles, Formatting.Indented);
            File.WriteAllText(confProfiles, config_prof);
        }
コード例 #5
0
 public static T Get <T>(SettingsProfile profile, SettingsKey <T> key)
 {
     return(key.GetValue(profile, true));
 }
コード例 #6
0
 public SaveData()
 {
     profile  = new PlayerProfile();
     settings = new SettingsProfile();
 }
コード例 #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SettingsViewModel"/> class.
        /// </summary>
        /// <param name="serviceProvider">A service provider that can provide a <see cref="IDispatcherService"/> and an <see cref="IDialogService"/> to use for this view model.</param>
        /// <param name="profile">The profile associated </param>
        public SettingsViewModel([NotNull] IViewModelServiceProvider serviceProvider, SettingsProfile profile)
            : base(serviceProvider, new AssetNodeContainer())
        {
            var viewModelService = ServiceProvider.Get <GraphViewModelService>();

            RegisterNodePresenterUpdater(new SettingsPropertyNodeUpdater());
            ServiceProvider        = new ViewModelServiceProvider(serviceProvider, viewModelService.Yield());
            ValidateChangesCommand = new AnonymousTaskCommand(serviceProvider, ValidateChanges);
            DiscardChangesCommand  = new AnonymousCommand(serviceProvider, DiscardChanges);
            Profile = profile;
            Initialize();
        }
コード例 #8
0
ファイル: SettingsService.cs プロジェクト: Powerino73/paradox
        /// <summary>
        /// Loads a settings profile from the given file.
        /// </summary>
        /// <param name="filePath">The path of the file from which to load settings.</param>
        /// <param name="setAsCurrent">If <c>true</c>, the loaded profile will also be set as <see cref="CurrentProfile"/>.</param>
        /// <param name="parent">The profile to use as parent for the loaded profile. If <c>null</c>, a default profile will be used.</param>
        /// <returns><c>true</c> if settings were correctly loaded, <c>false</c> otherwise.</returns>
        public static SettingsProfile LoadSettingsProfile(UFile filePath, bool setAsCurrent, SettingsProfile parent = null)
        {
            if (filePath == null) throw new ArgumentNullException("filePath");

            if (!File.Exists(filePath))
            {
                Logger.Error("Settings file [{0}] was not found", filePath);
                return null;
            }

            SettingsProfile profile;
            try
            {
                SettingsFile settingsFile;
                using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    settingsFile = (SettingsFile)YamlSerializer.Deserialize(stream);
                }
                profile = new SettingsProfile(parent ?? DefaultProfile) { FilePath = filePath };

                foreach (var settings in settingsFile.Settings)
                {
                    SettingsKey key;
                    var value = settings.Value;
                    if (SettingsKeys.TryGetValue(settings.Key, out key))
                    {
                        value = key.ConvertValue(value);
                    }
                    profile.SetValue(settings.Key, value);
                }
            }
            catch (Exception e)
            {
                Logger.Error("Error while loading settings file [{0}]: {1}", e, filePath, e.FormatForReport());
                return null;
            }

            ProfileList.Add(profile);
            if (setAsCurrent)
            {
                CurrentProfile = profile;
            }
            
            var handler = SettingsFileLoaded;
            if (handler != null)
            {
                SettingsFileLoaded(null, new SettingsFileLoadedEventArgs(filePath));
            }
            return profile;
        }
コード例 #9
0
 private void ConfigurePerformancePreferences()
 {
     SettingsProfile.ApplyConfiguredPerformanceSettings();
 }
コード例 #10
0
        private async Task SendEmail(string to, string cc, string subject, string htmlContent,
                                     SettingsProfile customSettingsProfile = null, LinkedResource linkedResource = null)
        {
            SettingsProfile settingsProfile;
            var             usingCustomSettingsProfile = false;

            if (customSettingsProfile == null)
            {
                settingsProfile = _dataManager.GetSettingsProfileWithPassword();
            }
            else
            {
                settingsProfile            = customSettingsProfile;
                usingCustomSettingsProfile = true;
            }

            if (string.IsNullOrEmpty(to))
            {
                to = settingsProfile.EmailAddress;
            }

            try
            {
                using (var client = new SmtpClient())
                {
                    client.Port = settingsProfile.EmailPort;
                    client.UseDefaultCredentials = false;
                    client.Credentials           = new NetworkCredential(settingsProfile.EmailAddress,
                                                                         settingsProfile.EmailPassword);
                    client.Host      = settingsProfile.SMTPAddress;
                    client.EnableSsl = settingsProfile.EmailUsesSSL;

                    using (var message = new MailMessage())
                    {
                        message.IsBodyHtml = true;
                        message.From       = new MailAddress(settingsProfile.EmailAddress);
                        message.To.Add(new MailAddress(to));
                        if (!string.IsNullOrEmpty(cc))
                        {
                            message.CC.Add(new MailAddress(cc));
                        }
                        message.Subject = string.Format(VISUAL_GRADING_PREFIX, subject);

                        if (linkedResource != null)
                        {
                            var messageHeader = string.Format(MESSAGE_FORMAT, settingsProfile.EmailMessage,
                                                              string.Empty);

                            var completeMessage = string.Format(HTML_WRAPPER_TABLE_CONSTRUCTOR, messageHeader,
                                                                htmlContent, linkedResource.ContentId);

                            var alternateView = AlternateView.CreateAlternateViewFromString(completeMessage, null,
                                                                                            "text/html");

                            alternateView.LinkedResources.Add(linkedResource);

                            message.AlternateViews.Add(alternateView);
                        }
                        else
                        {
                            var messageWithoutChart = string.Format(MESSAGE_FORMAT, settingsProfile.EmailMessage,
                                                                    htmlContent);

                            message.Body = messageWithoutChart;
                        }

                        await client.SendMailAsync(message);

                        //todo: this is not MVVM friendly, needs to route exceptions back up to view instead
                        MessageBox.Show(EMAIL_SUCCESS);
                    }
                }
            }
            catch (Exception ex)
            {
                //todo: this is not MVVM friendly, needs to route exceptions back up to view instead
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (!usingCustomSettingsProfile)
                {
                    settingsProfile.EmailPassword.Dispose();
                }
            }
        }
コード例 #11
0
 public async Task SendTestEmail(SettingsProfile customSettingsProfile)
 {
     await SendEmail(customSettingsProfile.EmailAddress, string.Empty, TEST_SUBJECT, string.Empty,
                     customSettingsProfile);
 }
コード例 #12
0
            /// <summary>
            /// Create a new instance of the correct implementation of <see cref="SettingsKeyWrapper"/> that matches the given settings key.
            /// </summary>
            /// <param name="key">The settings key for which to create a instance.</param>
            /// <param name="profile">The <see cref="SettingsProfile"/> in which this settings key is contained.</param>
            /// <param name="package">The package to mark dirty.</param>
            /// <returns>A new instance of the <see cref="SettingsKeyWrapper"/> class.</returns>
            public static SettingsKeyWrapper Create(SettingsKey key, SettingsProfile profile, Package package = null)
            {
                var result = (SettingsKeyWrapper)Activator.CreateInstance(typeof(SettingsKeyWrapper <>).MakeGenericType(key.Type), key, profile, package);

                return(result);
            }
コード例 #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SettingsKeyWrapper"/> class.
 /// </summary>
 /// <param name="key">The <see cref="SettingsKey"/> represented by this instance.</param>
 /// <param name="profile">The <see cref="SettingsProfile"/> in which this settings key is contained.</param>
 protected SettingsKeyWrapper(SettingsKey key, SettingsProfile profile)
 {
     Key     = key;
     Profile = profile;
 }
コード例 #14
0
 public PrintLevelingData(SettingsProfile settingsProfile)
 {
     this.settingsProfile = settingsProfile;
 }
コード例 #15
0
ファイル: SettingsService.cs プロジェクト: Powerino73/paradox
 static SettingsService()
 {
     ProfileList.Add(DefaultProfile);
     currentProfile = DefaultProfile;
     Logger = new LoggerResult();
 }
コード例 #16
0
            protected override void _drawGUI(int id)
            {
                GUILayout.BeginVertical();

                // Moderation sections
                GUILayout.BeginHorizontal();
                pvc.moderate_aoa = GUILayout.Toggle(pvc.moderate_aoa, "Moderate AoA", GUIStyles.toggleButtonStyle);
                float.TryParse(GUILayout.TextField(pvc.max_aoa.ToString("G4"), GUIStyles.textBoxStyle), out pvc.max_aoa);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                pvc.moderate_g = GUILayout.Toggle(pvc.moderate_g, "Moderate G", GUIStyles.toggleButtonStyle);
                float.TryParse(GUILayout.TextField(pvc.max_g_force.ToString("G4"), GUIStyles.textBoxStyle), out pvc.max_g_force);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                yvc.moderate_aoa = GUILayout.Toggle(yvc.moderate_aoa, "Moderate Sideslip", GUIStyles.toggleButtonStyle);
                float.TryParse(GUILayout.TextField(yvc.max_aoa.ToString("G4"), GUIStyles.textBoxStyle), out yvc.max_aoa);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                yvc.moderate_g = GUILayout.Toggle(yvc.moderate_g, "Moderate side-G", GUIStyles.toggleButtonStyle);
                float.TryParse(GUILayout.TextField(yvc.max_g_force.ToString("G4"), GUIStyles.textBoxStyle), out yvc.max_g_force);
                GUILayout.EndHorizontal();

                // rotation rate limits
                GUILayout.BeginHorizontal();
                GUILayout.Label("pitch rate limit", GUIStyles.labelStyleLeft);
                float.TryParse(GUILayout.TextField(pvc.max_v_construction.ToString("G4"), GUIStyles.textBoxStyle), out pvc.max_v_construction);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Label("roll rate limit", GUIStyles.labelStyleLeft);
                float.TryParse(GUILayout.TextField(rvc.max_v_construction.ToString("G4"), GUIStyles.textBoxStyle), out rvc.max_v_construction);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Label("yaw rate limit", GUIStyles.labelStyleLeft);
                float.TryParse(GUILayout.TextField(yvc.max_v_construction.ToString("G4"), GUIStyles.textBoxStyle), out yvc.max_v_construction);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Label("director strength", GUIStyles.labelStyleLeft);
                double.TryParse(GUILayout.TextField(dc.strength.ToString("G4"), GUIStyles.textBoxStyle), out dc.strength);
                GUILayout.EndHorizontal();

                // wing leveler
                rvc.wing_leveler = GUILayout.Toggle(rvc.wing_leveler, "Snap wings to level", GUIStyles.toggleButtonStyle);

                // profile section

                // profile creation section
                GUILayout.Space(8.0f);
                GUILayout.Label("profiles", GUIStyles.labelStyleCenter);
                GUILayout.BeginHorizontal();
                profile_name = GUILayout.TextField(profile_name, GUIStyles.textBoxStyle);
                bool pressed = GUILayout.Button("save", GUIStyles.toggleButtonStyleRight, GUILayout.Width(40.0f));

                if (pressed && profile_name.Length > 0)
                {
                    // remove old profile with same name if needed
                    if (profiles.Count > 0 && profile_name != null && profile_name.Length > 0)
                    {
                        SettingsProfile old_profile = null;
                        for (int i = 0; i < profiles.Count; i++)
                        {
                            var p = profiles[i];
                            if (p.profile_name.Equals(profile_name))
                            {
                                old_profile = p;
                                break;
                            }
                        }
                        if (old_profile != null)
                        {
                            profiles.Remove(old_profile);
                        }
                    }
                    // save new profile
                    SettingsProfile profile = new SettingsProfile(this);
                    profile.profile_name = profile_name;
                    profiles.Add(profile);
                    // serialize it
                    Serialize();
                }
                GUILayout.EndHorizontal();
                // profile selection section
                for (int i = 0; i < profiles.Count; i++)
                {
                    GUILayout.BeginHorizontal();
                    var s = profiles[i];
                    pressed = GUILayout.Button(s.profile_name, GUIStyles.toggleButtonStyle);
                    if (pressed)
                    {
                        // let's actiavte this profile
                        s.Apply(this);
                        profile_name = s.profile_name;
                    }
                    pressed = GUILayout.Button("del", GUIStyles.toggleButtonStyleRight, GUILayout.Width(30.0f));
                    if (pressed)
                    {
                        // let's delete this profile
                        profiles.Remove(s);
                        window.height = 0.0f;       // compact window
                        Serialize();
                    }
                    GUILayout.EndHorizontal();
                }

                GUILayout.EndVertical();
                GUI.DragWindow();
            }
コード例 #17
0
 public static async Task PersistAsync(SettingsProfile profile)
 {
     await File.WriteAllTextAsync(profile.Path, JsonConvert.SerializeObject(profile, Formatting.Indented)).ConfigureAwait(false);
 }
コード例 #18
0
        public EditConnectionWidget(ConnectionWindow windowController, GuiWidget containerWindowToClose, Printer activePrinter = null, object state = null)
            : base(windowController, containerWindowToClose)
        {
            textImageButtonFactory.normalTextColor   = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.hoverTextColor    = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.pressedTextColor  = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.borderWidth       = 0;

            linkButtonFactory.textColor = ActiveTheme.Instance.PrimaryTextColor;
            linkButtonFactory.fontSize  = 8;

            this.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            this.AnchorAll();
            this.Padding = new BorderDouble(0);             //To be re-enabled once native borders are turned off

            GuiWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);

            mainContainer.AnchorAll();
            mainContainer.Padding         = new BorderDouble(3, 3, 3, 5);
            mainContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

            string headerTitle;

            if (activePrinter == null)
            {
                headerTitle                 = string.Format("Add a Printer");
                this.addNewPrinterFlag      = true;
                this.ActivePrinter          = new Printer();
                this.ActivePrinter.Name     = "Default Printer";
                this.ActivePrinter.BaudRate = "250000";
                try
                {
                    this.ActivePrinter.ComPort = FrostedSerialPort.GetPortNames().FirstOrDefault();
                }
                catch (Exception e)
                {
                    Debug.Print(e.Message);
                    GuiWidget.BreakInDebugger();
                    //No active COM ports
                }
            }
            else
            {
                this.ActivePrinter = activePrinter;
                string editHeaderTitleTxt = LocalizedString.Get("Edit Printer");
                headerTitle = string.Format("{1} - {0}", this.ActivePrinter.Name, editHeaderTitleTxt);
                if (this.ActivePrinter.BaudRate == null)
                {
                    this.ActivePrinter.BaudRate = "250000";
                }
                if (this.ActivePrinter.ComPort == null)
                {
                    try
                    {
                        this.ActivePrinter.ComPort = FrostedSerialPort.GetPortNames().FirstOrDefault();
                    }
                    catch (Exception e)
                    {
                        Debug.Print(e.Message);
                        GuiWidget.BreakInDebugger();
                        //No active COM ports
                    }
                }
            }

            FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight);

            headerRow.Margin  = new BorderDouble(0, 3, 0, 0);
            headerRow.Padding = new BorderDouble(0, 3, 0, 3);
            headerRow.HAnchor = HAnchor.ParentLeftRight;
            {
                TextWidget headerLabel = new TextWidget(headerTitle, pointSize: 14);
                headerLabel.TextColor = this.defaultTextColor;

                headerRow.AddChild(headerLabel);
            }

            ConnectionControlContainer                 = new FlowLayoutWidget(FlowDirection.TopToBottom);
            ConnectionControlContainer.Padding         = new BorderDouble(5);
            ConnectionControlContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            ConnectionControlContainer.HAnchor         = HAnchor.ParentLeftRight;
            {
                TextWidget printerNameLabel = new TextWidget(LocalizedString.Get("Name"), 0, 0, 10);
                printerNameLabel.TextColor = this.defaultTextColor;
                printerNameLabel.HAnchor   = HAnchor.ParentLeftRight;
                printerNameLabel.Margin    = new BorderDouble(0, 0, 0, 1);

                printerNameInput = new MHTextEditWidget(this.ActivePrinter.Name);

                printerNameInput.HAnchor |= HAnchor.ParentLeftRight;

                comPortLabelWidget = new FlowLayoutWidget();

                Button refreshComPorts = linkButtonFactory.Generate(LocalizedString.Get("(refresh)"));
                refreshComPorts.Margin  = new BorderDouble(left: 5);
                refreshComPorts.VAnchor = VAnchor.ParentBottom;
                refreshComPorts.Click  += new EventHandler(RefreshComPorts);

                FlowLayoutWidget comPortContainer = null;

#if !__ANDROID__
                TextWidget comPortLabel = new TextWidget(LocalizedString.Get("Serial Port"), 0, 0, 10);
                comPortLabel.TextColor = this.defaultTextColor;

                comPortLabelWidget.AddChild(comPortLabel);
                comPortLabelWidget.AddChild(refreshComPorts);
                comPortLabelWidget.Margin  = new BorderDouble(0, 0, 0, 10);
                comPortLabelWidget.HAnchor = HAnchor.ParentLeftRight;

                comPortContainer         = new FlowLayoutWidget(FlowDirection.TopToBottom);
                comPortContainer.Margin  = new BorderDouble(0);
                comPortContainer.HAnchor = HAnchor.ParentLeftRight;

                CreateSerialPortControls(comPortContainer, this.ActivePrinter.ComPort);
#endif

                TextWidget baudRateLabel = new TextWidget(LocalizedString.Get("Baud Rate"), 0, 0, 10);
                baudRateLabel.TextColor = this.defaultTextColor;
                baudRateLabel.Margin    = new BorderDouble(0, 0, 0, 10);
                baudRateLabel.HAnchor   = HAnchor.ParentLeftRight;

                baudRateWidget         = GetBaudRateWidget();
                baudRateWidget.HAnchor = HAnchor.ParentLeftRight;

                FlowLayoutWidget printerMakeContainer  = createPrinterMakeContainer();
                FlowLayoutWidget printerModelContainer = createPrinterModelContainer();

                enableAutoconnect           = new CheckBox(LocalizedString.Get("Auto Connect"));
                enableAutoconnect.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                enableAutoconnect.Margin    = new BorderDouble(top: 10);
                enableAutoconnect.HAnchor   = HAnchor.ParentLeft;
                if (this.ActivePrinter.AutoConnectFlag)
                {
                    enableAutoconnect.Checked = true;
                }

                if (state as StateBeforeRefresh != null)
                {
                    enableAutoconnect.Checked = ((StateBeforeRefresh)state).autoConnect;
                }

                SerialPortControl serialPortScroll = new SerialPortControl();

                if (comPortContainer != null)
                {
                    serialPortScroll.AddChild(comPortContainer);
                }

                ConnectionControlContainer.VAnchor = VAnchor.ParentBottomTop;
                ConnectionControlContainer.AddChild(printerNameLabel);
                ConnectionControlContainer.AddChild(printerNameInput);
                ConnectionControlContainer.AddChild(printerMakeContainer);
                ConnectionControlContainer.AddChild(printerModelContainer);
                ConnectionControlContainer.AddChild(comPortLabelWidget);
                ConnectionControlContainer.AddChild(serialPortScroll);
                ConnectionControlContainer.AddChild(baudRateLabel);
                ConnectionControlContainer.AddChild(baudRateWidget);
#if !__ANDROID__
                ConnectionControlContainer.AddChild(enableAutoconnect);
#endif
            }

            FlowLayoutWidget buttonContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
            buttonContainer.HAnchor = HAnchor.ParentLeft | HAnchor.ParentRight;
            //buttonContainer.VAnchor = VAnchor.BottomTop;
            buttonContainer.Margin = new BorderDouble(0, 5, 0, 3);
            {
                //Construct buttons
                saveButton = textImageButtonFactory.Generate(LocalizedString.Get("Save"));
                //saveButton.VAnchor = VAnchor.Bottom;

                cancelButton = textImageButtonFactory.Generate(LocalizedString.Get("Cancel"));
                //cancelButton.VAnchor = VAnchor.Bottom;
                cancelButton.Click += new EventHandler(CancelButton_Click);

                //Add buttons to buttonContainer
                buttonContainer.AddChild(saveButton);
                buttonContainer.AddChild(new HorizontalSpacer());
                buttonContainer.AddChild(cancelButton);
            }

            //mainContainer.AddChild(new PrinterChooser());

            mainContainer.AddChild(headerRow);
            mainContainer.AddChild(ConnectionControlContainer);
            mainContainer.AddChild(buttonContainer);

#if __ANDROID__
            this.AddChild(new SoftKeyboardContentOffset(mainContainer));
#else
            this.AddChild(mainContainer);
#endif

            BindSaveButtonHandlers();
            BindBaudRateHandlers();
        }
コード例 #19
0
 public void AddProfile(SettingsProfile profile)
 {
     _profiles.Add(profile);
     SettingsProfileStorageAdapter.PersistAsync(profile).Wait();
     OnProfilesChanged();
 }
コード例 #20
0
 public FileModifiedEventArgs(SettingsProfile profile)
 {
     Profile = profile;
 }
コード例 #21
0
ファイル: SettingsService.cs プロジェクト: Powerino73/paradox
        /// <summary>
        /// Reloads a profile from its file, updating the value that have changed.
        /// </summary>
        /// <param name="profile">The profile to reload.</param>
        public static void ReloadSettingsProfile(SettingsProfile profile)
        {
            var filePath = profile.FilePath;
            if (filePath == null) throw new ArgumentException("profile");
            if (!File.Exists(filePath))
            {
                Logger.Error("Settings file [{0}] was not found", filePath);
                throw new ArgumentException("profile");
            }

            try
            {
                SettingsFile settingsFile;
                using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    settingsFile = (SettingsFile)YamlSerializer.Deserialize(stream);
                }

                foreach (var settings in settingsFile.Settings)
                {
                    SettingsKey key;
                    var value = settings.Value;
                    if (SettingsKeys.TryGetValue(settings.Key, out key))
                    {
                        value = key.ConvertValue(value);
                    }
                    profile.SetValue(settings.Key, value);
                }
            }
            catch (Exception e)
            {
                Logger.Error("Error while loading settings file [{0}]: {1}", e, filePath, e.FormatForReport());
            }

            var handler = SettingsFileLoaded;
            if (handler != null)
            {
                SettingsFileLoaded(null, new SettingsFileLoadedEventArgs(filePath));
            }
        }
コード例 #22
0
ファイル: DataManager.cs プロジェクト: PtrMzk/VisualGrading
 private byte[] EncryptEmailPassword(SettingsProfile settingsProfile)
 {
     return(_encryption.EncryptSecureString(settingsProfile.EmailPassword));
 }
コード例 #23
0
ファイル: SettingsService.cs プロジェクト: Powerino73/paradox
 /// <summary>
 /// Unloads a profile that was previously loaded.
 /// </summary>
 /// <param name="profile">The profile to unload.</param>
 public static void UnloadSettingsProfile(SettingsProfile profile)
 {
     if (profile == DefaultProfile)
         throw new ArgumentException("The default profile cannot be unloaded");
     if (profile == CurrentProfile)
         throw new InvalidOperationException("Unable to unload the current profile.");
     ProfileList.Remove(profile);
 }
コード例 #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SettingsEntryValue"/> class.
 /// </summary>
 /// <param name="profile">The profile this <see cref="SettingsEntryValue"/>belongs to.</param>
 /// <param name="name">The name associated to this <see cref="SettingsEntryValue"/>.</param>
 /// <param name="value">The value to associate to this <see cref="SettingsEntryValue"/>.</param>
 internal SettingsEntryValue(SettingsProfile profile, UFile name, object value)
     : base(profile, name)
 {
     Value = value;
     ShouldNotify = true;
 }
コード例 #25
0
ファイル: SettingsService.cs プロジェクト: Powerino73/paradox
        /// <summary>
        /// Saves the given settings profile to a file at the given path.
        /// </summary>
        /// <param name="profile">The profile to save.</param>
        /// <param name="filePath">The path of the file.</param>
        /// <returns><c>true</c> if the file was correctly saved, <c>false</c> otherwise.</returns>
        public static bool SaveSettingsProfile(SettingsProfile profile, UFile filePath)
        {
            if (profile == null) throw new ArgumentNullException("profile");
            try
            {
                profile.Saving = true;
                Directory.CreateDirectory(filePath.GetFullDirectory());

                var settingsFile = new SettingsFile();
                foreach (var entry in profile.Settings.Values)
                {
                    settingsFile.Settings.Add(entry.Name, entry.GetSerializableValue());
                }

                using (var stream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.Write))
                {
                    YamlSerializer.Serialize(stream, settingsFile);
                }
            }
            catch (Exception e)
            {
                Logger.Error("Error while saving settings file [{0}]: {1}", e, filePath, e.FormatForReport());
                return false;
            }
            finally
            {
                profile.Saving = false;
            }
            return true;
        }
コード例 #26
0
ファイル: Settings.cs プロジェクト: nelsont/FTPbox
        /// <summary>
        /// If an old settings file is found (settings.xml), load its contents and convert to json format
        /// </summary>
        public static void LoadXmlSettings()
        {
            xmlDocument = new XmlDocument();
            try
            {
                xmlDocument.Load(xmlDocumentPath);
            }
            catch
            {
                xmlDocument.LoadXml("<settings></settings>");
            }

            settingsGeneral.Language = Get("Settings/Language", "");
            settingsGeneral.TrayAction =
                (TrayAction)
                Enum.Parse(typeof(TrayAction), Get("Settings/OpenInBrowser", TrayAction.OpenInBrowser.ToString()));
            settingsGeneral.Notifications = Get("Settings/ShowNots", "True") == "True";
            settingsGeneral.DownloadLimit = Get("Settings/DownLimit", 0);
            settingsGeneral.UploadLimit = Get("Settings/DownLimit", 0);

            var def = new SettingsProfile();

            def.Account.Host = Get("Account/Host", "");
            def.Account.Username = Get("Account/Username", "");
            def.Account.Password = Get("Account/Password", "");
            def.Account.Port = Get("Account/Port", bool.Parse(Get("Account/FTP", "True")) ? 21 : 22);
            def.Account.Protocol = bool.Parse(Get("Account/FTP", "True"))
                                       ? (bool.Parse(Get("Account/FTPS", "True")) ? FtpProtocol.FTPS : FtpProtocol.FTP)
                                       : FtpProtocol.SFTP;
            def.Account.FtpsMethod = (def.Account.Protocol == FtpProtocol.FTP)
                                         ? FtpsMethod.None
                                         : ((bool.Parse(Get("Account/FTPES", "True")))
                                                ? FtpsMethod.Explicit
                                                : FtpsMethod.Implicit);
            def.Account.FtpSecurityProtocol = Get("Account/FtpSecurityProtocol", "Default") == "Default"
                                                  ? FtpSecurityProtocol.None
                                                  : (FtpSecurityProtocol)
                                                    Enum.Parse(typeof(FtpSecurityProtocol),
                                                               Get("Account/FtpSecurityProtocol", "Default"));
            def.Account.SyncFrequency = Get("Settings/SyncFrequency", 10);
            def.Account.SyncMethod = Get("Settings/SyncMethod", SyncMethod.Automatic.ToString()) == "Automatic"
                                         ? SyncMethod.Automatic
                                         : SyncMethod.Manual;

            def.Paths.Remote = Get("Paths/rPath", "");
            def.Paths.Local = Get("Paths/lPath", "");
            def.Paths.Parent = Get("Paths/Parent", "");

            def.Log.Items = ConvertXmlLog;
            def.Log.Folders = Get("Log/folders", "").Split('|', '|');

            def.Ignored.Folders = Get("IgnoreSettings/Folders", "").Split('|', '|');
            def.Ignored.Extensions = Get("IgnoreSettings/Extensions", "").Split('|', '|');
            def.Ignored.Dotfiles = Get("IgnoreSettings/dotfiles", "False") == "True";
            def.Ignored.Tempfiles = Get("IgnoreSettings/tempfiles", "True") == "True";

            Profiles.Clear();
            Profiles.Add(def);
            Profile.Load();
            Common.FileLog = new FileLog();

            Save();

            try
            {
                xmlDocument = new XmlDocument();
                File.Delete(xmlDocumentPath);
            }
            catch
            {
            }
        }
コード例 #27
0
ファイル: InternalSettings.cs プロジェクト: Aggror/Stride
 static InternalSettings()
 {
     MostRecentlyUsedSessions.FallbackDeserializers.Add(LegacyMRUDeserializer);
     Profile = LoadProfile(true);
     SettingsContainer.CurrentProfile = Profile;
 }