예제 #1
0
        /// <summary>
        /// Saves the pane switcher state of all tabs to the INI file.
        /// </summary>
        public void SaveTabStates()
        {
            if (_curTabState != null)
            {
                _curTabState.SidebarState = _querySidebar.CurrentState;
            }

            int activeWorkspaceID = (_activeWorkspace == null) ? 0 : _activeWorkspace.Id;

            _workspaceTabs[activeWorkspaceID] = _tabBar.SelectedIndex;
            Core.SettingStore.WriteInt("WorkspaceTabs", "ActiveWorkspace", activeWorkspaceID);

            foreach (IntHashTableOfInt.Entry e in _workspaceTabs)
            {
                Core.SettingStore.WriteInt("WorkspaceTabs", e.Key.ToString(), e.Value);
            }

            foreach (DictionaryEntry de in _tabStates)
            {
                WorkspaceTabState stateKey = (WorkspaceTabState)de.Key;
                TabState          state    = (TabState)de.Value;

                if (state.SidebarState != null)
                {
                    state.SidebarState.SaveToIni(stateKey.GetIniString());
                }
            }
        }
예제 #2
0
        public override bool Equals(object obj)
        {
            WorkspaceTabState rhs = obj as WorkspaceTabState;

            if (rhs == null)
            {
                return(false);
            }

            return(_tabID == rhs._tabID && _workspaceID == rhs._workspaceID);
        }
예제 #3
0
        /// <summary>
        /// Loads the pane switcher state for all tabs in the specified workspace.
        /// </summary>
        private void RestoreTabStatesForWorkspace(int workspaceID)
        {
            string workspaceText = (workspaceID == 0) ? "" : workspaceID + ".";

            for (int i = 0; i < _tabBar.TabCount; i++)
            {
                TabFilter    filter = (TabFilter)_tabBar.GetTabTag(i);
                SidebarState state  = SidebarState.RestoreFromIni("TabState." + workspaceText + filter.Id);
                if (state != null)
                {
                    TabState tabState = new TabState();
                    tabState.SidebarState = state;

                    WorkspaceTabState stateKey = new WorkspaceTabState(filter.Id, workspaceID);
                    _tabStates[stateKey] = tabState;
                }
            }
        }
예제 #4
0
        /// <summary>
        /// The main function for switching resource type tabs and workspaces.
        /// </summary>
        private void UpdateSelectedTab()
        {
            if (Core.State == CoreState.ShuttingDown)
            {
                return;
            }

            using (new WaitCursorDisplayer())
            {
                if (TabChanging != null)
                {
                    TabChanging(this, EventArgs.Empty);
                }

                _resourceBrowser.UnhookResourceList(null);

                Trace.WriteLine("--- Start tab switch ---");
                if (_curTabState != null)
                {
                    _curTabState.SidebarState = _querySidebar.CurrentState;
                }

                TabFilter tabFilter = (TabFilter)_tabBar.SelectedTabTag;

                string   tabText          = _tabBar.GetTabText(_tabBar.SelectedIndex);
                string   tabName          = (_tabBar.SelectedIndex > 0) ? tabText : null;
                string[] tabResourceTypes = tabFilter.GetResourceTypes();
                string   tabId            = tabFilter.Id;

                Trace.WriteLine("Setting default resource browser columns");
                _resourceBrowser.SetCaptionPrefix(tabName, false);
                _resourceBrowser.DefaultColumns = (tabResourceTypes == null)
                                        ? null
                                        : (Core.DisplayColumnManager as DisplayColumnManager).GetColumnsForTypes(tabResourceTypes);

                Trace.WriteLine("Initializing tab state");
                bool newState = false;
                WorkspaceTabState tabStateKey = GetCurStateKey();
                TabState          state       = (TabState)_tabStates[tabStateKey];
                if (state == null)
                {
                    newState = true;
                    state    = new TabState();
                    _tabStates[tabStateKey] = state;
                }

                //_resourceBrowser.ResourceListView.Filters.BeginUpdate();

                Trace.WriteLine("Updating ResourceListView filters");

                _curTabFilter = tabFilter;

                UpdateResourceBrowserFilterList();
                _resourceBrowser.UpdatePerTabSettings();

                Trace.WriteLine("Showing panes in QuerySidebar");
                _querySidebar.ShowPanesForTab(tabId, state.SidebarState);

                ResourceTreePaneBase defaultViewPane = _querySidebar.DefaultViewPane as ResourceTreePaneBase;
                if (defaultViewPane != null)
                {
                    defaultViewPane.UnreadState = _curUnreadState;
                }
                JetResourceTreePane structurePane = _querySidebar.ResourceStructurePane as JetResourceTreePane;
                if (structurePane != null)
                {
                    structurePane.UnreadState = _curUnreadState;
                }

                Trace.WriteLine("Firing TabSwitch handler");
                if (TabChanged != null)
                {
                    TabChanged(this, EventArgs.Empty);
                }

                if (newState)
                {
                    Trace.WriteLine("Showing columns for resource list");
                    if (_resourceBrowser.DefaultColumns != null)
                    {
                        _resourceBrowser.ShowListViewColumns(_resourceBrowser.DefaultColumns);
                    }
                    else
                    {
                        _resourceBrowser.ShowColumnsForResourceList();
                    }

                    Trace.WriteLine("Selecting default view");
//  Debug
                    try
                    {
                        SelectDefaultView(tabId);
                    }
                    catch (NullReferenceException)
                    {
                        throw new ApplicationException("Illegal name of the View [" + tabId + "] while switching to [" + tabText + "]");
                    }
//  endDebug
                }
                else
                {
                    Trace.WriteLine("Selecting default view");
                    if (state.SidebarState != null &&
                        state.SidebarState.SelectedResource == null)
                    {
//  Debug
                        try
                        {
                            SelectDefaultView(tabId);
                        }
                        catch (NullReferenceException)
                        {
                            throw new ApplicationException("Illegal name of the View [" + tabId + "] while switching to [" + tabText + "]");
                        }
//  endDebug
                    }
                }
                Trace.WriteLine("Ending filters update");
                //_resourceBrowser.ResourceListView.Filters.EndUpdate();
                _curTabState = state;
                Trace.WriteLine("--- Done tab switch ---");
            }
        }