internal FrmMain(ClientCredential credential, DesktopClientSettings settings, ExtensionManager extensionManager, StyleManager styleManager) { this.credential = credential; this.settings = settings; this.extensionManager = extensionManager; this.styleManager = styleManager; this.InitializeComponent(); this.InitializeHtmlEditor(); this.InitializeExtensions(); this.Text = string.Format("CloudNotes - {0}@{1}", credential.UserName, credential.ServerUri); // Fix the main form size var currentScreen = Screen.FromControl(this); this.Width = Convert.ToInt32(currentScreen.Bounds.Width * 0.75F); this.Height = Convert.ToInt32(currentScreen.Bounds.Height * 0.75F); this.Location = new Point(currentScreen.Bounds.X + (currentScreen.Bounds.Width - this.Width) / 2, currentScreen.Bounds.Y + (currentScreen.Bounds.Height - this.Height) / 2); this.splitContainer.SplitterDistance = Convert.ToInt32(this.Width * 0.25F); this.notifyIcon.Text = string.Format("CloudNotes - {0}", credential.UserName); this.notesNode = this.tvNotes.Nodes.Add("NotesRoot", Resources.NotesNodeTitle, 0, 0); this.trashNode = this.tvNotes.Nodes.Add("TrashRoot", Resources.TrashNodeTitle, 1, 1); Application.Idle += (s, e) => { this.slblStatus.Text = Resources.Ready; }; }
public FrmLogin(Profile profile, DesktopClientSettings settings, string fileName) : this() { this.profile = profile; this.fileName = fileName; this.settings = settings; }
internal FrmSettings(DesktopClientSettings settings, ExtensionManager extensionManager, StyleManager styleManager) { InitializeComponent(); this.settings = settings; this.extensionManager = extensionManager; this.styleManager = styleManager; }
/// <summary> /// When overridden in a derived class, allows a designer to emit code that configures the splash screen and main form. /// </summary> protected override void OnCreateMainForm() { var extensionManager = new ExtensionManager(); var styleManager = new StyleManager(); var settings = DesktopClientSettings.ReadSettings(); var loadExtensionTask = Task.Factory.StartNew(() => { // As the extensions are loaded in another thread, setting that thread's ui culture // to the one read from the setting preference. Thread.CurrentThread.CurrentUICulture = new CultureInfo(settings.General.Language); extensionManager.Load(); }); var loadStyleTask = Task.Factory.StartNew(() => styleManager.Load()); Thread.CurrentThread.CurrentUICulture = new CultureInfo(settings.General.Language); var credential = LoginProvider.Login(Application.Exit, settings); if (credential != null) { Task.WaitAll(loadExtensionTask, loadStyleTask); // Instantiate your main application form this.MainForm = new FrmMain(credential, settings, extensionManager, styleManager); } }
internal FrmCreateNote(string prompt, StyleManager styleManager, DesktopClientSettings settings, IEnumerable <Tuple <Func <string, bool>, string> > validations = null) : this() { this.prompt = prompt; this.styleManager = styleManager; this.settings = settings; if (validations != null) { this.validations.AddRange(validations); } }
public static ClientCredential Login(Action cancelCallback, DesktopClientSettings settings, bool alwaysShowDialog = false) { var crypto = Crypto.CreateDefaultCrypto(); Profile profile; var profileFile = Directories.GetFullName(Constants.ProfileFileName); if (File.Exists(profileFile)) { try { profile = Profile.Load(profileFile); } catch { profile = new Profile(); } } else { profile = new Profile(); } ClientCredential credential = null; var selectedUserProfile = profile.UserProfiles.FirstOrDefault(p => p.IsSelected); var selectedServerProfile = profile.ServerProfiles.FirstOrDefault(p => p.IsSelected); if (alwaysShowDialog || selectedUserProfile == null || !selectedUserProfile.AutoLogin) { var loginForm = new FrmLogin(profile, settings, profileFile); var dialogResult = loginForm.ShowDialog(); if (dialogResult == DialogResult.OK) { credential = loginForm.Credential; } else { cancelCallback(); } } else { credential = new ClientCredential { Password = crypto.Decrypt(selectedUserProfile.Password), ServerUri = selectedServerProfile == null ? string.Empty : selectedServerProfile.Uri, UserName = selectedUserProfile.UserName }; } return(credential); }
private void btnOK_Click(object sender, EventArgs e) { // Saves the extension settings foreach (var extension in this.extensionManager.AllExtensions) { var settingProvider = extension.Value.SettingProvider; if (settingProvider != null) { settingProvider.PersistSettings(); } } settings.General.Language = ((KeyValuePair <string, string>)cbLanguage.SelectedItem).Key; settings.General.ShowUnderExtensionsMenu = chkShowExtensionInMenuGroup.Checked; settings.General.OnlyShowForMaximumExtensionsLoaded = chkOnlyShowWhenMoreThan.Checked; settings.General.MaximumExtensionsLoadedValue = Convert.ToInt32(numMaxExtensionsLoaded.Value); DesktopClientSettings.WriteSettings(settings); }
internal FrmMain(ClientCredential credential, DesktopClientSettings settings, ExtensionManager extensionManager) { this.credential = credential; this.settings = settings; this.extensionManager = extensionManager; this.InitializeComponent(); this.InitializeHtmlEditor(); this.InitializeExtensions(); this.Text = string.Format("CloudNotes - {0}@{1}", credential.UserName, credential.ServerUri); this.notifyIcon.Text = string.Format("CloudNotes - {0}", credential.UserName); this.notesNode = this.tvNotes.Nodes.Add("NotesRoot", Resources.NotesNodeTitle, 0, 0); this.trashNode = this.tvNotes.Nodes.Add("TrashRoot", Resources.TrashNodeTitle, 1, 1); Application.Idle += (s, e) => { this.slblStatus.Text = Resources.Ready; }; }
public DesktopClientService(DesktopClientSettings settings) { this.settings = settings; }