Skip to content

Commit 199d219

Browse files
authored
Merge pull request #518 from emoacht/develop
Develop
2 parents 1ad34fa + 5feabdd commit 199d219

File tree

140 files changed

+14006
-14600
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+14006
-14600
lines changed

Source/IconImage/App.xaml.cs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Configuration;
4-
using System.Data;
5-
using System.Linq;
6-
using System.Threading.Tasks;
7-
using System.Windows;
1+
using System.Windows;
82

9-
namespace IconImage
3+
namespace IconImage;
4+
5+
public partial class App : Application
106
{
11-
public partial class App : Application
12-
{
13-
}
147
}
Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
using System.Windows;
7-
using System.Windows.Controls;
8-
using System.Windows.Data;
9-
using System.Windows.Documents;
10-
using System.Windows.Input;
11-
using System.Windows.Media;
12-
using System.Windows.Media.Imaging;
1+
using System.Windows.Controls;
132

14-
namespace IconImage
3+
namespace IconImage;
4+
5+
public partial class DarkAppIcon : UserControl
156
{
16-
public partial class DarkAppIcon : UserControl
7+
public DarkAppIcon()
178
{
18-
public DarkAppIcon()
19-
{
20-
InitializeComponent();
21-
}
9+
InitializeComponent();
2210
}
2311
}
Lines changed: 45 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,66 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.IO;
4-
using System.Linq;
5-
using System.Text;
6-
using System.Threading.Tasks;
73
using System.Windows;
84
using System.Windows.Media;
95
using System.Windows.Media.Imaging;
106

