Skip to content

Commit

Permalink
Merge pull request #236 from lastbattle/staging
Browse files Browse the repository at this point in the history
Staging - Image property grid + image filter editor
  • Loading branch information
lastbattle authored Jul 3, 2024
2 parents 2991362 + eb1f4ef commit 131fbdb
Show file tree
Hide file tree
Showing 22 changed files with 914 additions and 567 deletions.
8 changes: 4 additions & 4 deletions HaRepacker/Converter/ImageSizeDoubleToIntegerConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
34 changes: 34 additions & 0 deletions HaRepacker/Converter/PointFConverter.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
5 changes: 3 additions & 2 deletions HaRepacker/Converter/PointFOriginToStringConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
}
}
}
5 changes: 3 additions & 2 deletions HaRepacker/Converter/PointFToVisiblityConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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
}
}
}
19 changes: 19 additions & 0 deletions HaRepacker/Converter/PointFValueConverter.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
5 changes: 3 additions & 2 deletions HaRepacker/Converter/VectorOriginPointFToMarginConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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;
}
}
Expand Down
11 changes: 11 additions & 0 deletions HaRepacker/GUI/AboutForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions HaRepacker/GUI/AboutForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,19 @@ private void button1_Click(object sender, EventArgs e)
{
Close();
}

/// <summary>
/// Hyperlink
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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);
}
}
}
}
46 changes: 38 additions & 8 deletions HaRepacker/GUI/AboutForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;label1.ZOrder" xml:space="preserve">
<value>5</value>
<value>6</value>
</data>
<data name="label2.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 50</value>
Expand All @@ -174,7 +174,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;label2.ZOrder" xml:space="preserve">
<value>4</value>
<value>5</value>
</data>
<data name="label3.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 73</value>
Expand Down Expand Up @@ -203,7 +203,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;label3.ZOrder" xml:space="preserve">
<value>3</value>
<value>4</value>
</data>
<data name="label4.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 98</value>
Expand Down Expand Up @@ -231,7 +231,7 @@ Copyright (C) 2009-2015 haha01haha01</value>
<value>$this</value>
</data>
<data name="&gt;&gt;label4.ZOrder" xml:space="preserve">
<value>2</value>
<value>3</value>
</data>
<data name="button1.Location" type="System.Drawing.Point, System.Drawing">
<value>211, 297</value>
Expand All @@ -255,23 +255,26 @@ Copyright (C) 2009-2015 haha01haha01</value>
<value>$this</value>
</data>
<data name="&gt;&gt;button1.ZOrder" xml:space="preserve">
<value>1</value>
<value>2</value>
</data>
<data name="label5.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="label5.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="label5.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 191</value>
<value>114, 242</value>
</data>
<data name="label5.Size" type="System.Drawing.Size, System.Drawing">
<value>563, 75</value>
<value>49, 13</value>
</data>
<data name="label5.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
</data>
<data name="label5.Text" xml:space="preserve">
<value>A fork~ https://github.com/lastbattle</value>
<value>A fork~ </value>
</data>
<data name="label5.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleCenter</value>
Expand All @@ -286,6 +289,33 @@ Copyright (C) 2009-2015 haha01haha01</value>
<value>$this</value>
</data>
<data name="&gt;&gt;label5.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="linkLabel1.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="linkLabel1.Location" type="System.Drawing.Point, System.Drawing">
<value>169, 242</value>
</data>
<data name="linkLabel1.Size" type="System.Drawing.Size, System.Drawing">
<value>280, 13</value>
</data>
<data name="linkLabel1.TabIndex" type="System.Int32, mscorlib">
<value>6</value>
</data>
<data name="linkLabel1.Text" xml:space="preserve">
<value>https://github.com/lastbattle/Harepacker-resurrected</value>
</data>
<data name="&gt;&gt;linkLabel1.Name" xml:space="preserve">
<value>linkLabel1</value>
</data>
<data name="&gt;&gt;linkLabel1.Type" xml:space="preserve">
<value>System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;linkLabel1.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;linkLabel1.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
Expand Down
55 changes: 55 additions & 0 deletions HaRepacker/GUI/Controls/NotifyPointF.cs
Original file line number Diff line number Diff line change
@@ -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 {
/// <summary>
/// Custom PointF struct that implements INotifyPropertyChanged for PropertyView
/// </summary>
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);
}
}
Loading

0 comments on commit 131fbdb

Please sign in to comment.