Skip to content

Commit c403fa5

Browse files
committed
dataview markers
1 parent afef4d9 commit c403fa5

File tree

19 files changed

+1593
-4
lines changed

19 files changed

+1593
-4
lines changed
10.5 KB
Binary file not shown.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{A9CA9EB9-2E7B-45AF-9B39-A8A89BE77F62}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<RootNamespace>_03_functional</RootNamespace>
10+
<AssemblyName>03 functional</AssemblyName>
11+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<PlatformTarget>AnyCPU</PlatformTarget>
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<PlatformTarget>AnyCPU</PlatformTarget>
27+
<DebugType>pdbonly</DebugType>
28+
<Optimize>true</Optimize>
29+
<OutputPath>bin\Release\</OutputPath>
30+
<DefineConstants>TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
</PropertyGroup>
34+
<ItemGroup>
35+
<Reference Include="System" />
36+
<Reference Include="System.Core" />
37+
<Reference Include="System.Xml.Linq" />
38+
<Reference Include="System.Data.DataSetExtensions" />
39+
<Reference Include="Microsoft.CSharp" />
40+
<Reference Include="System.Data" />
41+
<Reference Include="System.Deployment" />
42+
<Reference Include="System.Drawing" />
43+
<Reference Include="System.Net.Http" />
44+
<Reference Include="System.Windows.Forms" />
45+
<Reference Include="System.Xml" />
46+
</ItemGroup>
47+
<ItemGroup>
48+
<Compile Include="Form1.cs">
49+
<SubType>Form</SubType>
50+
</Compile>
51+
<Compile Include="Form1.Designer.cs">
52+
<DependentUpon>Form1.cs</DependentUpon>
53+
</Compile>
54+
<Compile Include="Program.cs" />
55+
<Compile Include="Properties\AssemblyInfo.cs" />
56+
<Compile Include="ScottPlot.cs" />
57+
<EmbeddedResource Include="Form1.resx">
58+
<DependentUpon>Form1.cs</DependentUpon>
59+
</EmbeddedResource>
60+
<EmbeddedResource Include="Properties\Resources.resx">
61+
<Generator>ResXFileCodeGenerator</Generator>
62+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
63+
<SubType>Designer</SubType>
64+
</EmbeddedResource>
65+
<Compile Include="Properties\Resources.Designer.cs">
66+
<AutoGen>True</AutoGen>
67+
<DependentUpon>Resources.resx</DependentUpon>
68+
</Compile>
69+
<None Include="Properties\Settings.settings">
70+
<Generator>SettingsSingleFileGenerator</Generator>
71+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
72+
</None>
73+
<Compile Include="Properties\Settings.Designer.cs">
74+
<AutoGen>True</AutoGen>
75+
<DependentUpon>Settings.settings</DependentUpon>
76+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
77+
</Compile>
78+
</ItemGroup>
79+
<ItemGroup>
80+
<None Include="App.config" />
81+
</ItemGroup>
82+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
83+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
5+
</startup>
6+
</configuration>

projects/18-01-15_form_drawing/drawing/03 functional/Form1.Designer.cs

