Skip to content

Commit

Permalink
Dev (#179)
Browse files Browse the repository at this point in the history
* cleanup code
* fix index out of range when only front matter present
* fix clipboard to DataUri
* allow per monitor dpi
* move commands
* move commands
* move commands
* refactor to use static
* refactor commands
* fix init problem
* refactor more commands
* refactor more commands
* refactor more commands
* refactor more commands
* fix openfile command
* move more commands
* main window refactored
* begin refactoring editor commands
* move more editor commands:
* move more commands
* refactor to commands
* update packages, reduce template
* make stylesheet less github like
* add list indent on tab
* add multi-jit startup
* fix redraw issues
* navigate to named anchors in same document #171
* only add to list items if it's increasing line count #172
* check if previous/previous line in list #173
* to enable newer common control styles
* move app manifest into solution items
* v1.30
  • Loading branch information
mike-ward authored Aug 25, 2016
1 parent 4424000 commit a4cf980
Show file tree
Hide file tree
Showing 100 changed files with 3,173 additions and 1,804 deletions.
5 changes: 4 additions & 1 deletion src/MarkdownEdit.sln
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MarkdownEdit", "MarkdownEdit\MarkdownEdit.csproj", "{DE1D15CE-DF4B-4BD8-8A15-2306C3896885}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{9B81C9BB-9A90-41EB-9AFE-6401D6217D5B}"
ProjectSection(SolutionItems) = preProject
MarkdownEdit\app.manifest = MarkdownEdit\app.manifest
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "UnitTests\UnitTests.csproj", "{EC7EE115-CDB3-4216-8C3A-41422EC3BDAB}"
EndProject
Expand Down
3 changes: 3 additions & 0 deletions src/MarkdownEdit/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@
</setting>
</MarkdownEdit.Properties.Settings>
</userSettings>
<runtime>
<AppContextSwitchOverrides value = "Switch.System.Windows.DoNotScaleForDpiChanges=false"/>
</runtime>
</configuration>
10 changes: 10 additions & 0 deletions src/MarkdownEdit/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows;
Expand Down Expand Up @@ -31,6 +32,15 @@ public partial class App
[DllImport("user32.dll")]
private static extern bool IsIconic(IntPtr hWnd);

public App()
{
// Enable Multi-JIT startup
var profileRoot = UserSettings.SettingsFolder;
Directory.CreateDirectory(profileRoot);
ProfileOptimization.SetProfileRoot(profileRoot);
ProfileOptimization.StartProfile("Startup.profile");
}

private void OnStartup(object sender, StartupEventArgs ea)
{
InitializeSettings();
Expand Down
22 changes: 22 additions & 0 deletions src/MarkdownEdit/Commands/CloseCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Windows;
using System.Windows.Input;
using MarkdownEdit.Controls;

namespace MarkdownEdit.Commands
{
internal static class CloseCommand
{
public static readonly RoutedCommand Command = ApplicationCommands.Close;

static CloseCommand()
{
Application.Current.MainWindow.CommandBindings.Add(new CommandBinding(Command, Execute));
}

private static void Execute(object sender, ExecutedRoutedEventArgs e)
{
var mainWindow = (MainWindow)sender;
mainWindow.Close();
}
}
}
29 changes: 29 additions & 0 deletions src/MarkdownEdit/Commands/ConvertSelectionToListCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.Windows;
using System.Windows.Input;
using MarkdownEdit.Controls;
using MarkdownEdit.Models;

namespace MarkdownEdit.Commands
{
internal static class ConvertSelectionToListCommand
{
public static readonly RoutedCommand Command = new RoutedCommand();

static ConvertSelectionToListCommand()
{
Application.Current.MainWindow.CommandBindings.Add(new CommandBinding(Command, Execute, CanExecute));
}

private static void Execute(object sender, ExecutedRoutedEventArgs e)
{
var editor = ((MainWindow)sender).Editor;
EditorUtilities.ConvertSelectionToList(editor.EditBox);
}

private static void CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
var editor = ((MainWindow)sender).Editor;
e.CanExecute = !editor.EditBox.IsReadOnly;
}
}
}
23 changes: 23 additions & 0 deletions src/MarkdownEdit/Commands/DecreaseEditorMarginCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Windows;
using System.Windows.Input;
using MarkdownEdit.Controls;

namespace MarkdownEdit.Commands
{
internal static class DecreaseEditorMarginCommand
{
public static readonly RoutedCommand Command = new RoutedCommand();

static DecreaseEditorMarginCommand()
{
Application.Current.MainWindow.CommandBindings.Add(new CommandBinding(Command, Execute));
}

private static void Execute(object sender, ExecutedRoutedEventArgs e)
{
App.UserSettings.SinglePaneMargin =
Math.Min(App.UserSettings.SinglePaneMargin + 1, MainWindow.EditorMarginMax);
}
}
}
23 changes: 23 additions & 0 deletions src/MarkdownEdit/Commands/DecreaseFontSizeCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Windows;
using System.Windows.Documents;
using System.Windows.Input;
using MarkdownEdit.Controls;

namespace MarkdownEdit.Commands
{
internal static class DecreaseFontSizeCommand
{
public static readonly RoutedCommand Command = EditingCommands.DecreaseFontSize;

static DecreaseFontSizeCommand()
{
Application.Current.MainWindow.CommandBindings.Add(new CommandBinding(Command, Execute));
}

private static void Execute(object sender, ExecutedRoutedEventArgs e)
{
var mainWindow = (MainWindow)sender;
mainWindow.Editor.DecreaseFontSize();
}
}
}
28 changes: 28 additions & 0 deletions src/MarkdownEdit/Commands/DeselectCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Windows;
using System.Windows.Input;
using MarkdownEdit.Controls;

namespace MarkdownEdit.Commands
{
internal static class DeselectCommand
{
public static readonly RoutedCommand Command = new RoutedCommand();

static DeselectCommand()
{
Application.Current.MainWindow.CommandBindings.Add(new CommandBinding(Command, Execute, CanExecute));
}

private static void Execute(object sender, ExecutedRoutedEventArgs e)
{
var editor = ((MainWindow)sender).Editor;
editor.EditBox.SelectionLength = 0;
}

private static void CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
var editor = ((MainWindow)sender).Editor;
e.CanExecute = !editor.EditBox.IsReadOnly;
}
}
}
23 changes: 23 additions & 0 deletions src/MarkdownEdit/Commands/EditorFindCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Input;
using MarkdownEdit.Controls;

namespace MarkdownEdit.Commands
{
internal static class EditorFindCommand
{
public static readonly RoutedCommand Command = new RoutedCommand();

static EditorFindCommand()
{
Application.Current.MainWindow.CommandBindings.Add(new CommandBinding(Command, Execute));
}

private static void Execute(object sender, ExecutedRoutedEventArgs e)
{
var mainWindow = (MainWindow)sender;
mainWindow.Editor.Find(e.Parameter as Regex);
}
}
}
25 changes: 25 additions & 0 deletions src/MarkdownEdit/Commands/EditorReplaceAllCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Input;
using MarkdownEdit.Controls;

namespace MarkdownEdit.Commands
{
internal static class EditorReplaceAllCommand
{
public static readonly RoutedCommand Command = new RoutedCommand();

static EditorReplaceAllCommand()
{
Application.Current.MainWindow.CommandBindings.Add(new CommandBinding(Command, Execute));
}

private static void Execute(object sender, ExecutedRoutedEventArgs e)
{
var mainWindow = (MainWindow)sender;
var tuple = (Tuple<Regex, string>)e.Parameter;
mainWindow.Editor.ReplaceAll(tuple.Item1, tuple.Item2);
}
}
}
25 changes: 25 additions & 0 deletions src/MarkdownEdit/Commands/EditorReplaceCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Input;
using MarkdownEdit.Controls;

namespace MarkdownEdit.Commands
{
internal static class EditorReplaceCommand
{
public static readonly RoutedCommand Command = new RoutedCommand();

static EditorReplaceCommand()
{
Application.Current.MainWindow.CommandBindings.Add(new CommandBinding(Command, Execute));
}

private static void Execute(object sender, ExecutedRoutedEventArgs e)
{
var mainWindow = (MainWindow)sender;
var tuple = (Tuple<Regex, string>)e.Parameter;
mainWindow.Editor.Replace(tuple.Item1, tuple.Item2);
}
}
}
22 changes: 22 additions & 0 deletions src/MarkdownEdit/Commands/EditorReplaceDialogCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Windows;
using System.Windows.Input;
using MarkdownEdit.Controls;

namespace MarkdownEdit.Commands
{
internal static class EditorReplaceDialogCommand
{
public static readonly RoutedCommand Command = ApplicationCommands.Replace;

static EditorReplaceDialogCommand()
{
Application.Current.MainWindow.CommandBindings.Add(new CommandBinding(Command, Execute));
}

private static void Execute(object sender, ExecutedRoutedEventArgs e)
{
var mainWindow = (MainWindow)sender;
mainWindow.Editor.ReplaceDialog();
}
}
}
23 changes: 23 additions & 0 deletions src/MarkdownEdit/Commands/ExportHtmlCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Windows;
using System.Windows.Input;
using MarkdownEdit.Controls;
using Clipboard = MarkdownEdit.Models.Clipboard;

namespace MarkdownEdit.Commands
{
internal static class ExportHtmlCommand
{
public static readonly RoutedCommand Command = new RoutedCommand();

static ExportHtmlCommand()
{
Application.Current.MainWindow.CommandBindings.Add(new CommandBinding(Command, Execute));
}

private static void Execute(object sender, ExecutedRoutedEventArgs e)
{
var mainWindow = (MainWindow)sender;
Clipboard.ExportHtmlToClipboard(mainWindow.Editor.Text);
}
}
}
23 changes: 23 additions & 0 deletions src/MarkdownEdit/Commands/ExportHtmlTemplateCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Windows;
using System.Windows.Input;
using MarkdownEdit.Controls;
using Clipboard = MarkdownEdit.Models.Clipboard;

namespace MarkdownEdit.Commands
{
internal static class ExportHtmlTemplateCommand
{
public static readonly RoutedCommand Command = new RoutedCommand();

static ExportHtmlTemplateCommand()
{
Application.Current.MainWindow.CommandBindings.Add(new CommandBinding(Command, Execute));
}

private static void Execute(object sender, ExecutedRoutedEventArgs e)
{
var mainWindow = (MainWindow)sender;
Clipboard.ExportHtmlToClipboard(mainWindow.Editor.Text, true);
}
}
}
22 changes: 22 additions & 0 deletions src/MarkdownEdit/Commands/FindNextCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Windows;
using System.Windows.Input;
using MarkdownEdit.Controls;

namespace MarkdownEdit.Commands
{
internal static class FindNextCommand
{
public static readonly RoutedCommand Command = new RoutedCommand();

static FindNextCommand()
{
Application.Current.MainWindow.CommandBindings.Add(new CommandBinding(Command, Execute));
}

private static void Execute(object sender, ExecutedRoutedEventArgs e)
{
var editor = ((MainWindow)sender).Editor;
editor.FindReplaceDialog.FindNext();
}
}
}
22 changes: 22 additions & 0 deletions src/MarkdownEdit/Commands/FindPreviousCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Windows;
using System.Windows.Input;
using MarkdownEdit.Controls;

namespace MarkdownEdit.Commands
{
internal static class FindPreviousCommand
{
public static readonly RoutedCommand Command = new RoutedCommand();

static FindPreviousCommand()
{
Application.Current.MainWindow.CommandBindings.Add(new CommandBinding(Command, Execute));
}

private static void Execute(object sender, ExecutedRoutedEventArgs e)
{
var editor = ((MainWindow)sender).Editor;
editor.FindReplaceDialog.FindPrevious();
}
}
}
Loading

0 comments on commit a4cf980

Please sign in to comment.