-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a527fde
commit b9f671d
Showing
16 changed files
with
225 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,18 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<configSections> | ||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > | ||
<section name="HeimerFlyingOnYourScreen.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> | ||
</sectionGroup> | ||
</configSections> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> | ||
</startup> | ||
<userSettings> | ||
<HeimerFlyingOnYourScreen.Properties.Settings> | ||
<setting name="Skin" serializeAs="String"> | ||
<value>Classic</value> | ||
</setting> | ||
</HeimerFlyingOnYourScreen.Properties.Settings> | ||
</userSettings> | ||
</configuration> |
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,84 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
|
||
namespace HeimerFlyingOnYourScreen | ||
{ | ||
/// <summary> | ||
/// STACKOVERFLOW FTW | ||
/// </summary> | ||
public class ExclusiveMenuItem : DependencyObject | ||
{ | ||
public static Dictionary<MenuItem, String> ElementToGroupNames = new Dictionary<MenuItem, String>(); | ||
|
||
public static readonly DependencyProperty GroupNameProperty = | ||
DependencyProperty.RegisterAttached("GroupName", | ||
typeof(String), | ||
typeof(ExclusiveMenuItem), | ||
new PropertyMetadata(String.Empty, OnGroupNameChanged)); | ||
|
||
public static void SetGroupName(MenuItem element, String value) | ||
{ | ||
element.SetValue(GroupNameProperty, value); | ||
} | ||
|
||
public static String GetGroupName(MenuItem element) | ||
{ | ||
return element.GetValue(GroupNameProperty).ToString(); | ||
} | ||
|
||
private static void OnGroupNameChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | ||
{ | ||
//Add an entry to the group name collection | ||
var menuItem = d as MenuItem; | ||
|
||
if (menuItem != null) | ||
{ | ||
String newGroupName = e.NewValue.ToString(); | ||
String oldGroupName = e.OldValue.ToString(); | ||
if (String.IsNullOrEmpty(newGroupName)) | ||
{ | ||
//Removing the toggle button from grouping | ||
RemoveCheckboxFromGrouping(menuItem); | ||
} | ||
else | ||
{ | ||
//Switching to a new group | ||
if (newGroupName != oldGroupName) | ||
{ | ||
if (!String.IsNullOrEmpty(oldGroupName)) | ||
{ | ||
//Remove the old group mapping | ||
RemoveCheckboxFromGrouping(menuItem); | ||
} | ||
ElementToGroupNames.Add(menuItem, e.NewValue.ToString()); | ||
menuItem.Checked += MenuItemChecked; | ||
} | ||
} | ||
} | ||
} | ||
|
||
private static void RemoveCheckboxFromGrouping(MenuItem checkBox) | ||
{ | ||
ElementToGroupNames.Remove(checkBox); | ||
checkBox.Checked -= MenuItemChecked; | ||
} | ||
|
||
|
||
static void MenuItemChecked(object sender, RoutedEventArgs e) | ||
{ | ||
var menuItem = e.OriginalSource as MenuItem; | ||
foreach (var item in ElementToGroupNames) | ||
{ | ||
if (item.Key != menuItem && item.Value == GetGroupName(menuItem)) | ||
{ | ||
item.Key.IsChecked = false; | ||
} | ||
} | ||
} | ||
} | ||
} |
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
Binary file added
BIN
+21.7 KB
HeimerFlyingOnYourScreen/HeimerImages/AlienInvader/AlienInvaderTurret.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+22.3 KB
HeimerFlyingOnYourScreen/HeimerImages/ExplodingHeim/ExplodingHeimTurret.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+21.4 KB
HeimerFlyingOnYourScreen/HeimerImages/PiltoverHeim/PiltoverHeimTurret.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+22.6 KB
HeimerFlyingOnYourScreen/HeimerImages/Snowmerdinger/SnowmerdingerTurret.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
<?xml version='1.0' encoding='utf-8'?> | ||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)"> | ||
<Profiles> | ||
<Profile Name="(Default)" /> | ||
</Profiles> | ||
<Settings /> | ||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="HeimerFlyingOnYourScreen.Properties" GeneratedClassName="Settings"> | ||
<Profiles /> | ||
<Settings> | ||
<Setting Name="Skin" Type="System.String" Scope="User"> | ||
<Value Profile="(Default)">Classic</Value> | ||
</Setting> | ||
</Settings> | ||
</SettingsFile> |
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,38 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Controls; | ||
using System.Windows.Media.Imaging; | ||
|
||
namespace HeimerFlyingOnYourScreen | ||
{ | ||
public static class ResourceData | ||
{ | ||
public static string[] ImplementedSkins { get; } = new string[] | ||
{ | ||
"Classic", | ||
"AlienInvader", | ||
"ExplodingHeim", | ||
"PiltoverHeim", | ||
"Snowmerdinger" | ||
}; | ||
public static void UpdateImageSource(Image img, bool isTurret = false) | ||
{ | ||
var skin = Properties.Settings.Default.Skin; | ||
img.Source = new BitmapImage(new Uri($"pack://application:,,,/HeimerFlyingOnYourScreen;component/HeimerImages/{skin}/{skin}{(isTurret ? "Turret" : "")}.png")); | ||
} | ||
|
||
public static void UpdateImageSource(Image img, string skinName, bool replaceSettings = true) | ||
{ | ||
if (!ImplementedSkins.Contains(skinName)) throw new InvalidOperationException("Skin name isn't right :/"); | ||
if (replaceSettings) | ||
{ | ||
Properties.Settings.Default.Skin = skinName; | ||
Properties.Settings.Default.Save(); | ||
} | ||
img.Source = new BitmapImage(new Uri($"pack://application:,,,/HeimerFlyingOnYourScreen;component/HeimerImages/{skinName}/{skinName}.png")); | ||
} | ||
} | ||
} |
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