Exemple #1
0
        public void RefreshTreeView(ModelInfo sourceModel, ModelInfo recipientModel, TreeView sourceView, TreeView recipientView, TreeViewSortBy sortBy, bool createLinks)
        {
            try
            {
                ViewMapClass viewMap = new ViewMapClass(sourceModel, recipientModel, createLinks);
                if (null != viewMap)
                {
                    sourceView.ItemsSource    = null;
                    recipientView.ItemsSource = null;

                    if (sortBy == TreeViewSortBy.Sheet)
                    {
                        sourceView.ItemsSource    = TreeViewModel.SetTreeBySheet(sourceModel.DocTitle, viewMap.SourceViews, sheetNumbers);
                        recipientView.ItemsSource = TreeViewModel.SetTreeBySheet(recipientModel.DocTitle, viewMap.RecipientViews, sheetNumbers);
                    }
                    else if (sortBy == TreeViewSortBy.ViewType)
                    {
                        sourceView.ItemsSource    = TreeViewModel.SetTreeByViewType(sourceModel.DocTitle, viewMap.SourceViews, viewTypeNames);
                        recipientView.ItemsSource = TreeViewModel.SetTreeByViewType(recipientModel.DocTitle, viewMap.RecipientViews, viewTypeNames);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to refresh the tree view.\nSource Model:" + sourceModel.DocTitle + "\nRecipient Model:" + recipientModel.DocTitle + "\n" + ex.Message, "Refresh Tree View", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Exemple #2
0
        public void RefreshTreeViewBySelection(ModelInfo sourceModel, ModelInfo recipientModel, TreeView sourceView, TreeView recipientView, TreeViewSortBy sortBy, string filterString, bool createLinks)
        {
            try
            {
                ViewMapClass viewMap = new ViewMapClass(sourceModel, recipientModel, createLinks);
                if (null != viewMap)
                {
                    List <string> strList = new List <string>();
                    strList.Add(filterString);

                    recipientView.ItemsSource = null;

                    if (sortBy == TreeViewSortBy.Sheet)
                    {
                        recipientView.ItemsSource = TreeViewModel.SetTreeBySheet(recipientModel.DocTitle, viewMap.RecipientViews, strList);
                    }
                    else if (sortBy == TreeViewSortBy.ViewType)
                    {
                        recipientView.ItemsSource = TreeViewModel.SetTreeByViewType(recipientModel.DocTitle, viewMap.RecipientViews, strList);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to refresh the tree view by " + filterString + "\n" + ex.Message, "Refresh Tree View By Selection", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Exemple #3
0
        public bool FixViewDictionary(ViewMapClass viewMapClass)
        {
            bool result = false;

            try
            {
                ModelInfo recipientInfo = viewMapClass.RecipientInfo;
                ObservableCollection <LinkInfo> linkInfoCollection = recipientInfo.LinkInfoCollection;
                List <LinkInfo> fixedLInkInfo = viewMapClass.LinkInfoList;

                //deleted links
                var linkToDelete = from info in fixedLInkInfo where info.ItemStatus == LinkItemStatus.Deleted select info;
                if (linkToDelete.Count() > 0)
                {
                    foreach (LinkInfo linkInfo in linkToDelete)
                    {
                        int index = linkInfoCollection.IndexOf(linkInfoCollection.Where(x => x.SourceModelId == linkInfo.SourceModelId && x.SourceItemId == linkInfo.SourceItemId && x.DestItemId == linkInfo.DestItemId).FirstOrDefault());
                        if (index > -1)
                        {
                            linkInfoCollection[index].ItemStatus = linkInfo.ItemStatus;
                        }
                    }
                }

                //added links
                var linkToAdd = from info in fixedLInkInfo where info.ItemStatus == LinkItemStatus.Added select info;
                if (linkToAdd.Count() > 0)
                {
                    foreach (LinkInfo linkInfo in linkToAdd)
                    {
                        int index = linkInfoCollection.IndexOf(linkInfoCollection.Where(x => x.SourceModelId == linkInfo.SourceModelId && x.SourceItemId == linkInfo.SourceItemId && x.DestItemId == linkInfo.DestItemId).FirstOrDefault());
                        if (index > -1)
                        {
                            linkInfoCollection[index].ItemStatus = linkInfo.ItemStatus;
                        }
                        else
                        {
                            linkInfoCollection.Add(linkInfo);
                        }
                    }
                }

                if (modelInfoDictionary.ContainsKey(recipientInfo.RevitDocumentID))
                {
                    modelInfoDictionary.Remove(recipientInfo.RevitDocumentID);
                }

                recipientInfo.LinkInfoCollection = linkInfoCollection;
                modelInfoDictionary.Add(recipientInfo.RevitDocumentID, recipientInfo);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to fix the link information.\n" + ex.Message, "Fix Link Information", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            return(result);
        }
        public FixLinkWindow(ViewMapClass viewMapClass)
        {
            fixedViewMap  = viewMapClass;
            sourceInfo    = fixedViewMap.SourceInfo;
            recipientInfo = fixedViewMap.RecipientInfo;

            sourceViews    = viewMapClass.SourceViews;
            recipientViews = viewMapClass.RecipientViews;
            listLinkInfo   = viewMapClass.LinkInfoList; //from recepient model only related to the source model

            InitializeComponent();

            textSourceTitle.Text    = sourceInfo.DocTitle;
            textRecipientTitle.Text = recipientInfo.DocTitle;

            DisplayViews();
        }
Exemple #5
0
        public bool UpdateDraftingViews(ModelInfo sourceInfo, ModelInfo recipientInfo, TreeView treeViewSource, TreeView treeViewRecipient, bool createSheet, bool createLinks, TextBlock statusLable, ProgressBar progressBar)
        {
            bool result = false;

            try
            {
                List <int>        sourceViewIds  = new List <int>();
                List <PreviewMap> previewMapList = new List <PreviewMap>();

                ViewMapClass vmc = new ViewMapClass(sourceInfo, recipientInfo, createLinks);
                Dictionary <int, ViewProperties> sourceViews    = vmc.SourceViews;
                Dictionary <int, ViewProperties> recipientViews = vmc.RecipientViews;

                List <TreeViewModel> treeviewModels = treeViewSource.ItemsSource as List <TreeViewModel>;
                foreach (TreeViewModel rootNode in treeviewModels)
                {
                    foreach (TreeViewModel secondNode in rootNode.Children)
                    {
                        foreach (TreeViewModel viewNode in secondNode.Children)
                        {
                            if (viewNode.IsChecked == true)
                            {
                                int viewId = 0;
                                if (int.TryParse(viewNode.Tag.ToString(), out viewId))
                                {
                                    if (sourceViews.ContainsKey(viewId) && !sourceViewIds.Contains(viewId))
                                    {
                                        ViewProperties viewSource = sourceViews[viewId];
                                        if (viewSource.DependantViews.Count > 0)
                                        {
                                            foreach (int dependentId in viewSource.DependantViews.Keys)
                                            {
                                                if (!sourceViewIds.Contains(dependentId))
                                                {
                                                    ViewProperties dependentSource    = viewSource.DependantViews[dependentId];
                                                    ViewProperties dependentRecipient = null;
                                                    LinkInfo       dependantlinkInfo  = new LinkInfo();
                                                    if (null != dependentSource.LinkedView)
                                                    {
                                                        dependentRecipient = dependentSource.LinkedView;
                                                        var linkInfoList = from info in vmc.LinkInfoList where info.SourceItemId == dependentId && info.DestItemId == dependentRecipient.ViewId select info;
                                                        if (linkInfoList.Count() > 0)
                                                        {
                                                            dependantlinkInfo = linkInfoList.First();
                                                        }
                                                    }

                                                    PreviewMap dependantView = new PreviewMap();
                                                    dependantView.SourceModelInfo         = sourceInfo;
                                                    dependantView.RecipientModelInfo      = recipientInfo;
                                                    dependantView.SourceViewProperties    = dependentSource;
                                                    dependantView.RecipientViewProperties = dependentRecipient;
                                                    dependantView.ViewLinkInfo            = dependantlinkInfo;
                                                    dependantView.IsEnabled = true;

                                                    sourceViewIds.Add(dependentId);
                                                    previewMapList.Add(dependantView);
                                                }
                                            }
                                        }

                                        ViewProperties viewRecipient = null;
                                        LinkInfo       linkInfo      = new LinkInfo();
                                        if (null != viewSource.LinkedView)
                                        {
                                            viewRecipient = viewSource.LinkedView;
                                            var linkInfoList = from info in vmc.LinkInfoList where info.SourceItemId == viewId && info.DestItemId == viewRecipient.ViewId && info.ItemStatus != LinkItemStatus.Deleted select info;
                                            if (linkInfoList.Count() > 0)
                                            {
                                                linkInfo = linkInfoList.First();
                                            }
                                        }

                                        PreviewMap preview = new PreviewMap();
                                        preview.SourceModelInfo         = sourceInfo;
                                        preview.RecipientModelInfo      = recipientInfo;
                                        preview.SourceViewProperties    = viewSource;
                                        preview.RecipientViewProperties = viewRecipient;
                                        preview.ViewLinkInfo            = linkInfo;
                                        preview.IsEnabled = true;

                                        sourceViewIds.Add(viewId);
                                        previewMapList.Add(preview);
                                    }
                                }
                            }
                        }
                    }
                }

                if (previewMapList.Count > 0)
                {
                    PreviewWindow pWindow = new PreviewWindow(previewMapList, createSheet);
                    if (true == pWindow.ShowDialog())
                    {
                        previewMapList = pWindow.PreviewMapList;

                        progressBar.Visibility = System.Windows.Visibility.Visible;
                        statusLable.Visibility = System.Windows.Visibility.Visible;

                        bool updatedDictionary  = UpdateRecipientViewDictionary(recipientInfo, previewMapList);
                        bool updatedGoogleSheet = GoogleSheetUtil.WriteLinkIfo(recipientInfo.GoogleSheetID, recipientInfo.LinkInfoCollection);
                        bool updatedLinkStatus  = UpdateLinkStatus(recipientInfo);

                        progressBar.Visibility = System.Windows.Visibility.Hidden;
                        statusLable.Visibility = System.Windows.Visibility.Hidden;
                    }
                }
                else
                {
                    MessageBox.Show("Please select at least one source item to duplicate views.", "Select a Source Item", MessageBoxButton.OK, MessageBoxImage.Information);
                    result = false;
                }
                result = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to update drafting views.\n" + ex.Message, "Update Drafting Views", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            return(result);
        }