Skip to content

Commit

Permalink
Fixed some options not work after restart VS and allow disable compar…
Browse files Browse the repository at this point in the history
…e selected files menu
  • Loading branch information
heku committed Apr 6, 2024
1 parent cb1a0f5 commit 20d907d
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 8 deletions.
1 change: 1 addition & 0 deletions Kool.VsDiff.Linked/I18n.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Kool.VsDiff.Linked/I18n.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@
<data name="OptionsPage_EnableDiffClipboardWithFile" xml:space="preserve">
<value>Enable compare Clipboard content with selected file.</value>
</data>
<data name="OptionsPage_EnableDiffSelectedFiles" xml:space="preserve">
<value>Enable compare two selected files.</value>
</data>
<data name="OptionsPage_PreferToUsePreviewWindow" xml:space="preserve">
<value>Prefer to use preview window (if support).</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions Kool.VsDiff.Linked/I18n.zh-Hans.resx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@
<data name="OptionsPage_EnableDiffClipboardWithFile" xml:space="preserve">
<value>启用选中文件与剪贴板内容的比较功能</value>
</data>
<data name="OptionsPage_EnableDiffSelectedFiles" xml:space="preserve">
<value>启用两个选中文件的比较功能</value>
</data>
<data name="OptionsPage_PreferToUsePreviewWindow" xml:space="preserve">
<value>优先使用预览窗口 (如果支持的话)</value>
</data>
Expand Down
5 changes: 1 addition & 4 deletions Kool.VsDiff.Shared/Models/VS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,7 @@ private static List<NameFile> GetSelectedFiles(SelectedItems selectedItems)
{
continue;
}
if (files == null)
{
files = new List<NameFile>();
}
files ??= new List<NameFile>();
files.Add(new NameFile { Name = item.ProjectItem.Name, File = file });
}
return files ?? GetSelectedFilesInsideFolderView();
Expand Down
4 changes: 3 additions & 1 deletion Kool.VsDiff.Shared/Package.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke
CommandService.AddCommand(DiffClipboardWithFileCommand.Instance);
CommandService.AddCommand(DiffClipboardWithDocumentCommand.Instance);

Debug.WriteLine("Package is sited and initialized.");
Options.RefreshCommandsState();

Debug.WriteLine(NAME + " Package is initialized.");
}
}
14 changes: 11 additions & 3 deletions Kool.VsDiff.Shared/Pages/VsDiffOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ internal sealed class VsDiffOptions : UIElementDialogPage
public string CustomDiffToolPath { get; set; }
public string CustomDiffToolArgs { get; set; }

public bool DiffSelectedFilesEnabled { get; set; }
public bool DiffClipboardWithCodeEnabled { get; set; }
public bool DiffClipboardWithFileEnabled { get; set; }
public bool DiffClipboardWithDocumentEnabled { get; set; }
Expand All @@ -35,14 +36,20 @@ protected override void OnActivate(CancelEventArgs e)

protected override void OnApply(PageApplyEventArgs e)
{
DiffClipboardWithCodeCommand.Instance.Turn(DiffClipboardWithCodeEnabled);
DiffClipboardWithFileCommand.Instance.Turn(DiffClipboardWithFileEnabled);
DiffClipboardWithDocumentCommand.Instance.Turn(DiffClipboardWithDocumentEnabled);
RefreshCommandsState();
DiffToolFactory.ClearCache();

base.OnApply(e);
}

public void RefreshCommandsState()
{
DiffSelectedFilesCommand.Instance.Turn(DiffSelectedFilesEnabled);
DiffClipboardWithCodeCommand.Instance.Turn(DiffClipboardWithCodeEnabled);
DiffClipboardWithFileCommand.Instance.Turn(DiffClipboardWithFileEnabled);
DiffClipboardWithDocumentCommand.Instance.Turn(DiffClipboardWithDocumentEnabled);
}

protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
Expand All @@ -61,6 +68,7 @@ private void SetDefaults()
UseCustomDiffTool = false;
CustomDiffToolPath = @"%ProgramFiles(x86)%\WinMerge\WinMergeU.exe";
CustomDiffToolArgs = "-e -u \"$FILE1\" \"$FILE2\" -dl \"$NAME1\" -dr \"$NAME2\"";
DiffSelectedFilesEnabled = true;
DiffClipboardWithCodeEnabled = true;
DiffClipboardWithFileEnabled = true;
DiffClipboardWithDocumentEnabled = true;
Expand Down
1 change: 1 addition & 0 deletions Kool.VsDiff.Shared/Pages/VsDiffOptionsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
</Grid>
</StackPanel>
</GroupBox>
<CheckBox Margin="0,5,0,0" IsChecked="{Binding DiffSelectedFilesEnabled}" Content="{x:Static kv:I18n.OptionsPage_EnableDiffSelectedFiles}" />
<CheckBox Margin="0,5,0,0" IsChecked="{Binding DiffClipboardWithCodeEnabled}" Content="{x:Static kv:I18n.OptionsPage_EnableDiffClipboardWithCode}" />
<CheckBox Margin="0,5,0,0" IsChecked="{Binding DiffClipboardWithFileEnabled}" Content="{x:Static kv:I18n.OptionsPage_EnableDiffClipboardWithFile}" />
<CheckBox Margin="0,5,0,0" IsChecked="{Binding DiffClipboardWithDocumentEnabled}" Content="{x:Static kv:I18n.OptionsPage_EnableDiffClipboardWithDocument}" />
Expand Down
Binary file modified Screenshots/Configuration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 20d907d

Please sign in to comment.