Implemented the current section's path

- Added label for path
- Increased the min. height for the component
This commit is contained in:
Thorsten Sommer 2022-07-12 21:05:50 +02:00
parent 5428cb9489
commit 620bc992a8
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
3 changed files with 46 additions and 10 deletions

View File

@ -110,9 +110,9 @@
// splitContainerRTB.Panel1 // splitContainerRTB.Panel1
// //
this.splitContainerRTB.Panel1.Controls.Add(this.textElements); this.splitContainerRTB.Panel1.Controls.Add(this.textElements);
this.splitContainerRTB.Panel1MinSize = 200; this.splitContainerRTB.Panel1MinSize = 240;
this.splitContainerRTB.Size = new System.Drawing.Size(636, 531); this.splitContainerRTB.Size = new System.Drawing.Size(636, 531);
this.splitContainerRTB.SplitterDistance = 211; this.splitContainerRTB.SplitterDistance = 240;
this.splitContainerRTB.TabIndex = 0; this.splitContainerRTB.TabIndex = 0;
// //
// textElements // textElements
@ -121,7 +121,7 @@
this.textElements.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this.textElements.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.textElements.Location = new System.Drawing.Point(0, 0); this.textElements.Location = new System.Drawing.Point(0, 0);
this.textElements.Name = "textElements"; this.textElements.Name = "textElements";
this.textElements.Size = new System.Drawing.Size(634, 209); this.textElements.Size = new System.Drawing.Size(634, 238);
this.textElements.TabIndex = 0; this.textElements.TabIndex = 0;
// //
// Main // Main

View File

