Skip to content

Commit

Permalink
Merge pull request #1943 from gitmacer/feature/SaveDebugWindow
Browse files Browse the repository at this point in the history
Save/Autostart/contextmenu Debug Windows
  • Loading branch information
diogotr7 authored Apr 3, 2020
2 parents 9eb55d5 + c4c7365 commit 10da642
Show file tree
Hide file tree
Showing 10 changed files with 356 additions and 139 deletions.
6 changes: 6 additions & 0 deletions Project-Aurora/Project-Aurora/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,12 @@ protected override void OnStartup(StartupEventArgs e)

MainWindow = new ConfigUI();
((ConfigUI)MainWindow).Display();

//Debug Windows on Startup
if (Global.Configuration.BitmapWindowOnStartUp)
Window_BitmapView.Open();
if (Global.Configuration.HttpWindowOnStartUp)
Window_GSIHttpDebug.Open();
}
else
{
Expand Down
14 changes: 13 additions & 1 deletion Project-Aurora/Project-Aurora/ConfigUI.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,19 @@
</StackPanel.ContextMenu>
</StackPanel>
</ScrollViewer>
<Image Source="Resources/settings_icon.png" ToolTip="General Settings" Margin="6,0,10,0" MouseDown="DesktopControl_MouseDown" RenderTransformOrigin="0.5,0.5" Height="40" VerticalAlignment="Bottom" HorizontalAlignment="Center"/>
<Image Source="Resources/settings_icon.png" ToolTip="General Settings" Margin="6,0,10,0" MouseLeftButtonDown="DesktopControl_MouseLeftButtonDown" RenderTransformOrigin="0.5,0.5" Height="40" VerticalAlignment="Bottom" HorizontalAlignment="Center">
<Image.ContextMenu>
<ContextMenu x:Name="cmenuSettings" Background="#FF181818" HorizontalContentAlignment="Center">
<ContextMenu.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Background="#FF181818" />
</ItemsPanelTemplate>
</ContextMenu.ItemsPanel>
<MenuItem x:Name="cmbtnOpenBitmap" Header="Open Bitmap Window" Click="cmbtnOpenBitmapWindow_Clicked" Foreground="White"/>
<MenuItem x:Name="cmbtnOpenhttpDebug" Header="Open GSI/HTTP Window" Click="cmbtnOpenHttpDebugWindow_Clicked" Foreground="White"/>
</ContextMenu>
</Image.ContextMenu>
</Image>
</Grid>

<Grid x:Name="gridManagers" Margin="5,5,0,5" HorizontalAlignment="Left" Width="200">
Expand Down
5 changes: 4 additions & 1 deletion Project-Aurora/Project-Aurora/ConfigUI.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ private void AddProfile_MouseDown(object sender, MouseButtonEventArgs e)
}
}

private void DesktopControl_MouseDown(object sender, MouseButtonEventArgs e)
private void DesktopControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
this.FocusedApplication = null;
SelectedControl = settingsControl;
Expand All @@ -680,6 +680,9 @@ private void DesktopControl_MouseDown(object sender, MouseButtonEventArgs e)

UpdateProfileStackBackground(sender as FrameworkElement);
}
private void cmbtnOpenBitmapWindow_Clicked(object sender, RoutedEventArgs e) => Window_BitmapView.Open();
private void cmbtnOpenHttpDebugWindow_Clicked(object sender, RoutedEventArgs e) =>Window_GSIHttpDebug.Open();


