Skip to content

Commit

Permalink
Implement a message content size adjustment in KryptonTaskDialog (#92)
Browse files Browse the repository at this point in the history
* Fix placement of build artifacts of KryptonExplorer

* Adjust build location of Designer. Guard file execution in Explorer

* Adjust hint paths in all example projects (addition to issue #87)

* Implement a message content size adjustment

The content display control of the KryptonTaskDialog is changed
based on the size of the content.  If the content contains more
than 20 lines of text, the control changes to a multi-line text
container.  The size of the KryptonTaskDialog is also limitted
to 0.6 size of the display area to fix the issue of displaying
very large dialog boxes that don't fit in a screen.
  • Loading branch information
saleyn authored and ComponentFactory committed Dec 21, 2017
1 parent 9d78c8a commit 5463f83
Show file tree
Hide file tree
Showing 99 changed files with 268 additions and 181 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,8 @@
<PropertyGroup>
<PostBuildEvent>rem "$(ProjectDir)..\GacUtil.exe" -i "$(TargetPath)" /f
copy "$(ProjectDir)..\GacUtil.exe" "$(ProjectDir)..\..\..\build\bin\$(Configuration)\"
copy "$(ProjectDir)..\RegisterToGAC.bat" "$(ProjectDir)..\..\..\build\bin\$(Configuration)\"</PostBuildEvent>
copy "$(ProjectDir)..\RegisterToGAC.bat" "$(ProjectDir)..\..\..\build\bin\$(Configuration)\"
copy "$(ProjectDir)..\UnRegisterFromGAC.bat" "$(ProjectDir)..\..\..\build\bin\$(Configuration)\"</PostBuildEvent>
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ protected override void WndProc(ref Message m)
private KryptonPanel _panelMainText;
private KryptonWrapLabel _messageText;
private KryptonWrapLabel _messageContent;
private KryptonTextBox _messageContentMultiline;
private KryptonPanel _panelButtons;
private MessageButton _buttonOK;
private MessageButton _buttonYes;
Expand Down Expand Up @@ -215,7 +216,21 @@ private void UpdateText()
{
Text = _windowTitle;
_messageText.Text = _mainInstruction;
_messageContent.Text = _content;
// If the content has more than 20 lines, use the multiline text control
if (string.IsNullOrEmpty(_content))
_messageContent.Text = string.Empty;
else if (_content.Length - _content.Replace("\n", "").Length > 20)
{
_messageContentMultiline.Text = _content;
_messageContentMultiline.Visible = true;
_messageContent.Visible = false;
}
else
{
_messageContent.Text = _content;
_messageContentMultiline.Visible = false;
_messageContent.Visible = true;
}
}

private void UpdateIcon()
Expand Down Expand Up @@ -522,14 +537,26 @@ private void UpdateSizing()

private Size UpdateMainTextSizing()
{
Size messageContentSize;

// Update size of the main instruction and content labels but applying a sensible maximum
using (Graphics g = CreateGraphics())
{
// Find size of the labels when it has a maximum length of 400
_messageText.UpdateFont();
_messageContent.UpdateFont();
_messageContentMultiline.Font = _messageContent.Font;
Size messageMainSize = g.MeasureString(_mainInstruction, _messageText.Font, 400).ToSize();
Size messageContentSize = g.MeasureString(_content, _messageContent.Font, 400).ToSize();
messageContentSize = g.MeasureString(_content, _messageContent.Font, 400).ToSize();

// Get the display size and make sure that the content size is not greater than 0.6 of display size
var dispSize = Screen.GetWorkingArea(this.Location);

var h = (int)Math.Min(messageContentSize.Height, dispSize.Height * 0.6);
var w = (int)Math.Min(messageContentSize.Width, dispSize.Width * 0.6);
var sz = new Size(w, h);
if (messageContentSize != sz)
messageContentSize = sz;

// Work out DPI adjustment factor
float factorX = g.DpiX > 96 ? (1.0f * g.DpiX / 96) : 1.0f;
Expand All @@ -545,15 +572,17 @@ private Size UpdateMainTextSizing()
messageContentSize.Width += 5;
_messageText.Size = messageMainSize;
_messageContent.Size = messageContentSize;
_messageContentMultiline.Size = messageContentSize;
}

// Resize panel containing the main text
Padding panelMessagePadding = _panelMainText.Padding;
_panelMainText.Width = Math.Max(_messageText.Size.Width, _messageContent.Size.Width) + panelMessagePadding.Horizontal;
_panelMainText.Height = _messageText.Size.Height + _messageContent.Size.Height + panelMessagePadding.Vertical + BUTTON_GAP;
_panelMainText.Width = Math.Max(_messageText.Size.Width, messageContentSize.Width) + panelMessagePadding.Horizontal;
_panelMainText.Height = _messageText.Size.Height + messageContentSize.Height + panelMessagePadding.Vertical + BUTTON_GAP;

// Position the content label below the main label
_messageContent.Location = new Point(_messageText.Left + 2, _messageText.Bottom);
_messageContentMultiline.Location = _messageContent.Location;
return _panelMainText.Size;
}

Expand Down Expand Up @@ -923,6 +952,7 @@ private void InitializeComponent()
this._panelMainRadio = new ComponentFactory.Krypton.Toolkit.KryptonPanel();
this._panelMainText = new ComponentFactory.Krypton.Toolkit.KryptonPanel();
this._messageContent = new ComponentFactory.Krypton.Toolkit.KryptonWrapLabel();
this._messageContentMultiline = new ComponentFactory.Krypton.Toolkit.KryptonTextBox();
this._messageText = new ComponentFactory.Krypton.Toolkit.KryptonWrapLabel();
this._panelIcon = new ComponentFactory.Krypton.Toolkit.KryptonPanel();
this._messageIcon = new System.Windows.Forms.PictureBox();
Expand Down Expand Up @@ -969,7 +999,7 @@ private void InitializeComponent()
this._panelMain.Dock = System.Windows.Forms.DockStyle.Top;
this._panelMain.Location = new System.Drawing.Point(0, 0);
this._panelMain.Name = "_panelMain";
this._panelMain.Size = new System.Drawing.Size(408, 72);
this._panelMain.Size = new System.Drawing.Size(544, 72);
this._panelMain.TabIndex = 0;
//
// _panelMainSpacer
Expand Down Expand Up @@ -1001,12 +1031,13 @@ private void InitializeComponent()
//
this._panelMainText.AutoSize = true;
this._panelMainText.Controls.Add(this._messageContent);
this._panelMainText.Controls.Add(this._messageContentMultiline);
this._panelMainText.Controls.Add(this._messageText);
this._panelMainText.Location = new System.Drawing.Point(42, 0);
this._panelMainText.Margin = new System.Windows.Forms.Padding(0);
this._panelMainText.Name = "_panelMainText";
this._panelMainText.Padding = new System.Windows.Forms.Padding(5, 5, 5, 0);
this._panelMainText.Size = new System.Drawing.Size(149, 60);
this._panelMainText.Size = new System.Drawing.Size(357, 60);
this._panelMainText.TabIndex = 0;
//
// _messageContent
Expand All @@ -1020,6 +1051,16 @@ private void InitializeComponent()
this._messageContent.Name = "_messageContent";
this._messageContent.Size = new System.Drawing.Size(78, 15);
this._messageContent.Text = "Content";
//
// _messageContentMultiline
//
this._messageContentMultiline.Location = new System.Drawing.Point(48, 45);
this._messageContentMultiline.Multiline = true;
this._messageContentMultiline.Name = "_messageContentMultiline";
this._messageContentMultiline.ReadOnly = true;
this._messageContentMultiline.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this._messageContentMultiline.Size = new System.Drawing.Size(351, 10);
this._messageContentMultiline.TabIndex = 4;
//
// _messageText
//
Expand Down Expand Up @@ -1070,7 +1111,7 @@ private void InitializeComponent()
this._panelButtons.Margin = new System.Windows.Forms.Padding(0);
this._panelButtons.Name = "_panelButtons";
this._panelButtons.PanelBackStyle = ComponentFactory.Krypton.Toolkit.PaletteBackStyle.PanelAlternate;
this._panelButtons.Size = new System.Drawing.Size(408, 46);
this._panelButtons.Size = new System.Drawing.Size(544, 46);
this._panelButtons.TabIndex = 1;
//
// _checkBox
Expand All @@ -1089,7 +1130,7 @@ private void InitializeComponent()
this._panelButtonsBorderTop.Dock = System.Windows.Forms.DockStyle.Top;
this._panelButtonsBorderTop.Location = new System.Drawing.Point(0, 0);
this._panelButtonsBorderTop.Name = "_panelButtonsBorderTop";
this._panelButtonsBorderTop.Size = new System.Drawing.Size(408, 1);
this._panelButtonsBorderTop.Size = new System.Drawing.Size(544, 1);
this._panelButtonsBorderTop.Text = "kryptonBorderEdge1";
//
// _buttonOK
Expand All @@ -1098,7 +1139,7 @@ private void InitializeComponent()
this._buttonOK.AutoSize = true;
this._buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
this._buttonOK.IgnoreAltF4 = false;
this._buttonOK.Location = new System.Drawing.Point(299, 9);
this._buttonOK.Location = new System.Drawing.Point(435, 9);
this._buttonOK.Margin = new System.Windows.Forms.Padding(0);
this._buttonOK.MinimumSize = new System.Drawing.Size(50, 26);
this._buttonOK.Name = "_buttonOK";
Expand All @@ -1113,7 +1154,7 @@ private void InitializeComponent()
this._buttonYes.AutoSize = true;
this._buttonYes.DialogResult = System.Windows.Forms.DialogResult.Yes;
this._buttonYes.IgnoreAltF4 = false;
this._buttonYes.Location = new System.Drawing.Point(199, 9);
this._buttonYes.Location = new System.Drawing.Point(335, 9);
this._buttonYes.Margin = new System.Windows.Forms.Padding(0);
this._buttonYes.MinimumSize = new System.Drawing.Size(50, 26);
this._buttonYes.Name = "_buttonYes";
Expand All @@ -1128,7 +1169,7 @@ private void InitializeComponent()
this._buttonNo.AutoSize = true;
this._buttonNo.DialogResult = System.Windows.Forms.DialogResult.No;
this._buttonNo.IgnoreAltF4 = false;
this._buttonNo.Location = new System.Drawing.Point(149, 9);
this._buttonNo.Location = new System.Drawing.Point(285, 9);
this._buttonNo.Margin = new System.Windows.Forms.Padding(0);
this._buttonNo.MinimumSize = new System.Drawing.Size(50, 26);
this._buttonNo.Name = "_buttonNo";
Expand All @@ -1143,7 +1184,7 @@ private void InitializeComponent()
this._buttonRetry.AutoSize = true;
this._buttonRetry.DialogResult = System.Windows.Forms.DialogResult.Retry;
this._buttonRetry.IgnoreAltF4 = false;
this._buttonRetry.Location = new System.Drawing.Point(249, 9);
this._buttonRetry.Location = new System.Drawing.Point(385, 9);
this._buttonRetry.Margin = new System.Windows.Forms.Padding(0);
this._buttonRetry.MinimumSize = new System.Drawing.Size(50, 26);
this._buttonRetry.Name = "_buttonRetry";
Expand All @@ -1158,7 +1199,7 @@ private void InitializeComponent()
this._buttonCancel.AutoSize = true;
this._buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this._buttonCancel.IgnoreAltF4 = false;
this._buttonCancel.Location = new System.Drawing.Point(92, 9);
this._buttonCancel.Location = new System.Drawing.Point(228, 9);
this._buttonCancel.Margin = new System.Windows.Forms.Padding(0);
this._buttonCancel.MinimumSize = new System.Drawing.Size(50, 26);
this._buttonCancel.Name = "_buttonCancel";
Expand All @@ -1172,7 +1213,7 @@ private void InitializeComponent()
this._buttonClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this._buttonClose.AutoSize = true;
this._buttonClose.IgnoreAltF4 = false;
this._buttonClose.Location = new System.Drawing.Point(349, 9);
this._buttonClose.Location = new System.Drawing.Point(485, 9);
this._buttonClose.Margin = new System.Windows.Forms.Padding(0);
this._buttonClose.MinimumSize = new System.Drawing.Size(50, 26);
this._buttonClose.Name = "_buttonClose";
Expand All @@ -1192,7 +1233,7 @@ private void InitializeComponent()
this._panelFooter.Location = new System.Drawing.Point(0, 118);
this._panelFooter.Name = "_panelFooter";
this._panelFooter.PanelBackStyle = ComponentFactory.Krypton.Toolkit.PaletteBackStyle.PanelAlternate;
this._panelFooter.Size = new System.Drawing.Size(408, 49);
this._panelFooter.Size = new System.Drawing.Size(544, 49);
this._panelFooter.TabIndex = 2;
//
// _linkLabelFooter
Expand Down Expand Up @@ -1233,14 +1274,15 @@ private void InitializeComponent()
this._panelFooterBorderTop.Dock = System.Windows.Forms.DockStyle.Top;
this._panelFooterBorderTop.Location = new System.Drawing.Point(0, 0);
this._panelFooterBorderTop.Name = "_panelFooterBorderTop";
this._panelFooterBorderTop.Size = new System.Drawing.Size(408, 1);
this._panelFooterBorderTop.Size = new System.Drawing.Size(544, 1);
this._panelFooterBorderTop.Text = "kryptonBorderEdge1";
//
// VisualTaskDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(408, 164);
this.AutoScroll = true;
this.ClientSize = new System.Drawing.Size(561, 164);
this.Controls.Add(this._panelFooter);
this.Controls.Add(this._panelButtons);
this.Controls.Add(this._panelMain);
Expand Down
Empty file modified Source/Krypton Components/RegisterToGAC.bat
100644 → 100755
Empty file.
6 changes: 6 additions & 0 deletions Source/Krypton Components/UnRegisterFromGAC.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gacutil.exe -u "ComponentFactory.Krypton.Design.dll"
gacutil.exe -u "ComponentFactory.Krypton.Docking.dll"
gacutil.exe -u "ComponentFactory.Krypton.Navigator.dll"
gacutil.exe -u "ComponentFactory.Krypton.Ribbon.dll"
gacutil.exe -u "ComponentFactory.Krypton.Toolkit.dll"
gacutil.exe -u "ComponentFactory.Krypton.Workspace.dll"
Empty file modified Source/Krypton Components/gacutil.exe
100644 → 100755
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,23 @@
<ItemGroup>
<Reference Include="ComponentFactory.Krypton.Ribbon, Version=4.4.0.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Bin\ComponentFactory.Krypton.Ribbon.dll</HintPath>
<HintPath>../../../build/bin/ComponentFactory.Krypton.Ribbon.dll</HintPath>
</Reference>
<Reference Include="ComponentFactory.Krypton.Toolkit, Version=4.4.0.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Bin\ComponentFactory.Krypton.Toolkit.dll</HintPath>
<HintPath>../../../build/bin/ComponentFactory.Krypton.Toolkit.dll</HintPath>
</Reference>
<Reference Include="ComponentFactory.Krypton.Docking, Version=4.4.0.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Bin\ComponentFactory.Krypton.Docking.dll</HintPath>
<HintPath>../../../build/bin/ComponentFactory.Krypton.Docking.dll</HintPath>
</Reference>
<Reference Include="ComponentFactory.Krypton.Navigator, Version=4.4.0.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Bin\ComponentFactory.Krypton.Navigator.dll</HintPath>
<HintPath>../../../build/bin/ComponentFactory.Krypton.Navigator.dll</HintPath>
</Reference>
<Reference Include="ComponentFactory.Krypton.Workspace, Version=4.4.0.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Bin\ComponentFactory.Krypton.Workspace.dll</HintPath>
<HintPath>../../../build/bin/ComponentFactory.Krypton.Workspace.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,23 @@
<ItemGroup>
<Reference Include="ComponentFactory.Krypton.Ribbon, Version=4.4.0.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Bin\ComponentFactory.Krypton.Ribbon.dll</HintPath>
<HintPath>../../../build/bin/ComponentFactory.Krypton.Ribbon.dll</HintPath>
</Reference>
<Reference Include="ComponentFactory.Krypton.Toolkit, Version=4.4.0.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Bin\ComponentFactory.Krypton.Toolkit.dll</HintPath>
<HintPath>../../../build/bin/ComponentFactory.Krypton.Toolkit.dll</HintPath>
</Reference>
<Reference Include="ComponentFactory.Krypton.Docking, Version=4.4.0.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Bin\ComponentFactory.Krypton.Docking.dll</HintPath>
<HintPath>../../../build/bin/ComponentFactory.Krypton.Docking.dll</HintPath>
</Reference>
<Reference Include="ComponentFactory.Krypton.Navigator, Version=4.4.0.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Bin\ComponentFactory.Krypton.Navigator.dll</HintPath>
<HintPath>../../../build/bin/ComponentFactory.Krypton.Navigator.dll</HintPath>
</Reference>
<Reference Include="ComponentFactory.Krypton.Workspace, Version=4.4.0.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Bin\ComponentFactory.Krypton.Workspace.dll</HintPath>
<HintPath>../../../build/bin/ComponentFactory.Krypton.Workspace.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,23 @@
<ItemGroup>
<Reference Include="ComponentFactory.Krypton.Ribbon, Version=4.4.0.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Bin\ComponentFactory.Krypton.Ribbon.dll</HintPath>
<HintPath>../../../build/bin/ComponentFactory.Krypton.Ribbon.dll</HintPath>
</Reference>
<Reference Include="ComponentFactory.Krypton.Toolkit, Version=4.4.0.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Bin\ComponentFactory.Krypton.Toolkit.dll</HintPath>
<HintPath>../../../build/bin/ComponentFactory.Krypton.Toolkit.dll</HintPath>
</Reference>
<Reference Include="ComponentFactory.Krypton.Docking, Version=4.4.0.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Bin\ComponentFactory.Krypton.Docking.dll</HintPath>
<HintPath>../../../build/bin/ComponentFactory.Krypton.Docking.dll</HintPath>
</Reference>
<Reference Include="ComponentFactory.Krypton.Navigator, Version=4.4.0.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Bin\ComponentFactory.Krypton.Navigator.dll</HintPath>
<HintPath>../../../build/bin/ComponentFactory.Krypton.Navigator.dll</HintPath>
</Reference>
<Reference Include="ComponentFactory.Krypton.Workspace, Version=4.4.0.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Bin\ComponentFactory.Krypton.Workspace.dll</HintPath>
<HintPath>../../../build/bin/ComponentFactory.Krypton.Workspace.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
Expand Down
Loading

0 comments on commit 5463f83

Please sign in to comment.