Exemple #1
0
        internal ResourceListState ConfigureColumns(ResourceListState state, IResourceList resList,
                                                    IResource ownerResource)
        {
            RestoreSettings();
            _displayColumnManager = Core.DisplayColumnManager as DisplayColumnManager;
            _resourceList         = resList;
            _allTypes             = _resourceList.GetAllTypes();
            _allNoFileTypes       = _displayColumnManager.CollapseFileTypes(_allTypes);
            _availableColumns     = _displayColumnManager.GetAvailableColumns(_resourceList);
            _state = state;
            FillPropertyList();

            SetViewRadioButtons(_state, ownerResource);

            if (ShowDialog(Core.MainWindow) == DialogResult.OK)
            {
                if (_state.KeyTypes != null && radThisView.Checked)
                {
                    _state = new ResourceListState(new ColumnDescriptor[] {}, _state.SortSettings, state.GroupItems);
                    _state.SetOwner(ownerResource, Core.TabManager.CurrentTabId);
                }
                else if (_state.OwnerResource != null && radAllViews.Checked)
                {
                    _state.Delete();
                    _state = _displayColumnManager.StateFromList(_resourceList,
                                                                 _displayColumnManager.GetDefaultColumns(_resourceList), true);
                }
                SaveColumnsToState(_state);
            }
            return(_state);
        }
Exemple #2
0
        /// <summary>
        /// Sets the "For all views" and "For this view" radio buttons based on the state.
        /// </summary>
        private void SetViewRadioButtons(ResourceListState state, IResource ownerResource)
        {
            string[] resTypes = new string[_allNoFileTypes.Length];
            for (int i = 0; i < _allNoFileTypes.Length; i++)
            {
                // "File" is a pseudo resource type
                if (Core.ResourceStore.ResourceTypes.Exist(_allNoFileTypes [i]) &&
                    Core.ResourceStore.ResourceTypes [_allNoFileTypes [i]].DisplayName != null)
                {
                    resTypes [i] = Core.ResourceStore.ResourceTypes [_allNoFileTypes [i]].DisplayName;
                }
                else
                {
                    resTypes [i] = _allNoFileTypes [i];
                }
            }
            radAllViews.Text += " " + String.Join(", ", resTypes);

            if (state.KeyTypes != null)
            {
                radAllViews.Checked = true;
            }
            else
            {
                radThisView.Checked = true;
            }

            if (ownerResource == null)
            {
                radThisView.Enabled = false;
            }
        }
Exemple #3
0
        /// <summary>
        /// Locates and, if necessary, creates a resource list state which applies to all views
        /// with resources of types matching the contents of the resource list.
        /// </summary>
        internal ResourceListState StateFromList(IResourceList resList, ColumnDescriptor[] defaultColumns,
                                                 bool defaultGroupItems)
        {
            string[] keyTypes = resList.GetAllTypes();
            keyTypes = CollapseFileTypes(keyTypes);
            ComparableArrayList keyTypeList = new ComparableArrayList(keyTypes);
            ResourceListState   state       = (ResourceListState)_columnState [keyTypeList];

            if (state == null)
            {
                IResource stateResource = Core.ResourceStore.FindUniqueResource("ColumnScheme",
                                                                                _props.ColumnKeyTypes, String.Join(";", keyTypes));
                if (stateResource != null)
                {
                    state = ResourceListState.FromResource(stateResource);
                    // filter out invalid data
                    if (state.Columns.Length == 0)
                    {
                        state.Columns = defaultColumns;
                    }
                }
                else
                {
                    state          = new ResourceListState(defaultColumns, null, defaultGroupItems);
                    state.KeyTypes = keyTypes;
                }
                _columnState [keyTypeList] = state;
            }
            return(state);
        }
Exemple #4
0
        internal ResourceListState GetListViewState(IResource ownerResource, IResourceList resList,
                                                    ColumnDescriptor[] defaultColumns, bool defaultGroupItems)
        {
            ResourceListState state;
            IResource         columnScheme = null;

            if (ownerResource != null)
            {
                IResourceList columnSchemes = ownerResource.GetLinksOfType("ColumnScheme", Props.ColumnSchemeOwner);
                foreach (IResource aScheme in columnSchemes)
                {
                    if (aScheme.GetStringProp(Props.ColumnSchemeTab) == Core.TabManager.CurrentTabId)
                    {
                        columnScheme = aScheme;
                        break;
                    }
                }
            }

            if (columnScheme != null)
            {
                state = ResourceListState.FromResource(columnScheme);
            }
            else
            {
                state = StateFromList(resList, defaultColumns, defaultGroupItems);
            }
            return(state);
        }
