mirror of
https://github.com/Stone-Red-Code/Decho.git
synced 2026-09-04 00:46:11 +02:00
Initial commit
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
# Auto detect text files and perform LF normalization
|
||||||
|
* text=auto
|
||||||
+401
@@ -0,0 +1,401 @@
|
|||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
##
|
||||||
|
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.rsuser
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
|
*.userprefs
|
||||||
|
|
||||||
|
# Mono auto generated files
|
||||||
|
mono_crash.*
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
[Ww][Ii][Nn]32/
|
||||||
|
[Aa][Rr][Mm]/
|
||||||
|
[Aa][Rr][Mm]64/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Ll]og/
|
||||||
|
[Ll]ogs/
|
||||||
|
|
||||||
|
# Visual Studio 2015/2017 cache/options directory
|
||||||
|
.vs/
|
||||||
|
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||||
|
#wwwroot/
|
||||||
|
|
||||||
|
# Visual Studio 2017 auto generated files
|
||||||
|
Generated\ Files/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
# NUnit
|
||||||
|
*.VisualState.xml
|
||||||
|
TestResult.xml
|
||||||
|
nunit-*.xml
|
||||||
|
|
||||||
|
# Build Results of an ATL Project
|
||||||
|
[Dd]ebugPS/
|
||||||
|
[Rr]eleasePS/
|
||||||
|
dlldata.c
|
||||||
|
|
||||||
|
# Benchmark Results
|
||||||
|
BenchmarkDotNet.Artifacts/
|
||||||
|
|
||||||
|
# .NET Core
|
||||||
|
project.lock.json
|
||||||
|
project.fragment.lock.json
|
||||||
|
artifacts/
|
||||||
|
|
||||||
|
# ASP.NET Scaffolding
|
||||||
|
ScaffoldingReadMe.txt
|
||||||
|
|
||||||
|
# StyleCop
|
||||||
|
StyleCopReport.xml
|
||||||
|
|
||||||
|
# Files built by Visual Studio
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*_h.h
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.iobj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.ipdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
# but not Directory.Build.rsp, as it configures directory-level build defaults
|
||||||
|
!Directory.Build.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*_wpftmp.csproj
|
||||||
|
*.log
|
||||||
|
*.tlog
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.svclog
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
_Chutzpah*
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opendb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
*.VC.db
|
||||||
|
*.VC.VC.opendb
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
*.sap
|
||||||
|
|
||||||
|
# Visual Studio Trace Files
|
||||||
|
*.e2e
|
||||||
|
|
||||||
|
# TFS 2012 Local Workspace
|
||||||
|
$tf/
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
*.DotSettings.user
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# AxoCover is a Code Coverage Tool
|
||||||
|
.axoCover/*
|
||||||
|
!.axoCover/settings.json
|
||||||
|
|
||||||
|
# Coverlet is a free, cross platform Code Coverage Tool
|
||||||
|
coverage*.json
|
||||||
|
coverage*.xml
|
||||||
|
coverage*.info
|
||||||
|
|
||||||
|
# Visual Studio code coverage results
|
||||||
|
*.coverage
|
||||||
|
*.coveragexml
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
_NCrunch_*
|
||||||
|
.NCrunch_*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
nCrunchTemp_*
|
||||||
|
|
||||||
|
# MightyMoose
|
||||||
|
*.mm.*
|
||||||
|
AutoTest.Net/
|
||||||
|
|
||||||
|
# Web workbench (sass)
|
||||||
|
.sass-cache/
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.azurePubxml
|
||||||
|
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||||
|
# but database connection strings (with potential passwords) will be unencrypted
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||||
|
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||||
|
# in these scripts will be unencrypted
|
||||||
|
PublishScripts/
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
# NuGet Symbol Packages
|
||||||
|
*.snupkg
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
**/[Pp]ackages/*
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
!**/[Pp]ackages/build/
|
||||||
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
#!**/[Pp]ackages/repositories.config
|
||||||
|
# NuGet v3's project.json files produces more ignorable files
|
||||||
|
*.nuget.props
|
||||||
|
*.nuget.targets
|
||||||
|
|
||||||
|
# Microsoft Azure Build Output
|
||||||
|
csx/
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Microsoft Azure Emulator
|
||||||
|
ecf/
|
||||||
|
rcf/
|
||||||
|
|
||||||
|
# Windows Store app package directories and files
|
||||||
|
AppPackages/
|
||||||
|
BundleArtifacts/
|
||||||
|
Package.StoreAssociation.xml
|
||||||
|
_pkginfo.txt
|
||||||
|
*.appx
|
||||||
|
*.appxbundle
|
||||||
|
*.appxupload
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
*.[Cc]ache
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
!?*.[Cc]ache/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
ClientBin/
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.dbproj.schemaview
|
||||||
|
*.jfm
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
orleans.codegen.cs
|
||||||
|
|
||||||
|
# Including strong name files can present a security risk
|
||||||
|
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||||
|
#*.snk
|
||||||
|
|
||||||
|
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||||
|
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||||
|
#bower_components/
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file
|
||||||
|
# to a newer Visual Studio version. Backup files are not needed,
|
||||||
|
# because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
ServiceFabricBackup/
|
||||||
|
*.rptproj.bak
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
*.mdf
|
||||||
|
*.ldf
|
||||||
|
*.ndf
|
||||||
|
|
||||||
|
# Business Intelligence projects
|
||||||
|
*.rdl.data
|
||||||
|
*.bim.layout
|
||||||
|
*.bim_*.settings
|
||||||
|
*.rptproj.rsuser
|
||||||
|
*- [Bb]ackup.rdl
|
||||||
|
*- [Bb]ackup ([0-9]).rdl
|
||||||
|
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||||
|
|
||||||
|
# Microsoft Fakes
|
||||||
|
FakesAssemblies/
|
||||||
|
|
||||||
|
# GhostDoc plugin setting file
|
||||||
|
*.GhostDoc.xml
|
||||||
|
|
||||||
|
# Node.js Tools for Visual Studio
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
*.plg
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace options file
|
||||||
|
*.opt
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||||
|
*.vbw
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
|
||||||
|
*.vbp
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
|
||||||
|
*.dsw
|
||||||
|
*.dsp
|
||||||
|
|
||||||
|
# Visual Studio 6 technical files
|
||||||
|
*.ncb
|
||||||
|
*.aps
|
||||||
|
|
||||||
|
# Visual Studio LightSwitch build output
|
||||||
|
**/*.HTMLClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/ModelManifest.xml
|
||||||
|
**/*.Server/GeneratedArtifacts
|
||||||
|
**/*.Server/ModelManifest.xml
|
||||||
|
_Pvt_Extensions
|
||||||
|
|
||||||
|
# Paket dependency manager
|
||||||
|
.paket/paket.exe
|
||||||
|
paket-files/
|
||||||
|
|
||||||
|
# FAKE - F# Make
|
||||||
|
.fake/
|
||||||
|
|
||||||
|
# CodeRush personal settings
|
||||||
|
.cr/personal
|
||||||
|
|
||||||
|
# Python Tools for Visual Studio (PTVS)
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
|
||||||
|
# Cake - Uncomment if you are using it
|
||||||
|
# tools/**
|
||||||
|
# !tools/packages.config
|
||||||
|
|
||||||
|
# Tabs Studio
|
||||||
|
*.tss
|
||||||
|
|
||||||
|
# Telerik's JustMock configuration file
|
||||||
|
*.jmconfig
|
||||||
|
|
||||||
|
# BizTalk build output
|
||||||
|
*.btp.cs
|
||||||
|
*.btm.cs
|
||||||
|
*.odx.cs
|
||||||
|
*.xsd.cs
|
||||||
|
|
||||||
|
# OpenCover UI analysis results
|
||||||
|
OpenCover/
|
||||||
|
|
||||||
|
# Azure Stream Analytics local run output
|
||||||
|
ASALocalRun/
|
||||||
|
|
||||||
|
# MSBuild Binary and Structured Log
|
||||||
|
*.binlog
|
||||||
|
|
||||||
|
# NVidia Nsight GPU debugger configuration file
|
||||||
|
*.nvuser
|
||||||
|
|
||||||
|
# MFractors (Xamarin productivity tool) working folder
|
||||||
|
.mfractor/
|
||||||
|
|
||||||
|
# Local History for Visual Studio
|
||||||
|
.localhistory/
|
||||||
|
|
||||||
|
# Visual Studio History (VSHistory) files
|
||||||
|
.vshistory/
|
||||||
|
|
||||||
|
# BeatPulse healthcheck temp database
|
||||||
|
healthchecksdb
|
||||||
|
|
||||||
|
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||||
|
MigrationBackup/
|
||||||
|
|
||||||
|
# Ionide (cross platform F# VS Code tools) working folder
|
||||||
|
.ionide/
|
||||||
|
|
||||||
|
# Fody - auto-generated XML schema
|
||||||
|
FodyWeavers.xsd
|
||||||
|
|
||||||
|
# VS Code files for those working on multiple tools
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
*.code-workspace
|
||||||
|
|
||||||
|
# Local History for Visual Studio Code
|
||||||
|
.history/
|
||||||
|
|
||||||
|
# Windows Installer files from build outputs
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msix
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
|
||||||
|
# JetBrains Rider
|
||||||
|
*.sln.iml
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<Solution>
|
||||||
|
<Project Path="Decho/Decho.csproj" />
|
||||||
|
</Solution>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<Application xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
x:Class="Decho.App"
|
||||||
|
xmlns:local="using:Decho"
|
||||||
|
RequestedThemeVariant="Default">
|
||||||
|
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
|
||||||
|
|
||||||
|
<Application.DataTemplates>
|
||||||
|
<local:ViewLocator/>
|
||||||
|
</Application.DataTemplates>
|
||||||
|
|
||||||
|
<Application.Styles>
|
||||||
|
<RomzetronTheme />
|
||||||
|
</Application.Styles>
|
||||||
|
</Application>
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
|
using Decho.ViewModels;
|
||||||
|
using Decho.Views;
|
||||||
|
|
||||||
|
namespace Decho;
|
||||||
|
|
||||||
|
public partial class App : Application
|
||||||
|
{
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
AvaloniaXamlLoader.Load(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnFrameworkInitializationCompleted()
|
||||||
|
{
|
||||||
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||||
|
{
|
||||||
|
desktop.MainWindow = new MainWindow
|
||||||
|
{
|
||||||
|
DataContext = new MainWindowViewModel(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
base.OnFrameworkInitializationCompleted();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 172 KiB |
@@ -0,0 +1,29 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
|
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Models\" />
|
||||||
|
<AvaloniaResource Include="Assets\**" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Avalonia" Version="11.3.12" />
|
||||||
|
<PackageReference Include="Avalonia.Desktop" Version="11.3.12" />
|
||||||
|
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.12" />
|
||||||
|
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.12" />
|
||||||
|
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||||
|
<PackageReference Include="Avalonia.Diagnostics" Version="11.3.12">
|
||||||
|
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
|
||||||
|
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Projektanker.Icons.Avalonia.FontAwesome" Version="9.6.2" />
|
||||||
|
<PackageReference Include="ReactiveUI.Avalonia" Version="11.3.8" />
|
||||||
|
<PackageReference Include="Romzetron.Avalonia" Version="11.3.4" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
|
namespace Decho.Models;
|
||||||
|
|
||||||
|
public sealed class ChannelModel
|
||||||
|
{
|
||||||
|
public ChannelModel(string id, string name, ObservableCollection<MessageModel> messages)
|
||||||
|
{
|
||||||
|
Id = id;
|
||||||
|
Name = name;
|
||||||
|
Messages = messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Id { get; }
|
||||||
|
|
||||||
|
public string Name { get; }
|
||||||
|
|
||||||
|
public ObservableCollection<MessageModel> Messages { get; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Decho.Models;
|
||||||
|
|
||||||
|
public sealed class MessageModel
|
||||||
|
{
|
||||||
|
public MessageModel(string id, UserModel author, DateTimeOffset sentAt, string content)
|
||||||
|
{
|
||||||
|
Id = id;
|
||||||
|
Author = author;
|
||||||
|
SentAt = sentAt;
|
||||||
|
Content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Id { get; }
|
||||||
|
|
||||||
|
public UserModel Author { get; }
|
||||||
|
|
||||||
|
public DateTimeOffset SentAt { get; }
|
||||||
|
|
||||||
|
public string Content { get; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
|
namespace Decho.Models;
|
||||||
|
|
||||||
|
public sealed class ServerModel
|
||||||
|
{
|
||||||
|
public ServerModel(string id, string name, ObservableCollection<ChannelModel> channels)
|
||||||
|
{
|
||||||
|
Id = id;
|
||||||
|
Name = name;
|
||||||
|
Channels = channels;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Id { get; }
|
||||||
|
|
||||||
|
public string Name { get; }
|
||||||
|
|
||||||
|
public ObservableCollection<ChannelModel> Channels { get; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
namespace Decho.Models;
|
||||||
|
|
||||||
|
public sealed class UserModel
|
||||||
|
{
|
||||||
|
public UserModel(string id, string displayName)
|
||||||
|
{
|
||||||
|
Id = id;
|
||||||
|
DisplayName = displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Id { get; }
|
||||||
|
|
||||||
|
public string DisplayName { get; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
global using ReactiveUI;
|
||||||
|
global using ReactiveUI.Avalonia;
|
||||||
|
|
||||||
|
using Avalonia;
|
||||||
|
|
||||||
|
using Projektanker.Icons.Avalonia;
|
||||||
|
using Projektanker.Icons.Avalonia.FontAwesome;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Decho;
|
||||||
|
|
||||||
|
internal sealed class Program
|
||||||
|
{
|
||||||
|
// Initialization code. Don't use any Avalonia, third-party APIs or any
|
||||||
|
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
|
||||||
|
// yet and stuff might break.
|
||||||
|
[STAThread]
|
||||||
|
public static void Main(string[] args) => BuildAvaloniaApp()
|
||||||
|
.StartWithClassicDesktopLifetime(args);
|
||||||
|
|
||||||
|
// Avalonia configuration, don't remove; also used by visual designer.
|
||||||
|
public static AppBuilder BuildAvaloniaApp()
|
||||||
|
{
|
||||||
|
IconProvider.Current
|
||||||
|
.Register<FontAwesomeIconProvider>();
|
||||||
|
|
||||||
|
return AppBuilder.Configure<App>()
|
||||||
|
.UsePlatformDetect()
|
||||||
|
.WithInterFont()
|
||||||
|
.LogToTrace()
|
||||||
|
.UseReactiveUI();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Controls.Templates;
|
||||||
|
|
||||||
|
using Decho.ViewModels;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
|
||||||
|
namespace Decho;
|
||||||
|
/// <summary>
|
||||||
|
/// Given a view model, returns the corresponding view if possible.
|
||||||
|
/// </summary>
|
||||||
|
[RequiresUnreferencedCode(
|
||||||
|
"Default implementation of ViewLocator involves reflection which may be trimmed away.",
|
||||||
|
Url = "https://docs.avaloniaui.net/docs/concepts/view-locator")]
|
||||||
|
public class ViewLocator : IDataTemplate
|
||||||
|
{
|
||||||
|
public Control? Build(object? param)
|
||||||
|
{
|
||||||
|
if (param is null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var name = param.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal);
|
||||||
|
var type = Type.GetType(name);
|
||||||
|
|
||||||
|
if (type != null)
|
||||||
|
{
|
||||||
|
return (Control)Activator.CreateInstance(type)!;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new TextBlock { Text = "Not Found: " + name };
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Match(object? data)
|
||||||
|
{
|
||||||
|
return data is ViewModelBase;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
using Decho.Models;
|
||||||
|
|
||||||
|
namespace Decho.ViewModels;
|
||||||
|
|
||||||
|
public sealed class ChannelViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
public ChannelViewModel(ChannelModel model)
|
||||||
|
{
|
||||||
|
Model = model;
|
||||||
|
Messages = new ObservableCollection<MessageViewModel>(
|
||||||
|
model.Messages.Select(message => new MessageViewModel(message)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChannelModel Model { get; }
|
||||||
|
|
||||||
|
public string Name => Model.Name;
|
||||||
|
|
||||||
|
public ObservableCollection<MessageViewModel> Messages { get; }
|
||||||
|
|
||||||
|
public void AddMessage(MessageModel message)
|
||||||
|
{
|
||||||
|
Model.Messages.Add(message);
|
||||||
|
Messages.Add(new MessageViewModel(message));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
|
namespace Decho.ViewModels;
|
||||||
|
|
||||||
|
public sealed class ChatViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
private ObservableCollection<MessageViewModel> _messages = new();
|
||||||
|
private string _channelTitle = "Select a channel";
|
||||||
|
|
||||||
|
public ChatViewModel()
|
||||||
|
{
|
||||||
|
Composer = new MessageComposerViewModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObservableCollection<MessageViewModel> Messages
|
||||||
|
{
|
||||||
|
get => _messages;
|
||||||
|
private set => this.RaiseAndSetIfChanged(ref _messages, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ChannelTitle
|
||||||
|
{
|
||||||
|
get => _channelTitle;
|
||||||
|
private set => this.RaiseAndSetIfChanged(ref _channelTitle, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageComposerViewModel Composer { get; }
|
||||||
|
|
||||||
|
public void SetChannel(ChannelViewModel? channel)
|
||||||
|
{
|
||||||
|
if (channel is null)
|
||||||
|
{
|
||||||
|
Messages = new ObservableCollection<MessageViewModel>();
|
||||||
|
ChannelTitle = "Select a channel";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Messages = channel.Messages;
|
||||||
|
ChannelTitle = "#" + channel.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Reactive.Linq;
|
||||||
|
|
||||||
|
using Decho.Models;
|
||||||
|
using ReactiveUI;
|
||||||
|
|
||||||
|
namespace Decho.ViewModels;
|
||||||
|
|
||||||
|
public sealed class MainWindowViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
private readonly UserModel _currentUser;
|
||||||
|
|
||||||
|
public string Title { get; } = "Decho";
|
||||||
|
|
||||||
|
public SidebarViewModel Sidebar { get; }
|
||||||
|
|
||||||
|
public ChatViewModel Chat { get; }
|
||||||
|
|
||||||
|
public MainWindowViewModel()
|
||||||
|
{
|
||||||
|
_currentUser = new UserModel("user-1", "You");
|
||||||
|
|
||||||
|
var servers = SeedServers();
|
||||||
|
Sidebar = new SidebarViewModel(servers);
|
||||||
|
Chat = new ChatViewModel();
|
||||||
|
|
||||||
|
Sidebar.WhenAnyValue(x => x.SelectedChannel)
|
||||||
|
.Subscribe(channel => Chat.SetChannel(channel));
|
||||||
|
|
||||||
|
Chat.Composer.SendRequested += HandleSendRequested;
|
||||||
|
|
||||||
|
if (Sidebar.SelectedChannel is not null)
|
||||||
|
Chat.SetChannel(Sidebar.SelectedChannel);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleSendRequested(string text)
|
||||||
|
{
|
||||||
|
if (Sidebar.SelectedChannel is null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var message = new MessageModel(
|
||||||
|
Guid.NewGuid().ToString("N"),
|
||||||
|
_currentUser,
|
||||||
|
DateTimeOffset.Now,
|
||||||
|
text);
|
||||||
|
|
||||||
|
Sidebar.SelectedChannel.AddMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IReadOnlyList<ServerModel> SeedServers()
|
||||||
|
{
|
||||||
|
var alex = new UserModel("user-2", "Alex");
|
||||||
|
var sam = new UserModel("user-3", "Sam");
|
||||||
|
|
||||||
|
var general = new ChannelModel(
|
||||||
|
"channel-1",
|
||||||
|
"general",
|
||||||
|
new ObservableCollection<MessageModel>
|
||||||
|
{
|
||||||
|
new("message-1", alex, DateTimeOffset.Now.AddMinutes(-30), "This is a message."),
|
||||||
|
new("message-2", sam, DateTimeOffset.Now.AddMinutes(-25), "Another message for the channel."),
|
||||||
|
new("message-3", alex, DateTimeOffset.Now.AddMinutes(-10), "We should test the new layout."),
|
||||||
|
});
|
||||||
|
|
||||||
|
var random = new ChannelModel(
|
||||||
|
"channel-2",
|
||||||
|
"random",
|
||||||
|
new ObservableCollection<MessageModel>
|
||||||
|
{
|
||||||
|
new("message-4", sam, DateTimeOffset.Now.AddMinutes(-5), "Random chat keeps the vibe light."),
|
||||||
|
});
|
||||||
|
|
||||||
|
var music = new ChannelModel(
|
||||||
|
"channel-3",
|
||||||
|
"music",
|
||||||
|
new ObservableCollection<MessageModel>());
|
||||||
|
|
||||||
|
var server = new ServerModel(
|
||||||
|
"server-1",
|
||||||
|
"Server",
|
||||||
|
new ObservableCollection<ChannelModel> { general, random });
|
||||||
|
|
||||||
|
var anotherServer = new ServerModel(
|
||||||
|
"server-2",
|
||||||
|
"Another Server",
|
||||||
|
new ObservableCollection<ChannelModel>() { general, music});
|
||||||
|
|
||||||
|
return new[] { server, anotherServer };
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
using System;
|
||||||
|
using System.Reactive;
|
||||||
|
using System.Reactive.Linq;
|
||||||
|
|
||||||
|
using ReactiveUI;
|
||||||
|
|
||||||
|
namespace Decho.ViewModels;
|
||||||
|
|
||||||
|
public sealed class MessageComposerViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
private string _draft = string.Empty;
|
||||||
|
|
||||||
|
public MessageComposerViewModel()
|
||||||
|
{
|
||||||
|
var canSend = this.WhenAnyValue(x => x.Draft, draft => !string.IsNullOrWhiteSpace(draft));
|
||||||
|
SendCommand = ReactiveCommand.Create(Send, canSend);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Draft
|
||||||
|
{
|
||||||
|
get => _draft;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _draft, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReactiveCommand<Unit, Unit> SendCommand { get; }
|
||||||
|
|
||||||
|
public event Action<string>? SendRequested;
|
||||||
|
|
||||||
|
private void Send()
|
||||||
|
{
|
||||||
|
var text = Draft.Trim();
|
||||||
|
if (string.IsNullOrWhiteSpace(text))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Draft = string.Empty;
|
||||||
|
SendRequested?.Invoke(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using Decho.Models;
|
||||||
|
|
||||||
|
namespace Decho.ViewModels;
|
||||||
|
|
||||||
|
public sealed class MessageViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
public MessageViewModel(MessageModel model)
|
||||||
|
{
|
||||||
|
Model = model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageModel Model { get; }
|
||||||
|
|
||||||
|
public string AuthorName => Model.Author.DisplayName;
|
||||||
|
|
||||||
|
public string Content => Model.Content;
|
||||||
|
|
||||||
|
public string TimeText => Model.SentAt.ToLocalTime().ToString("h:mm tt");
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
using Decho.Models;
|
||||||
|
|
||||||
|
namespace Decho.ViewModels;
|
||||||
|
|
||||||
|
public sealed class ServerViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
private bool _isExpanded = true;
|
||||||
|
private ChannelViewModel? _selectedChannel;
|
||||||
|
|
||||||
|
public ServerViewModel(ServerModel model)
|
||||||
|
{
|
||||||
|
Model = model;
|
||||||
|
Channels = new ObservableCollection<ChannelViewModel>(
|
||||||
|
model.Channels.Select(channel => new ChannelViewModel(channel)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServerModel Model { get; }
|
||||||
|
|
||||||
|
public string Name => Model.Name;
|
||||||
|
|
||||||
|
public ObservableCollection<ChannelViewModel> Channels { get; }
|
||||||
|
|
||||||
|
public ChannelViewModel? SelectedChannel
|
||||||
|
{
|
||||||
|
get => _selectedChannel;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _selectedChannel, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsExpanded
|
||||||
|
{
|
||||||
|
get => _isExpanded;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _isExpanded, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reactive.Linq;
|
||||||
|
|
||||||
|
using Decho.Models;
|
||||||
|
using ReactiveUI;
|
||||||
|
|
||||||
|
namespace Decho.ViewModels;
|
||||||
|
|
||||||
|
public sealed class SidebarViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
private ChannelViewModel? _selectedChannel;
|
||||||
|
|
||||||
|
public SidebarViewModel(IEnumerable<ServerModel> servers)
|
||||||
|
{
|
||||||
|
Servers = new ObservableCollection<ServerViewModel>(
|
||||||
|
servers.Select(server => new ServerViewModel(server)));
|
||||||
|
SelectedChannel = Servers.FirstOrDefault()?.Channels.FirstOrDefault();
|
||||||
|
|
||||||
|
foreach (var server in Servers)
|
||||||
|
{
|
||||||
|
server.WhenAnyValue(s => s.SelectedChannel)
|
||||||
|
.Where(channel => channel is not null)
|
||||||
|
.Subscribe(new Action<ChannelViewModel?>(channel => SelectedChannel = channel!));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObservableCollection<ServerViewModel> Servers { get; }
|
||||||
|
|
||||||
|
public ChannelViewModel? SelectedChannel
|
||||||
|
{
|
||||||
|
get => _selectedChannel;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (ReferenceEquals(_selectedChannel, value))
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.RaiseAndSetIfChanged(ref _selectedChannel, value);
|
||||||
|
|
||||||
|
if (value is null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach (var server in Servers)
|
||||||
|
{
|
||||||
|
if (server.Channels.Contains(value))
|
||||||
|
{
|
||||||
|
if (!ReferenceEquals(server.SelectedChannel, value))
|
||||||
|
server.SelectedChannel = value;
|
||||||
|
}
|
||||||
|
else if (server.SelectedChannel is not null)
|
||||||
|
{
|
||||||
|
server.SelectedChannel = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
using ReactiveUI;
|
||||||
|
|
||||||
|
namespace Decho.ViewModels;
|
||||||
|
|
||||||
|
public abstract class ViewModelBase : ReactiveObject
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:vm="using:Decho.ViewModels"
|
||||||
|
xmlns:views="using:Decho.Views"
|
||||||
|
xmlns:i="https://github.com/projektanker/icons.avalonia"
|
||||||
|
x:Class="Decho.Views.ChannelListView"
|
||||||
|
x:DataType="vm:ServerViewModel">
|
||||||
|
<ListBox Background="Transparent"
|
||||||
|
BorderThickness="0"
|
||||||
|
Margin="0"
|
||||||
|
ItemsSource="{Binding Channels}"
|
||||||
|
SelectedItem="{Binding SelectedChannel, Mode=TwoWay}">
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate x:DataType="vm:ChannelViewModel">
|
||||||
|
<TextBlock>
|
||||||
|
<InlineUIContainer BaselineAlignment="Bottom">
|
||||||
|
<i:Icon Value="fa-hashtag" FontWeight="Bold" Margin="0 0 0 1" />
|
||||||
|
</InlineUIContainer>
|
||||||
|
<Run Text="{Binding Name}" />
|
||||||
|
</TextBlock>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
|
||||||
|
namespace Decho.Views;
|
||||||
|
|
||||||
|
public partial class ChannelListView : UserControl
|
||||||
|
{
|
||||||
|
public ChannelListView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:vm="using:Decho.ViewModels"
|
||||||
|
xmlns:views="using:Decho.Views"
|
||||||
|
x:Class="Decho.Views.ChatView"
|
||||||
|
x:DataType="vm:ChatViewModel">
|
||||||
|
<Grid RowDefinitions="Auto, *, Auto" Margin="10">
|
||||||
|
<TextBlock FontWeight="Bold"
|
||||||
|
FontSize="16"
|
||||||
|
Margin="0 0 0 8"
|
||||||
|
Text="{Binding ChannelTitle}" />
|
||||||
|
<views:MessageListView Grid.Row="1" />
|
||||||
|
<views:MessageComposerView Grid.Row="2"
|
||||||
|
DataContext="{Binding Composer}" />
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
|
||||||
|
namespace Decho.Views;
|
||||||
|
|
||||||
|
public partial class ChatView : UserControl
|
||||||
|
{
|
||||||
|
public ChatView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:vm="using:Decho.ViewModels"
|
||||||
|
xmlns:views="using:Decho.Views"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
x:Class="Decho.Views.MainWindow"
|
||||||
|
x:DataType="vm:MainWindowViewModel"
|
||||||
|
Icon="/Assets/avalonia-logo.ico"
|
||||||
|
Title="Decho">
|
||||||
|
|
||||||
|
<Design.DataContext>
|
||||||
|
<!-- This only sets the DataContext for the previewer in an IDE,
|
||||||
|
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
|
||||||
|
<vm:MainWindowViewModel/>
|
||||||
|
</Design.DataContext>
|
||||||
|
|
||||||
|
<Grid RowDefinitions="Auto, *" ColumnDefinitions="Auto, *">
|
||||||
|
<TextBlock Grid.ColumnSpan="2"
|
||||||
|
FontSize="20"
|
||||||
|
FontWeight="Bold"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
Text="{Binding Title}" />
|
||||||
|
<views:SidebarView Grid.Row="1"
|
||||||
|
Grid.Column="0"
|
||||||
|
DataContext="{Binding Sidebar}"
|
||||||
|
SelectedChannel="{Binding SelectedChannel, Mode=TwoWay}" />
|
||||||
|
<views:ChatView Grid.Row="1"
|
||||||
|
Grid.Column="1"
|
||||||
|
DataContext="{Binding Chat}" />
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
|
||||||
|
namespace Decho.Views;
|
||||||
|
|
||||||
|
public partial class MainWindow : Window
|
||||||
|
{
|
||||||
|
public MainWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:vm="using:Decho.ViewModels"
|
||||||
|
xmlns:i="https://github.com/projektanker/icons.avalonia"
|
||||||
|
x:Class="Decho.Views.MessageComposerView"
|
||||||
|
x:DataType="vm:MessageComposerViewModel">
|
||||||
|
<Grid ColumnDefinitions="*, Auto, Auto" Margin="5">
|
||||||
|
<TextBox HorizontalAlignment="Stretch"
|
||||||
|
Margin="0 0 5 0"
|
||||||
|
Text="{Binding Draft, Mode=TwoWay}" />
|
||||||
|
<Button Grid.Column="1"
|
||||||
|
Height="33"
|
||||||
|
Width="33"
|
||||||
|
Content="Attach"
|
||||||
|
i:Attached.Icon="fa-paperclip"
|
||||||
|
Margin="0 0 5 0" />
|
||||||
|
<Button Grid.Column="2"
|
||||||
|
Height="33"
|
||||||
|
Width="33"
|
||||||
|
Content="Send"
|
||||||
|
i:Attached.Icon="fa-paper-plane"
|
||||||
|
Command="{Binding SendCommand}" />
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
|
||||||
|
namespace Decho.Views;
|
||||||
|
|
||||||
|
public partial class MessageComposerView : UserControl
|
||||||
|
{
|
||||||
|
public MessageComposerView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:vm="using:Decho.ViewModels"
|
||||||
|
x:Class="Decho.Views.MessageItemView"
|
||||||
|
x:DataType="vm:MessageViewModel">
|
||||||
|
<Grid Margin="5" ColumnDefinitions="Auto, Auto, *" RowDefinitions="Auto, Auto">
|
||||||
|
<Ellipse Grid.RowSpan="2"
|
||||||
|
Width="40"
|
||||||
|
Height="40"
|
||||||
|
Fill="{DynamicResource UiTheme00}"
|
||||||
|
Margin="0 0 5 0" />
|
||||||
|
<TextBlock Grid.Column="1"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Text="{Binding AuthorName}"
|
||||||
|
FontWeight="Bold" />
|
||||||
|
<TextBlock Grid.Column="1"
|
||||||
|
Grid.Row="1"
|
||||||
|
Text="{Binding TimeText}"
|
||||||
|
FontSize="10" />
|
||||||
|
<TextBlock Grid.Column="2"
|
||||||
|
Grid.RowSpan="1"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="{Binding Content}"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
Margin="10 5 0 0" />
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
|
||||||
|
namespace Decho.Views;
|
||||||
|
|
||||||
|
public partial class MessageItemView : UserControl
|
||||||
|
{
|
||||||
|
public MessageItemView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:vm="using:Decho.ViewModels"
|
||||||
|
xmlns:views="using:Decho.Views"
|
||||||
|
x:Class="Decho.Views.MessageListView"
|
||||||
|
x:DataType="vm:ChatViewModel">
|
||||||
|
<ScrollViewer>
|
||||||
|
<ItemsControl ItemsSource="{Binding Messages}">
|
||||||
|
<ItemsControl.ItemTemplate>
|
||||||
|
<DataTemplate x:DataType="vm:MessageViewModel">
|
||||||
|
<views:MessageItemView />
|
||||||
|
</DataTemplate>
|
||||||
|
</ItemsControl.ItemTemplate>
|
||||||
|
</ItemsControl>
|
||||||
|
</ScrollViewer>
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
|
||||||
|
namespace Decho.Views;
|
||||||
|
|
||||||
|
public partial class MessageListView : UserControl
|
||||||
|
{
|
||||||
|
public MessageListView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:vm="using:Decho.ViewModels"
|
||||||
|
xmlns:views="using:Decho.Views"
|
||||||
|
x:Class="Decho.Views.SidebarView"
|
||||||
|
x:DataType="vm:SidebarViewModel">
|
||||||
|
<Panel Background="{DynamicResource UiTheme00}" Width="250">
|
||||||
|
<ScrollViewer Padding="5">
|
||||||
|
<ItemsControl ItemsSource="{Binding Servers}">
|
||||||
|
<ItemsControl.ItemTemplate>
|
||||||
|
<DataTemplate x:DataType="vm:ServerViewModel">
|
||||||
|
<Expander Padding="0"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
IsExpanded="{Binding IsExpanded}">
|
||||||
|
<Expander.Header>
|
||||||
|
<TextBlock FontWeight="Bold"
|
||||||
|
TextTrimming="CharacterEllipsis"
|
||||||
|
MaxWidth="190"
|
||||||
|
Padding="0"
|
||||||
|
Text="{Binding Name}" />
|
||||||
|
</Expander.Header>
|
||||||
|
<views:ChannelListView />
|
||||||
|
</Expander>
|
||||||
|
</DataTemplate>
|
||||||
|
</ItemsControl.ItemTemplate>
|
||||||
|
</ItemsControl>
|
||||||
|
</ScrollViewer>
|
||||||
|
</Panel>
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
|
||||||
|
using Decho.ViewModels;
|
||||||
|
|
||||||
|
namespace Decho.Views;
|
||||||
|
|
||||||
|
public partial class SidebarView : UserControl
|
||||||
|
{
|
||||||
|
public static readonly StyledProperty<ChannelViewModel?> SelectedChannelProperty =
|
||||||
|
AvaloniaProperty.Register<SidebarView, ChannelViewModel?>(
|
||||||
|
nameof(SelectedChannel),
|
||||||
|
defaultBindingMode: Avalonia.Data.BindingMode.TwoWay);
|
||||||
|
|
||||||
|
public SidebarView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChannelViewModel? SelectedChannel
|
||||||
|
{
|
||||||
|
get => GetValue(SelectedChannelProperty);
|
||||||
|
set => SetValue(SelectedChannelProperty, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<!-- This manifest is used on Windows only.
|
||||||
|
Don't remove it as it might cause problems with window transparency and embedded controls.
|
||||||
|
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
|
||||||
|
<assemblyIdentity version="1.0.0.0" name="Decho.Desktop"/>
|
||||||
|
|
||||||
|
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||||
|
<application>
|
||||||
|
<!-- A list of the Windows versions that this application has been tested on
|
||||||
|
and is designed to work with. Uncomment the appropriate elements
|
||||||
|
and Windows will automatically select the most compatible environment. -->
|
||||||
|
|
||||||
|
<!-- Windows 10 -->
|
||||||
|
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
|
||||||
|
</application>
|
||||||
|
</compatibility>
|
||||||
|
</assembly>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2026 Stone_Red
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
Reference in New Issue
Block a user