Пример #1
0
        //
        public String AddNewImage(String ParentNodeString, PropertyChangedEventHandler evtPropertyChange)
        {
            String     new_label   = "";
            BaseStruct parent_node = m_ObjectList;


            try
            {
                //
                if (IsNameAvailable(m_iObjectCounter.ToString()) == false)
                {
                    return("");
                }

                // Find the selected node to be the Parent
                if (ParentNodeString != "ROOT")
                {
                    // Find the selected node to be a parent
                    BaseStruct obj = m_ObjectList.FindChildNode(m_ObjectList, ParentNodeString);
                    if (obj != null)
                    {
                        parent_node = obj;
                    }
                }

                // Add new node into the root
                using (ImageStruct obj = new ImageStruct())
                {
                    obj.Name = m_iObjectCounter.ToString();

                    //
                    parent_node.AddChildNode(obj);

                    //
                    new_label            = "image_" + obj.Name;
                    obj.PropertyChanged += evtPropertyChange;
                }

                //
                m_iObjectCounter++;
            }
            catch (Exception)
            {
                new_label = "";
            }

            return(new_label);
        }
Пример #2
0
        //
        public object GetObject(String strName)
        {
            BaseStruct obj = null;


            try
            {
                string[] piece = strName.Split('_');
                if (piece.Length >= 2)
                {
                    obj = m_ObjectList.FindChildNode(m_ObjectList, piece[1]);
                }
            }
            catch (Exception)
            {
            }

            return(obj);
        }
Пример #3
0
        //
        public BaseStruct FindChildNode(BaseStruct Obj, String NodeName)
        {
            BaseStruct ret = null;

            foreach (BaseStruct bs in Obj.m_ChildNodes)
            {
                if (bs.m_ChildNodes.Count > 0)
                {
                    ret = FindChildNode(bs, NodeName);
                    if (ret != null)
                    {
                        return(ret);
                    }
                }
                //
                if (bs.Name == NodeName)
                {
                    ret = bs;
                    break;
                }
            }

            return(ret);
        }
Пример #4
0
 //
 public ObjectManage()
 {
     m_ObjectList     = new BaseStruct();
     m_iObjectCounter = 1;
 }
Пример #5
0
 //
 public void AddChild(BaseStruct Node)
 {
     AddChildNode(Node);
 }
Пример #6
0
 //
 public void AddChildNode(BaseStruct Obj)
 {
     m_ChildNodes.Add(Obj);
 }