Exemple #1
0
        /// <summary>
        /// Select Project Command through command interface
        /// </summary>
        private void SelectProject(Object p)
        {
            ProjectModel selectedProject = GetProject((int)p);

            Globals.Project_ID         = (int)p;
            Globals.ProjectSelected    = true;
            ProjectSelected            = true;
            Globals.ProjectName        = selectedProject.ProjectName;
            Globals.ContractNo         = selectedProject.ContractNo;
            selectedProject.LastOpened = DateTime.Now;

            // Store the current DateTime in the selected project record so it can be used to sort the project list
            EDBEntities eDB = new EDBEntities();
            tblProject  Rec = eDB.tblProjects.Where(o => o.ID == selectedProject.ID).FirstOrDefault();

            Rec.LastOpened   = selectedProject.LastOpened;
            Rec.LastOpenedBy = Environment.UserName;
            eDB.SaveChanges();

            IsBackStageOpen = false;
            MainTitle       = Globals.ContractNo + Globals.ProjectName;
            TypeViewModelLocator.GetTypeVM();
            ObjectViewModelLocator.GetObjectVM();
            TemplateViewModelLocator.GetTemplateVM();
            PropertyViewModelLocator.GetPropertyVM();
            AspectViewModelLocator.GetAspectVM();
            AttributeViewModelLocator.GetAttributeVM();
            ObjectAssociationViewModelLocator.GetObjectAssociationVM();
            ObjectRequirementViewModelLocator.GetObjectRequirementVM();
            TemplateAssociationViewModelLocator.GetTemplateAssociationVM();
            TemplateRequirementViewModelLocator.GetTemplateRequirementVM();
        }
 public TemplateView()
 {
     InitializeComponent();
     DataContext = TemplateViewModelLocator.GetTemplateVM();
     PropertyTreeListView.DataContext            = PropertyViewModelLocator.GetPropertyVM();
     RequirementTreeListView.DataContext         = RequirementViewModelLocator.GetRequirementVM();
     TemplateAssociationTreeListView.DataContext = TemplateAssociationViewModelLocator.GetTemplateAssociationVM();
     TemplateRequirementTreeListView.DataContext = TemplateRequirementViewModelLocator.GetTemplateRequirementVM();
 }
        //TODO: fix hard code
        private void OnDrop(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
        {
            if (e.Data != null && e.AllowedEffects != DragDropEffects.None)
            {
                var             treeListViewName = (sender as RadTreeListView).Name;
                TreeListViewRow destination      = e.OriginalSource as TreeListViewRow ?? (e.OriginalSource as FrameworkElement).ParentOfType <TreeListViewRow>();
                switch (treeListViewName)
                {
                case "ObjectTreeListView":
                    ObjectViewModelLocator.GetObjectVM().MoveSelection(destination);
                    break;

                case "TemplateTreeListView":
                    TemplateViewModelLocator.GetTemplateVM().MoveSelection(destination);
                    break;

                case "PropertyTreeListView":
                    PropertyViewModelLocator.GetPropertyVM().MoveSelection(destination);
                    break;

                case "ObjectAssociationTreeListView":
                    ObjectAssociationViewModel objectAssociationViewModel = ObjectAssociationViewModelLocator.GetObjectAssociationVM();
                    objectAssociationViewModel.AssociateWithObject(destination);
                    objectAssociationViewModel.FilteredObjectAssociations.View.Refresh();
                    break;

                case "ObjectRequirementTreeListView":
                    ObjectRequirementViewModel objectRequirementViewModel = ObjectRequirementViewModelLocator.GetObjectRequirementVM();
                    objectRequirementViewModel.AssociateWithObject(destination);
                    objectRequirementViewModel.FilteredObjectRequirements.View.Refresh();
                    break;

                case "TemplateAssociationTreeListView":
                    TemplateAssociationViewModel templateAssociationViewModel = TemplateAssociationViewModelLocator.GetTemplateAssociationVM();
                    templateAssociationViewModel.AssociateWithTemplate(destination);
                    templateAssociationViewModel.FilteredTemplateAssociations.View.Refresh();
                    break;

                case "TemplateRequirementTreeListView":
                    TemplateRequirementViewModel templateRequirementViewModel = TemplateRequirementViewModelLocator.GetTemplateRequirementVM();
                    templateRequirementViewModel.AssociateWithTemplate(destination);
                    templateRequirementViewModel.FilteredTemplateRequirements.View.Refresh();
                    break;

                case "RequirementTreeListView":
                    RequirementViewModelLocator.GetRequirementVM().MoveSelection(destination);
                    break;
                }
            }
        }
Exemple #4
0
 private void LoadTemplateProperties(ObjectAssociationModel templateItem)
 {
     //var propertyItem = PropertyViewModelLocator.GetPropertyVM().GetProperty(objectAssociationItem.Association_ID, null);
     //if (templateItem != null)
     //{
     //objectAssociationItem.Name = templateItem.TemplateName;
     //objectAssociationItem.Description = templateItem.Description;
     //objectAssociationItem.AssociationType_ID = templateItem.TemplateType_ID;
     // and get any child items
     foreach (var itemAssociation in TemplateAssociationViewModelLocator.GetTemplateAssociationVM().TemplateAssociations)
     {
         if (itemAssociation.Template_ID == templateItem.Association_ID)
         {
             var propertyItem = PropertyViewModelLocator.GetPropertyVM().GetProperty(itemAssociation.Association_ID);
             if (propertyItem != null)
             {
                 ObjectAssociationModel item = new ObjectAssociationModel
                 {
                     ID                 = itemAssociation.ID,
                     Project_ID         = templateItem.Project_ID,
                     Object_ID          = templateItem.Object_ID,
                     Association_ID     = itemAssociation.Association_ID,
                     Name               = propertyItem.PropertyName,
                     Description        = propertyItem.Description,
                     AssociationType    = "TemplateProperty",
                     AssociationType_ID = itemAssociation.AssociationType_ID,
                     IsChanged          = false,
                     IsNew              = false,
                     ChildAssociations  = new TD.ObservableItemCollection <ObjectAssociationModel>()
                 };
                 templateItem.ChildAssociations.Add(item);
             }
         }
     }
     //}
     //else
     //{
     //    throw new System.InvalidOperationException(String.Format("Association without source\nTemplate ID: {0}\nFix in database", objectAssociationItem.Association_ID));
     //}
 }