Example #1
0
        public void UpdateText()
        {
            string s;

            switch (c.JointPosition)
            {
            case RcJointPosition.North:
                s = "N:";
                break;

            case RcJointPosition.South:
                s = "S:";
                break;

            case RcJointPosition.East:
                s = "E:";
                break;

            case RcJointPosition.West:
                s = "W:";
                break;

            default:
                s = "";
                break;
            }
            this.Text       = s + c.ToString();
            this.ImageIndex = (int)RcChipBase.CheckType(c);
        }
Example #2
0
        private void tvModel_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
#if false
            RcTreeNode rcnode = (RcTreeNode)e.Node;

            RcChipBase c;
            c = RcChipBase.Parse(datasource, e.Label);

            if (c is RcChipCowl && Array.Exists(rcnode.Chip.Child, x => !(x is RcChipCowl)))
            {
                if (
                    MessageBox.Show("派生チップにカウル以外のチップが存在します。すべてカウルに変更しますか?", "ツリービュー編集", MessageBoxButtons.YesNo)
                    == DialogResult.Yes)
                {
                    for (int i = 0; i < RcData.ChildCapasity; i++)
                    {
                        rcnode.Chip.Child[i] = rcnode.Chip.Child[i].ChangeType(RcChipType.Cowl);
                    }
                }
                else
                {
                }
            }
#else
            e.CancelEdit = true;
#endif
        }
Example #3
0
        public static RcChipCore Parse(string modelData, RcChipCore coreChip, RcData gen)
        {
            char openBrace  = char.Parse("{");
            char closeBrace = char.Parse("}");

            modelData = modelData.Replace(" ", "").Replace("\t", "").Replace("\n", "").Replace("\r", "");
            string[]           blocks    = modelData.Split(openBrace, closeBrace);
            Stack <RcChipBase> chipstack = new Stack <RcChipBase>();
            RcChipBase         buff;

            for (int i = 0; i < blocks.Length; i++)
            {
                if (blocks[i].ToLower().StartsWith("core"))
                {
                    coreChip.Read(blocks[i]);
                    chipstack.Push(coreChip);
                }
                else if (blocks[i] == "")
                {
                    if (chipstack.Count == 1)
                    {
                        break;
                    }
                    buff = (RcChipBase)chipstack.Pop();
                    ((RcChipBase)chipstack.Peek()).Add(buff.JointPosition, buff);
                }
                else
                {
                    chipstack.Push(RcChipBase.Parse(gen, blocks[i]));
                }
            }

            return((RcChipCore)chipstack.Pop());
        }
Example #4
0
 public RcTreeNode(RcChipBase chip) : base()
 {
     this.Chip       = chip;
     this.ImageIndex = this.SelectedImageIndex = (int)RcChipBase.CheckType(chip);
     if (Array.Exists(chip.Child, x => x != null))
     {
         foreach (var c in chip.Child)
         {
             if (c != null)
             {
                 this.Nodes.Add(new RcTreeNode(c));
             }
         }
     }
 }
Example #5
0
 public RcTreeNode Find(RcChipBase chip)
 {
     if (this.Chip == chip)
     {
         return(this);
     }
     else
     {
         foreach (TreeNode tn in this.Nodes)
         {
             RcTreeNode rctn = (RcTreeNode)tn;
             RcTreeNode ret  = rctn.Find(chip);
             if (ret != null)
             {
                 return(ret);
             }
         }
     }
     return(null);
 }
Example #6
0
        //	[Obsolete("未完成です。ずっと日の目を見ないかも。")]
        public void UpdateTree(RcChipBase updateRoot)
        {
            RcTreeNode root = ((RcTreeNode)tvModel.Nodes[0]).Find(updateRoot);

            if (root == null)
            {
                // まだないチップ -> 親をアップデート
                if (updateRoot.Parent == null)
                {
                    GenerateTree();
                    return;
                }
                Debug.WriteLine(updateRoot.Parent, "Parent Update");
                UpdateTree(updateRoot.Parent);
                root = ((RcTreeNode)tvModel.Nodes[0]).Find(updateRoot);
                if (root == null)
                {
                    throw new ArgumentException("ツリービューの更新に失敗しました。");
                }
            }

            int childCount = 0;

            for (int i = 0; i < RcData.ChildCapasity; i++)
            {
                if (updateRoot.Child[i] == null)
                {
                    continue;
                }
                childCount++;
                var childChip = updateRoot.Child[i];
                var childNode = root.Find(childChip);
                int nodeIndex = root.Nodes.IndexOf(childNode);

                if (childNode == null)
                {
                    // 追加
                    RcTreeNode n;
                    root.Nodes.Insert(i, n = new RcTreeNode(childChip));
                    Debug.WriteLine(n, "New node");
                }
                else if (nodeIndex != i)
                {
                    // 間にあるノードを削除
                    List <TreeNode> nodesToDelete = new List <TreeNode>();
                    for (int j = i; j < nodeIndex; j++)
                    {
                        nodesToDelete.Add(root.Nodes[j]);
                    }
                    foreach (var n in nodesToDelete)
                    {
                        root.Nodes.Remove(n);
                        Debug.WriteLine(n, "Delete node");
                    }
                }
            }

            Debug.WriteLine(root, "Update text");
            root.UpdateText();
            if (updateRoot is RcChipCowl)
            {
                root.Collapse();
            }
            else
            {
                root.Expand();
            }
        }