From 56de6cfa24d62625c40242b76df92233ecbfe747 Mon Sep 17 00:00:00 2001 From: shinichi Date: Wed, 14 Oct 2020 12:05:28 +0200 Subject: [PATCH] wip --- ClientApp/App.xaml | 10 ++++ ClientApp/ClientApp.csproj | 4 +- ClientApp/Styles/Buttons.xaml | 21 ++++++- ClientApp/Styles/Colors.xaml | 20 ++++++- ClientApp/Styles/Fonts.xaml | 5 ++ ClientApp/Styles/Texts.xaml | 4 +- ClientApp/Styles/Windows.xaml | 4 +- ClientApp/Utils/ObservableObject.cs | 7 ++- ClientApp/ViewModels/MainWindowViewModel.cs | 66 ++++++++++++++++++++- ClientApp/Views/MainWindow.xaml | 65 ++++++++++++++++++-- ClientApp/Views/MainWindow.xaml.cs | 2 +- 11 files changed, 191 insertions(+), 17 deletions(-) create mode 100644 ClientApp/Styles/Fonts.xaml diff --git a/ClientApp/App.xaml b/ClientApp/App.xaml index 1400927..98442cf 100644 --- a/ClientApp/App.xaml +++ b/ClientApp/App.xaml @@ -14,5 +14,15 @@ + + + + + + + + + diff --git a/ClientApp/ClientApp.csproj b/ClientApp/ClientApp.csproj index a28b5e8..0adf26c 100644 --- a/ClientApp/ClientApp.csproj +++ b/ClientApp/ClientApp.csproj @@ -4,7 +4,7 @@ WinExe netcoreapp3.1 true - Images\Logo\icon1.ico + @@ -20,7 +20,7 @@ - + diff --git a/ClientApp/Styles/Buttons.xaml b/ClientApp/Styles/Buttons.xaml index e86cfa5..6593716 100644 --- a/ClientApp/Styles/Buttons.xaml +++ b/ClientApp/Styles/Buttons.xaml @@ -1,5 +1,22 @@  - + xmlns:local="clr-namespace:ClientApp"> + + + + + + \ No newline at end of file diff --git a/ClientApp/Styles/Colors.xaml b/ClientApp/Styles/Colors.xaml index e86cfa5..3fa8d23 100644 --- a/ClientApp/Styles/Colors.xaml +++ b/ClientApp/Styles/Colors.xaml @@ -1,5 +1,21 @@  - + xmlns:local="clr-namespace:ClientApp"> + + #efefef + + + + #fafafa + + + #686868 + + + #000 + + + #fff + + \ No newline at end of file diff --git a/ClientApp/Styles/Fonts.xaml b/ClientApp/Styles/Fonts.xaml new file mode 100644 index 0000000..b0e7544 --- /dev/null +++ b/ClientApp/Styles/Fonts.xaml @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/ClientApp/Styles/Texts.xaml b/ClientApp/Styles/Texts.xaml index e86cfa5..b0e7544 100644 --- a/ClientApp/Styles/Texts.xaml +++ b/ClientApp/Styles/Texts.xaml @@ -1,5 +1,5 @@  - + xmlns:local="clr-namespace:ClientApp"> + \ No newline at end of file diff --git a/ClientApp/Styles/Windows.xaml b/ClientApp/Styles/Windows.xaml index e86cfa5..b0e7544 100644 --- a/ClientApp/Styles/Windows.xaml +++ b/ClientApp/Styles/Windows.xaml @@ -1,5 +1,5 @@  - + xmlns:local="clr-namespace:ClientApp"> + \ No newline at end of file diff --git a/ClientApp/Utils/ObservableObject.cs b/ClientApp/Utils/ObservableObject.cs index 3809fa1..c1c8a9b 100644 --- a/ClientApp/Utils/ObservableObject.cs +++ b/ClientApp/Utils/ObservableObject.cs @@ -7,6 +7,11 @@ namespace ClientApp.Utils { public abstract class ObservableObject : INotifyPropertyChanged { - public event PropertyChangedEventHandler PropertyChanged; + public event PropertyChangedEventHandler PropertyChanged = (sender, e) => { }; + + public void OnPropertyChanged(string name) + { + PropertyChanged(this, new PropertyChangedEventArgs(name)); + } } } diff --git a/ClientApp/ViewModels/MainWindowViewModel.cs b/ClientApp/ViewModels/MainWindowViewModel.cs index f30bf73..b4251b1 100644 --- a/ClientApp/ViewModels/MainWindowViewModel.cs +++ b/ClientApp/ViewModels/MainWindowViewModel.cs @@ -3,18 +3,82 @@ using ClientApp.Utils; using System; using System.Collections.Generic; using System.Text; +using System.Windows; namespace ClientApp.ViewModels { class MainWindowViewModel : ObservableObject { + #region private members + + private Window mWindow; + + private int mOuterMarginSize = 10; + private int mWindowRadius = 10; + + #endregion + + #region public properties public Info InfoModel { get; set; } public ObservableObject SelectedViewModel { get; set; } + public Client client { get; } - public MainWindowViewModel(Client client) + /// + /// size of the resize border around the window + /// + public int ResizeBorder { get; set; } = 6; + + public Thickness ResizeBorderThickness { get { return new Thickness(ResizeBorder + OuterMarginSize); } } + + public Thickness OuterMarginThickness { get { return new Thickness(OuterMarginSize); } } + + public CornerRadius WindowCornerRadius { get { return new CornerRadius(WindowRadius); } } + + public int OuterMarginSize { + get + { + return mWindow.WindowState == WindowState.Maximized ? 0 : mOuterMarginSize; + } + set + { + mOuterMarginSize = value; + } + } + + public int WindowRadius + { + get + { + return mWindow.WindowState == WindowState.Maximized ? 0 : mWindowRadius; + } + set + { + mWindowRadius = value; + } + } + + public int TitleHeight { get; set; } = 42; + + public GridLength TitleHeightGridLegth { get { return new GridLength(TitleHeight + ResizeBorder); } } + + #endregion + + public MainWindowViewModel(Window window, Client client) + { + this.mWindow = window; + + this.mWindow.StateChanged += (sender, e) => + { + OnPropertyChanged(nameof(ResizeBorderThickness)); + OnPropertyChanged(nameof(OuterMarginThickness)); + OnPropertyChanged(nameof(WindowCornerRadius)); + OnPropertyChanged(nameof(OuterMarginSize)); + OnPropertyChanged(nameof(WindowRadius)); + }; + this.InfoModel = new Info(); this.client = client; LoginViewModel loginViewModel = new LoginViewModel(this); diff --git a/ClientApp/Views/MainWindow.xaml b/ClientApp/Views/MainWindow.xaml index ec85b83..eab061d 100644 --- a/ClientApp/Views/MainWindow.xaml +++ b/ClientApp/Views/MainWindow.xaml @@ -9,10 +9,67 @@ mc:Ignorable="d" WindowStyle="None" AllowsTransparency="True" - Title="Whaazzzzuuuuuuuup"> - - + x:Name="applicatonWindow" + WindowStartupLocation="CenterScreen" + Title="Whaazzzzuuuuuuuup" + Width="500" + Height="500"> + + + + + + + + + + + diff --git a/ClientApp/Views/MainWindow.xaml.cs b/ClientApp/Views/MainWindow.xaml.cs index c86bbde..a9a0f6d 100644 --- a/ClientApp/Views/MainWindow.xaml.cs +++ b/ClientApp/Views/MainWindow.xaml.cs @@ -31,7 +31,7 @@ namespace ClientApp Client client = new Client(); InitializeComponent(); - DataContext = new MainWindowViewModel(client); + DataContext = new MainWindowViewModel(this, client); //BLEHandler bLEHandler = new BLEHandler(client);