Skip to content

Commit c31808a

Browse files
committed
add blach 5️⃣
1 parent cabc655 commit c31808a

15 files changed

+570
-8
lines changed

GraphPlot/GraphPlot.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ VisualStudioVersion = 14.0.25420.1
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GraphPlot", "GraphPlot\GraphPlot.csproj", "{5E6FDC62-53C3-47B6-9411-3EA4D1D6DEF0}"
77
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPFvisualization", "WPFvisualization\WPFvisualization.csproj", "{D93C2A79-B31C-401C-BF44-AA5A00C89C5F}"
9+
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1012
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
1517
{5E6FDC62-53C3-47B6-9411-3EA4D1D6DEF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
1618
{5E6FDC62-53C3-47B6-9411-3EA4D1D6DEF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
1719
{5E6FDC62-53C3-47B6-9411-3EA4D1D6DEF0}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{D93C2A79-B31C-401C-BF44-AA5A00C89C5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{D93C2A79-B31C-401C-BF44-AA5A00C89C5F}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{D93C2A79-B31C-401C-BF44-AA5A00C89C5F}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{D93C2A79-B31C-401C-BF44-AA5A00C89C5F}.Release|Any CPU.Build.0 = Release|Any CPU
1824
EndGlobalSection
1925
GlobalSection(SolutionProperties) = preSolution
2026
HideSolutionNode = FALSE

GraphPlot/GraphPlot/Controllers/PlotController.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,26 @@
44
using System.Net;
55
using System.Net.Http;
66
using System.Web.Http;
7-
7+
using GraphPlot.Models;
88
namespace GraphPlot.Controllers
99
{
1010
public class PlotController : ApiController
1111
{
12+
13+
private GraphsCreator CreateGraph;
1214
// GET: api/Plot
13-
public IEnumerable<string> Get()
15+
public IHttpActionResult Get()
1416
{
15-
return new string[] { "value1", "value2" };
17+
CreateGraph = new GraphsCreator();
18+
List<Point> XYList = new List<Point>();
19+
XYList = CreateGraph.GetXY();
20+
return Ok(XYList);
1621
}
1722

18-
// PUT: api/Plot/5
19-
public void Put(int id, [FromBody]string value)
20-
{
21-
}
23+
//public IHttpActionResult Post([FromUri]string function, [FromBody] string param)
24+
//{
25+
26+
//}
2227

2328
}
2429
}

GraphPlot/GraphPlot/Models/GraphsCreators.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ public List<Point> GetXY()
2727

2828

2929

30-
}
30+
}
31+
}

GraphPlot/WPFvisualization/App.config

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" />
5+
</startup>
6+
</configuration>

