コード例 #1
0
ファイル: MainForm.cs プロジェクト: wheeliemow/tinyopds
        void bs_CurrentItemChanged(object sender, EventArgs e)
        {
            string s = string.Empty;

            foreach (Credential cred in HttpProcessor.Credentials)
            {
                s += cred.User + ":" + cred.Password + ";";
            }
            try
            {
                TinyOPDS.Properties.Settings.Default.Credentials = string.IsNullOrEmpty(s) ? string.Empty : Crypt.EncryptStringAES(s, urlTemplate);
            }
            finally
            {
                TinyOPDS.Properties.Settings.Default.Save();
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: wheeliemow/tinyopds
        private void LoadSettings()
        {
            // Setup link labels
            converterLinkLabel.Links.Add(0, converterLinkLabel.Text.Length, "http://fb2epub.net/files/Fb2ePubSetup_1_1_3.zip");
            linkLabel3.Links.Add(0, linkLabel3.Text.Length, "https://code.google.com/p/fb2librarynet/");
            linkLabel5.Links.Add(0, linkLabel5.Text.Length, "http://epubreader.codeplex.com/");
            linkLabel4.Links.Add(0, linkLabel4.Text.Length, "http://dotnetzip.codeplex.com/");
            linkLabel6.Links.Add(0, linkLabel6.Text.Length, "http://www.fb2library.net/projects/fb2fix");

            // Setup settings controls
            libraryPath.Text = TinyOPDS.Properties.Settings.Default.LibraryPath;
            if (!string.IsNullOrEmpty(TinyOPDS.Properties.Settings.Default.LibraryPath))
            {
                databaseFileName.Text = Utils.CreateGuid(Utils.IsoOidNamespace, TinyOPDS.Properties.Settings.Default.LibraryPath.SanitizePathName()).ToString() + ".db";
            }
            if (Utils.IsLinux)
            {
                startWithWindows.Enabled = false;
            }
            if (string.IsNullOrEmpty(TinyOPDS.Properties.Settings.Default.ConvertorPath))
            {
                if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ProgramFiles")))
                {
                    if (File.Exists(Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles"), "FB2ePub\\Fb2ePub.exe")))
                    {
                        convertorPath.Text = TinyOPDS.Properties.Settings.Default.ConvertorPath = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles"), "FB2ePub");
                    }
                }
            }
            else
            {
                convertorPath.Text = TinyOPDS.Properties.Settings.Default.ConvertorPath;
            }
            converterLinkLabel.Visible = string.IsNullOrEmpty(convertorPath.Text);

            // We should update all invisible controls
            interfaceCombo.SelectedIndex      = Math.Min(UPnPController.LocalInterfaces.Count - 1, TinyOPDS.Properties.Settings.Default.LocalInterfaceIndex);
            logVerbosity.SelectedIndex        = Math.Min(2, TinyOPDS.Properties.Settings.Default.LogLevel);
            updateCombo.SelectedIndex         = Math.Min(2, TinyOPDS.Properties.Settings.Default.UpdatesCheck);
            langCombo.SelectedValue           = TinyOPDS.Properties.Settings.Default.Language;
            sortOrderCombo.SelectedIndex      = TinyOPDS.Properties.Settings.Default.SortOrder;
            newBooksPeriodCombo.SelectedIndex = TinyOPDS.Properties.Settings.Default.NewBooksPeriod;

            openPort.Checked           = TinyOPDS.Properties.Settings.Default.UseUPnP ? TinyOPDS.Properties.Settings.Default.OpenNATPort : false;
            banClients.Enabled         = rememberClients.Enabled = dataGridView1.Enabled = TinyOPDS.Properties.Settings.Default.UseHTTPAuth;
            wrongAttemptsCount.Enabled = banClients.Checked && useHTTPAuth.Checked;

            _notifyIcon.Visible = TinyOPDS.Properties.Settings.Default.CloseToTray;
            _updateChecker.Start();

            // Load saved credentials
            try
            {
                HttpProcessor.Credentials.Clear();
                string[] pairs = Crypt.DecryptStringAES(TinyOPDS.Properties.Settings.Default.Credentials, urlTemplate).Split(';');
                foreach (string pair in pairs)
                {
                    string[] cred = pair.Split(':');
                    if (cred.Length == 2)
                    {
                        HttpProcessor.Credentials.Add(new Credential(cred[0], cred[1]));
                    }
                }
            }
            catch { }
        }