-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug fixes, organization and a new feature (dim modes)
- Loading branch information
Showing
16 changed files
with
361 additions
and
174 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
Focus Dimmer/Classifiers/DimGray/DimGrayFormatDefinition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Microsoft.VisualStudio.Text.Classification; | ||
using Microsoft.VisualStudio.Utilities; | ||
using System.ComponentModel.Composition; | ||
using System.Windows.Media; | ||
|
||
namespace Focus_Dimmer.Classifiers | ||
{ | ||
[Export(typeof(EditorFormatDefinition))] | ||
[Name("Alpzy/DimGray")] | ||
[ClassificationType(ClassificationTypeNames = "Alpzy/DimGray")] | ||
[UserVisible(true)] | ||
[Order(After = Priority.High)] | ||
class DimGrayFormatDefinition : ClassificationFormatDefinition | ||
{ | ||
public DimGrayFormatDefinition() | ||
{ | ||
this.DisplayName = "DimGray Classifier"; // Human readable version of the name | ||
this.ForegroundColor = Colors.DimGray; | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Focus Dimmer/Classifiers/Transparent/TransparentFormatClassifierTypeDefinition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.ComponentModel.Composition; | ||
using Microsoft.VisualStudio.Text.Classification; | ||
using Microsoft.VisualStudio.Utilities; | ||
|
||
namespace Focus_Dimmer.Classifiers | ||
{ | ||
internal static class TransparentFormatClassifierTypeDefinition | ||
{ | ||
[Export(typeof(ClassificationTypeDefinition))] | ||
[Name("Alpzy/Transparent")] | ||
private static ClassificationTypeDefinition typeDefinition; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
Focus Dimmer/Classifiers/Transparent/TransparentFormatDefinition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Microsoft.VisualStudio.Text.Classification; | ||
using Microsoft.VisualStudio.Utilities; | ||
using System.ComponentModel.Composition; | ||
|
||
namespace Focus_Dimmer.Classifiers | ||
{ | ||
[Export(typeof(EditorFormatDefinition))] | ||
[Name("Alpzy/Transparent")] | ||
[ClassificationType(ClassificationTypeNames = "Alpzy/Transparent")] | ||
[UserVisible(true)] | ||
[Order(After = Priority.High)] | ||
class TransparentFormatDefinition : ClassificationFormatDefinition | ||
{ | ||
public TransparentFormatDefinition() | ||
{ | ||
this.DisplayName = "Transparent Classifier"; // Human readable version of the name | ||
this.ForegroundOpacity = 0.25; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System; | ||
using System.ComponentModel.Design; | ||
using Focus_Dimmer.Enums; | ||
using Microsoft.VisualStudio.Shell; | ||
using Task = System.Threading.Tasks.Task; | ||
|
||
namespace Focus_Dimmer.Commands | ||
{ | ||
public sealed class ToggleModeCommand | ||
{ | ||
public const int CommandId = 0x0101; | ||
|
||
public static readonly Guid CommandSet = new Guid("7cef4032-34d2-4bfd-9b60-b1ae5e3f0305"); | ||
|
||
private readonly AsyncPackage package; | ||
|
||
public EventHandler toggled; | ||
|
||
private ToggleModeCommand(AsyncPackage package, OleMenuCommandService commandService) | ||
{ | ||
this.package = package ?? throw new ArgumentNullException(nameof(package)); | ||
commandService = commandService ?? throw new ArgumentNullException(nameof(commandService)); | ||
var menuCommandID = new CommandID(CommandSet, CommandId); | ||
var menuItem = new MenuCommand(this.onToggled, menuCommandID); | ||
commandService.AddCommand(menuItem); | ||
} | ||
|
||
public static ToggleModeCommand Instance | ||
{ | ||
get; | ||
private set; | ||
} | ||
|
||
private Microsoft.VisualStudio.Shell.IAsyncServiceProvider ServiceProvider | ||
{ | ||
get | ||
{ | ||
return this.package; | ||
} | ||
} | ||
|
||
public static async Task InitializeAsync(AsyncPackage package) | ||
{ | ||
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken); | ||
|
||
OleMenuCommandService commandService = await package.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService; | ||
Instance = new ToggleModeCommand(package, commandService); | ||
} | ||
|
||
private void onToggled(object sender, EventArgs e) | ||
{ | ||
FocusDimmer.Mode = FocusDimmer.Mode == Modes.DimGray ? Modes.Transparent : Modes.DimGray; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Focus_Dimmer.Enums | ||
{ | ||
public enum Modes : int | ||
{ | ||
DimGray = 0, | ||
Transparent = 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.