-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
238 additions
and
60 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
<Application x:Class="OneProject.Desktop.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="clr-namespace:OneProject.Desktop" | ||
StartupUri="MainWindow.xaml"> | ||
<Application x:Class="OneProject.Desktop.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"> | ||
|
||
<Application.Resources> | ||
|
||
</Application.Resources> | ||
|
||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
OneProject.Desktop/Converters/DoubleGridLengthConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace OneProject.Desktop.Converters; | ||
|
||
using System; | ||
using System.Globalization; | ||
|
||
public class DoubleGridLengthConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
if(value is double d) | ||
{ | ||
return new GridLength(d); | ||
} | ||
|
||
return Binding.DoNothing; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace OneProject.Desktop.Converters; | ||
|
||
using Humanizer; | ||
|
||
public class FileSizeConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) => value switch | ||
{ | ||
long l => l.Bytes().ToString(), | ||
double d => d.Bytes().ToString(), | ||
_ => Binding.DoNothing, | ||
}; | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
=> throw new NotImplementedException(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace OneProject; | ||
namespace OneProject.Desktop; | ||
|
||
using System; | ||
using System.IO; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace OneProject.Desktop.Infrastructures; | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
public static class FontHelper | ||
{ | ||
private static readonly Lazy<IEnumerable<FontFamily>> _fonts = new( | ||
static () => Fonts.SystemFontFamilies.OrderBy(x => x.Source)); | ||
|
||
public static IEnumerable<FontFamily> SystemFonts => _fonts.Value; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
<Window x:Class="OneProject.Desktop.MainWindow" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:local="clr-namespace:OneProject.Desktop" | ||
mc:Ignorable="d" | ||
Title="MainWindow" Height="450" Width="800"> | ||
<Grid> | ||
|
||
<Window x:Class="OneProject.Desktop.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:OneProject.Desktop" | ||
mc:Ignorable="d" Title="MainWindow" MinHeight="700" MinWidth="1000" | ||
xmlns:models="clr-namespace:OneProject.Desktop.ViewModels" TextElement.Foreground="{DynamicResource MaterialDesignBody}" | ||
TextElement.FontWeight="Regular" TextElement.FontSize="13" TextOptions.TextFormattingMode="Ideal" | ||
TextOptions.TextRenderingMode="Auto" Background="{DynamicResource MaterialDesignPaper}" | ||
FontFamily="{DynamicResource MaterialDesignFont}" d:DataContext="{d:DesignInstance models:MainWindowModel}"> | ||
<Grid > | ||
</Grid> | ||
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<UserControl x:Class="OneProject.Desktop.Pages.Home" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:OneProject.Desktop.Pages" mc:Ignorable="d" | ||
d:DesignHeight="450" d:DesignWidth="800" > | ||
|
||
<Grid> | ||
<TextBlock Text="首页" /> | ||
</Grid> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace OneProject.Desktop.Pages; | ||
|
||
using System; | ||
|
||
public partial class Home : UserControl | ||
{ | ||
public Home() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public override void BeginInit() | ||
{ | ||
base.BeginInit(); | ||
} | ||
|
||
protected override void OnInitialized(EventArgs e) | ||
{ | ||
base.OnInitialized(e); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<UserControl x:Class="OneProject.Desktop.Pages.WindowsReg" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:OneProject.Desktop.Pages" mc:Ignorable="d" | ||
d:DesignHeight="450" d:DesignWidth="800"> | ||
|
||
<Grid> | ||
|
||
<TextBlock Text="注册表" /> | ||
</Grid> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace OneProject.Desktop.Pages; | ||
|
||
using System.Windows.Controls; | ||
|
||
public partial class WindowsReg : UserControl | ||
{ | ||
public WindowsReg() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
|
||
<ResourceDictionary.MergedDictionaries> | ||
<ResourceDictionary Source="pack://application:,,,/OneProject.Desktop;component/Theme/ThemeBase.xaml" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
</ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
namespace OneProject.Desktop.ViewModels; | ||
|
||
using System.Collections.ObjectModel; | ||
|
||
public partial class MainWindowModel : ObservableObject | ||
{ | ||
[ObservableProperty] | ||
private int selectedIndex; | ||
|
||
[ObservableProperty] | ||
private MenuItemModel selectedItem; | ||
|
||
public MainWindowModel( | ||
string title, | ||
string version, | ||
ObservableCollection<MenuItemModel> pages, | ||
int selectedIndex = 0) | ||
{ | ||
Title = title; | ||
Version = version; | ||
Menus = pages; | ||
SelectedItem = pages[selectedIndex]; | ||
SelectedIndex = selectedIndex; | ||
} | ||
|
||
public string Title { get; } | ||
|
||
public string Version { get; } | ||
|
||
public ObservableCollection<MenuItemModel> Menus { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
namespace OneProject.Desktop.ViewModels; | ||
|
||
public class MenuItemModel | ||
{ | ||
private object? _content; | ||
private MenuItemModel(string name, Type contentType, object? data = null) | ||
{ | ||
Title = name; | ||
ContentType = contentType; | ||
Data = data; | ||
} | ||
public Type ContentType { get; } | ||
|
||
public string Title { get; } | ||
|
||
public object? Data { get; } | ||
|
||
public object? Content => _content ??= CreateContent(); | ||
|
||
public static MenuItemModel Create<T>(string name, object? dataContent = null) | ||
=> new(name, typeof(T), dataContent); | ||
|
||
private object? CreateContent() | ||
{ | ||
var instance = Activator.CreateInstance(ContentType); | ||
|
||
if(Data is not null | ||
&& Content is FrameworkElement element) | ||
{ | ||
element.DataContext = Data; | ||
} | ||
|
||
return instance; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.