コード例 #1
0
 public CORelease(User creator, LocationEnum origin, PriorityEnum priority, params string[] controlobjects) : this(creator, origin, priority)
 {
     foreach (var co in controlobjects)
     {
         ControlObjects.Add(new ControlObject(co));
     }
 }
コード例 #2
0
        public void Paste()
        {
            foreach (var controllerItem in CopiedItems)
            {
                ControlObjectModel copiedcontrollerItem = new ControlObjectModel();
                copiedcontrollerItem.ID                   = Guid.NewGuid();
                copiedcontrollerItem.Project_ID           = controllerItem.Project_ID;
                copiedcontrollerItem.ObjectName           = controllerItem.ObjectName + "_1";
                copiedcontrollerItem.Description          = controllerItem.Description;
                copiedcontrollerItem.ControlObjectType_ID = controllerItem.ControlObjectType_ID;
                copiedcontrollerItem.IsChanged            = false;
                copiedcontrollerItem.IsNew                = true;
                copiedcontrollerItem.ChildControlObjects  = new TD.ObservableItemCollection <ControlObjectModel>();

                if (SelectedItem == null)
                {
                    copiedcontrollerItem.Parent_ID = null;
                    ControlObjects.Add(copiedcontrollerItem);
                }
                // Otherwise get the parent object and add the new object as a child
                else
                {
                    copiedcontrollerItem.Parent_ID = SelectedItem.ID;
                    SelectedItem.ChildControlObjects.Add(copiedcontrollerItem);
                }
                //SelectedItem = copiedcontrollerItem;
            }

            IsChanged = true;
        }
コード例 #3
0
        public void AddSibling()
        {
            // Instanciate a new object
            ControlObjectModel controllerItem = new ControlObjectModel
            {
                ID                   = Guid.NewGuid(),
                Project_ID           = Globals.Project_ID,
                ObjectName           = "New Object",
                Description          = "New Object Description",
                IsChanged            = false,
                IsNew                = true,
                ControlObjectType_ID = TypeViewModelLocator.GetTypeVM().GetTypeGroupID("Object"),
                ChildControlObjects  = new TD.ObservableItemCollection <ControlObjectModel>()
            };

            // If no item has been selected, put the object in the root of the tree
            if (SelectedItem == null)
            {
                controllerItem.Parent_ID = null;
                ControlObjects.Add(controllerItem);
            }
            // If the selected item is in the root, put the new object in the root also
            else if (SelectedItem.Parent_ID == null)
            {
                controllerItem.Parent_ID            = null;
                controllerItem.ControlObjectType_ID = SelectedItem.ControlObjectType_ID;
                ControlObjects.Insert(ControlObjects.IndexOf(SelectedItem) + 1, controllerItem);
            }
            // Otherwise get the parent object and add the new object as a child
            else
            {
                ControlObjectModel parentItem = GetController(SelectedItem.Parent_ID);
                controllerItem.Parent_ID            = SelectedItem.Parent_ID;
                controllerItem.ControlObjectType_ID = SelectedItem.ControlObjectType_ID;
                parentItem.ChildControlObjects.Insert(parentItem.ChildControlObjects.IndexOf(SelectedItem) + 1, controllerItem);
            }
            IsChanged = true;
            OnFocusRequested("ObjectName");
        }
コード例 #4
0
        /// <summary>
        /// Loads the records from the DbSet into the ViewModel. This function designed for recursive use
        /// </summary>
        /// <param name="Project_ID"></param>
        /// <param name="Parent_ID"></param>
        /// <returns>Observable collection of VMControlObject</returns>
        private TD.ObservableItemCollection <ControlObjectModel> Load(Guid?Parent_ID)
        {
            TD.ObservableItemCollection <ControlObjectModel> ChildControlObjects = new TD.ObservableItemCollection <ControlObjectModel>();
            // TD.ObservableItemCollection<ControlObjectModel> personalLayout = new TD.ObservableItemCollection<ControlObjectModel>();

            using (EDBEntities eDB = new EDBEntities())
            {
                foreach (tblControlObject Rec in (from o in eDB.tblControlObjects where (o.Project_ID == Globals.Project_ID && o.Parent_ID == Parent_ID) orderby o.ObjectName select o))
                {
                    ControlObjectModel controllerItem = new ControlObjectModel
                    {
                        ID                   = Rec.ID,
                        Parent_ID            = Rec.Parent_ID,
                        Project_ID           = Rec.Project_ID,
                        ObjectName           = Rec.ObjectName,
                        Description          = Rec.Description,
                        ControlObjectType_ID = (int)Rec.ControlObjectType_ID,
                        IsChanged            = false,
                    };

                    // Load ControlObject with a parent_ID equal to the ID of this object
                    controllerItem.ChildControlObjects = Load(Rec.ID);

                    // If the parent ID is null, this is a root object and needs to be added to the collection that is the itemsource of the object tree
                    // Else it is a child object which needs to be added to the childobjectlist
                    if (Rec.Parent_ID == null)
                    {
                        ControlObjects.Add(controllerItem);
                    }
                    else
                    {
                        ChildControlObjects.Add(controllerItem);
                    }
                }
            }
            IsChanged = false;
            return(ChildControlObjects);
        }