/// <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();
                }
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        /// <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);
                    }
                }
            }
        }