private void UpdateProfileStackBackground(FrameworkElement item)
{
Expand Down
2 changes: 2 additions & 0 deletions Project-Aurora/Project-Aurora/Project-Aurora.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,7 @@
<DependentUpon>Control_ROTTombRaider.xaml</DependentUpon>
</Compile>
<Compile Include="Profiles\ROT Tomb Raider\ROTTombRaiderApplication.cs" />
<Compile Include="Settings\Window_BitmapView.cs" />
<Compile Include="Settings\Window_GSIHttpDebug.xaml.cs">
<DependentUpon>Window_GSIHttpDebug.xaml</DependentUpon>
</Compile>
Expand All @@ -876,6 +877,7 @@
<Compile Include="Settings\Window_ProcessSelection.xaml.cs">
<DependentUpon>Window_ProcessSelection.xaml</DependentUpon>
</Compile>
<Compile Include="Utils\WindowPlacement.cs" />
<Compile Include="Utils\Converters.cs" />
<Compile Include="Utils\DesktopUtils.cs" />
<Compile Include="Utils\DesktopDuplicator.cs" />
Expand Down
15 changes: 14 additions & 1 deletion Project-Aurora/Project-Aurora/Settings/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Aurora.Profiles.Generic_Application;
using Aurora.Profiles;
using Newtonsoft.Json.Serialization;
using Aurora.Utils;

namespace Aurora.Settings
{
Expand Down Expand Up @@ -467,13 +468,25 @@ public class Configuration : Settings

public VariableRegistry VarRegistry;

//Debug Settings
//BitmapDebug Data
private bool bitmapDebugTopMost;
public bool BitmapDebugTopMost { get { return bitmapDebugTopMost; } set { bitmapDebugTopMost = value; InvokePropertyChanged(); } }

private WINDOWPLACEMENT bitmapPlacement;
public WINDOWPLACEMENT BitmapPlacement { get { return bitmapPlacement; } set { bitmapPlacement = value; InvokePropertyChanged(); } }

private bool bitmapWindowOnStartUp;
public bool BitmapWindowOnStartUp { get { return bitmapWindowOnStartUp; } set { bitmapWindowOnStartUp = value; InvokePropertyChanged(); } }

//httpDebug Data
private bool httpDebugTopMost;
public bool HttpDebugTopMost { get { return httpDebugTopMost; } set { httpDebugTopMost = value; InvokePropertyChanged(); } }

private WINDOWPLACEMENT httpDebugPlacement;
public WINDOWPLACEMENT HttpDebugPlacement { get { return httpDebugPlacement; } set { httpDebugPlacement = value; InvokePropertyChanged(); } }

private bool httpWindowOnStartUp;
public bool HttpWindowOnStartUp { get { return httpWindowOnStartUp; } set { httpWindowOnStartUp = value; InvokePropertyChanged(); } }

public List<string> ProfileOrder { get; set; } = new List<string>();

Expand Down
73 changes: 64 additions & 9 deletions Project-Aurora/Project-Aurora/Settings/Control_Settings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:Controls="clr-namespace:Aurora.Controls" xmlns:params="http://schemas.codeplex.com/elysium/params" x:Class="Aurora.Settings.Control_Settings"
mc:Ignorable="d"
d:DesignHeight="400" d:DesignWidth="403.521" Height="Auto" Width="Auto" MinHeight="300" MinWidth="850" Loaded="UserControl_Loaded" Unloaded="UserControl_Unloaded" x:Name="ctrlSettings">
d:DesignHeight="400" d:DesignWidth="403.521" Height="Auto" Width="Auto" MinHeight="300" MinWidth="850" Loaded="UserControl_Loaded" x:Name="ctrlSettings">
<UserControl.Resources>
<ResourceDictionary>
<ObjectDataProvider x:Key="PercentEffectType" MethodName="GetValues" ObjectType="{x:Type System:Enum}">
Expand Down Expand Up @@ -362,14 +362,69 @@
</TabItem>
<TabItem Header="Debug">
<Grid>
<TextBlock x:Name="textBlock" HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" Text="Current Keyboard bitmap:" VerticalAlignment="Top"/>
<Image x:Name="debug_bitmap_preview" HorizontalAlignment="Left" Margin="152,10,0,0" VerticalAlignment="Top" MaxWidth="400" MaxHeight="400"/>
<Button x:Name="btnShowBitmapWindow" Content="Show Bitmap Window" HorizontalAlignment="Left" Margin="10,31,0,0" VerticalAlignment="Top" Click="btnShowBitmapWindow_Click"/>
<CheckBox x:Name="chkBitmapTopMost" Content="Always on top" HorizontalAlignment="Left" Margin="10,56,0,0" VerticalAlignment="Top" IsChecked="{Binding BitmapDebugTopMost, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<Button x:Name="btnShowLogsFolder" Content="Show Logs Folder" HorizontalAlignment="Left" Margin="10,121,0,0" VerticalAlignment="Top" Click="btnShowLogsFolder_Click"/>
<Button x:Name="btnShowGSILog" Content="Show GSI HTTP requests" HorizontalAlignment="Left" Margin="10,76,0,0" VerticalAlignment="Top" Click="btnShowGSILog_Click" />
<CheckBox x:Name="chkHttpDebugTopMost" Content="Always on top" HorizontalAlignment="Left" Margin="10,101,0,0" VerticalAlignment="Top" IsChecked="{Binding HttpDebugTopMost, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<Button Content="Record" HorizontalAlignment="Left" Margin="10,81,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click" IsEnabled="False" Visibility="Collapsed"/>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>

<StackPanel Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Top" >
<Button
x:Name="btnShowBitmapWindow"
Content="Show Bitmap Window"
Click="btnShowBitmapWindow_Click"
Margin="0,50,0,0"
Width="150"
Height="30"
/>
<CheckBox
x:Name="chkBitmapTopMost"
Content="Always on top"
IsChecked="{Binding BitmapDebugTopMost, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Margin="0,10,0,0"
/>
<CheckBox
x:Name="chkBitmapStartUp"
Content="Open at startup"
IsChecked="{Binding BitmapWindowOnStartUp, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Margin="0,10,0,0"
/>
</StackPanel>

<StackPanel Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Top">
<Button
x:Name="btnShowGSILog"
Content="Show GSI HTTP requests"
Click="btnShowGSILog_Click"
Margin="0,50,0,0"
Width="150"
Height="30"
/>
<CheckBox
x:Name="chkHttpDebugTopMost"
Content="Always on top"
IsChecked="{Binding HttpDebugTopMost, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Margin="0,10,0,0"
/>
<CheckBox
x:Name="chkHttpStartUp"
Content="Open at startup"
IsChecked="{Binding HttpWindowOnStartUp, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Margin="0,10,0,0"

/>
</StackPanel>

<StackPanel Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Top">
<Button
x:Name="btnShowLogsFolder"
Content="Show Logs Folder"
Click="btnShowLogsFolder_Click"
Margin="0,50,0,0"
Width="150"
Height="30"
/>
</StackPanel>
</Grid>
</TabItem>
</TabControl>
Expand Down
125 changes: 3 additions & 122 deletions Project-Aurora/Project-Aurora/Settings/Control_Settings.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ public partial class Control_Settings : UserControl
private RegistryKey runRegistryPath = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
private const string StartupTaskID = "AuroraStartup";

private Window winBitmapView = null;
private Image imgBitmap = new Image();
private static bool bitmapViewOpen;

public Control_Settings()
{
InitializeComponent();
Expand Down Expand Up @@ -174,50 +170,11 @@ public Control_Settings()
}
}

private void OnLayerRendered(System.Drawing.Bitmap map)
{
try
{
Dispatcher.Invoke(
() =>
{
using (MemoryStream memory = new MemoryStream())
{
//Fix conflict with AtomOrb due to async
lock (map)
{
map.Save(memory, System.Drawing.Imaging.ImageFormat.Png);
}
memory.Position = 0;
BitmapImage bitmapimage = new BitmapImage();
bitmapimage.BeginInit();
bitmapimage.StreamSource = memory;
bitmapimage.CacheOption = BitmapCacheOption.OnLoad;
bitmapimage.EndInit();

this.debug_bitmap_preview.Width = 4 * bitmapimage.Width;
this.debug_bitmap_preview.Height = 4 * bitmapimage.Height;
this.debug_bitmap_preview.Source = bitmapimage;
}
});
}
catch (Exception ex)
{
Global.logger.Warn(ex.ToString());
}
}

private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
Global.effengine.NewLayerRender += OnLayerRendered;
this.ctrlPluginManager.Host = Global.PluginManager;
}

