コード例 #1
0
ファイル: Controller.cs プロジェクト: plutonowy/planer2
 public Controller(Model mod)
 {
     this.mod = mod;
     subNodesList = mod.GetNodesList(0);
     prevSubNodesList = new List<Node>();
     currentNode = null;
 }
コード例 #2
0
ファイル: Controller.cs プロジェクト: plutonowy/planer2
        private void Cd(params string[] args)
        {
            if (args [1] == "..")
            {
                if(prevSubNodesList.Count>0)
                {
                    int lastNode = prevSubNodesList.Count-1;
                    this.currentNode = mod.GetNode(prevSubNodesList[lastNode].GetID());
                    ReloadLists();
                }
                else
                {
                    this.currentNode = null;
                    ReloadLists();
                }
            }
            else
            {
                if(subNodesList.Count==0) return;
                foreach(Node temp in subNodesList)
                {
                    if(temp.name == args[1])
                    {
                        currentNode = temp;

                        ReloadLists();
                        break;
                    }
                }
            }
        }
コード例 #3
0
ファイル: Controller.cs プロジェクト: plutonowy/planer2
 public Controller(string path)
 {
     this.mod = new Model(path);
     subNodesList = mod.GetNodesList(0);
     prevSubNodesList = new List<Node>();
     currentNode = null;
 }
コード例 #4
0
ファイル: Command.cs プロジェクト: plutonowy/planer2
 public override void realizeCommand(params string[] args)
 {
     View.WriteMessage(string.Format("dodaje nowy wezel o nazwie {0}", args[1]));
     UInt32 newID = 1000; //tymczasowa wartosc
     Node newNode = new Node(args[1],StateOfNode.uncompleted,newID,con.currentLvl+1);
     if(con.currentLvl!=0)
         mod.NewNode(con.currentNode.GetID(),newNode);
     else mod.NewNode(true,newNode);
     con.subNodesList.Add(newNode);
 }
コード例 #5
0
ファイル: Controller.cs プロジェクト: plutonowy/planer2
 private void AddNode(params string[] args)
 {
     Node newNode = new Node (args [1]);
     if (currentNode != null) {
         mod.NewNode (currentNode.GetID (), newNode);
         subNodesList = mod.GetSubNodesList (currentNode.GetID ());
     }
     else
     {
         mod.NewNode (true, newNode);
         subNodesList=mod.GetNodesList(0);
     }
 }
コード例 #6
0
ファイル: Command.cs プロジェクト: plutonowy/planer2
 void DestroyChildren(Node current)
 {
     List<Node> children = mod.GetSubNodesList (current.GetID ());
     if (children.Count == 0)
         mod.Delete (current.GetID());
     else
     {
         foreach(Node tmp in children)
         {
             DestroyChildren(tmp);
             children = mod.GetSubNodesList(current.GetID());
         }
         DestroyChildren(current);
     }
 }
コード例 #7
0
ファイル: Model.cs プロジェクト: plutonowy/planer2
        // overload, now you can send Node object like a argument
        private void SetReaderOn(Node nod)
        {
            reader.DiscardBufferedData();
            reader.BaseStream.Position = 0;//zabezpieczyc przed reader bez sciezki do pliku

            string line;

            while ((line = reader.ReadLine()) != null)
            {
                if(ParseID(line) == nod.GetID()) return;
            }

            reader.BaseStream.Position = 0;
        }
コード例 #8
0
ファイル: Model.cs プロジェクト: plutonowy/planer2
        private Node ParseNode(string line)
        {
            Node newNode = new Node();

            newNode.name = ParseName(line);
            newNode.SetID(ParseID(line));
            newNode.state = ParseState(line);
            newNode.Level = ParseLevel(line);

            return newNode;
        }
コード例 #9
0
ファイル: Model.cs プロジェクト: plutonowy/planer2
        public void Save(Node NodeToSave)
        {
            reader.DiscardBufferedData();
            reader.BaseStream.Position = 0;

            string line;

            while ((line = reader.ReadLine()) != null)
            {
                if (ParseID(line) == NodeToSave.GetID())
                {
                    line = NodeToSave.ToString ();
                }

                writer.WriteLine (line);
            }

            reader.BaseStream.Position=0;

            ReloadStreams();
        }
コード例 #10
0
ファイル: Model.cs プロジェクト: plutonowy/planer2
        public void NewNode(bool First, Node NewNodeToSave)
        {
            NewNodeToSave.Level=0;
            if(reader.BaseStream.Length != 0) NewNodeToSave.SetID(AssignNewID());
            else NewNodeToSave.SetID(0);

            string lineToWrite = NewNodeToSave.ToString();

            string line;
            reader.DiscardBufferedData();
            reader.BaseStream.Position = 0;

            writer.BaseStream.Position=0;

            writer.WriteLine(lineToWrite);

            while ((line = reader.ReadLine()) != null)
            {
                writer.WriteLine(line);
            }

            ReloadStreams();
        }
コード例 #11
0
ファイル: Model.cs プロジェクト: plutonowy/planer2
        public void NewNode(UInt32 ParentID, Node NewNodeToSave)
        {
            reader.BaseStream.Position = 0;
            //writer.BaseStream.Position = 0;

            NewNodeToSave.SetID(AssignNewID());
            NewNodeToSave.Level = GetLevel(ParentID) + 1;
            string newLineToWrite = NewNodeToSave.ToString ();

            string line;

            reader.DiscardBufferedData();
            while ((line = reader.ReadLine()) != null)
            {
                writer.WriteLine(line);

                if(ParseID(line) == ParentID)
                {
                    writer.WriteLine(newLineToWrite);
                }
            }

            ReloadStreams();
        }