Example #1
0
        public ConversionRepoForm(string filePath, ref SADS6x s6x)
        {
            InitializeComponent();

            repoFilePath = filePath;
            sadS6x       = s6x;

            try { Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath); }
            catch { }

            repoRepository = (RepositoryConversion)ToolsXml.DeserializeFile(repoFilePath, typeof(RepositoryConversion));
            if (repoRepository == null)
            {
                repoRepository = new RepositoryConversion();
            }
            repoRepository.isSaved = true;

            bindingSource            = new BindingSource();
            bindingSource.DataSource = repoRepository.Items.FindAll(searchRepositoryConversionItem);

            repoListBox.DisplayMember = "Title";
            repoListBox.DataSource    = bindingSource;

            this.FormClosing += new FormClosingEventHandler(RepositoryForm_FormClosing);

            searchTextBox.KeyPress           += new KeyPressEventHandler(searchTextBox_KeyPress);
            repoListBox.MouseMove            += new MouseEventHandler(repoListBox_MouseMove);
            repoListBox.MouseDown            += new MouseEventHandler(repoListBox_MouseDown);
            repoListBox.MouseClick           += new MouseEventHandler(repoListBox_MouseClick);
            repoListBox.SelectedIndexChanged += new EventHandler(repoListBox_SelectedIndexChanged);

            titleTextBox.ModifiedChanged       += new EventHandler(RepoItemTextBox_ModifiedChanged);
            iFormulaTextBox.ModifiedChanged    += new EventHandler(RepoItemTextBox_ModifiedChanged);
            commentsTextBox.ModifiedChanged    += new EventHandler(RepoItemTextBox_ModifiedChanged);
            informationTextBox.ModifiedChanged += new EventHandler(RepoItemTextBox_ModifiedChanged);

            titleTextBox.KeyDown       += new KeyEventHandler(RepoItemTextBox_KeyDown);
            iFormulaTextBox.KeyDown    += new KeyEventHandler(RepoItemTextBox_KeyDown);
            commentsTextBox.KeyDown    += new KeyEventHandler(RepoItemTextBox_KeyDown);
            informationTextBox.KeyDown += new KeyEventHandler(RepoItemTextBox_KeyDown);

            titleTextBox.Leave       += new EventHandler(RepoItemTextBox_Leave);
            iFormulaTextBox.Leave    += new EventHandler(RepoItemTextBox_Leave);
            commentsTextBox.Leave    += new EventHandler(RepoItemTextBox_Leave);
            informationTextBox.Leave += new EventHandler(RepoItemTextBox_Leave);

            iFormulaTextBox.TextChanged += new EventHandler(iFormulaTextBox_TextChanged);

            repoListBox.SelectedItem = null;
            repoListBox_SelectedIndexChanged(repoListBox, new EventArgs());
        }
Example #2
0
        private void initRepositories()
        {
            repoTables = (Repository)ToolsXml.DeserializeFile(Application.StartupPath + "\\" + SADDef.repoFileNameTables, typeof(Repository));
            if (repoTables == null)
            {
                repoTables = new Repository();
            }

            repoFunctions = (Repository)ToolsXml.DeserializeFile(Application.StartupPath + "\\" + SADDef.repoFileNameFunctions, typeof(Repository));
            if (repoFunctions == null)
            {
                repoFunctions = new Repository();
            }

            repoScalars = (Repository)ToolsXml.DeserializeFile(Application.StartupPath + "\\" + SADDef.repoFileNameScalars, typeof(Repository));
            if (repoScalars == null)
            {
                repoScalars = new Repository();
            }

            repoStructures = (Repository)ToolsXml.DeserializeFile(Application.StartupPath + "\\" + SADDef.repoFileNameStructures, typeof(Repository));
            if (repoStructures == null)
            {
                repoStructures = new Repository();
            }

            repoUnits = (Repository)ToolsXml.DeserializeFile(Application.StartupPath + "\\" + SADDef.repoFileNameUnits, typeof(Repository));
            if (repoUnits == null)
            {
                repoUnits = new Repository();
            }

            repoConversion = (RepositoryConversion)ToolsXml.DeserializeFile(Application.StartupPath + "\\" + SADDef.repoFileNameConversion, typeof(RepositoryConversion));
            if (repoConversion == null)
            {
                repoConversion = new RepositoryConversion();
            }
        }
Example #3
0
        private void repoToolStripTextBox_TextChanged(object sender, EventArgs e)
        {
            Repository           repoRepository           = null;
            RepositoryConversion repoRepositoryConversion = null;

            repoToolStripMenuItem.DropDownItems.Clear();

            if (repoContextMenuStrip.Tag == null)
            {
                return;
            }

            switch (repoContextMenuStrip.Tag.ToString())
            {
            case "elemHeaderPanel":
                switch (elemTabControl.SelectedTab.Name)
                {
                case "tableTabPage":
                    repoRepository = repoTables;
                    break;

                case "functionTabPage":
                    repoRepository = repoFunctions;
                    break;

                case "scalarTabPage":
                    repoRepository = repoScalars;
                    break;

                case "structureTabPage":
                    repoRepository = repoStructures;
                    break;

                default:
                    return;
                }
                break;

            case "tableCellsUnitsTextBox":
            case "tableColsUnitsTextBox":
            case "tableRowsUnitsTextBox":
            case "functionUnitsInputTextBox":
            case "functionUnitsOutputTextBox":
            case "scalarUnitsTextBox":
                repoRepository = repoUnits;
                break;

            case "tableScaleTextBox":
            case "functionScaleInputTextBox":
            case "functionScaleOutputTextBox":
            case "scalarScaleTextBox":
                repoRepositoryConversion = repoConversion;
                break;

            default:
                repoContextMenuStrip.Tag = null;
                break;
            }

            string searchLabel = repoToolStripTextBox.Text.ToUpper();

            SortedList slFiltered = new SortedList();

            if (repoRepository != null)
            {
                foreach (RepositoryItem repoItem in repoRepository.Items)
                {
                    string sLabel = repoItem.ShortLabel;
                    string label  = repoItem.Label;

                    if (sLabel == null)
                    {
                        continue;
                    }
                    if (label == null)
                    {
                        label = string.Empty;
                    }

                    if (searchLabel == string.Empty || sLabel.ToUpper().Contains(searchLabel) || label.ToUpper().Contains(searchLabel))
                    {
                        if (!slFiltered.ContainsKey(sLabel))
                        {
                            slFiltered.Add(sLabel, repoItem);
                        }
                    }
                }
                repoRepository = null;

                foreach (RepositoryItem repoItem in slFiltered.Values)
                {
                    ToolStripMenuItem tsMI = new ToolStripMenuItem();
                    tsMI.Tag         = repoItem;
                    tsMI.Text        = repoItem.ShortLabel;
                    tsMI.ToolTipText = string.Empty;
                    if (repoItem.Label != null && repoItem.Label != string.Empty)
                    {
                        tsMI.ToolTipText += repoItem.Label + "\r\n\r\n";
                    }
                    if (repoItem.Comments != null && repoItem.Comments != string.Empty)
                    {
                        tsMI.ToolTipText += repoItem.Comments + "\r\n\r\n";
                    }
                    if (repoItem.Information != null && repoItem.Information != string.Empty)
                    {
                        tsMI.ToolTipText += repoItem.Information + "\r\n\r\n";
                    }
                    repoToolStripMenuItem.DropDownItems.Add(tsMI);
                    // Limited to 50
                    if (repoToolStripMenuItem.DropDownItems.Count >= 50)
                    {
                        break;
                    }
                }
            }
            if (repoRepositoryConversion != null)
            {
                foreach (RepositoryConversionItem repoItem in repoRepositoryConversion.Items)
                {
                    string sLabel = repoItem.Title;

                    if (sLabel == null)
                    {
                        continue;
                    }

                    if (searchLabel == string.Empty || sLabel.ToUpper().Contains(searchLabel))
                    {
                        if (!slFiltered.ContainsKey(sLabel))
                        {
                            slFiltered.Add(sLabel, repoItem);
                        }
                    }
                }
                repoRepositoryConversion = null;

                foreach (RepositoryConversionItem repoItem in slFiltered.Values)
                {
                    ToolStripMenuItem tsMI = new ToolStripMenuItem();
                    tsMI.Tag         = repoItem;
                    tsMI.Text        = repoItem.Title;
                    tsMI.ToolTipText = string.Empty;
                    if (repoItem.InternalFormula != null && repoItem.InternalFormula != string.Empty)
                    {
                        tsMI.ToolTipText += repoItem.InternalFormula + "\r\n\r\n";
                    }
                    if (repoItem.Comments != null && repoItem.Comments != string.Empty)
                    {
                        tsMI.ToolTipText += repoItem.Comments + "\r\n\r\n";
                    }
                    if (repoItem.Information != null && repoItem.Information != string.Empty)
                    {
                        tsMI.ToolTipText += repoItem.Information + "\r\n\r\n";
                    }
                    repoToolStripMenuItem.DropDownItems.Add(tsMI);
                    // Limited to 50
                    if (repoToolStripMenuItem.DropDownItems.Count >= 50)
                    {
                        break;
                    }
                }
            }
            slFiltered = null;
        }