11-
namespace IconImage
7+
namespace IconImage;
8+
9+
public class FrameworkElementImage
1210
{
13-
public class FrameworkElementImage
11+
/// <summary>
12+
/// Saves the image of a specified FrameworkElement to file in PNG format.
13+
/// </summary>
14+
/// <param name="source">FrameworkElement</param>
15+
/// <param name="filePath">File path</param>
16+
/// <param name="width">Width of saved image (optional)</param>
17+
/// <param name="height">Height of saved image (optional)</param>
18+
public static void SaveImage(FrameworkElement source, string filePath, double width = 0D, double height = 0D)
1419
{
15-
/// <summary>
16-
/// Saves the image of a specified FrameworkElement to file in PNG format.
17-
/// </summary>
18-
/// <param name="source">FrameworkElement</param>
19-
/// <param name="filePath">File path</param>
20-
/// <param name="width">Width of saved image (optional)</param>
21-
/// <param name="height">Height of saved image (optional)</param>
22-
public static void SaveImage(FrameworkElement source, string filePath, double width = 0D, double height = 0D)
23-
{
24-
if (source is null)
25-
throw new ArgumentNullException(nameof(source));
26-
if (string.IsNullOrWhiteSpace(filePath))
27-
throw new ArgumentNullException(nameof(filePath));
28-
29-
var rtb = new RenderTargetBitmap(
30-
(int)source.Width,
31-
(int)source.Height,
32-
96D, 96D,
33-
PixelFormats.Pbgra32);
20+
if (source is null)
21+
throw new ArgumentNullException(nameof(source));
22+
if (string.IsNullOrWhiteSpace(filePath))
23+
throw new ArgumentNullException(nameof(filePath));
3424

35-
rtb.Render(source);
25+
var rtb = new RenderTargetBitmap(
26+
(int)source.Width,
27+
(int)source.Height,
28+
96D, 96D,
29+
PixelFormats.Pbgra32);
3630

37-
var encoder = new PngBitmapEncoder();
38-
encoder.Frames.Add(BitmapFrame.Create(rtb));
31+
rtb.Render(source);
3932

40-
if ((0 < width) || (0 < height))
41-
{
42-
var bi = new BitmapImage();
33+
var encoder = new PngBitmapEncoder();
34+
encoder.Frames.Add(BitmapFrame.Create(rtb));
4335

44-
using (var ms = new MemoryStream())
45-
{
46-
encoder.Save(ms);
47-
ms.Seek(0, SeekOrigin.Begin);
36+
if ((0 < width) || (0 < height))
37+
{
38+
var bi = new BitmapImage();
4839

49-
bi.BeginInit();
50-
bi.CacheOption = BitmapCacheOption.OnLoad;
51-
bi.StreamSource = ms;
40+
using (var ms = new MemoryStream())
41+
{
42+
encoder.Save(ms);
43+
ms.Seek(0, SeekOrigin.Begin);
5244

53-
if (0 < width)
54-
bi.DecodePixelWidth = (int)width;
55-
if (0 < height)
56-
bi.DecodePixelHeight = (int)height;
45+
bi.BeginInit();
46+
bi.CacheOption = BitmapCacheOption.OnLoad;
47+
bi.StreamSource = ms;
5748

58-
bi.EndInit();
59-
}
49+
if (0 < width)
50+
bi.DecodePixelWidth = (int)width;
51+
if (0 < height)
52+
bi.DecodePixelHeight = (int)height;
6053

61-
encoder = new PngBitmapEncoder(); // Save method cannot be used twice.
62-
encoder.Frames.Add(BitmapFrame.Create(bi));
54+
bi.EndInit();
6355
}
6456

65-
using (var fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
66-
{
67-
encoder.Save(fs);
68-
}
57+
encoder = new PngBitmapEncoder(); // Save method cannot be used twice.
58+
encoder.Frames.Add(BitmapFrame.Create(bi));
59+
}
60+
61+
using (var fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
62+
{
63+
encoder.Save(fs);
6964
}
7065
}
7166
}
Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
using System.Windows;
7-
using System.Windows.Controls;
8-
using System.Windows.Data;
9-
using System.Windows.Documents;
10-
using System.Windows.Input;
11-
using System.Windows.Media;
12-
using System.Windows.Media.Imaging;
1+
using System.Windows.Controls;
132

14-
namespace IconImage
3+
namespace IconImage;
4+
5+
public partial class LightAppIcon : UserControl
156
{
16-
public partial class LightAppIcon : UserControl
7+
public LightAppIcon()
178
{
18-
public LightAppIcon()
19-
{
20-
InitializeComponent();
21-
}
9+
InitializeComponent();
2210
}
2311
}
Lines changed: 36 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,56 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.IO;
4-
using System.Linq;
53
using System.Media;
6-
using System.Text;
7-
using System.Threading.Tasks;
84
using System.Windows;
9-
using System.Windows.Controls;
10-
using System.Windows.Data;
11-
using System.Windows.Documents;
12-
using System.Windows.Input;
13-
using System.Windows.Media;
14-
using System.Windows.Media.Imaging;
155
using Microsoft.Win32;
166

17-
namespace IconImage
7+
namespace IconImage;
8+
9+
public partial class MainWindow : Window
1810
{
19-
public partial class MainWindow : Window
20-
{
21-
#region Property
11+
#region Property
2212

23-
public double ImageLength
24-
{
25-
get { return (double)GetValue(ImageLengthProperty); }
26-
set { SetValue(ImageLengthProperty, value); }
27-
}
28-
public static readonly DependencyProperty ImageLengthProperty =
29-
DependencyProperty.Register(
30-
"ImageLength",
31-
typeof(double),
32-
typeof(MainWindow),
33-
new PropertyMetadata(256D));
13+
public double ImageLength
14+
{
15+
get { return (double)GetValue(ImageLengthProperty); }
16+
set { SetValue(ImageLengthProperty, value); }
17+
}
18+
public static readonly DependencyProperty ImageLengthProperty =
19+
DependencyProperty.Register(
20+
"ImageLength",
21+
typeof(double),
22+
typeof(MainWindow),
23+
new PropertyMetadata(256D));
3424

35-
#endregion
25+
#endregion
3626

37-
public MainWindow()
38-
{
39-
InitializeComponent();
40-
}
27+
public MainWindow()
28+
{
29+
InitializeComponent();
30+
}
4131

42-
private void Save(object sender, RoutedEventArgs e) => SaveImage();
32+
private void Save(object sender, RoutedEventArgs e) => SaveImage();
4333

44-
private string _fileName = "Icon.png";
45-
private string _folderPath;
34+
private string _fileName = "Icon.png";
35+
private string _folderPath;
4636

47-
public void SaveImage()
37+
public void SaveImage()
38+
{
39+
var sfd = new SaveFileDialog
4840
{
49-
var sfd = new SaveFileDialog
50-
{
51-
FileName = _fileName,
52-
Filter = "*(.png)|*.png",
53-
InitialDirectory = _folderPath ?? Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
54-
};
41+
FileName = _fileName,
42+
Filter = "*(.png)|*.png",
43+
InitialDirectory = _folderPath ?? Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
44+
};
5545

56-
if (sfd.ShowDialog() != true)
57-
return;
46+
if (sfd.ShowDialog() != true)
47+
return;
5848

59-
_fileName = Path.GetFileName(sfd.FileName);
60-
_folderPath = Path.GetDirectoryName(sfd.FileName);
49+
_fileName = Path.GetFileName(sfd.FileName);
50+
_folderPath = Path.GetDirectoryName(sfd.FileName);
6151

62-
FrameworkElementImage.SaveImage(ImageContent, sfd.FileName, ImageLength, ImageLength);
52+
FrameworkElementImage.SaveImage(ImageContent, sfd.FileName, ImageLength, ImageLength);
6353

64-
SystemSounds.Asterisk.Play();
65-
}
54+
SystemSounds.Asterisk.Play();
6655
}
6756
}

Source/IconImage/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("4.0.0.0")]
55-
[assembly: AssemblyFileVersion("4.0.0.0")]
54+
[assembly: AssemblyVersion("4.5.0.0")]
55+
[assembly: AssemblyFileVersion("4.5.0.0")]

Source/IconImage/ScaleConverter.cs

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Globalization;
4-
using System.Linq;
5-
using System.Text;
6-
using System.Threading.Tasks;
73
using System.Windows;
84
using System.Windows.Data;
95

10-
namespace IconImage
6+
namespace IconImage;
7+
8+
[ValueConversion(typeof(double), typeof(double))]
9+
public class ScaleConverter : IValueConverter
1110
{
12-
[ValueConversion(typeof(double), typeof(double))]
13-
public class ScaleConverter : IValueConverter
11+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
1412
{
15-
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
16-
{
17-
if ((value is not double sourceValue) || !double.TryParse(parameter?.ToString(), out double factor))
18-
return DependencyProperty.UnsetValue;
13+
if ((value is not double sourceValue) || !double.TryParse(parameter?.ToString(), out double factor))
14+
return DependencyProperty.UnsetValue;
1915

20-
return sourceValue / factor;
21-
}
16+
return sourceValue / factor;
17+
}
2218

23-
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
24-
{
25-
if ((value is not double targetValue) || !double.TryParse(parameter?.ToString(), out double factor))
26-
return DependencyProperty.UnsetValue;
19+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
20+
{
21+
if ((value is not double targetValue) || !double.TryParse(parameter?.ToString(), out double factor))
22+
return DependencyProperty.UnsetValue;
2723

28-
return targetValue * factor;
29-
}
24+
return targetValue * factor;
3025
}
3126
}

Source/Installer/Product.wxs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
3-
<Product Id="*" Name="Monitorian" Manufacturer="emoacht" Version="4.4.14"
3+
<Product Id="*" Name="Monitorian" Manufacturer="emoacht" Version="4.5.0"
44
Language="1033" Codepage="1252" UpgradeCode="{81A4D148-75D3-462E-938D-8C208FB48E3C}">
55
<Package Id="*" InstallerVersion="500" Compressed="yes"
66
InstallScope="perMachine" InstallPrivileges="elevated"

0 commit comments

Comments
 (0)