public Graph_History(Schematix.FSM.Constructor_Core core) { this.core = core; history = new List <HistoryElem>(); this.elem = new HistoryElem(core.Graph.Clone(), "Start value"); history.Add(elem); }
public void add(HistoryElem item) { int index = history.IndexOf(elem); if (index == history.Count - 1) { history.Add(item); elem = item; return; } history.RemoveRange(index + 1, (history.Count - index - 1)); history.Add(item); elem = item; }
public void SetPosition(string name) { foreach (Schematix.FSM.HistoryElem history_elem in history) { if (history_elem.Name == name) { int index = history.IndexOf(history_elem); elem = history.ElementAt <HistoryElem>(index); core.Graph = history_elem.Graph; core.Bitmap.UpdateBitmap(); core.form.Invalidate(); return; } } }
/// <summary> /// Отменить действие /// </summary> /// <returns></returns> public My_Graph UnDo() { Schematix.FSM.My_Graph graph = null; int index = history.IndexOf(elem); if (index <= 0) { graph = elem.Graph; } if (index > 0) { elem = history.ElementAt <HistoryElem>(index - 1); graph = elem.Graph; } return(graph.Clone()); }
/// <summary> /// Загрузить данные с потока /// </summary> /// <param name="stream"></param> public void OpenFile(Stream stream) { My_Graph item = null; item = My_Graph.OpenFile(stream); item.Core = this; Graph_History.History.Clear(); Graph = item; Bitmap.UpdateBitmap(); form.Invalidate(); HistoryElem newElem = AddToHistory("File Opened"); graph_history.SetAsSaved(); }
/// <summary> /// Повторить действие /// </summary> /// <returns></returns> public My_Graph ReDo() { Schematix.FSM.My_Graph graph = null; int index = history.IndexOf(elem); if (index == history.Count - 1) { elem = history.Last <HistoryElem>(); } else { if (index == -1) { elem = history.First <HistoryElem>(); } else { elem = history.ElementAt <HistoryElem>(index + 1); } } graph = elem.Graph; return(graph.Clone()); }