Exemplo n.º 1
0
 internal FrmSettings(DesktopClientSettings settings, ExtensionManager extensionManager, StyleManager styleManager)
 {
     InitializeComponent();
     this.settings = settings;
     this.extensionManager = extensionManager;
     this.styleManager = styleManager;
 }
Exemplo n.º 2
0
        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; };
        }
Exemplo n.º 3
0
 public FrmLogin(Profile profile, DesktopClientSettings settings, string fileName)
     : this()
 {
     this.profile = profile;
     this.fileName = fileName;
     this.settings = settings;
 }
Exemplo n.º 4
0
        public static ClientCredential Login(Action cancelCallback, DesktopClientSettings settings,
            bool alwaysShowDialog = false)
        {
            var crypto = Crypto.CreateDefaultCrypto();
            Profile profile;
            var profileFile = Directories.GetFullName(Constants.ProfileFileName);
            var profileDirectory = Path.GetDirectoryName(profileFile);
            if (string.IsNullOrEmpty(profileDirectory))
                throw new InvalidOperationException("The directory name is invalid (empty).");
            if (!Directory.Exists(profileDirectory))
            {
                Directory.CreateDirectory(profileDirectory);
                profile = new Profile();
            }
            else
            {
                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;
        }
Exemplo n.º 5
0
 static DesktopClientSettings()
 {
     Default = new DesktopClientSettings();
     Default.General = new GeneralSettings();
     Default.General.Language = Thread.CurrentThread.CurrentUICulture.Name;
     Default.General.ShowUnderExtensionsMenu = false;
     Default.General.OnlyShowForMaximumExtensionsLoaded = false;
     Default.General.MaximumExtensionsLoadedValue = 0;
     Default.PackageServer = ConfigurationManager.AppSettings[Constants.PackageServerSettingKey];
 }
Exemplo n.º 6
0
 static DesktopClientSettings()
 {
     Default                  = new DesktopClientSettings();
     Default.General          = new GeneralSettings();
     Default.General.Language = Thread.CurrentThread.CurrentUICulture.Name;
     Default.General.ShowUnderExtensionsMenu            = false;
     Default.General.OnlyShowForMaximumExtensionsLoaded = false;
     Default.General.MaximumExtensionsLoadedValue       = 0;
     Default.PackageServer = ConfigurationManager.AppSettings[Constants.PackageServerSettingKey];
 }
Exemplo n.º 7
0
        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; };
        }
Exemplo n.º 8
0
 public static void WriteSettings(DesktopClientSettings settings)
 {
     var json = JsonConvert.SerializeObject(settings);
     File.WriteAllText(SettingsFile, json);
 }
Exemplo n.º 9
0
        public static void WriteSettings(DesktopClientSettings settings)
        {
            var json = JsonConvert.SerializeObject(settings);

            File.WriteAllText(SettingsFile, json);
        }