コード例 #1
0
ファイル: MainWindow.cs プロジェクト: suvjunmd/Moritz
        private void MenuItemRebuildKrystalFamily_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show(
                "Re-expand and re-modulate all expansion and modulation krystals\n" +
                "in the krystals directory?\n\n" +
                "This will ensure that all krystal dependencies are up to date.",
                "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);

            if(result == DialogResult.OK)
            {
                KrystalFamily kFamily = new KrystalFamily(K.KrystalsFolder);
                kFamily.Rebuild();
                MessageBox.Show("All expansion and modulation krystals have been successfully recreated",
                    "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #2
0
ファイル: KrystalBrowser.cs プロジェクト: suvjunmd/Moritz
        private void InitializeKrystalBrowser()
        {
            this.Width = 650;
            this.Height = Screen.PrimaryScreen.WorkingArea.Height;
            this.Location = new Point(0, 0);
            this.splitContainer1.SplitterDistance = 190;
            this.splitContainer2.SplitterDistance = this.splitContainer1.SplitterDistance;

            if(_sendKrystal != null)
            {
                this.ReturnKrystalButton.Show();
                this.CloseButton.Hide();
            }
            else
            {
                this.ReturnKrystalButton.Hide();
                this.CloseButton.Show();
            }

            _krystalFamily = new KrystalFamily(this._krystalsFolder);
            SetKrystalFamilyTree();
            SetForKrystal(null);
        }
コード例 #3
0
ファイル: ExpansionEditor.cs プロジェクト: suvjunmd/Moritz
        /// <summary>
        /// The user can replace expanders and krystals using the Replace command.
        /// In order to replace (overwrite) an expander, the user loads a krystal which uses it, edits the
        /// expander, and replaces the krystal using its original name. The krystal's name includes its
        /// expander's signature (the portion of the krystal's name in brackets), so both the krystal and its
        /// expander are overwritten.
        /// To replace a krystal without changing the expander, load the krystal, expand it (with any new input(s)
        /// but without changing the expander), then replace the krystal and expander.
        /// When a krystal and/or expander are replaced, all the krystals in the krystals directory have to be
        /// rebuilt so as to preserve the relations between them. (Krystals contain references to expanders and 
        /// other krystals. Expanders contain references to other expanders.) The edited krystal may itself have
        /// changed as a result of this rebuilding (its input krystals may have changed), so it is reloaded when
        /// rebuilding has completed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItemReplace_Click(object sender, EventArgs e)
        {
            try
            {
                string expansionKrystalFilepath = GetExpansionKrystalFilepathFromReplaceFileDialog();
                if (expansionKrystalFilepath.Length > 0)
                {
                    bool abort = true;
                    string krystalName = Path.GetFileName(expansionKrystalFilepath);
                    CheckExpansionKrystalName(krystalName); // throws exception if name is invalid
                    string expanderName = K.ExpansionOperatorFilename(krystalName);
                    string expanderPath = K.KrystalsFolder + @"\" +  expanderName;
                    if (File.Exists(expanderPath))
                    {
                        string msg = "The following krystal and expander are about to be replaced:\n\n"
                            + "              krystal:\t" + krystalName + "\n"
                            + "         expander:\t" + expanderName
                            + "\n\nNote: the krystal and expander can only be replaced together.     \n\n"
                            + "When a krystal and expander are replaced, all the krystals in the\n"
                            + "krystals directory have to be rebuilt to maintain the consistency\n"
                            + "of the relationships between them. This may result in the current\n"
                            + "krystal changing as the result of its input krystals changing.\n"
                            + "Krystals contain references to expanders and other krystals.\n\n"
                            + "Replace this krystal and expander, rebuild all the other krystals\n"
                            + "and then reload the currently loaded krystal?\n\n";
                        if (MessageBox.Show(msg, "Replace and rebuild", MessageBoxButtons.YesNo, MessageBoxIcon.Warning,
                            MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                            abort = false;
                        else
                            abort = true;
                    }
                    else abort = false;

                    if (!abort)
                    {
                        _expander.Name = expanderName;
                        _outputKrystal.Name = krystalName;
                        _outputKrystal.Save(false, true); // save expander, but not krystal

                        KrystalFamily kFamily = new KrystalFamily(K.KrystalsFolder);
                        kFamily.Rebuild();

                        _outputKrystal = new ExpansionKrystal(expansionKrystalFilepath);
                        this.ExpandButton.Enabled = false;
                        this.ZoomLabel.Enabled = true;
                        this.ZoomComboBox.Enabled = true;
                        this.PercentLabel.Enabled = true;
                        LoadNewOutputKrystalIntoEditor();
                    }
                }
            }
            catch (ApplicationException ae)
            {
                MessageBox.Show(ae.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            //catch (SystemException ae)
            //{
            //    MessageBox.Show(ae.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            //}
        }