Skip to content

Commit

Permalink
Merge pull request #1 & #2 from Adam-Kay/NET-7-Upgrade
Browse files Browse the repository at this point in the history
Finally merging in all changes from #1 and #2.
  • Loading branch information
Adam-Kay authored Oct 21, 2023
2 parents 8935b24 + 923abcc commit 3cd66f6
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 34 deletions.
20 changes: 12 additions & 8 deletions CustomControls/CustomComboBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ public class CustomComboBox : ComboBox {
private readonly int buttonWidth = SystemInformation.HorizontalScrollBarArrowWidth;
protected override void WndProc(ref Message m) {
base.WndProc(ref m);

/// Supposedly reduces flicker.
SetStyle(ControlStyles.OptimizedDoubleBuffer, true); // seems to make no difference

if (m.Msg == WM_PAINT) {
using (var g = Graphics.FromHwnd(Handle)) {
using var b = new SolidBrush(Color.FromArgb(48, 48, 48));
Expand Down Expand Up @@ -101,18 +105,18 @@ private void ChangeAppearance() {
/// Very dirty solution but it's too much work to render text through the control
private void PlaceholderChanger(object sender = null, EventArgs e = null) {
if (!(string.IsNullOrWhiteSpace(this._PlaceholderText))) { /// If the PlaceholderText string isn't empty
if (this.Text == this.renderedText) { /// If the current text and text to be rendered are the same
this.Text = ""; /// Set the text to blank
this.TextAppearance = AppearanceTypes.Active; /// And the Appearance Type to active
} else if (string.IsNullOrWhiteSpace(this.Text)) { /// OR if the current Text is empty
this.TextAppearance = AppearanceTypes.Passive; /// Set the Appearance type to passive
this.Text = this.renderedText; /// And set the text to the text to be rendered
if (this.Text == this.renderedText) { /// If the current text and text to be rendered are the same
this.Text = ""; /// Set the text to blank
this.TextAppearance = AppearanceTypes.Active; /// And the Appearance Type to active
} else if (string.IsNullOrWhiteSpace(this.Text)) { /// OR if the current Text is empty
this.TextAppearance = AppearanceTypes.Passive; /// Set the Appearance type to passive
this.Text = this.renderedText; /// And set the text to the text to be rendered
} else {
this.TextAppearance = AppearanceTypes.Active;
}
} else { /// If the PlaceholderText IS empty
this.Text = ""; /// Set the text to empty
this.TextAppearance = AppearanceTypes.Active; /// And Appearance type to active
this.Text = ""; /// Set the text to empty
this.TextAppearance = AppearanceTypes.Active; /// And Appearance type to active
}
}

Expand Down
120 changes: 120 additions & 0 deletions CustomControls/CustomComboBox.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
5 changes: 2 additions & 3 deletions MainWindow.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 4 additions & 11 deletions MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public partial class MainWindow : Form
public MainWindow()
{
InitializeComponent();

/// Reduces flicker on drawn controls (https://stackoverflow.com/a/64507)
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);

this.ActiveControl = label_Title; /// Set focus to label to draw focus away from buttons
customComboBox_DestinationExtension.SelectedIndex = 0;
//customComboBox_DestinationFolder.BorderColor = SystemColors.GrayText;
Expand Down Expand Up @@ -62,17 +66,6 @@ public void MainWindow_MouseDown(object sender, System.Windows.Forms.MouseEventA
}
#endregion

/// Reduces flicker on drawn UserControls
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000; /// Turn on WS_EX_COMPOSITED
return cp;
}
}

private void parse_TextBoxSource_for_DestinationComboBox()
{

Expand Down
2 changes: 1 addition & 1 deletion Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,16 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="gearpng" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\gear.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="videobutton" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\videobutton.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="check_mark" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\check-mark.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="dropdownIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\dropdownIcon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="check_mark" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\check-mark.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="gearpng" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\gear.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="videobutton" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\videobutton.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
18 changes: 14 additions & 4 deletions Video Encoder (NET Core Version).csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<TargetFramework>net7.0-windows</TargetFramework>
<RootNamespace>Video_Encoder__NET_Core_Version_</RootNamespace>
<UseWindowsForms>true</UseWindowsForms>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
<ApplicationIcon>Resources\videobutton.ico</ApplicationIcon>
<StartupObject>Video_Encoder__NET_Core_Version_.Program</StartupObject>
<Version>1.3.5</Version>
<AssemblyName>Video Encoder (NET Core)</AssemblyName>
<Version>1.0.3</Version>
<AssemblyName>Video Encoder</AssemblyName>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<AssemblyVersion>1.0</AssemblyVersion>
<FileVersion></FileVersion>
<!-- Have to include the above line so that it actually publishes to a single file. Net 5.0 weirdness. -->
</PropertyGroup>

Expand All @@ -35,6 +38,10 @@
</Compile>
</ItemGroup>

<ItemGroup>
<Folder Include="CustomControls\Icons\" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
Expand All @@ -43,7 +50,10 @@
</ItemGroup>

<ItemGroup>
<Folder Include="CustomControls\Icons\" />
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 3cd66f6

Please sign in to comment.