示例#1
0
        /// <summary>
        /// The saved context.
        /// </summary>
//        public new GenSavedContext SavedContext { get { return base.SavedContext; } private set { base.SavedContext = value; } }

        /// <summary>
        /// Create a new <see cref="SubClassTreeNode"/> for the selected subclass.
        /// </summary>
        /// <param name="parentNode">The tree node of the parent class of this subclass.</param>
        /// <param name="genDataBase">The data being navigated.</param>
        /// <param name="definition">The definition data for the data being navigated.</param>
        /// <param name="classId">The ClassId of this subclass.</param>
        public SubClassTreeNode(ClassTreeNode parentNode, GenDataBase genDataBase, Definition definition, int classId)
        {
            ClassId     = classId;
            ParentNode  = parentNode;
            GenDataBase = genDataBase;
            Definition  = definition;
            var    genDataDef = GenDataBase.GenDataDef;
            int    parentClassId;
            string parentClassName;
            Class  parentClass;

            Def = null;
            if (ParentNode == null)
            {
                SubClassBase = genDataBase.Root.SubClass[0];
            }
            else
            {
                parentClassId   = ParentNode.ClassId;
                parentClassName = genDataDef.GetClassName(parentClassId);
                SubClassBase    = ParentNode.GenObject.GetSubClass(genDataDef.GetClassName(classId));
                parentClass     = definition.ClassList.Find(parentClassName);
                var i = genDataDef.Classes[parentClassId].IndexOfSubClass(genDataDef.GetClassName(ClassId));
                SubClassDef = genDataDef.GetClassSubClasses(parentClassId)[i];
                if (parentClass != null)
                {
                    Def = parentClass.SubClassList[i];
                }
            }

            Text = genDataDef.GetClassName(ClassId) +
                   (SubClassDef != null && !string.IsNullOrEmpty(SubClassDef.Reference)
                       ? ":" + SubClassBase.Reference
                       : "");
            ImageIndex  = 2;
            ToolTipText = Text;
            Tag         = new SubClassViewModel(ParentNode == null ? null : ParentNode.GenObject.ParentSubClass, SubClassBase, Def,
                                                SubClassDef, SubClassDef != null && !string.IsNullOrEmpty(SubClassDef.Reference));

            for (var j = 0; j < SubClassBase.Count; j++)
            {
                Nodes.Add(new ClassTreeNode(this, GenDataBase, Definition, ClassId, SubClassBase[j]));
            }
        }
示例#2
0
        /// <summary>
        /// Add a new tree node of the current class.
        /// </summary>
        /// <returns>The added tree node.</returns>
        public override ClassTreeNode AddNewNode()
        {
            var parentClassName = ParentNode == null ? "" : ParentNode.ClassDef.Name;
            var className       = SubClassDef.SubClass.Name;

            if (string.IsNullOrEmpty(SubClassDef.ReferenceDefinition))
            {
                var parent    = ParentNode == null ? GenDataBase.Root : ParentNode.GenObject;
                var genObject = parent.CreateGenObject(className);
                var idx       = genObject.Definition.Properties.IndexOf("Name");
                if (idx >= 0)
                {
                    genObject.Attributes[idx] = "new";
                }
                var node = new ClassTreeNode(this, GenDataBase, Definition, ClassId, genObject);
                node.ViewModel.IsNew = true;
                node.ViewModel.Save();
                Nodes.Add(node);
                return(node);
            }
            return(null);
        }
示例#3
0
        internal bool MakeMove(ClassTreeNode node, ListMove move)
        {
            var nodeData = node.ViewModel;

            if (nodeData == null)
            {
                return(false);
            }
            var  index = Nodes.IndexOf(node);
            bool result;

            switch (move)
            {
            case ListMove.ToTop:
                result = MoveToTop(index, node);
                break;

            case ListMove.Up:
                result = MoveUp(index, node);
                break;

            case ListMove.Down:
                result = MoveDown(index, node);
                break;

            case ListMove.ToBottom:
                result = MoveToBottom(index, node);
                break;

            default:
                throw new ArgumentOutOfRangeException("move");
            }

            TreeView.SelectedNode = node;
            return(result);
        }