Skip to content

Commit 69f3b9d

Browse files
committed
1.6.2
[Changes] - Using large icons now [Bug fixes] - Custom display name of an application has not been saved - Scroll bars won't show up, if there are to many applications
1 parent 16549e9 commit 69f3b9d

File tree

7 files changed

+128
-83
lines changed

7 files changed

+128
-83
lines changed

Source/HDRProfile/ApplicationAdder.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ public void GetFile()
7676

7777
public void CreateApplicationItem(object parameter)
7878
{
79+
if (applicationItem != null)
80+
ApplicationItem.DisplayName = DisplayName;
7981
OKClicked?.Invoke(this, EventArgs.Empty);
8082
CloseDialog(parameter as Window);
8183
}

Source/HDRProfile/ApplicationItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class ApplicationItem : BaseViewModel, IEquatable<ApplicationItem>
2626

2727
public string DisplayName { get => displayName; set { displayName = value; OnPropertyChanged(); } }
2828
public string ApplicationName { get => _applicationName; set { _applicationName = value; OnPropertyChanged(); } }
29-
public string ApplicationFilePath { get => _applicationFilePath; set { _applicationFilePath = value; try { Icon = System.Drawing.Icon.ExtractAssociatedIcon(value).ToBitmap(); } catch { } OnPropertyChanged(); } }
29+
public string ApplicationFilePath { get => _applicationFilePath; set { _applicationFilePath = value; try { Icon = Tools.GetFileIcon(value); } catch { } OnPropertyChanged(); } }
3030
public bool RestartProcess { get => _restartProcess; set { _restartProcess = value; OnPropertyChanged(); } }
3131
public bool IsUWP { get => _isUWP; set { _isUWP = value; OnPropertyChanged(); } }
3232

Source/HDRProfile/AutoHDR.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@
111111
<HintPath>..\Release\CodectoryCore.UI.Wpf.dll</HintPath>
112112
<Private>True</Private>
113113
</Reference>
114+
<Reference Include="CodectoryCore.Windows">
115+
<HintPath>Externals\CodectoryCore.Windows.dll</HintPath>
116+
</Reference>
114117
<Reference Include="Costura, Version=4.1.0.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
115118
<HintPath>..\packages\Costura.Fody.4.1.0\lib\net40\Costura.dll</HintPath>
116119
</Reference>
Binary file not shown.

Source/HDRProfile/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@
5252
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
5353
// indem Sie "*" wie unten gezeigt eingeben:
5454
// [assembly: AssemblyVersion("1.0.*")]
55-
[assembly: AssemblyVersion("1.6.1.0")]
56-
[assembly: AssemblyFileVersion("1.6.1.0")]
55+
[assembly: AssemblyVersion("1.6.2.0")]
56+
[assembly: AssemblyFileVersion("1.6.2.0")]

Source/HDRProfile/Tools.cs

Lines changed: 116 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
using System;
44
using System.Collections.Generic;
55
using System.Diagnostics;
6+
using System.Drawing;
7+
using System.Drawing.Imaging;
68
using System.Linq;
79
using System.Reflection;
10+
using System.Runtime.InteropServices;
11+
using System.Windows;
12+
using System.Windows.Media.Imaging;
813

914
namespace AutoHDR
1015
{
@@ -17,84 +22,117 @@ enum ShowWindowEnum
1722
Restore = 9, ShowDefault = 10, ForceMinimized = 11
1823
};
1924

