From d7127bd2e13df32616e9bdf93cad208387341192 Mon Sep 17 00:00:00 2001 From: "Sergey V. Zhdanovskih" Date: Wed, 6 Mar 2024 00:26:31 +0300 Subject: [PATCH] Minor improvements --- projects/GKCore/GKCore.csproj | 1 + .../Controllers/RecordSelectDlgController.cs | 9 ++++- .../GKCore/GKCore/Lists/SourceListModel.cs | 4 +- .../GKUI/Forms/RecordSelectDlg.Designer.cs | 7 ++-- .../GEDKeeper2/GKUI/Forms/RecordSelectDlg.cs | 12 +++++- .../GKUI/Components/GKListView.cs | 18 ++++++++- .../GKv3/GEDKeeper3/GKUI/Forms/BaseWinSDI.cs | 38 +++++++++++++++++++ .../GKUI/Forms/FilePropertiesDlg.xeto | 2 +- .../GEDKeeper3/GKUI/Forms/RecordSelectDlg.cs | 21 +++++++++- .../GKUI/Forms/RecordSelectDlg.xeto | 8 ++-- .../GKUI/Forms/RelationshipCalculatorDlg.xeto | 2 +- .../GEDKeeper3/GKUI/Forms/SourceEditDlg.xeto | 8 ++-- .../GKv3/GKComponents/GKComponents.csproj | 2 +- .../GKUI/Components/GKListView.cs | 16 +++++++- .../GKUI/Components/GKSheetList.cs | 5 +++ 15 files changed, 132 insertions(+), 21 deletions(-) diff --git a/projects/GKCore/GKCore.csproj b/projects/GKCore/GKCore.csproj index 9538b29e1..1e80b2a3c 100644 --- a/projects/GKCore/GKCore.csproj +++ b/projects/GKCore/GKCore.csproj @@ -373,6 +373,7 @@ + diff --git a/projects/GKCore/GKCore/Controllers/RecordSelectDlgController.cs b/projects/GKCore/GKCore/Controllers/RecordSelectDlgController.cs index 1fd7289dd..f9f770fa6 100644 --- a/projects/GKCore/GKCore/Controllers/RecordSelectDlgController.cs +++ b/projects/GKCore/GKCore/Controllers/RecordSelectDlgController.cs @@ -1,6 +1,6 @@ /* * "GEDKeeper", the personal genealogical database editor. - * Copyright (C) 2009-2023 by Sergey V. Zhdanovskih. + * Copyright (C) 2009-2024 by Sergey V. Zhdanovskih. * * This file is part of "GEDKeeper". * @@ -197,6 +197,13 @@ public override void UpdateView() } recordsList.UpdateContents(); + + UpdateButtons(); + } + + private void UpdateButtons() + { + GetControl("btnSelect").Enabled = fView.RecordsList.ListMan.FilteredCount > 0; } public override void SetLocale() diff --git a/projects/GKCore/GKCore/Lists/SourceListModel.cs b/projects/GKCore/GKCore/Lists/SourceListModel.cs index 30ef8e24e..3fc698da5 100644 --- a/projects/GKCore/GKCore/Lists/SourceListModel.cs +++ b/projects/GKCore/GKCore/Lists/SourceListModel.cs @@ -95,11 +95,11 @@ protected override object GetColumnValueEx(int colType, int colSubtype, bool isV break; case ColumnType.ctAuthor: - result = fFetchedRec.Originator.Lines.Text.Trim(); + result = GKUtils.MergeStrings(fFetchedRec.Originator.Lines); break; case ColumnType.ctTitle: - result = fFetchedRec.Title.Lines.Text.Trim(); + result = GKUtils.MergeStrings(fFetchedRec.Title.Lines); break; //case ColumnType.ctPublication: diff --git a/projects/GKv2/GEDKeeper2/GKUI/Forms/RecordSelectDlg.Designer.cs b/projects/GKv2/GEDKeeper2/GKUI/Forms/RecordSelectDlg.Designer.cs index 07574c947..ed04ac55e 100644 --- a/projects/GKv2/GEDKeeper2/GKUI/Forms/RecordSelectDlg.Designer.cs +++ b/projects/GKv2/GEDKeeper2/GKUI/Forms/RecordSelectDlg.Designer.cs @@ -28,17 +28,17 @@ private void InitializeComponent() this.btnSelect.Location = new System.Drawing.Point(280, 466); this.btnSelect.Name = "btnSelect"; this.btnSelect.Size = new System.Drawing.Size(113, 31); - this.btnSelect.TabIndex = 3; + this.btnSelect.TabIndex = 2; this.btnSelect.Text = "btnSelect"; this.btnSelect.TextAlign = System.Drawing.ContentAlignment.MiddleRight; this.btnSelect.Click += new System.EventHandler(this.btnSelect_Click); // // btnCreate - // + // this.btnCreate.Location = new System.Drawing.Point(146, 466); this.btnCreate.Name = "btnCreate"; this.btnCreate.Size = new System.Drawing.Size(113, 31); - this.btnCreate.TabIndex = 2; + this.btnCreate.TabIndex = 3; this.btnCreate.Text = "btnCreate"; this.btnCreate.Click += new System.EventHandler(this.btnCreate_Click); // @@ -78,6 +78,7 @@ private void InitializeComponent() this.fltCtl.Name = "fltCtl"; this.fltCtl.Size = new System.Drawing.Size(36, 32); this.fltCtl.TabIndex = 1; + this.fltCtl.TabStop = false; // // panList // diff --git a/projects/GKv2/GEDKeeper2/GKUI/Forms/RecordSelectDlg.cs b/projects/GKv2/GEDKeeper2/GKUI/Forms/RecordSelectDlg.cs index 3fe7561d9..3a2a91119 100644 --- a/projects/GKv2/GEDKeeper2/GKUI/Forms/RecordSelectDlg.cs +++ b/projects/GKv2/GEDKeeper2/GKUI/Forms/RecordSelectDlg.cs @@ -1,6 +1,6 @@ /* * "GEDKeeper", the personal genealogical database editor. - * Copyright (C) 2009-2023 by Sergey V. Zhdanovskih. + * Copyright (C) 2009-2024 by Sergey V. Zhdanovskih. * * This file is part of "GEDKeeper". * @@ -73,6 +73,8 @@ public RecordSelectDlg(IBaseWindow baseWin, GDMRecordType recType) { InitializeComponent(); + TabIndexChanged += Form_TabIndexChanged; + btnSelect.Image = UIHelper.LoadResourceImage("Resources.btn_accept.gif"); btnCancel.Image = UIHelper.LoadResourceImage("Resources.btn_cancel.gif"); @@ -92,6 +94,14 @@ public RecordSelectDlg(IBaseWindow baseWin, GDMRecordType recType) UpdateRecordsView(); } + private void Form_TabIndexChanged(object sender, EventArgs e) + { + if (fltCtl.Focused) { + fListRecords.Focus(); + fListRecords.SelectItem(0); + } + } + protected override void Dispose(bool disposing) { if (disposing) { diff --git a/projects/GKv2/GKComponents/GKUI/Components/GKListView.cs b/projects/GKv2/GKComponents/GKUI/Components/GKListView.cs index 28674c636..c3dbac09b 100644 --- a/projects/GKv2/GKComponents/GKUI/Components/GKListView.cs +++ b/projects/GKv2/GKComponents/GKUI/Components/GKListView.cs @@ -1,6 +1,6 @@ /* * "GEDKeeper", the personal genealogical database editor. - * Copyright (C) 2009-2023 by Sergey V. Zhdanovskih. + * Copyright (C) 2009-2024 by Sergey V. Zhdanovskih. * * This file is part of "GEDKeeper". * @@ -283,6 +283,10 @@ public BSDSortOrder SortOrder set { fSortOrder = value; } } + + public event EventHandler ItemsUpdated; + + public GKListView() { fAppearance = new ListViewAppearance(this); @@ -558,6 +562,12 @@ public void SortModelColumn(int columnId) } } + private void DoItemsUpdated() + { + var eventHandler = ItemsUpdated; + if (eventHandler != null) eventHandler(this, new EventArgs()); + } + public void UpdateContents(bool columnsChanged = false) { if (fListMan == null) return; @@ -584,6 +594,8 @@ public void UpdateContents(bool columnsChanged = false) } finally { EndUpdate(); if (tempRec != null) SelectItem(tempRec); + + DoItemsUpdated(); } } catch (Exception ex) { Logger.WriteError("GKListView.UpdateContents()", ex); @@ -768,6 +780,10 @@ private void SelectItem(int index, GKListItem item) public void SelectItem(int index) { + if (index == -1) { + index = Items.Count - 1; + } + if (index >= 0 && index < Items.Count) { var item = (GKListItem)Items[index]; SelectItem(index, item); diff --git a/projects/GKv3/GEDKeeper3/GKUI/Forms/BaseWinSDI.cs b/projects/GKv3/GEDKeeper3/GKUI/Forms/BaseWinSDI.cs index fb4b2519c..400bdb8fd 100644 --- a/projects/GKv3/GEDKeeper3/GKUI/Forms/BaseWinSDI.cs +++ b/projects/GKv3/GEDKeeper3/GKUI/Forms/BaseWinSDI.cs @@ -250,6 +250,7 @@ private void CreatePage(string pageText, GDMRecordType recType) recView.AllowMultipleSelection = true; recView.MouseDoubleClick += miRecordEdit_Click; recView.SelectedItemsChanged += List_SelectedIndexChanged; + recView.KeyDown += Form_KeyDown; recView.ContextMenu = contextMenu; recView.ListMan = RecordsListModel.Create(fContext, recType, false); recView.UpdateContents(); @@ -342,6 +343,43 @@ private void BaseContext_ModifiedChanged(object sender, EventArgs e) private void Form_KeyDown(object sender, KeyEventArgs e) { + switch (e.Key) { + /*case Keys.I: + ItemAdd(); + break; + case Keys.D: + ItemDelete(); + break;*/ + + case Keys.Enter: + if (e.Control) { + EditRecord(); + e.Handled = true; + } + break; + + case Keys.Home: + case Keys.End: + if (sender is GKListView) { + var listView = sender as GKListView; + if (e.Key == Keys.Home) { + listView.SelectedIndex = 0; + } else { + listView.SelectedIndex = -1; + } + e.Handled = true; + } + break; + + case Keys.F12: + break; + + /*case Keys.F: + if (e.Control) { + QuickFind(); + } + break;*/ + } } private void contextMenu_Opening(object sender, EventArgs e) diff --git a/projects/GKv3/GEDKeeper3/GKUI/Forms/FilePropertiesDlg.xeto b/projects/GKv3/GEDKeeper3/GKUI/Forms/FilePropertiesDlg.xeto index 95be7df6a..249674e83 100644 --- a/projects/GKv3/GEDKeeper3/GKUI/Forms/FilePropertiesDlg.xeto +++ b/projects/GKv3/GEDKeeper3/GKUI/Forms/FilePropertiesDlg.xeto @@ -16,7 +16,7 @@