Exemple #1
0
        public void AddandActiveDocument(IRDocument doc, bool setactive)
        {
            string typeName = doc.GetType().ToString();
            Type   docTy;

            if (!_documentTypesLoaded.TryGetValue(typeName, out docTy))
            {
                _documentTypesLoaded.Add(typeName, doc.GetType());
                doc.CreateDocumentSpecificRibbonTabs();
                doc.CreateDocumentSpecificTools();
                LoadExternalToolsFromPlugin(typeName);
            }

            _documents.Add(doc);

            Eventaggregator.GetEvent <NewDocumentAddedEvent>().Publish(doc);

            if (setactive)
            {
                ActiveDocument = doc;
            }
        }
        private void AddUITabsFromDoc(IRDocument doc)
        {
            if (RibbonControl == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(_currentDoctype) || _currentDoctype != doc.GetType().ToString())
            {
                RemoveAllExistingTabs();
                List <ITab> lstTabs;

                if (Data.UIManager.RibbonTabs.TryGetValue(doc.GetType().ToString(), out lstTabs))
                {
                    foreach (var item in lstTabs)
                    {
                        _ribbonControl.Tabs.Add(item as RibbonTabItem);
                    }
                    _currentDoctype = doc.GetType().ToString();
                }
            }
        }
        public void CreateDocument(IRDocument obj, bool setActive)
        {
            Type doctype = obj.GetType();

            RDocumentData docData = Data.DocumentTypeData.Where(a => a.DocType == doctype).Select(a => a).FirstOrDefault();

            if (docData != null)
            {
                object[] parms = new object[1];
                parms[0] = obj;
                DocumentViewModel doc = (DocumentViewModel)Activator.CreateInstance(docData.ViewModel, parms);
                _documentCollection.Add(doc);
                if (setActive)
                {
                    ActiveDocumentViewModel = doc;
                }
            }
        }