20-
public static class Tools
21-
{
22-
23-
public static int GlobalRefreshInterval = 500;
24-
25-
public static void SetAutoStart(string applicationName, string filePath, bool autostart)
26-
{
27-
RegistryKey rk = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
28-
object existing = rk.GetValue(applicationName);
29-
if (filePath.Equals(existing) && autostart)
30-
return;
31-
if (rk.GetValue(applicationName) == null && !autostart)
32-
return;
33-
34-
if (autostart)
35-
rk.SetValue(applicationName, filePath);
36-
else
37-
rk.DeleteValue(applicationName, false);
38-
}
39-
40-
public static IDictionary<TKey, TValue> CloneDictionaryCloningValues<TKey, TValue>
41-
(Dictionary<TKey, TValue> original) where TValue : ICloneable
42-
{
43-
Dictionary<TKey, TValue> ret = new Dictionary<TKey, TValue>(original.Count, original.Comparer);
44-
foreach (KeyValuePair<TKey, TValue> entry in original)
45-
{
46-
ret.Add(entry.Key, (TValue)entry.Value.Clone());
47-
}
48-
return ret;
49-
}
50-
public static Version ApplicationVersion
51-
{
52-
get
53-
{
54-
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
55-
string versionString = assembly.GetName().Version.ToString();
56-
Version version = new Version(versionString.Substring(0, versionString.LastIndexOf('.')));
57-
return version;
58-
}
59-
}
60-
61-
public static Logs Logs = new Logs($"{System.AppDomain.CurrentDomain.BaseDirectory}AutoHDR.log", "AutoHDR", Assembly.GetExecutingAssembly().GetName().Version.ToString(), false);
62-
63-
[System.Runtime.InteropServices.DllImport("user32.dll")]
64-
[return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)]
65-
private static extern bool ShowWindow(IntPtr hWnd, ShowWindowEnum flags);
66-
67-
[System.Runtime.InteropServices.DllImport("user32.dll")]
68-
private static extern int SetForegroundWindow(IntPtr hwnd);
69-
70-
71-
public static void BringMainWindowToFront(string processName)
72-
{
73-
// get the process
74-
Process bProcess = Process.GetProcessesByName(processName).FirstOrDefault();
75-
76-
// check if the process is running
77-
if (bProcess != null)
78-
{
79-
// check if the window is hidden / minimized
80-
if (bProcess.MainWindowHandle == IntPtr.Zero)
81-
{
82-
// the window is hidden so try to restore it before setting focus.
83-
ShowWindow(bProcess.Handle, ShowWindowEnum.Restore);
84-
}
85-
86-
// set user the focus to the window
87-
SetForegroundWindow(bProcess.MainWindowHandle);
88-
}
89-
else
90-
{
91-
// the process is not running, so start it
92-
Process.Start(processName);
93-
}
94-
}
95-
96-
}
97-
25+
public static class Tools
26+
{
27+
28+
public static int GlobalRefreshInterval = 500;
29+
30+
public static void SetAutoStart(string applicationName, string filePath, bool autostart)
31+
{
32+
RegistryKey rk = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
33+
object existing = rk.GetValue(applicationName);
34+
if (filePath.Equals(existing) && autostart)
35+
return;
36+
if (rk.GetValue(applicationName) == null && !autostart)
37+
return;
38+
39+
if (autostart)
40+
rk.SetValue(applicationName, filePath);
41+
else
42+
rk.DeleteValue(applicationName, false);
43+
}
44+
45+
public static IDictionary<TKey, TValue> CloneDictionaryCloningValues<TKey, TValue>
46+
(Dictionary<TKey, TValue> original) where TValue : ICloneable
47+
{
48+
Dictionary<TKey, TValue> ret = new Dictionary<TKey, TValue>(original.Count, original.Comparer);
49+
foreach (KeyValuePair<TKey, TValue> entry in original)
50+
{
51+
ret.Add(entry.Key, (TValue)entry.Value.Clone());
52+
}
53+
return ret;
54+
}
55+
public static Version ApplicationVersion
56+
{
57+
get
58+
{
59+
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
60+
string versionString = assembly.GetName().Version.ToString();
61+
Version version = new Version(versionString.Substring(0, versionString.LastIndexOf('.')));
62+
return version;
63+
}
64+
}
65+
66+
public static Logs Logs = new Logs($"{System.AppDomain.CurrentDomain.BaseDirectory}AutoHDR.log", "AutoHDR", Assembly.GetExecutingAssembly().GetName().Version.ToString(), false);
67+
68+
[System.Runtime.InteropServices.DllImport("user32.dll")]
69+
[return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)]
70+
private static extern bool ShowWindow(IntPtr hWnd, ShowWindowEnum flags);
71+
72+
[System.Runtime.InteropServices.DllImport("user32.dll")]
73+
private static extern int SetForegroundWindow(IntPtr hwnd);
74+
75+
76+
public static void BringMainWindowToFront(string processName)
77+
{
78+
// get the process
79+
Process bProcess = Process.GetProcessesByName(processName).FirstOrDefault();
80+
81+
// check if the process is running
82+
if (bProcess != null)
83+
{
84+
// check if the window is hidden / minimized
85+
if (bProcess.MainWindowHandle == IntPtr.Zero)
86+
{
87+
// the window is hidden so try to restore it before setting focus.
88+
ShowWindow(bProcess.Handle, ShowWindowEnum.Restore);
89+
}
90+
91+
// set user the focus to the window
92+
SetForegroundWindow(bProcess.MainWindowHandle);
93+
}
94+
else
95+
{
96+
// the process is not running, so start it
97+
Process.Start(processName);
98+
}
99+
}
100+
101+
102+
103+
104+
/// <summary>
105+
/// Returns an icon for a given file - indicated by the name parameter.
106+
/// </summary>
107+
/// <param name="name">Pathname for file.</param>
108+
/// <param name="size">Large or small</param>
109+
/// <param name="linkOverlay">Whether to include the link icon</param>
110+
/// <returns>System.Drawing.Icon</returns>
111+
public static Bitmap GetFileIcon(string name)
112+
{
113+
return CodectoryCore.Windows.Icons.IconHelper.GetIconImage(name, CodectoryCore.Windows.Icons.IconHelper.IconSize.jumbo);
114+
}
115+
116+
private static Bitmap GetBitmap(BitmapSource source)
117+
{
118+
Bitmap bmp = new Bitmap(
119+
source.PixelWidth,
120+
source.PixelHeight,
121+
PixelFormat.Format32bppPArgb);
122+
BitmapData data = bmp.LockBits(
123+
new Rectangle(System.Drawing.Point.Empty, bmp.Size),
124+
ImageLockMode.WriteOnly,
125+
PixelFormat.Format32bppPArgb);
126+
source.CopyPixels(
127+
Int32Rect.Empty,
128+
data.Scan0,
129+
data.Height * data.Stride,
130+
data.Stride);
131+
bmp.UnlockBits(data);
132+
return bmp;
133+
}
134+
135+
}
98136

