Exemplo n.º 1
0
 private void NewConstantKrystalMenuItem_Click(object sender, EventArgs e)
 {
     using (NewConstantKrystalDialog dlg = new NewConstantKrystalDialog())
     {
         DialogResult result = dlg.ShowDialog();
         if (result == DialogResult.OK)
         {
             String constantValueStr = dlg.ConstantKrystalValue;
             if (constantValueStr.Length > 0)
             {
                 uint            constantValue = uint.Parse(constantValueStr);
                 ConstantKrystal ck            = new ConstantKrystal(K.UntitledKrystalName, constantValue);
                 ck.Save(false);  // false: do not ovewrite existing files
             }
         }
     }
 }
Exemplo n.º 2
0
 private void OpenConstantKrystalMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         string constantKrystalFilepath = K.GetFilepathFromOpenFileDialog(K.DialogFilterIndex.constant);
         if (constantKrystalFilepath.Length > 0)
         {
             ConstantKrystal          constantKrystal = new ConstantKrystal(constantKrystalFilepath);
             NewConstantKrystalDialog dlg             = new NewConstantKrystalDialog();
             dlg.Text = constantKrystal.Name;
             dlg.SetButtons();
             dlg.ConstantKrystalValue = constantKrystal.MaxValue.ToString();
             dlg.Show();
         }
     }
     catch (ApplicationException ae)
     {
         MessageBox.Show(ae.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
Exemplo n.º 3
0
 private void NewConstantKrystalMenuItem_Click(object sender, EventArgs e)
 {
     using(NewConstantKrystalDialog dlg = new NewConstantKrystalDialog())
     {
         DialogResult result = dlg.ShowDialog();
         if(result == DialogResult.OK)
         {
             String constantValueStr = dlg.ConstantKrystalValue;
             if(constantValueStr.Length > 0)
             {
                 uint constantValue = uint.Parse(constantValueStr);
                 ConstantKrystal ck = new ConstantKrystal(K.UntitledKrystalName, constantValue);
                 ck.Save(false);  // false: do not ovewrite existing files
             }
         }
     }
 }
Exemplo n.º 4
0
 private void OpenConstantKrystalMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         string constantKrystalFilepath = K.GetFilepathFromOpenFileDialog(K.DialogFilterIndex.constant);
         if (constantKrystalFilepath.Length > 0)
         {
             ConstantKrystal constantKrystal = new ConstantKrystal(constantKrystalFilepath);
             NewConstantKrystalDialog dlg = new NewConstantKrystalDialog();
             dlg.Text = constantKrystal.Name;
             dlg.SetButtons();
             dlg.ConstantKrystalValue = constantKrystal.MaxValue.ToString();
             dlg.Show();
         }
     }
     catch (ApplicationException ae)
     {
         MessageBox.Show(ae.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
Exemplo n.º 5
0
        public static Krystal LoadKrystal(string pathname)
        {
            Krystal krystal = null;
            string filename = Path.GetFileName(pathname);
            if(IsConstantKrystalFilename(filename))
                krystal = new ConstantKrystal(pathname);
            else if(IsLineKrystalFilename(filename))
                krystal = new LineKrystal(pathname);
            else if(IsExpansionKrystalFilename(filename))
                krystal = new ExpansionKrystal(pathname);
            else if(IsShapedExpansionKrystalFilename(filename))
                krystal = new ShapedExpansionKrystal(pathname);
            else if(IsModulationKrystalFilename(filename))
                krystal = new ModulationKrystal(pathname);
            else if(IsPermutationKrystalFilename(filename))
                krystal = new PermutationKrystal(pathname);

            else
            {
                string msg = pathname + "\r\n\r\n is not a known type of krystal.";
                MessageBox.Show(msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            return krystal;
        }
Exemplo n.º 6
0
        public void SetForKrystal(string filename)
        {
            this.SuspendLayout();
            if (filename != null && K.IsKrystalFilename(filename))
            {
                string pathname = _krystalsFolder + "\\" + filename;
                _krystal = K.LoadKrystal(pathname);
            }

            if (_ancestorsTreeView != null)
            {
                KrystalAncestorsTreeView tv = this.splitContainer2.Panel1.Controls[0] as KrystalAncestorsTreeView;
                this.splitContainer2.Panel1.Controls.Clear();
                tv.Dispose();
            }
            // if filename is null, _krystal is null here
            _ancestorsTreeView              = new KrystalAncestorsTreeView(_krystal, _krystalFamily.DependencyList);
            _ancestorsTreeView.AfterSelect += new TreeViewEventHandler(this.AncestorsTreeView_AfterSelect);
            this.splitContainer2.Panel1.Controls.Add(_ancestorsTreeView);

            ConstantKrystal        ck = _krystal as ConstantKrystal;
            LineKrystal            lk = _krystal as LineKrystal;
            ExpansionKrystal       xk = _krystal as ExpansionKrystal;
            ShapedExpansionKrystal sk = _krystal as ShapedExpansionKrystal;
            ModulationKrystal      mk = _krystal as ModulationKrystal;
            PermutationKrystal     pk = _krystal as PermutationKrystal;

            if (ck != null)
            {
                this.BasicData.Text = string.Format("Constant Krystal: {0}   Level: {1}   Value: {2}",
                                                    _krystal.Name, _krystal.Level.ToString(), _krystal.MaxValue.ToString());
                SetForConstantKrystal();
            }
            else if (lk != null)
            {
                this.BasicData.Text = string.Format("Line Krystal: {0}    Level: {1}    Range of Values: {2}..{3}",
                                                    _krystal.Name, _krystal.Level.ToString(), _krystal.MinValue.ToString(), _krystal.MaxValue.ToString());
                SetForLineKrystal();
            }
            else if (xk != null)
            {
                this.BasicData.Text = string.Format("Expansion Krystal: {0}   Expander: {1}   Level: {2}   Range of Values: {3}..{4}",
                                                    _krystal.Name, xk.Expander.Name, _krystal.Level.ToString(), _krystal.MinValue.ToString(), _krystal.MaxValue.ToString());
                SetForExpansionKrystal(xk);
            }
            else if (sk != null)
            {
                this.BasicData.Text = string.Format("Shaped Expansion Krystal: {0}   Expander: {1}   Level: {2}   Range of Values: {3}..{4}",
                                                    _krystal.Name, sk.Expander.Name, _krystal.Level.ToString(), _krystal.MinValue.ToString(), _krystal.MaxValue.ToString());
                SetForShapedExpansionKrystal(sk);
            }
            else if (mk != null)
            {
                this.BasicData.Text = string.Format("Modulation Krystal: {0}   Modulator: {1}   Level: {2}   Range of Values: {3}..{4}",
                                                    _krystal.Name, mk.Modulator.Name, _krystal.Level.ToString(), _krystal.MinValue.ToString(), _krystal.MaxValue.ToString());
                SetForModulationKrystal(mk);
            }
            else if (pk != null)
            {
                string sortFirstString;
                if (pk.SortFirst)
                {
                    sortFirstString = "true";
                }
                else
                {
                    sortFirstString = "false";
                }

                this.BasicData.Text = string.Format("Permutation Krystal: {0}   Level: {1}   pLevel: {2}   sortFirst: {3}   Range of Values: {4}..{5}",
                                                    _krystal.Name, _krystal.Level.ToString(), pk.PermutationLevel.ToString(), sortFirstString, _krystal.MinValue.ToString(), _krystal.MaxValue.ToString());
                SetForPermutationKrystal(pk);
            }
            else // _krystal == null
            {
                this.BasicData.Text = "";
                SetForNoKrystal();
            }

            if (_krystal != null)
            {
                if (_selectedTreeView == null || _selectedTreeView.Equals(this._krystalFamilyTreeView) == false)
                {
                    SelectNodeInFamilyTree(_krystal.Name);
                }
                SetFirstAncestorAppearance();
            }
            this.ResumeLayout();
        }