Пример #1
0
        public void InitialiseView()
        {
            if (showSourceCode)
            {
                if (!tabControlMainView.Contains(tabPageSourceCodeView))
                {
                    tabControlMainView.AddTab(tabPageSourceCodeView);
                }
            }
            else
            {
                if (tabControlMainView.Contains(tabPageSourceCodeView))
                {
                    tabControlMainView.RemoveTab(tabPageSourceCodeView);
                }
            }

            if (userControl == MainForm.UserControls.None)
            {
                // Remove Data view tab
                if (tabControlMainView.Contains(tabPageDataView))
                {
                    tabControlMainView.RemoveTab(tabPageDataView);
                }
            }
            else
            {
                if (!tabControlMainView.Contains(tabPageDataView))
                {
                    //int tabCount = tabControlMainView.TabPages.Count;
                    tabControlMainView.AddTab(tabPageDataView);
                }

                // Determine which control we are going to display

                if (userControl != MainForm.UserControls.DataViewer)
                {
                    if (dataViewer != null)
                    {
                        tabPageDataView.Controls.Remove(dataViewer);
                        dataViewer = null;
                    }
                }

                if (userControl != MainForm.UserControls.ScreenViewer)
                {
                    if (screenViewer != null)
                    {
                        tabPageDataView.Controls.Remove(screenViewer);
                        screenViewer = null;
                    }
                }

                if (userControl != MainForm.UserControls.CharacterSetViewer)
                {
                    if (characterSetViewer != null)
                    {
                        tabPageDataView.Controls.Remove(characterSetViewer);
                        characterSetViewer = null;
                    }
                }

                if (userControl != MainForm.UserControls.DataFileViewer)
                {
                    if (dataFileViewer != null)
                    {
                        tabPageDataView.Controls.Remove(dataFileViewer);
                        dataFileViewer = null;
                    }
                }

                if (userControl != MainForm.UserControls.SequentialFileViewer)
                {
                    if (sequentialFileViewer != null)
                    {
                        tabPageDataView.Controls.Remove(sequentialFileViewer);
                        sequentialFileViewer = null;
                    }
                }

                switch (userControl)
                {
                case MainForm.UserControls.DataViewer:
                    if (dataViewer == null)
                    {
                        dataViewer = new DataViewerControl();
                        tabPageDataView.Controls.Add(dataViewer);

                        // Rename the tab header
                        tabPageDataView.Title = "Data Viewer";
                    }
                    break;

                case MainForm.UserControls.ScreenViewer:
                    if (screenViewer == null)
                    {
                        screenViewer = new ScreenViewerControl();
                        tabPageDataView.Controls.Add(screenViewer);

                        // Rename the tab header
                        tabPageDataView.Title = "Screen Viewer";
                    }
                    break;

                case MainForm.UserControls.CharacterSetViewer:
                    if (characterSetViewer == null)
                    {
                        characterSetViewer = new CharacterSetViewerControl();
                        tabPageDataView.Controls.Add(characterSetViewer);

                        // Rename the tab header
                        tabPageDataView.Title = "Character Set Viewer";
                    }
                    break;

                case MainForm.UserControls.DataFileViewer:
                    if (dataFileViewer == null)
                    {
                        dataFileViewer = new DataFileViewer();
                        tabPageDataView.Controls.Add(dataFileViewer);

                        // Rename the tab header
                        tabPageDataView.Title = "Data File Viewer";
                    }
                    break;

                case MainForm.UserControls.SequentialFileViewer:
                    if (sequentialFileViewer == null)
                    {
                        sequentialFileViewer = new SequentialFileViewer();
                        tabPageDataView.Controls.Add(sequentialFileViewer);

                        // Rename the tab header
                        tabPageDataView.Title = "Sequential File Viewer";
                    }
                    break;

                case MainForm.UserControls.None:
                    break;

                default:
                    break;
                }
            }

            Invalidate();
        }