private void FillHighlightMaskList() { this.highlightMaskGridView.Rows.Clear(); DataGridViewComboBoxColumn comboColumn = (DataGridViewComboBoxColumn)this.highlightMaskGridView.Columns[1]; comboColumn.Items.Clear(); DataGridViewTextBoxColumn textColumn = (DataGridViewTextBoxColumn)this.highlightMaskGridView.Columns[0]; IList<HilightGroup> groups = this.logTabWin.HilightGroupList; foreach (HilightGroup group in groups) { int index = comboColumn.Items.Add(group.GroupName); } foreach (HighlightMaskEntry maskEntry in this.Preferences.highlightMaskList) { DataGridViewRow row = new DataGridViewRow(); row.Cells.Add(new DataGridViewTextBoxCell()); DataGridViewComboBoxCell cell = new DataGridViewComboBoxCell(); foreach (HilightGroup group in groups) { int index = cell.Items.Add(group.GroupName); } row.Cells.Add(cell); row.Cells[0].Value = maskEntry.mask; HilightGroup currentGroup = this.logTabWin.FindHighlightGroup(maskEntry.highlightGroupName); if (currentGroup == null) currentGroup = groups[0]; if (currentGroup == null) currentGroup = new HilightGroup(); row.Cells[1].Value = currentGroup.GroupName; this.highlightMaskGridView.Rows.Add(row); } int count = this.highlightMaskGridView.RowCount; if (count > 0 && !this.highlightMaskGridView.Rows[count - 1].IsNewRow) { DataGridViewComboBoxCell comboCell = (DataGridViewComboBoxCell)this.highlightMaskGridView.Rows[count - 1].Cells[1]; comboCell.Value = comboCell.Items[0]; } }
public CurrentHighlightGroupChangedEventArgs(LogWindow logWindow, HilightGroup currentGroup) { this.LogWindow = logWindow; this.CurrentGroup = currentGroup; }
private void newGroupButton_Click(object sender, EventArgs e) { // Propose a unique name const string baseName = "New group"; string name = baseName; bool uniqueName = false; int i = 1; while (!uniqueName) { uniqueName = (this.HilightGroupList.FindIndex(delegate(HilightGroup g) { return g.GroupName == name; }) < 0); if (!uniqueName) name = string.Format("{0} #{1}", baseName, i++); } HilightGroup newGroup = new HilightGroup() { GroupName = name }; this.HilightGroupList.Add(newGroup); FillGroupComboBox(); SelectGroup(this.HilightGroupList.Count - 1); }
private void SelectGroup(int index) { if (index >= 0 && index < this.HilightGroupList.Count) { this.currentGroup = this.HilightGroupList[index]; this.groupComboBox.Items[index] = this.currentGroup; this.groupComboBox.SelectedIndex = index; //this.groupComboBox.Text = this.currentGroup.GroupName; this.groupComboBox.SelectedItem = this.currentGroup; FillHilightListBox(); } else { this.currentGroup = null; this.hilightListBox.Items.Clear(); } ReEvaluateHilightButtonStates(); ReEvaluateGroupButtonStates(); }
private void InitData() { const string def = "[Default]"; if (this.HilightGroupList == null || this.HilightGroupList.Count == 0) { this.HilightGroupList.Add(new HilightGroup()); this.HilightGroupList[0].GroupName = def; this.HilightGroupList[0].HilightEntryList = new List<HilightEntry>(); } FillGroupComboBox(); this.currentGroup = null; string groupToSelect = this.PreSelectedGroupName; if (string.IsNullOrEmpty(groupToSelect)) groupToSelect = def; foreach (HilightGroup group in this.HilightGroupList) { if (group.GroupName.Equals(groupToSelect)) { this.currentGroup = group; this.groupComboBox.SelectedValue = group; this.groupComboBox.SelectedIndex = this.HilightGroupList.IndexOf(group); break; } } ReEvaluateGroupButtonStates(); FillHilightListBox(); }
/// <summary> /// Loads Settings of a given file or creates new settings if the file does not exist /// </summary> /// <param name="fileInfo">file that has settings saved</param> /// <returns>loaded or created settings</returns> private Settings LoadOrCreateNew(FileSystemInfo fileInfo) { lock (_loadSaveLock) { Settings settings; if (fileInfo == null || fileInfo.Exists == false) { settings = new Settings(); } else { try { settings = JsonConvert.DeserializeObject <Settings>(File.ReadAllText($"{fileInfo.FullName}")); } catch (Exception e) { _logger.Error($"Error while deserializing config data: {e}"); settings = new Settings(); } } if (settings.preferences == null) { settings.preferences = new Preferences(); } if (settings.preferences.toolEntries == null) { settings.preferences.toolEntries = new List <ToolEntry>(); } if (settings.preferences.columnizerMaskList == null) { settings.preferences.columnizerMaskList = new List <ColumnizerMaskEntry>(); } if (settings.fileHistoryList == null) { settings.fileHistoryList = new List <string>(); } if (settings.lastOpenFilesList == null) { settings.lastOpenFilesList = new List <string>(); } if (settings.fileColors == null) { settings.fileColors = new List <ColorEntry>(); } if (settings.preferences.showTailColor == Color.Empty) { settings.preferences.showTailColor = Color.FromKnownColor(KnownColor.Blue); } if (settings.preferences.timeSpreadColor == Color.Empty) { settings.preferences.timeSpreadColor = Color.Gray; } if (settings.preferences.bufferCount < 10) { settings.preferences.bufferCount = 100; } if (settings.preferences.linesPerBuffer < 1) { settings.preferences.linesPerBuffer = 500; } if (settings.filterList == null) { settings.filterList = new List <FilterParams>(); } if (settings.searchHistoryList == null) { settings.searchHistoryList = new List <string>(); } if (settings.filterHistoryList == null) { settings.filterHistoryList = new List <string>(); } if (settings.filterRangeHistoryList == null) { settings.filterRangeHistoryList = new List <string>(); } foreach (FilterParams filterParams in settings.filterList) { filterParams.Init(); } if (settings.hilightGroupList == null) { settings.hilightGroupList = new List <HilightGroup>(); // migrate old non-grouped entries HilightGroup defaultGroup = new HilightGroup(); defaultGroup.GroupName = "[Default]"; defaultGroup.HilightEntryList = settings.hilightEntryList; settings.hilightGroupList.Add(defaultGroup); } if (settings.preferences.highlightMaskList == null) { settings.preferences.highlightMaskList = new List <HighlightMaskEntry>(); } if (settings.preferences.pollingInterval < 20) { settings.preferences.pollingInterval = 250; } if (settings.preferences.multiFileOptions == null) { settings.preferences.multiFileOptions = new MultiFileOptions(); } if (settings.preferences.defaultEncoding == null) { settings.preferences.defaultEncoding = Encoding.Default.HeaderName; } if (settings.preferences.maximumFilterEntriesDisplayed == 0) { settings.preferences.maximumFilterEntriesDisplayed = 20; } if (settings.preferences.maximumFilterEntries == 0) { settings.preferences.maximumFilterEntries = 30; } ConvertSettings(settings); return(settings); } }