private void UserControl_Unloaded(object sender, RoutedEventArgs e)
{
Global.effengine.NewLayerRender -= OnLayerRendered;
}

private void app_exit_mode_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (IsLoaded)
Expand Down Expand Up @@ -951,84 +908,6 @@ private void wrapper_install_lightfx_64_Click(object sender, RoutedEventArgs e)
}
}

private void btnShowBitmapWindow_Click(object sender, RoutedEventArgs e)
{
if (winBitmapView == null)
{
if (bitmapViewOpen == true)
{
System.Windows.MessageBox.Show("Keyboard Bitmap View already open.\r\nPlease close it.");
return;
}

winBitmapView = new Window();
winBitmapView.Closed += WinBitmapView_Closed;
winBitmapView.ResizeMode = ResizeMode.CanResize;

winBitmapView.SetBinding(Window.TopmostProperty, new Binding("BitmapDebugTopMost") { Source = Global.Configuration });

//winBitmapView.SizeToContent = SizeToContent.WidthAndHeight;

winBitmapView.Title = "Keyboard Bitmap View";
winBitmapView.Background = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
Global.effengine.NewLayerRender += Effengine_NewLayerRender;

imgBitmap.SnapsToDevicePixels = true;
imgBitmap.HorizontalAlignment = HorizontalAlignment.Stretch;
imgBitmap.VerticalAlignment = VerticalAlignment.Stretch;
/*imgBitmap.MinWidth = 0;
imgBitmap.MinHeight = 0;*/
imgBitmap.MinWidth = Effects.canvas_width;
imgBitmap.MinHeight = Effects.canvas_height;

winBitmapView.Content = imgBitmap;

winBitmapView.UpdateLayout();
winBitmapView.Show();
}
else
{
winBitmapView.BringIntoView();
}
}

