Skip to content

Commit 3889291

Browse files
Initial commit
0 parents  commit 3889291

File tree

13 files changed

+275
-0
lines changed

13 files changed

+275
-0
lines changed

.gitignore

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
*.swp
2+
*.*~
3+
project.lock.json
4+
.DS_Store
5+
*.pyc
6+
nupkg/
7+
8+
# Visual Studio Code
9+
.vscode
10+
11+
# Rider
12+
.idea
13+
14+
# User-specific files
15+
*.suo
16+
*.user
17+
*.userosscache
18+
*.sln.docstates
19+
20+
# Build results
21+
[Dd]ebug/
22+
[Dd]ebugPublic/
23+
[Rr]elease/
24+
[Rr]eleases/
25+
x64/
26+
x86/
27+
build/
28+
bld/
29+
[Bb]in/
30+
[Oo]bj/
31+
[Oo]ut/
32+
msbuild.log
33+
msbuild.err
34+
msbuild.wrn
35+
36+
# Visual Studio 2015
37+
.vs/
38+
39+
# Common IntelliJ Platform excludes
40+
41+
# User specific
42+
**/.idea/**/workspace.xml
43+
**/.idea/**/tasks.xml
44+
**/.idea/shelf/*
45+
**/.idea/dictionaries
46+
**/.idea/httpRequests/
47+
48+
# Sensitive or high-churn files
49+
**/.idea/**/dataSources/
50+
**/.idea/**/dataSources.ids
51+
**/.idea/**/dataSources.xml
52+
**/.idea/**/dataSources.local.xml
53+
**/.idea/**/sqlDataSources.xml
54+
**/.idea/**/dynamic.xml
55+
56+
# Rider
57+
# Rider auto-generates .iml files, and contentModel.xml
58+
**/.idea/**/*.iml
59+
**/.idea/**/contentModel.xml
60+
**/.idea/**/modules.xml
61+
62+
*.suo
63+
*.user
64+
.vs/
65+
[Bb]in/
66+
[Oo]bj/
67+
_UpgradeReport_Files/
68+
[Pp]ackages/
69+
70+
Thumbs.db
71+
Desktop.ini
72+
.DS_Store

src/SiteMonitor.sln

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiteMonitor", "SiteMonitor\SiteMonitor.csproj", "{9C6BE74C-22B4-4A81-91EA-32204163F8EE}"
4+
EndProject
5+
Global
6+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
7+
Debug|Any CPU = Debug|Any CPU
8+
Release|Any CPU = Release|Any CPU
9+
EndGlobalSection
10+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
11+
{9C6BE74C-22B4-4A81-91EA-32204163F8EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
12+
{9C6BE74C-22B4-4A81-91EA-32204163F8EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
13+
{9C6BE74C-22B4-4A81-91EA-32204163F8EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
14+
{9C6BE74C-22B4-4A81-91EA-32204163F8EE}.Release|Any CPU.Build.0 = Release|Any CPU
15+
EndGlobalSection
16+
EndGlobal

src/SiteMonitor/App.axaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Application xmlns="https://github.com/avaloniaui"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
x:Class="AvaloniaApplication1.App"
4+
xmlns:local="using:AvaloniaApplication1"
5+
RequestedThemeVariant="Default">
6+
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
7+
8+
<Application.DataTemplates>
9+
<local:ViewLocator/>
10+
</Application.DataTemplates>
11+
12+
<Application.Styles>
13+
<FluentTheme />
14+
</Application.Styles>
15+
</Application>

src/SiteMonitor/App.axaml.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Avalonia;
2+
using Avalonia.Controls.ApplicationLifetimes;
3+
using Avalonia.Markup.Xaml;
4+
using AvaloniaApplication1.ViewModels;
5+
using AvaloniaApplication1.Views;
6+
7+
namespace AvaloniaApplication1;
8+
9+
public partial class App : Application
10+
{
11+
public override void Initialize()
12+
{
13+
AvaloniaXamlLoader.Load(this);
14+
}
15+
16+
public override void OnFrameworkInitializationCompleted()
17+
{
18+
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
19+
{
20+
desktop.MainWindow = new MainWindow
21+
{
22+
DataContext = new MainWindowViewModel(),
23+
};
24+
}
25+
26+
base.OnFrameworkInitializationCompleted();
27+
}
28+
}
172 KB
Binary file not shown.

src/SiteMonitor/Program.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using Avalonia;
2+
using Avalonia.ReactiveUI;
3+
using System;
4+
5+
namespace AvaloniaApplication1;
6+
7+
sealed class Program
8+
{
9+
// Initialization code. Don't use any Avalonia, third-party APIs or any
10+
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
11+
// yet and stuff might break.
12+
[STAThread]
13+
public static void Main(string[] args) => BuildAvaloniaApp()
14+
.StartWithClassicDesktopLifetime(args);
15+
16+
// Avalonia configuration, don't remove; also used by visual designer.
17+
public static AppBuilder BuildAvaloniaApp()
18+
=> AppBuilder.Configure<App>()
19+
.UsePlatformDetect()
20+
.WithInterFont()
21+
.LogToTrace()
22+
.UseReactiveUI();
23+
}

src/SiteMonitor/SiteMonitor.csproj

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>WinExe</OutputType>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
7+
<ApplicationManifest>app.manifest</ApplicationManifest>
8+
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<Folder Include="Models\"/>
13+
<AvaloniaResource Include="Assets\**"/>
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<PackageReference Include="Avalonia" Version="11.0.10"/>
18+
<PackageReference Include="Avalonia.Desktop" Version="11.0.10"/>
19+
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.10"/>
20+
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.10"/>
21+
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
22+
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.10"/>
23+
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.10"/>
24+
</ItemGroup>
25+
</Project>

src/SiteMonitor/ViewLocator.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
using Avalonia.Controls;
3+
using Avalonia.Controls.Templates;
4+
using AvaloniaApplication1.ViewModels;
5+
6+
namespace AvaloniaApplication1;
7+
8+
public class ViewLocator : IDataTemplate
9+
{
10+
public Control? Build(object? data)
11+
{
12+
if (data is null)
13+
return null;
14+
15+
var name = data.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal);
16+
var type = Type.GetType(name);
17+
18+
if (type != null)
19+
{
20+
var control = (Control)Activator.CreateInstance(type)!;
21+
control.DataContext = data;
22+
return control;
23+
}
24+
25+
return new TextBlock { Text = "Not Found: " + name };
26+
}
27+
28+
public bool Match(object? data)
29+
{
30+
return data is ViewModelBase;
31+
}
32+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace AvaloniaApplication1.ViewModels;
2+
3+
public class MainWindowViewModel : ViewModelBase
4+
{
5+
#pragma warning disable CA1822 // Mark members as static
6+
public string Greeting => "Welcome to Avalonia!";
7+
#pragma warning restore CA1822 // Mark members as static
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
using ReactiveUI;
2+
3+
namespace AvaloniaApplication1.ViewModels;
4+
5+
public class ViewModelBase : ReactiveObject
6+
{
7+
}

0 commit comments

Comments
 (0)