Lines changed: 489 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Data;
5+
using System.Drawing;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
using System.Windows.Forms;
10+
11+
namespace _03_functional
12+
{
13+
public partial class Form1 : Form
14+
{
15+
16+
private ScottPlot scottPlot;
17+
18+
public Form1()
19+
{
20+
InitializeComponent();
21+
scottPlot = new ScottPlot(pb_graph.Width, pb_graph.Height);
22+
dataView_update_all();
23+
}
24+
25+
// TOP LEVEL THINGS
26+
27+
private void dataView_update_all()
28+
{
29+
dataView_update_labels();
30+
dataView_update_scrollbars();
31+
dataView_redraw_markers();
32+
dataView_redraw_graph();
33+
}
34+
35+
36+
37+
38+
// MID LEVEL THINGS
39+
40+
private void dataView_redraw_graph()
41+
{
42+
pb_graph.Image = scottPlot.Render();
43+
}
44+
45+
private void dataView_redraw_markers()
46+
{
47+
Bitmap bmp_markers = new Bitmap(pb_markers.Width, pb_markers.Height);
48+
Graphics gfx_markers = Graphics.FromImage(bmp_markers);
49+
gfx_markers.Clear(SystemColors.Control);
50+
51+
//int marker_position_1 = 10;
52+
//int marker_position_2 = 50;
53+
//int marker_position_3 = 80;
54+
//int marker_position_4 = 120;
55+
56+
57+
58+
// prepare brushes and fonts
59+
60+
Font font = new Font("arial", 9, FontStyle.Regular);
61+
StringFormat stringFormat = new StringFormat();
62+
stringFormat.Alignment = StringAlignment.Center;
63+
64+
int[] markers = { 50, 150, 200, 222 };
65+
int markerSelected = 3;
66+
67+
for (int i=0; i<markers.Length;i++)
68+
{
69+
70+
// coordinates for an upside-down triangle
71+
int xPixel = markers[i];
72+
Point[] triangle_points = {
73+
new Point(xPixel - 8, 0),
74+
new Point(xPixel + 8, 0),
75+
new Point(xPixel, 12) };
76+
77+
// default colors
78+
Brush brush_triangle = new SolidBrush(Color.Gray);
79+
Brush brush_label = new SolidBrush(Color.Black);
80+
Pen pen = new Pen(Color.Black, 1);
81+
82+
if (markerSelected - 1 == i)
83+
{
84+
brush_triangle = new SolidBrush(Color.Red);
85+
brush_label = new SolidBrush(Color.Red);
86+
}
87+
88+
// draw the
89+
gfx_markers.FillPolygon(brush_triangle, triangle_points);
90+
gfx_markers.DrawPolygon(pen, triangle_points);
91+
int xOffset = 12 * (int)((i % 2 - .5)*2); // -12 for markers 1 and 3, +12 for markers 2 and 4
92+
gfx_markers.DrawString((i+1).ToString(), font, brush_label, new Point(xPixel + xOffset, -2), stringFormat);
93+
94+
}
95+
96+
pb_markers.Image = bmp_markers;
97+
}
98+
99+
private void dataView_update_scrollbars()
100+
{
101+
hScrollBar1.Value = 50;
102+
vScrollBar1.Value = 50;
103+
}
104+
105+
private void dataView_update_labels()
106+
{
107+
lbl_axis_x.Text = "Time (seconds)";
108+
lbl_axis_y.Text = "Units";
109+
lbl_sweep.Text = "Sweep 1 of 10";
110+
}
111+
112+
113+
114+
115+
116+
117+
// EVENT BINDINGS
118+
119+
private void Form1_Resize(object sender, EventArgs e)
120+
{
121+
if (scottPlot == null) return;
122+
scottPlot.Resize(pb_graph.Width, pb_graph.Height);
123+
dataView_update_all();
124+
}
125+
126+
private void btn_zoom_y_in_Click(object sender, EventArgs e)
127+
{
128+
129+
}
130+
131+
private void btn_zoom_y_out_Click(object sender, EventArgs e)
132+
{
133+
134+
}
135+
136+
private void btn_zoom_x_out_Click(object sender, EventArgs e)
137+
{
138+
139+
}
140+
141+
private void btn_zoom_x_in_Click(object sender, EventArgs e)
142+
{
143+
144+
}
145+
146+
private void hScrollBar1_Scroll(object sender, ScrollEventArgs e)
147+
{
148+
149+
}
150+
151+
private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
152+
{
153+
154+
}
155+
156+
private void pb_graph_MouseMove(object sender, MouseEventArgs e)
157+
{
158+
159+
}
160+
161+
private void pb_graph_MouseDown(object sender, MouseEventArgs e)
162+
{
163+
164+
}
165+
166+
private void pb_graph_MouseUp(object sender, MouseEventArgs e)
167+
{
168+
169+
}
170+
171+
172+
}
173+
}
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<root>
3+
<!--
4+
Microsoft ResX Schema
5+
6+
Version 2.0
7+
8+
The primary goals of this format is to allow a simple XML format
9+
that is mostly human readable. The generation and parsing of the
10+
various data types are done through the TypeConverter classes
11+
associated with the data types.
12+
13+
Example:
14+
15+
... ado.net/XML headers & schema ...
16+
<resheader name="resmimetype">text/microsoft-resx</resheader>
17+
<resheader name="version">2.0</resheader>
18+
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19+
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20+
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21+
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22+
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23+
<value>[base64 mime encoded serialized .NET Framework object]</value>
24+
</data>
25+
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26+
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27+
<comment>This is a comment</comment>
28+
</data>
29+
30+
There are any number of "resheader" rows that contain simple
31+
name/value pairs.
32+
33+
Each data row contains a name, and value. The row also contains a
34+
type or mimetype. Type corresponds to a .NET class that support
35+
text/value conversion through the TypeConverter architecture.
36+
Classes that don't support this are serialized and stored with the
37+
mimetype set.
38+
39+
The mimetype is used for serialized objects, and tells the
40+
ResXResourceReader how to depersist the object. This is currently not
41+
extensible. For a given mimetype the value must be set accordingly:
42+
43+
Note - application/x-microsoft.net.object.binary.base64 is the format
44+
that the ResXResourceWriter will generate, however the reader can
45+
read any of the formats listed below.
46+
47+
mimetype: application/x-microsoft.net.object.binary.base64
48+
value : The object must be serialized with
49+
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50+
: and then encoded with base64 encoding.
51+
52+
mimetype: application/x-microsoft.net.object.soap.base64
53+
value : The object must be serialized with
54+
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55+
: and then encoded with base64 encoding.
56+
57+
mimetype: application/x-microsoft.net.object.bytearray.base64
58+
value : The object must be serialized into a byte array
59+
: using a System.ComponentModel.TypeConverter
60+
: and then encoded with base64 encoding.
61+
-->
62+
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63+
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64+
<xsd:element name="root" msdata:IsDataSet="true">
65+
<xsd:complexType>
66+
<xsd:choice maxOccurs="unbounded">
67+
<xsd:element name="metadata">
68+
<xsd:complexType>
69+
<xsd:sequence>
70+
<xsd:element name="value" type="xsd:string" minOccurs="0" />
71+
</xsd:sequence>
72+
<xsd:attribute name="name" use="required" type="xsd:string" />
73+
<xsd:attribute name="type" type="xsd:string" />
74+
<xsd:attribute name="mimetype" type="xsd:string" />
75+
<xsd:attribute ref="xml:space" />
76+
</xsd:complexType>
77+
</xsd:element>
78+
<xsd:element name="assembly">
79+
<xsd:complexType>
80+
<xsd:attribute name="alias" type="xsd:string" />
81+
<xsd:attribute name="name" type="xsd:string" />
82+
</xsd:complexType>
83+
</xsd:element>
84+
<xsd:element name="data">
85+
<xsd:complexType>
86+
<xsd:sequence>
87+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88+
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89+
</xsd:sequence>
90+
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91+
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92+
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93+
<xsd:attribute ref="xml:space" />
94+
</xsd:complexType>
95+
</xsd:element>
96+
<xsd:element name="resheader">
97+
<xsd:complexType>
98+
<xsd:sequence>
99+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100+
</xsd:sequence>
101+
<xsd:attribute name="name" type="xsd:string" use="required" />
102+
</xsd:complexType>
103+
</xsd:element>
104+
</xsd:choice>
105+
</xsd:complexType>
106+
</xsd:element>
107+
</xsd:schema>
108+
<resheader name="resmimetype">
109+
<value>text/microsoft-resx</value>
110+
</resheader>
111+
<resheader name="version">
112+
<value>2.0</value>
113+
</resheader>
114+
<resheader name="reader">
115+
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116+
</resheader>
117+
<resheader name="writer">
118+
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119+
</resheader>
120+
</root>

0 commit comments

Comments
 (0)