Пример #1
0
 void internalThread_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     if (appSettings != null)
     {
         if (IsInfoValid())
         {
             appSettings.setValue(SETTINGS_SECTION_NAME, SETTINGS_NEWER_VERSION, VersionAvailable().ToString());
             appSettings.setValue(SETTINGS_SECTION_NAME, SETTINGS_MORE_INFO, getMoreInfoURL());
             appSettings.setValue(SETTINGS_SECTION_NAME, SETTINGS_RELEASE_DATE, getReleaseDate().ToShortDateString());
         }
         appSettings.setValue(SETTINGS_SECTION_NAME, SETTINGS_LAST_CHECK, DateTime.Now.ToShortDateString());
     }
     if (callbackFunction != null)
     {
         callbackFunction();
     }
 }
Пример #2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            string testURL = txtServerURL.Text.Trim();

            if (testURL.StartsWith("http"))
            {
                settings.setValue("server_url", "\"" + testURL + "\"");
                settings.save();
                this.Close();
            }
            else
            {
                MessageBox.Show("Server URL must start with 'http'.");
            }
        }
        public EmbroideryReaderSettings()
        {
            string settingsPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

            settingsPath = System.IO.Path.Combine(settingsPath, SETTINGS_PATH_COMPANY);
            settingsPath = System.IO.Path.Combine(settingsPath, SETTINGS_PATH_APP_NAME);
            if (!System.IO.Directory.Exists(settingsPath))
            {
                System.IO.Directory.CreateDirectory(settingsPath);
            }
            settingsPath = System.IO.Path.Combine(settingsPath, SETTINGS_FILENAME);
            // new settings file in application data folder
            settings = new NJCrawford.IniFile(settingsPath);

            // if the new file doesn't exist but the old one does, copy useful settings from old file to new
            if (!System.IO.File.Exists(settingsPath) && System.IO.File.Exists(SETTINGS_FILENAME))
            {
                // Old settings file stored in installation folder breaks on
                // Windows 7.
                NJCrawford.IniFile oldSettings = new NJCrawford.IniFile(SETTINGS_FILENAME);

                if (oldSettings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_ENABLED, -1) != -1)
                {
                    settings.setValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_ENABLED, oldSettings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_ENABLED, ""));
                }

                if (oldSettings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_RED, -1) != -1)
                {
                    settings.setValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_RED, oldSettings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_RED, ""));
                }

                if (oldSettings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_GREEN, -1) != -1)
                {
                    settings.setValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_GREEN, oldSettings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_GREEN, ""));
                }

                if (oldSettings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_BLUE, -1) != -1)
                {
                    settings.setValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_BLUE, oldSettings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_BLUE, ""));
                }

                if (oldSettings.getValue(SETTING_FILTER_STITCHES, false))
                {
                    settings.setValue(SETTING_FILTER_STITCHES, oldSettings.getValue(SETTING_FILTER_STITCHES, ""));
                }

                if (oldSettings.getValue(SETTING_FILTER_STITCHES_THRESHOLD, 0.0) > 0.0)
                {
                    settings.setValue(SETTING_FILTER_STITCHES_THRESHOLD, oldSettings.getValue(SETTING_FILTER_STITCHES_THRESHOLD, ""));
                }

                if (oldSettings.getValue(SETTING_THREAD_THICKNESS, 0.0) > 0.0)
                {
                    settings.setValue(SETTING_THREAD_THICKNESS, oldSettings.getValue(SETTING_THREAD_THICKNESS, ""));
                }

                if (!String.IsNullOrEmpty(oldSettings.getValue(SETTING_LAST_OPEN_FILE_FOLDER, "")))
                {
                    settings.setValue(SETTING_LAST_OPEN_FILE_FOLDER, oldSettings.getValue(SETTING_LAST_OPEN_FILE_FOLDER, ""));
                }

                if (!String.IsNullOrEmpty(oldSettings.getValue(SETTING_LAST_SAVE_IMAGE_LOCATION, "")))
                {
                    settings.setValue(SETTING_LAST_SAVE_IMAGE_LOCATION, oldSettings.getValue(SETTING_LAST_SAVE_IMAGE_LOCATION, ""));
                }
            }

            // Default to transparency grid enabled
            if (String.IsNullOrWhiteSpace(settings.getValue(SECTION_TRANSPARENCY_GRID, SETTING_TRANSPARENCY_GRID_ENABLE, "")))
            {
                settings.setValue(SECTION_TRANSPARENCY_GRID, SETTING_TRANSPARENCY_GRID_ENABLE, true);
            }

            // Update deprecated settings
            if (settings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_ENABLED, "") == "yes")
            {
                settings.setValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_ENABLED, true);
            }
            else
            {
                settings.setValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_ENABLED, false);
            }

            // Default language to english
            if (String.IsNullOrWhiteSpace(settings.getValue(SETTING_TRANSLATION, "")))
            {
                settings.setValue(SETTING_TRANSLATION, "English (EN-US)");
            }
        }
        public EmbroideryReaderSettings()
        {
            string settingsPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            settingsPath = System.IO.Path.Combine(settingsPath, SETTINGS_PATH_COMPANY);
            settingsPath = System.IO.Path.Combine(settingsPath, SETTINGS_PATH_APP_NAME);
            if (!System.IO.Directory.Exists(settingsPath))
            {
                System.IO.Directory.CreateDirectory(settingsPath);
            }
            settingsPath = System.IO.Path.Combine(settingsPath, SETTINGS_FILENAME);
            // new settings file in application data folder
            settings = new NJCrawford.IniFile(settingsPath);

            // if the new file doesn't exist but the old one does, copy useful settings from old file to new
            if (!System.IO.File.Exists(settingsPath) && System.IO.File.Exists(SETTINGS_FILENAME))
            {
                // Old settings file stored in installation folder breaks on
                // Windows 7.
                NJCrawford.IniFile oldSettings = new NJCrawford.IniFile(SETTINGS_FILENAME);

                if (oldSettings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_ENABLED, -1) != -1)
                {
                    settings.setValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_ENABLED, oldSettings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_ENABLED, ""));
                }

                if (oldSettings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_RED, -1) != -1)
                {
                    settings.setValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_RED, oldSettings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_RED, ""));
                }

                if (oldSettings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_GREEN, -1) != -1)
                {
                    settings.setValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_GREEN, oldSettings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_GREEN, ""));
                }

                if (oldSettings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_BLUE, -1) != -1)
                {
                    settings.setValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_BLUE, oldSettings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_BLUE, ""));
                }

                if (oldSettings.getValue(SETTING_FILTER_STITCHES, false))
                {
                    settings.setValue(SETTING_FILTER_STITCHES, oldSettings.getValue(SETTING_FILTER_STITCHES, ""));
                }

                if (oldSettings.getValue(SETTING_FILTER_STITCHES_THRESHOLD, 0.0) > 0.0)
                {
                    settings.setValue(SETTING_FILTER_STITCHES_THRESHOLD, oldSettings.getValue(SETTING_FILTER_STITCHES_THRESHOLD, ""));
                }

                if (oldSettings.getValue(SETTING_THREAD_THICKNESS, 0.0) > 0.0)
                {
                    settings.setValue(SETTING_THREAD_THICKNESS, oldSettings.getValue(SETTING_THREAD_THICKNESS, ""));
                }

                if (!String.IsNullOrEmpty(oldSettings.getValue(SETTING_LAST_OPEN_FILE_FOLDER, "")))
                {
                    settings.setValue(SETTING_LAST_OPEN_FILE_FOLDER, oldSettings.getValue(SETTING_LAST_OPEN_FILE_FOLDER, ""));
                }

                if (!String.IsNullOrEmpty(oldSettings.getValue(SETTING_LAST_SAVE_IMAGE_LOCATION, "")))
                {
                    settings.setValue(SETTING_LAST_SAVE_IMAGE_LOCATION, oldSettings.getValue(SETTING_LAST_SAVE_IMAGE_LOCATION, ""));
                }
            }

            // Default to transparency grid enabled
            if (String.IsNullOrWhiteSpace(settings.getValue(SECTION_TRANSPARENCY_GRID, SETTING_TRANSPARENCY_GRID_ENABLE, "")))
            {
                settings.setValue(SECTION_TRANSPARENCY_GRID, SETTING_TRANSPARENCY_GRID_ENABLE, true);
            }

            // Update deprecated settings
            if (settings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_ENABLED, "") == "yes")
            {
                settings.setValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_ENABLED, true);
            }
            else
            {
                settings.setValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_ENABLED, false);
            }

            // Default language to english
            if (String.IsNullOrWhiteSpace(settings.getValue(SETTING_TRANSLATION, "")))
            {
                settings.setValue(SETTING_TRANSLATION, "English (EN-US)");
            }
        }
        public EmbroideryReaderSettings()
        {
            string settingsPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            settingsPath = System.IO.Path.Combine(settingsPath, SETTINGS_PATH_COMPANY);
            settingsPath = System.IO.Path.Combine(settingsPath, SETTINGS_PATH_APP_NAME);
            if (!System.IO.Directory.Exists(settingsPath))
            {
                System.IO.Directory.CreateDirectory(settingsPath);
            }
            settingsPath = System.IO.Path.Combine(settingsPath, SETTINGS_FILENAME);
            // new settings file in application data folder
            settings = new NJCrawford.IniFile(settingsPath);

            // if the new file doesn't exist but the old one does, copy useful settings from old file to new
            if (!System.IO.File.Exists(settingsPath) && System.IO.File.Exists(SETTINGS_FILENAME))
            {
                // Old settings file stored in installation folder breaks on
                // Windows 7.
                NJCrawford.IniFile oldSettings = new NJCrawford.IniFile(SETTINGS_FILENAME);

                if (!String.IsNullOrEmpty(oldSettings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_ENABLED)))
                {
                    settings.setValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_ENABLED, oldSettings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_ENABLED));
                }

                if (!String.IsNullOrEmpty(oldSettings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_RED)))
                {
                    settings.setValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_RED, oldSettings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_RED));
                }

                if (!String.IsNullOrEmpty(oldSettings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_GREEN)))
                {
                    settings.setValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_GREEN, oldSettings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_GREEN));
                }

                if (!String.IsNullOrEmpty(oldSettings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_BLUE)))
                {
                    settings.setValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_BLUE, oldSettings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_BLUE));
                }

                if (!String.IsNullOrEmpty(oldSettings.getValue(SETTING_FILTER_STITCHES)))
                {
                    settings.setValue(SETTING_FILTER_STITCHES, oldSettings.getValue(SETTING_FILTER_STITCHES));
                }

                if (!String.IsNullOrEmpty(oldSettings.getValue(SETTING_FILTER_STITCHES_THRESHOLD)))
                {
                    settings.setValue(SETTING_FILTER_STITCHES_THRESHOLD, oldSettings.getValue(SETTING_FILTER_STITCHES_THRESHOLD));
                }

                if (!String.IsNullOrEmpty(oldSettings.getValue(SETTING_THREAD_THICKNESS)))
                {
                    settings.setValue(SETTING_THREAD_THICKNESS, oldSettings.getValue(SETTING_THREAD_THICKNESS));
                }

                if (!String.IsNullOrEmpty(oldSettings.getValue(SETTING_LAST_OPEN_FILE_FOLDER)))
                {
                    settings.setValue(SETTING_LAST_OPEN_FILE_FOLDER, oldSettings.getValue(SETTING_LAST_OPEN_FILE_FOLDER));
                }

                if (!String.IsNullOrEmpty(oldSettings.getValue(SETTING_LAST_SAVE_IMAGE_LOCATION)))
                {
                    settings.setValue(SETTING_LAST_SAVE_IMAGE_LOCATION, oldSettings.getValue(SETTING_LAST_SAVE_IMAGE_LOCATION));
                }
            }
        }