コード例 #1
0
 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);
 }
コード例 #2
0
        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;
        }
コード例 #3
0
 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;
         }
     }
 }
コード例 #4
0
        /// <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());
        }
コード例 #5
0
        /// <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();
        }
コード例 #6
0
        /// <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());
        }