From 827080097420f5125c043a3feb037fda9c11c9b5 Mon Sep 17 00:00:00 2001 From: "NotYoojun.!" Date: Thu, 26 Oct 2023 22:01:32 +0800 Subject: [PATCH] Update v1.2.6 --- source/MCSkinn/App.xaml | 2 +- source/MCSkinn/Controls/ColorPicker.xaml.cs | 4 +- source/MCSkinn/Controls/OtkWpfControl.cs | 2 +- .../UserControls/NewSkinDialogContent.xaml | 118 +++++ .../UserControls/NewSkinDialogContent.xaml.cs | 359 +++++++++++++++ .../Dialogs/GeneralQuestionDialog.xaml.cs | 6 +- source/MCSkinn/Dialogs/LogWindow.xaml.cs | 6 +- .../Dialogs/SkinSizeMismatchDialug.xaml.cs | 2 +- source/MCSkinn/Forms/Controls/Brushes.cs | 4 +- source/MCSkinn/MainWindow.xaml | 44 ++ source/MCSkinn/MainWindow.xaml.cs | 153 +++++++ source/MCSkinn/Pages/PageSettings.xaml | 128 ++++-- source/MCSkinn/Pages/PageSettings.xaml.cs | 210 +++++---- source/MCSkinn/Pages/PageSplash.xaml | 4 +- source/MCSkinn/Pages/PageSplash.xaml.cs | 34 +- source/MCSkinn/Properties/AssemblyInfo.cs | 6 +- source/MCSkinn/Scripts/BackgroundImage.cs | 2 +- source/MCSkinn/Scripts/Editor.cs | 414 +++++++++++++----- source/MCSkinn/Scripts/ErrorReport.cs | 2 +- source/MCSkinn/Scripts/FolderNode.cs | 8 +- source/MCSkinn/Scripts/GlobalDirtiness.cs | 2 +- source/MCSkinn/Scripts/GlobalSettings.cs | 26 +- source/MCSkinn/Scripts/ImageUtilities.cs | 2 +- source/MCSkinn/Scripts/MenuStripShortcut.cs | 2 +- .../MCSkinn/Scripts/Models/ModelFormatTCN.cs | 16 +- source/MCSkinn/Scripts/Models/ModelLoader.cs | 6 +- .../Components/Shortcuts/ControlShortcut.cs | 2 +- .../Shortcuts/IShortcutImplementor.cs | 2 +- .../Components/Shortcuts/ShortcutBase.cs | 2 +- .../Components/Shortcuts/ShortcutEditor.cs | 2 +- .../Paril/Components/Undo/UndoBuffer.cs | 2 +- .../Scripts/Paril/Components/Undo/Undoable.cs | 2 +- source/MCSkinn/Scripts/Paril/Drawing/Color.cs | 2 +- .../Scripts/Paril/Drawing/ColorBlending.cs | 2 +- .../Scripts/Paril/Drawing/FastPixel.cs | 2 +- .../Scripts/Paril/Extensions/Extensions.cs | 2 +- .../Paril/OpenGL/ClientArrayRenderer.cs | 2 +- .../Scripts/Paril/OpenGL/ImmediateRenderer.cs | 2 +- .../MCSkinn/Scripts/Paril/OpenGL/Renderer.cs | 2 +- .../MCSkinn/Scripts/Paril/OpenGL/TextureGL.cs | 2 +- .../Settings/Serializers/ColorSerializer.cs | 6 +- .../Settings/Serializers/EnumSerializer.cs | 2 +- .../Settings/Serializers/HexSerializer.cs | 2 +- .../Serializers/PasswordSerializer.cs | 2 +- .../Scripts/Paril/Settings/Settings.cs | 6 +- source/MCSkinn/Scripts/PartTreeNode.cs | 2 +- .../MCSkinn/Scripts/PixelsChangedUndoable.cs | 2 +- source/MCSkinn/Scripts/Skin.cs | 6 +- source/MCSkinn/Scripts/StaticHolder.cs | 2 +- source/MCSkinn/Scripts/Tools/BrushToolBase.cs | 2 +- source/MCSkinn/Scripts/Tools/CameraTool.cs | 14 +- .../Scripts/Tools/DarkenLightenTool.cs | 2 +- source/MCSkinn/Scripts/Tools/DodgeBurnTool.cs | 2 +- source/MCSkinn/Scripts/Tools/DropperTool.cs | 2 +- source/MCSkinn/Scripts/Tools/EraserTool.cs | 2 +- source/MCSkinn/Scripts/Tools/FloodFillTool.cs | 6 +- source/MCSkinn/Scripts/Tools/ITool.cs | 2 +- source/MCSkinn/Scripts/Tools/NoiseTool.cs | 2 +- source/MCSkinn/Scripts/Tools/PencilTool.cs | 6 +- source/MCSkinn/Scripts/Tools/Stamp.cs | 2 +- source/MCSkinn/Scripts/Tools/ToolIndex.cs | 4 +- source/MCSkinn/Scripts/Tools/Tools.cs | 2 +- source/MCSkinn/Scripts/TransparencyMode.cs | 2 +- source/MCSkinn/Scripts/TypeHelper.cs | 6 +- source/MCSkinn/Scripts/ViewMode.cs | 2 +- source/MCSkinn/Scripts/VisiblePartFlags.cs | 2 +- source/MCSkinn/Scripts/Workfolder.cs | 6 +- .../Scripts/lemon42/Colors/ColorManager.cs | 4 +- source/MCSkinn/Themes/PathIcons.xaml | 13 - 69 files changed, 1334 insertions(+), 369 deletions(-) create mode 100644 source/MCSkinn/Controls/UserControls/NewSkinDialogContent.xaml create mode 100644 source/MCSkinn/Controls/UserControls/NewSkinDialogContent.xaml.cs create mode 100644 source/MCSkinn/MainWindow.xaml create mode 100644 source/MCSkinn/MainWindow.xaml.cs delete mode 100644 source/MCSkinn/Themes/PathIcons.xaml diff --git a/source/MCSkinn/App.xaml b/source/MCSkinn/App.xaml index 1d52596..63cd7ca 100644 --- a/source/MCSkinn/App.xaml +++ b/source/MCSkinn/App.xaml @@ -61,7 +61,7 @@ --> - + diff --git a/source/MCSkinn/Controls/ColorPicker.xaml.cs b/source/MCSkinn/Controls/ColorPicker.xaml.cs index 68d9156..925a771 100644 --- a/source/MCSkinn/Controls/ColorPicker.xaml.cs +++ b/source/MCSkinn/Controls/ColorPicker.xaml.cs @@ -14,7 +14,7 @@ using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; -using Inkore.Coreworks.Windows.Helpers; +using iNKORE.Coreworks.Windows.Helpers; namespace MCSkinn.Controls { @@ -50,7 +50,7 @@ private void Button_Select_Click(object sender, RoutedEventArgs e) System.Windows.Forms.ColorDialog d = new System.Windows.Forms.ColorDialog(); if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK) { - this.Color = d.Color.D2W(); + this.Color = d.Color.ToWpfColor(); RaiseEvent(new RoutedEventArgs(ColorPickedEvent)); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Color")); } diff --git a/source/MCSkinn/Controls/OtkWpfControl.cs b/source/MCSkinn/Controls/OtkWpfControl.cs index 58920c6..7d7e9c4 100644 --- a/source/MCSkinn/Controls/OtkWpfControl.cs +++ b/source/MCSkinn/Controls/OtkWpfControl.cs @@ -11,7 +11,7 @@ using OpenTK; using OpenTK.Graphics; using System.Windows.Threading; -using Inkore.UI.WPF.Modern.Controls; +using iNKORE.UI.WPF.Modern.Controls; using System.Windows.Input; using MCSkinn.Scripts.Paril.OpenGL; diff --git a/source/MCSkinn/Controls/UserControls/NewSkinDialogContent.xaml b/source/MCSkinn/Controls/UserControls/NewSkinDialogContent.xaml new file mode 100644 index 0000000..5b7f6d3 --- /dev/null +++ b/source/MCSkinn/Controls/UserControls/NewSkinDialogContent.xaml @@ -0,0 +1,118 @@ + + + + 16 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/source/MCSkinn/Controls/UserControls/NewSkinDialogContent.xaml.cs b/source/MCSkinn/Controls/UserControls/NewSkinDialogContent.xaml.cs new file mode 100644 index 0000000..8c2ca79 --- /dev/null +++ b/source/MCSkinn/Controls/UserControls/NewSkinDialogContent.xaml.cs @@ -0,0 +1,359 @@ +using GongSolutions.Wpf.DragDrop.Utilities; +using iNKORE.Coreworks.Helpers; +using iNKORE.Coreworks.Localization; +using iNKORE.Coreworks.Windows.Presentation; +using MCSkinn.Forms.Controls; +using MCSkinn.Scripts; +using MCSkinn.Scripts.Paril.Imaging; +using MCSkinn.Scripts.Paril.OpenGL; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Drawing = System.Drawing; +using Forms = System.Windows.Forms; + +namespace MCSkinn.Dialogs +{ + /// + /// NewSkinDialogContent.xaml 的交互逻辑 + /// + public partial class NewSkinDialogContent : UserControl + { + public NewSkinDialogContent() + { + InitializeComponent(); + } + + private void UserControl_Initialized(object sender, EventArgs e) + { + TreeView_Models.ItemsSource = Program.Page_Editor.MenuFlyout_Model.Items; + } + + public System.Windows.Forms.OpenFileDialog OpenFileDialog_Local_Broswe; + + private void Button_Local_Dropfile_Click(object sender, RoutedEventArgs e) + { + if(OpenFileDialog_Local_Broswe == null) + { + OpenFileDialog_Local_Broswe = new System.Windows.Forms.OpenFileDialog(); + OpenFileDialog_Local_Broswe.Multiselect = false; + OpenFileDialog_Local_Broswe.Filter = "Minecraft Skin (*.png)|*.png|All files|*.*"; + } + + if (OpenFileDialog_Local_Broswe.ShowDialog() == System.Windows.Forms.DialogResult.OK) + { + TextBlock_Dropfile_Path.Text = OpenFileDialog_Local_Broswe.FileName; + TryGetModel(); + } + + SetDialogButtonEnabled(); + } + + private void Button_Local_Dropfile_Drop(object sender, DragEventArgs e) + { + try + { + if (e.Data.GetDataPresent(DataFormats.FileDrop)) + { + var fileName = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString(); + + + if (System.IO.Path.GetExtension(fileName) == ".png") + { + TextBlock_Dropfile_Path.Text = System.IO.Path.GetFullPath(fileName); + TryGetModel(); + e.Effects = DragDropEffects.Copy; + } + else + e.Effects = DragDropEffects.None; + } + } + catch (Exception ex) + { + Program.Log(ex); + MessageBox.Show(ex.Message); + } + finally + { + SetDialogButtonEnabled(); + + } + } + + System.Windows.Forms.SaveFileDialog SaveFileDialog_SaveTo; + + private void Button_SaveTo_Browse_Click(object sender, RoutedEventArgs e) + { + if (SaveFileDialog_SaveTo == null) + { + SaveFileDialog_SaveTo = new System.Windows.Forms.SaveFileDialog(); + SaveFileDialog_SaveTo.Filter = "Minecraft Skin (*.png)|*.png|All files|*.*"; + } + + SaveFileDialog_SaveTo.FileName = TextBox_SaveTo.Text; + + if(SaveFileDialog_SaveTo.ShowDialog() == System.Windows.Forms.DialogResult.OK) + { + TextBox_SaveTo.Text = SaveFileDialog_SaveTo.FileName; + } + } + + private void Button_Local_Dropfile_DragOver(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(DataFormats.FileDrop)) + { + try + { + var fileName = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString(); + + if (System.IO.Path.GetExtension(fileName) == ".png") + e.Effects = DragDropEffects.Copy; + else + e.Effects = DragDropEffects.None; + } + catch { e.Effects = DragDropEffects.None; } + } + else if (e.Data.GetDataPresent(DataFormats.Bitmap)) + { + e.Effects = DragDropEffects.None; + } + else + { + e.Effects = DragDropEffects.None; + } + + } + + public void CreateSkin() + { + if (!(TreeView_Models.SelectedItem is ModelToolStripMenuItem) || string.IsNullOrEmpty(TextBox_SaveTo.Text)) + return; + + //if (specificModel == null) + // specificModel = ModelLoader.Models["Players/Steve"]; + + string newSkinName = TextBox_SaveTo.Text; + Model specificModel = ((ModelToolStripMenuItem)TreeView_Models.SelectedItem).Model; + + + Drawing.Bitmap bmp = null; + + if (TabControl_SourceSelector.SelectedItem == TabItem_SourceSelector_Empty) + { + if(CheckBox_EmptySkin_UseTemplate.IsChecked == true) + { + string templatePath = System.IO.Path.Combine(GlobalSettings.FullPath_Templates, specificModel.DefaultTexture); + + if (File.Exists(templatePath) && templatePath.EndsWith(".png")) + { + using (var mp = new FileStream(templatePath, FileMode.Open, FileAccess.Read)) + using (var bitmap = Drawing.Image.FromStream(mp)) + { + bmp = new Drawing.Bitmap(bitmap.Width, bitmap.Height); + Drawing.Graphics g = Drawing.Graphics.FromImage(bmp); + g.DrawImage(bitmap, 0, 0, bitmap.Width, bitmap.Height); + + g.Dispose(); + } + + } + + } + + if (bmp == null) + { + bmp = new Drawing.Bitmap((int)specificModel.DefaultWidth, (int)specificModel.DefaultHeight); + Drawing.Graphics g = Drawing.Graphics.FromImage(bmp); + g.DrawRectangle(Drawing.Pens.Transparent, new Drawing.Rectangle(Drawing.Point.Empty, bmp.Size)); + foreach (var mesh in specificModel.Meshes) + { + foreach (var face in mesh.Faces) + { + var color = new Scripts.Paril.Drawing.ConvertableColor(Scripts.Paril.Drawing.ColorRepresentation.RGB, (face.Normal.X / 2) + 0.5f, (face.Normal.Y / 2) + 0.5f, (face.Normal.Z / 2) + 0.5f, !mesh.IsArmor ? 1.0f : 0.5f); + + var baseColor = color.ToColor(); + color.L += 0.1f; + var lightColor = color.ToColor(); + + if (mesh.IsArmor) + lightColor = baseColor; + + Drawing.Rectangle coords = face.TexCoordsToInteger(bmp.Width, bmp.Height); + + for (var y = coords.Top; y < coords.Bottom; ++y) + { + for (var x = coords.Left; x < coords.Right; ++x) + bmp.SetPixel(x, y, ((x + y) % 2) == 0 ? baseColor : lightColor); + } + } + } + + g.Dispose(); + } + + + } + else if (TabControl_SourceSelector.SelectedItem == TabItem_SourceSelector_Local) + { + using (var mp = new FileStream(TextBlock_Dropfile_Path.Text, FileMode.Open, FileAccess.Read)) + using (var bitmap = Drawing.Image.FromStream(mp)) + { + bmp = new Drawing.Bitmap(bitmap.Width, bitmap.Height); + Drawing.Graphics g = Drawing.Graphics.FromImage(bmp); + g.DrawImage(bitmap, 0, 0, bitmap.Width, bitmap.Height); + + g.Dispose(); + } + } + else + { + bmp = new Drawing.Bitmap((int)specificModel.DefaultWidth, (int)specificModel.DefaultHeight); + } + + bmp.SaveSafe(newSkinName); + + bmp.Dispose(); + + var md = new Dictionary(); + md.Add("Model", specificModel.Name); + PNGMetadata.WriteMetadata(newSkinName, md); + + + switch (TabControl_SourceSelector.SelectedIndex) + { + case 0: + + break; + } + + + } + + public void SetDialogButtonEnabled() + { + if(!(TreeView_Models.SelectedItem is ModelToolStripMenuItem) || TextBox_SaveTo.Text.IsNullOrEmptyOrWhitespace()) + { + SetDialogButtonEnabled(false); return; + } + + switch (TabControl_SourceSelector.SelectedIndex) + { + case 0: + SetDialogButtonEnabled(true); + break; + case 1: + if (System.IO.File.Exists(TextBlock_Dropfile_Path.Text)) + SetDialogButtonEnabled(true); + else + SetDialogButtonEnabled(false); + break; + } + } + public void SetDialogButtonEnabled(bool isPrimaryButtonEnabled) + { + if(Program.Page_Editor?.ContentDialog_NewSkin != null) + { + Program.Page_Editor.ContentDialog_NewSkin.IsPrimaryButtonEnabled = isPrimaryButtonEnabled; + } + } + + private void TabControl_SourceSelector_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + SetDialogButtonEnabled(); + } + + private void TreeView_Models_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs e) + { + + try + { + ModelToolStripMenuItem m = TreeView_Models.SelectedItem as ModelToolStripMenuItem; + + bool isTemplateAvailable = false; + + if (m != null) + { + if (m.Model?.DefaultTexture != null) + { + string templatePath = System.IO.Path.Combine(GlobalSettings.FullPath_Templates, m.Model.DefaultTexture); + + if (File.Exists(templatePath) && templatePath.EndsWith(".png")) + { + isTemplateAvailable = true; + } + } + } + + if (isTemplateAvailable && !CheckBox_EmptySkin_UseTemplate.IsEnabled && CheckBox_EmptySkin_UseTemplate.IsChecked == false) + { + CheckBox_EmptySkin_UseTemplate.IsChecked = true; + } + + CheckBox_EmptySkin_UseTemplate.IsEnabled = isTemplateAvailable; + + } + catch (Exception ex) + { + Program.Log(ex, "NewSkinDialogContent.TreeView_Models_SelectedItemChanged()"); + } + + if (!CheckBox_EmptySkin_UseTemplate.IsEnabled && CheckBox_EmptySkin_UseTemplate.IsChecked == true) + CheckBox_EmptySkin_UseTemplate.IsChecked = false; + + SetDialogButtonEnabled(); + } + + public void TryGetModel() + { + string path = TextBlock_Dropfile_Path.Text; + + System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(path); + + Model model = Skin.TryGetModel(path, bmp, TreeView_Models.SelectedItem == null); + + if (model != null) + { + TreeView_Models.GetTreeViewItem(model.DropDownItem).IsSelected = true; + + } + } + + private void TextBox_SaveTo_LostFocus(object sender, RoutedEventArgs e) + { + SetDialogButtonEnabled(); + } + + private void UserControl_Loaded(object sender, RoutedEventArgs e) + { + LanguageWpf.Register(this, TabItem_SourceSelector_Empty, TabItem.HeaderProperty); + LanguageWpf.Register(this, TabItem_SourceSelector_Local, TabItem.HeaderProperty); + + LanguageWpf.Register(this, TextBlock_Dropfile, TextBlock.TextProperty); + LanguageWpf.Register(this, TextBlock_EmptySkin, TextBlock.TextProperty); + LanguageWpf.Register(this, TextBlock_SaveTo, TextBlock.TextProperty); + LanguageWpf.Register(this, CheckBox_EmptySkin_UseTemplate, ContentProperty); + } + + private void UserControl_Unloaded(object sender, RoutedEventArgs e) + { + UnregisterLangauge(); + } + + public void UnregisterLangauge() + { + LanguageWpf.UnregisterContainer(this); + } + } +} diff --git a/source/MCSkinn/Dialogs/GeneralQuestionDialog.xaml.cs b/source/MCSkinn/Dialogs/GeneralQuestionDialog.xaml.cs index 0a8eda4..6c51c45 100644 --- a/source/MCSkinn/Dialogs/GeneralQuestionDialog.xaml.cs +++ b/source/MCSkinn/Dialogs/GeneralQuestionDialog.xaml.cs @@ -1,4 +1,4 @@ -using Inkore.UI.WPF.Modern.Controls; +using iNKORE.UI.WPF.Modern.Controls; using System; using System.Collections.Generic; using System.Linq; @@ -21,6 +21,10 @@ namespace MCSkinn.Dialogs /// public partial class GeneralQuestionDialog : ContentDialog { + public GeneralQuestionDialog() + { + InitializeComponent(); + } public GeneralQuestionDialog(string title, string content, ContentDialogButton defaultButton = ContentDialogButton.Primary, string button1text = "C_YES", string button2text = "C_NO", string buttonCanceltext = null) { InitializeComponent(); diff --git a/source/MCSkinn/Dialogs/LogWindow.xaml.cs b/source/MCSkinn/Dialogs/LogWindow.xaml.cs index 3e93d3e..69b8acd 100644 --- a/source/MCSkinn/Dialogs/LogWindow.xaml.cs +++ b/source/MCSkinn/Dialogs/LogWindow.xaml.cs @@ -1,13 +1,13 @@ -using Inkore.Coreworks; +using iNKORE.Coreworks; using System.IO; using System.Windows; using System.Windows.Controls; using System.Windows.Input; -using Inkore.Coreworks.Windows.Helpers; +using iNKORE.Coreworks.Windows.Helpers; using System.Diagnostics; using MCSkinn.Scripts; using System; -using Inkore.Coreworks.Windows.Presentation; +using iNKORE.Coreworks.Windows.Presentation; namespace MCSkinn.Dialogs { diff --git a/source/MCSkinn/Dialogs/SkinSizeMismatchDialug.xaml.cs b/source/MCSkinn/Dialogs/SkinSizeMismatchDialug.xaml.cs index f9494c4..4261da5 100644 --- a/source/MCSkinn/Dialogs/SkinSizeMismatchDialug.xaml.cs +++ b/source/MCSkinn/Dialogs/SkinSizeMismatchDialug.xaml.cs @@ -1,4 +1,4 @@ -using Inkore.UI.WPF.Modern.Controls; +using iNKORE.UI.WPF.Modern.Controls; using System; using System.Collections.Generic; using System.Linq; diff --git a/source/MCSkinn/Forms/Controls/Brushes.cs b/source/MCSkinn/Forms/Controls/Brushes.cs index 597563c..b720bf6 100644 --- a/source/MCSkinn/Forms/Controls/Brushes.cs +++ b/source/MCSkinn/Forms/Controls/Brushes.cs @@ -3,7 +3,7 @@ // Copyright © iNKORE! 2023 // // The copy of source (only the public part) can be used anywhere with a credit to MCSkinn page at your own risk -// https://github.com/InkoreStudios/MCSkinn +// https://github.com/iNKOREStudios/MCSkinn // using System; @@ -13,7 +13,7 @@ using System.IO; using System.Windows.Forms; using MCSkinn.Scripts.Paril.Drawing; -using Inkore.Coreworks.Windows.Helpers; +using iNKORE.Coreworks.Windows.Helpers; using System.Collections.ObjectModel; using System.ComponentModel; using Newtonsoft.Json.Linq; diff --git a/source/MCSkinn/MainWindow.xaml b/source/MCSkinn/MainWindow.xaml new file mode 100644 index 0000000..ea56d2a --- /dev/null +++ b/source/MCSkinn/MainWindow.xaml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + diff --git a/source/MCSkinn/MainWindow.xaml.cs b/source/MCSkinn/MainWindow.xaml.cs new file mode 100644 index 0000000..36554e8 --- /dev/null +++ b/source/MCSkinn/MainWindow.xaml.cs @@ -0,0 +1,153 @@ +using MCSkinn.Dialogs; +using MCSkinn.Forms.Controls; +using MCSkinn.Scripts; +using iNKORE.Coreworks.Localization; +using MCSkinn.Scripts.Paril.OpenGL; +using MCSkinn.Scripts.Tools; +using iNKORE.UI.WPF.Modern.Controls; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Interop; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Windows.Threading; +using Windows.Storage; +using Microsoft.AppCenter.Crashes; +using System.Windows.Media.Animation; +using iNKORE.UI.WPF.Modern.Media.Animation; + +namespace MCSkinn +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + this.Title = "MCSkinn - Version " + Program.VersionFull; + + //Program.Page_Editor.TextBlock_User.Text = Environment.UserName; + + //PageEditor.resizeTimer.Tick += ResizeTimer_Tick; + //PageEditor.resizeTimer.Interval = TimeSpan.FromMilliseconds(100); + } + + //private void Window_SizeChanged(object sender, SizeChangedEventArgs e) + //{ + // if (WindowsFormsHost_Viewport.Visibility != Visibility.Collapsed) + // { + // WindowsFormsHost_Viewport.Visibility = Visibility.Collapsed; + // } + + // resizeDelay = 0; + // if (!resizeTimer.IsEnabled) + // { + // resizeTimer.Start(); + // } + + //} + private void Window_Loaded(object sender, RoutedEventArgs e) + { + if (Width >= System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width || Height >= System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height) + { + this.Width = 600; + this.Height = 480; + this.WindowState = WindowState.Maximized; + } + + DoNavigate(Program.Page_Splash); + } + private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) + { + + if (Program.Editor?.FormClosing() == true) + { + Program.App_Main.Shutdown(0); + } + else + { + e.Cancel = true; + } + + } + + private void Window_Activated(object sender, EventArgs e) + { + if(!Program.IsNativeMicaSupported) + TitlebarOpacityAnimation(1d); + } + + private void Window_Deactivated(object sender, EventArgs e) + { + if (!Program.IsNativeMicaSupported) + TitlebarOpacityAnimation(0.45d); + } + + public static Duration TitlebarOpacityAnimationDuration = new Duration(TimeSpan.FromMilliseconds(500)); + public bool TitlebarOpacityAnimation(double to) + { + FrameworkElement titleBar = (Frame_Main.Content as FrameworkElement)?.FindName("Border_AppTitlebar") as FrameworkElement; + if (titleBar != null) + { + DoubleAnimation ani = new DoubleAnimation() { To = to, Duration = TitlebarOpacityAnimationDuration }; + titleBar.BeginAnimation(OpacityProperty, ani); + + return true; + } + else + { + return false; + } + } + + private const string NavigationConfirmation = "CONFIRM_NAVIGATE"; + public void DoNavigate(System.Windows.Controls.Page p) + { + Frame_Main.Navigate(p, NavigationConfirmation); + } + private void Frame_Main_Navigating(object sender, NavigatingCancelEventArgs e) + { + if (e.ExtraData as string != NavigationConfirmation) + e.Cancel = true; + } + + private void Frame_Main_Navigated(object sender, NavigationEventArgs e) + { + if (this.IsActive) + Window_Activated(this, e); + else + Window_Deactivated(this, e); + } + + private void Window_KeyDown(object sender, KeyEventArgs e) + { + + } + + private void Window_Initialized(object sender, EventArgs e) + { + if (!GlobalSettings.CompatibilityMode) + { + iNKORE.UI.WPF.Modern.Controls.Primitives.WindowHelper.SetUseModernWindowStyle(this, true); + } + else + { + this.BorderBrush = null; + this.BorderThickness = new Thickness(0); + this.SetResourceReference(BackgroundProperty, iNKORE.UI.WPF.Modern.ThemeKeys.ApplicationPageBackgroundThemeBrushKey); + } + } + } +} diff --git a/source/MCSkinn/Pages/PageSettings.xaml b/source/MCSkinn/Pages/PageSettings.xaml index 8c05147..c898dd9 100644 --- a/source/MCSkinn/Pages/PageSettings.xaml +++ b/source/MCSkinn/Pages/PageSettings.xaml @@ -8,9 +8,7 @@ d:DesignWidth="800" Title="" Loaded="Page_Loaded" Unloaded="Page_Unloaded"> - + + @@ -42,7 +43,7 @@ - + @@ -52,12 +53,11 @@ - + - - + @@ -91,17 +91,13 @@ - + - + - - - - - + @@ -110,23 +106,28 @@ + - + - + - - - - - - - + + + + + + + + + + + @@ -135,20 +136,20 @@ + - + - + - + -