99137
}
100138

Source/HDRProfile/Views/AutoHDRMainView.xaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,12 @@
131131
<Grid>
132132
<Grid.RowDefinitions>
133133
<RowDefinition Height="Auto"/>
134-
<RowDefinition Height="Auto" />
134+
<RowDefinition Height="*" />
135135
</Grid.RowDefinitions>
136136
<TextBlock Grid.Row="0" TextWrapping="Wrap" Text="{x:Static pres:Locale_Texts.RestartProccessOnFirstOccurence}" HorizontalAlignment="Right" Width="Auto" Height="16" VerticalAlignment="Top" Margin="0,5,5,0"/>
137-
<ListBox Grid.Row="1" x:Name="ApplicationList" HorizontalContentAlignment="Stretch" ItemsPanel="{StaticResource StackListViewTemplate}" ItemTemplate="{StaticResource ApplicationItemTemplate}" ItemsSource="{Binding Settings.ApplicationItems}" ScrollViewer.VerticalScrollBarVisibility="Auto" Background="{x:Null}" BorderThickness="0"/>
137+
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
138+
<ListBox x:Name="ApplicationList" HorizontalContentAlignment="Stretch" ItemsPanel="{StaticResource StackListViewTemplate}" ItemTemplate="{StaticResource ApplicationItemTemplate}" ItemsSource="{Binding Settings.ApplicationItems}" ScrollViewer.VerticalScrollBarVisibility="Disabled" Background="{x:Null}" BorderThickness="0" ScrollViewer.HorizontalScrollBarVisibility="Disabled" VerticalAlignment="Top"/>
139+
</ScrollViewer>
138140
</Grid>
139141
</Border>
140142
<Grid Grid.Row="1" Height="Auto" VerticalAlignment="Bottom" ScrollViewer.HorizontalScrollBarVisibility="Auto">

0 commit comments

Comments
 (0)