Skip to content

Commit

Permalink
Merge pull request #41 from sergey-visual-studio/MouseWheelZoom
Browse files Browse the repository at this point in the history
Added miscellaneous feature to control editor mouse wheel zoom.
  • Loading branch information
sergey-visual-studio authored Jul 3, 2022
2 parents 13377b3 + c5906c1 commit cf637a0
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 40 deletions.
7 changes: 6 additions & 1 deletion DPackRx/Features/Miscellaneous/MouseWheelZoomListener.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.ComponentModel.Composition;

using DPackRx.Options;
using DPackRx.Services;
using DPackRx.Extensions;

using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Utilities;
Expand All @@ -21,7 +23,10 @@ internal class MouseWheelZoomListener : IWpfTextViewCreationListener

public void TextViewCreated(IWpfTextView textView)
{
textView.Options.SetOptionValue<bool>(DefaultWpfViewOptions.EnableMouseWheelZoomId, false);
var optionsService = _serviceProvider?.GetService<IOptionsService>(false);
var mouseWheelZoom = optionsService != null && optionsService.GetBoolOption(KnownFeature.Miscellaneous, "MouseWheelZoom", false);

textView.Options.SetOptionValue<bool>(DefaultWpfViewOptions.EnableMouseWheelZoomId, mouseWheelZoom);
}

#endregion
Expand Down
15 changes: 15 additions & 0 deletions DPackRx/Options/OptionsGeneral.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class OptionsGeneral : OptionsBase
#region Fields

private bool _logging;
private bool _mouseWheelZoom;
private ICommand _assignShortcutsCommand;
private ICommand _loggingCommand;
private ICommand _logFolderCommand;
Expand Down Expand Up @@ -61,6 +62,16 @@ public bool Logging
}
}

public bool MouseWheelZoom
{
get { return _mouseWheelZoom; }
set
{
_mouseWheelZoom = value;
RaisePropertyChanged(nameof(this.MouseWheelZoom));
}
}

#endregion

#region Commands
Expand Down Expand Up @@ -132,6 +143,7 @@ protected override void OnLoad()
if (!this.Logging)
_logging = true;
#endif
_mouseWheelZoom = this.OptionsService.GetBoolOption(KnownFeature.Miscellaneous, "MouseWheelZoom", false);

Refresh();
}
Expand All @@ -145,6 +157,8 @@ protected override void OnSave()

var log = this.ServiceProvider.GetService<ILog>();
log.Enabled = _logging;

this.OptionsService.SetBoolOption(KnownFeature.Miscellaneous, "MouseWheelZoom", _mouseWheelZoom);
}

#endregion
Expand All @@ -154,6 +168,7 @@ protected override void OnSave()
private void Refresh()
{
RaisePropertyChanged(nameof(this.Logging));
RaisePropertyChanged(nameof(this.MouseWheelZoom));
}

private void OnAssignShortcuts(object parameter)
Expand Down
54 changes: 33 additions & 21 deletions DPackRx/Options/OptionsGeneralControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:local="clr-namespace:DPackRx.Options"
xmlns:ui="clr-namespace:DPackRx.UI"
mc:Ignorable="d"
d:DesignHeight="200" d:DesignWidth="400">
d:DesignHeight="260" d:DesignWidth="400">

<UserControl.Resources>
<ResourceDictionary>
Expand All @@ -17,24 +17,36 @@
</ResourceDictionary>
</UserControl.Resources>

<DockPanel LastChildFill="False">
<TextBlock DockPanel.Dock="Top" Style="{StaticResource TextBlockTop}" />

<Button DockPanel.Dock="Top" Content="Keyboard Shortcuts" ToolTip="Assign keyboard shortcuts" Style="{StaticResource ButtonRegular}" Margin="0"
Command="{Binding AssignShortcutsCommand}" />

<Border DockPanel.Dock="Top" Style="{StaticResource BorderDiv}" />

<CheckBox DockPanel.Dock="Top" Content="Enable Logging"
IsEnabled="{Binding LoggingEnabled}"
IsChecked="{Binding Logging}" Command="{Binding LoggingCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=IsChecked}" />

<Button DockPanel.Dock="Top" Content="Open Log Folder" Style="{StaticResource ButtonRegular}"
Command="{Binding LogFolderCommand}" />

<Border DockPanel.Dock="Top" Style="{StaticResource BorderDiv}" />

<Button DockPanel.Dock="Top" Content="Reset All" ToolTip="Reset all settings" Style="{StaticResource ButtonRegular}"
Command="{Binding ResetAllCommand}" />
</DockPanel>
<Grid>
<Grid.RowDefinitions>
<RowDefinition MaxHeight="70" />
<RowDefinition MaxHeight="70" />
<RowDefinition MaxHeight="110" />
</Grid.RowDefinitions>

<GroupBox Header="Shortcuts">
<Button Content="Keyboard shortcuts" ToolTip="Assign keyboard shortcuts" Style="{StaticResource ButtonRegular}" Margin="4,4,0,0"
Command="{Binding AssignShortcutsCommand}" />
</GroupBox>

<GroupBox Grid.Row="1" Header="Logging" Margin="0,16,0,0">
<CheckBox Content="Enable logging" Margin="4,12,0,0"
IsEnabled="{Binding LoggingEnabled}"
IsChecked="{Binding Logging}" Command="{Binding LoggingCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=IsChecked}" />
</GroupBox>

<GroupBox Grid.Row="2" Header="Miscellaneous" Margin="0,16,0,0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<CheckBox Content="Editor mouse wheel zoom" Margin="4,12,0,12"
IsChecked="{Binding MouseWheelZoom}" />
<Button Grid.Row="1" Content="Reset all" ToolTip="Reset all settings" Style="{StaticResource ButtonRegular}" Margin="4,0,0,0"
Command="{Binding ResetAllCommand}" />
</Grid>
</GroupBox>
</Grid>
</UserControl>
6 changes: 0 additions & 6 deletions DPackRx/UI/Styles/OptionsDictionary.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:DPackRx.UI">

<Style x:Key="BorderDiv" TargetType="Border">
<Setter Property="Height" Value="1" />
<Setter Property="Background" Value="Gray" />
<Setter Property="Margin" Value="0,12,0,0" />
</Style>

<Style TargetType="CheckBox">
<Setter Property="Margin" Value="0,12,0,0" />
</Style>
Expand Down
13 changes: 1 addition & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Build Status](https://dev.azure.com/sergey-visual-studio/dpack/_apis/build/status/sergey-visual-studio.dpack?branchName=master)](https://dev.azure.com/sergey-visual-studio/dpack/_build/latest?definitionId=1&branchName=master)

[[What is DPack Rx]](#what-is-dpack-rx) [[What's included]](#what-features-are-included-so-far) [[Major changes]](#major-changes) [[Future plans]](#future-plans) [[Contribute]](#help-needed) [[Donate]](#donate)
[[What is DPack Rx]](#what-is-dpack-rx) [[What's included]](#what-features-are-included-so-far) [[Major changes]](#major-changes) [[Future plans]](#future-plans) [[Contribute]](#help-needed)

### DPack Rx (former DPack)

Expand Down Expand Up @@ -51,14 +51,3 @@ Driving principal behind DPack design is fire-and-forget user experience with mi
Thanks and enjoy.

Sergey Mishkovskiy

### Donate

If you wish to express your appreciation
for the time and resources the authors have expended developing and supporting
DPack over the years, we do accept and appreciate donations.
You can contribute via PayPal donate button below.

Thank you for your support!

[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif "Donate")](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DXDC8CEJZRQLE&source=url)

0 comments on commit cf637a0

Please sign in to comment.