Exemplo n.º 1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            IConfiguration conf = ConfigurationRepository.IConfiguration;

            IConfigurationItem recentDomainTemplates = conf.GetConfigurationItem(UI_Constants.RecentDomainTemplates);

            // truncate actual config file storage
            recentDomainTemplates.ConfigurationItems.Clear();

            // Fill the new config file storage
            if (selectedDomainModelFile != "")
            {
                string itemName = string.Format("item-{0}", recentDomainTemplates.ConfigurationItems.Count + 1);
                recentDomainTemplates.AddConfigurationItem(new IConfigurationItemImpl(itemName, selectedDomainModelFile, UI_Constants.ConfigurationSource));

                ListViewItem item = GetListViewItem(selectedDomainModelFile);
                if (item != null)
                {
                    RecentFilesListView.Items.Remove(item);
                }
            }

            int index = 0;

            while (recentDomainTemplates.ConfigurationItems.Count < 10 && RecentFilesListView.Items.Count > index)
            {
                string domainTemplate = RecentFilesListView.Items[index++].Tag.ToString();
                string itemName       = string.Format("item-{0}", recentDomainTemplates.ConfigurationItems.Count + 1);
                recentDomainTemplates.AddConfigurationItem(new IConfigurationItemImpl(itemName, domainTemplate, UI_Constants.ConfigurationSource));
            }

            conf.Save();
        }
Exemplo n.º 2
0
        protected override void Dispose(bool disposing)
        {
            if (!DesignMode && _Persistence != ePersistence.None && conf != null)
            {
                IConfigurationItem list = conf.GetConfigurationItem(Name);
                if (list == null)
                {
                    DefineConfiguration();
                    list = conf.GetConfigurationItem(Name);
                }

                if (list != null)
                {
                    list.Clear();
                    foreach (string elem in Items)
                    {
                        list.AddConfigurationItem(new IConfigurationItemImpl("item" + Convert.ToString(list.ConfigurationItems.Count + 1), elem, _ConfigurationSource));
                    }
                }

                if ((this as IConfigurationControl).ConfigurationName() != "")
                {
                    ConfigurationRepository.IConfiguration.SetConfigurationValue((this as IConfigurationControl).ConfigurationName(), SelectedIndex);
                }

                conf.Save();
            }

            base.Dispose(disposing);
        }
Exemplo n.º 3
0
        void IPgConnectionStash.PersistConnections(IConfigurationItem node, eConfigurationSource configurationSource)
        {
            foreach (IPgConnection dbCon in _DbSettings.Values)
            {
                if (dbCon.Persist)
                {
                    log.Debug("Persist database connection: " + dbCon.ToString());

                    IConfigurationItem item = new IConfigurationItemImpl("item" + Convert.ToString(node.ConfigurationItems.Count + 1), "", configurationSource);
                    node.AddConfigurationItem(item);

                    item.AddConfigurationItem(new IConfigurationItemImpl("name", dbCon.Name, configurationSource));
                    item.AddConfigurationItem(new IConfigurationItemImpl("server", dbCon.Server, configurationSource));
                    item.AddConfigurationItem(new IConfigurationItemImpl("port", dbCon.Port, configurationSource));
                    item.AddConfigurationItem(new IConfigurationItemImpl("database", dbCon.Database, configurationSource));
                    item.AddConfigurationItem(new IConfigurationItemImpl("user", dbCon.User, configurationSource));

                    IConfigurationItem keyIt = new IConfigurationItemImpl("password", "", configurationSource);
                    keyIt.StorageKey    = "system";
                    keyIt.Configuration = node.Configuration;
                    keyIt.SetValue(dbCon.Password);
                    item.AddConfigurationItem(keyIt);
                }
            }
        }
Exemplo n.º 4
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            IConfigurationItem size = conf.GetConfigurationItem(UI_Constants.ConfigurationFormSize);

            (size as IConfigurationItemObject <Size>).SetValue(this.Size);

            IConfigurationItem location = conf.GetConfigurationItem(UI_Constants.ConfigurationFormLocation);

            (location as IConfigurationItemObject <Point>).SetValue(this.Location);

            conf.SetConfigurationValue(UI_Constants.SakwaModelPath, tbxModelFolder.Text);
            conf.SetConfigurationValue(UI_Constants.SakwaTemplatePath, tbxTemplateFolder.Text);
            conf.SetConfigurationValue(UI_Constants.SakwaModelOnStart, chxOpenOnStart.Checked.ToString());

            conf.SetConfigurationValue(UI_Constants.FullHelpPath, tbxHelpFile.Text);

            modelGUIConfig.Save();

            IConfigurationItem stockMethods = conf.GetConfigurationItem(UI_Constants.StockMethods);

            if (stockMethods != null)
            {
                eConfigurationSource src = stockMethods.Source;
                stockMethods.Clear();
                stockMethods.Source = src;

                foreach (string mthd in lbMethods.Items)
                {
                    string name = string.Format("item-{0}", stockMethods.ConfigurationItems.Count + 1);
                    stockMethods.AddConfigurationItem(new IConfigurationItemImpl(name, mthd, UI_Constants.ConfigurationSource));
                }
            }

            string json = (tpgInferenceConfig.Controls[0] as ucPropertyEditor).PropertiesAsJson;

            conf.SetConfigurationValue(UI_Constants.GlobalConnectionProperties, json);

            conf.Save();
        }
Exemplo n.º 5
0
        private void TemplateForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            bool         CanExit      = true;
            DialogResult UserSelected = DialogResult.None;

            SakwaUserControl oldEditor = editor.Controls.Count > 0 ? editor.Controls[0] as SakwaUserControl : null;

            if (oldEditor != null)
            {
                oldEditor.OnDeactivate();
            }

            foreach (IDecisionTree tree in ctrl.Trees)
            {
                if (tree.IsDirty)
                {
                    UserSelected = IApplicationInterface.GetFloatingForm(
                        eFloatReason.NotSet,
                        new ucUnsavedExit(true)).ShowDialog();

                    switch (UserSelected)
                    {
                    case DialogResult.OK:
                        CanExit = true;
                        break;

                    case DialogResult.Yes:
                        btnSave_Click(this, new EventArgs());
                        CanExit = true;
                        break;

                    default:
                        CanExit = false;
                        break;
                    }

                    break;
                }
            }

            if (CanExit)
            {
                conf.SetConfigurationValue(UI_Constants.TemplateFormState, this.WindowState.ToString());
                IConfigurationItem size = conf.GetConfigurationItem(UI_Constants.TemplateFormSize);
                (size as IConfigurationItemObject <Size>).SetValue(this.Size);

                IConfigurationItem location = conf.GetConfigurationItem(UI_Constants.TemplateFormLocation);
                (location as IConfigurationItemObject <Point>).SetValue(this.Location);

                IConfigurationItem recentProjects = conf.GetConfigurationItem(UI_Constants.TemplateRecentProjects);
                if (recentProjects != null)
                {
                    recentProjects.Clear();
                    foreach (IDecisionTree tree in ctrl.Trees)
                    {
                        if (File.Exists(tree.FullPath))
                        {
                            string itemName = string.Format("item-{0}", recentProjects.ConfigurationItems.Count + 1);
                            recentProjects.AddConfigurationItem(new IConfigurationItemImpl(itemName, tree.FullPath, UI_Constants.ConfigurationSource));
                        }
                    }

                    string path = ctrl.SelectedPath;
                    conf.SetConfigurationValue(UI_Constants.TemplateRecentNode, path);
                }

                try
                {
                    conf.Save();
                }
                catch (Exception ex)
                {
                    log.Debug(ex.ToString());
                }

                _IApplication.ShowHideTemplateEditor(false, true);
            }
            else
            {
                e.Cancel = true;
            }
        }