diff --git a/HaRepacker/Converter/ImageSizeDoubleToIntegerConverter.cs b/HaRepacker/Converter/ImageSizeDoubleToIntegerConverter.cs
index a49d96a0..13b17a5b 100644
--- a/HaRepacker/Converter/ImageSizeDoubleToIntegerConverter.cs
+++ b/HaRepacker/Converter/ImageSizeDoubleToIntegerConverter.cs
@@ -21,16 +21,16 @@ public class ImageSizeDoubleToIntegerConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
- double value_ = (double)value;
+ int value_ = (int)value;
- return (int)value_;
+ return value_;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
- double value_ = (double)value;
+ int value_ = (int)value;
- return (int)value_;
+ return value_;
}
}
}
diff --git a/HaRepacker/Converter/ImageWidthOrHeightToScreenDPIConverter.cs b/HaRepacker/Converter/ImageWidthOrHeightToScreenDPIConverter.cs
index d91ff290..daa93ca1 100644
--- a/HaRepacker/Converter/ImageWidthOrHeightToScreenDPIConverter.cs
+++ b/HaRepacker/Converter/ImageWidthOrHeightToScreenDPIConverter.cs
@@ -23,16 +23,16 @@ public class ImageWidthOrHeightToScreenDPIConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
- double widthOrHeight = (double)value;
- double realWidthOrHeightToDisplay = widthOrHeight * ScreenDPIUtil.GetScreenScaleFactor();
+ int widthOrHeight = (int)value;
+ int realWidthOrHeightToDisplay = (int) ((double) widthOrHeight * ScreenDPIUtil.GetScreenScaleFactor());
return realWidthOrHeightToDisplay;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
- double value_ = (double)value;
- double imageWidthOrHeight = value_ / ScreenDPIUtil.GetScreenScaleFactor();
+ int value_ = (int)value;
+ int imageWidthOrHeight = (int) ((double)value_ / ScreenDPIUtil.GetScreenScaleFactor());
return imageWidthOrHeight;
}
diff --git a/HaRepacker/Converter/PointFConverter.cs b/HaRepacker/Converter/PointFConverter.cs
new file mode 100644
index 00000000..d302a1b7
--- /dev/null
+++ b/HaRepacker/Converter/PointFConverter.cs
@@ -0,0 +1,34 @@
+using HaRepacker.GUI.Controls;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HaRepacker.Converter {
+ public class PointFConverter : TypeConverter {
+ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) {
+ return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
+ if (value is string stringValue) {
+ string[] parts = stringValue.Split(',');
+ if (parts.Length == 2 && float.TryParse(parts[0], out float x) && float.TryParse(parts[1], out float y)) {
+ return new NotifyPointF(x, y);
+ }
+ }
+ return base.ConvertFrom(context, culture, value);
+ }
+
+ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {
+ if (destinationType == typeof(string) && value is NotifyPointF point) {
+ return $"{point.X},{point.Y}";
+ }
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+ }
+}
diff --git a/HaRepacker/Converter/PointFOriginToStringConverter.cs b/HaRepacker/Converter/PointFOriginToStringConverter.cs
index 27457d84..46a128af 100644
--- a/HaRepacker/Converter/PointFOriginToStringConverter.cs
+++ b/HaRepacker/Converter/PointFOriginToStringConverter.cs
@@ -6,6 +6,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+using HaRepacker.GUI.Controls;
using System;
using System.Collections.Generic;
using System.Drawing;
@@ -23,14 +24,14 @@ public class PointFOriginToStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
- PointF point = (PointF)value;
+ NotifyPointF point = (PointF)value;
return string.Format("X {0}, Y {1}", point.X, point.Y);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
- return new PointF(0,0); // anyway wtf
+ return new NotifyPointF(0,0); // anyway wtf
}
}
}
diff --git a/HaRepacker/Converter/PointFToVisiblityConverter.cs b/HaRepacker/Converter/PointFToVisiblityConverter.cs
index 7d3c9abe..71edb72c 100644
--- a/HaRepacker/Converter/PointFToVisiblityConverter.cs
+++ b/HaRepacker/Converter/PointFToVisiblityConverter.cs
@@ -5,6 +5,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+using HaRepacker.GUI.Controls;
using System;
using System.Collections.Generic;
using System.Drawing;
@@ -25,7 +26,7 @@ public class PointFToVisiblityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
- PointF point = (PointF)value;
+ NotifyPointF point = (NotifyPointF)value;
if (point.X == 0 && point.Y == 0)
return Visibility.Collapsed;
@@ -35,7 +36,7 @@ public object Convert(object value, Type targetType, object parameter, System.Gl
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
- return new PointF(0, 0); // anyway wtf
+ return new NotifyPointF(0, 0); // anyway wtf
}
}
}
diff --git a/HaRepacker/Converter/PointFValueConverter.cs b/HaRepacker/Converter/PointFValueConverter.cs
new file mode 100644
index 00000000..56621413
--- /dev/null
+++ b/HaRepacker/Converter/PointFValueConverter.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+
+namespace HaRepacker.Converter {
+ public class PointFValueConverter : IValueConverter {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
+ return value;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
+ return value;
+ }
+ }
+}
diff --git a/HaRepacker/Converter/VectorOriginPointFToMarginConverter.cs b/HaRepacker/Converter/VectorOriginPointFToMarginConverter.cs
index db235d8e..c5bd9269 100644
--- a/HaRepacker/Converter/VectorOriginPointFToMarginConverter.cs
+++ b/HaRepacker/Converter/VectorOriginPointFToMarginConverter.cs
@@ -5,6 +5,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+using HaRepacker.GUI.Controls;
using HaRepacker.Utils;
using System;
using System.Collections.Generic;
@@ -26,7 +27,7 @@ public class VectorOriginPointFToMarginConverter : IValueConverter
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
- PointF originValue = (PointF)value;
+ NotifyPointF originValue = (NotifyPointF)value;
// converted
// its always -50, as it is 50px wide, as specified in the xaml
@@ -41,7 +42,7 @@ public object ConvertBack(object value, Type targetType, object parameter, Syste
Thickness value_ = (Thickness)value;
// converted
- PointF originValue = new PointF((float) ((value_.Left) * ScreenDPIUtil.GetScreenScaleFactor()), (float) ((value_.Top + fCrossHairWidthHeight) * ScreenDPIUtil.GetScreenScaleFactor()));
+ PointF originValue = new NotifyPointF((float) ((value_.Left) * ScreenDPIUtil.GetScreenScaleFactor()), (float) ((value_.Top + fCrossHairWidthHeight) * ScreenDPIUtil.GetScreenScaleFactor()));
return originValue;
}
}
diff --git a/HaRepacker/GUI/AboutForm.Designer.cs b/HaRepacker/GUI/AboutForm.Designer.cs
index 391973e6..c3b3a352 100644
--- a/HaRepacker/GUI/AboutForm.Designer.cs
+++ b/HaRepacker/GUI/AboutForm.Designer.cs
@@ -35,6 +35,7 @@ private void InitializeComponent()
this.label4 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.label5 = new System.Windows.Forms.Label();
+ this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.SuspendLayout();
//
// label1
@@ -69,10 +70,18 @@ private void InitializeComponent()
resources.ApplyResources(this.label5, "label5");
this.label5.Name = "label5";
//
+ // linkLabel1
+ //
+ resources.ApplyResources(this.linkLabel1, "linkLabel1");
+ this.linkLabel1.Name = "linkLabel1";
+ this.linkLabel1.TabStop = true;
+ this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
+ //
// AboutForm
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.linkLabel1);
this.Controls.Add(this.label5);
this.Controls.Add(this.button1);
this.Controls.Add(this.label4);
@@ -82,6 +91,7 @@ private void InitializeComponent()
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "AboutForm";
this.ResumeLayout(false);
+ this.PerformLayout();
}
@@ -93,5 +103,6 @@ private void InitializeComponent()
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label5;
+ private System.Windows.Forms.LinkLabel linkLabel1;
}
}
\ No newline at end of file
diff --git a/HaRepacker/GUI/AboutForm.cs b/HaRepacker/GUI/AboutForm.cs
index 02a7aa6a..9f325c85 100644
--- a/HaRepacker/GUI/AboutForm.cs
+++ b/HaRepacker/GUI/AboutForm.cs
@@ -42,5 +42,19 @@ private void button1_Click(object sender, EventArgs e)
{
Close();
}
+
+ ///
+ /// Hyperlink
+ ///
+ ///
+ ///
+ private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
+ try {
+ System.Diagnostics.Process.Start(linkLabel1.Text);
+ }
+ catch (Exception ex) {
+ MessageBox.Show($"An error occurred: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
}
}
diff --git a/HaRepacker/GUI/AboutForm.resx b/HaRepacker/GUI/AboutForm.resx
index 782f34db..7bc7eeea 100644
--- a/HaRepacker/GUI/AboutForm.resx
+++ b/HaRepacker/GUI/AboutForm.resx
@@ -147,7 +147,7 @@
$this
- 5
+ 6
12, 50
@@ -174,7 +174,7 @@
$this
- 4
+ 5
12, 73
@@ -203,7 +203,7 @@
$this
- 3
+ 4
12, 98
@@ -231,7 +231,7 @@ Copyright (C) 2009-2015 haha01haha01
$this
- 2
+ 3
211, 297
@@ -255,23 +255,26 @@ Copyright (C) 2009-2015 haha01haha01
$this
- 1
+ 2
+
+
+ True
NoControl
- 12, 191
+ 114, 242
- 563, 75
+ 49, 13
5
- A fork~ https://github.com/lastbattle
+ A fork~
MiddleCenter
@@ -286,6 +289,33 @@ Copyright (C) 2009-2015 haha01haha01
$this
+ 1
+
+
+ True
+
+
+ 169, 242
+
+
+ 280, 13
+
+
+ 6
+
+
+ https://github.com/lastbattle/Harepacker-resurrected
+
+
+ linkLabel1
+
+
+ System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ $this
+
+
0
diff --git a/HaRepacker/GUI/Controls/NotifyPointF.cs b/HaRepacker/GUI/Controls/NotifyPointF.cs
new file mode 100644
index 00000000..35d90ff9
--- /dev/null
+++ b/HaRepacker/GUI/Controls/NotifyPointF.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HaRepacker.GUI.Controls {
+ ///
+ /// Custom PointF struct that implements INotifyPropertyChanged for PropertyView
+ ///
+ public class NotifyPointF : INotifyPropertyChanged {
+ private float _x;
+ private float _y;
+
+ public float X {
+ get => _x;
+ set {
+ if (_x != value) {
+ _x = value;
+ OnPropertyChanged(nameof(X));
+ }
+ }
+ }
+
+ public float Y {
+ get => _y;
+ set {
+ if (_y != value) {
+ _y = value;
+ OnPropertyChanged(nameof(Y));
+ }
+ }
+ }
+
+ public NotifyPointF(float x, float y) {
+ _x = x;
+ _y = y;
+ }
+ public NotifyPointF(PointF f) {
+ _x = f.X;
+ _y = f.Y;
+ }
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ private void OnPropertyChanged(string propertyName) {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+
+ public static implicit operator PointF(NotifyPointF point) => new PointF(point.X, point.Y);
+ public static implicit operator NotifyPointF(PointF point) => new NotifyPointF(point.X, point.Y);
+ }
+}
diff --git a/HaRepacker/GUI/Controls/PointFEditor.cs b/HaRepacker/GUI/Controls/PointFEditor.cs
new file mode 100644
index 00000000..bf2e486d
--- /dev/null
+++ b/HaRepacker/GUI/Controls/PointFEditor.cs
@@ -0,0 +1,27 @@
+using HaRepacker.Converter;
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Globalization;
+using System.Windows;
+using System.Windows.Data;
+using Xceed.Wpf.Toolkit.PropertyGrid;
+using Xceed.Wpf.Toolkit.PropertyGrid.Editors;
+
+namespace HaRepacker.GUI.Controls {
+
+ public class PointFEditor : TypeEditor {
+ protected override void SetValueDependencyProperty() {
+ ValueProperty = PointFEditorControl.PointFProperty;
+ }
+
+ protected override void SetControlProperties(PropertyItem propertyItem) {
+ base.SetControlProperties(propertyItem);
+ Editor.IsReadOnly = propertyItem.IsReadOnly;
+ }
+
+ protected override IValueConverter CreateValueConverter() {
+ return new PointFValueConverter();
+ }
+ }
+}
\ No newline at end of file
diff --git a/HaRepacker/GUI/Controls/PointFEditorControl.cs b/HaRepacker/GUI/Controls/PointFEditorControl.cs
new file mode 100644
index 00000000..cc0d632c
--- /dev/null
+++ b/HaRepacker/GUI/Controls/PointFEditorControl.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace HaRepacker.GUI.Controls {
+ ///
+ /// A custom control to make PointF editable.
+ ///
+ public class PointFEditorControl : Control {
+ public static readonly DependencyProperty PointFProperty =
+ DependencyProperty.Register(nameof(PointF), typeof(NotifyPointF), typeof(PointFEditorControl),
+ new FrameworkPropertyMetadata(new NotifyPointF(0, 0), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
+
+ public static readonly DependencyProperty IsReadOnlyProperty =
+ DependencyProperty.Register(nameof(IsReadOnly), typeof(bool), typeof(PointFEditorControl), new PropertyMetadata(false));
+
+ public NotifyPointF PointF {
+ get {
+ return (NotifyPointF)GetValue(PointFProperty);
+ }
+ set {
+ SetValue(PointFProperty, value);
+ }
+ }
+
+ public bool IsReadOnly {
+ get {
+ return (bool)GetValue(IsReadOnlyProperty);
+ }
+ set {
+ SetValue(IsReadOnlyProperty, value);
+ }
+ }
+
+ static PointFEditorControl() {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(PointFEditorControl), new FrameworkPropertyMetadata(typeof(PointFEditorControl)));
+ }
+ }
+}
\ No newline at end of file
diff --git a/HaRepacker/GUI/Panels/MainPanel.xaml b/HaRepacker/GUI/Panels/MainPanel.xaml
index cb56b88a..ac2c012a 100644
--- a/HaRepacker/GUI/Panels/MainPanel.xaml
+++ b/HaRepacker/GUI/Panels/MainPanel.xaml
@@ -272,9 +272,9 @@
-
+
-
+
@@ -371,7 +371,7 @@
-
+
actions = new List(); // Undo action
- ChangeCanvasPropBoxImage(bmp);
+ if (bitmapBytes != null) {
+ MemoryStream ms = new MemoryStream(bitmapBytes); // dont close this
+ System.Drawing.Bitmap newBitmap = new System.Drawing.Bitmap(ms);
+
+ ChangeCanvasPropBoxImage(newBitmap);
+ }
}
}
@@ -944,17 +954,18 @@ private void MenuItem_changeImage_Click(object sender, RoutedEventArgs e)
///
///
///
- private void ChangeCanvasPropBoxImage(Bitmap bmp)
+ public void ChangeCanvasPropBoxImage(Bitmap bmp)
{
if (DataTree.SelectedNode.Tag is WzCanvasProperty property)
{
+ WzNode parentCanvasNode = (WzNode)DataTree.SelectedNode;
+
WzCanvasProperty selectedWzCanvas = property;
if (selectedWzCanvas.ContainsInlinkProperty()) // if its an inlink property, remove that before updating base image.
{
selectedWzCanvas.RemoveProperty(selectedWzCanvas[WzCanvasProperty.InlinkPropertyName]);
- WzNode parentCanvasNode = (WzNode)DataTree.SelectedNode;
WzNode childInlinkNode = WzNode.GetChildNode(parentCanvasNode, WzCanvasProperty.InlinkPropertyName);
// Add undo actions
@@ -968,7 +979,6 @@ private void ChangeCanvasPropBoxImage(Bitmap bmp)
{
selectedWzCanvas.RemoveProperty(selectedWzCanvas[WzCanvasProperty.OutlinkPropertyName]);
- WzNode parentCanvasNode = (WzNode)DataTree.SelectedNode;
WzNode childInlinkNode = WzNode.GetChildNode(parentCanvasNode, WzCanvasProperty.OutlinkPropertyName);
// Add undo actions
@@ -978,10 +988,18 @@ private void ChangeCanvasPropBoxImage(Bitmap bmp)
selectedWzCanvas.PngProperty.SetImage(bmp);
- // Updates
- selectedWzCanvas.ParentImage.Changed = true;
+ canvasPropBox.SetIsLoading(true);
+ try {
+ canvasPropBox.BindingPropertyItem.Bitmap = bmp;
+ canvasPropBox.BindingPropertyItem.BitmapBackup = bmp;
+ }
+ finally {
+ canvasPropBox.SetIsLoading(false);
+ }
- canvasPropBox.Image = bmp.ToWpfBitmap();
+ // flag changed for saving updates
+ // and also node foreground color
+ parentCanvasNode.ChangedNodeProperty();
// Add undo actions
//UndoRedoMan.AddUndoBatch(actions);
@@ -999,8 +1017,10 @@ private void RefreshSelectedImageToImageRenderviewer(object selectedTreeNode, Im
if (selectedTreeNode is WzCanvasProperty) // only allow button click if its an image property
{
System.Drawing.Image img = ((WzCanvasProperty)(selectedTreeNode))?.GetLinkedWzCanvasBitmap();
- if (img != null)
- canvasPropBox.Image = ((System.Drawing.Bitmap)img).ToWpfBitmap();
+ if (img != null) {
+ canvasPropBox.BindingPropertyItem.Bitmap = (Bitmap)img;
+ canvasPropBox.BindingPropertyItem.BitmapBackup = (Bitmap)img;
+ }
}
}
@@ -1289,9 +1309,12 @@ private void UpscaleImageNodesRecursively(WzNode node, Dictionary(bitmap, property, node));
+ toUpscaleImageDictionary.Add(property.FullPath.GetHashCode().ToString(), new Tuple(bitmap, property, node));
+ }
}
}
else {
@@ -1766,15 +1789,18 @@ private void ShowObjectValue(WzObject obj)
menuItem_saveImage.Visibility = Visibility.Visible;
// Image
- if (canvasProp.ContainsInlinkProperty() || canvasProp.ContainsOutlinkProperty())
- {
+ if (canvasProp.ContainsInlinkProperty() || canvasProp.ContainsOutlinkProperty()) {
System.Drawing.Image img = canvasProp.GetLinkedWzCanvasBitmap();
- if (img != null)
- canvasPropBox.Image = ((System.Drawing.Bitmap)img).ToWpfBitmap();
+ if (img != null) {
+ canvasPropBox.BindingPropertyItem.Bitmap = (System.Drawing.Bitmap)img;
+ canvasPropBox.BindingPropertyItem.BitmapBackup = (System.Drawing.Bitmap)img;
+ }
+ }
+ else {
+ Bitmap bmp = canvasProp.GetLinkedWzCanvasBitmap();
+ canvasPropBox.BindingPropertyItem.Bitmap = bmp;
+ canvasPropBox.BindingPropertyItem.BitmapBackup = bmp;
}
- else
- canvasPropBox.Image = canvasProp.GetLinkedWzCanvasBitmap().ToWpfBitmap();
-
SetImageRenderView(canvasProp);
}
else if (obj is WzUOLProperty uolProperty)
@@ -1786,7 +1812,11 @@ private void ShowObjectValue(WzObject obj)
if (linkValue is WzCanvasProperty canvasUOL)
{
canvasPropBox.Visibility = Visibility.Visible;
- canvasPropBox.Image = canvasUOL.GetLinkedWzCanvasBitmap().ToWpfBitmap(); // in any event that the WzCanvasProperty is an '_inlink' or '_outlink'
+
+ Bitmap bmp = canvasUOL.GetLinkedWzCanvasBitmap();
+ canvasPropBox.BindingPropertyItem.Bitmap = bmp; // in any event that the WzCanvasProperty is an '_inlink' or '_outlink'
+ canvasPropBox.BindingPropertyItem.BitmapBackup = bmp; // in any event that the WzCanvasProperty is an '_inlink' or '_outlink'
+
menuItem_saveImage.Visibility = Visibility.Visible; // dont show change image, as its a UOL
SetImageRenderView(canvasUOL);
@@ -2007,15 +2037,23 @@ private void SetImageRenderView(WzCanvasProperty canvas)
PointF headVector = canvas.GetCanvasHeadPosition();
PointF ltVector = canvas.GetCanvasLtPosition();
- // Set XY point to canvas xaml
- canvasPropBox.ParentWzCanvasProperty = canvas;
- canvasPropBox.Delay = delay ?? 0;
- canvasPropBox.CanvasVectorOrigin = originVector;
- canvasPropBox.CanvasVectorHead = headVector;
- canvasPropBox.CanvasVectorLt = ltVector;
+ canvasPropBox.SetIsLoading(true);
+ try {
+ canvasPropBox.SetParentMainPanel(this);
+
+ // Set XY point to canvas xaml
+ canvasPropBox.BindingPropertyItem.ParentWzCanvasProperty = canvas;
+ canvasPropBox.BindingPropertyItem.Delay = delay ?? 0;
+ canvasPropBox.BindingPropertyItem.CanvasVectorOrigin = new NotifyPointF(originVector);
+ canvasPropBox.BindingPropertyItem.CanvasVectorHead = new NotifyPointF(headVector);
+ canvasPropBox.BindingPropertyItem.CanvasVectorLt = new NotifyPointF(ltVector);
- if (canvasPropBox.Visibility != Visibility.Visible)
- canvasPropBox.Visibility = Visibility.Visible;
+ if (canvasPropBox.Visibility != Visibility.Visible)
+ canvasPropBox.Visibility = Visibility.Visible;
+ }
+ finally {
+ canvasPropBox.SetIsLoading(false);
+ }
}
#endregion
diff --git a/HaRepacker/GUI/Panels/SubPanels/ImageRenderViewer.xaml b/HaRepacker/GUI/Panels/SubPanels/ImageRenderViewer.xaml
index c5bf55f6..284c1fe6 100644
--- a/HaRepacker/GUI/Panels/SubPanels/ImageRenderViewer.xaml
+++ b/HaRepacker/GUI/Panels/SubPanels/ImageRenderViewer.xaml
@@ -4,10 +4,12 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:HaRepacker.GUI.Panels.SubPanels"
+ xmlns:guiControls="clr-namespace:HaRepacker.GUI.Controls"
+ xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:converter="clr-namespace:HaRepacker.Converter"
mc:Ignorable="d"
- d:DesignHeight="250" d:DesignWidth="400">
+ d:DesignHeight="400" d:DesignWidth="600">
@@ -466,6 +468,24 @@
+
+
+
@@ -495,12 +515,6 @@
-
-
-
-
-
-
@@ -510,8 +524,12 @@
+
+
+
+
-
@@ -521,7 +539,7 @@
Height="{Binding ImageHeight, Converter={StaticResource imageWidthOrHeightToScreenDPIConverter}}"
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="80,50,0,0">
-
+ Visibility="{Binding ShowImageBorder, Converter={StaticResource checkboxToVisibilityConverter}}">
-
+
-
+
-
-
+
@@ -590,7 +606,7 @@
@@ -605,7 +621,7 @@
@@ -620,174 +636,49 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
-
-
-
+
+
/// Interaction logic for ImageRenderViewer.xaml
///
- public partial class ImageRenderViewer : UserControl, INotifyPropertyChanged
+ public partial class ImageRenderViewer : UserControl
{
private bool isLoading = false;
+ private MainPanel mainPanel;
+
+ private ImageRenderViewerItem _bindingPropertyItem = new ImageRenderViewerItem();
+ public ImageRenderViewerItem BindingPropertyItem {
+ get { return _bindingPropertyItem; }
+ private set { }
+ }
+
public ImageRenderViewer()
{
isLoading = true; // set isloading
@@ -39,405 +50,208 @@ public ImageRenderViewer()
VisualStateManager.GoToState(this, "BlackTheme", false);
}
- this.DataContext = this; // set data binding to self.
+ this.DataContext = _bindingPropertyItem; // set data binding
+ _bindingPropertyItem.PropertyChanged += ImgPropertyItem_PropertyChanged; // on propertygrid property changed
+
Loaded += ImageRenderViewer_Loaded;
}
+ public void SetIsLoading(bool bIsLoading) {
+ this.isLoading = bIsLoading;
+ }
+ public void SetParentMainPanel(MainPanel panel) {
+ this.mainPanel = panel;
+ }
+
+
///
/// When the page loads
///
///
///
- private void ImageRenderViewer_Loaded(object sender, RoutedEventArgs e)
- {
- try
- {
+ private void ImageRenderViewer_Loaded(object sender, RoutedEventArgs e) {
+ try {
// Set via app settings
- checkbox_crosshair.IsChecked = Program.ConfigurationManager.UserSettings.EnableCrossHairDebugInformation;
- checkbox_border.IsChecked = Program.ConfigurationManager.UserSettings.EnableBorderDebugInformation;
+ _bindingPropertyItem.ShowCrosshair = Program.ConfigurationManager.UserSettings.EnableCrossHairDebugInformation;
+ _bindingPropertyItem.ShowImageBorder = Program.ConfigurationManager.UserSettings.EnableBorderDebugInformation;
ZoomSlider.Value = Program.ConfigurationManager.UserSettings.ImageZoomLevel;
- } finally
- {
- isLoading = false;
- }
- }
-
- #region Exported Fields
- private WzCanvasProperty _ParentWzCanvasProperty = null;
- ///
- /// The parent WZCanvasProperty to display from
- ///
- public WzCanvasProperty ParentWzCanvasProperty
- {
- get { return _ParentWzCanvasProperty; }
- set
- {
- _ParentWzCanvasProperty = value;
- }
- }
-
- private ImageSource _Image = null;
- ///
- /// The image to display on the canvas
- ///
- public ImageSource Image
- {
- get { return _Image; }
- set
- {
- _Image = value;
- OnPropertyChanged("Image");
-
- // Update image width and height too.
- ImageWidth = _Image.Width;
- ImageHeight = _Image.Height;
- }
- }
-
- private int _Delay = 0;
- ///
- /// Delay of the image
- ///
- public int Delay
- {
- get { return _Delay; }
- set
- {
- _Delay = value;
- OnPropertyChanged("Delay");
-
- textbox_delay.Text = _Delay.ToString();
- }
- }
-
- private PointF _CanvasVectorOrigin = new PointF(0, 0);
- ///
- /// Origin to center the crosshair
- ///
- public PointF CanvasVectorOrigin
- {
- get { return _CanvasVectorOrigin; }
- set
- {
- _CanvasVectorOrigin = value;
- OnPropertyChanged("CanvasVectorOrigin");
-
- textbox_originX.Text = _CanvasVectorOrigin.X.ToString();
- textbox_originY.Text = _CanvasVectorOrigin.Y.ToString();
- }
- }
-
- private PointF _CanvasVectorHead = new PointF(0, 0);
- ///
- /// Head vector (Hit positioning for mobs?)
- ///
- public PointF CanvasVectorHead
- {
- get { return _CanvasVectorHead; }
- set
- {
- _CanvasVectorHead = value;
- OnPropertyChanged("CanvasVectorHead");
-
- textbox_headX.Text = _CanvasVectorHead.X.ToString();
- textbox_headY.Text = _CanvasVectorHead.Y.ToString();
}
- }
-
- private PointF _CanvasVectorLt = new PointF(0, 0);
- ///
- /// lt vector
- ///
- public PointF CanvasVectorLt
- {
- get { return _CanvasVectorLt; }
- set
- {
- _CanvasVectorLt = value;
- OnPropertyChanged("CanvasVectorLt");
-
- textbox_ltX.Text = _CanvasVectorLt.X.ToString();
- textbox_ltY.Text = _CanvasVectorLt.Y.ToString();
- }
- }
-
- private double _ImageWidth = 0;
- ///
- /// The width of the image currently displayed on the canvas
- ///
- public double ImageWidth
- {
- get { return _ImageWidth; }
- set {
- this._ImageWidth = value;
- OnPropertyChanged("ImageWidth");
+ finally {
+ isLoading = false;
}
}
- private double _ImageHeight = 0;
- ///
- /// The Height of the image currently displayed on the canvas
- ///
- public double ImageHeight
- {
- get { return _ImageHeight; }
- set {
- this._ImageHeight = value;
- OnPropertyChanged("ImageHeight");
- }
- }
- #endregion
-
- #region Property Changed
- ///
- /// Property changed event handler to trigger update UI
- ///
- public event PropertyChangedEventHandler PropertyChanged;
- protected virtual void OnPropertyChanged(string propertyName)
- {
- PropertyChangedEventHandler handler = PropertyChanged;
- if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
- }
- #endregion
-
#region UI Events
- ///
- /// Checkbox for crosshair
- ///
- ///
- ///
- private void checkbox_crosshair_Checked(object sender, RoutedEventArgs e)
- {
- if (isLoading)
- return;
-
- CheckBox checkbox = (CheckBox)sender;
- if (checkbox.IsChecked == true)
- {
- Program.ConfigurationManager.UserSettings.EnableCrossHairDebugInformation = true;
- } else
- {
- Program.ConfigurationManager.UserSettings.EnableCrossHairDebugInformation = false;
- }
- }
///
- /// Checkbox for Border
+ /// Image zoom level on value changed
///
///
///
- private void checkbox_border_Checked(object sender, RoutedEventArgs e)
+ private void ZoomSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
{
if (isLoading)
return;
- CheckBox checkbox = (CheckBox)sender;
- if (checkbox.IsChecked == true)
- {
- Program.ConfigurationManager.UserSettings.EnableBorderDebugInformation = true;
- }
- else
- {
- Program.ConfigurationManager.UserSettings.EnableBorderDebugInformation = false;
- }
+ Slider zoomSlider = (Slider)sender;
+ Program.ConfigurationManager.UserSettings.ImageZoomLevel = zoomSlider.Value;
}
- ///
- /// 'lt' value changed
- ///
- ///
- ///
- private void textbox_lt_TextChanged(object sender, TextChangedEventArgs e)
- {
- if (isLoading)
- return;
-
- button_ltEdit.IsEnabled = true;
- }
+ private bool bBorderDragging = false;
- ///
- /// 'head' value changed
- ///
- ///
- ///
- private void textbox_head_TextChanged(object sender, TextChangedEventArgs e)
+ private void Rectangle_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
- if (isLoading)
- return;
+ bBorderDragging = true;
+ Rectangle_MouseMove(sender, e);
- button_headEdit.IsEnabled = true;
+ System.Diagnostics.Debug.WriteLine("Mouse left button down");
}
- ///
- /// 'vector' value changed
- ///
- ///
- ///
- private void textbox_origin_TextChanged(object sender, TextChangedEventArgs e)
+ private void Rectangle_MouseMove(object sender, MouseEventArgs e)
{
- if (isLoading)
- return;
-
- button_originEdit.IsEnabled = true;
+ if (bBorderDragging)
+ {
+ // dragMove
+ System.Diagnostics.Debug.WriteLine("Mouse drag move");
+ }
}
- ///
- /// 'delay' valeu changed
- ///
- ///
- ///
- private void textbox_delay_TextChanged(object sender, TextChangedEventArgs e)
+ private void Rectangle_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
- if (isLoading)
- return;
+ bBorderDragging = false;
- button_delayEdit.IsEnabled = true;
+ System.Diagnostics.Debug.WriteLine("Mouse left button up");
}
///
- /// Easy access to editing image 'lt' properties
+ /// On propertygrid property changed
///
///
///
- private void button_ltEdit_Click(object sender, RoutedEventArgs e)
- {
- if (isLoading)
+ private void ImgPropertyItem_PropertyChanged(object sender, PropertyChangedEventArgs e) {
+ if (isLoading) {
return;
-
- if (int.TryParse(textbox_ltX.Text, out int newX) && int.TryParse(textbox_ltY.Text, out int newY))
- {
- WzVectorProperty vectorProp = _ParentWzCanvasProperty[WzCanvasProperty.LtPropertyName] as WzVectorProperty;
- if (vectorProp != null)
- {
- vectorProp.X.Value = newX;
- vectorProp.Y.Value = newY;
-
- // Update local UI
- CanvasVectorLt = new PointF(newX, newY);
-
- button_ltEdit.IsEnabled = false;
- }
}
- }
- ///
- /// Easy access to editing image 'head' properties
- ///
- ///
- ///
- private void button_headEdit_Click(object sender, RoutedEventArgs e)
- {
- if (isLoading)
- return;
-
- if (int.TryParse(textbox_headX.Text, out int newX) && int.TryParse(textbox_headY.Text, out int newY))
- {
- WzVectorProperty vectorProp = _ParentWzCanvasProperty[WzCanvasProperty.HeadPropertyName] as WzVectorProperty;
- if (vectorProp != null)
- {
- vectorProp.X.Value = newX;
- vectorProp.Y.Value = newY;
-
- // Update local UI
- CanvasVectorHead = new PointF(newX, newY);
-
- button_headEdit.IsEnabled = false;
- }
+ switch (e.PropertyName) {
+ case "ShowCrosshair": {
+ if (_bindingPropertyItem.ShowCrosshair == true) {
+ Program.ConfigurationManager.UserSettings.EnableCrossHairDebugInformation = true;
+ }
+ else {
+ Program.ConfigurationManager.UserSettings.EnableCrossHairDebugInformation = false;
+ }
+ break;
+ }
+ case "ShowImageBorder": {
+ if (_bindingPropertyItem.ShowImageBorder == true) {
+ Program.ConfigurationManager.UserSettings.EnableBorderDebugInformation = true;
+ }
+ else {
+ Program.ConfigurationManager.UserSettings.EnableBorderDebugInformation = false;
+ }
+ break;
+ }
+ case "Delay": {
+ int newdelay = _bindingPropertyItem.Delay;
+ WzIntProperty intProperty = this._bindingPropertyItem.ParentWzCanvasProperty[WzCanvasProperty.AnimationDelayPropertyName] as WzIntProperty;
+ if (intProperty != null) {
+ intProperty.Value = newdelay;
+ }
+ break;
+ }
+ case "CanvasVectorOrigin": {
+ NotifyPointF CanvasVectorOrigin = this._bindingPropertyItem.CanvasVectorOrigin;
+
+ WzVectorProperty vectorProp = this._bindingPropertyItem.ParentWzCanvasProperty[WzCanvasProperty.OriginPropertyName] as WzVectorProperty;
+ if (vectorProp == null) {
+ vectorProp = new WzVectorProperty(WzCanvasProperty.OriginPropertyName, 0, 0);
+
+ this._bindingPropertyItem.ParentWzCanvasProperty.AddProperty(vectorProp);
+ this._bindingPropertyItem.ParentWzCanvasProperty.ParentImage.Changed = true;
+ }
+ vectorProp.X.Value = (int)CanvasVectorOrigin.X;
+ vectorProp.Y.Value = (int)CanvasVectorOrigin.Y;
+ break;
+ }
+ case "CanvasVectorHead": {
+ NotifyPointF vectorHead = this._bindingPropertyItem.CanvasVectorHead;
+
+ WzVectorProperty vectorProp = this._bindingPropertyItem.ParentWzCanvasProperty[WzCanvasProperty.HeadPropertyName] as WzVectorProperty;
+ if (vectorProp == null) {
+ vectorProp = new WzVectorProperty(WzCanvasProperty.HeadPropertyName, 0, 0);
+
+ this._bindingPropertyItem.ParentWzCanvasProperty.AddProperty(vectorProp);
+ this._bindingPropertyItem.ParentWzCanvasProperty.ParentImage.Changed = true;
+ }
+ vectorProp.X.Value = (int)vectorHead.X;
+ vectorProp.Y.Value = (int)vectorHead.Y;
+ break;
+ }
+ case "CanvasVectorLt": {
+ NotifyPointF vectorLt = this._bindingPropertyItem.CanvasVectorLt;
+
+ WzVectorProperty vectorProp = this._bindingPropertyItem.ParentWzCanvasProperty[WzCanvasProperty.LtPropertyName] as WzVectorProperty;
+ if (vectorProp == null) {
+ vectorProp = new WzVectorProperty(WzCanvasProperty.LtPropertyName, 0, 0);
+
+ this._bindingPropertyItem.ParentWzCanvasProperty.AddProperty(vectorProp);
+ this._bindingPropertyItem.ParentWzCanvasProperty.ParentImage.Changed = true;
+ }
+ vectorProp.X.Value = (int)vectorLt.X;
+ vectorProp.Y.Value = (int)vectorLt.Y;
+ break;
+ }
}
}
///
- /// Easy access to editing image 'delay' properties
+ /// Color picker -- image ARGB editor
///
///
///
- private void button_delayEdit_Click(object sender, RoutedEventArgs e)
- {
+ private void MyColorCanvas_SelectedColorChanged(object sender, RoutedPropertyChangedEventArgs e) {
if (isLoading)
return;
- if (int.TryParse(textbox_delay.Text, out int newdelay))
- {
- WzIntProperty intProperty = _ParentWzCanvasProperty[WzCanvasProperty.AnimationDelayPropertyName] as WzIntProperty;
- if (intProperty != null)
- {
- intProperty.Value = newdelay;
+ if (e.NewValue.HasValue) {
+ System.Windows.Media.Color selectedColor = e.NewValue.Value;
- // Update local UI
- Delay = newdelay;
+ if (selectedColor != null) {
+ //ColorDisplay.Fill = new SolidColorBrush(selectedColor);
- button_delayEdit.IsEnabled = false;
+ // set only the temporary "Image" object that only displays to the user
+ // while keeping the original copy until the user is ready to "apply"
+ _bindingPropertyItem.Bitmap = BitmapHelper.ApplyColorFilter(_bindingPropertyItem.BitmapBackup, selectedColor);
}
}
}
- ///
- /// Easy access to editing image 'origin' properties
- ///
- ///
- ///
- private void button_originEdit_Click(object sender, RoutedEventArgs e)
- {
+ private void button_filter_apply_Click(object sender, RoutedEventArgs e) {
if (isLoading)
return;
- if (int.TryParse(textbox_originX.Text, out int newX) && int.TryParse(textbox_originY.Text, out int newY))
- {
- WzVectorProperty vectorProp = _ParentWzCanvasProperty[WzCanvasProperty.OriginPropertyName] as WzVectorProperty;
- if (vectorProp != null)
- {
- vectorProp.X.Value = newX;
- vectorProp.Y.Value = newY;
-
- // Update local UI
- CanvasVectorOrigin = new PointF(newX, newY);
+ if (_bindingPropertyItem.Image != null) {
+ // re-calculate based on current ARGB and then apply
+ System.Windows.Media.Color? selectedColor = MyColorCanvas.SelectedColor;
+ if (selectedColor != null) {
+ _bindingPropertyItem.Bitmap = BitmapHelper.ApplyColorFilter(_bindingPropertyItem.BitmapBackup, selectedColor.Value);
- button_originEdit.IsEnabled = false;
+ mainPanel.ChangeCanvasPropBoxImage(_bindingPropertyItem.Bitmap);
}
}
}
- ///
- /// Image zoom level on value changed
- ///
- ///
- ///
- private void ZoomSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
- {
+ private void button_filter_reset_Click(object sender, RoutedEventArgs e) {
if (isLoading)
return;
- Slider zoomSlider = (Slider)sender;
- Program.ConfigurationManager.UserSettings.ImageZoomLevel = zoomSlider.Value;
- }
-
- private bool bBorderDragging = false;
-
- private void Rectangle_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- bBorderDragging = true;
- Rectangle_MouseMove(sender, e);
-
- System.Diagnostics.Debug.WriteLine("Mouse left button down");
- }
-
- private void Rectangle_MouseMove(object sender, MouseEventArgs e)
- {
- if (bBorderDragging)
- {
- // dragMove
- System.Diagnostics.Debug.WriteLine("Mouse drag move");
+ if (_bindingPropertyItem.Bitmap != null) {
+ _bindingPropertyItem.Bitmap = _bindingPropertyItem.BitmapBackup;
}
}
-
- private void Rectangle_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
- {
- bBorderDragging = false;
-
- System.Diagnostics.Debug.WriteLine("Mouse left button up");
- }
#endregion
}
}
diff --git a/HaRepacker/GUI/Panels/SubPanels/ImageRenderViewerItem.cs b/HaRepacker/GUI/Panels/SubPanels/ImageRenderViewerItem.cs
new file mode 100644
index 00000000..9d748d2c
--- /dev/null
+++ b/HaRepacker/GUI/Panels/SubPanels/ImageRenderViewerItem.cs
@@ -0,0 +1,262 @@
+using HaRepacker.Converter;
+using HaRepacker.GUI.Controls;
+using MapleLib.Converters;
+using MapleLib.WzLib.WzProperties;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Media;
+
+namespace HaRepacker.GUI.Panels.SubPanels {
+
+ ///
+ /// Items in the PropertyGrid
+ /// see: https://github.com/xceedsoftware/wpftoolkit/wiki/PropertyGrid
+ ///
+ public class ImageRenderViewerItem : INotifyPropertyChanged {
+ private const string CATEGORY_DISPLAY = "Display";
+ private const string CATEGORY_IMAGEINFO = "Image information";
+ private const string CATEGORY_ANIMATION = "Animation";
+
+ public ImageRenderViewerItem() {
+ _CanvasVectorOrigin.PropertyChanged += (sender, args) => OnPropertyChanged(nameof(CanvasVectorOrigin));
+ _CanvasVectorHead.PropertyChanged += (sender, args) => OnPropertyChanged(nameof(CanvasVectorHead));
+ _CanvasVectorLt.PropertyChanged += (sender, args) => OnPropertyChanged(nameof(CanvasVectorLt));
+ }
+
+ #region Display
+
+ private bool _bShowImageBorder;
+ [Category(CATEGORY_DISPLAY)]
+ [Description("Shows the image border")]
+ [DisplayName("Border")]
+ public bool ShowImageBorder {
+ get => _bShowImageBorder;
+ set {
+ if (_bShowImageBorder != value) {
+ _bShowImageBorder = value;
+ OnPropertyChanged(nameof(ShowImageBorder));
+ }
+ }
+ }
+
+ private bool _bShowCrosshair;
+ [Category(CATEGORY_DISPLAY)]
+ [Description("Show crosshair")]
+ [DisplayName("Crosshair")]
+ public bool ShowCrosshair {
+ get => _bShowCrosshair;
+ set {
+ if (_bShowCrosshair != value) {
+ _bShowCrosshair = value;
+ OnPropertyChanged(nameof(ShowCrosshair));
+ }
+ }
+ }
+ #endregion
+
+ #region Image information
+ private WzCanvasProperty _ParentWzCanvasProperty = null;
+ ///
+ /// The parent WZCanvasProperty to display from
+ ///
+ [ReadOnly(true)] // This makes the Name property read-only
+ [Browsable(false)] // This hides the ID property from the PropertyGrid
+ public WzCanvasProperty ParentWzCanvasProperty {
+ get { return _ParentWzCanvasProperty; }
+ set {
+ _ParentWzCanvasProperty = value;
+ }
+ }
+
+ private ImageSource _Image = null;
+ ///
+ /// The image to display on the canvas
+ ///
+ [ReadOnly(true)] // This makes the Name property read-only
+ [Browsable(false)] // This hides the ID property from the PropertyGrid
+ [DisplayName("Image")]
+ [Category(CATEGORY_IMAGEINFO)]
+ public ImageSource Image {
+ get { return _Image; }
+ set {
+ _Image = value;
+ OnPropertyChanged(nameof(Image));
+
+ // Update image width and height too.
+ ImageWidth = (int) _Image.Width;
+ ImageHeight = (int)_Image.Height;
+ }
+ }
+
+ private Bitmap _Bitmap = null;
+ private Bitmap _Bitmap_bak = null;
+ ///
+ /// The image to display on the canvas
+ ///
+ [ReadOnly(true)] // This makes the Name property read-only
+ [Browsable(false)] // This hides the ID property from the PropertyGrid
+ [DisplayName("Bitmap")]
+ [Category(CATEGORY_IMAGEINFO)]
+ public Bitmap Bitmap {
+ get { return _Bitmap; }
+ set {
+ _Bitmap = value;
+ OnPropertyChanged(nameof(Bitmap));
+
+ Image = _Bitmap.ToWpfBitmap();
+ }
+ }
+
+ [ReadOnly(true)] // This makes the Name property read-only
+ [Browsable(false)] // This hides the ID property from the PropertyGrid
+ public Bitmap BitmapBackup {
+ get { return _Bitmap_bak; }
+ set {
+ _Bitmap_bak = value;
+ }
+ }
+
+ private int _ImageWidth = 0;
+ ///
+ /// The width of the image currently displayed on the canvas
+ ///
+ [ReadOnly(true)] // This makes the Name property read-only
+ [DisplayName("Image Width")]
+ [Category(CATEGORY_IMAGEINFO)]
+ public int ImageWidth {
+ get { return _ImageWidth; }
+ set {
+ this._ImageWidth = value;
+ OnPropertyChanged(nameof(ImageWidth));
+ }
+ }
+
+ private int _ImageHeight = 0;
+ ///
+ /// The Height of the image currently displayed on the canvas
+ ///
+ [ReadOnly(true)] // This makes the Name property read-only
+ [DisplayName("Image Height")]
+ [Category(CATEGORY_IMAGEINFO)]
+ public int ImageHeight {
+ get { return _ImageHeight; }
+ set {
+ this._ImageHeight = value;
+ OnPropertyChanged(nameof(ImageHeight));
+ }
+ }
+ #endregion
+
+ #region Animation
+ private int _Delay = 0;
+
+ ///
+ /// Delay of the image
+ ///
+ [Category(CATEGORY_ANIMATION)]
+ [DisplayName("Delay")]
+ [Description("The delay to display this animation.")]
+ public int Delay {
+ get { return _Delay; }
+ set {
+ _Delay = value;
+ OnPropertyChanged(nameof(Delay));
+ }
+ }
+
+ private NotifyPointF _CanvasVectorOrigin = new NotifyPointF(0, 0);
+ ///
+ /// Origin to center the crosshair
+ ///
+ [Category(CATEGORY_ANIMATION)]
+ [DisplayName("Origin")]
+ [Description("The X-Y origin coordinates.")]
+ [TypeConverter(typeof(PointFConverter))]
+ [Editor(typeof(PointFEditor), typeof(PointFEditor))]
+ public NotifyPointF CanvasVectorOrigin {
+ get { return _CanvasVectorOrigin; }
+ set {
+ if (_CanvasVectorOrigin != value) {
+ if (_CanvasVectorOrigin != null) {
+ _CanvasVectorOrigin.PropertyChanged -= (sender, args) => OnPropertyChanged(nameof(CanvasVectorOrigin));
+ }
+ _CanvasVectorOrigin = value;
+ if (_CanvasVectorOrigin != null) {
+ _CanvasVectorOrigin.PropertyChanged += (sender, args) => OnPropertyChanged(nameof(CanvasVectorOrigin));
+ }
+ OnPropertyChanged(nameof(CanvasVectorOrigin));
+ }
+ }
+ }
+
+ private NotifyPointF _CanvasVectorHead = new NotifyPointF(0, 0);
+
+ ///
+ /// Head vector (Hit positioning for mobs?)
+ ///
+ [Category(CATEGORY_ANIMATION)]
+ [DisplayName("Vector head")]
+ [Description("The X-Y vector head coordinate.")]
+ [TypeConverter(typeof(PointFConverter))]
+ [Editor(typeof(PointFEditor), typeof(PointFEditor))]
+ public NotifyPointF CanvasVectorHead {
+ get { return _CanvasVectorHead; }
+ set {
+ if (_CanvasVectorHead != value) {
+ if (_CanvasVectorHead != null) {
+ _CanvasVectorHead.PropertyChanged -= (sender, args) => OnPropertyChanged(nameof(CanvasVectorHead));
+ }
+ _CanvasVectorHead = value;
+ if (_CanvasVectorHead != null) {
+ _CanvasVectorHead.PropertyChanged += (sender, args) => OnPropertyChanged(nameof(CanvasVectorHead));
+ }
+ OnPropertyChanged(nameof(CanvasVectorHead));
+ }
+ }
+ }
+
+ private NotifyPointF _CanvasVectorLt = new NotifyPointF(0, 0);
+ ///
+ /// lt vector
+ ///
+ [Category(CATEGORY_ANIMATION)]
+ [DisplayName("Vector Lt")]
+ [Description("The X-Y vector Lt coordinate.")]
+ [TypeConverter(typeof(PointFConverter))]
+ [Editor(typeof(PointFEditor), typeof(PointFEditor))]
+ public NotifyPointF CanvasVectorLt {
+ get { return _CanvasVectorLt; }
+ set {
+ if (_CanvasVectorLt != value) {
+ if (_CanvasVectorLt != null) {
+ _CanvasVectorLt.PropertyChanged -= (sender, args) => OnPropertyChanged(nameof(CanvasVectorLt));
+ }
+ _CanvasVectorLt = value;
+ if (_CanvasVectorLt != null) {
+ _CanvasVectorLt.PropertyChanged += (sender, args) => OnPropertyChanged(nameof(CanvasVectorLt));
+ }
+ OnPropertyChanged(nameof(CanvasVectorLt));
+ }
+ }
+ }
+ #endregion
+
+
+ #region Events
+
+ public event PropertyChangedEventHandler PropertyChanged;
+ ///
+ /// On property changed
+ ///
+ ///
+ protected virtual void OnPropertyChanged(string propertyName) {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+ #endregion
+ }
+}
diff --git a/HaRepacker/Harepacker-resurrected.csproj b/HaRepacker/Harepacker-resurrected.csproj
index 010bfc99..af3a1c48 100644
--- a/HaRepacker/Harepacker-resurrected.csproj
+++ b/HaRepacker/Harepacker-resurrected.csproj
@@ -134,8 +134,8 @@
..\packages\AvalonEdit.6.3.0.90\lib\net462\ICSharpCode.AvalonEdit.dll
-
- ..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll
+
+ ..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll
..\packages\MonoGame.Framework.WindowsDX.3.8.0.1641\lib\net452\MonoGame.Framework.dll
@@ -208,12 +208,29 @@
..\packages\WpfAnimatedGif.2.0.2\lib\net40\WpfAnimatedGif.dll
+
+ ..\packages\Extended.Wpf.Toolkit.4.6.0\lib\net40\Xceed.Wpf.AvalonDock.dll
+
+
+ ..\packages\Extended.Wpf.Toolkit.4.6.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll
+
+
+ ..\packages\Extended.Wpf.Toolkit.4.6.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll
+
+
+ ..\packages\Extended.Wpf.Toolkit.4.6.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll
+
+
+ ..\packages\Extended.Wpf.Toolkit.4.6.0\lib\net40\Xceed.Wpf.Toolkit.dll
+
+
+
@@ -230,6 +247,9 @@
AboutForm.cs
+
+
+
Form
@@ -387,6 +407,7 @@
ImageRenderViewer.xaml
+
LoadingPanel.xaml
diff --git a/HaRepacker/packages.config b/HaRepacker/packages.config
index 7eb8fdd1..96599f6b 100644
--- a/HaRepacker/packages.config
+++ b/HaRepacker/packages.config
@@ -2,7 +2,8 @@
-
+
+
diff --git a/HaSharedLibrary/Util/BitmapHelper.cs b/HaSharedLibrary/Util/BitmapHelper.cs
index a618584c..06817e7a 100644
--- a/HaSharedLibrary/Util/BitmapHelper.cs
+++ b/HaSharedLibrary/Util/BitmapHelper.cs
@@ -1,6 +1,12 @@
using Microsoft.Xna.Framework.Graphics;
+using System;
+using System.Diagnostics;
using System.Drawing;
+using System.Drawing.Imaging;
using System.IO;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace HaSharedLibrary.Util
@@ -27,6 +33,28 @@ public static BitmapImage Convert(this Bitmap src, System.Drawing.Imaging.ImageF
}
}
+ ///
+ /// Takes a System.Windows.Media.ImageSource and converts it back to System.Drawing.Bitmap
+ ///
+ ///
+ ///
+ ///
+ public static Bitmap ConvertImageSourceToBitmap(this ImageSource imageSource) {
+ BitmapSource bitmapSource = imageSource as BitmapSource;
+ if (bitmapSource == null) {
+ throw new ArgumentException("ImageSource must be of type BitmapSource");
+ }
+
+ Bitmap bitmap;
+ using (MemoryStream outStream = new MemoryStream()) {
+ BitmapEncoder enc = new BmpBitmapEncoder();
+ enc.Frames.Add(BitmapFrame.Create(bitmapSource));
+ enc.Save(outStream);
+ bitmap = new Bitmap(outStream);
+ }
+ return bitmap;
+ }
+
public static Texture2D ToTexture2D(this System.Drawing.Bitmap bitmap, GraphicsDevice device)
{
if (bitmap == null)
@@ -41,5 +69,60 @@ public static Texture2D ToTexture2D(this System.Drawing.Bitmap bitmap, GraphicsD
return Texture2D.FromStream(device, s);
}
}
+
+ ///
+ /// Gets the image format extention from ImageFormat object i.e Png returns "png"
+ ///
+ ///
+ ///
+ public static string GetImageFormatExtension(ImageFormat imageFormat) {
+ // Get all image encoders
+ ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
+
+ // Find the codec with the matching format
+ foreach (ImageCodecInfo codec in codecs) {
+ //Debug.WriteLine(codec.FormatID.ToString() + ", " + imageFormat.Guid.ToString());
+ if (codec.FormatID.ToString() == imageFormat.Guid.ToString()) {
+ // Extract the file extension from the codec's FilenameExtension property
+ string extension = codec.FilenameExtension.Split(';').First().TrimStart('*');
+ return extension;
+ }
+ }
+ return "unknown";
+ }
+
+ ///
+ /// Applies a color filter to a bitmap
+ ///
+ ///
+ ///
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static Bitmap ApplyColorFilter(Bitmap originalBitmap, System.Windows.Media.Color filterColor) {
+ // Create a copy of the original bitmap
+ Bitmap filteredBitmap = new Bitmap(originalBitmap.Width, originalBitmap.Height);
+
+ // Create a ColorMatrix object
+ ColorMatrix colorMatrix = new ColorMatrix(new float[][]
+ {
+ new float[] {filterColor.R / 255f, 0, 0, 0, 0},
+ new float[] {0, filterColor.G / 255f, 0, 0, 0},
+ new float[] {0, 0, filterColor.B / 255f, 0, 0},
+ new float[] {0, 0, 0, 1, 0},
+ new float[] {0, 0, 0, 0, 1}
+ });
+
+ // Create ImageAttributes
+ using (ImageAttributes attributes = new ImageAttributes()) {
+ attributes.SetColorMatrix(colorMatrix);
+
+ // Draw the filtered image
+ using (Graphics g = Graphics.FromImage(filteredBitmap)) {
+ g.DrawImage(originalBitmap, new Rectangle(0, 0, originalBitmap.Width, originalBitmap.Height),
+ 0, 0, originalBitmap.Width, originalBitmap.Height, GraphicsUnit.Pixel, attributes);
+ }
+ }
+ return filteredBitmap;
+ }
}
}
diff --git a/MapleLib b/MapleLib
index bbadd00c..d4740fb7 160000
--- a/MapleLib
+++ b/MapleLib
@@ -1 +1 @@
-Subproject commit bbadd00ced05c015e6ab3475d9ac19095ec95ce2
+Subproject commit d4740fb7928214a9f93b54a6ebcf3b93a58e2457