private void toolStripMenuItemSetting_Click(object sender, EventArgs e) { Form form; form = new SettingForm((p) => this.parameters = p, this.parameters); form.ShowDialog(this); }
private void StateLoad(string path, bool dialog) { TreeNode root; Dictionary <string, Value> values; int version; if (this.treeViewValue.Nodes.Count < 1) { return; } root = this.treeViewValue.Nodes[0]; root.Nodes.Clear(); try { using (BinaryReader reader = new BinaryReader(new FileStream(path, FileMode.Open), Encoding.UTF8)) { values = new Dictionary <string, Value> (); version = reader.ReadInt32(); if (version < 1 || version > 2) { MessageBox.Show(this, string.Format(CultureInfo.InvariantCulture, "Incompatible file format")); return; } if (ValueAccessor.Load(reader, values)) { foreach (KeyValuePair <string, Value> pair in values) { root.Nodes.Add(this.NodeCreate(pair.Key, pair.Value)); } } this.parameters = new SettingForm.Parameters { BlockBegin = reader.ReadString(), BlockContinue = reader.ReadString(), BlockEnd = reader.ReadString(), TrimmerIndex = version > 1 ? reader.ReadInt32() : TrimmerCollection.DEFAULT_INDEX }; this.textBoxInput.Text = reader.ReadString(); } root.ExpandAll(); if (dialog) { MessageBox.Show(this, string.Format(CultureInfo.InvariantCulture, "State successfully loaded from \"{0}\".", path), "File save successfull", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch { MessageBox.Show(this, string.Format(CultureInfo.InvariantCulture, "Cannot open input file \"{0}\"", path), "File load error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void toolStripMenuItemSetting_Click(object sender, EventArgs e) { Form form; form = new SettingForm ((p) => this.parameters = p, this.parameters); form.ShowDialog (this); }
private void StateLoad(string path, bool dialog) { TreeNode root; Dictionary<string, Value> values; int version; if (this.treeViewValue.Nodes.Count < 1) return; root = this.treeViewValue.Nodes[0]; root.Nodes.Clear (); try { using (BinaryReader reader = new BinaryReader (new FileStream (path, FileMode.Open), Encoding.UTF8)) { values = new Dictionary<string, Value> (); version = reader.ReadInt32 (); if (version < 1 || version > 2) { MessageBox.Show (this, string.Format (CultureInfo.InvariantCulture, "Incompatible file format")); return; } if (ValueAccessor.Load (reader, values)) { foreach (KeyValuePair<string, Value> pair in values) root.Nodes.Add (this.NodeCreate (pair.Key, pair.Value)); } this.parameters = new SettingForm.Parameters { BlockBegin = reader.ReadString (), BlockContinue = reader.ReadString (), BlockEnd = reader.ReadString (), TrimmerIndex = version > 1 ? reader.ReadInt32 () : TrimmerCollection.DEFAULT_INDEX }; this.textBoxInput.Text = reader.ReadString (); } root.ExpandAll (); if (dialog) MessageBox.Show (this, string.Format (CultureInfo.InvariantCulture, "State successfully loaded from \"{0}\".", path), "File save successfull", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { MessageBox.Show (this, string.Format (CultureInfo.InvariantCulture, "Cannot open input file \"{0}\"", path), "File load error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }