Esempio n. 1
0
        private void HandleAfterComponentFileSelected(int index)
        {
            WaitCursor.Show();

            SuspendLayout();

            try
            {
                _splitter.Panel2.Controls.Clear();

                if (_tabCtrl != null)
                {
                    _tabCtrl.Dispose();
                    _tabCtrl = null;
                }

                if (index < 0)
                {
                    return;
                }

                var file = _descriptionFileGrid.GetFileAt(index);
                List <IEditorProvider> providers = new List <IEditorProvider>();

                if ((file.FileType is AudioFileType) || (file.FileType is VideoFileType))
                {
                    providers.Add(new AudioVideoPlayer(file, null));
                }
                else if (file.FileType is ImageFileType)
                {
                    providers.Add(new ImageViewer(file));
                }
                else
                {
                    providers.Add(new BrowserEditor(file, null));
                }

                providers.Add(new NotesEditor(file));
                _tabCtrl = new ComponentEditorsTabControl("UnknownFileType", _tabControlImages, providers,
                                                          BackColor, SystemColors.ControlDark);
                _tabCtrl.MakeAppropriateEditorsVisible();

                _splitter.Panel2.Controls.Add(_tabCtrl);
                _tabCtrl.Dock    = DockStyle.Fill;
                _tabCtrl.Visible = true;
            }
            finally
            {
                ResumeLayout();
                WaitCursor.Hide();
            }
        }
Esempio n. 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Each set of editors (i.e. a set being the editors associated with a single
        /// component file type) has its own tab control with a tab page for each editor.
        /// The tab controls are cached in a dictionary whose key is the file type name.
        /// The process of showing the editors for a component file is just a matter of
        /// hiding the tab control containing the previously selected file's editors and
        /// unhiding the tab control containing the selected file's editors.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected void ShowSelectedComponentFileEditors()
        {
            var currProviderKey = _model.GetSelectedProviderKey();

            _componentFilesControl.AddButtonEnabled = (currProviderKey != null);

            if (currProviderKey == null)
            {
                return;
            }

            var editorProviders = _model.GetComponentEditorProviders().ToArray();
            ComponentEditorsTabControl tabCtrl;

            // Check if editiors for the current file type have been shown yet. If not then
            // load a new tab control for this file type containing the appropriate editors.
            if (!_tabControls.TryGetValue(currProviderKey, out tabCtrl))
            {
                tabCtrl = new ComponentEditorsTabControl(currProviderKey, _tabControlImages,
                                                         editorProviders, ComponentEditorBackgroundColor, ComponentEditorBorderColor);

                tabCtrl.Selecting            += HandleSelectedComponentEditorTabSelecting;
                _tabControls[currProviderKey] = tabCtrl;
                _tabControlHostControl.Controls.Add(tabCtrl);

                foreach (var editor in editorProviders)
                {
                    editor.ComponentFileListRefreshAction = ComponentFileListRefreshFromEditor;
                }
            }

            // Don't do anything if the selected tab control hasn't changed.
            if (_selectedEditorsTabControl != tabCtrl)
            {
                if (_selectedEditorsTabControl != null)
                {
                    _selectedEditorsTabControl.Visible = false;
                }

                tabCtrl.Visible            = true;
                _selectedEditorsTabControl = tabCtrl;
            }

            tabCtrl.MakeAppropriateEditorsVisible();
        }