private void Effengine_NewLayerRender(System.Drawing.Bitmap bitmap)
{
try
{
Dispatcher.Invoke(
() =>
{
lock (bitmap)
{
using (MemoryStream memory = new MemoryStream())
{
bitmap.Save(memory, System.Drawing.Imaging.ImageFormat.Png);
memory.Position = 0;
BitmapImage bitmapimage = new BitmapImage();
bitmapimage.BeginInit();
bitmapimage.StreamSource = memory;
bitmapimage.CacheOption = BitmapCacheOption.OnLoad;
bitmapimage.EndInit();

imgBitmap.Source = bitmapimage;
}
}
});
}
catch (Exception ex)
{
Global.logger.Warn(ex.ToString());
}
}

private void WinBitmapView_Closed(object sender, EventArgs e)
{
winBitmapView = null;
Global.effengine.NewLayerRender -= Effengine_NewLayerRender;
bitmapViewOpen = false;
}

private void btnShowLogsFolder_Click(object sender, RoutedEventArgs e)
{
if (sender is Button)
Expand All @@ -1049,7 +928,9 @@ private void chkHigherPriority_IsCheckedChanged(object sender, RoutedEventArgs e
Process.GetCurrentProcess().PriorityClass = Global.Configuration.HighPriority ? ProcessPriorityClass.High : ProcessPriorityClass.Normal;
}

private void btnShowGSILog_Click(object sender, RoutedEventArgs e) => new Window_GSIHttpDebug().Show();
private void btnShowBitmapWindow_Click(object sender, RoutedEventArgs e) => Window_BitmapView.Open();

private void btnShowGSILog_Click(object sender, RoutedEventArgs e) => Window_GSIHttpDebug.Open();

private void startDelayAmount_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e) {
using (TaskService service = new TaskService()) {
Expand Down
Loading

0 comments on commit 10da642

Please sign in to comment.