Skip to content

Commit

Permalink
Dev (#244)
Browse files Browse the repository at this point in the history
* VS like selection style for editor
Signed-off-by: Konstantin Gawrilyako <[email protected]>
* update packages, remove browser unload code, move to vs2017
* update packages
* move to .net 4.7, update get/setter styles
* fix out of range crash
* fix out of range crash
* fix file in use crash
* fix some crash reports
* add github cmark for for future consideration
* update pandoc, mess around with cmark-gfm
  • Loading branch information
mike-ward committed Jun 10, 2017
1 parent b122000 commit 00a5929
Show file tree
Hide file tree
Showing 36 changed files with 351 additions and 287 deletions.
4 changes: 2 additions & 2 deletions src/MarkdownEdit/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/>
</startup>
<userSettings>
<MarkdownEdit.Properties.Settings>
Expand Down Expand Up @@ -43,6 +43,6 @@
</MarkdownEdit.Properties.Settings>
</userSettings>
<runtime>
<AppContextSwitchOverrides value = "Switch.System.Windows.DoNotScaleForDpiChanges=false"/>
<AppContextSwitchOverrides value="Switch.System.Windows.DoNotScaleForDpiChanges=false"/>
</runtime>
</configuration>
2 changes: 1 addition & 1 deletion src/MarkdownEdit/Commands/SnippetTabCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private static int StartOfListOffset(ITextSource textSource, int offset)
var startOffset = offset - 1;
while (startOffset > 0 && char.IsWhiteSpace(textSource.GetCharAt(startOffset)))
{
startOffset -= 1;
startOffset = Math.Min(0, startOffset - 1);
}
var c = textSource.GetCharAt(startOffset);
return (c == '-' || c == '*') ? startOffset : -1;
Expand Down
4 changes: 2 additions & 2 deletions src/MarkdownEdit/Controls/DisplayDocumentStructure.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public DisplayDocumentStructure()

public Block AbstractSyntaxTree
{
get { return (Block)GetValue(AbstractSyntaxTreeProperty); }
set { SetValue(AbstractSyntaxTreeProperty, value); }
get => (Block)GetValue(AbstractSyntaxTreeProperty);
set => SetValue(AbstractSyntaxTreeProperty, value);
}

private void OnIsVisibleChanged(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ internal class DisplayDocumentStructureViewModel : INotifyPropertyChanged

public DocumentStructure[] Structure
{
get { return _structure; }
set { Set(ref _structure, value); }
get => _structure;
set => Set(ref _structure, value);
}

public event PropertyChangedEventHandler PropertyChanged;
Expand Down Expand Up @@ -46,7 +46,7 @@ private string InlineContent(Inline inline)

public void Selected(int index)
{
var offset = index <= Structure.Length ? Structure[index].Offset : 0;
var offset = index >= 0 && index < Structure.Length ? Structure[index].Offset : 0;
ScrollToOffsetCommand.Command.Execute(offset, Application.Current.MainWindow);
}

Expand Down
4 changes: 2 additions & 2 deletions src/MarkdownEdit/Controls/DisplaySettings.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public DisplaySettings()

public ISpellCheckProvider SpellCheckProvider
{
get { return (ISpellCheckProvider)GetValue(SpellCheckProviderProperty); }
set { SetValue(SpellCheckProviderProperty, value); }
get => (ISpellCheckProvider)GetValue(SpellCheckProviderProperty);
set => SetValue(SpellCheckProviderProperty, value);
}

private void OnIsVisibleChanged(object sender,
Expand Down
22 changes: 21 additions & 1 deletion src/MarkdownEdit/Controls/Editor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,27 @@
ScrollViewer.ScrollChanged="ScrollViewerOnScrollChanged"
ShowLineNumbers="{Binding Path=ShowLineNumbers, Mode=TwoWay}"
VerticalScrollBarVisibility="{Binding VerticalScrollBarVisibility}"
WordWrap="{Binding Path=WordWrap, Mode=TwoWay}" />
WordWrap="{Binding Path=WordWrap, Mode=TwoWay}">
<avalonedit:TextEditor.Resources>
<Style TargetType="{x:Type avalonedit:TextArea}">
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="SelectionForeground" Value="{x:Null}" />
<Setter Property="SelectionCornerRadius" Value="0.0" />

<Setter Property="SelectionBrush">
<Setter.Value>
<SolidColorBrush Color="{DynamicResource {x:Static SystemColors.HighlightColorKey}}" Opacity="0.3" />
</Setter.Value>
</Setter>

<Setter Property="SelectionBorder">
<Setter.Value>
<Pen Brush="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" Thickness="0" />
</Setter.Value>
</Setter>
</Style>
</avalonedit:TextEditor.Resources>
</avalonedit:TextEditor>
</Border>

<UserControl.CommandBindings>
Expand Down
87 changes: 42 additions & 45 deletions src/MarkdownEdit/Controls/Editor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,123 +93,120 @@ public FindReplaceDialog FindReplaceDialog

public string Text
{
get { return EditBox.Text; }
set { EditBox.Text = value; }
get => EditBox.Text;
set => EditBox.Text = value;
}

public bool IsReadOnly
{
get { return EditBox.IsReadOnly; }
set { EditBox.IsReadOnly = value; }
get => EditBox.IsReadOnly;
set => EditBox.IsReadOnly = value;
}

public string FileName
{
get { return _fileName; }
set { Set(ref _fileName, value); }
get => _fileName;
set => Set(ref _fileName, value);
}

public string DisplayName
{
get
{
return string.IsNullOrWhiteSpace(_displayName) == false
? _displayName
: string.IsNullOrWhiteSpace(FileName)
? $"{Translate("editor-new-document")} {_f1ForHelp}"
: Path.GetFileName(FileName);
}
set { Set(ref _displayName, value); }
get => string.IsNullOrWhiteSpace(_displayName) == false
? _displayName
: string.IsNullOrWhiteSpace(FileName)
? $"{Translate("editor-new-document")} {_f1ForHelp}"
: Path.GetFileName(FileName);
set => Set(ref _displayName, value);
}

public bool IsModified
{
get { return _isModified; }
set { Set(ref _isModified, value); }
get => _isModified;
set => Set(ref _isModified, value);
}

public bool AutoSave
{
get { return (bool)GetValue(AutoSaveProperty); }
set { SetValue(AutoSaveProperty, value); }
get => (bool)GetValue(AutoSaveProperty);
set => SetValue(AutoSaveProperty, value);
}

public Theme Theme
{
get { return (Theme)GetValue(ThemeProperty); }
set { SetValue(ThemeProperty, value); }
get => (Theme)GetValue(ThemeProperty);
set => SetValue(ThemeProperty, value);
}

public ScrollBarVisibility VerticalScrollBarVisibility
{
get { return (ScrollBarVisibility)GetValue(VerticalScrollBarVisibilityProperty); }
set { SetValue(VerticalScrollBarVisibilityProperty, value); }
get => (ScrollBarVisibility)GetValue(VerticalScrollBarVisibilityProperty);
set => SetValue(VerticalScrollBarVisibilityProperty, value);
}

public bool ShowEndOfLine
{
get { return (bool)GetValue(ShowEndOfLineProperty); }
set { SetValue(ShowEndOfLineProperty, value); }
get => (bool)GetValue(ShowEndOfLineProperty);
set => SetValue(ShowEndOfLineProperty, value);
}

public bool ShowSpaces
{
get { return (bool)GetValue(ShowSpacesProperty); }
set { SetValue(ShowSpacesProperty, value); }
get => (bool)GetValue(ShowSpacesProperty);
set => SetValue(ShowSpacesProperty, value);
}

public bool ShowLineNumbers
{
get { return (bool)GetValue(ShowLineNumbersProperty); }
set { SetValue(ShowLineNumbersProperty, value); }
get => (bool)GetValue(ShowLineNumbersProperty);
set => SetValue(ShowLineNumbersProperty, value);
}

public bool ShowTabs
{
get { return (bool)GetValue(ShowTabsProperty); }
set { SetValue(ShowTabsProperty, value); }
get => (bool)GetValue(ShowTabsProperty);
set => SetValue(ShowTabsProperty, value);
}

public ISpellCheckProvider SpellCheckProvider
{
get { return (ISpellCheckProvider)GetValue(SpellCheckProviderProperty); }
set { SetValue(SpellCheckProviderProperty, value); }
get => (ISpellCheckProvider)GetValue(SpellCheckProviderProperty);
set => SetValue(SpellCheckProviderProperty, value);
}

public bool HighlightCurrentLine
{
get { return (bool)GetValue(HighlightCurrentLineProperty); }
set { SetValue(HighlightCurrentLineProperty, value); }
get => (bool)GetValue(HighlightCurrentLineProperty);
set => SetValue(HighlightCurrentLineProperty, value);
}

public ISnippetManager SnippetManager
{
get { return (ISnippetManager)GetValue(SnippetManagerProperty); }
set { SetValue(SnippetManagerProperty, value); }
get => (ISnippetManager)GetValue(SnippetManagerProperty);
set => SetValue(SnippetManagerProperty, value);
}

public bool WordWrap
{
get { return (bool)GetValue(WordWrapProperty); }
set { SetValue(WordWrapProperty, value); }
get => (bool)GetValue(WordWrapProperty);
set => SetValue(WordWrapProperty, value);
}

public bool SpellCheck
{
get { return (bool)GetValue(SpellCheckProperty); }
set { SetValue(SpellCheckProperty, value); }
get => (bool)GetValue(SpellCheckProperty);
set => SetValue(SpellCheckProperty, value);
}

public Block AbstractSyntaxTree
{
get { return (Block)GetValue(AbstractSyntaxTreeProperty); }
set { SetValue(AbstractSyntaxTreeProperty, value); }
get => (Block)GetValue(AbstractSyntaxTreeProperty);
set => SetValue(AbstractSyntaxTreeProperty, value);
}

public MyEncodingInfo Encoding
{
get { return (MyEncodingInfo)GetValue(MyEncodingInfoProperty); }
set { SetValue(MyEncodingInfoProperty, value); }
get => (MyEncodingInfo)GetValue(MyEncodingInfoProperty);
set => SetValue(MyEncodingInfoProperty, value);
}

private void OnIsVisibleChanged(object sender,
Expand Down
4 changes: 2 additions & 2 deletions src/MarkdownEdit/Controls/EncodingComboBox.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public partial class EncodingComboBox

public MyEncodingInfo SelectedEncoding
{
get { return (MyEncodingInfo)GetValue(SelectedEncodingProperty); }
set { SetValue(SelectedEncodingProperty, value); }
get => (MyEncodingInfo)GetValue(SelectedEncodingProperty);
set => SetValue(SelectedEncodingProperty, value);
}

public ICollection<MyEncodingInfo> SystemEncodings => MyEncodingInfo.GetEncodings();
Expand Down
8 changes: 5 additions & 3 deletions src/MarkdownEdit/Controls/FindReplaceDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ public FindReplaceDialog(FindReplaceSettings findReplaceSettings)
};
}

public string FindText { get { return _findText; } set { Set(ref _findText, value); } }
public string FindText { get => _findText;
set => Set(ref _findText, value);
}

public FindReplaceSettings FindReplaceSettings
{
get { return _findReplaceSettings; }
set { Set(ref _findReplaceSettings, value); }
get => _findReplaceSettings;
set => Set(ref _findReplaceSettings, value);
}

public event PropertyChangedEventHandler PropertyChanged;
Expand Down
8 changes: 4 additions & 4 deletions src/MarkdownEdit/Controls/FontComboBox.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ public partial class FontComboBox

public FontFamily SelectedFontFamily
{
get { return (FontFamily)GetValue(SelectedFontFamilyProperty); }
set { SetValue(SelectedFontFamilyProperty, value); }
get => (FontFamily)GetValue(SelectedFontFamilyProperty);
set => SetValue(SelectedFontFamilyProperty, value);
}

public double SelectedFontSize
{
get { return (double)GetValue(SelectedFontSizeProperty); }
set { SetValue(SelectedFontSizeProperty, value); }
get => (double)GetValue(SelectedFontSizeProperty);
set => SetValue(SelectedFontSizeProperty, value);
}
}
}
4 changes: 2 additions & 2 deletions src/MarkdownEdit/Controls/ImageDropDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public ImageDropDialog()

public string DocumentFileName
{
set { _vm.DocumentFileName = value; }
set => _vm.DocumentFileName = value;
}

public bool UseClipboardImage
{
set { _vm.UseClipboardImage = value; }
set => _vm.UseClipboardImage = value;
}

private void OnLoaded(object sender, EventArgs eventArgs)
Expand Down
12 changes: 6 additions & 6 deletions src/MarkdownEdit/Controls/ImageDropDialogViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ public class ImageDropDialogViewModel : INotifyPropertyChanged

public string DocumentFileName
{
get { return _documentFileName; }
set { Set(ref _documentFileName, value); }
get => _documentFileName;
set => Set(ref _documentFileName, value);
}

public bool Uploading
{
get { return _uploading; }
set { Set(ref _uploading, value); }
get => _uploading;
set => Set(ref _uploading, value);
}

public bool UseClipboardImage
{
get { return _useClipboardImage; }
set { Set(ref _useClipboardImage, value); }
get => _useClipboardImage;
set => Set(ref _useClipboardImage, value);
}

// INotifyPropertyChanged
Expand Down
Loading

0 comments on commit 00a5929

Please sign in to comment.