├── .gitignore
├── LICENSE
├── README.md
├── documents
└── _dummy
├── images
├── XIVNote.ico
├── XIVNote_256.png
├── XIVNote_512.png
├── XIVNote_overview.png
└── _dummy
└── source
├── Thirdparty
└── _dummy
├── XIVNote.sln
├── XIVNote
├── App.config
├── App.xaml
├── App.xaml.cs
├── Config.DefaultValues.cs
├── Config.cs
├── FodyWeavers.xml
├── FodyWeavers.xsd
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── Note.Default.cs
├── Note.cs
├── Notes.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── ViewModels
│ ├── ConfigViewModel.cs
│ ├── MainWindowViewModel.cs
│ ├── NoteConfigViewModel.cs
│ ├── NoteViewModel.cs
│ └── WidgetViewModel.cs
├── Views
│ ├── ConfigView.xaml
│ ├── ConfigView.xaml.cs
│ ├── INoteOverlay.cs
│ ├── NoteConfigView.xaml
│ ├── NoteConfigView.xaml.cs
│ ├── NoteView.xaml
│ ├── NoteView.xaml.cs
│ ├── WidgetView.xaml
│ └── WidgetView.xaml.cs
├── XIVNote.csproj
├── XIVNote.ico
├── app.manifest
└── images
│ └── _dummy
├── aframe
├── documents
│ └── _dummy
├── images
│ └── _dummy
├── source
│ ├── _dummy
│ ├── aframe.Core
│ │ ├── AppLogger.Server.cs
│ │ ├── AppLogger.Wrapper.cs
│ │ ├── AppLogger.cs
│ │ ├── Bases
│ │ │ ├── JsonConfigBase.cs
│ │ │ └── RestClientBase.cs
│ │ ├── Constants.cs
│ │ ├── Controls
│ │ │ └── BindableRichTextBox.cs
│ │ ├── Converters
│ │ │ ├── BooleanConverter.cs
│ │ │ ├── BooleanToHiddenConverter.cs
│ │ │ ├── BooleanToIntConverter.cs
│ │ │ ├── BooleanToNotVisibilityConverter.cs
│ │ │ ├── ColorToBrushConverter.cs
│ │ │ ├── CompanyNameConverter.cs
│ │ │ ├── CompanyNameOmitConverter.cs
│ │ │ ├── CompanyNameToShortConverter.cs
│ │ │ ├── DayOfWeekToBrushConverter.cs
│ │ │ ├── EnumBooleanConverter.cs
│ │ │ ├── EnumToDisplayNameConverter.cs
│ │ │ ├── FontFamilyToNameConverter.cs
│ │ │ ├── FontSizeToLargeConverter.cs
│ │ │ ├── FontSizeToSmallConverter.cs
│ │ │ ├── InverseBooleanConverter.cs
│ │ │ └── StringToDoubleConverter.cs
│ │ ├── Crypter.cs
│ │ ├── Dialogs
│ │ │ ├── ColorDialogResult.cs
│ │ │ ├── ColorDialogWrapper.cs
│ │ │ ├── FontDialogResult.cs
│ │ │ ├── FontDialogWrapper.cs
│ │ │ └── Views
│ │ │ │ ├── ColorDialog.cs
│ │ │ │ ├── ColorDialogContent.xaml
│ │ │ │ ├── ColorDialogContent.xaml.cs
│ │ │ │ ├── ColorDialogViewModel.cs
│ │ │ │ ├── Dialog.xaml
│ │ │ │ ├── Dialog.xaml.cs
│ │ │ │ ├── FontDialog.cs
│ │ │ │ ├── FontDialogContent.xaml
│ │ │ │ └── FontDialogContent.xaml.cs
│ │ ├── Extensions
│ │ │ ├── AssemblyExtensions.cs
│ │ │ ├── DateTimeExtensions.cs
│ │ │ ├── DependencyObjectExtensions.cs
│ │ │ ├── EnumExtensions.cs
│ │ │ ├── EnumerableExtensions.cs
│ │ │ ├── ExceptionExtensions.cs
│ │ │ ├── ObjectExtensions.cs
│ │ │ ├── ObservableCollectionExtensions.cs
│ │ │ ├── StringExtensions.cs
│ │ │ └── TreeViewExtensions.cs
│ │ ├── FodyWeavers.xml
│ │ ├── FodyWeavers.xsd
│ │ ├── FontInfo.cs
│ │ ├── Helpers
│ │ │ ├── CommandHelper.cs
│ │ │ ├── DocumentHelper.cs
│ │ │ ├── MessageBoxHelper.cs
│ │ │ ├── ScrollViewerHelper.cs
│ │ │ ├── WPFHelper.cs
│ │ │ └── WebBrowserHelper.cs
│ │ ├── Models
│ │ │ └── VersionInfoModel.cs
│ │ ├── NativeMethods.cs
│ │ ├── Properties
│ │ │ ├── AssemblyInfo.cs
│ │ │ ├── Resources.Designer.cs
│ │ │ ├── Resources.resx
│ │ │ ├── Settings.Designer.cs
│ │ │ └── Settings.settings
│ │ ├── SuspendableObservableCollection.cs
│ │ ├── Updater.ico
│ │ ├── Updater
│ │ │ ├── ReleaseChannels.cs
│ │ │ ├── ReleaseNote.cs
│ │ │ ├── ReleaseNotes.cs
│ │ │ └── UpdateChecker.cs
│ │ ├── ViewModels
│ │ │ ├── HelpViewModel.cs
│ │ │ └── UpdateCheckerViewModel.cs
│ │ ├── Views
│ │ │ ├── CreditView.xaml
│ │ │ ├── CreditView.xaml.cs
│ │ │ ├── HelpView.xaml
│ │ │ ├── HelpView.xaml.cs
│ │ │ ├── IOverlay.cs
│ │ │ ├── MessageView.xaml
│ │ │ ├── MessageView.xaml.cs
│ │ │ ├── MessageWindow.xaml
│ │ │ ├── MessageWindow.xaml.cs
│ │ │ ├── UpdateCheckerView.xaml
│ │ │ └── UpdateCheckerView.xaml.cs
│ │ ├── WaColors.cs
│ │ ├── WrappingStream.cs
│ │ └── aframe.Core.csproj
│ ├── aframe.Updater
│ │ ├── App.config
│ │ ├── FodyWeavers.xml
│ │ ├── FodyWeavers.xsd
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── Updater.ico
│ │ ├── aframe.Updater.csproj
│ │ └── app.manifest
│ ├── aframe.sln
│ └── restore_packages.ps1
└── tools
│ └── nuget.exe
└── tools
├── 7za.exe
├── Version.master.cs
└── libz.exe
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 anoyetta
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # XIVNote
2 | [](https://github.com/anoyetta/XIVNote/releases)
3 | [](https://github.com/anoyetta/XIVNote)
4 |
5 | 
6 |
7 | 「14ノート」とでも呼んでください。
8 |
9 | FFXIV向けの付箋ツールです。
10 | FFXIVのウィンドウに対して常に前面にいるように設定されたいわゆる付箋ツールです。
11 | FFXIVのメモリ、ログ、パケットを読み取ることは一切ありません。
12 |
13 | 地図探索時の座標メモや攻略時のボスの攻撃シーケンスのカンペなどご自由にお使いください。
14 |
15 | **[Lastest-Release](https://github.com/anoyetta/XIVTags/releases)**
16 |
--------------------------------------------------------------------------------
/documents/_dummy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anoyetta/XIVNote/b7a0dff302cf8b0d44538e1aa38a89c949161c53/documents/_dummy
--------------------------------------------------------------------------------
/images/XIVNote.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anoyetta/XIVNote/b7a0dff302cf8b0d44538e1aa38a89c949161c53/images/XIVNote.ico
--------------------------------------------------------------------------------
/images/XIVNote_256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anoyetta/XIVNote/b7a0dff302cf8b0d44538e1aa38a89c949161c53/images/XIVNote_256.png
--------------------------------------------------------------------------------
/images/XIVNote_512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anoyetta/XIVNote/b7a0dff302cf8b0d44538e1aa38a89c949161c53/images/XIVNote_512.png
--------------------------------------------------------------------------------
/images/XIVNote_overview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anoyetta/XIVNote/b7a0dff302cf8b0d44538e1aa38a89c949161c53/images/XIVNote_overview.png
--------------------------------------------------------------------------------
/images/_dummy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anoyetta/XIVNote/b7a0dff302cf8b0d44538e1aa38a89c949161c53/images/_dummy
--------------------------------------------------------------------------------
/source/Thirdparty/_dummy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anoyetta/XIVNote/b7a0dff302cf8b0d44538e1aa38a89c949161c53/source/Thirdparty/_dummy
--------------------------------------------------------------------------------
/source/XIVNote.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.28714.193
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "aframe.Core", "aframe\source\aframe.Core\aframe.Core.csproj", "{1E602601-AEA4-47CD-8F44-6C5E1D7387A5}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "aframe.Updater", "aframe\source\aframe.Updater\aframe.Updater.csproj", "{38E4D044-78F5-453E-A52C-96F6B201C8B8}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XIVNote", "XIVNote\XIVNote.csproj", "{7FE1DE40-7B3D-4B06-A29C-D199754F45C3}"
11 | EndProject
12 | Global
13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 | Debug|Any CPU = Debug|Any CPU
15 | Release|Any CPU = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {1E602601-AEA4-47CD-8F44-6C5E1D7387A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {1E602601-AEA4-47CD-8F44-6C5E1D7387A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {1E602601-AEA4-47CD-8F44-6C5E1D7387A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {1E602601-AEA4-47CD-8F44-6C5E1D7387A5}.Release|Any CPU.Build.0 = Release|Any CPU
22 | {38E4D044-78F5-453E-A52C-96F6B201C8B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {38E4D044-78F5-453E-A52C-96F6B201C8B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {38E4D044-78F5-453E-A52C-96F6B201C8B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 | {38E4D044-78F5-453E-A52C-96F6B201C8B8}.Release|Any CPU.Build.0 = Release|Any CPU
26 | {7FE1DE40-7B3D-4B06-A29C-D199754F45C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {7FE1DE40-7B3D-4B06-A29C-D199754F45C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {7FE1DE40-7B3D-4B06-A29C-D199754F45C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {7FE1DE40-7B3D-4B06-A29C-D199754F45C3}.Release|Any CPU.Build.0 = Release|Any CPU
30 | EndGlobalSection
31 | GlobalSection(SolutionProperties) = preSolution
32 | HideSolutionNode = FALSE
33 | EndGlobalSection
34 | GlobalSection(ExtensibilityGlobals) = postSolution
35 | SolutionGuid = {B02AAB55-E009-4683-A86E-C8F7D1D54733}
36 | SolutionGuid = {D1BC3741-3A21-4CE3-8E3A-98EAAB6019E9}
37 | EndGlobalSection
38 | EndGlobal
39 |
--------------------------------------------------------------------------------
/source/XIVNote/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/source/XIVNote/App.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
39 |
40 |
57 |
58 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/source/XIVNote/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Reflection;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Interop;
8 | using System.Windows.Media;
9 | using System.Windows.Threading;
10 | using aframe;
11 |
12 | namespace XIVNote
13 | {
14 | ///
15 | /// App.xaml の相互作用ロジック
16 | ///
17 | public partial class App : Application
18 | {
19 | public App()
20 | {
21 | AppDomain.CurrentDomain.AssemblyResolve += CefSharpResolver;
22 |
23 | this.ShutdownMode = ShutdownMode.OnMainWindowClose;
24 | RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
25 |
26 | this.Startup += this.App_Startup;
27 | this.Exit += this.App_Exit;
28 | this.DispatcherUnhandledException += this.App_DispatcherUnhandledException;
29 | }
30 |
31 | private async void App_Startup(object sender, StartupEventArgs e)
32 | {
33 | var c = Config.Instance;
34 | c.SetStartup(c.IsStartupWithWindows);
35 |
36 | var notes = await Task.Run(() => Notes.Instance);
37 | await notes.ShowNotesAsync();
38 |
39 | await Task.Delay(10);
40 | notes.StartForegroundAppSubscriber();
41 |
42 | c.StartAutoSave();
43 | }
44 |
45 | private void App_Exit(object sender, ExitEventArgs e)
46 | {
47 | // NO-OP
48 | }
49 |
50 | private async void App_DispatcherUnhandledException(
51 | object sender,
52 | DispatcherUnhandledExceptionEventArgs e)
53 | {
54 | await Task.Run(() =>
55 | {
56 | Notes.Instance.Save();
57 | Config.Instance.Save();
58 |
59 | File.WriteAllText(
60 | @".\XIVNote.error.log",
61 | e.Exception.ToString(),
62 | new UTF8Encoding(false));
63 | });
64 |
65 | if (this.MainWindow != null)
66 | {
67 | MessageBoxHelper.ShowDialogMessageWindow(
68 | "XIVNote - Fatal",
69 | "予期しない例外を検知しました。アプリケーションを終了します。",
70 | e.Exception);
71 | }
72 | else
73 | {
74 | MessageBox.Show(
75 | "予期しない例外を検知しました。アプリケーションを終了します。\n\n" +
76 | e.Exception,
77 | "XIVNote - Fatal",
78 | MessageBoxButton.OK,
79 | MessageBoxImage.Error);
80 | }
81 | }
82 |
83 | private static Assembly CefSharpResolver(object sender, ResolveEventArgs args)
84 | {
85 | if (args.Name.StartsWith("CefSharp", StringComparison.OrdinalIgnoreCase))
86 | {
87 | var assemblyName = args.Name.Split(new[] { ',' }, 2)[0] + ".dll";
88 | var archSpecificPath = Path.Combine(
89 | AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
90 | Environment.Is64BitProcess ? "x64" : "x86",
91 | assemblyName);
92 |
93 | return File.Exists(archSpecificPath) ?
94 | Assembly.LoadFile(archSpecificPath) :
95 | null;
96 | }
97 |
98 | return null;
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/source/XIVNote/Config.DefaultValues.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace XIVNote
5 | {
6 | public partial class Config
7 | {
8 | public static readonly double DefaultWidth = 380;
9 | public static readonly double DefaultHeight = 640;
10 |
11 | public override Dictionary DefaultValues => new Dictionary()
12 | {
13 | { nameof(Scale), 1.0d },
14 | { nameof(X), 200 },
15 | { nameof(Y), 100 },
16 | { nameof(W), DefaultWidth },
17 | { nameof(H), DefaultHeight },
18 | { nameof(IsStartupWithWindows), false },
19 | { nameof(IsMinimizeStartup), false },
20 | { nameof(IsHideWhenNotExistsFFXIV), false },
21 | { nameof(ImageFileDirectory), Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) },
22 | };
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/source/XIVNote/FodyWeavers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/source/XIVNote/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using MahApps.Metro.Controls;
4 | using XIVNote.ViewModels;
5 |
6 | namespace XIVNote
7 | {
8 | ///
9 | /// MainWindow.xaml の相互作用ロジック
10 | ///
11 | public partial class MainWindow : MetroWindow
12 | {
13 | public MainWindow()
14 | {
15 | this.InitializeComponent();
16 |
17 | this.StateChanged += this.MainWindow_StateChanged;
18 |
19 | if (Config.Instance.IsMinimizeStartup)
20 | {
21 | this.ShowInTaskbar = false;
22 | this.WindowState = WindowState.Minimized;
23 |
24 | this.Loaded += (_, __) =>
25 | {
26 | this.ToHide();
27 | this.ShowInTaskbar = true;
28 | };
29 | }
30 | else
31 | {
32 | this.Loaded += (_, __) => this.Activate();
33 | }
34 |
35 | this.ViewModel.ShowCallback = () => this.ToShow();
36 | }
37 |
38 | public MainWindowViewModel ViewModel => this.DataContext as MainWindowViewModel;
39 |
40 | private void MainWindow_StateChanged(object sender, EventArgs e)
41 | {
42 | if (this.WindowState == WindowState.Minimized)
43 | {
44 | this.ToHide();
45 | }
46 | else
47 | {
48 | this.ToShow();
49 | }
50 | }
51 |
52 | public void ToShow()
53 | {
54 | this.Show();
55 | this.WindowState = WindowState.Normal;
56 | this.NotifyIcon.Visibility = Visibility.Collapsed;
57 |
58 | this.Activate();
59 | }
60 |
61 | public void ToHide()
62 | {
63 | this.NotifyIcon.Visibility = Visibility.Visible;
64 | this.Hide();
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/source/XIVNote/Note.Default.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Xml.Serialization;
3 | using aframe;
4 | using Prism.Mvvm;
5 |
6 | namespace XIVNote
7 | {
8 | public partial class Note : BindableBase
9 | {
10 | public static readonly double DefaultNoteSize = 350;
11 | public static readonly double DefaultWidgetNoteSize = 530;
12 |
13 | public static readonly double MinWidth = 200;
14 |
15 | public static readonly double MinHeight = 100;
16 |
17 | public static Note CreateNew()
18 | {
19 | var obj = (Notes.Instance.DefaultNote ?? DefaultNoteStyle).Clone();
20 | obj.ID = Guid.NewGuid();
21 | obj.Text = string.Empty;
22 | return obj;
23 | }
24 |
25 | [XmlIgnore]
26 | public static readonly Note DefaultNoteStyle = new Note()
27 | {
28 | IsDefault = true,
29 | W = DefaultNoteSize,
30 | H = DefaultNoteSize,
31 | ForegroundColorString = "#000000",
32 | BackgroundColorString = "#fcc800",
33 | Opacity = 0.9,
34 | Font = FontInfo.DefaultFont,
35 | };
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/source/XIVNote/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 | using System.Windows;
4 |
5 | [assembly: AssemblyTitle("XIVNote")]
6 | [assembly: AssemblyDescription("https://github.com/anoyetta/XIVNote")]
7 | [assembly: AssemblyConfiguration("")]
8 | [assembly: AssemblyCompany("")]
9 | [assembly: AssemblyProduct("XIVNote")]
10 | [assembly: AssemblyCopyright("Copyright © anoyetta 2019")]
11 | [assembly: AssemblyTrademark("")]
12 | [assembly: AssemblyCulture("")]
13 | [assembly: ComVisible(false)]
14 | [assembly: ThemeInfo(
15 | ResourceDictionaryLocation.None,
16 | ResourceDictionaryLocation.SourceAssembly
17 | )]
18 | [assembly: AssemblyVersion("2.2.1.0")]
19 |
--------------------------------------------------------------------------------
/source/XIVNote/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // このコードはツールによって生成されました。
4 | // ランタイム バージョン:4.0.30319.42000
5 | //
6 | // このファイルへの変更は、以下の状況下で不正な動作の原因になったり、
7 | // コードが再生成されるときに損失したりします。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace XIVNote.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// ローカライズされた文字列などを検索するための、厳密に型指定されたリソース クラスです。
17 | ///
18 | // このクラスは StronglyTypedResourceBuilder クラスが ResGen
19 | // または Visual Studio のようなツールを使用して自動生成されました。
20 | // メンバーを追加または削除するには、.ResX ファイルを編集して、/str オプションと共に
21 | // ResGen を実行し直すか、または VS プロジェクトをビルドし直します。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// このクラスで使用されているキャッシュされた ResourceManager インスタンスを返します。
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("XIVNote.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// すべてについて、現在のスレッドの CurrentUICulture プロパティをオーバーライドします
51 | /// 現在のスレッドの CurrentUICulture プロパティをオーバーライドします。
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/source/XIVNote/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/source/XIVNote/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // このコードはツールによって生成されました。
4 | // ランタイム バージョン:4.0.30319.42000
5 | //
6 | // このファイルへの変更は、以下の状況下で不正な動作の原因になったり、
7 | // コードが再生成されるときに損失したりします。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace XIVNote.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/source/XIVNote/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/source/XIVNote/ViewModels/ConfigViewModel.cs:
--------------------------------------------------------------------------------
1 | using aframe;
2 | using Prism.Commands;
3 | using Prism.Mvvm;
4 |
5 | namespace XIVNote.ViewModels
6 | {
7 | public class ConfigViewModel : BindableBase
8 | {
9 | public ConfigViewModel()
10 | {
11 | }
12 |
13 | public Config Config => Config.Instance;
14 |
15 | public Note DefaultNote => Notes.Instance.DefaultNote;
16 |
17 | private DelegateCommand changeBackgroundCommand;
18 |
19 | public DelegateCommand ChangeBackgroundCommand =>
20 | this.changeBackgroundCommand ?? (this.changeBackgroundCommand = new DelegateCommand(
21 | () => CommandHelper.ExecuteChangeColor(
22 | () => this.DefaultNote.BackgroundColor,
23 | color => this.DefaultNote.BackgroundColor = color)));
24 |
25 | private DelegateCommand changeForegroundCommand;
26 |
27 | public DelegateCommand ChangeForegroundCommand =>
28 | this.changeForegroundCommand ?? (this.changeForegroundCommand = new DelegateCommand(
29 | () => CommandHelper.ExecuteChangeColor(
30 | () => this.DefaultNote.ForegroundColor,
31 | color => this.DefaultNote.ForegroundColor = color)));
32 |
33 | private DelegateCommand changeFontCommand;
34 |
35 | public DelegateCommand ChangeFontCommand =>
36 | this.changeFontCommand ?? (this.changeFontCommand = new DelegateCommand(
37 | () => CommandHelper.ExecuteChangeFont(
38 | () => this.DefaultNote.Font,
39 | font => this.DefaultNote.Font = font)));
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/source/XIVNote/ViewModels/MainWindowViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using aframe;
5 | using Prism.Commands;
6 | using Prism.Mvvm;
7 | using XIVNote.Views;
8 |
9 | namespace XIVNote.ViewModels
10 | {
11 | public class MainWindowViewModel : BindableBase
12 | {
13 | public Action ShowCallback { get; set; }
14 |
15 | public MainWindowViewModel()
16 | {
17 | Notes.Instance.NoteList.CollectionChanged += (_, __) => this.RaisePropertyChanged(nameof(this.NoteList));
18 | }
19 |
20 | public Config Config => Config.Instance;
21 |
22 | public IEnumerable NoteList => Notes.Instance.NoteList.Where(x => !x.IsDefault);
23 |
24 | #region Show
25 |
26 | private DelegateCommand showCommand;
27 |
28 | public DelegateCommand ShowCommand =>
29 | this.showCommand ?? (this.showCommand = new DelegateCommand(this.ExecuteShowCommand));
30 |
31 | private void ExecuteShowCommand() => this.ShowCallback?.Invoke();
32 |
33 | #endregion Show
34 |
35 | #region ShowConfig
36 |
37 | private DelegateCommand showConfigCommand;
38 |
39 | public DelegateCommand ShowConfigCommand =>
40 | this.showConfigCommand ?? (this.showConfigCommand = new DelegateCommand(this.ExecuteShowConfigCommand));
41 |
42 | private void ExecuteShowConfigCommand()
43 | {
44 | var mainView = WPFHelper.MainWindow;
45 |
46 | var configView = new ConfigView();
47 | configView.Height = mainView.Height;
48 | configView.Left = mainView.Left + mainView.Width + 3;
49 | configView.Top = mainView.Top;
50 |
51 | configView.Show();
52 | }
53 |
54 | #endregion ShowConfig
55 |
56 | #region Exit
57 |
58 | private DelegateCommand exitCommand;
59 |
60 | public DelegateCommand ExitCommand =>
61 | this.exitCommand ?? (this.exitCommand = new DelegateCommand(this.ExecuteExitCommand));
62 |
63 | private void ExecuteExitCommand() => WPFHelper.MainWindow?.Close();
64 |
65 | #endregion Exit
66 |
67 | #region AddWidget
68 |
69 | private DelegateCommand addWidgetCommand;
70 |
71 | public DelegateCommand AddWidgetCommand =>
72 | this.addWidgetCommand ?? (this.addWidgetCommand = new DelegateCommand(this.ExecuteAddWidgetCommand));
73 |
74 | private async void ExecuteAddWidgetCommand() => await Notes.Instance.AddNoteAsync(
75 | Notes.Instance.NoteList.LastOrDefault(x => !x.IsDefault),
76 | true);
77 |
78 | #endregion AddWidget
79 |
80 | #region AddNote
81 |
82 | private DelegateCommand addNoteCommand;
83 |
84 | public DelegateCommand AddNoteCommand =>
85 | this.addNoteCommand ?? (this.addNoteCommand = new DelegateCommand(this.ExecuteAddNoteCommand));
86 |
87 | private async void ExecuteAddNoteCommand() => await Notes.Instance.AddNoteAsync(
88 | Notes.Instance.NoteList.LastOrDefault(x => !x.IsDefault));
89 |
90 | #endregion AddNote
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/source/XIVNote/ViewModels/NoteConfigViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using aframe;
3 | using Prism.Commands;
4 | using Prism.Mvvm;
5 |
6 | namespace XIVNote.ViewModels
7 | {
8 | public class NoteConfigViewModel : BindableBase
9 | {
10 | public NoteConfigViewModel()
11 | {
12 | }
13 |
14 | private Note model = WPFHelper.IsDesignMode ? Note.DefaultNoteStyle : null;
15 |
16 | public Note Model
17 | {
18 | get => this.model;
19 | set => this.SetProperty(ref this.model, value);
20 | }
21 |
22 | public Guid ID => this.Model?.ID ?? Guid.Empty;
23 |
24 | private DelegateCommand changeBackgroundCommand;
25 |
26 | public DelegateCommand ChangeBackgroundCommand =>
27 | this.changeBackgroundCommand ?? (this.changeBackgroundCommand = new DelegateCommand(
28 | () => CommandHelper.ExecuteChangeColor(
29 | () => this.model.BackgroundColor,
30 | color => this.model.BackgroundColor = color)));
31 |
32 | private DelegateCommand changeForegroundCommand;
33 |
34 | public DelegateCommand ChangeForegroundCommand =>
35 | this.changeForegroundCommand ?? (this.changeForegroundCommand = new DelegateCommand(
36 | () => CommandHelper.ExecuteChangeColor(
37 | () => this.model.ForegroundColor,
38 | color => this.model.ForegroundColor = color)));
39 |
40 | private DelegateCommand changeFontCommand;
41 |
42 | public DelegateCommand ChangeFontCommand =>
43 | this.changeFontCommand ?? (this.changeFontCommand = new DelegateCommand(
44 | () => CommandHelper.ExecuteChangeFont(
45 | () => this.model.Font,
46 | font => this.model.Font = font)));
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/source/XIVNote/ViewModels/NoteViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Threading;
3 | using aframe;
4 | using Prism.Commands;
5 | using Prism.Mvvm;
6 | using XIVNote.Views;
7 |
8 | namespace XIVNote.ViewModels
9 | {
10 | public class NoteViewModel : BindableBase
11 | {
12 | public NoteViewModel()
13 | {
14 | if (!AutoSaveTimer.IsEnabled)
15 | {
16 | AutoSaveTimer.Start();
17 | }
18 | }
19 |
20 | private Note model = WPFHelper.IsDesignMode ? Note.DefaultNoteStyle : null;
21 |
22 | public Note Model
23 | {
24 | get => this.model;
25 | set => this.SetProperty(ref this.model, value);
26 | }
27 |
28 | public Guid ID => this.Model?.ID ?? Guid.Empty;
29 |
30 | public Config Config => Config.Instance;
31 |
32 | #region AddNote
33 |
34 | private DelegateCommand addNoteCommand;
35 |
36 | public DelegateCommand AddNoteCommand =>
37 | this.addNoteCommand ?? (this.addNoteCommand = new DelegateCommand(this.ExecuteAddNoteCommand));
38 |
39 | private async void ExecuteAddNoteCommand() => await Notes.Instance.AddNoteAsync(this.Model);
40 |
41 | #endregion AddNote
42 |
43 | #region ShowConfig
44 |
45 | private DelegateCommand showConfigCommand;
46 |
47 | public DelegateCommand ShowConfigCommand =>
48 | this.showConfigCommand ?? (this.showConfigCommand = new DelegateCommand(this.ExecuteShowConfigCommand));
49 |
50 | private void ExecuteShowConfigCommand()
51 | {
52 | var config = new NoteConfigView();
53 |
54 | config.ViewModel.Model = this.Model;
55 | config.Height = this.Model.H;
56 | config.Top = this.Model.Y;
57 | config.Left = this.Model.X + this.Model.W + 3;
58 |
59 | config.Show();
60 | }
61 |
62 | #endregion ShowConfig
63 |
64 | #region Minimize
65 |
66 | private DelegateCommand minimizeCommand;
67 |
68 | public DelegateCommand MinimizeCommand =>
69 | this.minimizeCommand ?? (this.minimizeCommand = new DelegateCommand(this.ExecuteMinimizeCommand));
70 |
71 | private void ExecuteMinimizeCommand()
72 | {
73 | this.Model.IsVisible = false;
74 | Notes.Instance.EnqueueSave();
75 | }
76 |
77 | #endregion Minimize
78 |
79 | #region Close
80 |
81 | private DelegateCommand closeCommand;
82 |
83 | public DelegateCommand CloseCommand =>
84 | this.closeCommand ?? (this.closeCommand = new DelegateCommand(this.ExecuteCloseCommand));
85 |
86 | private async void ExecuteCloseCommand() => await Notes.Instance.RemoveNoteAsync(this.Model);
87 |
88 | #endregion Close
89 |
90 | #region Auto Save Timer
91 |
92 | public static volatile bool IsSaveQueue = false;
93 |
94 | private static readonly Lazy LazyAutoSaveTimer = new Lazy(CreateAutoSaveTimer);
95 |
96 | private static DispatcherTimer AutoSaveTimer => LazyAutoSaveTimer.Value;
97 |
98 | private static DispatcherTimer CreateAutoSaveTimer()
99 | {
100 | var timer = new DispatcherTimer(DispatcherPriority.ContextIdle)
101 | {
102 | Interval = TimeSpan.FromSeconds(6),
103 | };
104 |
105 | timer.Tick += (_, __) =>
106 | {
107 | if (IsSaveQueue)
108 | {
109 | IsSaveQueue = false;
110 | Notes.Instance.EnqueueSave();
111 | }
112 | };
113 |
114 | return timer;
115 | }
116 |
117 | #endregion Auto Save Timer
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/source/XIVNote/ViewModels/WidgetViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using System.Windows.Threading;
4 | using aframe;
5 | using Prism.Commands;
6 | using Prism.Mvvm;
7 |
8 | namespace XIVNote.ViewModels
9 | {
10 | public class WidgetViewModel : BindableBase
11 | {
12 | public WidgetViewModel()
13 | {
14 | if (!AutoSaveTimer.IsEnabled)
15 | {
16 | AutoSaveTimer.Start();
17 | }
18 | }
19 |
20 | private Note model = WPFHelper.IsDesignMode ? Note.DefaultNoteStyle : null;
21 |
22 | public Note Model
23 | {
24 | get => this.model;
25 | set => this.SetProperty(ref this.model, value);
26 | }
27 |
28 | public Guid ID => this.Model?.ID ?? Guid.Empty;
29 |
30 | public Config Config => Config.Instance;
31 |
32 | private DelegateCommand changeBackgroundCommand;
33 |
34 | public DelegateCommand ChangeBackgroundCommand =>
35 | this.changeBackgroundCommand ?? (this.changeBackgroundCommand = new DelegateCommand(
36 | () => CommandHelper.ExecuteChangeColor(
37 | () => this.model.BackgroundColor,
38 | color => this.model.BackgroundColor = color)));
39 |
40 | #region Minimize
41 |
42 | private DelegateCommand minimizeCommand;
43 |
44 | public DelegateCommand MinimizeCommand =>
45 | this.minimizeCommand ?? (this.minimizeCommand = new DelegateCommand(this.ExecuteMinimizeCommand));
46 |
47 | private async void ExecuteMinimizeCommand()
48 | {
49 | this.Model.IsVisible = false;
50 | await Task.Run(Notes.Instance.Save);
51 | }
52 |
53 | #endregion Minimize
54 |
55 | #region Close
56 |
57 | private DelegateCommand closeCommand;
58 |
59 | public DelegateCommand CloseCommand =>
60 | this.closeCommand ?? (this.closeCommand = new DelegateCommand(this.ExecuteCloseCommand));
61 |
62 | private async void ExecuteCloseCommand() => await Notes.Instance.RemoveNoteAsync(this.Model);
63 |
64 | #endregion Close
65 |
66 | #region Auto Save Timer
67 |
68 | public static volatile bool IsSaveQueue = false;
69 |
70 | private static readonly Lazy LazyAutoSaveTimer = new Lazy(CreateAutoSaveTimer);
71 |
72 | private static DispatcherTimer AutoSaveTimer => LazyAutoSaveTimer.Value;
73 |
74 | private static DispatcherTimer CreateAutoSaveTimer()
75 | {
76 | var timer = new DispatcherTimer(DispatcherPriority.ContextIdle)
77 | {
78 | Interval = TimeSpan.FromSeconds(7),
79 | };
80 |
81 | timer.Tick += (_, __) =>
82 | {
83 | if (IsSaveQueue)
84 | {
85 | IsSaveQueue = false;
86 | Notes.Instance.EnqueueSave();
87 | }
88 | };
89 |
90 | return timer;
91 | }
92 |
93 | #endregion Auto Save Timer
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/source/XIVNote/Views/ConfigView.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using MahApps.Metro.Controls;
3 |
4 | namespace XIVNote.Views
5 | {
6 | ///
7 | /// ConfigView.xaml の相互作用ロジック
8 | ///
9 | public partial class ConfigView : MetroWindow
10 | {
11 | public ConfigView()
12 | {
13 | this.InitializeComponent();
14 |
15 | this.Closing += async (_, __) =>
16 | {
17 | await Task.Run(() =>
18 | {
19 | Config.Instance.Save();
20 | Notes.Instance.Save();
21 | });
22 | };
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/source/XIVNote/Views/INoteOverlay.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using aframe.Views;
3 |
4 | namespace XIVNote.Views
5 | {
6 | public interface INoteOverlay : IOverlay
7 | {
8 | Guid ID { get; }
9 |
10 | Note Note { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/source/XIVNote/Views/NoteConfigView.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using MahApps.Metro.Controls;
3 | using XIVNote.ViewModels;
4 |
5 | namespace XIVNote.Views
6 | {
7 | ///
8 | /// NoteConfigView.xaml の相互作用ロジック
9 | ///
10 | public partial class NoteConfigView : MetroWindow
11 | {
12 | public NoteConfigView()
13 | {
14 | this.InitializeComponent();
15 | }
16 |
17 | public NoteConfigViewModel ViewModel => this.DataContext as NoteConfigViewModel;
18 |
19 | public Guid ID => this.ViewModel?.Model?.ID ?? Guid.Empty;
20 |
21 | public Config Config => Config.Instance;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/source/XIVNote/Views/NoteView.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Windows;
4 | using System.Windows.Controls;
5 | using aframe.Views;
6 | using XIVNote.ViewModels;
7 |
8 | namespace XIVNote.Views
9 | {
10 | ///
11 | /// NoteView.xaml の相互作用ロジック
12 | ///
13 | public partial class NoteView : Window, INoteOverlay
14 | {
15 | public NoteView()
16 | {
17 | this.InitializeComponent();
18 |
19 | this.MinWidth = Note.MinWidth;
20 | this.MinHeight = Note.MinHeight;
21 |
22 | this.Image.MouseLeftButtonDown += (_, __) => this.DragMove();
23 | this.ToolBarGrid.MouseLeftButtonDown += (_, __) => this.DragMove();
24 |
25 | this.MouseEnter += (_, __) => this.ToolBarGrid.Visibility = Visibility.Visible;
26 | this.MouseLeave += (_, __) => this.ToolBarGrid.Visibility = Visibility.Collapsed;
27 |
28 | this.Loaded += (_, __) =>
29 | {
30 | this.ViewModel.Model.PropertyChanged += this.Model_PropertyChanged;
31 |
32 | this.InitializeOverlayVisible(
33 | ref this.overlayVisible,
34 | this.ViewModel.Model?.IsVisible ?? true);
35 |
36 | this.ToolBarGrid.Visibility = this.IsMouseOver ?
37 | Visibility.Visible :
38 | Visibility.Collapsed;
39 |
40 | this.SubscribeZOrderCorrector();
41 | };
42 |
43 | this.Closed += (_, __) =>
44 | {
45 | this.ViewModel.Model.PropertyChanged -= this.Model_PropertyChanged;
46 | };
47 |
48 | this.LeftThumb.DragDelta += (_, e) =>
49 | {
50 | this.Left += e.HorizontalChange;
51 | this.Width -= e.HorizontalChange;
52 | };
53 |
54 | this.RightThumb.DragDelta += (_, e) =>
55 | {
56 | this.Width += e.HorizontalChange;
57 | };
58 |
59 | this.TopThumb.DragDelta += (_, e) =>
60 | {
61 | this.Top += e.VerticalChange;
62 | this.Height -= e.VerticalChange;
63 | };
64 |
65 | this.BottomThumb.DragDelta += (_, e) =>
66 | {
67 | this.Height += e.VerticalChange;
68 | };
69 | }
70 |
71 | public NoteViewModel ViewModel => this.DataContext as NoteViewModel;
72 |
73 | public Guid ID => this.ViewModel?.Model?.ID ?? Guid.Empty;
74 |
75 | public Note Note
76 | {
77 | get => this.ViewModel.Model;
78 | set => this.ViewModel.Model = value;
79 | }
80 |
81 | private void Model_PropertyChanged(object sender, PropertyChangedEventArgs e)
82 | {
83 | var model = sender as Note;
84 |
85 | switch (e.PropertyName)
86 | {
87 | case nameof(Note.IsVisible):
88 | this.OverlayVisible = model.IsVisible;
89 | break;
90 |
91 | default:
92 | break;
93 | }
94 |
95 | NoteViewModel.IsSaveQueue = true;
96 | }
97 |
98 | private void NoteTextBox_TextChanged(object sender, TextChangedEventArgs e)
99 | => this.ViewModel.Model.Text = this.NoteTextBox.Text;
100 |
101 | #region IOverlay
102 |
103 | public int ZOrder => 0;
104 |
105 | private bool overlayVisible;
106 |
107 | public bool OverlayVisible
108 | {
109 | get => this.overlayVisible;
110 | set => this.SetOverlayVisible(ref this.overlayVisible, value);
111 | }
112 |
113 | #endregion IOverlay
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/source/XIVNote/XIVNote.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anoyetta/XIVNote/b7a0dff302cf8b0d44538e1aa38a89c949161c53/source/XIVNote/XIVNote.ico
--------------------------------------------------------------------------------
/source/XIVNote/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | true/PM
23 |
24 |
25 |
26 |
27 |
28 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/source/XIVNote/images/_dummy:
--------------------------------------------------------------------------------
1 | # Markdown file
--------------------------------------------------------------------------------
/source/aframe/documents/_dummy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anoyetta/XIVNote/b7a0dff302cf8b0d44538e1aa38a89c949161c53/source/aframe/documents/_dummy
--------------------------------------------------------------------------------
/source/aframe/images/_dummy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anoyetta/XIVNote/b7a0dff302cf8b0d44538e1aa38a89c949161c53/source/aframe/images/_dummy
--------------------------------------------------------------------------------
/source/aframe/source/_dummy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anoyetta/XIVNote/b7a0dff302cf8b0d44538e1aa38a89c949161c53/source/aframe/source/_dummy
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/AppLogger.Server.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Runtime.CompilerServices;
4 | using Microsoft.AspNetCore.Mvc;
5 |
6 | namespace aframe
7 | {
8 | public static partial class AppLogger
9 | {
10 | public static void WriteApiErrorLog(
11 | ControllerBase controller,
12 | Exception exception,
13 | [CallerMemberName] string callerMemberName = null,
14 | [CallerFilePath] string callerFilePath = null)
15 | {
16 | var caller = string.Empty;
17 | if (!string.IsNullOrEmpty(callerMemberName) &&
18 | !string.IsNullOrEmpty(callerFilePath))
19 | {
20 | caller = $"{Path.GetFileNameWithoutExtension(callerFilePath)} {callerMemberName}()";
21 | }
22 |
23 | var uri = default(string);
24 | var request = controller.Request;
25 | if (request != null)
26 | {
27 | uri = $"{request.Method} {request.Path}{request.QueryString}";
28 | }
29 |
30 | AppLogger.Error(
31 | uri != null ? $"[{caller}] {uri}" : $"[{caller}]",
32 | exception);
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/AppLogger.Wrapper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Runtime.CompilerServices;
4 | using System.Threading.Tasks;
5 |
6 | namespace aframe
7 | {
8 | public static partial class AppLogger
9 | {
10 | public delegate bool ExceptionHandler(string methodName, Exception catchedException);
11 |
12 | public static Action Wrap(
13 | Func action,
14 | ExceptionHandler exceptionHandler = null,
15 | [CallerMemberName] string callerMemberName = null,
16 | [CallerFilePath] string callerFilePath = null)
17 | => new Action(async () =>
18 | {
19 | var caller = string.Empty;
20 | if (!string.IsNullOrEmpty(callerMemberName) &&
21 | !string.IsNullOrEmpty(callerFilePath))
22 | {
23 | caller = $"{Path.GetFileNameWithoutExtension(callerFilePath)} {callerMemberName}()";
24 | }
25 |
26 | try
27 | {
28 | AppLogger.Write($"{caller} begin.");
29 | await action();
30 | }
31 | catch (Exception ex)
32 | {
33 | AppLogger.Error($"{caller} catched exception.", ex);
34 |
35 | var handled = false;
36 | if (exceptionHandler != null)
37 | {
38 | handled = exceptionHandler.Invoke(caller, ex);
39 | }
40 |
41 | if (!handled)
42 | {
43 | throw;
44 | }
45 | }
46 | finally
47 | {
48 | AppLogger.Write($"{caller} end.");
49 | }
50 | });
51 |
52 | public static Action Wrap(
53 | Action action,
54 | ExceptionHandler exceptionHandler = null,
55 | [CallerMemberName] string callerMemberName = null,
56 | [CallerFilePath] string callerFilePath = null)
57 | => new Action(() =>
58 | {
59 | var caller = string.Empty;
60 | if (!string.IsNullOrEmpty(callerMemberName) &&
61 | !string.IsNullOrEmpty(callerFilePath))
62 | {
63 | caller = $"{Path.GetFileNameWithoutExtension(callerFilePath)} {callerMemberName}()";
64 | }
65 |
66 | try
67 | {
68 | AppLogger.Write($"{caller} begin.");
69 | action();
70 | }
71 | catch (Exception ex)
72 | {
73 | AppLogger.Error($"{caller} catched exception.", ex);
74 |
75 | var handled = false;
76 | if (exceptionHandler != null)
77 | {
78 | handled = exceptionHandler.Invoke(caller, ex);
79 | }
80 |
81 | if (!handled)
82 | {
83 | throw;
84 | }
85 | }
86 | finally
87 | {
88 | AppLogger.Write($"{caller} end.");
89 | }
90 | });
91 |
92 | public static void RunWrap(
93 | Func action,
94 | ExceptionHandler exceptionHandler = null,
95 | [CallerMemberName] string callerMemberName = null,
96 | [CallerFilePath] string callerFilePath = null)
97 | => Wrap(action, exceptionHandler, callerMemberName, callerFilePath).Invoke();
98 |
99 | public static void RunWrap(
100 | Action action,
101 | ExceptionHandler exceptionHandler = null,
102 | [CallerMemberName] string callerMemberName = null,
103 | [CallerFilePath] string callerFilePath = null)
104 | => Wrap(action, exceptionHandler, callerMemberName, callerFilePath).Invoke();
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Bases/RestClientBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Specialized;
3 | using System.Diagnostics;
4 | using System.IO;
5 | using System.Net.Http;
6 | using System.Net.Http.Headers;
7 | using System.Threading.Tasks;
8 | using System.Web;
9 | using aframe.Models;
10 | using aframe.ViewModels;
11 |
12 | namespace aframe
13 | {
14 | public abstract class RestClientBase :
15 | IDisposable
16 | {
17 | public abstract Uri BaseAddress { get; }
18 |
19 | private readonly HttpClient client = new HttpClient();
20 |
21 | public RestClientBase()
22 | {
23 | this.InitializeClient();
24 | }
25 |
26 | private void InitializeClient()
27 | {
28 | this.client.BaseAddress = this.BaseAddress;
29 | this.client.DefaultRequestHeaders.Accept.Clear();
30 | this.client.DefaultRequestHeaders.Accept.Add(
31 | new MediaTypeWithQualityHeaderValue("application/json"));
32 | }
33 |
34 | public async Task CreateAsync(
35 | string uri,
36 | T data,
37 | NameValueCollection queryString = null)
38 | {
39 | if (queryString != null)
40 | {
41 | uri += "?" + queryString.ToString();
42 | }
43 |
44 | var res = await this.client.PostAsJsonAsync(uri, data);
45 | res.EnsureSuccessStatusCode();
46 | return res;
47 | }
48 |
49 | public async Task GetAsync(
50 | string uri,
51 | NameValueCollection queryString = null)
52 | {
53 | if (queryString != null)
54 | {
55 | uri += "?" + queryString.ToString();
56 | }
57 |
58 | return await this.client.GetAsync(uri);
59 | }
60 |
61 | public async Task UpdateAsync(
62 | string uri,
63 | object id,
64 | T data,
65 | NameValueCollection queryString = null)
66 | {
67 | uri = Path.Combine(uri, id.ToString());
68 | uri = uri.Replace("\\", "/");
69 |
70 | if (queryString != null)
71 | {
72 | uri += "?" + queryString.ToString();
73 | }
74 |
75 | var res = await this.client.PutAsJsonAsync(uri, data);
76 | res.EnsureSuccessStatusCode();
77 | return res;
78 | }
79 |
80 | public async Task DeleteAsync(
81 | string uri,
82 | object id,
83 | NameValueCollection queryString = null)
84 | {
85 | uri = Path.Combine(uri, id.ToString());
86 | uri = uri.Replace("\\", "/");
87 |
88 | if (queryString != null)
89 | {
90 | uri += "?" + queryString.ToString();
91 | }
92 |
93 | var res = await client.DeleteAsync(uri);
94 | res.EnsureSuccessStatusCode();
95 | return res;
96 | }
97 |
98 | public async Task GetVersionAsync()
99 | {
100 | try
101 | {
102 | var result = await this.GetAsync("version");
103 | var vi = await result?.Content?.ReadAsAsync();
104 | if (vi != null)
105 | {
106 | HelpViewModel.Instance.AddVersionInfos(vi);
107 | }
108 | }
109 | catch (Exception ex)
110 | {
111 | Debug.WriteLine(ex);
112 | }
113 | }
114 |
115 | public NameValueCollection CreateQueryStringParser()
116 | => HttpUtility.ParseQueryString(string.Empty);
117 |
118 | public void Dispose()
119 | {
120 | this.client?.Dispose();
121 | }
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Constants.cs:
--------------------------------------------------------------------------------
1 | namespace aframe
2 | {
3 | public static class Constants
4 | {
5 | ///
6 | /// フォントサイズの拡大基本レート
7 | ///
8 | public const double FontSizeScalingRate = 0.1;
9 |
10 | public static double ScalingL => 1.0 + (Constants.FontSizeScalingRate * 1.0);
11 |
12 | public static double ScalingXL => 1.0 + (Constants.FontSizeScalingRate * 2.0);
13 |
14 | public static double ScalingS => 1.0 - (Constants.FontSizeScalingRate * 1.0);
15 |
16 | public static double ScalingXS => 1.0 - (Constants.FontSizeScalingRate * 2.0);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Controls/BindableRichTextBox.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Controls;
3 | using System.Windows.Documents;
4 |
5 | namespace aframe
6 | {
7 | public class BindableRichTextBox : RichTextBox
8 | {
9 | public static readonly DependencyProperty DocumentProperty = DependencyProperty.Register(
10 | nameof(Document),
11 | typeof(FlowDocument),
12 | typeof(BindableRichTextBox),
13 | new UIPropertyMetadata(
14 | null,
15 | OnRichTextItemsChanged));
16 |
17 | public new FlowDocument Document
18 | {
19 | get => (FlowDocument)this.GetValue(DocumentProperty);
20 | set => this.SetValue(DocumentProperty, value);
21 | }
22 |
23 | private static void OnRichTextItemsChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
24 | {
25 | var control = sender as RichTextBox;
26 | if (control != null)
27 | {
28 | control.Document = e.NewValue as FlowDocument;
29 | }
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Converters/BooleanConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Windows.Data;
5 |
6 | namespace aframe
7 | {
8 | public class BooleanConverter : IValueConverter
9 | {
10 | public BooleanConverter(
11 | T trueValue,
12 | T falseValue)
13 | {
14 | this.True = trueValue;
15 | this.False = falseValue;
16 | }
17 |
18 | public T True { get; set; }
19 |
20 | public T False { get; set; }
21 |
22 | public virtual object Convert(object value, Type targetType, object parameter, CultureInfo culture)
23 | => value is bool && ((bool)value) ? True : False;
24 |
25 | public virtual object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
26 | => value is T && EqualityComparer.Default.Equals((T)value, True);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Converters/BooleanToHiddenConverter.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace aframe
4 | {
5 | public class BooleanToHiddenConverter :
6 | BooleanConverter
7 | {
8 | public BooleanToHiddenConverter() :
9 | base(Visibility.Visible, Visibility.Hidden)
10 | {
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Converters/BooleanToIntConverter.cs:
--------------------------------------------------------------------------------
1 | namespace aframe
2 | {
3 | public class BooleanToIntConverter :
4 | BooleanConverter
5 | {
6 | public BooleanToIntConverter() :
7 | base(1, 0)
8 | {
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Converters/BooleanToNotVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace aframe
4 | {
5 | public class BooleanToNotVisibilityConverter :
6 | BooleanConverter
7 | {
8 | public BooleanToNotVisibilityConverter() :
9 | base(Visibility.Collapsed, Visibility.Visible)
10 | {
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Converters/ColorToBrushConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 | using System.Windows.Media;
5 |
6 | namespace aframe
7 | {
8 | public class ColorToBrushConverter :
9 | IValueConverter
10 | {
11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
12 | {
13 | if (value is Color color)
14 | {
15 | return new SolidColorBrush(color);
16 | }
17 |
18 | return null;
19 | }
20 |
21 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
22 | => value;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Converters/CompanyNameConverter.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 |
4 | namespace aframe
5 | {
6 | public static class CompanyNameConverter
7 | {
8 | #region 会社称号の定義テーブル
9 |
10 | private static readonly IReadOnlyList<(string Formal, string Short)> CompanySubtitles = new List<(string Formal, string Short)>()
11 | {
12 | // 株式会社
13 | ("株式会社", "(株)"),
14 | ("株式会社", "㈱"),
15 | ("株式会社", "(株"),
16 | ("株式会社", "株)"),
17 | ("株式会社", "(カ)"),
18 | ("株式会社", "(カ"),
19 | ("株式会社", "カ)"),
20 |
21 | // 有限会社
22 | ("有限会社", "(有)"),
23 | ("有限会社", "㈲"),
24 | ("有限会社", "(有"),
25 | ("有限会社", "有)"),
26 | ("有限会社", "(ユ)"),
27 | ("有限会社", "(ユ"),
28 | ("有限会社", "ユ)"),
29 |
30 | // 医療法人
31 | ("医療法人", "(医)"),
32 | ("医療法人", "(医"),
33 | ("医療法人", "医)"),
34 | ("医療法人", "(イ)"),
35 | ("医療法人", "(イ"),
36 | ("医療法人", "イ)"),
37 | ("医療法人社団", "(医)"),
38 | ("医療法人社団", "(医"),
39 | ("医療法人社団", "医)"),
40 | ("医療法人社団", "(イ)"),
41 | ("医療法人社団", "(イ"),
42 | ("医療法人社団", "イ)"),
43 | ("医療法人財団", "(医)"),
44 | ("医療法人財団", "(医"),
45 | ("医療法人財団", "医)"),
46 | ("医療法人財団", "(イ)"),
47 | ("医療法人財団", "(イ"),
48 | ("医療法人財団", "イ)"),
49 | ("社会医療法人", "(医)"),
50 | ("社会医療法人", "(医"),
51 | ("社会医療法人", "医)"),
52 | ("社会医療法人", "(イ)"),
53 | ("社会医療法人", "(イ"),
54 | ("社会医療法人", "イ)"),
55 |
56 | // 福祉系
57 | ("宗教法人", "(宗)"),
58 | ("宗教法人", "宗)"),
59 | ("宗教法人", "(宗"),
60 | ("宗教法人", "(シユウ)"),
61 | ("宗教法人", "シユウ)"),
62 | ("宗教法人", "(シユウ"),
63 | ("学校法人", "(学)"),
64 | ("学校法人", "学)"),
65 | ("学校法人", "(学"),
66 | ("学校法人", "(ガク)"),
67 | ("学校法人", "ガク)"),
68 | ("学校法人", "(ガク"),
69 | ("社会福祉法人", "(福)"),
70 | ("社会福祉法人", "福)"),
71 | ("社会福祉法人", "(福"),
72 | ("社会福祉法人", "(フク)"),
73 | ("社会福祉法人", "フク)"),
74 | ("社会福祉法人", "(フク"),
75 |
76 | // 士業系
77 | ("税理士法人", "(税)"),
78 | ("税理士法人", "税)"),
79 | ("税理士法人", "(税"),
80 | ("税理士法人", "(ゼイ)"),
81 | ("税理士法人", "ゼイ)"),
82 | ("税理士法人", "(ゼイ"),
83 | ("弁護士法人", "(弁)"),
84 | ("弁護士法人", "弁)"),
85 | ("弁護士法人", "(弁"),
86 | ("弁護士法人", "(ベン)"),
87 | ("弁護士法人", "ベン)"),
88 | ("弁護士法人", "(ベン"),
89 | ("行政書士法人", "(行)"),
90 | ("行政書士法人", "行)"),
91 | ("行政書士法人", "(行"),
92 | ("行政書士法人", "(ギヨ)"),
93 | ("行政書士法人", "ギヨ)"),
94 | ("行政書士法人", "(ギヨ"),
95 | ("司法書士法人", "(司)"),
96 | ("司法書士法人", "司)"),
97 | ("司法書士法人", "(司"),
98 | ("司法書士法人", "(シホウ)"),
99 | ("司法書士法人", "シホウ)"),
100 | ("司法書士法人", "(シホウ"),
101 | ("社会保険労務士法人", "(労)"),
102 | ("社会保険労務士法人", "労)"),
103 | ("社会保険労務士法人", "(労"),
104 | ("社会保険労務士法人", "(ロウム)"),
105 | ("社会保険労務士法人", "ロウム)"),
106 | ("社会保険労務士法人", "(ロウム"),
107 | };
108 |
109 | #endregion 会社称号の定義テーブル
110 |
111 | ///
112 | /// 会社名から称号を除去する
113 | ///
114 | ///
115 | ///
116 | public static string Omit(
117 | string companyName)
118 | {
119 | var result = companyName;
120 |
121 | // 一旦全角に変換する
122 | result = result.ToWide();
123 |
124 | foreach (var entry in CompanySubtitles)
125 | {
126 | result = result.Replace(entry.Formal, string.Empty);
127 | result = result.Replace(entry.Short.ToWide(), string.Empty);
128 | }
129 |
130 | result = result.Trim();
131 |
132 | return result;
133 | }
134 |
135 | ///
136 | /// 会社名の称号を正式表記にする
137 | ///
138 | ///
139 | ///
140 | public static string ToFormal(
141 | string companyName)
142 | {
143 | var result = companyName;
144 |
145 | // 一旦全角に変換する
146 | result = result.ToWide();
147 |
148 | foreach (var entry in CompanySubtitles)
149 | {
150 | result = result.Replace(entry.Short.ToWide(), entry.Formal);
151 | }
152 |
153 | result = result.Trim();
154 |
155 | return result;
156 | }
157 |
158 | ///
159 | /// 会社名の称号を省略表記にする
160 | ///
161 | ///
162 | ///
163 | public static string ToShort(
164 | string companyName)
165 | {
166 | var result = companyName;
167 |
168 | // 一旦正式表記に変換する
169 | result = ToFormal(result);
170 |
171 | var topSubtitles = CompanySubtitles
172 | .GroupBy(x => x.Formal)
173 | .Select(x => x.First());
174 |
175 | foreach (var entry in topSubtitles)
176 | {
177 | result = result.Replace(entry.Formal, entry.Short.ToNarrow());
178 | }
179 |
180 | result = result.Trim();
181 |
182 | return result;
183 | }
184 | }
185 | }
186 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Converters/CompanyNameOmitConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 |
5 | namespace aframe
6 | {
7 | ///
8 | /// 会社名の称号をカットするコンバーター
9 | ///
10 | ///
11 | /// 株式会社ほげ -> ほげ
12 | /// 有限会社ふー -> ふー
13 | /// (株)ほげ -> ほげ
14 | /// (有)ふー -> ふー
15 | ///
16 | public class CompanyNameOmitConverter :
17 | IValueConverter
18 | {
19 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
20 | {
21 | if (!(value is string text))
22 | {
23 | return value;
24 | }
25 |
26 | return CompanyNameConverter.Omit(text);
27 | }
28 |
29 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
30 | => value;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Converters/CompanyNameToShortConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 |
5 | namespace aframe
6 | {
7 | ///
8 | /// 会社名の称号を省略表記にするコンバーター
9 | ///
10 | ///
11 | /// 株式会社 -> (株)
12 | /// 有限会社 -> (有)
13 | ///
14 | public class CompanyNameToShortConverter :
15 | IValueConverter
16 | {
17 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
18 | {
19 | if (!(value is string text))
20 | {
21 | return value;
22 | }
23 |
24 | return CompanyNameConverter.ToShort(text);
25 | }
26 |
27 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
28 | => value;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Converters/DayOfWeekToBrushConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 | using System.Windows.Media;
5 |
6 | namespace aframe
7 | {
8 | public class DayOfWeekToBrushConverter :
9 | IValueConverter
10 | {
11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
12 | {
13 | if (!(value is DateTime date))
14 | {
15 | return null;
16 | }
17 |
18 | switch (date.DayOfWeek)
19 | {
20 | case DayOfWeek.Saturday:
21 | return Brushes.Blue;
22 |
23 | case DayOfWeek.Sunday:
24 | return Brushes.Red;
25 |
26 | default:
27 | return Brushes.Transparent;
28 | }
29 | }
30 |
31 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
32 | => value;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Converters/EnumBooleanConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows;
4 | using System.Windows.Data;
5 |
6 | namespace aframe
7 | {
8 | public class EnumBooleanConverter : IValueConverter
9 | {
10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
11 | {
12 | var parameterString = parameter as string;
13 | if (parameterString == null)
14 | {
15 | return DependencyProperty.UnsetValue;
16 | }
17 |
18 | if (Enum.IsDefined(value.GetType(), value) == false)
19 | {
20 | return DependencyProperty.UnsetValue;
21 | }
22 |
23 | var parameterValue = Enum.Parse(value.GetType(), parameterString);
24 |
25 | return parameterValue.Equals(value);
26 | }
27 |
28 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
29 | {
30 | var parameterString = parameter as string;
31 | if (parameterString == null)
32 | {
33 | return DependencyProperty.UnsetValue;
34 | }
35 |
36 | return Enum.Parse(targetType, parameterString);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Converters/EnumToDisplayNameConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 |
5 | namespace aframe
6 | {
7 | public class EnumToDisplayNameConverter :
8 | IValueConverter
9 | {
10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
11 | {
12 | if (!(value is Enum e))
13 | {
14 | return value;
15 | }
16 |
17 | return e.ToDisplayName();
18 | }
19 |
20 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
21 | => value;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Converters/FontFamilyToNameConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Linq;
4 | using System.Threading;
5 | using System.Windows.Data;
6 | using System.Windows.Media;
7 |
8 | namespace aframe
9 | {
10 | public class FontFamilyToNameConverter : IValueConverter
11 | {
12 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
13 | {
14 | var v = value as FontFamily;
15 | var cul = Thread.CurrentThread.CurrentCulture;
16 | return v.FamilyNames.FirstOrDefault(o =>
17 | o.Key.IetfLanguageTag.ToLower() == cul.IetfLanguageTag.ToLower()).Value ?? v.Source;
18 | }
19 |
20 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
21 | {
22 | return null;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Converters/FontSizeToLargeConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 |
5 | namespace aframe
6 | {
7 | public class FontSizeToLargeConverter :
8 | IValueConverter
9 | {
10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
11 | {
12 | if (!(value is double size))
13 | {
14 | return value;
15 | }
16 |
17 | var rate = Constants.FontSizeScalingRate;
18 | if (parameter != null &&
19 | parameter is double rateParam)
20 | {
21 | rate = rateParam;
22 | }
23 |
24 | return size + (size * rate);
25 | }
26 |
27 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
28 | {
29 | if (!(value is double size))
30 | {
31 | return value;
32 | }
33 |
34 | var rate = Constants.FontSizeScalingRate;
35 | if (parameter != null &&
36 | parameter is double rateParam)
37 | {
38 | rate = rateParam;
39 | }
40 |
41 | return size - (size * rate);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Converters/FontSizeToSmallConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 |
5 | namespace aframe
6 | {
7 | public class FontSizeToSmallConverter :
8 | IValueConverter
9 | {
10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
11 | {
12 | if (!(value is double size))
13 | {
14 | return value;
15 | }
16 |
17 | var rate = Constants.FontSizeScalingRate;
18 | if (parameter != null &&
19 | parameter is double rateParam)
20 | {
21 | rate = rateParam;
22 | }
23 |
24 | return size - (size * rate);
25 | }
26 |
27 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
28 | {
29 | if (!(value is double size))
30 | {
31 | return value;
32 | }
33 |
34 | var rate = Constants.FontSizeScalingRate;
35 | if (parameter != null &&
36 | parameter is double rateParam)
37 | {
38 | rate = rateParam;
39 | }
40 |
41 | return size + (size * rate);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Converters/InverseBooleanConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 |
5 | namespace aframe
6 | {
7 | [ValueConversion(typeof(bool), typeof(bool))]
8 | public class InverseBooleanConverter : IValueConverter
9 | {
10 | #region IValueConverter Members
11 |
12 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
13 | {
14 | if (targetType != typeof(bool))
15 | throw new InvalidOperationException("The target must be a boolean");
16 |
17 | return !(bool)value;
18 | }
19 |
20 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
21 | {
22 | throw new NotSupportedException();
23 | }
24 |
25 | #endregion IValueConverter Members
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Converters/StringToDoubleConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 |
5 | namespace aframe
6 | {
7 | public class StringToDoubleConverter : IValueConverter
8 | {
9 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
10 | {
11 | double d;
12 | double.TryParse((string)value, out d);
13 | return d;
14 | }
15 |
16 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
17 | {
18 | if (parameter == null)
19 | {
20 | return ((double)value).ToString();
21 | }
22 | else
23 | {
24 | return ((double)value).ToString((string)parameter);
25 | }
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Crypter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Security.Cryptography;
3 | using System.Text;
4 |
5 | namespace aframe
6 | {
7 | public class Crypter
8 | {
9 | ///
10 | /// 初期Salt
11 | ///
12 | private static readonly string DefaultSalt = "L+DCZF4pmD8SVAv.$m5sYv/3$,x$wXAW";
13 |
14 | ///
15 | /// 初期パスワード
16 | ///
17 | private static readonly string DefaultPassword = "ym%#EPcY5g(WN4CRTE|mv5c/rvqVXA7m";
18 |
19 | ///
20 | /// 文字列を暗号化する
21 | ///
22 | /// 暗号化する文字列
23 | /// 暗号化に使用するパスワード
24 | /// 暗号化された文字列
25 | public static string EncryptString(
26 | string sourceString,
27 | string password = null)
28 | {
29 | if (string.IsNullOrEmpty(password))
30 | {
31 | password = DefaultPassword;
32 | }
33 |
34 | var encryptedString = string.Empty;
35 |
36 | using (var rijndael = new RijndaelManaged())
37 | {
38 | byte[] key, iv;
39 | Crypter.GenerateKeyFromPassword(password, rijndael.KeySize, out key, rijndael.BlockSize, out iv);
40 | rijndael.Key = key;
41 | rijndael.IV = iv;
42 |
43 | var strBytes = Encoding.UTF8.GetBytes(sourceString);
44 |
45 | using (var encryptor = rijndael.CreateEncryptor())
46 | {
47 | var encBytes = encryptor.TransformFinalBlock(strBytes, 0, strBytes.Length);
48 | encryptedString = Convert.ToBase64String(encBytes);
49 | }
50 | }
51 |
52 | return encryptedString;
53 | }
54 |
55 | ///
56 | /// 暗号化された文字列を復号化する
57 | ///
58 | /// 暗号化された文字列
59 | /// 暗号化に使用したパスワード
60 | /// 復号化された文字列
61 | public static string DecryptString(
62 | string sourceString,
63 | string password = null)
64 | {
65 | if (string.IsNullOrEmpty(password))
66 | {
67 | password = DefaultPassword;
68 | }
69 |
70 | var decryptedString = string.Empty;
71 |
72 | using (var rijndael = new RijndaelManaged())
73 | {
74 | byte[] key, iv;
75 | Crypter.GenerateKeyFromPassword(password, rijndael.KeySize, out key, rijndael.BlockSize, out iv);
76 | rijndael.Key = key;
77 | rijndael.IV = iv;
78 |
79 | var strBytes = Convert.FromBase64String(sourceString);
80 |
81 | using (var decryptor = rijndael.CreateDecryptor())
82 | {
83 | var decBytes = decryptor.TransformFinalBlock(strBytes, 0, strBytes.Length);
84 | decryptedString = Encoding.UTF8.GetString(decBytes);
85 | }
86 | }
87 |
88 | return decryptedString;
89 | }
90 |
91 | ///
92 | /// パスワードから共有キーと初期化ベクタを生成する
93 | ///
94 | /// 基になるパスワード
95 | /// 共有キーのサイズ(ビット)
96 | /// 作成された共有キー
97 | /// 初期化ベクタのサイズ(ビット)
98 | /// 作成された初期化ベクタ
99 | private static void GenerateKeyFromPassword(
100 | string password,
101 | int keySize,
102 | out byte[] key,
103 | int blockSize,
104 | out byte[] iv)
105 | {
106 | // パスワードから共有キーと初期化ベクタを作成する
107 | // saltを決める
108 | var salt = Encoding.UTF8.GetBytes(DefaultSalt);
109 |
110 | // Rfc2898DeriveBytesオブジェクトを作成する
111 | var deriveBytes = new Rfc2898DeriveBytes(password, salt);
112 |
113 | // 反復処理回数を指定する
114 | deriveBytes.IterationCount = 1000;
115 |
116 | // 共有キーと初期化ベクタを生成する
117 | key = deriveBytes.GetBytes(keySize / 8);
118 | iv = deriveBytes.GetBytes(blockSize / 8);
119 | }
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Dialogs/ColorDialogResult.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Runtime.Serialization;
3 | using System.Runtime.Serialization.Json;
4 | using System.Text;
5 | using System.Windows.Media;
6 | using FFXIV.Framework.Extensions;
7 |
8 | namespace FFXIV.Framework.Dialog
9 | {
10 | [DataContract]
11 | public class ColorDialogResult
12 | {
13 | public const string SymbolKeyword = nameof(ColorDialogResult);
14 |
15 | [DataMember(Order = 1)]
16 | public string Symbol { get; set; } = SymbolKeyword;
17 |
18 | [DataMember(Order = 2)]
19 | public bool Result { get; set; }
20 |
21 | [DataMember(Order = 3)]
22 | public Color Color { get; set; }
23 |
24 | [DataMember(Order = 4)]
25 | public bool IgnoreAlpha { get; set; }
26 |
27 | public System.Drawing.Color LegacyColor => this.Color.ToLegacy();
28 |
29 | public static ColorDialogResult FromString(
30 | string json)
31 | {
32 | var obj = default(ColorDialogResult);
33 |
34 | var serializer = new DataContractJsonSerializer(typeof(ColorDialogResult));
35 | var data = Encoding.UTF8.GetBytes(json);
36 | using (var ms = new MemoryStream(data))
37 | {
38 | obj = (ColorDialogResult)serializer.ReadObject(ms);
39 | }
40 |
41 | return obj;
42 | }
43 |
44 | public override string ToString()
45 | {
46 | var json = string.Empty;
47 |
48 | var serializer = new DataContractJsonSerializer(typeof(ColorDialogResult));
49 | using (var ms = new MemoryStream())
50 | {
51 | serializer.WriteObject(ms, this);
52 | json = Encoding.UTF8.GetString(ms.ToArray());
53 | }
54 |
55 | return json;
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Dialogs/ColorDialogWrapper.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Media;
2 | using FFXIV.Framework.Dialog.Views;
3 | using FFXIV.Framework.Extensions;
4 |
5 | namespace FFXIV.Framework.Dialog
6 | {
7 | public class ColorDialogWrapper
8 | {
9 | public static ColorDialogResult ShowDialog(
10 | System.Drawing.Color? color = null,
11 | bool ignoreAlpha = false)
12 | {
13 | var wpfColor = color?.ToWPF();
14 | return ColorDialogWrapper.ShowDialog(wpfColor, ignoreAlpha);
15 | }
16 |
17 | public static ColorDialogResult ShowDialog(
18 | Color? color = null,
19 | bool ignoreAlpha = false)
20 | {
21 | var result = new ColorDialogResult()
22 | {
23 | Color = color.HasValue ? color.Value : Colors.Transparent,
24 | IgnoreAlpha = ignoreAlpha,
25 | };
26 |
27 | ColorDialog.Color = result.Color;
28 | ColorDialog.IgnoreAlpha = result.IgnoreAlpha;
29 | if (ColorDialog.ShowDialog() ?? false)
30 | {
31 | result.Color = ColorDialog.Color;
32 | result.Result = true;
33 | }
34 |
35 | return result;
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Dialogs/FontDialogResult.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Runtime.Serialization;
3 | using System.Runtime.Serialization.Json;
4 | using System.Text;
5 | using FFXIV.Framework.Common;
6 |
7 | namespace FFXIV.Framework.Dialog
8 | {
9 | [DataContract]
10 | public class FontDialogResult
11 | {
12 | public const string SymbolKeyword = nameof(FontDialogResult);
13 |
14 | [DataMember(Order = 1)]
15 | public string Symbol { get; set; } = SymbolKeyword;
16 |
17 | [DataMember(Order = 2)]
18 | public bool Result { get; set; }
19 |
20 | [DataMember(Order = 3)]
21 | public FontInfo Font { get; set; }
22 |
23 | public static FontDialogResult FromString(
24 | string json)
25 | {
26 | var obj = default(FontDialogResult);
27 |
28 | var serializer = new DataContractJsonSerializer(typeof(FontDialogResult));
29 | var data = Encoding.UTF8.GetBytes(json);
30 | using (var ms = new MemoryStream(data))
31 | {
32 | obj = (FontDialogResult)serializer.ReadObject(ms);
33 | }
34 |
35 | return obj;
36 | }
37 |
38 | public override string ToString()
39 | {
40 | var json = string.Empty;
41 |
42 | var serializer = new DataContractJsonSerializer(typeof(FontDialogResult));
43 | using (var ms = new MemoryStream())
44 | {
45 | serializer.WriteObject(ms, this);
46 | json = Encoding.UTF8.GetString(ms.ToArray());
47 | }
48 |
49 | return json;
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Dialogs/FontDialogWrapper.cs:
--------------------------------------------------------------------------------
1 | using FFXIV.Framework.Common;
2 | using FFXIV.Framework.Dialog.Views;
3 |
4 | namespace FFXIV.Framework.Dialog
5 | {
6 | public class FontDialogWrapper
7 | {
8 | public static FontDialogResult ShowDialog(
9 | FontInfo font = null)
10 | {
11 | var result = new FontDialogResult()
12 | {
13 | Font = font,
14 | };
15 |
16 | FontDialog.Font = result.Font;
17 | if (FontDialog.ShowDialog() ?? false)
18 | {
19 | result.Font = FontDialog.Font;
20 | result.Result = true;
21 | }
22 |
23 | return result;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Dialogs/Views/ColorDialog.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Interop;
3 | using System.Windows.Media;
4 |
5 | namespace aframe
6 | {
7 | public static class ColorDialog
8 | {
9 | private static ColorDialogContent CreateContent() => new ColorDialogContent()
10 | {
11 | Color = ColorDialog.Color,
12 | IgnoreAlpha = ColorDialog.IgnoreAlpha,
13 | };
14 |
15 | private static Dialog CreateDialog(ColorDialogContent content) => new Dialog()
16 | {
17 | Title = "Color",
18 | Content = content,
19 | MaxWidth = 1390,
20 | MaxHeight = 700,
21 | };
22 |
23 | public static Color Color { get; set; } = Colors.White;
24 |
25 | public static bool IgnoreAlpha { get; set; }
26 |
27 | public static bool? ShowDialog()
28 | {
29 | var content = CreateContent();
30 | var dialog = CreateDialog(content);
31 |
32 | dialog.WindowStartupLocation = WindowStartupLocation.CenterScreen;
33 |
34 | dialog.OkButton.Click += (x, y) => content.Apply();
35 |
36 | var result = dialog.ShowDialog();
37 | if (result.Value)
38 | {
39 | Color = content.Color;
40 | }
41 |
42 | return result;
43 | }
44 |
45 | public static bool? ShowDialog(
46 | Window owner)
47 | {
48 | var content = CreateContent();
49 | var dialog = CreateDialog(content);
50 |
51 | dialog.WindowStartupLocation = owner != null ?
52 | WindowStartupLocation.CenterOwner :
53 | WindowStartupLocation.CenterScreen;
54 |
55 | if (owner != null)
56 | {
57 | dialog.Owner = owner;
58 | }
59 |
60 | dialog.OkButton.Click += (x, y) => content.Apply();
61 |
62 | var result = dialog.ShowDialog();
63 | if (result.Value)
64 | {
65 | Color = content.Color;
66 | }
67 |
68 | return result;
69 | }
70 |
71 | public static bool? ShowDialog(
72 | System.Windows.Forms.Form owner)
73 | {
74 | var content = CreateContent();
75 | var dialog = CreateDialog(content);
76 |
77 | dialog.WindowStartupLocation = owner != null ?
78 | WindowStartupLocation.CenterOwner :
79 | WindowStartupLocation.CenterScreen;
80 |
81 | if (owner != null)
82 | {
83 | var helper = new WindowInteropHelper(dialog);
84 | helper.Owner = owner.Handle;
85 | }
86 |
87 | dialog.OkButton.Click += (x, y) => content.Apply();
88 |
89 | var result = dialog.ShowDialog();
90 | if (result.Value)
91 | {
92 | Color = content.Color;
93 | }
94 |
95 | return result;
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Dialogs/Views/ColorDialogContent.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using System.Threading.Tasks;
3 | using System.Windows;
4 | using System.Windows.Controls;
5 | using System.Windows.Media;
6 |
7 | namespace aframe
8 | {
9 | public partial class ColorDialogContent : UserControl
10 | {
11 | public ColorDialogContent()
12 | {
13 | this.InitializeComponent();
14 |
15 | this.Color = Colors.White;
16 |
17 | this.Loaded += this.ColorDialogContent_Loaded;
18 | this.PredefinedColorsListBox.SelectionChanged += this.PredefinedColorsListBox_SelectionChanged;
19 | this.RTextBox.ValueChanged += (s, e) => this.ToHex();
20 | this.GTextBox.ValueChanged += (s, e) => this.ToHex();
21 | this.BTextBox.ValueChanged += (s, e) => this.ToHex();
22 | this.ATextBox.ValueChanged += (s, e) => this.ToHex();
23 | this.HexTextBox.LostFocus += (s, e) =>
24 | {
25 | var color = Colors.White;
26 |
27 | try
28 | {
29 | color = (Color)ColorConverter.ConvertFromString(this.HexTextBox.Text);
30 | }
31 | catch
32 | {
33 | }
34 |
35 | this.RTextBox.Value = color.R;
36 | this.GTextBox.Value = color.G;
37 | this.BTextBox.Value = color.B;
38 | this.ATextBox.Value = !this.IgnoreAlpha ? color.A : 255;
39 |
40 | this.ToPreview();
41 | };
42 | }
43 |
44 | public Color Color { get; set; }
45 |
46 | private bool ignoreAlpha;
47 |
48 | public bool IgnoreAlpha
49 | {
50 | get => this.ignoreAlpha;
51 | set
52 | {
53 | if (this.ignoreAlpha != value)
54 | {
55 | this.ignoreAlpha = value;
56 |
57 | if (this.ignoreAlpha)
58 | {
59 | this.ATextBox.Value = 255;
60 | this.APanel.Visibility = Visibility.Collapsed;
61 | }
62 | else
63 | {
64 | this.APanel.Visibility = Visibility.Visible;
65 | }
66 | }
67 | }
68 | }
69 |
70 | public void Apply()
71 | {
72 | var color = Colors.White;
73 |
74 | try
75 | {
76 | color = (Color)ColorConverter.ConvertFromString(this.HexTextBox.Text);
77 | }
78 | catch
79 | {
80 | }
81 |
82 | this.Color = color;
83 | }
84 |
85 | private async void ColorDialogContent_Loaded(object sender, RoutedEventArgs e)
86 | {
87 | var item = await Task.Run(() =>
88 | this.PredefinedColorsListBox.Items.Cast()
89 | .FirstOrDefault(x => x.Color == this.Color));
90 |
91 | if (item != null)
92 | {
93 | this.PredefinedColorsListBox.SelectedItem = item;
94 | (this.PredefinedColorsListBox.ItemContainerGenerator.ContainerFromItem(item) as ListBoxItem)?.Focus();
95 | }
96 |
97 | if (this.PredefinedColorsListBox.SelectedItem == null &&
98 | this.Color != null)
99 | {
100 | this.RTextBox.Value = this.Color.R;
101 | this.GTextBox.Value = this.Color.G;
102 | this.BTextBox.Value = this.Color.B;
103 | this.ATextBox.Value = !this.IgnoreAlpha ? this.Color.A : 255;
104 | }
105 | }
106 |
107 | private void PredefinedColorsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
108 | {
109 | if (this.PredefinedColorsListBox.SelectedItem != null)
110 | {
111 | var color = ((PredefinedColor)this.PredefinedColorsListBox.SelectedItem).Color;
112 |
113 | this.RTextBox.Value = color.R;
114 | this.GTextBox.Value = color.G;
115 | this.BTextBox.Value = color.B;
116 | this.ATextBox.Value = !this.IgnoreAlpha ? color.A : 255;
117 | }
118 | }
119 |
120 | private void ToHex()
121 | {
122 | var color = Color.FromArgb(
123 | (byte)(this.ATextBox.Value ?? 0),
124 | (byte)(this.RTextBox.Value ?? 0),
125 | (byte)(this.GTextBox.Value ?? 0),
126 | (byte)(this.BTextBox.Value ?? 0));
127 |
128 | this.HexTextBox.Text = color.ToString();
129 |
130 | this.ToPreview();
131 | }
132 |
133 | private void ToPreview()
134 | {
135 | var color = Colors.White;
136 |
137 | try
138 | {
139 | color = (Color)ColorConverter.ConvertFromString(this.HexTextBox.Text);
140 | }
141 | catch
142 | {
143 | }
144 |
145 | this.PreviewRectangle.Fill = new SolidColorBrush(color);
146 | }
147 | }
148 | }
149 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Dialogs/Views/ColorDialogViewModel.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.ComponentModel;
3 | using System.Linq;
4 | using System.Runtime.CompilerServices;
5 | using System.Threading.Tasks;
6 | using System.Windows.Media;
7 |
8 | namespace aframe
9 | {
10 | public class ColorDialogViewModel : INotifyPropertyChanged
11 | {
12 | private static PredefinedColor[] predefinedColors;
13 |
14 | public PredefinedColor[] PredefinedColors
15 | {
16 | get { return predefinedColors ?? (predefinedColors = this.EnumlatePredefinedColors()); }
17 | set
18 | {
19 | predefinedColors = value;
20 | this.RaisePropertyChanged();
21 | }
22 | }
23 |
24 | private PredefinedColor[] EnumlatePredefinedColors()
25 | {
26 | var list = new List();
27 |
28 | var t1 = Task.Run(() =>
29 | {
30 | var solidColors = new List();
31 | foreach (var color in typeof(Colors).GetProperties())
32 | {
33 | try
34 | {
35 | solidColors.Add(new PredefinedColor()
36 | {
37 | Name = color.Name,
38 | Color = (Color)ColorConverter.ConvertFromString(color.Name)
39 | });
40 | }
41 | catch
42 | {
43 | }
44 | }
45 |
46 | return solidColors.OrderBy(x => x.Color.ToString());
47 | });
48 |
49 | var t2 = Task.Run(() =>
50 | {
51 | var waColors = new List();
52 | foreach (var color in typeof(WaColors).GetProperties())
53 | {
54 | try
55 | {
56 | waColors.Add(new PredefinedColor()
57 | {
58 | Name = color.Name,
59 | Color = (Color)color.GetValue(null, null),
60 | });
61 | }
62 | catch
63 | {
64 | }
65 | }
66 |
67 | return waColors.OrderBy(x => x.Color.ToString());
68 | });
69 |
70 | list.AddRange(t1.Result);
71 | list.AddRange(t2.Result);
72 |
73 | return list.ToArray();
74 | }
75 |
76 | #region Implementation of INotifyPropertyChanged
77 |
78 | public event PropertyChangedEventHandler PropertyChanged;
79 |
80 | private void RaisePropertyChanged([CallerMemberName] string caller = "")
81 | {
82 | if (this.PropertyChanged != null)
83 | {
84 | this.PropertyChanged(this, new PropertyChangedEventArgs(caller));
85 | }
86 | }
87 |
88 | #endregion Implementation of INotifyPropertyChanged
89 | }
90 |
91 | public class PredefinedColor
92 | {
93 | public SolidColorBrush Brush => new SolidColorBrush(this.Color);
94 | public Color Color { get; set; }
95 | public string Name { get; set; }
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Dialogs/Views/Dialog.xaml:
--------------------------------------------------------------------------------
1 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
33 |
34 |
35 |
36 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Dialogs/Views/Dialog.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Controls;
3 | using System.Windows.Forms.Integration;
4 | using MahApps.Metro.Controls;
5 |
6 | namespace aframe
7 | {
8 | ///
9 | /// Dialog.xaml の相互作用ロジック
10 | ///
11 | public partial class Dialog : MetroWindow
12 | {
13 | public Dialog()
14 | {
15 | ElementHost.EnableModelessKeyboardInterop(this);
16 | this.InitializeComponent();
17 | this.Loaded += this.Dialog_Loaded;
18 | }
19 |
20 | public Button OkButton => this.InnerOkButton;
21 | public Button CancelButton => this.InnerCancelButton;
22 |
23 | public new UIElement Content
24 | {
25 | get => this.ContentPanel.Children.Count > 0 ? this.ContentPanel.Children[0] : null;
26 | set
27 | {
28 | this.ContentPanel.Children.Clear();
29 | this.ContentPanel.Children.Add(value);
30 | }
31 | }
32 |
33 | private void Dialog_Loaded(object sender, RoutedEventArgs e)
34 | {
35 | this.InnerOkButton.Click += (x, y) => this.DialogResult = true;
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Dialogs/Views/FontDialog.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Interop;
3 |
4 | namespace aframe
5 | {
6 | public static class FontDialog
7 | {
8 | private static FontDialogContent CreateContent() => new FontDialogContent()
9 | {
10 | FontInfo = FontDialog.Font,
11 | };
12 |
13 | private static Dialog CreateDialog(FontDialogContent content) => new Dialog()
14 | {
15 | Title = "Font",
16 | Content = content,
17 | MaxWidth = 1100,
18 | MaxHeight = 620,
19 | };
20 |
21 | public static FontInfo Font { get; set; }
22 |
23 | public static bool? ShowDialog()
24 | {
25 | var content = CreateContent();
26 | var dialog = CreateDialog(content);
27 |
28 | dialog.WindowStartupLocation = WindowStartupLocation.CenterScreen;
29 |
30 | dialog.OkButton.Click += content.OKBUtton_Click;
31 |
32 | var result = dialog.ShowDialog();
33 | if (result.Value)
34 | {
35 | Font = content.FontInfo;
36 | }
37 |
38 | return result;
39 | }
40 |
41 | public static bool? ShowDialog(
42 | Window owner)
43 | {
44 | var content = CreateContent();
45 | var dialog = CreateDialog(content);
46 |
47 | dialog.WindowStartupLocation = owner != null ?
48 | WindowStartupLocation.CenterOwner :
49 | WindowStartupLocation.CenterScreen;
50 |
51 | if (owner != null)
52 | {
53 | dialog.Owner = owner;
54 | }
55 |
56 | dialog.OkButton.Click += content.OKBUtton_Click;
57 |
58 | var result = dialog.ShowDialog();
59 | if (result.Value)
60 | {
61 | Font = content.FontInfo;
62 | }
63 |
64 | return result;
65 | }
66 |
67 | public static bool? ShowDialog(
68 | System.Windows.Forms.Form owner)
69 | {
70 | var content = CreateContent();
71 | var dialog = CreateDialog(content);
72 |
73 | dialog.WindowStartupLocation = owner != null ?
74 | WindowStartupLocation.CenterOwner :
75 | WindowStartupLocation.CenterScreen;
76 |
77 | if (owner != null)
78 | {
79 | var helper = new WindowInteropHelper(dialog);
80 | helper.Owner = owner.Handle;
81 | }
82 |
83 | dialog.OkButton.Click += content.OKBUtton_Click;
84 |
85 | var result = dialog.ShowDialog();
86 | if (result.Value)
87 | {
88 | Font = content.FontInfo;
89 | }
90 |
91 | return result;
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Dialogs/Views/FontDialogContent.xaml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
88 |
89 |
90 |
91 |
96 |
97 |
98 |
99 |
100 |
114 |
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Dialogs/Views/FontDialogContent.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 | using System.Windows.Media;
5 |
6 | namespace aframe
7 | {
8 | public partial class FontDialogContent : UserControl
9 | {
10 | private FontInfo fontInfo = (FontInfo)FontInfo.DefaultFont.Clone();
11 |
12 | public FontDialogContent()
13 | {
14 | this.InitializeComponent();
15 |
16 | this.Loaded += (s, e) =>
17 | {
18 | this.ShowFontInfo();
19 |
20 | // リストボックスにフォーカスを設定する
21 | ListBox box;
22 |
23 | box = this.FontStyleListBox;
24 | if (box.SelectedItem != null)
25 | {
26 | var item =
27 | box.ItemContainerGenerator.ContainerFromItem(box.SelectedItem)
28 | as ListBoxItem;
29 |
30 | if (item != null)
31 | {
32 | item.Focus();
33 | }
34 | }
35 |
36 | box = this.FontFamilyListBox;
37 | if (box.SelectedItem != null)
38 | {
39 | var item =
40 | box.ItemContainerGenerator.ContainerFromItem(box.SelectedItem)
41 | as ListBoxItem;
42 |
43 | if (item != null)
44 | {
45 | item.Focus();
46 | }
47 | }
48 | };
49 |
50 | this.FontFamilyListBox.SelectionChanged += this.FontFamilyListBox_SelectionChanged;
51 | }
52 |
53 | public FontInfo FontInfo
54 | {
55 | get
56 | {
57 | return this.fontInfo;
58 | }
59 | set
60 | {
61 | this.fontInfo = value;
62 | this.ShowFontInfo();
63 | }
64 | }
65 |
66 | internal void OKBUtton_Click(object sender, RoutedEventArgs e)
67 | {
68 | this.fontInfo = new FontInfo(
69 | this.PreviewTextBlock.FontFamily,
70 | this.PreviewTextBlock.FontSize,
71 | this.PreviewTextBlock.FontStyle,
72 | this.PreviewTextBlock.FontWeight,
73 | this.PreviewTextBlock.FontStretch);
74 | }
75 |
76 | private void FontFamilyListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
77 | {
78 | this.FontStyleListBox.SelectedIndex = 0;
79 | }
80 |
81 | private void ShowFontInfo()
82 | {
83 | if (this.fontInfo == null)
84 | {
85 | return;
86 | }
87 |
88 | this.FontSizeTextBox.Value = this.fontInfo.Size;
89 |
90 | int i = 0;
91 | foreach (FontFamily item in this.FontFamilyListBox.Items)
92 | {
93 | if (this.fontInfo.FontFamily != null)
94 | {
95 | if (item.Source == this.fontInfo.FontFamily.Source ||
96 | item.FamilyNames.Any(x => x.Value == this.fontInfo.FontFamily.Source))
97 | {
98 | break;
99 | }
100 | }
101 |
102 | i++;
103 | }
104 |
105 | if (i < this.FontFamilyListBox.Items.Count)
106 | {
107 | this.FontFamilyListBox.SelectedIndex = i;
108 | this.FontFamilyListBox.ScrollIntoView(this.FontFamilyListBox.Items[i]);
109 | }
110 |
111 | this.FontStyleListBox.SelectedItem = this.fontInfo.Typeface;
112 | }
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Extensions/AssemblyExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Reflection;
4 | using System.Runtime.InteropServices;
5 | using aframe.Updater;
6 |
7 | namespace aframe
8 | {
9 | public static class AssemblyExtensions
10 | {
11 | public static string GetLocationDirectory(
12 | this Assembly asm)
13 | => Path.GetDirectoryName(asm.Location);
14 |
15 | public static string GetTitle(
16 | this Assembly asm)
17 | {
18 | var att = asm.GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
19 | return att.Length == 0 ? string.Empty : ((AssemblyTitleAttribute)att[0]).Title;
20 | }
21 |
22 | public static string GetProduct(
23 | this Assembly asm)
24 | {
25 | var att = asm.GetCustomAttributes(typeof(AssemblyProductAttribute), false);
26 | return att.Length == 0 ? string.Empty : ((AssemblyProductAttribute)att[0]).Product;
27 | }
28 |
29 | public static string GetDescription(
30 | this Assembly asm)
31 | {
32 | var att = asm.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
33 | return att.Length == 0 ? string.Empty : ((AssemblyDescriptionAttribute)att[0]).Description;
34 | }
35 |
36 | public static string GetCopyright(
37 | this Assembly asm)
38 |
39 | {
40 | var att = asm.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
41 | return att.Length == 0 ? string.Empty : ((AssemblyCopyrightAttribute)att[0]).Copyright;
42 | }
43 |
44 | public static string GetConfiguration(
45 | this Assembly asm)
46 |
47 | {
48 | var att = asm.GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false);
49 | return att.Length == 0 ? string.Empty : ((AssemblyConfigurationAttribute)att[0]).Configuration;
50 | }
51 |
52 | public static ReleaseChannels GetReleaseChannels(
53 | this Assembly asm)
54 | {
55 | var result = ReleaseChannels.Stable;
56 | var config = asm.GetConfiguration();
57 | Enum.TryParse(config, out result);
58 | return result;
59 | }
60 |
61 | public static Version GetVersion(
62 | this Assembly asm)
63 | => asm.GetName().Version;
64 |
65 | public static string Guid(
66 | this Assembly asm)
67 | {
68 | var att = asm.GetCustomAttributes(typeof(GuidAttribute), false);
69 | return att.Length == 0 ? string.Empty : ((GuidAttribute)att[0]).Value;
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Extensions/DateTimeExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace aframe
4 | {
5 | public static class DateTimeExtensions
6 | {
7 | public static int ToInt(
8 | this DateTime date) => int.Parse(date.ToString("yyyyMMdd"));
9 |
10 | public static decimal ToDecimal(
11 | this DateTime date) => decimal.Parse(date.ToString("yyyyMMdd"));
12 |
13 | public static DateTime GetFirstDayOfMonth(
14 | this DateTime date) => new DateTime(date.Year, date.Month, 1);
15 |
16 | public static DateTime GetEndDayOfMonth(
17 | this DateTime date) => new DateTime(date.Year, date.Month, DateTime.DaysInMonth(date.Year, date.Month));
18 |
19 | public static DateTime GetDayOfSameMonth(
20 | this DateTime date,
21 | int day)
22 | {
23 | if (day > DateTime.DaysInMonth(date.Year, date.Month))
24 | {
25 | day = DateTime.DaysInMonth(date.Year, date.Month);
26 | }
27 |
28 | if (day < 1)
29 | {
30 | day = 1;
31 | }
32 |
33 | return new DateTime(date.Year, date.Month, day);
34 | }
35 |
36 | public static DateTime GetDateOnly(
37 | this DateTime date) => new DateTime(date.Year, date.Month, date.Day);
38 |
39 | public static DateTime GetDbMinValue(
40 | this DateTime date) => DateTimeConverter.DbMinValue;
41 |
42 | public static DateTime SetDbMinValue(
43 | this DateTime date) => date = DateTimeConverter.DbMinValue;
44 | }
45 |
46 | public static class DateTimeConverter
47 | {
48 | public static readonly DateTime DbMinValue = DateTime.Parse("1800-1-1");
49 |
50 | public static DateTime FromInt(
51 | int dateTime) => DateTime.Parse(dateTime.ToString("0000/00/00"));
52 |
53 | public static DateTime FromInt(
54 | decimal dateTime) => DateTime.Parse(dateTime.ToString("0000/00/00"));
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Extensions/DependencyObjectExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using System.Windows.Media;
4 |
5 | namespace aframe
6 | {
7 | public static class DependencyObjectExtensions
8 | {
9 | ///
10 | /// 子オブジェクトに対してデリゲートを実行する
11 | ///
12 | /// this : DependencyObject
13 | /// デリゲート : Action
14 | public static void Walk(
15 | this DependencyObject obj,
16 | Action action)
17 | {
18 | if (action == null)
19 | {
20 | throw new ArgumentNullException();
21 | }
22 |
23 | WalkCore(obj, action);
24 | }
25 |
26 | ///
27 | /// WalkInChildrenメソッドの本体
28 | ///
29 | /// DependencyObject
30 | /// Action
31 | private static void WalkCore(
32 | DependencyObject obj,
33 | Action action)
34 | {
35 | var count = VisualTreeHelper.GetChildrenCount(obj);
36 | for (int i = 0; i < count; i++)
37 | {
38 | var child = VisualTreeHelper.GetChild(obj, i);
39 | if (child is DependencyObject)
40 | {
41 | action(child as DependencyObject);
42 | WalkCore(child as DependencyObject, action);
43 | }
44 | }
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Extensions/EnumExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel.DataAnnotations;
4 | using System.Linq;
5 |
6 | namespace aframe
7 | {
8 | public static class EnumExtensions
9 | {
10 | public static string ToDisplayName(
11 | this T e) where T : Enum
12 | {
13 | var name = e.ToString();
14 |
15 | var fi = e.GetType().GetField(e.ToString());
16 | var attrs = fi.GetCustomAttributes(
17 | typeof(DisplayAttribute),
18 | false) as DisplayAttribute[];
19 |
20 | if (attrs != null &&
21 | attrs.Length > 0)
22 | {
23 | name = attrs[0].Name;
24 | }
25 |
26 | return name;
27 | }
28 |
29 | public static string ToName(
30 | this T e) where T : Enum
31 | => Enum.GetName(typeof(T), e);
32 |
33 | public static int ToInt(
34 | this T e) where T : Enum
35 | => Convert.ToInt32(e);
36 | }
37 |
38 | public static class EnumConverter
39 | {
40 | public static T FromString(
41 | string text) where T : Enum
42 | => (T)Enum.Parse(typeof(T), text, true);
43 |
44 | public static T FromInt(
45 | int value) where T : Enum
46 | => (T)Enum.ToObject(typeof(T), value);
47 |
48 | public static IEnumerable ToEnumerable(
49 | params T[] ignores) where T : Enum
50 | {
51 | var values = default(IEnumerable);
52 | values = (IEnumerable)Enum.GetValues(typeof(T));
53 |
54 | if (ignores != null &&
55 | ignores.Length > 0)
56 | {
57 | values = values.Where(x => !ignores.Contains(x));
58 | }
59 |
60 | return values;
61 | }
62 |
63 | public static IEnumerable> ToEnumerableContainer(
64 | params T[] ignores) where T : Enum
65 | {
66 | var values = default(IEnumerable);
67 | values = (IEnumerable)Enum.GetValues(typeof(T));
68 |
69 | if (ignores != null &&
70 | ignores.Length > 0)
71 | {
72 | values = values.Where(x => !ignores.Contains(x));
73 | }
74 |
75 | return values.Select(x => new EnumContainer(x));
76 | }
77 | }
78 |
79 | public class EnumContainer where T : Enum
80 | {
81 | public EnumContainer(
82 | T value)
83 | {
84 | this.Value = value;
85 | }
86 |
87 | public T Value { get; set; }
88 |
89 | public string Display => this.Value.ToDisplayName();
90 |
91 | public override string ToString()
92 | => this.Display;
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Extensions/EnumerableExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace aframe
5 | {
6 | public static class EnumerableExtensions
7 | {
8 | public static IEnumerable Walk(
9 | this IEnumerable e,
10 | Action action)
11 | {
12 | foreach (var item in e)
13 | {
14 | action(item);
15 | }
16 |
17 | return e;
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Extensions/ExceptionExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 |
4 | namespace aframe
5 | {
6 | public static class ExceptionExtensions
7 | {
8 | public static string ToFormat(
9 | this Exception ex)
10 | {
11 | var sb = new StringBuilder();
12 |
13 | sb.AppendLine(ex.GetType().ToString() + " :");
14 | sb.AppendLine(ex.Message);
15 |
16 | if (ex.StackTrace != null)
17 | {
18 | sb.AppendLine();
19 | sb.AppendLine("Stack Trace :");
20 | sb.AppendLine(ex.StackTrace);
21 | }
22 |
23 | if (ex.InnerException != null)
24 | {
25 | sb.AppendLine();
26 | sb.AppendLine("Inner Excepsion :");
27 | sb.AppendLine(ex.InnerException.ToFormat());
28 | }
29 |
30 | return sb.ToString();
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Extensions/ObjectExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 |
3 | namespace aframe
4 | {
5 | public static class ObjectExtensions
6 | {
7 | public static T Clone(
8 | this T source)
9 | where T : class
10 | => typeof(T).InvokeMember(
11 | "MemberwiseClone",
12 | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod,
13 | null, source, null) as T;
14 |
15 | public static dynamic Clone(
16 | this object source)
17 | => source.GetType().InvokeMember(
18 | "MemberwiseClone",
19 | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod,
20 | null, source, null);
21 |
22 | public static void CopyProperties(
23 | this object source,
24 | object destination,
25 | params string[] ignoreProperties)
26 | {
27 | var pis = source.GetType().GetProperties();
28 | foreach (var pi in pis)
29 | {
30 | if (ignoreProperties != null)
31 | {
32 | if (ignoreProperties.Contains(pi.Name))
33 | {
34 | continue;
35 | }
36 | }
37 |
38 | var value = pi.GetValue(
39 | source);
40 |
41 | if (value != null)
42 | {
43 | pi.SetValue(destination, value);
44 | }
45 | }
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Extensions/ObservableCollectionExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 |
5 | namespace aframe
6 | {
7 | public static class ObservableCollectionExtensions
8 | {
9 | public static void Sort(
10 | this ObservableCollection collection,
11 | Comparison comparison)
12 | {
13 | var sortableList = new List(collection);
14 | sortableList.Sort(comparison);
15 |
16 | for (int i = 0; i < sortableList.Count; i++)
17 | {
18 | collection.Move(collection.IndexOf(sortableList[i]), i);
19 | }
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Extensions/StringExtensions.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualBasic;
2 |
3 | namespace aframe
4 | {
5 | public static class StringExtensions
6 | {
7 | private const int JPLocaleID = 0x411;
8 |
9 | public static string ToWide(
10 | this string s)
11 | => Strings.StrConv(s, VbStrConv.Wide, JPLocaleID);
12 |
13 | public static string ToNarrow(
14 | this string s)
15 | => Strings.StrConv(s, VbStrConv.Narrow, JPLocaleID);
16 |
17 | public static string ToHiragana(
18 | this string s)
19 | => Strings.StrConv(s, VbStrConv.Hiragana, JPLocaleID);
20 |
21 | public static string ToKatakana(
22 | this string s)
23 | => Strings.StrConv(s, VbStrConv.Katakana, JPLocaleID);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Extensions/TreeViewExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using System.Windows.Controls;
3 |
4 | namespace aframe
5 | {
6 | public static class TreeViewExtensions
7 | {
8 | public static void ExpandAllNodes(
9 | this TreeView treeView)
10 | {
11 | foreach (var item in treeView.Items.OfType())
12 | {
13 | ExpandAllNodes(item);
14 | }
15 | }
16 |
17 | public static void ExpandAllNodes(
18 | this TreeViewItem treeItem)
19 | {
20 | treeItem.IsExpanded = true;
21 | foreach (var child in treeItem.Items.OfType())
22 | {
23 | ExpandAllNodes(child);
24 | }
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/FodyWeavers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/FodyWeavers.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Used to control if the On_PropertyName_Changed feature is enabled.
12 |
13 |
14 |
15 |
16 | Used to change the name of the method that fires the notify event. This is a string that accepts multiple values in a comma separated form.
17 |
18 |
19 |
20 |
21 | Used to control if equality checks should be inserted. If false, equality checking will be disabled for the project.
22 |
23 |
24 |
25 |
26 | Used to control if equality checks should use the Equals method resolved from the base class.
27 |
28 |
29 |
30 |
31 | Used to control if equality checks should use the static Equals method resolved from the base class.
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.
40 |
41 |
42 |
43 |
44 | A comma-separated list of error codes that can be safely ignored in assembly verification.
45 |
46 |
47 |
48 |
49 | 'false' to turn off automatic generation of the XML Schema file.
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Helpers/CommandHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using System.Windows.Media;
4 |
5 | namespace aframe
6 | {
7 | public static class CommandHelper
8 | {
9 | public static async void ExecuteChangeColor(
10 | Func getter,
11 | Action setter,
12 | bool ignoreAlpha = true,
13 | Window owner = null)
14 | {
15 | ColorDialog.Color = getter();
16 | ColorDialog.IgnoreAlpha = ignoreAlpha;
17 |
18 | if (owner == null)
19 | {
20 | owner = WPFHelper.MainWindow;
21 | }
22 |
23 | var result = await WPFHelper.Dispatcher.InvokeAsync(() =>
24 | ColorDialog.ShowDialog(owner) ?? false);
25 |
26 | if (result)
27 | {
28 | setter(ColorDialog.Color);
29 | }
30 | }
31 |
32 | public static async void ExecuteChangeFont(
33 | Func getter,
34 | Action setter,
35 | Window owner = null)
36 | {
37 | FontDialog.Font = getter();
38 |
39 | if (owner == null)
40 | {
41 | owner = WPFHelper.MainWindow;
42 | }
43 |
44 | var result = await WPFHelper.Dispatcher.InvokeAsync(() =>
45 | FontDialog.ShowDialog(owner) ?? false);
46 |
47 | if (result)
48 | {
49 | setter(FontDialog.Font);
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Helpers/DocumentHelper.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Documents;
3 |
4 | namespace aframe
5 | {
6 | public static class DocumentHelper
7 | {
8 | public static readonly DependencyProperty VisibleProperty =
9 | DependencyProperty.RegisterAttached(
10 | "Visible",
11 | typeof(bool),
12 | typeof(DocumentHelper),
13 | new FrameworkPropertyMetadata(
14 | true,
15 | new PropertyChangedCallback(OnVisibilityChanged)));
16 |
17 | public static bool GetVisible(Run d)
18 | => (bool)d.GetValue(VisibleProperty);
19 |
20 | public static void SetVisible(Run d, bool value)
21 | => d.SetValue(VisibleProperty, value);
22 |
23 | private static void OnVisibilityChanged(
24 | DependencyObject d,
25 | DependencyPropertyChangedEventArgs e)
26 | {
27 | if (d is Run run)
28 | {
29 | if ((bool)e.NewValue == true)
30 | {
31 | if (run.Tag != null)
32 | {
33 | run.FontSize = (double)run.Tag;
34 | }
35 | }
36 | else
37 | {
38 | run.Tag = run.FontSize;
39 | run.FontSize = 0.004;
40 | }
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Helpers/MessageBoxHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.CompilerServices;
3 | using System.Threading.Tasks;
4 | using System.Windows;
5 | using aframe.Views;
6 | using MahApps.Metro.Controls.Dialogs;
7 | using Microsoft.Win32;
8 |
9 | namespace aframe
10 | {
11 | public static class MessageBoxHelper
12 | {
13 | public async static Task ShowMessageAsync(
14 | string title,
15 | string message,
16 | MessageDialogStyle style = MessageDialogStyle.Affirmative,
17 | MetroDialogSettings settings = null)
18 | => await WPFHelper.MainWindow?.ShowMessageAsync(
19 | title,
20 | message,
21 | style,
22 | settings);
23 |
24 | public static Task ShowExceptionAsync(
25 | string title,
26 | string message,
27 | Exception exception = null,
28 | MetroDialogSettings settings = null,
29 | [CallerMemberName]string memberName = null,
30 | [CallerFilePath]string filePath = null,
31 | [CallerLineNumber]int lineNumber = 0)
32 | {
33 | var metro = WPFHelper.MainWindow;
34 | if (metro == null)
35 | {
36 | return null;
37 | }
38 |
39 | var dialog = new CustomDialog(
40 | metro,
41 | settings)
42 | {
43 | Title = title
44 | };
45 |
46 | dialog.Content = new MessageView(
47 | () => metro.HideMetroDialogAsync(dialog))
48 | {
49 | Message = message,
50 | Exception = exception,
51 | };
52 |
53 | return metro.ShowMetroDialogAsync(dialog);
54 | }
55 |
56 | public static void ShowDialogMessageWindow(
57 | Window owner,
58 | string title,
59 | string message,
60 | Exception exception = null,
61 | string windowTitle = null)
62 | => MessageWindow.Show(owner, title, message, exception, windowTitle, true);
63 |
64 | public static void ShowDialogMessageWindow(
65 | string title,
66 | string message,
67 | Exception exception = null,
68 | string windowTitle = null)
69 | => MessageWindow.Show(null, title, message, exception, windowTitle, true);
70 |
71 | public static void ShowMessageWindow(
72 | string title,
73 | string message,
74 | Exception exception = null,
75 | string windowTitle = null)
76 | => MessageWindow.Show(title, message, exception, windowTitle);
77 |
78 | public static void ShowMessageWindow(
79 | Window owner,
80 | string title,
81 | string message,
82 | Exception exception = null,
83 | string windowTitle = null)
84 | => MessageWindow.Show(owner, title, message, exception, windowTitle);
85 |
86 | public delegate void EnqueueSnackbarDelegate(string message, bool neverConsiderToBeDuplicate = false);
87 |
88 | public static EnqueueSnackbarDelegate EnqueueSnackbarCallback;
89 |
90 | ///
91 | /// スナックバーにメッセージ表示キューを登録する
92 | ///
93 | /// メッセージ
94 | /// 重複するメッセージを消去しない?true:消去しない, false:消去する
95 | public static void EnqueueSnackMessage(
96 | string message,
97 | bool neverConsiderToBeDuplicate = false)
98 | => EnqueueSnackbarCallback?.Invoke(message, neverConsiderToBeDuplicate);
99 |
100 | public delegate bool ShowSaveFileDialogDelegate(SaveFileDialog dialog);
101 |
102 | public static ShowSaveFileDialogDelegate ShowSaveFileDialogCallback;
103 |
104 | ///
105 | /// 指定されたSaveFileDialogをメインWindowの子として表示する
106 | ///
107 | /// SaveFileDialog
108 | ///
109 | public static bool ShowSaveFileDialog(
110 | SaveFileDialog dialog)
111 | => ShowSaveFileDialogCallback?.Invoke(dialog) ?? false;
112 |
113 | public delegate bool ShowOpenFileDialogDelegate(OpenFileDialog dialog);
114 |
115 | public static ShowOpenFileDialogDelegate ShowOpenFileDialogCallback;
116 |
117 | ///
118 | /// 指定されたOpenFileDialogをメインWindowの子として表示する
119 | ///
120 | /// OpenFileDialog
121 | ///
122 | public static bool ShowOpenFileDialog(
123 | OpenFileDialog dialog)
124 | => ShowOpenFileDialogCallback?.Invoke(dialog) ?? false;
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Helpers/ScrollViewerHelper.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Controls;
3 |
4 | namespace aframe
5 | {
6 | public static class ScrollViewerHelper
7 | {
8 | private static readonly object AutoScroll = new object();
9 |
10 | public static readonly DependencyProperty AutoScrollProperty =
11 | DependencyProperty.RegisterAttached(
12 | nameof(AutoScroll),
13 | typeof(bool),
14 | typeof(ScrollViewerHelper),
15 | new PropertyMetadata(
16 | false,
17 | AutoScrollPropertyChanged));
18 |
19 | public static void AutoScrollPropertyChanged(
20 | DependencyObject obj,
21 | DependencyPropertyChangedEventArgs args)
22 | {
23 | var scrollViewer = obj as ScrollViewer;
24 | if (scrollViewer != null && (bool)args.NewValue)
25 | {
26 | scrollViewer.ScrollChanged += ScrollViewer_ScrollChanged;
27 | scrollViewer.ScrollToEnd();
28 | }
29 | else
30 | {
31 | scrollViewer.ScrollChanged -= ScrollViewer_ScrollChanged;
32 | }
33 | }
34 |
35 | private static void ScrollViewer_ScrollChanged(
36 | object sender,
37 | ScrollChangedEventArgs e)
38 | {
39 | if (e.ExtentHeightChange != 0)
40 | {
41 | var scrollViewer = sender as ScrollViewer;
42 | scrollViewer?.ScrollToBottom();
43 | }
44 | }
45 |
46 | public static bool GetAutoScroll(DependencyObject obj)
47 | => (bool)obj.GetValue(AutoScrollProperty);
48 |
49 | public static void SetAutoScroll(DependencyObject obj, bool value)
50 | => obj.SetValue(AutoScrollProperty, value);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Helpers/WPFHelper.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using System.Windows;
3 | using System.Windows.Threading;
4 | using MahApps.Metro.Controls;
5 | using MahApps.Metro.Controls.Dialogs;
6 |
7 | namespace aframe
8 | {
9 | public static class WPFHelper
10 | {
11 | public delegate Task ShowMessageAsyncDelegate(
12 | string title,
13 | string message,
14 | MessageDialogStyle style = MessageDialogStyle.Affirmative,
15 | MetroDialogSettings settings = null);
16 |
17 | public delegate void EnqueueSnackMessageDelegate(
18 | string message,
19 | bool neverDuplicate = true);
20 |
21 | public static MetroWindow MainWindow => Application.Current?.MainWindow as MetroWindow;
22 |
23 | public static Dispatcher Dispatcher => Application.Current?.Dispatcher;
24 |
25 | #if DEBUG
26 | private readonly static bool isDebugMode = true;
27 | private static bool isDesignMode = false;
28 | #else
29 | private readonly static bool isDebugMode = false;
30 | #endif
31 |
32 | public static bool IsDebugMode => isDebugMode;
33 |
34 | public static bool IsDesignMode
35 | {
36 | get
37 | {
38 | #if DEBUG
39 | if (!isDebugMode)
40 | {
41 | if (System.ComponentModel.LicenseManager.UsageMode ==
42 | System.ComponentModel.LicenseUsageMode.Designtime)
43 | {
44 | isDesignMode = true;
45 | }
46 | else
47 | {
48 | using (var p = System.Diagnostics.Process.GetCurrentProcess())
49 | {
50 | isDesignMode =
51 | p.ProcessName.Equals("DEVENV", System.StringComparison.OrdinalIgnoreCase) ||
52 | p.ProcessName.Equals("XDesProc", System.StringComparison.OrdinalIgnoreCase);
53 | }
54 | }
55 | }
56 |
57 | return isDesignMode;
58 | #else
59 | return false;
60 | #endif
61 | }
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Helpers/WebBrowserHelper.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using System.IO;
3 | using Microsoft.Win32;
4 |
5 | namespace aframe
6 | {
7 | public static class WebBrowserHelper
8 | {
9 | public static void SetUseNewestWebBrowser()
10 | {
11 | var filename = Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName);
12 | if (filename.Contains("vhost"))
13 | {
14 | filename = filename.Substring(0, filename.IndexOf('.') + 1) + "exe";
15 | }
16 |
17 | var key1 = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION");
18 | var key2 = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BEHAVIORS");
19 | key1?.SetValue(filename, 11001, RegistryValueKind.DWord);
20 | key2?.SetValue(filename, 11001, RegistryValueKind.DWord);
21 | key1?.Close();
22 | key2?.Close();
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Models/VersionInfoModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Reflection;
4 | using System.Runtime.Serialization;
5 | using aframe.Updater;
6 | using Prism.Mvvm;
7 | using Reactive.Bindings;
8 |
9 | namespace aframe.Models
10 | {
11 | [DataContract]
12 | public class VersionInfoModel : BindableBase
13 | {
14 | public VersionInfoModel() : this(null)
15 | {
16 | }
17 |
18 | public VersionInfoModel(
19 | Assembly assembly)
20 | {
21 | this.Assembly.Value = assembly;
22 |
23 | this.Assembly.Subscribe(x =>
24 | {
25 | if (x == null)
26 | {
27 | return;
28 | }
29 |
30 | this.ProductName.Value = x.GetProduct();
31 | this.Title.Value = x.GetTitle();
32 | this.Version.Value = x.GetVersion().ToString();
33 | this.ReleaseChannel.Value = x.GetReleaseChannels();
34 | this.Timestamp.Value = new FileInfo(x.Location).CreationTime;
35 | this.Copyright.Value = x.GetCopyright();
36 | });
37 | }
38 |
39 | [IgnoreDataMember]
40 | public ReactiveProperty Assembly { get; } = new ReactiveProperty();
41 |
42 | [DataMember]
43 | public ReactiveProperty ProductName { get; set; } = new ReactiveProperty();
44 |
45 | [DataMember]
46 | public ReactiveProperty Title { get; set; } = new ReactiveProperty();
47 |
48 | [DataMember]
49 | public ReactiveProperty EndPointUri { get; set; } = new ReactiveProperty();
50 |
51 | [DataMember]
52 | public ReactiveProperty Version { get; set; } = new ReactiveProperty();
53 |
54 | [DataMember]
55 | public ReactiveProperty ReleaseChannel { get; set; } = new ReactiveProperty();
56 |
57 | [DataMember]
58 | public ReactiveProperty Timestamp { get; set; } = new ReactiveProperty();
59 |
60 | [DataMember]
61 | public ReactiveProperty Copyright { get; set; } = new ReactiveProperty();
62 |
63 | public override string ToString()
64 | => $"{this.ProductName.Value} v{this.Version.Value} {this.Timestamp.Value:yyyy-MM-dd HH:m:ss}";
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 | using System.Windows;
4 |
5 | [assembly: AssemblyTitle("aframe.Core")]
6 | [assembly: AssemblyDescription("this is a framework for something software...")]
7 | [assembly: AssemblyConfiguration("")]
8 | [assembly: AssemblyCompany("AN")]
9 | [assembly: AssemblyProduct("aframe")]
10 | [assembly: AssemblyCopyright("Copyright © AN 2018")]
11 | [assembly: AssemblyTrademark("")]
12 | [assembly: AssemblyCulture("")]
13 | [assembly: ComVisible(false)]
14 | [assembly: ThemeInfo(
15 | ResourceDictionaryLocation.None,
16 | ResourceDictionaryLocation.SourceAssembly
17 | )]
18 | [assembly: AssemblyVersion("1.1.0.0")]
19 | [assembly: AssemblyFileVersion("1.1.0.0")]
20 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // このコードはツールによって生成されました。
4 | // ランタイム バージョン:4.0.30319.42000
5 | //
6 | // このファイルへの変更は、以下の状況下で不正な動作の原因になったり、
7 | // コードが再生成されるときに損失したりします。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace aframe.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// ローカライズされた文字列などを検索するための、厳密に型指定されたリソース クラスです。
17 | ///
18 | // このクラスは StronglyTypedResourceBuilder クラスが ResGen
19 | // または Visual Studio のようなツールを使用して自動生成されました。
20 | // メンバーを追加または削除するには、.ResX ファイルを編集して、/str オプションと共に
21 | // ResGen を実行し直すか、または VS プロジェクトをビルドし直します。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// このクラスで使用されているキャッシュされた ResourceManager インスタンスを返します。
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("aframe.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// すべてについて、現在のスレッドの CurrentUICulture プロパティをオーバーライドします
51 | /// 現在のスレッドの CurrentUICulture プロパティをオーバーライドします。
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // このコードはツールによって生成されました。
4 | // ランタイム バージョン:4.0.30319.42000
5 | //
6 | // このファイルへの変更は、以下の状況下で不正な動作の原因になったり、
7 | // コードが再生成されるときに損失したりします。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace aframe.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/SuspendableObservableCollection.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Collections.ObjectModel;
3 | using System.Collections.Specialized;
4 | using System.Linq;
5 | using PropertyChanged;
6 |
7 | namespace aframe
8 | {
9 | public class SuspendableObservableCollection : ObservableCollection
10 | {
11 | public SuspendableObservableCollection()
12 | {
13 | }
14 |
15 | public SuspendableObservableCollection(IEnumerable collection) : base(collection)
16 | {
17 | }
18 |
19 | public SuspendableObservableCollection(List list) : base(list)
20 | {
21 | }
22 |
23 | private bool _suppressNotification = false;
24 |
25 | [SuppressPropertyChangedWarnings]
26 | protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
27 | {
28 | if (!this._suppressNotification)
29 | {
30 | base.OnCollectionChanged(e);
31 | }
32 | }
33 |
34 | public void AddRange(
35 | IEnumerable elements,
36 | bool clear = false)
37 | {
38 | if (elements == null ||
39 | !elements.Any())
40 | {
41 | return;
42 | }
43 |
44 | try
45 | {
46 | this._suppressNotification = true;
47 |
48 | if (clear)
49 | {
50 | this.Clear();
51 | }
52 |
53 | foreach (var item in elements)
54 | {
55 | this.Add(item);
56 | }
57 | }
58 | finally
59 | {
60 | this._suppressNotification = false;
61 | }
62 |
63 | this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Updater.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anoyetta/XIVNote/b7a0dff302cf8b0d44538e1aa38a89c949161c53/source/aframe/source/aframe.Core/Updater.ico
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Updater/ReleaseChannels.cs:
--------------------------------------------------------------------------------
1 | namespace aframe.Updater
2 | {
3 | public enum ReleaseChannels
4 | {
5 | Stable = 0,
6 | Beta,
7 | Alpha
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Updater/ReleaseNote.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.IO;
4 | using System.Net;
5 | using System.Threading.Tasks;
6 | using System.Xml.Serialization;
7 | using Prism.Mvvm;
8 | using PropertyChanged;
9 |
10 | namespace aframe.Updater
11 | {
12 | [Serializable]
13 | [AddINotifyPropertyChangedInterface]
14 | public class ReleaseNote : BindableBase
15 | {
16 | private string version = string.Empty;
17 |
18 | [XmlElement(ElementName = "version")]
19 | public string Version
20 | {
21 | get => this.version;
22 | set
23 | {
24 | if (this.SetProperty(ref this.version, value))
25 | {
26 | this.RaisePropertyChanged(nameof(VersionInfo));
27 | }
28 | }
29 | }
30 |
31 | [XmlIgnore]
32 | public Version VersionInfo =>
33 | !string.IsNullOrEmpty(this.Version) ?
34 | new Version(this.Version) :
35 | null;
36 |
37 | [XmlElement(ElementName = "channel")]
38 | public ReleaseChannels ReleaseChannel { get; set; } = ReleaseChannels.Stable;
39 |
40 | [XmlElement(ElementName = "timestamp")]
41 | public DateTime Timestamp { get; set; } = DateTime.MinValue;
42 |
43 | [XmlElement(ElementName = "uri")]
44 | public string Uri { get; set; } = string.Empty;
45 |
46 | private string description = string.Empty;
47 |
48 | [XmlElement(ElementName = "description")]
49 | public string Description
50 | {
51 | get => this.description;
52 | set
53 | {
54 | var text = string.Empty;
55 |
56 | if (!string.IsNullOrEmpty(value))
57 | {
58 | using (var sr = new StringReader(value))
59 | {
60 | while (true)
61 | {
62 | var line = sr.ReadLine();
63 | if (line == null)
64 | {
65 | break;
66 | }
67 |
68 | line = line.Trim();
69 | if (string.IsNullOrEmpty(line))
70 | {
71 | continue;
72 | }
73 |
74 | text += !string.IsNullOrEmpty(text) ?
75 | Environment.NewLine + line :
76 | line;
77 | }
78 | }
79 | }
80 |
81 | this.SetProperty(ref this.description, text);
82 | }
83 | }
84 |
85 | private WebClient downloadClient;
86 |
87 | public async Task DownloadAsync(
88 | string destination,
89 | DownloadProgressChangedEventHandler progressChangedEventHandler = null,
90 | AsyncCompletedEventHandler completedEventHandler = null)
91 | {
92 | using (this.downloadClient = new WebClient())
93 | {
94 | if (progressChangedEventHandler != null)
95 | {
96 | this.downloadClient.DownloadProgressChanged += progressChangedEventHandler;
97 | }
98 |
99 | if (completedEventHandler != null)
100 | {
101 | this.downloadClient.DownloadFileCompleted += completedEventHandler;
102 | }
103 |
104 | await this.downloadClient.DownloadFileTaskAsync(
105 | this.Uri,
106 | destination);
107 | }
108 |
109 | this.downloadClient = null;
110 | }
111 |
112 | public void CancelDownload()
113 | => this.downloadClient?.CancelAsync();
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Updater/ReleaseNotes.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Net;
6 | using System.Reflection;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Xml;
10 | using System.Xml.Serialization;
11 | using Prism.Mvvm;
12 | using PropertyChanged;
13 |
14 | namespace aframe.Updater
15 | {
16 | [Serializable]
17 | [AddINotifyPropertyChangedInterface]
18 | [XmlRoot(ElementName = "release_notes")]
19 | public class ReleaseNotes : BindableBase
20 | {
21 | [XmlElement(ElementName = "name")]
22 | public string Name { get; set; } = string.Empty;
23 |
24 | private List notes = new List();
25 |
26 | [XmlElement(ElementName = "note")]
27 | public ReleaseNote[] Notes
28 | {
29 | get => this.notes.ToArray();
30 | set
31 | {
32 | this.notes.Clear();
33 | this.notes.AddRange(value);
34 | this.RaisePropertyChanged();
35 | }
36 | }
37 |
38 | public void Serialize(
39 | string fileName)
40 | {
41 | var dir = Path.GetDirectoryName(fileName);
42 | if (!Directory.Exists(dir))
43 | {
44 | Directory.CreateDirectory(dir);
45 | }
46 |
47 | File.WriteAllText(
48 | fileName,
49 | this.Serialize(),
50 | new UTF8Encoding(false));
51 | }
52 |
53 | public const string DefaultFileName = "RELEASE_NOTES.xml";
54 |
55 | public string Serialize()
56 | {
57 | var ns = new XmlSerializerNamespaces();
58 | ns.Add(string.Empty, string.Empty);
59 |
60 | var sb = new StringBuilder();
61 | using (var sw = new StringWriter(sb))
62 | using (var xw = XmlWriter.Create(sw, new XmlWriterSettings()
63 | {
64 | OmitXmlDeclaration = true,
65 | Indent = true,
66 | NewLineHandling = NewLineHandling.None,
67 | NewLineOnAttributes = true,
68 | }))
69 | {
70 | var xs = new XmlSerializer(this.GetType());
71 | xs.Serialize(xw, this, ns);
72 | }
73 |
74 | sb.Replace("utf-16", "utf-8");
75 |
76 | return sb.ToString();
77 | }
78 |
79 | public static ReleaseNotes Deserialize(
80 | string fileNameOrXMLText)
81 | {
82 | var source = string.Empty;
83 |
84 | if (File.Exists(fileNameOrXMLText))
85 | {
86 | source = File.ReadAllText(fileNameOrXMLText, new UTF8Encoding(false));
87 | }
88 | else
89 | {
90 | source = fileNameOrXMLText;
91 | }
92 |
93 | if (string.IsNullOrEmpty(source))
94 | {
95 | return null;
96 | }
97 |
98 | var obj = default(ReleaseNotes);
99 | using (var reader = new StringReader(source))
100 | {
101 | var xs = new XmlSerializer(typeof(ReleaseNotes));
102 | obj = xs.Deserialize(reader) as ReleaseNotes;
103 | }
104 |
105 | return obj;
106 | }
107 |
108 | public static async Task DeserializeAsync(
109 | Uri uri)
110 | {
111 | var source = string.Empty;
112 |
113 | using (var client = new WebClient())
114 | {
115 | try
116 | {
117 | client.Encoding = new UTF8Encoding(false);
118 | source = await client.DownloadStringTaskAsync(uri);
119 | }
120 | catch (WebException ex)
121 | {
122 | System.Diagnostics.Debug.WriteLine(ex);
123 | return null;
124 | }
125 | }
126 |
127 | return Deserialize(source);
128 | }
129 |
130 | public ReleaseNote GetNewerVersion(
131 | Assembly currentAssembly,
132 | ReleaseChannels channel = ReleaseChannels.Stable,
133 | bool isForce = false)
134 | {
135 | var currentVersion = currentAssembly.GetVersion();
136 |
137 | ReleaseChannels currentChannel;
138 | var config = currentAssembly.GetConfiguration();
139 | if (!Enum.TryParse(config, out currentChannel))
140 | {
141 | currentChannel = ReleaseChannels.Stable;
142 | }
143 |
144 | var note = (
145 | from x in this.Notes
146 | where
147 | x.ReleaseChannel <= channel &&
148 | x.VersionInfo != null &&
149 | x.VersionInfo >= currentVersion
150 | orderby
151 | x.Version descending,
152 | x.ReleaseChannel ascending
153 | select
154 | x).FirstOrDefault();
155 |
156 | if (note == null)
157 | {
158 | return null;
159 | }
160 |
161 | if (!isForce)
162 | {
163 | if (note.VersionInfo == currentVersion &&
164 | note.ReleaseChannel == currentChannel)
165 | {
166 | return null;
167 | }
168 | }
169 |
170 | return note;
171 | }
172 | }
173 | }
174 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Updater/UpdateChecker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net;
3 | using System.Net.Security;
4 | using System.Reflection;
5 | using System.Security.Cryptography.X509Certificates;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using aframe.Views;
9 |
10 | namespace aframe.Updater
11 | {
12 | public static class UpdateChecker
13 | {
14 | ///
15 | /// アップデートチェック間隔(h)の初期値
16 | ///
17 | public const double DefaultUpdateCheckInterval = 12.0d;
18 |
19 | public static string UpdateSourceUri { get; set; }
20 |
21 | public static Action LastUpdateCheckCallback { get; set; }
22 |
23 | public static ReleaseChannels LastCheckedUpdateChannel { get; private set; } = ReleaseChannels.Stable;
24 |
25 | public static Action ShutdownCallback { get; set; }
26 |
27 | public static async Task IsUpdateAsync(
28 | DateTimeOffset lastUpdateCheckDateTime,
29 | ReleaseChannels updateChannel = ReleaseChannels.Stable,
30 | double updateCheckInterval = DefaultUpdateCheckInterval,
31 | bool isForce = false)
32 | {
33 | // アップデートChannelを保存する
34 | LastCheckedUpdateChannel = updateChannel;
35 |
36 | if (!isForce)
37 | {
38 | // チェック間隔にランダムなゆらぎを与える
39 | var rnd = new Random((int)DateTime.Now.Ticks);
40 | var adjust = rnd.Next(-2, 2);
41 | updateCheckInterval += adjust;
42 |
43 | if ((DateTimeOffset.Now - lastUpdateCheckDateTime).TotalHours <= updateCheckInterval)
44 | {
45 | return false;
46 | }
47 | }
48 |
49 | return await IsUpdateAsync(updateChannel, isForce);
50 | }
51 |
52 | private static async Task IsUpdateAsync(
53 | ReleaseChannels updateChannel,
54 | bool isForce = false)
55 | {
56 | SetupSSL();
57 |
58 | // アップデートChannelを保存する
59 | LastCheckedUpdateChannel = updateChannel;
60 |
61 | if (string.IsNullOrEmpty(UpdateSourceUri))
62 | {
63 | return false;
64 | }
65 |
66 | var now = DateTimeOffset.Now;
67 | var targetAssembly = Assembly.GetEntryAssembly();
68 |
69 | try
70 | {
71 | // リリースノートを取得する
72 | var notes = await ReleaseNotes.DeserializeAsync(new Uri(UpdateSourceUri));
73 | if (notes == null)
74 | {
75 | AppLogger.Error($"Update checker error. RELEASE_NOTES.xml not found. uri={UpdateSourceUri}");
76 | return false;
77 | }
78 |
79 | // より新しいバージョンがあるか?
80 | var newer = notes.GetNewerVersion(
81 | targetAssembly,
82 | updateChannel,
83 | isForce);
84 | if (newer == null)
85 | {
86 | AppLogger.Write("Update checker. this version is up-to-date.");
87 | return false;
88 | }
89 |
90 | AppLogger.Write($"Update checker found newer version. v{newer.Version}-{newer.ReleaseChannel}");
91 |
92 | // アップデートWindowを表示する
93 | await Application.Current.Dispatcher.InvokeAsync(() =>
94 | {
95 | UpdateCheckerView.Show(
96 | notes.Name,
97 | targetAssembly,
98 | newer);
99 | });
100 | }
101 | catch (Exception ex)
102 | {
103 | AppLogger.Fatal("Update checker fatal error.", ex);
104 | throw;
105 | }
106 | finally
107 | {
108 | LastUpdateCheckCallback?.Invoke(now);
109 | AppLogger.Flush();
110 | }
111 |
112 | return true;
113 | }
114 |
115 | public static void SetupSSL()
116 | {
117 | // TLS1.2を有効にする
118 | ServicePointManager.SecurityProtocol =
119 | SecurityProtocolType.Tls11 |
120 | SecurityProtocolType.Tls12;
121 |
122 | // 自己発行証明書の警告を無視する
123 | ServicePointManager.ServerCertificateValidationCallback =
124 | OnRemoteCertificateValidationCallback;
125 | }
126 |
127 | private static bool OnRemoteCertificateValidationCallback(
128 | object sender,
129 | X509Certificate certificate,
130 | X509Chain chain,
131 | SslPolicyErrors sslPolicyErrors) => true;
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Views/CreditView.xaml:
--------------------------------------------------------------------------------
1 |
34 |
35 |
36 |
37 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
54 |
55 |
63 |
64 |
65 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Views/CreditView.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Threading;
4 | using System.Threading.Tasks;
5 | using System.Windows;
6 | using System.Windows.Controls;
7 | using System.Windows.Media.Animation;
8 | using aframe.ViewModels;
9 |
10 | namespace aframe.Views
11 | {
12 | ///
13 | /// CreditView.xaml の相互作用ロジック
14 | ///
15 | public partial class CreditView : Window
16 | {
17 | public CreditView()
18 | {
19 | this.InitializeComponent();
20 | this.ToNonActive();
21 |
22 | this.Loaded += (_, __) =>
23 | {
24 | this.Activate();
25 | this.StartCreadit();
26 | };
27 |
28 | this.MouseLeftButtonUp += (_, __) =>
29 | {
30 | this.Close();
31 | };
32 |
33 | this.SubTitle.Text = string.Empty;
34 | this.Names.Text = string.Empty;
35 | }
36 |
37 | private readonly List CreditList = new List();
38 | private Task showCreditTask;
39 | private volatile bool isCreditRunning = false;
40 |
41 | private void StartCreadit()
42 | {
43 | this.isCreditRunning = true;
44 |
45 | Storyboard.SetTargetName(this.CreaditAnimation, nameof(this.Names));
46 | Storyboard.SetTargetProperty(this.CreaditAnimation, new PropertyPath(TextBlock.OpacityProperty));
47 | this.CreaditAnimationStory.Children.Add(this.CreaditAnimation);
48 |
49 | this.showCreditTask = Task.Run(() =>
50 | {
51 | foreach (var credit in this.CreditList)
52 | {
53 | if (!this.isCreditRunning)
54 | {
55 | break;
56 | }
57 |
58 | this.Dispatcher.Invoke(() =>
59 | {
60 | this.Names.Opacity = 0;
61 |
62 | this.SubTitle.Text = credit.SubTitle;
63 | this.Names.Text = string.Join(Environment.NewLine, credit.Names);
64 |
65 | this.SubTitle.Visibility = !string.IsNullOrEmpty(credit.SubTitle) ?
66 | Visibility.Visible :
67 | Visibility.Collapsed;
68 |
69 | this.CreaditAnimationStory.Begin(this, true);
70 | });
71 |
72 | Thread.Sleep(TimeSpan.FromSeconds(7));
73 | }
74 |
75 | this.Dispatcher.Invoke(() =>
76 | {
77 | this.Close();
78 | });
79 | });
80 | }
81 |
82 | private void StopCredit()
83 | {
84 | this.isCreditRunning = false;
85 | }
86 |
87 | public static void ShowCredits(
88 | IEnumerable credits,
89 | Window owner = null)
90 | {
91 | var view = new CreditView()
92 | {
93 | Owner = owner
94 | };
95 |
96 | view.CreditList.AddRange(credits);
97 | view.Show();
98 | }
99 |
100 | private readonly Storyboard CreaditAnimationStory = new Storyboard();
101 |
102 | private readonly DoubleAnimationUsingKeyFrames CreaditAnimation = new DoubleAnimationUsingKeyFrames()
103 | {
104 | KeyFrames = new DoubleKeyFrameCollection()
105 | {
106 | new LinearDoubleKeyFrame(0, ToKeyTime("0:0:0")),
107 | new LinearDoubleKeyFrame(1, ToKeyTime("0:0:1")),
108 | new LinearDoubleKeyFrame(1, ToKeyTime("0:0:5")),
109 | new LinearDoubleKeyFrame(0, ToKeyTime("0:0:6")),
110 | }
111 | };
112 |
113 | private static readonly KeyTimeConverter KeyTimeConverter = new KeyTimeConverter();
114 |
115 | private static KeyTime ToKeyTime(string time)
116 | => (KeyTime)KeyTimeConverter.ConvertFromString(time);
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Views/HelpView.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Controls;
3 | using System.Windows.Threading;
4 | using Prism.Events;
5 |
6 | namespace aframe.Views
7 | {
8 | ///
9 | /// HelpView.xaml の相互作用ロジック
10 | ///
11 | public partial class HelpView : UserControl
12 | {
13 | public HelpView()
14 | {
15 | this.InitializeComponent();
16 |
17 | LogScrollerMessenger.GetEvent().Subscribe(async () =>
18 | {
19 | try
20 | {
21 | await this.Dispatcher.InvokeAsync(() =>
22 | {
23 | if (this.IsLoaded)
24 | {
25 | this.LogScrollViewer.ScrollToEnd();
26 | }
27 | },
28 | DispatcherPriority.Background);
29 | }
30 | catch (Exception)
31 | {
32 | }
33 | });
34 | }
35 |
36 | private static readonly EventAggregator LogScrollerMessenger = new EventAggregator();
37 |
38 | public static void SendScrollToEndLog()
39 | => LogScrollerMessenger.GetEvent().Publish();
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Views/MessageView.xaml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
41 |
42 |
46 |
47 |
48 |
49 |
50 |
54 |
60 |
61 |
62 | ログを開く
63 |
64 |
65 |
66 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Views/MessageView.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Diagnostics;
4 | using System.IO;
5 | using System.Runtime.CompilerServices;
6 | using System.Windows.Controls;
7 | using Prism.Commands;
8 |
9 | namespace aframe.Views
10 | {
11 | ///
12 | /// MessageView.xaml の相互作用ロジック
13 | ///
14 | public partial class MessageView :
15 | UserControl,
16 | INotifyPropertyChanged
17 | {
18 | public MessageView()
19 | {
20 | this.InitializeComponent();
21 |
22 | if (WPFHelper.IsDesignMode)
23 | {
24 | this.Message = "設定ファイルが見つかりませんでした。\nアプリケーションが正しく配置されているか確認してください。";
25 | this.Exception = new FileNotFoundException("ファイルが見つかりません。");
26 | }
27 | }
28 |
29 | public MessageView(
30 | Action closeHandler) : this()
31 | => this.closeHandler = closeHandler;
32 |
33 | private string message;
34 |
35 | public string Message
36 | {
37 | get => this.message;
38 | set => this.SetProperty(ref this.message, value);
39 | }
40 |
41 | private Exception exception;
42 |
43 | public Exception Exception
44 | {
45 | get => this.exception;
46 | set
47 | {
48 | if (this.SetProperty(ref this.exception, value))
49 | {
50 | this.RaisePropertyChanged(nameof(this.IsExistsException));
51 | this.RaisePropertyChanged(nameof(this.ExceptionMessage));
52 | }
53 | }
54 | }
55 |
56 | public bool IsExistsException => this.Exception != null;
57 |
58 | public string ExceptionMessage => this.Exception?.ToFormat();
59 |
60 | public Action CloseHandler
61 | {
62 | get => this.closeHandler;
63 | set => this.SetProperty(ref this.closeHandler, value);
64 | }
65 |
66 | private Action closeHandler;
67 |
68 | private DelegateCommand okCommand;
69 |
70 | public DelegateCommand OKCommand =>
71 | this.okCommand ?? (this.okCommand = new DelegateCommand(this.ExecuteOKCommand));
72 |
73 | private void ExecuteOKCommand() => this.closeHandler.Invoke();
74 |
75 | private DelegateCommand openLogCommand;
76 |
77 | public DelegateCommand OpenLogCommand =>
78 | this.openLogCommand ?? (this.openLogCommand = new DelegateCommand(this.ExecuteOpenLogCommand));
79 |
80 | private void ExecuteOpenLogCommand()
81 | {
82 | var file = AppLogger.GetCurrentLogFileName();
83 | if (!string.IsNullOrEmpty(file))
84 | {
85 | Process.Start(file);
86 | }
87 | }
88 |
89 | #region INotifyPropertyChanged
90 |
91 | [field: NonSerialized]
92 | public event PropertyChangedEventHandler PropertyChanged;
93 |
94 | public void RaisePropertyChanged(
95 | [CallerMemberName]string propertyName = null)
96 | => this.PropertyChanged?.Invoke(
97 | this,
98 | new PropertyChangedEventArgs(propertyName));
99 |
100 | protected virtual bool SetProperty(
101 | ref T field,
102 | T value,
103 | [CallerMemberName]string propertyName = null)
104 | {
105 | if (object.Equals(field, value))
106 | {
107 | return false;
108 | }
109 |
110 | field = value;
111 | this.PropertyChanged?.Invoke(
112 | this,
113 | new PropertyChangedEventArgs(propertyName));
114 |
115 | return true;
116 | }
117 |
118 | #endregion INotifyPropertyChanged
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Views/MessageWindow.xaml:
--------------------------------------------------------------------------------
1 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Views/MessageWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Media;
3 | using System.Reflection;
4 | using System.Windows;
5 | using MahApps.Metro.Controls;
6 |
7 | namespace aframe.Views
8 | {
9 | ///
10 | /// MessageWindow.xaml の相互作用ロジック
11 | ///
12 | public partial class MessageWindow :
13 | MetroWindow
14 | {
15 | public MessageWindow()
16 | {
17 | this.InitializeComponent();
18 | }
19 |
20 | internal static void ShowDialog(
21 | string title,
22 | string message,
23 | Exception exception = null,
24 | string windowTitle = null)
25 | => Show(null, title, message, exception, windowTitle, true);
26 |
27 | internal static void Show(
28 | string title,
29 | string message,
30 | Exception exception = null,
31 | string windowTitle = null)
32 | => Show(null, title, message, exception, windowTitle);
33 |
34 | internal static void Show(
35 | Window owner,
36 | string title,
37 | string message,
38 | Exception exception = null,
39 | string windowTitle = null,
40 | bool isModal = false)
41 | {
42 | if (string.IsNullOrEmpty(windowTitle))
43 | {
44 | windowTitle = Assembly.GetEntryAssembly().GetProduct();
45 | }
46 |
47 | var window = new MessageWindow()
48 | {
49 | Owner = owner,
50 | Title = windowTitle,
51 | WindowStartupLocation = owner != null ?
52 | WindowStartupLocation.CenterOwner :
53 | WindowStartupLocation.CenterScreen
54 | };
55 |
56 | window.MessageContent.CloseHandler += () => window.Close();
57 | window.TitleLabel.Content = title;
58 | window.MessageContent.Message = message;
59 | window.MessageContent.Exception = exception;
60 |
61 | SystemSounds.Asterisk.Play();
62 |
63 | if (!isModal)
64 | {
65 | window.Show();
66 | }
67 | else
68 | {
69 | window.ShowDialog();
70 | }
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Views/UpdateCheckerView.xaml:
--------------------------------------------------------------------------------
1 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
85 |
86 |
91 |
92 |
93 |
94 |
97 |
104 |
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/Views/UpdateCheckerView.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Windows;
3 | using aframe.Updater;
4 | using aframe.ViewModels;
5 | using MahApps.Metro.Controls;
6 |
7 | namespace aframe.Views
8 | {
9 | ///
10 | /// UpdateCheckerView.xaml の相互作用ロジック
11 | ///
12 | public partial class UpdateCheckerView : MetroWindow
13 | {
14 | private static UpdateCheckerView instance;
15 |
16 | public static void Show(
17 | string appName,
18 | Assembly targetAssembly,
19 | ReleaseNote releaseNote)
20 | {
21 | instance = new UpdateCheckerView();
22 |
23 | instance.Owner = WPFHelper.MainWindow;
24 | instance.ViewModel.AppName.Value = appName;
25 | instance.ViewModel.TargetAssembly.Value = targetAssembly;
26 | instance.ViewModel.Model.Value = releaseNote;
27 |
28 | instance.Show();
29 | }
30 |
31 | public static void CloseUpdateChecker()
32 | {
33 | if (instance != null)
34 | {
35 | instance.Close();
36 | instance = null;
37 | }
38 | }
39 |
40 | public UpdateCheckerView()
41 | {
42 | this.InitializeComponent();
43 | this.ViewModel.CloseViewCallback = () => this.Close();
44 | }
45 |
46 | public UpdateCheckerViewModel ViewModel => this.DataContext as UpdateCheckerViewModel;
47 |
48 | private void CancelButton_Click(object sender, RoutedEventArgs e)
49 | => this.Close();
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Core/WrappingStream.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Threading.Tasks;
4 |
5 | namespace aframe
6 | {
7 | ///
8 | /// ストリームのWrapperクラス
9 | ///
10 | ///
11 | /// Dispose 時に、内部ストリームの参照を外します
12 | ///
13 | public class WrappingStream : Stream
14 | {
15 | private Stream m_streamBase;
16 |
17 | public WrappingStream(Stream streamBase)
18 | {
19 | if (streamBase == null)
20 | {
21 | throw new ArgumentNullException("streamBase");
22 | }
23 |
24 | m_streamBase = streamBase;
25 | }
26 |
27 | public override bool CanRead => this.m_streamBase.CanRead;
28 |
29 | public override bool CanSeek => this.m_streamBase.CanSeek;
30 |
31 | public override bool CanWrite => this.m_streamBase.CanWrite;
32 |
33 | public override long Length => this.m_streamBase.Length;
34 |
35 | public override long Position
36 | {
37 | get => this.m_streamBase.Position;
38 | set => this.m_streamBase.Position = value;
39 | }
40 |
41 | public override void Flush() => this.m_streamBase?.Flush();
42 |
43 | public override int Read(byte[] buffer, int offset, int count) =>
44 | this.m_streamBase.Read(buffer, offset, count);
45 |
46 | public override Task ReadAsync(byte[] buffer, int offset, int count, System.Threading.CancellationToken cancellationToken)
47 | {
48 | ThrowIfDisposed();
49 | return m_streamBase.ReadAsync(buffer, offset, count, cancellationToken);
50 | }
51 |
52 | public new Task ReadAsync(byte[] buffer, int offset, int count)
53 | {
54 | ThrowIfDisposed();
55 | return m_streamBase.ReadAsync(buffer, offset, count);
56 | }
57 |
58 | public override long Seek(long offset, SeekOrigin origin) =>
59 | this.m_streamBase.Seek(offset, origin);
60 |
61 | public override void SetLength(long value) =>
62 | this.m_streamBase.SetLength(value);
63 |
64 | public override void Write(byte[] buffer, int offset, int count) =>
65 | this.m_streamBase.Write(buffer, offset, count);
66 |
67 | protected override void Dispose(bool disposing)
68 | {
69 | if (disposing)
70 | {
71 | m_streamBase.Dispose();
72 | m_streamBase = null;
73 | }
74 |
75 | base.Dispose(disposing);
76 | }
77 |
78 | public byte[] ToArray()
79 | {
80 | if (this.m_streamBase is MemoryStream ms)
81 | {
82 | return ms.ToArray();
83 | }
84 |
85 | return null;
86 | }
87 |
88 | private void ThrowIfDisposed()
89 | {
90 | if (m_streamBase == null)
91 | {
92 | throw new ObjectDisposedException(GetType().Name);
93 | }
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Updater/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Updater/FodyWeavers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Updater/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | [assembly: AssemblyTitle("aframe.Updater")]
5 | [assembly: AssemblyDescription("this is a framework for something software...")]
6 | [assembly: AssemblyConfiguration("")]
7 | [assembly: AssemblyCompany("AN")]
8 | [assembly: AssemblyProduct("aframe")]
9 | [assembly: AssemblyCopyright("Copyright © AN 2018")]
10 | [assembly: AssemblyTrademark("")]
11 | [assembly: AssemblyCulture("")]
12 | [assembly: ComVisible(false)]
13 | [assembly: Guid("38e4d044-78f5-453e-a52c-96f6b201c8b8")]
14 | [assembly: AssemblyVersion("1.1.0.0")]
15 | [assembly: AssemblyFileVersion("1.1.0.0")]
16 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Updater/Updater.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anoyetta/XIVNote/b7a0dff302cf8b0d44538e1aa38a89c949161c53/source/aframe/source/aframe.Updater/Updater.ico
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Updater/aframe.Updater.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {38E4D044-78F5-453E-A52C-96F6B201C8B8}
8 | Exe
9 | aframe.Updater
10 | aframe.Updater
11 | v4.7.2
12 | 512
13 | true
14 | true
15 | publish\
16 | true
17 | Disk
18 | false
19 | Foreground
20 | 7
21 | Days
22 | false
23 | false
24 | true
25 | 0
26 | 1.0.0.%2a
27 | false
28 | false
29 | true
30 |
31 |
32 | aframe.Updater.Program
33 |
34 |
35 | Updater.ico
36 |
37 |
38 | app.manifest
39 |
40 |
41 | true
42 | bin\Debug\
43 | DEBUG;TRACE
44 | full
45 | AnyCPU
46 | latest
47 | prompt
48 | MinimumRecommendedRules.ruleset
49 | false
50 |
51 |
52 | bin\Release\
53 | TRACE
54 | true
55 | AnyCPU
56 | latest
57 | prompt
58 | MinimumRecommendedRules.ruleset
59 | false
60 | pdbonly
61 | true
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 | False
90 | Microsoft .NET Framework 4.7.2 %28x86 および x64%29
91 | true
92 |
93 |
94 | False
95 | .NET Framework 3.5 SP1
96 | false
97 |
98 |
99 |
100 |
101 | 4.1.0
102 |
103 |
104 | 12.0.3
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.Updater/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/source/aframe/source/aframe.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.28010.2050
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "aframe.Core", "aframe.Core\aframe.Core.csproj", "{1E602601-AEA4-47CD-8F44-6C5E1D7387A5}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {1E602601-AEA4-47CD-8F44-6C5E1D7387A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {1E602601-AEA4-47CD-8F44-6C5E1D7387A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {1E602601-AEA4-47CD-8F44-6C5E1D7387A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {1E602601-AEA4-47CD-8F44-6C5E1D7387A5}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {E74A211B-D2BB-4FCA-9F34-3CE66C512F97}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/source/aframe/source/restore_packages.ps1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anoyetta/XIVNote/b7a0dff302cf8b0d44538e1aa38a89c949161c53/source/aframe/source/restore_packages.ps1
--------------------------------------------------------------------------------
/source/aframe/tools/nuget.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anoyetta/XIVNote/b7a0dff302cf8b0d44538e1aa38a89c949161c53/source/aframe/tools/nuget.exe
--------------------------------------------------------------------------------
/source/tools/7za.exe:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:ff3706e94d9b769f78e4271928382426cb034b11c5a0f6a8ffea35726cc03692
3 | size 1075712
4 |
--------------------------------------------------------------------------------
/source/tools/Version.master.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | [assembly: AssemblyVersion("#VERSION#")]
4 | [assembly: AssemblyConfiguration("#CHANNEL#")]
5 |
--------------------------------------------------------------------------------
/source/tools/libz.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anoyetta/XIVNote/b7a0dff302cf8b0d44538e1aa38a89c949161c53/source/tools/libz.exe
--------------------------------------------------------------------------------