コード例 #1
0
ファイル: PartsView.cs プロジェクト: radtek/Shopdrawing
        private void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            PartInPartsExplorer part = (sender as FrameworkElement).DataContext as PartInPartsExplorer;

            if (part == null || e.ClickCount <= 1)
            {
                return;
            }
            this.PartsManager.OnDoubleClickItem(part);
        }
コード例 #2
0
ファイル: PartsModel.cs プロジェクト: radtek/Shopdrawing
        private void UpdateElementTimelineItem(SceneElement element, PartInPartsExplorer part)
        {
            if (element == null || element.ViewModel == null || (element.ViewModel.DesignerContext == null || element.ViewModel.TimelineItemManager == null))
            {
                return;
            }
            ElementTimelineItem elementTimelineItem = element.ViewModel.TimelineItemManager.FindTimelineItem((SceneNode)element) as ElementTimelineItem;

            if (elementTimelineItem == null)
            {
                return;
            }
            this.changedObjectTreeElements = true;
            elementTimelineItem.Invalidate();
            elementTimelineItem.PartStatus = part.Status;
            if (part.Status != PartStatus.WrongType)
            {
                return;
            }
            elementTimelineItem.WronglyAssignedPartCorrectType = part.TargetType.Name;
        }
コード例 #3
0
ファイル: PartsModel.cs プロジェクト: radtek/Shopdrawing
 public void UpdatePartsFromMetadata()
 {
     if (!this.IsEnabled)
     {
         this.parts.Clear();
         this.PartsList.Clear();
         this.lastEditingContainer = (SceneNode)null;
     }
     else
     {
         List <TemplatePartAttributeRecord> list = new List <TemplatePartAttributeRecord>((IEnumerable <TemplatePartAttributeRecord>)ProjectAttributeHelper.GetTemplatePartAttributes(this.TargetTemplate.ProjectContext.ResolveType(this.TargetTemplate.ControlTemplateTargetTypeId), (ITypeResolver)ProjectContext.GetProjectContext(this.viewModel.ProjectContext)));
         list.Sort((Comparison <TemplatePartAttributeRecord>)((first, second) => string.Compare(first.NameAttribute, second.NameAttribute, StringComparison.CurrentCulture)));
         this.parts.Clear();
         this.PartsList.Clear();
         foreach (TemplatePartAttributeRecord partAttributeRecord in list)
         {
             if (!string.IsNullOrEmpty(partAttributeRecord.NameAttribute) && !(partAttributeRecord.TypeAttribute == (Type)null))
             {
                 ITypeId type = (ITypeId)this.TargetTemplate.ProjectContext.GetType(partAttributeRecord.TypeAttribute);
                 if (PlatformTypes.FrameworkElement.IsAssignableFrom(type))
                 {
                     PartInPartsExplorer partInPartsExplorer = new PartInPartsExplorer(partAttributeRecord.NameAttribute, type);
                     if (!this.parts.ContainsKey(partAttributeRecord.NameAttribute))
                     {
                         PartsModel.PartsGroup partsGroup = new PartsModel.PartsGroup();
                         partsGroup.Add(partInPartsExplorer);
                         this.parts.Add(partAttributeRecord.NameAttribute, partsGroup);
                     }
                     else
                     {
                         this.parts[partAttributeRecord.NameAttribute].Add(partInPartsExplorer);
                     }
                     this.PartsList.Add(partInPartsExplorer);
                 }
             }
         }
         this.lastEditingContainer = this.viewModel.ActiveEditingContainer;
     }
 }
コード例 #4
0
ファイル: PartsModel.cs プロジェクト: radtek/Shopdrawing
        public void OnDoubleClickItem(PartInPartsExplorer part)
        {
            SceneElement selectionToSet = (SceneElement)null;

            if (part.Status != PartStatus.Unused)
            {
                selectionToSet = this.viewModel.GetSceneNode(this.viewModel.ActiveEditingContainer.DocumentNode.NameScope.FindNode(part.Name)) as SceneElement;
            }
            else
            {
                using (SceneEditTransaction editTransaction = this.viewModel.CreateEditTransaction(StringTable.UndoDoubleClickToMakePart, false))
                {
                    KeyValuePair <ITypeId, ITypeId> keyValuePair     = Enumerable.FirstOrDefault <KeyValuePair <ITypeId, ITypeId> >((IEnumerable <KeyValuePair <ITypeId, ITypeId> >)PartsModel.instanceTypesForAbstractParts, (Func <KeyValuePair <ITypeId, ITypeId>, bool>)(pair => pair.Key.Equals((object)part.TargetType)));
                    BaseFrameworkElement            frameworkElement = keyValuePair.Key == null ? (BaseFrameworkElement)this.viewModel.CreateSceneNode(part.TargetType) : (BaseFrameworkElement)this.viewModel.CreateSceneNode(keyValuePair.Value);
                    frameworkElement.Name = part.Name;
                    this.viewModel.ActiveSceneInsertionPoint.Insert((SceneNode)frameworkElement);
                    selectionToSet = (SceneElement)frameworkElement;
                    editTransaction.Update();
                    if (frameworkElement.IsViewObjectValid)
                    {
                        editTransaction.Commit();
                    }
                    else
                    {
                        editTransaction.Cancel();
                        selectionToSet = (SceneElement)null;
                    }
                }
            }
            if (selectionToSet == null || !PlatformTypes.UIElement.IsAssignableFrom((ITypeId)selectionToSet.Type))
            {
                return;
            }
            this.viewModel.ClearSelections();
            this.viewModel.ElementSelectionSet.SetSelection(selectionToSet);
            this.viewModel.TimelineItemManager.EnsureExpandedAncestors(this.viewModel.TimelineItemManager.FindTimelineItem((SceneNode)selectionToSet));
        }