/// <summary> /// Load a file /// </summary> /// <param name="sender">sender</param> /// <param name="e">arg</param> private void appLoadItem_Click(object sender, EventArgs e) { if (FunLab.IsDirty) { DialogResult dr = MessageBox.Show("Save current ?", "Not saved", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { FunLab.Save(ref this.path, ref this.fileName, po); } } try { if (FunLab.Load(ref this.path, ref this.fileName, ref po)) { this.Text = "Editor - " + this.fileName; this.stored.ForEach(x => { x.Close(); x.Dispose(); }); this.stored.Clear(); this.undoPos = 0; vars.BeginUpdate(); vars.Items.Clear(); FunLab.FillVars(vars, po); vars.EndUpdate(); datas.BeginUpdate(); datas.Items.Clear(); FunLab.FillData(datas, po); datas.EndUpdate(); txtSource.Text = po.ToString(); this.AddUndo(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Not loaded", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Redo /// </summary> /// <param name="sender">sender</param> /// <param name="e">arg</param> private void editRedoItem_Click(object sender, EventArgs e) { if (this.undoPos < this.stored.Count) { MemoryStream mem = this.stored[this.undoPos]; ++this.undoPos; mem.Seek(0, SeekOrigin.Begin); PrinterObject previous = PrinterObject.Load(mem); po = previous as PrinterObject; vars.BeginUpdate(); vars.Items.Clear(); FunLab.FillVars(vars, po); vars.EndUpdate(); datas.BeginUpdate(); datas.Items.Clear(); FunLab.FillData(datas, po); datas.EndUpdate(); txtSource.Text = po.ToString(); FunLab.IsDirty = true; this.Text = "Editor - " + this.fileName + " *"; } }