Skip to content

Commit

Permalink
Improve major ticks testing gauge
Browse files Browse the repository at this point in the history
- Utilize data binding capabilities to remove old slider, and replace a more modular property interface control grouping. Made sure value is bound properly.
  • Loading branch information
gbakeman committed May 16, 2024
1 parent a1fad29 commit 99d8078
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 36 deletions.
1 change: 1 addition & 0 deletions AGaugeDemo/AGaugeDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.config" />
<None Include="Properties\DataSources\GaugeDemo.MajTicksGaugeBusinessObject.datasource" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand Down
111 changes: 80 additions & 31 deletions AGaugeDemo/GaugeDemo.Designer.cs

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

30 changes: 25 additions & 5 deletions AGaugeDemo/GaugeDemo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using AGauge;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Windows.Forms;

namespace AGaugeDemo
Expand All @@ -9,14 +11,15 @@ public partial class GaugeDemo : Form
{
private AGaugeLabel label;
private AGaugeRange alert;
private MajTicksGaugeBusinessObject majTicksGBO = new MajTicksGaugeBusinessObject();

public GaugeDemo()
{
InitializeComponent();
label = aGauge1.GaugeLabels.FindByName("GaugeLabel1");
alert = aGauge1.GaugeRanges.FindByName("AlertRange");

tb_majTicks.Minimum = (int)gge_majTicks.MinValue;
tb_majTicks.Maximum = (int)gge_majTicks.MaxValue;
majTicksGaugeBusinessObjectBindingSource.DataSource = majTicksGBO;
}

#region aGauge1
Expand Down Expand Up @@ -53,10 +56,27 @@ private void button1_Click(object sender, EventArgs e)

#endregion

private void tb_majTicks_ValueChanged(object sender, EventArgs e)
public class MajTicksGaugeBusinessObject : INotifyPropertyChanged
{
gge_majTicks.Value = tb_majTicks.Value;
gge_majTicks.GaugeLabels[0].Text = tb_majTicks.Value.ToString();
public event PropertyChangedEventHandler PropertyChanged;

private void NotifyPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

private int _value;
public int Value
{
get { return _value; }
set
{
if (value != _value) {
_value = value;
NotifyPropertyChanged();
}
}
}
}
}
}
3 changes: 3 additions & 0 deletions AGaugeDemo/GaugeDemo.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="majTicksGaugeBusinessObjectBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is automatically generated by Visual Studio .Net. It is
used to store generic object data source configuration information.
Renaming the file extension or editing the content of this file may
cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="GaugeDemo+MajTicksGaugeBusinessObject" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<TypeInfo>AGaugeDemo.GaugeDemo+MajTicksGaugeBusinessObject, AGaugeDemo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>

0 comments on commit 99d8078

Please sign in to comment.