Esempio n. 1
0
        public FormManageConfiguration(FormMain parent) : base(parent)
        {
            this.parentFormMain = parent;
            InitializeComponent();

            //Paths
            textBoxOutputPath.Text        = GlobalParameters.OutputPath;
            textBoxConfigurationPath.Text = GlobalParameters.ConfigurationPath;

            // Adding tab pages to the Environment tabs.
            IntPtr localHandle = tabControlEnvironments.Handle;

            foreach (var environment in TeamEnvironmentCollection.EnvironmentDictionary)
            {
                // Adding tabs on the Tab Control
                var lastIndex = tabControlEnvironments.TabCount - 1;
                CustomTabPageEnvironment localCustomTabPage = new CustomTabPageEnvironment(environment.Value);
                localCustomTabPage.OnDeleteEnvironment += DeleteEnvironment;
                localCustomTabPage.OnSaveEnvironment   += SaveEnvironment;
                localCustomTabPage.OnChangeMainText    += UpdateMainInformationTextBox;
                tabControlEnvironments.TabPages.Insert(lastIndex, localCustomTabPage);
                tabControlEnvironments.SelectedIndex = 0;

                // Adding items in the drop down list
                comboBoxEnvironments.Items.Add(new KeyValuePair <TeamWorkingEnvironment, string>(environment.Value, environment.Value.environmentKey));
                comboBoxEnvironments.DisplayMember = "Value";
            }

            comboBoxEnvironments.SelectedIndex = comboBoxEnvironments.FindStringExact(GlobalParameters.WorkingEnvironment);

            // Load the configuration file using the paths retrieved from the application root contents (configuration path)
            try
            {
                LocalInitialiseConnections(GlobalParameters.ConfigurationPath + GlobalParameters.ConfigFileName + '_' + GlobalParameters.WorkingEnvironment + GlobalParameters.FileExtension);
            }
            catch (Exception ex)
            {
                richTextBoxInformation.AppendText("Errors occurred trying to load the configuration file, the message is " + ex + ". No default values were loaded. \r\n\r\n");
            }

            // Connection tabs for the specific environment.
            AddConnectionTabPages();

            if (TeamConfiguration.MetadataConnection is null)
            {
                GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Warning, $"No metadata connection is set."));
            }
            else
            {
                comboBoxMetadataConnection.SelectedIndex = comboBoxMetadataConnection.FindStringExact(TeamConfiguration.MetadataConnection.ConnectionKey);
            }

            _formLoading = false;
        }
Esempio n. 2
0
        /// <summary>
        /// OnMouseDown event on the Environments Tab, if New is clicked instantiate a new environment tab.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tabControlEnvironments_MouseDown(object sender, MouseEventArgs e)
        {
            var lastIndex = tabControlEnvironments.TabCount - 1;

            if (tabControlEnvironments.GetTabRect(lastIndex).Contains(e.Location))
            {
                TeamWorkingEnvironment workingEnvironment = new TeamWorkingEnvironment();
                workingEnvironment.environmentInternalId = Utility.CreateMd5(new[] { Utility.GetRandomString(100) }, " % $@");
                workingEnvironment.environmentName       = "New environment";
                workingEnvironment.environmentKey        = "New";

                bool newTabExists = false;
                foreach (TabPage customTabPage in tabControlEnvironments.TabPages)
                {
                    if (customTabPage.Name == "New environment")
                    {
                        newTabExists = true;
                    }
                    else
                    {
                        // Do nothing
                    }
                }

                if (newTabExists == false)
                {
                    CustomTabPageEnvironment localCustomTabPage = new CustomTabPageEnvironment(workingEnvironment);
                    localCustomTabPage.OnDeleteEnvironment += DeleteEnvironment;
                    localCustomTabPage.OnSaveEnvironment   += SaveEnvironment;
                    localCustomTabPage.OnChangeMainText    += UpdateMainInformationTextBox;
                    tabControlEnvironments.TabPages.Insert(lastIndex, localCustomTabPage);
                    tabControlEnvironments.SelectedIndex = lastIndex;
                }
                else
                {
                    richTextBoxInformation.AppendText("There is already a 'new environment' tab open. Please close or save this first.\r\n");
                }
            }
        }