Skip to content

Commit

Permalink
Merge pull request #356 from VPKSoft/fix_scripting
Browse files Browse the repository at this point in the history
Fix scripting
  • Loading branch information
Petteri Kautonen authored Oct 20, 2022
2 parents 1674e89 + f38e3d3 commit d0e1ebe
Show file tree
Hide file tree
Showing 161 changed files with 22,605 additions and 22,663 deletions.
138 changes: 68 additions & 70 deletions CustomControls/ComboBoxCustomSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
MIT License
Copyright(c) 2021 Petteri Kautonen
Copyright(c) 2022 Petteri Kautonen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -29,91 +29,89 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
using System.Linq;
using System.Windows.Forms;

namespace CustomControls
namespace CustomControls;
// Parts of the code from (C): https://social.msdn.microsoft.com/Forums/en-US/4ebaaed0-cd29-4663-9a43-973729d66cea/autocomplete-combobox-match-any-part-of-string-not-only-beginning-string?forum=winforms

/// <summary>
/// A <see cref="ComboBox"/> implementation auto-completing case-insensitively items containing the typed text.
/// Implements the <see cref="System.Windows.Forms.ComboBox" />
/// </summary>
/// <seealso cref="System.Windows.Forms.ComboBox" />
public class ComboBoxCustomSearch : ComboBox
{
// Parts of the code from (C): https://social.msdn.microsoft.com/Forums/en-US/4ebaaed0-cd29-4663-9a43-973729d66cea/autocomplete-combobox-match-any-part-of-string-not-only-beginning-string?forum=winforms
private IList<object> collectionList;

/// <summary>
/// A <see cref="ComboBox"/> implementation auto-completing case-insensitively items containing the typed text.
/// Implements the <see cref="System.Windows.Forms.ComboBox" />
/// Initializes a new instance of the <see cref="T:CustomControls.ComboBoxCustomSearch" /> class.
/// </summary>
/// <seealso cref="System.Windows.Forms.ComboBox" />
public class ComboBoxCustomSearch : ComboBox
public ComboBoxCustomSearch()
{
private IList<object> collectionList;
collectionList = new List<object>();
}

/// <summary>
/// Initializes a new instance of the <see cref="T:CustomControls.ComboBoxCustomSearch" /> class.
/// </summary>
public ComboBoxCustomSearch()
{
collectionList = new List<object>();
}
// ReSharper disable four times InconsistentNaming, WinApi constant..
// ReSharper disable four times IdentifierTypo, WinApi constant..
private const int CB_ADDSTRING = 0x143;
private const int CB_DELETESTRING = 0x144;
private const int CB_INSERTSTRING = 0x14A;
private const int CB_RESETCONTENT = 0x14B;

// ReSharper disable four times InconsistentNaming, WinApi constant..
// ReSharper disable four times IdentifierTypo, WinApi constant..
private const int CB_ADDSTRING = 0x143;
private const int CB_DELETESTRING = 0x144;
private const int CB_INSERTSTRING = 0x14A;
private const int CB_RESETCONTENT = 0x14B;

/// <summary>
/// Processes Windows messages.
/// </summary>
/// <param name="m">The <see cref="Message"/> message to process.</param>
protected override void WndProc(ref Message m)
/// <summary>
/// Processes Windows messages.
/// </summary>
/// <param name="m">The <see cref="Message"/> message to process.</param>
protected override void WndProc(ref Message m)
{
if (m.Msg is CB_ADDSTRING or CB_DELETESTRING or CB_INSERTSTRING or CB_RESETCONTENT)
{
if (m.Msg is CB_ADDSTRING or CB_DELETESTRING or CB_INSERTSTRING or CB_RESETCONTENT)
if (!filtering)
{
if (!filtering)
{
collectionList = Items.OfType<object>().ToList();
}
collectionList = Items.OfType<object>().ToList();
}
base.WndProc(ref m);
}
base.WndProc(ref m);
}

/// <summary>
/// A flag indicting whether the combo box is being filtered.
/// </summary>
private bool filtering;

/// <summary>
/// A flag indicating whether <see cref="OnCreateControl"/> has been called once.
/// </summary>
private bool controlCreated;

/// <summary>
/// Raises the <see cref="ComboBox.TextUpdate"/> event.
/// </summary>
/// <param name="e">An <see cref="EventArgs"/> that contains the event data.</param>
protected override void OnTextUpdate(EventArgs e)
{
filtering = true;
IList<object> Values = collectionList
.Where(x => (x.ToString() ?? "").Contains(Text, StringComparison.OrdinalIgnoreCase))
.ToList<object>();
/// <summary>
/// A flag indicting whether the combo box is being filtered.
/// </summary>
private bool filtering;

Items.Clear();
Items.AddRange(Text != string.Empty ? Values.ToArray() : collectionList.ToArray());
/// <summary>
/// A flag indicating whether <see cref="OnCreateControl"/> has been called once.
/// </summary>
private bool controlCreated;

SelectionStart = Text.Length;
DroppedDown = true;
filtering = false;
}
/// <summary>
/// Raises the <see cref="ComboBox.TextUpdate"/> event.
/// </summary>
/// <param name="e">An <see cref="EventArgs"/> that contains the event data.</param>
protected override void OnTextUpdate(EventArgs e)
{
filtering = true;
IList<object> Values = collectionList
.Where(x => (x.ToString() ?? "").Contains(Text, StringComparison.OrdinalIgnoreCase))
.ToList<object>();

Items.Clear();
Items.AddRange(Text != string.Empty ? Values.ToArray() : collectionList.ToArray());

SelectionStart = Text.Length;
DroppedDown = true;
filtering = false;
}


/// <summary>
/// Raises the <see cref="Control.CreateControl"/> method.
/// </summary>
protected override void OnCreateControl()
/// <summary>
/// Raises the <see cref="Control.CreateControl"/> method.
/// </summary>
protected override void OnCreateControl()
{
base.OnCreateControl();
if (!controlCreated)
{
base.OnCreateControl();
if (!controlCreated)
{
collectionList = Items.OfType<object>().ToList();
controlCreated = true;
}
collectionList = Items.OfType<object>().ToList();
controlCreated = true;
}
}
}
}
64 changes: 32 additions & 32 deletions CustomControls/CustomControls.csproj
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<UseWindowsForms>true</UseWindowsForms>
<TargetFramework>net6.0-windows</TargetFramework>
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />
<Authors>VPKSoft</Authors>
<Product>ScriptNotepad Custom Controls</Product>
<PackageId>CustomControls</PackageId>
<Description>Custom controls for the ScriptNotepad software.</Description>
<Copyright>Copyright © VPKSoft 2021</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://www.vpksoft.net/2015-03-31-13-33-28/scriptnotepad</PackageProjectUrl>
<PackageIcon>ScriptNotepad_icon.png</PackageIcon>
<PackageIconUrl />
<RepositoryUrl>https://github.com/VPKSoft/ScriptNotepad</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>custom control winforms</PackageTags>
<PackageReleaseNotes>See: https://github.com/VPKSoft/ScriptNotepad</PackageReleaseNotes>
</PropertyGroup>
<PropertyGroup>
<UseWindowsForms>true</UseWindowsForms>
<TargetFramework>net6.0-windows</TargetFramework>
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />
<Authors>VPKSoft</Authors>
<Product>ScriptNotepad Custom Controls</Product>
<PackageId>CustomControls</PackageId>
<Description>Custom controls for the ScriptNotepad software.</Description>
<Copyright>Copyright © VPKSoft 2022</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://www.vpksoft.net/2015-03-31-13-33-28/scriptnotepad</PackageProjectUrl>
<PackageIcon>ScriptNotepad_icon.png</PackageIcon>
<PackageIconUrl />
<RepositoryUrl>https://github.com/VPKSoft/ScriptNotepad</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>custom control winforms</PackageTags>
<PackageReleaseNotes>See: https://github.com/VPKSoft/ScriptNotepad</PackageReleaseNotes>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>C:\Files\GitHub\ScriptNotepad\CustomControls\CustomControls.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>C:\Files\GitHub\ScriptNotepad\CustomControls\CustomControls.xml</DocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>C:\Files\GitHub\ScriptNotepad\CustomControls\CustomControls.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>C:\Files\GitHub\ScriptNotepad\CustomControls\CustomControls.xml</DocumentationFile>
</PropertyGroup>