@ -38,6 +38,7 @@
this.textBoxFilter = new System.Windows.Forms.TextBox(); this.textBoxFilter = new System.Windows.Forms.TextBox();
this.labelFilter = new System.Windows.Forms.Label(); this.labelFilter = new System.Windows.Forms.Label();
this.toolTip = new System.Windows.Forms.ToolTip(this.components); this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.labelSectionPath = new System.Windows.Forms.Label();
this.tableLayout.SuspendLayout(); this.tableLayout.SuspendLayout();
this.flowLayoutToolbar.SuspendLayout(); this.flowLayoutToolbar.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
@ -49,13 +50,15 @@
this.tableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 80F)); this.tableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 80F));
this.tableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayout.Controls.Add(this.flowLayoutToolbar, 0, 0); this.tableLayout.Controls.Add(this.flowLayoutToolbar, 0, 0);
this.tableLayout.Controls.Add(this.listTextElements, 1, 0); this.tableLayout.Controls.Add(this.listTextElements, 1, 1);
this.tableLayout.Controls.Add(this.textBoxFilter, 2, 1); this.tableLayout.Controls.Add(this.textBoxFilter, 2, 2);
this.tableLayout.Controls.Add(this.labelFilter, 1, 1); this.tableLayout.Controls.Add(this.labelFilter, 1, 2);
this.tableLayout.Controls.Add(this.labelSectionPath, 1, 0);
this.tableLayout.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayout.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayout.Location = new System.Drawing.Point(0, 0); this.tableLayout.Location = new System.Drawing.Point(0, 0);
this.tableLayout.Name = "tableLayout"; this.tableLayout.Name = "tableLayout";
this.tableLayout.RowCount = 2; this.tableLayout.RowCount = 3;
this.tableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F));
this.tableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F)); this.tableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F));
this.tableLayout.Size = new System.Drawing.Size(706, 201); this.tableLayout.Size = new System.Drawing.Size(706, 201);
@ -71,7 +74,7 @@
this.flowLayoutToolbar.Location = new System.Drawing.Point(0, 0); this.flowLayoutToolbar.Location = new System.Drawing.Point(0, 0);
this.flowLayoutToolbar.Margin = new System.Windows.Forms.Padding(0); this.flowLayoutToolbar.Margin = new System.Windows.Forms.Padding(0);
this.flowLayoutToolbar.Name = "flowLayoutToolbar"; this.flowLayoutToolbar.Name = "flowLayoutToolbar";
this.tableLayout.SetRowSpan(this.flowLayoutToolbar, 2); this.tableLayout.SetRowSpan(this.flowLayoutToolbar, 3);
this.flowLayoutToolbar.Size = new System.Drawing.Size(66, 201); this.flowLayoutToolbar.Size = new System.Drawing.Size(66, 201);
this.flowLayoutToolbar.TabIndex = 0; this.flowLayoutToolbar.TabIndex = 0;
// //
@ -121,10 +124,10 @@
this.listTextElements.FormattingEnabled = true; this.listTextElements.FormattingEnabled = true;
this.listTextElements.IntegralHeight = false; this.listTextElements.IntegralHeight = false;
this.listTextElements.ItemHeight = 28; this.listTextElements.ItemHeight = 28;
this.listTextElements.Location = new System.Drawing.Point(69, 3); this.listTextElements.Location = new System.Drawing.Point(69, 43);
this.listTextElements.Name = "listTextElements"; this.listTextElements.Name = "listTextElements";
this.listTextElements.ScrollAlwaysVisible = true; this.listTextElements.ScrollAlwaysVisible = true;
this.listTextElements.Size = new System.Drawing.Size(634, 155); this.listTextElements.Size = new System.Drawing.Size(634, 115);
this.listTextElements.TabIndex = 1; this.listTextElements.TabIndex = 1;
// //
// textBoxFilter // textBoxFilter
@ -155,6 +158,19 @@
this.toolTip.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info; this.toolTip.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info;
this.toolTip.ToolTipTitle = "Help"; this.toolTip.ToolTipTitle = "Help";
// //
// labelSectionPath
//
this.labelSectionPath.AutoSize = true;
this.tableLayout.SetColumnSpan(this.labelSectionPath, 2);
this.labelSectionPath.Dock = System.Windows.Forms.DockStyle.Fill;
this.labelSectionPath.Location = new System.Drawing.Point(69, 0);
this.labelSectionPath.Name = "labelSectionPath";
this.labelSectionPath.Size = new System.Drawing.Size(634, 40);
this.labelSectionPath.TabIndex = 4;
this.labelSectionPath.Text = "Path";
this.labelSectionPath.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.toolTip.SetToolTip(this.labelSectionPath, "The path of the currently selected section");
//
// TextElements // TextElements
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(120F, 120F); this.AutoScaleDimensions = new System.Drawing.SizeF(120F, 120F);
@ -181,5 +197,6 @@
private ListBox listTextElements; private ListBox listTextElements;
private TextBox textBoxFilter; private TextBox textBoxFilter;
private Label labelFilter; private Label labelFilter;
private Label labelSectionPath;
} }
} }

View File

@ -1,20 +1,39 @@
using DataModel.Database; using DataModel.Database;
using DataModel.Database.Common;
using Microsoft.Extensions.DependencyInjection;
using Processor;
namespace UI_WinForms.Components; namespace UI_WinForms.Components;
public partial class TextElements : UserControl public partial class TextElements : UserControl
{ {
private readonly DataContext db;
private Section? currentSection; private Section? currentSection;
public TextElements() public TextElements()
{ {
this.InitializeComponent(); this.InitializeComponent();
// Check if we are in the designer:
if(Program.SERVICE_PROVIDER is null)
return;
// Get the DI context from the main form:
this.db = Program.SERVICE_PROVIDER.GetService<DataContext>()!;
// Dispose of the context when the control is disposed:
this.Disposed += (_, _) => this.db.Dispose();
// When the section is changed, update this component: // When the section is changed, update this component:
AppEvents.WhenSectionChanged += (sender, section) => AppEvents.WhenSectionChanged += (sender, section) =>
{ {
this.currentSection = section; this.currentSection = section;
this.buttonAdd.Enabled = this.currentSection is not null; this.buttonAdd.Enabled = this.currentSection is not null;
// Update the path:
if (this.currentSection is not null)
this.labelSectionPath.Text = SectionProcessor.GetSectionPath(this.db, this.currentSection.DataKey);
}; };
} }
} }