/// <summary>
        /// Initializes a new instance of the <see cref="PluginFrameworkSimulatorForm" /> class.
        /// </summary>
        /// <param name="simulator">The <see cref="IPluginFrameworkSimulator" /> that will drive this instance.</param>
        /// <exception cref="ArgumentNullException"><paramref name="simulator" /> is null.</exception>
        public PluginFrameworkSimulatorForm(IPluginFrameworkSimulator simulator)
            : this()
        {
            _simulator           = simulator ?? throw new ArgumentNullException(nameof(simulator));
            _criticalSectionForm = new CriticalSectionMockForm(simulator);
            _dataLoggerForm      = new DataLoggerMockForm(simulator);

            // Initialize config control last, since it is the one that will be displayed initially
            InitializeExecutionEngine();
            InitializeConfigurationControl();
            label_PluginType.Text = simulator.PluginAssemblyName;

            string lastAccessedFileName = UserAppDataRegistry.GetValue("PluginDataLocation") as string;

            if (!string.IsNullOrEmpty(lastAccessedFileName))
            {
                try
                {
                    ImportConfigurationData(lastAccessedFileName, false);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Import Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    //Couldn't load.  Return to clean state.
                    ClearConfigurationData();
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Sets global settings for which database
        /// </summary>
        /// <returns></returns>
        public static bool ConnectToDatabase()
        {
            if (STFDispatcherManager.Dispatcher == null || STFDispatcherManager.DisconnectFromDispatcher(true))
            {
                var systems = GetAvailableSystems();

                if (systems.Count == 1)
                {
                    StfSystem system = systems.First();
                    InitializeDataConnection(system.Name, system.Address);
                    return(true);
                }
                else
                {
                    string lastUsedSystem = UserAppDataRegistry.GetValue("STFSystem") as string;
                    using (InputDialog inputDialog = new InputDialog("Select an Environment to connect to:", "Connect to Environment", lastUsedSystem))
                    {
                        inputDialog.StartPosition = FormStartPosition.CenterScreen;
                        inputDialog.InitializeComboBox(systems.Select(x => x.Name).ToList());

                        if (inputDialog.ShowDialog() == DialogResult.OK)
                        {
                            var selectedSystem = systems.First(x => x.Name.Equals(inputDialog.Value));
                            InitializeDataConnection(selectedSystem.Name, selectedSystem.Address);
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
        /// <summary>
        /// Saves the settings for the application
        /// </summary>
        public void SaveSettings()
        {
            try
            {
                List <string> paths = new List <string>();
                foreach (string path in _manager.DriverPackagePaths.Items)
                {
                    if (!string.IsNullOrEmpty(path))
                    {
                        paths.Add(path);
                    }
                }

                UserAppDataRegistry.SetValue("PQI Driver Paths", string.Join(",", paths.ToArray()));
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (UnauthorizedAccessException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (SecurityException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (IOException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #4
0
        private static void InitializeDataConnection(string name, string value)
        {
            //Make sure we unsubscribe from any previous connections.
            SessionClient.Instance.Stop();

            //Save the selection to the registry.
            UserAppDataRegistry.SetValue("STFSystem", name);

            LoadGlobalSettings(value);
        }
Beispiel #5
0
        /// <summary>
        /// Load event.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            comboBox_Plugin.DataSource = GetPluginsFromFolder();
            string lastAccessedPlugin = UserAppDataRegistry.GetValue("PluginAssemblyName") as string;

            if (!string.IsNullOrEmpty(lastAccessedPlugin))
            {
                comboBox_Plugin.SelectedIndex = comboBox_Plugin.FindString(lastAccessedPlugin);
            }
        }
 private void exportConfigurationDataToolStripButton_Click(object sender, EventArgs e)
 {
     if (NullConfigurationDataCheck())
     {
         PluginConfigurationData configurationData = GetSelectedConfigurationData();
         if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
         {
             PluginConfigurationData.WriteToFile(configurationData, saveFileDialog.FileName);
             UserAppDataRegistry.SetValue("PluginDataLocation", saveFileDialog.FileName);
         }
     }
 }
Beispiel #7
0
        /// <summary>
        /// Loads the settings for the application
        /// </summary>
        private static string LoadDatabaseName()
        {
            string database = string.Empty;

            object registryPath = UserAppDataRegistry.GetValue("PQI Database");

            if (registryPath != null)
            {
                database = registryPath.ToString();
            }

            return(database);
        }
        private void ImportConfigurationData(string fileName, bool saveToRegistry)
        {
            PluginConfigurationData data = PluginConfigurationData.LoadFromFile(fileName);

            AddConfigurationData(data, Path.GetFileNameWithoutExtension(fileName));

            // Load metadata unless an activity is executing
            if (!executionBackgroundWorker.IsBusy)
            {
                PluginInitialize(data);
                if (saveToRegistry)
                {
                    UserAppDataRegistry.SetValue("PluginDataLocation", fileName);
                }
            }
        }
        /// <summary>
        /// Loads the settings for the application
        /// </summary>
        public void LoadSettings()
        {
            var registryPath = UserAppDataRegistry.GetValue("PQI Driver Paths");

            if (registryPath != null)
            {
                Collection <string> items = new Collection <string>(registryPath.ToString().Split(new char[] { ',' }));

                // Only load those driver paths that are still there
                foreach (string item in items)
                {
                    if (Directory.Exists(item))
                    {
                        _manager.DriverPackagePaths.Add(item);
                    }
                }
            }
        }
Beispiel #10
0
 /// <summary>
 /// Saves the settings for the application
 /// </summary>
 private static void SaveDatabaseName(string database)
 {
     try
     {
         UserAppDataRegistry.SetValue("PQI Database", database);
     }
     catch (ArgumentException ex)
     {
         MessageBox.Show(ex.Message);
     }
     catch (UnauthorizedAccessException ex)
     {
         MessageBox.Show(ex.Message);
     }
     catch (SecurityException ex)
     {
         MessageBox.Show(ex.Message);
     }
     catch (IOException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #11
0
 private void button_Ok_Click(object sender, EventArgs e)
 {
     UserAppDataRegistry.SetValue("PluginAssemblyName", PluginAssemblyName);
 }