<ItemGroup>
<None Include="..\ScriptNotepad_icon.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>
<ItemGroup>
<None Include="..\ScriptNotepad_icon.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>
</Project>
109 changes: 54 additions & 55 deletions CustomControls/ImageButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
MIT License
Copyright(c) 2021 Petteri Kautonen
Copyright(c) 2022 Petteri Kautonen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -29,67 +29,66 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
using System.Drawing;
using System.Windows.Forms;

namespace CustomControls
namespace CustomControls;

/// <summary>
/// A custom button control with an image and a label.
/// Implements the <see cref="System.Windows.Forms.UserControl" />
/// </summary>
/// <seealso cref="System.Windows.Forms.UserControl" />
[DefaultEvent(nameof(Click))]
public partial class ImageButton : UserControl
{
/// <summary>
/// A custom button control with an image and a label.
/// Implements the <see cref="System.Windows.Forms.UserControl" />
/// Initializes a new instance of the <see cref="ImageButton"/> class.
/// </summary>
/// <seealso cref="System.Windows.Forms.UserControl" />
[DefaultEvent(nameof(Click))]
public partial class ImageButton : UserControl
public ImageButton()
{
/// <summary>
/// Initializes a new instance of the <see cref="ImageButton"/> class.
/// </summary>
public ImageButton()
{
InitializeComponent();
}
InitializeComponent();
}

/// <summary>
/// Gets or sets the button image.
/// </summary>
/// <value>The button image.</value>
[Category("Appearance")]
[Description("The button image.")]
public Image ButtonImage { get => pnImage.BackgroundImage; set => pnImage.BackgroundImage = value; }
/// <summary>
/// Gets or sets the button image.
/// </summary>
/// <value>The button image.</value>
[Category("Appearance")]
[Description("The button image.")]
public Image ButtonImage { get => pnImage.BackgroundImage; set => pnImage.BackgroundImage = value; }

/// <summary>
/// Gets or sets the button image layout.
/// </summary>
/// <value>The button image layout.</value>
[Category("Appearance")]
[Description("The button image layout.")]
public ImageLayout ButtonImageLayout { get => pnImage.BackgroundImageLayout; set => pnImage.BackgroundImageLayout = value; }
/// <summary>
/// Gets or sets the button image layout.
/// </summary>
/// <value>The button image layout.</value>
[Category("Appearance")]
[Description("The button image layout.")]
public ImageLayout ButtonImageLayout { get => pnImage.BackgroundImageLayout; set => pnImage.BackgroundImageLayout = value; }

/// <summary>
/// Gets or sets the text associated with this control.
/// </summary>
/// <value>The text.</value>
[Category("Appearance")]
[Description("The text associated with this control.")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[EditorBrowsable(EditorBrowsableState.Always)]
public override string Text { get => lbButtonText.Text; set => lbButtonText.Text = value; }
/// <summary>
/// Gets or sets the text associated with this control.
/// </summary>
/// <value>The text.</value>
[Category("Appearance")]
[Description("The text associated with this control.")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[EditorBrowsable(EditorBrowsableState.Always)]
public override string Text { get => lbButtonText.Text; set => lbButtonText.Text = value; }

/// <summary>
/// Occurs when the control is clicked.
/// </summary>
[Category("Behaviour")]
[Description("The text associated with this control.")]
// ReSharper disable once InconsistentNaming
public new EventHandler Click;
/// <summary>
/// Occurs when the control is clicked.
/// </summary>
[Category("Behaviour")]
[Description("The text associated with this control.")]
// ReSharper disable once InconsistentNaming
public new EventHandler Click;

/// <summary>
/// Delegates the <see cref="Click"/> event to the base control.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void DelegateClick(object sender, EventArgs e)
{
Click?.Invoke(this, EventArgs.Empty);
}
/// <summary>
/// Delegates the <see cref="Click"/> event to the base control.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void DelegateClick(object sender, EventArgs e)
{
Click?.Invoke(this, EventArgs.Empty);
}
}
}
2 changes: 1 addition & 1 deletion InstallerBaseWixSharp/Files/Dialogs/ProgressDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public ProgressDialog()
InitializeComponent();
dialogText.MakeTransparentOn(banner);

showWaitPromptTimer = new System.Windows.Forms.Timer { Interval = 4000 };
showWaitPromptTimer = new System.Windows.Forms.Timer { Interval = 4000, };
showWaitPromptTimer.Tick += (s, e) =>
{
waitPrompt.Visible = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public void GetLocalizedTexts(string fileContents)
{
continue;
}
LocalizationTexts.Add(new LocalizationTextContainer { MessageName = delimited[0], Message = delimited[1], CultureName = locale});
LocalizationTexts.Add(new LocalizationTextContainer { MessageName = delimited[0], Message = delimited[1], CultureName = locale, });
}
}
}
Expand Down
Loading

0 comments on commit d0e1ebe

Please sign in to comment.