示例#1
0
        private void ActivateUiTab(TabPage ui)
        {
            ((TabUiSkeleton)ui.Controls[0]).InjectGlControl(glControl1);
            if (_renderer != null)
            {
                _renderer.TextOverlay.Clear();
            }

            // add postfix to main window title
            if (UiState != null)
            {
                var tab = UiState.TabForId(ui);
                if (tab != null)
                {
                    if (!string.IsNullOrEmpty(tab.File))
                    {
                        Text = _captionStub + "  [" + tab.File + "]";
                    }
                    else
                    {
                        Text = _captionStub;
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// Open a new tab given a scene file to load. If the specified scene is
        /// already open in a tab, the existing
        /// tab is selected in the UI (if requested) and no tab is added.
        /// </summary>
        /// <param name="file">Source file</param>
        /// <param name="async">Specifies whether the data is loaded asynchr.</param>
        /// <param name="setActive">Specifies whether the newly added tab will
        /// be selected when the loading process is complete.</param>
        public void AddTab(string file, bool async = true, bool setActive = true)
        {
            AddRecentItem(file);

            // check whether the scene is already loaded
            for (int j = 0; j < tabControl1.TabPages.Count; ++j)
            {
                var tab = UiState.TabForId(tabControl1.TabPages[j]);
                Debug.Assert(tab != null);

                if (tab.File == file)
                {
                    // if so, activate its tab and return
                    if (setActive)
                    {
                        SelectTab(tabControl1.TabPages[j]);
                    }

                    return;
                }
            }

            var key = GenerateTabKey();

            tabControl1.TabPages.Add(key, GenerateTabCaption(file) + LoadingTitlePostfix);

            var ui = tabControl1.TabPages[key];

            ui.ToolTipText           = file;
            tabControl1.ShowToolTips = true;

            PopulateUITab(ui);

            var t = new Tab(ui, file);

            UiState.AddTab(t);

            if (TabChanged != null)
            {
                TabChanged(t, true);
            }

            if (async)
            {
                var th = new Thread(() => OpenFile(t, setActive));
                th.Start();
            }
            else
            {
                OpenFile(t, setActive);
            }

            if (_emptyTab != null)
            {
                CloseTab(_emptyTab);
            }
        }
示例#3
0
        public MainViewer3DControl()
        {
            // create delegate used for asynchronous calls
            _delegateSelectTab         = SelectTab;
            _delegatePopulateInspector = PopulateInspector;

            InitializeComponent();
            _captionStub = Text;

            AddEmptyTab();

            // initialize UI state shelf with a default tab
            _ui  = new UiState(new Tab(_emptyTab, null));
            _fps = new FpsTracker();

            // sync global UI with UIState
            framerateToolStripMenuItem.Checked             = toolStripButtonShowFPS.Checked = _ui.ShowFps;
            lightingToolStripMenuItem.Checked              = toolStripButtonShowShaded.Checked = _ui.RenderLit;
            cullingToolStripMenuItem.Checked               = toolStripButtonCulling.Checked = GraphicsSettings.Default.BackFaceCulling;
            texturedToolStripMenuItem.Checked              = toolStripButtonShowTextures.Checked = _ui.RenderTextured;
            wireframeToolStripMenuItem.Checked             = toolStripButtonWireframe.Checked = _ui.RenderWireframe;
            showNormalVectorsToolStripMenuItem.Checked     = toolStripButtonShowNormals.Checked = _ui.ShowNormals;
            showBoundingBoxesToolStripMenuItem.Checked     = toolStripButtonShowBB.Checked = _ui.ShowBBs;
            showAnimationSkeletonToolStripMenuItem.Checked = toolStripButtonShowSkeleton.Checked = _ui.ShowSkeleton;

            // manually register the MouseWheel handler
            glControl1.MouseWheel += OnMouseMove;

            InitRecentList();

#if LEAP
            //LeapMotion Support
            _leapListener   = new LeapListener(this as MainWindow);
            _leapController = new Controller(_leapListener);
#endif

            // register listener for tab changs
            tabControl1.SelectedIndexChanged += (object o, EventArgs e) =>
            {
                if (SelectedTabChanged != null)
                {
                    SelectedTabChanged(UiState.TabForId(tabControl1.SelectedTab));
                }
            };

            _initialized = true;

            this.toolStripButton_OpenInteraction.Checked = true;
            this.bOpenInteraction = true;

            StartUndoRedoUiStatePollLoop();
        }
示例#4
0
        /// <summary>
        /// Select a given tab in the UI
        /// </summary>
        /// <param name="tab"></param>
        public void SelectTab(TabPage tab)
        {
            Debug.Assert(tab != null);
            tabControl1.SelectedTab = tab;

            var outer = UiState.TabForId(tab);

            Debug.Assert(outer != null);

            if (outer.ActiveScene != null)
            {
                toolStripStatistics.Text = outer.ActiveScene.StatsString;
            }
            else
            {
                toolStripStatistics.Text = "";
            }
            // update internal housekeeping
            UiState.SelectTab(tab);

            // update UI check boxes
            var vm = _ui.ActiveTab.ActiveViewMode;

            fullViewToolStripMenuItem.CheckState = toolStripButtonFullView.CheckState =
                vm == Tab.ViewMode.Single
                ? CheckState.Checked
                : CheckState.Unchecked;
            twoViewsToolStripMenuItem.CheckState = toolStripButtonTwoViews.CheckState =
                vm == Tab.ViewMode.Two
                ? CheckState.Checked
                : CheckState.Unchecked;
            twoViewsHorToolStripMenuItem.CheckState = toolStripButtonTwoViewsHor.CheckState =
                vm == Tab.ViewMode.TwoHorizontal
                ? CheckState.Checked
                : CheckState.Unchecked;
            fourViewsToolStripMenuItem.CheckState = toolStripButtonFourViews.CheckState =
                vm == Tab.ViewMode.Four
                ? CheckState.Checked
                : CheckState.Unchecked;

            // some other UI housekeeping, this also injects the GL panel into the tab
            ActivateUiTab(tab);
        }