Пример #1
0
        public void ShowOrCreateForm(Object formObject)
        {
            bool isSyntaxHelp            = (formObject is Type && ((Type)formObject) == typeof(SyntaxHelp));
            bool isTextEditableInterface = (formObject is TextEditableInterface);
            bool isTopic = (formObject is Preprocessor.TopicPreprocessor);
            bool canHaveMultipleFormInstances = (formObject is ItemListForm || formObject is FilteredTopicsViewerForm);

            // multiple windows of some forms are not allowed
            if (!canHaveMultipleFormInstances)
            {
                foreach (Form form in MdiChildren)
                {
                    if ((isSyntaxHelp && form is SyntaxHelp) ||
                        (isTextEditableInterface && form is TextEditForm && ((TextEditForm)form).IsOfType(((TextEditableInterface)formObject))) ||
                        (isTopic && form is TextEditForm && ((TextEditForm )form).PreprocessedTopic == (Preprocessor.TopicPreprocessor)formObject))
                    {
                        form.Activate();
                        return;
                    }
                }
            }

            // open a new form
            Form newForm = null;

            if (canHaveMultipleFormInstances)
            {
                newForm = (Form)formObject;
            }

            else if (isSyntaxHelp)
            {
                newForm = new SyntaxHelp();
            }

            else if (isTextEditableInterface)
            {
                newForm = new TextEditForm((TextEditableInterface)formObject, _helpComponents);
            }

            else if (isTopic)
            {
                newForm = new TextEditForm(new Topic((Preprocessor.TopicPreprocessor)formObject), _helpComponents);
            }

            if (newForm != null)
            {
                newForm.MdiParent = this;
                newForm.Show();
            }
        }
Пример #2
0
        public void ShowOrCreateForm(Object formObject)
        {
            bool isSyntaxHelp = ( formObject is Type && ((Type)formObject) == typeof(SyntaxHelp) );
            bool isItemListForm = ( formObject is ItemListForm );
            bool isTextEditableInterface = ( formObject is TextEditableInterface );
            bool isTopic = ( formObject is Preprocessor.TopicPreprocessor );

            // multiple item lists are allowed but otherwise multiple windows of a given type are not
            foreach( Form form in MdiChildren )
            {
                if( ( isSyntaxHelp && form is SyntaxHelp ) ||
                    ( isTextEditableInterface && form is TextEditForm && ((TextEditForm)form).IsOfType(((TextEditableInterface)formObject)) ) ||
                    ( isTopic && form is TextEditForm && ((TextEditForm )form).PreprocessedTopic == (Preprocessor.TopicPreprocessor)formObject ) )
                {
                    form.Activate();
                    return;
                }
            }

            // open a new form
            Form newForm = null;

            if( isSyntaxHelp )
                newForm = new SyntaxHelp();

            else if( isItemListForm )
                newForm = (Form)formObject;

            else if( isTextEditableInterface )
                newForm = new TextEditForm((TextEditableInterface)formObject,_helpComponents);

            else if( isTopic )
                newForm = new TextEditForm(new Topic((Preprocessor.TopicPreprocessor)formObject),_helpComponents);

            if( newForm != null )
            {
                newForm.MdiParent = this;
                newForm.Show();
            }
        }