Exemple #5
0
        /**
         * Saves the state of the list view (column widths) under the key that is
         * specified as a sequence of columns.
         */

        internal void SaveListViewState(ResourceListView2 listView, ResourceListDataProvider dataProvider,
                                        ResourceListState state, bool async)
        {
            ColumnDescriptor[] columns = ColumnDescriptorsFromList(listView);
            columns = UpdateColumnsFromState(columns, state);
            state.SaveState(columns, dataProvider.SortSettings, async);
        }
Exemple #6
0
        internal static ResourceListState FromResource(IResource res)
        {
            DisplayColumnProps props = (Core.DisplayColumnManager as DisplayColumnManager).Props;

            IResourceList columnDescriptorResources = res.GetLinksOfType("ColumnDescriptor", props.ColumnDescriptor);

            columnDescriptorResources.Sort(new int[] { props.ColumnOrder }, true);
            ColumnDescriptor[] columns = new ColumnDescriptor [columnDescriptorResources.Count];
            for (int i = 0; i < columnDescriptorResources.Count; i++)
            {
                columns [i] = LoadColumnDescriptor(columnDescriptorResources [i]);
            }

            SortSettings sortSettings = LoadSortSettings(res, props);

            ResourceListState result = new ResourceListState(columns, sortSettings,
                                                             res.HasProp(props.GroupItems));

            result._columnSchemeResource = res;

            if (res.HasProp(props.ColumnKeyTypes))
            {
                result.KeyTypes = res.GetPropText(props.ColumnKeyTypes).Split(';');
            }
            if (res.HasProp(props.ColumnSchemeOwner))
            {
                result.SetOwner(res.GetLinkProp(props.ColumnSchemeOwner),
                                res.GetStringProp(props.ColumnSchemeTab));
            }

            return(result);
        }
Exemple #7
0
        /// <summary>
        /// Checks if a column displaying the specified property is contained in the specified
        /// resource list state.
        /// </summary>
        private bool StateHasProp(ResourceListState state, int propId)
        {
            string propName = Core.ResourceStore.PropTypes [propId].Name;

            foreach (ColumnDescriptor colDesc in state.Columns)
            {
                for (int i = 0; i < colDesc.PropNames.Length; i++)
                {
                    if (colDesc.PropNames [i] == propName || colDesc.PropNames [i] == "-" + propName)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemple #8
0
        /**
         * Applies the columns selected in the dialog to the resource list view.
         */

        private void SaveColumnsToState(ResourceListState state)
        {
            ArrayList newColumnDescriptors = new ArrayList();

            foreach (JetListViewNode node in _propListView.Nodes)
            {
                PropertyTypeTag tag = (PropertyTypeTag)node.Data;
                if (_checkColumn.GetItemCheckState(tag) == CheckBoxState.Checked)
                {
                    SetFlagFromColumn(tag, _autoSizeColumn, ColumnDescriptorFlags.AutoSize);
                    SetFlagFromColumn(tag, _showIfNotEmptyColumn, ColumnDescriptorFlags.ShowIfNotEmpty);
                    SetFlagFromColumn(tag, _showIfDistinctColumn, ColumnDescriptorFlags.ShowIfDistinct);
                    newColumnDescriptors.Add(tag.ColDesc);
                }
            }
            state.Columns = (ColumnDescriptor[])newColumnDescriptors.ToArray(typeof(ColumnDescriptor));
        }
Exemple #9
0
        internal ColumnDescriptor[] UpdateColumnsFromState(ColumnDescriptor[] descriptors, ResourceListState state)
        {
            bool[]    usedColumns = new bool [state.Columns.Length];
            ArrayList result      = new ArrayList();

            for (int i = 0; i < descriptors.Length; i++)
            {
                bool found = false;
                for (int j = 0; j < state.Columns.Length; j++)
                {
                    if (state.Columns [j].PropNamesEqual(descriptors [i]))
                    {
                        ColumnDescriptor desc = descriptors [i];
                        desc.Flags = state.Columns [j].Flags;
                        result.Add(desc);
                        found           = true;
                        usedColumns [j] = true;
                        break;
                    }
                }
                if (!found)
                {
                    result.Add(descriptors [i]);
                }
            }

            for (int i = 0; i < state.Columns.Length; i++)
            {
                if (!usedColumns [i])
                {
                    int index = (i == 0)
                        ? 0
                        : FindColumn(result, state.Columns [i - 1]) + 1;
                    result.Insert(index, state.Columns [i]);
                }
            }

            return((ColumnDescriptor[])result.ToArray(typeof(ColumnDescriptor)));
        }