From 9b94dcb8c4a48db15a8bffb56503f55a75fc62d4 Mon Sep 17 00:00:00 2001 From: miyaji255 Date: Sun, 11 Jun 2023 17:43:37 +0900 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E9=80=9A=E3=82=8A=E7=A7=BB=E6=A4=8D?= =?UTF-8?q?=E5=AE=8C=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EasyPlot/App.xaml.cs | 7 + .../Services/ISharedConfigService.cs | 16 ++ EasyPlot/EasyPlot.csproj | 12 + EasyPlot/Services/PageService.cs | 2 + EasyPlot/Services/SharedConfigService.cs | 27 ++ .../ViewModels/GraphWholeSettingsViewModel.cs | 14 + EasyPlot/ViewModels/MainTabType.cs | 10 + EasyPlot/ViewModels/MainViewModel.cs | 137 ++++++---- EasyPlot/ViewModels/RightPanelViewModel.cs | 51 ++++ EasyPlot/ViewModels/SettingsViewModel.cs | 6 - .../ViewModels/Wrapper/GraphGroupViewModel.cs | 14 + .../Wrapper/GraphSettingViewModel.cs | 21 +- .../ViewModels/Wrapper/MainTabViewModel.cs | 72 ++++++ EasyPlot/Views/GraphGroupPage.xaml | 244 ++++++++++++++++++ EasyPlot/Views/GraphGroupPage.xaml.cs | 45 ++++ EasyPlot/Views/GraphWholeSettingsPage.xaml | 184 +++++++++++++ EasyPlot/Views/GraphWholeSettingsPage.xaml.cs | 22 ++ EasyPlot/Views/MainPage.xaml | 208 ++------------- EasyPlot/Views/MainPage.xaml.cs | 1 + EasyPlot/Views/RightPanelPage.xaml | 37 +++ EasyPlot/Views/RightPanelPage.xaml.cs | 31 +++ EasyPlot/Views/SettingsPage.xaml | 13 +- 22 files changed, 915 insertions(+), 259 deletions(-) create mode 100644 EasyPlot/Contracts/Services/ISharedConfigService.cs create mode 100644 EasyPlot/Services/SharedConfigService.cs create mode 100644 EasyPlot/ViewModels/GraphWholeSettingsViewModel.cs create mode 100644 EasyPlot/ViewModels/MainTabType.cs create mode 100644 EasyPlot/ViewModels/RightPanelViewModel.cs create mode 100644 EasyPlot/ViewModels/Wrapper/MainTabViewModel.cs create mode 100644 EasyPlot/Views/GraphGroupPage.xaml create mode 100644 EasyPlot/Views/GraphGroupPage.xaml.cs create mode 100644 EasyPlot/Views/GraphWholeSettingsPage.xaml create mode 100644 EasyPlot/Views/GraphWholeSettingsPage.xaml.cs create mode 100644 EasyPlot/Views/RightPanelPage.xaml create mode 100644 EasyPlot/Views/RightPanelPage.xaml.cs diff --git a/EasyPlot/App.xaml.cs b/EasyPlot/App.xaml.cs index 2393ab9..a49d156 100644 --- a/EasyPlot/App.xaml.cs +++ b/EasyPlot/App.xaml.cs @@ -62,6 +62,7 @@ public App() services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); // Core Services services.AddSingleton(); @@ -69,6 +70,12 @@ public App() // Views and ViewModels services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + // TODO: 全部ここに集約してしまっている。できたら解消する services.AddSingleton(); services.AddTransient(); diff --git a/EasyPlot/Contracts/Services/ISharedConfigService.cs b/EasyPlot/Contracts/Services/ISharedConfigService.cs new file mode 100644 index 0000000..39ef9e1 --- /dev/null +++ b/EasyPlot/Contracts/Services/ISharedConfigService.cs @@ -0,0 +1,16 @@ +namespace EasyPlot.Contracts.Services; + +public interface ISharedConfigService +{ + string TempDirectory { get; } + + string ResultGpPath { get; } + + string ResultPngPath { get; } + + // gnuplot では \ をパスとして認識しないので / のものを用意しておく + /// + /// パス区切り文字を / で返します + /// + string ResultPngPathNotBackSlash { get; } +} diff --git a/EasyPlot/EasyPlot.csproj b/EasyPlot/EasyPlot.csproj index b1c5933..269a03d 100644 --- a/EasyPlot/EasyPlot.csproj +++ b/EasyPlot/EasyPlot.csproj @@ -86,6 +86,9 @@ + + + @@ -107,6 +110,15 @@ Always + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + diff --git a/EasyPlot/Services/PageService.cs b/EasyPlot/Services/PageService.cs index 20ff630..c8199df 100644 --- a/EasyPlot/Services/PageService.cs +++ b/EasyPlot/Services/PageService.cs @@ -16,6 +16,8 @@ public PageService() { Configure(); Configure(); + Configure(); + Configure(); } public Type GetPageType(string key) diff --git a/EasyPlot/Services/SharedConfigService.cs b/EasyPlot/Services/SharedConfigService.cs new file mode 100644 index 0000000..6cd4710 --- /dev/null +++ b/EasyPlot/Services/SharedConfigService.cs @@ -0,0 +1,27 @@ +using EasyPlot.Contracts.Services; + +namespace EasyPlot.Services; + +public class SharedConfigService : ISharedConfigService +{ + public string TempDirectory { get; } + + public string ResultGpPath { get; } + + public string ResultPngPath { get; } + + public string ResultPngPathNotBackSlash { get; } + + public SharedConfigService() + { + // TODO: GUID に変更するか検討 + TempDirectory = Path.Combine(Path.GetTempPath(), "EasyPlot"); + + ResultGpPath = Path.Combine(TempDirectory, "result.gp"); + ResultPngPath = Path.Combine(TempDirectory, "result.png"); + ResultPngPathNotBackSlash = ResultPngPath.Replace('\\', '/'); + + if (!Directory.Exists(TempDirectory)) + Directory.CreateDirectory(TempDirectory); + } +} diff --git a/EasyPlot/ViewModels/GraphWholeSettingsViewModel.cs b/EasyPlot/ViewModels/GraphWholeSettingsViewModel.cs new file mode 100644 index 0000000..ef50561 --- /dev/null +++ b/EasyPlot/ViewModels/GraphWholeSettingsViewModel.cs @@ -0,0 +1,14 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using EasyPlot.ViewModels.Wrapper; + +namespace EasyPlot.ViewModels; + +public class GraphWholeSettingsViewModel: ObservableObject +{ + public WholeSettings WholeSettings { get; } + + public GraphWholeSettingsViewModel(MainViewModel mainViewModel) + { + WholeSettings = mainViewModel.WholeSettings; + } +} diff --git a/EasyPlot/ViewModels/MainTabType.cs b/EasyPlot/ViewModels/MainTabType.cs new file mode 100644 index 0000000..416272a --- /dev/null +++ b/EasyPlot/ViewModels/MainTabType.cs @@ -0,0 +1,10 @@ +namespace EasyPlot.ViewModels; + +public enum MainTabType +{ + GraphWholeSettings, + + GraphGroup, + + AppSettings, +} diff --git a/EasyPlot/ViewModels/MainViewModel.cs b/EasyPlot/ViewModels/MainViewModel.cs index fc92341..323652b 100644 --- a/EasyPlot/ViewModels/MainViewModel.cs +++ b/EasyPlot/ViewModels/MainViewModel.cs @@ -6,9 +6,13 @@ using EasyPlot.Contracts.Services; using EasyPlot.Utilities; using EasyPlot.ViewModels.Wrapper; +using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Data; using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Media.Imaging; using Windows.Storage; +using Windows.Storage.FileProperties; using Windows.Storage.Pickers; namespace EasyPlot.ViewModels; @@ -19,7 +23,9 @@ public partial class MainViewModel : ObservableRecipient public WholeSettings WholeSettings { get; } = new(); - public ObservableCollection TabItems { get; } + public List GraphGroups { get; } + + public ObservableCollection TabItems { get; } [ObservableProperty] [NotifyPropertyChangedFor(nameof(IsGenerateError))] @@ -30,11 +36,9 @@ public partial class MainViewModel : ObservableRecipient public bool IsGenerateSuccess => ErrorText == string.Empty; - public string ResultImagePath { get; set; } = Path.Combine(Path.GetTempPath(), "EasyPlot", "result.png"); - public ImageSource? ResultImage { get; private set; } - private readonly object _lockObj = new(); + public Uri ResultPath => new Uri(_sharedConfigService.ResultPngPath); private readonly CancellationTokenSource _cts = new(); @@ -44,58 +48,81 @@ public partial class MainViewModel : ObservableRecipient private readonly INavigationService _navigationService; + private readonly ISharedConfigService _sharedConfigService; + public MainViewModel(INavigationService navigationService) { _navigationService = navigationService; + _sharedConfigService = App.GetService(); - TabItems = new(new ObservableObject[] { WholeSettings, new GraphGroupViewModel() { GroupTitle = "Group 1" } }); + GraphGroups = new(new[] { new GraphGroupViewModel() { GroupTitle = "Group 1" } }); + TabItems = new(); _loopTimer = new PeriodicTimer(TimeSpan.FromSeconds(1)); PlotImageLoopAsync(); } #region commands - - public void OnAddTabButtonClick(TabView sender, object args) + public void OnAddTabButtonClick(TabView sender, object _) { - TabItems.Add(new GraphGroupViewModel() + // タイトルをBindするかが異なるため、直接バインディング + var newGroup = new GraphGroupViewModel() { - GroupTitle = $"Group {TabItems.Count + 1}", - }); + GroupTitle = $"Group {GraphGroups.Count + 1}", + }; + GraphGroups.Add(newGroup); + TabItems.Add(new MainTabViewModel(newGroup)); + + sender.SelectedIndex = TabItems.Count - 1; } - public void OnTabCloseRequested(TabView sender, TabViewTabCloseRequestedEventArgs args) + public void OnTabCloseRequested(TabView _, TabViewTabCloseRequestedEventArgs args) { - TabItems.Remove((args.Item as ObservableObject)!); - if (TabItems.Count < 2) + var item = (MainTabViewModel)args.Item; + TabItems.Remove(item); + if (item.Data is not null) { - TabItems.Add(new GraphGroupViewModel { GroupTitle = "Group 1" }); + GraphGroups.Remove(item.Data); + + if (GraphGroups.Count == 0) + { + var newGroup = new GraphGroupViewModel() + { + GroupTitle = "Group 1", + }; + GraphGroups.Add(newGroup); + TabItems.Add(new MainTabViewModel(newGroup)); + } } } - [RelayCommand] - private void OnSettingClicked() + public void OnComponentInitialized() { - _navigationService.NavigateTo(typeof(SettingsViewModel).FullName!); + // なかで ViewModel を要求するので初期化後に呼ぶ + TabItems.Add(new MainTabViewModel(WholeSettings)); + TabItems.Add(new MainTabViewModel(GraphGroups[0])); } [RelayCommand] - private async Task OnSaveImageAsync() + private void OnOpenSettingTab(TabView tabView) { - var copiedPath = Path.Combine(Path.GetTempPath(), "EasyPlot", "result-copied.png"); - File.Copy(ResultImagePath, copiedPath, true); + var settingTab = TabItems + .Select((tab, index) => (tab, index)) + .FirstOrDefault(t => t.tab.TabType == MainTabType.AppSettings); + if (settingTab.tab is null) + { + settingTab = (MainTabViewModel.CreateSetting(), TabItems.Count); - var picker = new FileSavePicker(); - picker.FileTypeChoices.Add("png", new[] { ".png" }); - picker.SuggestedFileName = "result"; - var file = await picker.PickSaveFileAsync(); + TabItems.Add(settingTab.tab); + } - if (file is null) - return; + tabView.SelectedIndex = settingTab.index; + } - CachedFileManager.DeferUpdates(file); - File.Copy(copiedPath, file.Path); - _ = await CachedFileManager.CompleteUpdatesAsync(file); + [RelayCommand] + private void OnSettingClicked() + { + _navigationService.NavigateTo(typeof(SettingsViewModel).FullName!); } #endregion @@ -113,10 +140,10 @@ private async void PlotImageLoopAsync() try { // 起動直後はメインスレッドが確定していないので待つ - await Task.Delay(2000); + await Task.Delay(1000); - if (!File.Exists(ResultImagePath)) - using (File.Create(ResultImagePath)) { } + if (!File.Exists(_sharedConfigService.ResultPngPath)) + using (File.Create(_sharedConfigService.ResultPngPath)) { } while (await _loopTimer.WaitForNextTickAsync(token)) { @@ -127,9 +154,13 @@ private async void PlotImageLoopAsync() if (plotText != _lastPlotText) { + _lastPlotText = plotText; await CreatePlotImageAsync(plotText, token); } - _lastPlotText = plotText; + else + { + _lastPlotText = plotText; + } } catch (Exception ex) when (ex is not OperationCanceledException) { @@ -140,14 +171,14 @@ private async void PlotImageLoopAsync() catch (OperationCanceledException) { } catch (Exception ex) { - Console.WriteLine(ex.ToString()); + ErrorText = ex.ToString(); } } private async Task CreatePlotImageAsync(string plotText, CancellationToken cancellationToken) { - var basePath = Path.Combine(Path.GetTempPath(), "EasyPlot"); - var gpFilePath = Path.Combine(basePath, "result.gp"); + var basePath = _sharedConfigService.TempDirectory; + var gpFilePath = _sharedConfigService.ResultGpPath; await File.WriteAllTextAsync(gpFilePath, plotText, UTF8WithoutBOM, cancellationToken); var info = new ProcessStartInfo { @@ -170,22 +201,24 @@ private async Task CreatePlotImageAsync(string plotText, CancellationToken cance if (errorText != string.Empty) errorText = errorText.Replace($"\"{gpFilePath}\"", string.Empty); - lock (_lockObj) + if (process.ExitCode != 0 && errorText == string.Empty) { - if (process.ExitCode != 0 && errorText == string.Empty) - { - ErrorText = "unknown error occured"; + ErrorText = "unknown error occured"; + return; + } + else + { + ErrorText = errorText; + if (IsGenerateError) return; - } - else - { - ErrorText = errorText; - if (IsGenerateError) - return; - } } - //ResultImage = ImageSource.FromFile(ResultImagePath); + var imageFile = await StorageFile.GetFileFromPathAsync(_sharedConfigService.ResultPngPath); + var stream = await imageFile.OpenReadAsync(); + var bitmap = new BitmapImage(); + await bitmap.SetSourceAsync(stream); + ResultImage = bitmap; + OnPropertyChanged(nameof(ResultPath)); OnPropertyChanged(nameof(ResultImage)); OnPropertyChanged(nameof(ErrorText)); OnPropertyChanged(nameof(IsGenerateError)); @@ -198,11 +231,9 @@ private string GeneratePlotText() builder.Append($""" set encoding utf8 set terminal pngcairo - set output "{ResultImagePath.Replace('\\', '/')}" + set output "{_sharedConfigService.ResultPngPathNotBackSlash}" """); - var graphGroups = TabItems.OfType().ToArray(); - if (WholeSettings.Title.Enabled) builder.Append($"\nset title \"{WholeSettings.Title.Value}\""); if (WholeSettings.XLabel.Enabled) @@ -220,10 +251,10 @@ set terminal pngcairo if (WholeSettings.Sampling.Enabled) builder.Append($"\nset sample {WholeSettings.Sampling.Value}"); - if (graphGroups.Any(g => g.Settings.Any())) + if (GraphGroups.Any(g => g.Settings.Any())) builder.Append("\nplot "); - foreach (var g in graphGroups) + foreach (var g in GraphGroups) { foreach (var s in g.Settings) { diff --git a/EasyPlot/ViewModels/RightPanelViewModel.cs b/EasyPlot/ViewModels/RightPanelViewModel.cs new file mode 100644 index 0000000..60adede --- /dev/null +++ b/EasyPlot/ViewModels/RightPanelViewModel.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using EasyPlot.Contracts.Services; +using Windows.Storage.Pickers; +using Windows.Storage; +using WinRT.Interop; + +namespace EasyPlot.ViewModels; + +public partial class RightPanelViewModel : ObservableObject +{ + public MainViewModel MainViewModel { get; } + + private readonly ISharedConfigService _sharedConfigService; + + public RightPanelViewModel(MainViewModel mainViewModel, ISharedConfigService sharedConfigService) + { + MainViewModel = mainViewModel; + _sharedConfigService = sharedConfigService; + } + + [RelayCommand] + private async Task OnSaveImageAsync() + { + if (!File.Exists(_sharedConfigService.ResultPngPath)) + return; + + var copiedPath = Path.Combine(_sharedConfigService.TempDirectory, "result-copied.png"); + File.Copy(_sharedConfigService.ResultPngPath, copiedPath, true); + + var picker = new FileSavePicker(); + picker.FileTypeChoices.Add("png", new[] { ".png" }); + picker.SuggestedFileName = "result"; + + var hwnd = WindowNative.GetWindowHandle(App.MainWindow); + InitializeWithWindow.Initialize(picker, hwnd); + var file = await picker.PickSaveFileAsync(); + + if (file is null) + return; + + CachedFileManager.DeferUpdates(file); + File.Move(copiedPath, file.Path, true); + _ = await CachedFileManager.CompleteUpdatesAsync(file); + } +} diff --git a/EasyPlot/ViewModels/SettingsViewModel.cs b/EasyPlot/ViewModels/SettingsViewModel.cs index 704f3bd..85e369c 100644 --- a/EasyPlot/ViewModels/SettingsViewModel.cs +++ b/EasyPlot/ViewModels/SettingsViewModel.cs @@ -61,10 +61,4 @@ private static string GetVersionDescription() return $"{"AppDisplayName".GetLocalized()} - {version.Major}.{version.Minor}.{version.Build}.{version.Revision}"; } - - [RelayCommand] - private void OnCloseSetting() - { - _navigationService.NavigateTo(typeof(MainViewModel).FullName!); - } } diff --git a/EasyPlot/ViewModels/Wrapper/GraphGroupViewModel.cs b/EasyPlot/ViewModels/Wrapper/GraphGroupViewModel.cs index d504d61..302ae9f 100644 --- a/EasyPlot/ViewModels/Wrapper/GraphGroupViewModel.cs +++ b/EasyPlot/ViewModels/Wrapper/GraphGroupViewModel.cs @@ -1,5 +1,6 @@ using System.Collections.ObjectModel; using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; namespace EasyPlot.ViewModels.Wrapper; @@ -23,4 +24,17 @@ public partial class GraphGroupViewModel : ObservableObject public TextBoxViewModel PointsSize { get; set; } = new(string.Empty); public TextBoxViewModel PointsType { get; set; } = new(string.Empty); + + [RelayCommand] + private void OnAddGraph() + { + var newSetting = new GraphSettingViewModel(); + newSetting.RemoveSettingRequested += OnRemoveSettingRequested; + Settings.Add(newSetting); + } + + private void OnRemoveSettingRequested(GraphSettingViewModel sender) + { + Settings.Remove(sender); + } } diff --git a/EasyPlot/ViewModels/Wrapper/GraphSettingViewModel.cs b/EasyPlot/ViewModels/Wrapper/GraphSettingViewModel.cs index 42be9e1..b1a50ad 100644 --- a/EasyPlot/ViewModels/Wrapper/GraphSettingViewModel.cs +++ b/EasyPlot/ViewModels/Wrapper/GraphSettingViewModel.cs @@ -9,16 +9,23 @@ using CommunityToolkit.Mvvm.Input; using EasyPlot.Models; using Windows.Storage.Pickers; +using WinRT.Interop; namespace EasyPlot.ViewModels.Wrapper; public partial class GraphSettingViewModel : ObservableObject { + public event Action? RemoveSettingRequested; + [ObservableProperty] [NotifyPropertyChangedFor(nameof(IsDataFile))] private bool _isFunction = true; - public bool IsDataFile => !IsFunction; + public bool IsDataFile + { + get => !IsFunction; + set => IsFunction = !value; + } [ObservableProperty] private string _functionText = string.Empty; @@ -40,7 +47,11 @@ private async Task OnOpenFilePicker() { var picker = new FileOpenPicker(); picker.FileTypeFilter.Add("*"); - picker.FileTypeFilter.Add("*.txt, *.tsv"); + picker.FileTypeFilter.Add(".txt"); + picker.FileTypeFilter.Add(".tsv"); + + var hwnd = WindowNative.GetWindowHandle(App.MainWindow); + InitializeWithWindow.Initialize(picker, hwnd); var result = await picker.PickSingleFileAsync(); if (result is null) return; @@ -49,6 +60,12 @@ private async Task OnOpenFilePicker() IsFunction = false; } + [RelayCommand] + private void OnRemoveSettingRequested() + { + RemoveSettingRequested?.Invoke(this); + } + [RelayCommand] private void OnFunctionTextBoxClicked() { diff --git a/EasyPlot/ViewModels/Wrapper/MainTabViewModel.cs b/EasyPlot/ViewModels/Wrapper/MainTabViewModel.cs new file mode 100644 index 0000000..4d24b96 --- /dev/null +++ b/EasyPlot/ViewModels/Wrapper/MainTabViewModel.cs @@ -0,0 +1,72 @@ +using System.ComponentModel; +using EasyPlot.Views; +using Microsoft.UI.Xaml.Controls; + +namespace EasyPlot.ViewModels.Wrapper; + +public class MainTabViewModel : INotifyPropertyChanged +{ + public event PropertyChangedEventHandler? PropertyChanged; + + public MainTabType TabType { get; } + + public GraphGroupViewModel? Data { get; } + + public string Title { get; private set; } + + public IconSource? IconSource { get; } + + public bool IsCloasble => TabType != MainTabType.GraphWholeSettings; + + public object DataContent { get; } + + private MainTabViewModel(MainTabType type, string title, object dataContent, IconSource? iconSource) + { + TabType = type; + Title = title; + DataContent = dataContent; + IconSource = iconSource; + } + + public MainTabViewModel(WholeSettings _) + { + TabType = MainTabType.GraphWholeSettings; + Title = "Home"; + + IconSource = new SymbolIconSource { Symbol = Symbol.Home }; + + var frame = new Frame(); + frame.Navigate(typeof(GraphWholeSettingsPage)); + DataContent = frame; + } + + public MainTabViewModel(GraphGroupViewModel viewModel) + { + TabType = MainTabType.GraphGroup; + Title = viewModel.GroupTitle; + viewModel.PropertyChanged += OnTitleChanged; + + Data = viewModel; + var frame = new Frame(); + frame.Navigate(typeof(GraphGroupPage), viewModel); + DataContent = frame; + } + + public static MainTabViewModel CreateSetting() + { + var frame = new Frame(); + frame.Navigate(typeof(SettingsPage)); + return new MainTabViewModel(MainTabType.AppSettings, "Setting", frame, new SymbolIconSource { Symbol = Symbol.Setting }); + } + + private void OnTitleChanged(object? sender, PropertyChangedEventArgs e) + { + if (PropertyChanged is null || e.PropertyName != nameof(GraphGroupViewModel.GroupTitle)) + return; + + Title = Data?.GroupTitle ?? string.Empty; + PropertyChanged(this, TitleArgs); + } + + private static readonly PropertyChangedEventArgs TitleArgs = new(nameof(Title)); +} diff --git a/EasyPlot/Views/GraphGroupPage.xaml b/EasyPlot/Views/GraphGroupPage.xaml new file mode 100644 index 0000000..d7e9098 --- /dev/null +++ b/EasyPlot/Views/GraphGroupPage.xaml @@ -0,0 +1,244 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EasyPlot/Views/GraphGroupPage.xaml.cs b/EasyPlot/Views/GraphGroupPage.xaml.cs new file mode 100644 index 0000000..5711b03 --- /dev/null +++ b/EasyPlot/Views/GraphGroupPage.xaml.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Navigation; +using EasyPlot.ViewModels.Wrapper; + +// To learn more about WinUI, the WinUI project structure, +// and more about our project templates, see: http://aka.ms/winui-project-info. + +namespace EasyPlot.Views +{ + /// + /// An empty page that can be used on its own or navigated to within a Frame. + /// + public sealed partial class GraphGroupPage : Page + { + public GraphGroupViewModel? ViewModel { get; private set; } + + public GraphGroupPage() + { + InitializeComponent(); + ImagePane.Navigate(typeof(RightPanelPage)); + } + + protected override void OnNavigatedTo(NavigationEventArgs e) + { + ViewModel = e.Parameter as GraphGroupViewModel; + } + + private void CheckBox_GettingFocus(UIElement sender, GettingFocusEventArgs args) + { + + } + } +} diff --git a/EasyPlot/Views/GraphWholeSettingsPage.xaml b/EasyPlot/Views/GraphWholeSettingsPage.xaml new file mode 100644 index 0000000..4122d57 --- /dev/null +++ b/EasyPlot/Views/GraphWholeSettingsPage.xaml @@ -0,0 +1,184 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EasyPlot/Views/GraphWholeSettingsPage.xaml.cs b/EasyPlot/Views/GraphWholeSettingsPage.xaml.cs new file mode 100644 index 0000000..7674a51 --- /dev/null +++ b/EasyPlot/Views/GraphWholeSettingsPage.xaml.cs @@ -0,0 +1,22 @@ +using EasyPlot.ViewModels; +using Microsoft.UI.Xaml.Controls; + +// To learn more about WinUI, the WinUI project structure, +// and more about our project templates, see: http://aka.ms/winui-project-info. + +namespace EasyPlot.Views; + +/// +/// An empty page that can be used on its own or navigated to within a Frame. +/// +public sealed partial class GraphWholeSettingsPage : Page +{ + public GraphWholeSettingsViewModel ViewModel { get; } + + public GraphWholeSettingsPage() + { + ViewModel = App.GetService(); + InitializeComponent(); + ImagePane.Navigate(typeof(RightPanelPage)); + } +} diff --git a/EasyPlot/Views/MainPage.xaml b/EasyPlot/Views/MainPage.xaml index 53621b7..3631274 100644 --- a/EasyPlot/Views/MainPage.xaml +++ b/EasyPlot/Views/MainPage.xaml @@ -8,214 +8,48 @@ xmlns:local="using:EasyPlot.Views" mc:Ignorable="d"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + TabItemsSource="{x:Bind ViewModel.TabItems}"> + + + + + + - + - - diff --git a/EasyPlot/Views/MainPage.xaml.cs b/EasyPlot/Views/MainPage.xaml.cs index 5db1099..03d9ec9 100644 --- a/EasyPlot/Views/MainPage.xaml.cs +++ b/EasyPlot/Views/MainPage.xaml.cs @@ -12,5 +12,6 @@ public MainPage() { ViewModel = App.GetService(); InitializeComponent(); + ViewModel.OnComponentInitialized(); } } diff --git a/EasyPlot/Views/RightPanelPage.xaml b/EasyPlot/Views/RightPanelPage.xaml new file mode 100644 index 0000000..b7cf0e7 --- /dev/null +++ b/EasyPlot/Views/RightPanelPage.xaml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + - - +