Skip to content

Commit

Permalink
Merge pull request #160 from PixiEditor/debuggerDisplays
Browse files Browse the repository at this point in the history
Added Debugging Tools
  • Loading branch information
flabbet committed Mar 11, 2021
2 parents bef0171 + aad1679 commit 43642b2
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 2 deletions.
2 changes: 2 additions & 0 deletions PixiEditor/Models/Controllers/BitmapManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Windows;
using System.Windows.Input;
Expand All @@ -18,6 +19,7 @@

namespace PixiEditor.Models.Controllers
{
[DebuggerDisplay("{Documents.Count} Document(s)")]
public class BitmapManager : NotifyableObject
{
private Document activeDocument;
Expand Down
2 changes: 2 additions & 0 deletions PixiEditor/Models/Controllers/UndoManager.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using PixiEditor.Models.Undo;
using PixiEditor.ViewModels;

namespace PixiEditor.Models.Controllers
{
[DebuggerDisplay("{UndoStack.Count} undo steps, {RedoStack.Count} redo step(s)")]
public class UndoManager
{
private bool lastChangeWasUndo;
Expand Down
2 changes: 2 additions & 0 deletions PixiEditor/Models/DataHolders/Document/Document.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Buffers;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
Expand All @@ -20,6 +21,7 @@

namespace PixiEditor.Models.DataHolders
{
[DebuggerDisplay("'{Name, nq}' {width}x{height} {Layers.Count} Layer(s)")]
public partial class Document : NotifyableObject
{
private int height;
Expand Down
2 changes: 2 additions & 0 deletions PixiEditor/Models/Layers/Layer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Windows;
using System.Windows.Media;
Expand All @@ -12,6 +13,7 @@

namespace PixiEditor.Models.Layers
{
[DebuggerDisplay("'{name,nq}' {width}x{height}")]
public class Layer : BasicLayer
{
private const int SizeOfArgb = 4;
Expand Down
2 changes: 1 addition & 1 deletion PixiEditor/Models/Tools/Tools/PenTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public BitmapPixelChanges Draw(Coordinates startingCoords, Coordinates latestCor
return changes;
}

changedPixelsindex += changedPixelsindex >= 2 ? 0 : 1;
changedPixelsindex += changedPixelsindex >= 2 ? (byte)0 : (byte)1;

var result = BitmapPixelChanges.FromSingleColoredArray(GetThickShape(latestPixels, toolSize), color);

Expand Down
2 changes: 2 additions & 0 deletions PixiEditor/Models/UserPreferences/PreferencesSettings.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using Newtonsoft.Json;
using PixiEditor.ViewModels;

namespace PixiEditor.Models.UserPreferences
{
[DebuggerDisplay("{Preferences.Count + LocalPreferences.Count} Preference(s)")]
public class PreferencesSettings : IPreferences
{
public static IPreferences Current => ViewModelMain.Current.Preferences;
Expand Down
13 changes: 13 additions & 0 deletions PixiEditor/ViewModels/SubViewModels/Main/DebugViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Diagnostics;
using PixiEditor.Helpers;

namespace PixiEditor.ViewModels.SubViewModels.Main
{
public class DebugViewModel : SubViewModel<ViewModelMain>
{
public DebugViewModel(ViewModelMain owner)
: base(owner)
{
}
}
}
19 changes: 18 additions & 1 deletion PixiEditor/ViewModels/ViewModelMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public class ViewModelMain : ViewModelBase

public DiscordViewModel DiscordViewModel { get; set; }

#if DEBUG
public DebugViewModel DebugSubViewModel { get; set; }
#endif

public BitmapManager BitmapManager { get; set; }

public PixelChangesController ChangesController { get; set; }
Expand All @@ -67,6 +71,16 @@ public class ViewModelMain : ViewModelBase

public IPreferences Preferences { get; set; }

public bool IsDebug
{
get =>
#if DEBUG
true;
#else
false;
#endif
}

public ViewModelMain(IServiceProvider services)
{
Current = this;
Expand Down Expand Up @@ -98,6 +112,9 @@ public ViewModelMain(IServiceProvider services)
DocumentSubViewModel = new DocumentViewModel(this);
MiscSubViewModel = new MiscViewModel(this);
DiscordViewModel = new DiscordViewModel(this, "764168193685979138");
#if DEBUG
DebugSubViewModel = new DebugViewModel(this);
#endif

ShortcutController = new ShortcutController
{
Expand Down Expand Up @@ -147,7 +164,7 @@ public ViewModelMain(IServiceProvider services)
new Shortcut(Key.F2, LayersSubViewModel.RenameLayerCommand, BitmapManager.ActiveDocument?.ActiveLayerIndex),

// View
new Shortcut(Key.OemTilde, ViewportSubViewModel.ToggleGridLinesCommand, modifier: ModifierKeys.Control)
new Shortcut(Key.OemTilde, ViewportSubViewModel.ToggleGridLinesCommand, modifier: ModifierKeys.Control),
}
};
BitmapManager.PrimaryColor = ColorsSubViewModel.PrimaryColor;
Expand Down
3 changes: 3 additions & 0 deletions PixiEditor/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@
<MenuItem Header="Third Party Licenses" Command="{Binding MiscSubViewModel.OpenHyperlinkCommand}"
CommandParameter="https://github.com/PixiEditor/PixiEditor/wiki/Third-party-licenses"/>
</MenuItem>
<MenuItem Header="_Debug" Visibility="{Binding IsDebug, Converter={StaticResource BoolToVisibilityConverter}}">
<MenuItem Header="Such empty here..." IsEnabled="False"/>
</MenuItem>
</Menu>
<StackPanel DockPanel.Dock="Right" VerticalAlignment="Top" Orientation="Horizontal"
HorizontalAlignment="Right" WindowChrome.IsHitTestVisibleInChrome="True">
Expand Down

0 comments on commit 43642b2

Please sign in to comment.