GraphPlot/WPFvisualization/App.xaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Application x:Class="WPFvisualization.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="clr-namespace:WPFvisualization"
5+
StartupUri="MainWindow.xaml">
6+
<Application.Resources>
7+
8+
</Application.Resources>
9+
</Application>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Configuration;
4+
using System.Data;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
9+
namespace WPFvisualization
10+
{
11+
/// <summary>
12+
/// Interaction logic for App.xaml
13+
/// </summary>
14+
public partial class App : Application
15+
{
16+
}
17+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<Window x:Class="WPFvisualization.MainWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:WPFvisualization"
7+
mc:Ignorable="d"
8+
Title="Sinusoidal" Height="350" Width="525">
9+
<Grid Background="#FF6198AB">
10+
<Grid.ColumnDefinitions>
11+
<ColumnDefinition Width="136*" />
12+
<ColumnDefinition Width="367*" />
13+
</Grid.ColumnDefinitions>
14+
15+
<StackPanel Orientation="Vertical" Grid.Column="1" Margin="2 2 2 2">
16+
<Canvas x:Name="canvas" Background="WhiteSmoke" Height="200" Margin="10, 10, 10, 10" VerticalAlignment="Top" Width="350"/>
17+
<Button x:Name="Draw_Graph" Content="Calculate and Plot Graphic" HorizontalAlignment="Center" FontSize="16" FontWeight="Bold" Click="Draw_Graph_Click"/>
18+
</StackPanel>
19+
20+
<StackPanel Orientation="Vertical" Grid.Column="0" Margin="2 2 2 2">
21+
<TextBlock HorizontalAlignment="Center" Margin="0,10,0,0" FontSize="14" FontWeight="Bold"> Math Function</TextBlock>
22+
<RadioButton Name="SinRadioBt" HorizontalAlignment="Left" Margin="10,10,0,0" GroupName="FunctionsRadiobutton">Sin</RadioButton>
23+
<RadioButton Name="CosRadioBt" HorizontalAlignment="Left" Margin="10,10,0,0" GroupName="FunctionsRadiobutton">Cos</RadioButton>
24+
25+
<StackPanel Orientation="Horizontal" Grid.Column="0" >
26+
<RadioButton Name="LogRadioBt" HorizontalAlignment="Left" Margin="10,10,0,0" GroupName="FunctionsRadiobutton">Log</RadioButton>
27+
<TextBlock VerticalAlignment="Center" Margin="10,7,0,0">x</TextBlock>
28+
<TextBox Name="LogX" VerticalAlignment="Center" Margin="5,7,0,0" Width="40" Height="18"></TextBox>
29+
</StackPanel>
30+
31+
<StackPanel Orientation="Horizontal" Grid.Column="0" >
32+
<RadioButton Name="PowRadioBt" HorizontalAlignment="Left" Margin="10,10,0,0" GroupName="FunctionsRadiobutton">Pow</RadioButton>
33+
<TextBlock VerticalAlignment="Center" Margin="10,7,0,0" Height="18">x</TextBlock>
34+
<TextBox Name="PowX" VerticalAlignment="Center" Margin="5,7,0,0" Width="20" Height="15"></TextBox>
35+
<TextBlock VerticalAlignment="Center" Margin="5,7,0,0" Height="18">n</TextBlock>
36+
<TextBox Name="PowN" VerticalAlignment="Center" Margin="5,7,0,0" Width="20" Height="15"></TextBox>
37+
</StackPanel>
38+
39+
<TextBlock HorizontalAlignment="Center" Margin="0,15,0,0" FontSize="14" FontWeight="Bold"> Parameters</TextBlock>
40+
<StackPanel Orientation="Horizontal" Grid.Column="0" Margin="2 2 2 2">
41+
<TextBlock VerticalAlignment="Center" Margin="10,2,0,0">Amplitude -</TextBlock>
42+
<TextBox Name="AmplitudeTexXox" VerticalAlignment="Center" Margin="5,2,0,0" Width="50"></TextBox>
43+
</StackPanel>
44+
45+
<StackPanel Orientation="Horizontal" Grid.Column="0" Margin="2 2 2 2">
46+
<TextBlock VerticalAlignment="Center" Margin="10,2,0,0">Frequency -</TextBlock>
47+
<TextBox Name="FrequencyTextBox" VerticalAlignment="Center" Margin="5,2,0,0" Width="50"></TextBox>
48+
</StackPanel>
49+
50+
</StackPanel>
51+
52+
53+
</Grid>
54+
</Window>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Net.Http;
4+
using System.Web.Script.Serialization;
5+
using System.Windows;
6+
using System.Windows.Ink;
7+
using System.Windows.Media;
8+
using System.Windows.Shapes;
9+
using System.Windows.Threading;
10+
11+
namespace WPFvisualization
12+
{
13+
/// <summary>
14+
/// Interaction logic for MainWindow.xaml
15+
/// </summary>
16+
public partial class MainWindow : Window
17+
{
18+
private Polyline polyline;
19+
public MainWindow()
20+
{
21+
polyline = new Polyline { Stroke = Brushes.Black};
22+
23+
InitializeComponent();
24+
}
25+
private Point CorrespondingPoint(Point pt)
26+
{
27+
double xmin = 0;
28+
double xmax = 6.5;
29+
double ymin = -1.1;
30+
double ymax = 1.1;
31+
32+
var result = new Point
33+
{
34+
X = (pt.X - xmin) * canvas.Width / (xmax - xmin),
35+
Y = canvas.Height - (pt.Y - ymin) * canvas.Height / (ymax - ymin)
36+
};
37+
return result;
38+
}
39+
private void Draw_Graph_Click(object sender, RoutedEventArgs e)
40+
{
41+
HttpClient client = new HttpClient();
42+
JavaScriptSerializer jss = new JavaScriptSerializer();
43+
string url = string.Format("http://localhost:53901/api/plot");
44+
client.GetAsync(url).ContinueWith(resurse =>
45+
{
46+
HttpResponseMessage message = client.GetAsync(url).Result;
47+
string responseText = message.Content.ReadAsStringAsync().Result;
48+
List<Point> list = jss.Deserialize<List<Point>>(responseText);
49+
50+
Dispatcher.BeginInvoke(DispatcherPriority.Normal,
51+
(Action)(() =>
52+
{
53+
foreach (var item in list)
54+
{
55+
polyline.Points.Add(CorrespondingPoint(new Point(item.X, item.Y)));
56+
}
57+
canvas.Children.Add(polyline);
58+
}));
59+
}
60+
61+
62+
63+
);
64+
}
65+
66+
}
67+
}
68+
69+
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System.Reflection;
2+
using System.Resources;
3+
using System.Runtime.CompilerServices;
4+
using System.Runtime.InteropServices;
5+
using System.Windows;
6+
7+
// General Information about an assembly is controlled through the following
8+
// set of attributes. Change these attribute values to modify the information
9+
// associated with an assembly.
10+
[assembly: AssemblyTitle("WPFvisualization")]
11+
[assembly: AssemblyDescription("")]
12+
[assembly: AssemblyConfiguration("")]
13+
[assembly: AssemblyCompany("")]
14+
[assembly: AssemblyProduct("WPFvisualization")]
15+
[assembly: AssemblyCopyright("Copyright © 2017")]
16+
[assembly: AssemblyTrademark("")]
17+
[assembly: AssemblyCulture("")]
18+
19+
// Setting ComVisible to false makes the types in this assembly not visible
20+
// to COM components. If you need to access a type in this assembly from
21+
// COM, set the ComVisible attribute to true on that type.
22+
[assembly: ComVisible(false)]
23+
24+
//In order to begin building localizable applications, set
25+
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
26+
//inside a <PropertyGroup>. For example, if you are using US english
27+
//in your source files, set the <UICulture> to en-US. Then uncomment
28+
//the NeutralResourceLanguage attribute below. Update the "en-US" in
29+
//the line below to match the UICulture setting in the project file.
30+
31+
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32+
33+
34+
[assembly: ThemeInfo(
35+
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36+
//(used if a resource is not found in the page,
37+
// or application resource dictionaries)
38+
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39+
//(used if a resource is not found in the page,
40+
// app, or any theme specific resource dictionaries)
41+
)]
42+
43+
44+
// Version information for an assembly consists of the following four values:
45+
//
46+
// Major Version
47+
// Minor Version
48+
// Build Number
49+
// Revision
50+
//
51+
// You can specify all the values or you can default the Build and Revision Numbers
52+
// by using the '*' as shown below:
53+
// [assembly: AssemblyVersion("1.0.*")]
54+
[assembly: AssemblyVersion("1.0.0.0")]
55+
[assembly: AssemblyFileVersion("1.0.0.0")]

GraphPlot/WPFvisualization/Properties/Resources.Designer.cs

Lines changed: 71 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)