-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display crosshair for image 'origin'
- Loading branch information
1 parent
40c3760
commit e121832
Showing
15 changed files
with
344 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* Copyright (C) 2020 LastBattle | ||
* https://github.com/lastbattle/Harepacker-resurrected | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* 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 System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Data; | ||
|
||
namespace HaRepacker.Converter | ||
{ | ||
/// <summary> | ||
/// Converts CheckBox IsChecked to Visiblity | ||
/// </summary> | ||
public class CheckboxToVisibilityConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | ||
{ | ||
bool? isChecked = (bool?)value; | ||
|
||
if (isChecked == true) | ||
{ | ||
return Visibility.Visible; | ||
} | ||
return Visibility.Collapsed; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | ||
{ | ||
return false; // anyway | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
HaRepacker/Converter/ImageWidthOrHeightToScreenDPIConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* Copyright (C) 2020 LastBattle | ||
* https://github.com/lastbattle/Harepacker-resurrected | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* 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.Utils; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Data; | ||
|
||
namespace HaRepacker.Converter | ||
{ | ||
/// <summary> | ||
/// Converts the image (x, y) width or height to the correct size according to the screen's DPI scaling factor | ||
/// </summary> | ||
public class ImageWidthOrHeightToScreenDPIConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | ||
{ | ||
double widthOrHeight = (double)value; | ||
double realWidthOrHeightToDisplay = widthOrHeight / ScreenDPI.GetScreenScaleFactor(); | ||
|
||
return realWidthOrHeightToDisplay; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | ||
{ | ||
// cant really convert back here anyway | ||
double value_ = (double)value; | ||
double imageWidthOrHeight = value_ * ScreenDPI.GetScreenScaleFactor(); | ||
|
||
return imageWidthOrHeight; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* Copyright (C) 2020 LastBattle | ||
* https://github.com/lastbattle/Harepacker-resurrected | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* 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 System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Data; | ||
|
||
namespace HaRepacker.Converter | ||
{ | ||
/// <summary> | ||
/// Converts PointF X and Y coordinates to homosapien-ape readable string | ||
/// </summary> | ||
public class PointFOriginToStringConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | ||
{ | ||
PointF 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 | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
HaRepacker/Converter/VectorOriginPointFToMarginConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* Copyright (C) 2020 LastBattle | ||
* https://github.com/lastbattle/Harepacker-resurrected | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* 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.Utils; | ||
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.Data; | ||
|
||
namespace HaRepacker.Converter | ||
{ | ||
/// <summary> | ||
/// Converts PointF vector origin to XAML Margin | ||
/// </summary> | ||
public class VectorOriginPointFToMarginConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | ||
{ | ||
PointF originValue = (PointF)value; | ||
|
||
// get DPI. | ||
//PresentationSource source = PresentationSource.FromVisual(this); | ||
|
||
// converted | ||
// its always -50, as it is 50px wide, as specified in the xaml | ||
Thickness margin = new Thickness(originValue.X / ScreenDPI.GetScreenScaleFactor(), originValue.Y / ScreenDPI.GetScreenScaleFactor(), 0, 0); // 20,75 | ||
|
||
|
||
return margin; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | ||
{ | ||
// cant really convert back here anyway | ||
Thickness value_ = (Thickness)value; | ||
|
||
// converted | ||
PointF originValue = new PointF((float) (value_.Left * ScreenDPI.GetScreenScaleFactor()), (float) (value_.Top * ScreenDPI.GetScreenScaleFactor())); | ||
return originValue; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.