private void NewLineKrystalMenuItem_Click(object sender, EventArgs e) { using (NewLineKrystalDialog dlg = new NewLineKrystalDialog()) { DialogResult result = dlg.ShowDialog(); if (result == DialogResult.OK) { string lineValue = dlg.LineKrystalValue; if (lineValue.Length > 0) { LineKrystal lk = new LineKrystal(K.UntitledKrystalName, lineValue); lk.Save(false); // false: do not ovewrite existing files } } } }
private void OpenLineKrystalMenuItem_Click(object sender, EventArgs e) { try { string lineKrystalFilepath = K.GetFilepathFromOpenFileDialog(K.DialogFilterIndex.line); if (lineKrystalFilepath.Length > 0) { LineKrystal lineKrystal = new LineKrystal(lineKrystalFilepath); NewLineKrystalDialog dlg = new NewLineKrystalDialog(); dlg.Text = lineKrystal.Name; dlg.SetButtons(); dlg.LineKrystalValue = K.GetStringOfUnsignedInts(lineKrystal.Strands[0].Values); dlg.Show(); } } catch (ApplicationException ae) { MessageBox.Show(ae.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void SetForLineKrystal(LineKrystal lineKrystal) { this.Controls.Remove(StrandsTreeView); StringBuilder sb = new StringBuilder(); int nValues = 0; foreach(uint value in lineKrystal.Strands[0].Values) { sb.Append(", "); sb.Append(value.ToString()); nValues++; } sb.Remove(0, 2); sb.Insert(0, "Line: "); LineStrandLabel.Text = sb.ToString(); StrandsTreeView.Nodes.Clear(); TreeNode tn = new TreeNode(LineStrandLabel.Text); StrandsTreeView.Nodes.Add(tn); this.Width = LineStrandLabel.Width + 14; this.Height = 48; }
private void SetForLineKrystal(LineKrystal lineKrystal) { this.Controls.Remove(StrandsTreeView); StringBuilder sb = new StringBuilder(); int nValues = 0; foreach (uint value in lineKrystal.Strands[0].Values) { sb.Append(", "); sb.Append(value.ToString()); nValues++; } sb.Remove(0, 2); sb.Insert(0, "Line: "); LineStrandLabel.Text = sb.ToString(); StrandsTreeView.Nodes.Clear(); TreeNode tn = new TreeNode(LineStrandLabel.Text); StrandsTreeView.Nodes.Add(tn); this.Width = LineStrandLabel.Width + 14; this.Height = 48; }
private void OpenLineKrystalMenuItem_Click(object sender, EventArgs e) { try { string lineKrystalFilepath = K.GetFilepathFromOpenFileDialog(K.DialogFilterIndex.line); if (lineKrystalFilepath.Length > 0) { LineKrystal lineKrystal = new LineKrystal(lineKrystalFilepath); NewLineKrystalDialog dlg = new NewLineKrystalDialog(); dlg.Text = lineKrystal.Name; dlg.SetButtons(); dlg.LineKrystalValue = K.GetStringOfUnsignedInts(lineKrystal.Strands[0].Values); dlg.Show(); } } catch (ApplicationException ae) { MessageBox.Show(ae.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void NewLineKrystalMenuItem_Click(object sender, EventArgs e) { using(NewLineKrystalDialog dlg = new NewLineKrystalDialog()) { DialogResult result = dlg.ShowDialog(); if(result == DialogResult.OK) { string lineValue = dlg.LineKrystalValue; if(lineValue.Length > 0) { LineKrystal lk = new LineKrystal(K.UntitledKrystalName, lineValue); lk.Save(false); // false: do not ovewrite existing files } } } }
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; }
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(); }