Пример #1
0
        public static void SaveGridSettings(string gridId, string dataSetId, DataGridSettings settings)
        {
            var settingsToSave = (Dictionary <string, Dictionary <string, DataGridSettings> >)GridSettingsDictionary;

            if (settingsToSave != null && settingsToSave.Any())
            {
                if (settingsToSave.ContainsKey(gridId))
                {
                    var tagsSettings = settingsToSave[gridId];
                    if (tagsSettings.ContainsKey(dataSetId))
                    {
                        settingsToSave[gridId][dataSetId] = settings;
                    }
                    else
                    {
                        settingsToSave[gridId].Add(dataSetId, settings);
                    }
                }
                else
                {
                    settingsToSave.Add(gridId, new Dictionary <string, DataGridSettings> {
                        { dataSetId, settings }
                    });
                }
            }
            else
            {
                var settingsDict = new Dictionary <string, Dictionary <string, DataGridSettings> >();
                settingsDict.Add(gridId, new Dictionary <string, DataGridSettings> {
                    { dataSetId, settings }
                });
                settingsToSave = settingsDict;
            }
            GridSettingsDictionary = settingsToSave;
        }
Пример #2
0
        private void SetGridSettings()
        {
            var gridSettingsDict = GlobalStore.GridSettingsDictionary;

            if (gridSettingsDict != null && gridSettingsDict.Any())
            {
                if (gridSettingsDict.ContainsKey("ManageProcess_Processes"))
                {
                    var tagsSettings = gridSettingsDict["ManageProcess_Processes"];
                    if (tagsSettings.ContainsKey("all"))
                    {
                        _processesGridSettingsLadedFromFile = true;
                        ProcessesGridSettings = tagsSettings["all"];
                    }
                    else
                    {
                        ProcessesGridSettings = null;
                    }
                }
                else
                {
                    ProcessesGridSettings = null;
                }
            }
            else
            {
                ProcessesGridSettings = null;
            }
        }
Пример #3
0
        private void GetSettings()
        {
            List <string> allColumnNames = new List <string>();

            if (this._sourceTable != null)
            {
                foreach (DataColumn currColumn in this._sourceTable.Columns)
                {
                    allColumnNames.Add(currColumn.ColumnName);
                }
            }
            ShowDataGridSettings settingsForm = new ShowDataGridSettings(allColumnNames, this._gridSettings)
            {
                Owner = this
            };

            if ((bool)settingsForm.ShowDialog())
            {
                this._gridSettings = settingsForm.SettingsInfo;
            }
        }
Пример #4
0
        private void GetSettings()
        {
            List <string> allColumnNames = new List <string>();

            if (this.dataGridView.DataSource != null)
            {
                foreach (DataColumn currColumn in ((DataTable)this.dataGridView.DataSource).Columns)
                {
                    allColumnNames.Add(currColumn.ColumnName);
                }
            }
            ShowDataGridSettingsForm settingsForm = new ShowDataGridSettingsForm(allColumnNames, this._gridSettings)
            {
                Owner = this
            };

            if (settingsForm.ShowDialog() == DialogResult.OK)
            {
                this._gridSettings = settingsForm.SettingsInfo;
            }
        }
Пример #5
0
        private static void ApplySettingsToColumns(DataGrid dataGrid, Action <DataGrid, DataGridColumn, DataGridColumnSettingsModel> function)
        {
            DataGridSettings settings = GetDataGridSettings(dataGrid.Name);

            if (settings.ColumnsSetting == null || !settings.ColumnsSetting.Any())
            {
                return;
            }

            IEnumerable <DataGridColumn> columns = dataGrid.Columns.Where(column => column.Header != null);

            foreach (DataGridColumn column in columns)
            {
                DataGridColumnSettingsModel columnSettings = settings.ColumnsSetting.FirstOrDefault(iColumnSettings => iColumnSettings.Header.Equals(
                                                                                                        column.Header.ToString(), StringComparison.InvariantCultureIgnoreCase));

                if (columnSettings == null)
                {
                    continue;
                }

                function(dataGrid, column, columnSettings);
            }
        }
Пример #6
0
        private static void SaveSettings(DataGrid dataGrid, DataGridColumnSettingsType settingsType)
        {
            DataGridSettings settings = GetDataGridSettings(dataGrid.Name);

            IEnumerable <DataGridColumn> columns = dataGrid.Columns.Where(column => column.Header != null);

            settings.ColumnsSetting = settings.ColumnsSetting ?? new List <DataGridColumnSettingsModel>();

            foreach (DataGridColumn column in columns)
            {
                DataGridColumnSettingsModel columnSettings = settings.ColumnsSetting.FirstOrDefault(iColumnSettings => iColumnSettings.Header.Equals(
                                                                                                        column.Header.ToString(), StringComparison.InvariantCultureIgnoreCase));

                if (columnSettings != null)
                {
                    switch (settingsType)
                    {
                    case DataGridColumnSettingsType.DisplayIndex:
                        columnSettings.DisplayIndex = column.DisplayIndex;
                        break;

                    case DataGridColumnSettingsType.Sorting:
                        columnSettings.SortDirection = column.SortDirection;
                        break;

                    case DataGridColumnSettingsType.Width:
                        columnSettings.Width = new DataGridLengthSettingsModel
                        {
                            Value        = column.Width.Value,
                            DesiredValue = column.Width.DesiredValue,
                            DisplayValue = column.Width.DisplayValue,
                            UnitType     = column.Width.UnitType
                        };
                        break;

                    case DataGridColumnSettingsType.Visibility:
                        columnSettings.Visibility = column.Visibility;
                        break;
                    }
                }
                else
                {
                    columnSettings = new DataGridColumnSettingsModel
                    {
                        Header       = column.Header.ToString(),
                        DisplayIndex = column.DisplayIndex,
                        Width        = new DataGridLengthSettingsModel
                        {
                            Value        = column.Width.Value,
                            DesiredValue = column.Width.DesiredValue,
                            DisplayValue = column.Width.DisplayValue,
                            UnitType     = column.Width.UnitType
                        },
                        SortDirection = column.SortDirection,
                        Visibility    = column.Visibility
                    };

                    settings.ColumnsSetting.Add(columnSettings);
                }
            }

            settings.Save();
        }
Пример #7
0
 public ShowDataGridSettingsForm(List <string> AllColumns, DataGridSettings CurrentSettings) : this()
 {
     this.AddColumnNamesToListBox(AllColumns);
     this.SettingsInfo = CurrentSettings;
 }
Пример #8
0
 /// <summary>
 /// Initializes a new instance of the AssignTagDialogViewModel class.
 /// </summary>
 public AssignTagDialogViewModel(ObservableCollection <Tag> tags, ObservableCollection <Tag> selectedTags, DataGridSettings settings)
 {
     Tags         = tags;
     SelectedTags = selectedTags;
     Settings     = settings;
 }