-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from rizi/master
Font size of region lines will be smaller.
- Loading branch information
Showing
12 changed files
with
534 additions
and
21 deletions.
There are no files selected for viewing
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
27 changes: 27 additions & 0 deletions
27
ExpandRegions/ExpandRegions/Classifications/ActiveRegionClassification.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,27 @@ | ||
using System.ComponentModel.Composition; | ||
using System.Windows.Media; | ||
|
||
using Microsoft.VisualStudio.Text.Classification; | ||
using Microsoft.VisualStudio.Utilities; | ||
|
||
namespace ExpandRegions.Classifications | ||
{ | ||
[Export(typeof(EditorFormatDefinition))] | ||
[ClassificationType(ClassificationTypeNames = Constants.ActiveRegionClassificationTypeNames)] | ||
[Name(Constants.ActiveRegionName)] | ||
[DisplayName(Constants.ActiveRegionName)] | ||
[UserVisible(true)] | ||
[Order(After = Constants.OrderAfterPriority, Before = Constants.OrderBeforePriority)] | ||
internal sealed class ActiveRegionClassification : ClassificationFormatDefinition | ||
{ | ||
#region Initialization | ||
|
||
// Methods | ||
public ActiveRegionClassification() | ||
{ | ||
ForegroundColor = Colors.DarkGray; | ||
} | ||
|
||
#endregion | ||
} | ||
} |
166 changes: 166 additions & 0 deletions
166
ExpandRegions/ExpandRegions/Classifications/ClassificationFormatDefinition.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,166 @@ | ||
using System.Globalization; | ||
using System.Windows; | ||
using System.Windows.Media; | ||
|
||
using Microsoft.VisualStudio.Text.Classification; | ||
|
||
namespace ExpandRegions.Classifications | ||
{ | ||
internal abstract class ClassificationFormatDefinition : EditorFormatDefinition | ||
{ | ||
#region Protected Methods | ||
|
||
protected override ResourceDictionary CreateResourceDictionaryFromDefinition() | ||
{ | ||
ResourceDictionary resourceDictionary = new ResourceDictionary(); | ||
AddOverridableProperties(resourceDictionary); | ||
if (ForegroundBrush != null) | ||
{ | ||
resourceDictionary["Foreground"] = ForegroundBrush; | ||
if (ForegroundBrush.Opacity != 1.0) | ||
{ | ||
resourceDictionary["ForegroundOpacity"] = ForegroundBrush.Opacity; | ||
} | ||
} | ||
if (BackgroundBrush != null) | ||
{ | ||
resourceDictionary["Background"] = BackgroundBrush; | ||
if (BackgroundBrush.Opacity != 1.0) | ||
{ | ||
resourceDictionary["BackgroundOpacity"] = BackgroundBrush.Opacity; | ||
} | ||
} | ||
if (FontTypeface != null) | ||
{ | ||
resourceDictionary.Add("Typeface", FontTypeface); | ||
if (FontTypeface.Weight == FontWeights.Bold) | ||
{ | ||
resourceDictionary["IsBold"] = true; | ||
} | ||
if (FontTypeface.Style == FontStyles.Italic) | ||
{ | ||
resourceDictionary["IsItalic"] = true; | ||
} | ||
} | ||
if (FontRenderingSize.HasValue) | ||
{ | ||
resourceDictionary.Add("FontRenderingSize", FontRenderingSize.Value); | ||
} | ||
if (FontHintingSize.HasValue) | ||
{ | ||
resourceDictionary.Add("FontHintingSize", FontHintingSize.Value); | ||
} | ||
if (TextDecorations != null) | ||
{ | ||
resourceDictionary.Add("TextDecorations", TextDecorations); | ||
} | ||
if (TextEffects != null) | ||
{ | ||
resourceDictionary.Add("TextEffects", TextEffects); | ||
} | ||
if (CultureInfo != null) | ||
{ | ||
resourceDictionary.Add("CultureInfo", CultureInfo); | ||
} | ||
return resourceDictionary; | ||
} | ||
|
||
#endregion | ||
|
||
#region Private Methods | ||
|
||
private void AddOverridableProperties(ResourceDictionary resourceDictionary) | ||
{ | ||
if (ForegroundOpacity.HasValue) | ||
{ | ||
resourceDictionary.Add("ForegroundOpacity", ForegroundOpacity.Value); | ||
} | ||
if (BackgroundOpacity.HasValue) | ||
{ | ||
resourceDictionary.Add("BackgroundOpacity", BackgroundOpacity.Value); | ||
} | ||
if (IsBold.HasValue) | ||
{ | ||
resourceDictionary.Add("IsBold", IsBold.Value); | ||
} | ||
if (IsItalic.HasValue) | ||
{ | ||
resourceDictionary.Add("IsItalic", IsItalic.Value); | ||
} | ||
if (ForegroundColor.HasValue) | ||
{ | ||
resourceDictionary["Foreground"] = new SolidColorBrush(ForegroundColor.Value); | ||
} | ||
if (BackgroundColor.HasValue) | ||
{ | ||
resourceDictionary["Background"] = new SolidColorBrush(BackgroundColor.Value); | ||
} | ||
} | ||
|
||
#endregion | ||
|
||
#region Public Properties | ||
|
||
public double? BackgroundOpacity | ||
{ | ||
get; | ||
protected set; | ||
} | ||
|
||
public CultureInfo CultureInfo | ||
{ | ||
get; | ||
protected set; | ||
} | ||
|
||
public double? FontHintingSize | ||
{ | ||
get; | ||
protected set; | ||
} | ||
|
||
public double? FontRenderingSize | ||
{ | ||
get; | ||
protected set; | ||
} | ||
|
||
public Typeface FontTypeface | ||
{ | ||
get; | ||
protected set; | ||
} | ||
|
||
public double? ForegroundOpacity | ||
{ | ||
get; | ||
protected set; | ||
} | ||
|
||
public bool? IsBold | ||
{ | ||
get; | ||
protected set; | ||
} | ||
|
||
public bool? IsItalic | ||
{ | ||
get; | ||
protected set; | ||
} | ||
|
||
public TextDecorationCollection TextDecorations | ||
{ | ||
get; | ||
protected set; | ||
} | ||
|
||
public TextEffectCollection TextEffects | ||
{ | ||
get; | ||
protected set; | ||
} | ||
|
||
#endregion | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
ExpandRegions/ExpandRegions/Classifications/ClassifierProvider.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,22 @@ | ||
using System.ComponentModel.Composition; | ||
|
||
using Microsoft.VisualStudio.Text.Classification; | ||
using Microsoft.VisualStudio.Utilities; | ||
|
||
namespace ExpandRegions.Classifications | ||
{ | ||
internal sealed class ClassifierProvider | ||
{ | ||
#region Internal Fields | ||
|
||
[Export] | ||
[Name(Constants.ActiveRegionClassificationTypeNames)] | ||
internal static ClassificationTypeDefinition ActiveRegionDefinition; | ||
|
||
[Export] | ||
[Name(Constants.InactiveRegionClassificationTypeNames)] | ||
internal static ClassificationTypeDefinition InactiveRegionDefinition; | ||
|
||
#endregion | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
ExpandRegions/ExpandRegions/Classifications/InactiveRegionClassification.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,29 @@ | ||
using System.ComponentModel.Composition; | ||
using System.Windows.Media; | ||
|
||
using Microsoft.VisualStudio.Text.Classification; | ||
using Microsoft.VisualStudio.Utilities; | ||
|
||
namespace ExpandRegions.Classifications | ||
{ | ||
[Export(typeof(EditorFormatDefinition))] | ||
[ClassificationType(ClassificationTypeNames = Constants.InactiveRegionClassificationTypeNames)] | ||
[Name(Constants.InactiveRegionName)] | ||
[DisplayName(Constants.InactiveRegionName)] | ||
[UserVisible(true)] | ||
[Order(After =Constants.OrderAfterPriority, Before = Constants.OrderBeforePriority)] | ||
internal sealed class InactiveRegionClassification : ClassificationFormatDefinition | ||
{ | ||
#region Initialization | ||
|
||
// Methods | ||
public InactiveRegionClassification() | ||
{ | ||
ForegroundColor = Colors.Gray; | ||
FontRenderingSize = 10; | ||
ForegroundOpacity = 0.5; | ||
} | ||
|
||
#endregion | ||
} | ||
} |
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,25 @@ | ||
namespace ExpandRegions | ||
{ | ||
internal static class Constants | ||
{ | ||
#region Internal Fields | ||
|
||
internal const char RegionIndicatorCharacter = '#'; | ||
internal const string RegionIndicator = "#region"; | ||
|
||
internal const string CSharpContentType = "CSharp"; | ||
internal const string BasicContentType = "Basic"; | ||
|
||
internal const string TextViewRole = "DOCUMENT"; | ||
|
||
internal const string ActiveRegionName = "Active Region"; | ||
internal const string InactiveRegionName = "Inactive Region"; | ||
internal const string ActiveRegionClassificationTypeNames = "activeRegion"; | ||
internal const string InactiveRegionClassificationTypeNames = "inactiveRegion"; | ||
|
||
internal const string OrderAfterPriority = "Default Priority"; | ||
internal const string OrderBeforePriority = "High Priority"; | ||
|
||
#endregion | ||
} | ||
} |
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.