Skip to content

Commit

Permalink
- Code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
wmjordan committed Jun 7, 2024
1 parent f77a037 commit 299e249
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
1 change: 1 addition & 0 deletions Codist/Codist.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
<Compile Include="AutoBuildVersion\BuildSetting.cs" />
<Compile Include="AutoBuildVersion\VersionRewriteMode.cs" />
<Compile Include="AutoBuildVersion\VersionSetting.cs" />
<Compile Include="Controls\ThemedRichTextBox.cs" />
<Compile Include="Commands\CancelRepeatingActionCommand.cs" />
<Compile Include="Helpers\VsImageHelper.cs" />
<Compile Include="Semantics\ArgumentAssignment.cs" />
Expand Down
1 change: 0 additions & 1 deletion Codist/Commands/ScreenshotCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.ComponentModel.Design;
using Codist.Controls;
using Microsoft.VisualStudio.Shell;
using R = Codist.Properties.Resources;
Expand Down
15 changes: 2 additions & 13 deletions Codist/Commands/WindowInformerCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace Codist.Commands
{
/// <summary>A command which displays information about the active window pane.</summary>
internal static class WindowInformerCommand
static class WindowInformerCommand
{
const int SubSectionFontSize = 14;

Expand All @@ -45,18 +45,7 @@ static void Execute(object sender, EventArgs e) {

[SuppressMessage("Usage", Suppression.VSTHRD010, Justification = Suppression.CheckedInCaller)]
static void DisplayWindowInfo(Window window) {
var tb = new RichTextBox {
BorderThickness = WpfHelper.NoMargin,
Background = ThemeHelper.DocumentPageBrush,
Foreground = ThemeHelper.DocumentTextBrush,
FontFamily = ThemeHelper.CodeTextFont,
IsDocumentEnabled = true,
IsReadOnly = true,
IsReadOnlyCaretVisible = true,
AcceptsReturn = false
};
tb.ApplyTemplate();
tb.GetFirstVisualChild<ScrollViewer>().ReferenceStyle(VsResourceKeys.ScrollViewerStyleKey);
var tb = new ThemedRichTextBox(true);
var blocks = tb.Document.Blocks;
blocks.Clear();
Section s;
Expand Down
23 changes: 23 additions & 0 deletions Codist/Controls/ThemedRichTextBox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Windows;
using System.Windows.Controls;
using Microsoft.VisualStudio.Shell;

namespace Codist.Controls
{
public class ThemedRichTextBox : RichTextBox
{
public ThemedRichTextBox(bool readOnly) {
BorderThickness = WpfHelper.NoMargin;
Background = ThemeHelper.DocumentPageBrush;
Foreground = ThemeHelper.DocumentTextBrush;
FontFamily = ThemeHelper.CodeTextFont;
IsDocumentEnabled = true;
IsReadOnly = readOnly;
IsReadOnlyCaretVisible = true;
AcceptsReturn = !readOnly;
ApplyTemplate();
this.GetFirstVisualChild<ScrollViewer>().ReferenceStyle(VsResourceKeys.ScrollViewerStyleKey);
}
}
}

0 comments on commit 299e249

Please sign in to comment.