Skip to content

Commit b0c106e

Browse files
Merge pull request #1 from SyncfusionExamples/Attach_Sample
Attach the Cloud Monitoring Blog Sample in WPF
2 parents 08d3f54 + 02b2393 commit b0c106e

File tree

12 files changed

+973
-2
lines changed

12 files changed

+973
-2
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.14.36109.1 d17.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudMonitoring", "CloudMonitoring\CloudMonitoring.csproj", "{0D41AF8F-240A-4881-A869-22943030DA46}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{0D41AF8F-240A-4881-A869-22943030DA46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{0D41AF8F-240A-4881-A869-22943030DA46}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{0D41AF8F-240A-4881-A869-22943030DA46}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{0D41AF8F-240A-4881-A869-22943030DA46}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {E00F6464-939A-4B59-81F5-2DE5A5EAB030}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Application x:Class="CloudMonitoring.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:CloudMonitoring"
5+
StartupUri="MainWindow.xaml">
6+
<Application.Resources>
7+
8+
</Application.Resources>
9+
</Application>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Configuration;
2+
using System.Data;
3+
using System.Windows;
4+
5+
namespace CloudMonitoring
6+
{
7+
/// <summary>
8+
/// Interaction logic for App.xaml
9+
/// </summary>
10+
public partial class App : Application
11+
{
12+
}
13+
14+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Windows;
2+
3+
[assembly: ThemeInfo(
4+
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5+
//(used if a resource is not found in the page,
6+
// or application resource dictionaries)
7+
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8+
//(used if a resource is not found in the page,
9+
// app, or any theme specific resource dictionaries)
10+
)]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>net9.0-windows</TargetFramework>
6+
<Nullable>enable</Nullable>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<UseWPF>true</UseWPF>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<None Remove="Images\cloudcomputing.png" />
13+
<None Remove="Images\verified.png" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<PackageReference Include="Syncfusion.SfChart.WPF" Version="*" />
18+
<PackageReference Include="Syncfusion.SfGrid.WPF" Version="*" />
19+
</ItemGroup>
20+
21+
<ItemGroup>
22+
<Resource Include="Images\cloudcomputing.png" />
23+
<Resource Include="Images\verified.png" />
24+
</ItemGroup>
25+
26+
</Project>
19.5 KB
Loading
14.5 KB
Loading

CloudMonitoring/CloudMonitoring/MainWindow.xaml

Lines changed: 458 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System.Text;
2+
using System.Windows;
3+
using System.Windows.Controls;
4+
using System.Windows.Data;
5+
using System.Windows.Documents;
6+
using System.Windows.Input;
7+
using System.Windows.Media;
8+
using System.Windows.Media.Imaging;
9+
using System.Windows.Navigation;
10+
using System.Windows.Shapes;
11+
12+
namespace CloudMonitoring
13+
{
14+
/// <summary>
15+
/// Interaction logic for MainWindow.xaml
16+
/// </summary>
17+
public partial class MainWindow : Window
18+
{
19+
public MainWindow()
20+
{
21+
InitializeComponent();
22+
this.StateChanged += MainWindow_StateChanged;
23+
}
24+
25+
private void MainWindow_StateChanged(object? sender, EventArgs e)
26+
{
27+
if(this.WindowState == WindowState.Normal)
28+
{
29+
scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible;
30+
}
31+
else
32+
{
33+
scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
34+
}
35+
}
36+
37+
private void CheckBox_Checked(object sender, RoutedEventArgs e)
38+
{
39+
viewModel.dispatcherTimer.Stop();
40+
}
41+
42+
private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
43+
{
44+
viewModel.dispatcherTimer.Start();
45+
}
46+
}
47+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
using System.Windows.Media;
2+
3+
namespace CloudMonitoring
4+
{
5+
public class CloudMetricsDataModel
6+
{
7+
public string? Name { get; set; }
8+
public double Value { get; set; }
9+
}
10+
11+
public class CloudPerformanceDataModel
12+
{
13+
public string? Name { get; set; }
14+
public double Value { get; set; }
15+
public DateTime Time{ get; set; }
16+
public double CPUUsage{ get; set; }
17+
public double NetworkIn { get; set; }
18+
public double NetworkOut { get; set; }
19+
public double Read { get; set; }
20+
public double Write { get; set; }
21+
}
22+
23+
public class InstanceInfo
24+
{
25+
public string InstanceID { get; set; }
26+
public string Type { get; set; }
27+
public string State { get; set; }
28+
public string PublicIP { get; set; }
29+
public string Health { get; set; }
30+
public Geometry HealthIconPath
31+
{
32+
get
33+
{
34+
return Health switch
35+
{
36+
"Healthy" => Geometry.Parse("M20.274001,10.542006L21.570001,12.055005 11.479,20.674995 7.5810001,15.146002 9.207,13.998003 11.849,17.740999z M13.866527,2.2019958C10.048523,6.8069916 4.1854995,8.7969971 2.1014939,9.3860016 1.776496,12.313995 1.3194939,24.153 13.981532,29.865997 26.234559,24.259995 26.195571,13.018005 25.890563,9.673996 25.876571,9.5139923 25.767562,9.3919983 25.60057,9.348999 24.861568,9.1640015 18.342538,7.4129944 13.866527,2.2019958z M13.845531,0L13.86053,0C14.351528,0 14.821532,0.23100281 15.152541,0.63600159 19.22755,5.5890045 25.396558,7.2460022 26.085571,7.4169922 27.079562,7.6679993 27.781575,8.4810028 27.874578,9.4909973 28.215568,13.209 28.254569,25.806 14.485532,31.820999L14.078533,32 13.569529,31.863998C-1.1805132,25.416992 -0.19151202,11.595993 0.15449728,8.8899994 0.23849713,8.2339935 0.70448663,7.6990051 1.3444878,7.5279999 2.5705045,7.197998 8.8755152,5.3159943 12.549522,0.66299438 12.876534,0.24699402 13.349527,0.0059967041 13.845531,0z"),
37+
"Warning" => Geometry.Parse("M15.998999,17.988002C16.551,17.988002 16.999,18.437009 16.999,18.990018 16.999,19.543027 16.551,19.992034 15.998999,19.992034 15.446999,19.992034 14.998999,19.543027 14.998999,18.990018 14.998999,18.437009 15.446999,17.988002 15.998999,17.988002z M15.998999,8.0630169C16.552,8.0630169,16.999,8.5110159,16.999,9.0650149L16.999,16.167001C16.999,16.721 16.552,17.168998 15.998999,17.168998 15.446,17.168998 14.998999,16.721 14.998999,16.167001L14.998999,9.0650149C14.998999,8.5110159,15.446,8.0630169,15.998999,8.0630169z M15.999277,2.3337629L2.3830507,22.996989 29.615442,22.996989z M15.999513,0C16.50052,-3.8678991E-07,17.001274,0.21826346,17.288297,0.65479128L31.74151,22.585975C32.057495,23.064982 32.084472,23.677966 31.812494,24.184989 31.541494,24.687009 31.02049,24.999999 30.450475,24.999999L1.5480773,24.999999C0.97903845,24.999999 0.45705819,24.687009 0.18703459,24.184989 -0.085979476,23.677966 -0.057963934,23.064982 0.25704309,22.585975L14.709219,0.65479128C14.997247,0.21826346,15.498506,-3.8678991E-07,15.999513,0z"), // Yellow triangle
38+
"Critical" => Geometry.Parse("M26.580956,6.8329883L6.8329535,26.581059 6.8670793,26.611267C9.4062033,28.804157 12.611519,30 16,30 19.738998,30 23.25499,28.543945 25.898987,25.898926 28.542999,23.255005 30,19.739014 30,16 30,12.611519 28.803381,9.4062033 26.611095,6.8670454z M16,2C12.260986,2 8.7449951,3.4559326 6.1009979,6.1009521 3.4570007,8.7449951 2,12.260986 2,16 2,19.388481 3.1966188,22.593796 5.3888941,25.132864L5.4190583,25.166948 25.167076,5.4188623 25.132906,5.3886132C22.593781,3.1957417,19.388468,2,16,2z M16,0C20.272995,0 24.291992,1.6639404 27.312988,4.6870117 30.334991,7.7080078 32,11.726929 32,16 32,20.272949 30.334991,24.291992 27.312988,27.312988 24.291992,30.335938 20.272995,32 16,32 11.72699,32 7.7079926,30.335938 4.6869965,27.312988 1.6649933,24.291992 0,20.272949 0,16 0,11.726929 1.6649933,7.7080078 4.6869965,4.6870117 7.7079926,1.6639404 11.72699,0 16,0z"),
39+
_ => Geometry.Parse("")
40+
};
41+
}
42+
}
43+
public Brush HealthColor
44+
{
45+
get
46+
{
47+
return Health switch
48+
{
49+
"Healthy" => new SolidColorBrush(Color.FromArgb(255, 40, 201, 55)),
50+
"Warning" => new SolidColorBrush(Color.FromArgb(255, 255, 157, 0)),
51+
"Critical" => new SolidColorBrush(Color.FromArgb(255, 229, 0, 0)),
52+
_ => Brushes.Gray
53+
};
54+
}
55+
}
56+
public Brush HealthBackground
57+
{
58+
get
59+
{
60+
return Health switch
61+
{
62+
"Healthy" => new SolidColorBrush(Color.FromArgb(255, 214, 246, 217)),
63+
"Warning" => new SolidColorBrush(Color.FromArgb(255, 255, 238, 211)),
64+
"Critical" => new SolidColorBrush(Color.FromArgb(255, 255, 201, 201)),
65+
_ => Brushes.Gray
66+
};
67+
}
68+
}
69+
70+
public InstanceInfo(string instanceID, string type, string publicIP, string state, string health)
71+
{
72+
InstanceID = instanceID;
73+
State = type;
74+
PublicIP = publicIP;
75+
Type = state;
76+
Health = health;
77+
}
78+
}
79+
}

0 commit comments

Comments
 (0)