public void OnOpenProjectEntity(ProjectEntityType type, string name)
        {
            // Open your schema and other document types here by entity name
            DocumentView view = null;

            switch (type)
            {
            case ProjectEntityType.Schema:
                foreach (DocumentView doc in documentViews)
                {
                    if (doc is SchemaView)
                    {
                        if (doc.DocumentName == name)
                        {
                            doc.Activate();
                            return;
                        }
                    }
                }
                view = new SchemaView();
                if ((view == null) || (view as SchemaView).LoadDocument(name) == false)
                {
                    System.Windows.MessageBox.Show(DialogMessages.CannotLoadSchema,
                                                   DialogMessages.ErrorCaption,
                                                   System.Windows.MessageBoxButton.OK,
                                                   System.Windows.MessageBoxImage.Error);
                    return;
                }
                break;

            case ProjectEntityType.VariableList:
                foreach (DocumentView doc in documentViews)
                {
                    if (doc is VariablesView)
                    {
                        doc.Activate();
                        return;
                    }
                }
                view = new VariablesView();
                if ((view == null))
                {
                    System.Windows.MessageBox.Show(DialogMessages.CannotLoadVariables,
                                                   DialogMessages.ErrorCaption,
                                                   System.Windows.MessageBoxButton.OK,
                                                   System.Windows.MessageBoxImage.Error);
                    return;
                }
                break;
            }
            documentViews.Add(view);
            view.FormClosing += new FormClosingEventHandler(OnDocumentWindowClosing);
            view.Show(dockPanel, DockState.Document);
            currentDocument = (DocumentView)dockPanel.ActiveDocument;
        }
Пример #2
0
        /// <summary>
        /// Create or active existing "Variables" view.
        /// </summary>
        public void ShowVariablesView()
        {
            foreach (var doc in documentViews)
            {
                if (doc is VariablesView)
                {
                    doc.Activate();
                    return;
                }
            }

            var view = new VariablesView();

            view.Show(dockPanel, DockState.Document);

            view.FormClosing   += new FormClosingEventHandler(OnDocumentWindowClosing);
            view.SelectChannel += new VariablesView.SelectChannelHandler(OnSelectChannel);
            documentViews.Add(view);
        }