public EmbroideryReaderUpdates(string updateLocation, NJCrawford.IniFile settingsFile, callbackFunctionType callback) { callbackFunction = callback; appSettings = settingsFile; infoReadyMutex = new Mutex(); updateURL = updateLocation; callerVersion = Assembly.GetCallingAssembly().GetName().Version; callerName = Assembly.GetCallingAssembly().GetName().Name; //internalThread = new Thread(new ThreadStart(internalThreadFunction)); internalThread = new BackgroundWorker(); internalThread.DoWork += new DoWorkEventHandler(internalThread_DoWork); internalThread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(internalThread_RunWorkerCompleted); internalThread.RunWorkerAsync(); }
private void frmSettings_Load(object sender, EventArgs e) { settings = new NJCrawford.IniFile("forest-client.conf"); // set a default for server url if there is nothing set String serverUrl = settings.getValue("server_url", ""); if (String.IsNullOrEmpty(serverUrl)) { txtServerURL.Text = "http://url-not-set/forest"; } else { txtServerURL.Text = serverUrl.Replace("\"", ""); } }
public EmbroideryReaderUpdates(string updateLocation, NJCrawford.IniFile settingsFile, callbackFunctionType callback) { callbackFunction = callback; appSettings = settingsFile; infoReadyMutex = new Mutex(); updateURL = updateLocation; callerVersion = Assembly.GetCallingAssembly().GetName().Version; callerName = Assembly.GetCallingAssembly().GetName().Name; //internalThread = new Thread(new ThreadStart(internalThreadFunction)); internalThread = new BackgroundWorker(); internalThread.DoWork += new DoWorkEventHandler(internalThread_DoWork); internalThread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(internalThread_RunWorkerCompleted); internalThread.RunWorkerAsync(); }
private void frmSettings_Load(object sender, EventArgs e) { settings = new NJCrawford.IniFile("forest-client.conf"); // set a default for server url if there is nothing set String serverUrl = settings.getValue("server_url", ""); if (String.IsNullOrEmpty(serverUrl)) { txtServerURL.Text = "http://url-not-set/forest"; } else { txtServerURL.Text = serverUrl.Replace("\"", ""); } }
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)); } } }