-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
TN8001
committed
Aug 27, 2018
1 parent
1378df5
commit 5aa5ea7
Showing
26 changed files
with
1,362 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,30 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.28010.2003 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoHideTabRename", "AutoHideTabRename\AutoHideTabRename.csproj", "{DFB3B197-B75C-4193-96F7-80A7CC4F1D43}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B70C6667-8F5A-4EAC-A9C7-203ADFE19B38}" | ||
ProjectSection(SolutionItems) = preProject | ||
README.md = README.md | ||
EndProjectSection | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{DFB3B197-B75C-4193-96F7-80A7CC4F1D43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{DFB3B197-B75C-4193-96F7-80A7CC4F1D43}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{DFB3B197-B75C-4193-96F7-80A7CC4F1D43}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{DFB3B197-B75C-4193-96F7-80A7CC4F1D43}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {5AC2AC7C-A2DC-4C50-A6DB-ECAB9A92D0E2} | ||
EndGlobalSection | ||
EndGlobal |
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<UserControl | ||
x:Class="AutoHideTabRename.SettingsControl" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:AutoHideTabRename" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
d:DesignHeight="200" | ||
d:DesignWidth="400" | ||
mc:Ignorable="d"> | ||
<UserControl.Resources> | ||
<Style TargetType="{x:Type TextBlock}"> | ||
<Style.Triggers> | ||
<Trigger Property="IsEnabled" Value="False"> | ||
<Setter Property="Foreground" Value="{StaticResource {x:Static SystemColors.GrayTextBrushKey}}" /> | ||
</Trigger> | ||
</Style.Triggers> | ||
</Style> | ||
<Style TargetType="{x:Type Button}"> | ||
<Setter Property="MinWidth" Value="80" /> | ||
<Setter Property="Margin" Value="5" /> | ||
</Style> | ||
</UserControl.Resources> | ||
<GroupBox> | ||
<GroupBox.Header> | ||
<CheckBox | ||
x:Name="checkBox" | ||
VerticalContentAlignment="Center" | ||
Content="Rename" | ||
IsChecked="{Binding Settings.IsEnabled}" /> | ||
</GroupBox.Header> | ||
<Grid IsEnabled="{Binding Settings.IsEnabled}"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
</Grid.RowDefinitions> | ||
<ListBox | ||
x:Name="listBox" | ||
Grid.IsSharedSizeScope="True" | ||
ItemsSource="{Binding Settings.Items}" | ||
SelectedIndex="{Binding Index, Mode=OneTime}"> | ||
<ListBox.ItemTemplate> | ||
<DataTemplate DataType="{x:Type local:TabNameModel}"> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition SharedSizeGroup="a" /> | ||
<ColumnDefinition Width="Auto" /> | ||
<ColumnDefinition /> | ||
</Grid.ColumnDefinitions> | ||
<TextBlock Text="{Binding TargetName}" /> | ||
<TextBlock | ||
Grid.Column="1" | ||
Margin="5,0" | ||
Text="->" /> | ||
<TextBlock Grid.Column="2" Text="{Binding NewName}" /> | ||
</Grid> | ||
</DataTemplate> | ||
</ListBox.ItemTemplate> | ||
</ListBox> | ||
<StackPanel | ||
Grid.Row="1" | ||
HorizontalAlignment="Right" | ||
Orientation="Horizontal"> | ||
<Button Click="AddButton_Click" Content=" Add" /> | ||
<Button Click="DeleteButton_Click" Content=" Delete" /> | ||
</StackPanel> | ||
<GroupBox Grid.Row="2"> | ||
<GroupBox.Header> | ||
<TextBlock Text="Edit" /> | ||
</GroupBox.Header> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition /> | ||
<ColumnDefinition Width="Auto" /> | ||
<ColumnDefinition /> | ||
</Grid.ColumnDefinitions> | ||
<TextBox Text="{Binding SelectedItem.TargetName, ElementName=listBox, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True}" /> | ||
<TextBlock | ||
Grid.Column="1" | ||
Margin="5,0" | ||
VerticalAlignment="Center" | ||
Text="->" /> | ||
<TextBox Grid.Column="2" Text="{Binding SelectedItem.NewName, ElementName=listBox, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True}" /> | ||
</Grid> | ||
</GroupBox> | ||
</Grid> | ||
</GroupBox> | ||
</UserControl> |
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.Collections; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
|
||
namespace AutoHideTabRename | ||
{ | ||
public partial class SettingsControl : UserControl | ||
{ | ||
private IList items => ((ViewModel)DataContext).Settings.Items; | ||
|
||
|
||
public SettingsControl() => InitializeComponent(); | ||
|
||
private void AddButton_Click(object sender, RoutedEventArgs e) | ||
{ | ||
items.Add(new TabNameModel("Target Name", "New Name")); | ||
listBox.SelectedIndex = items.Count - 1; | ||
} | ||
private void DeleteButton_Click(object sender, RoutedEventArgs e) | ||
{ | ||
if(listBox.SelectedItem is TabNameModel tab) | ||
{ | ||
var i = listBox.SelectedIndex; | ||
items.Remove(tab); | ||
listBox.SelectedIndex = i > items.Count - 1 ? items.Count - 1 : i; | ||
} | ||
} | ||
} | ||
} |
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,47 @@ | ||
using AutoHideTabRename.Utility; | ||
using System.Collections.ObjectModel; | ||
using System.Linq; | ||
using System.Runtime.Serialization; | ||
|
||
namespace AutoHideTabRename | ||
{ | ||
[DataContract] | ||
public class SettingsModel : Observable | ||
{ | ||
// 筋悪だがDistinctの都合上PropertyChanged | ||
[DataMember] | ||
public ObservableCollection<TabNameModel> Items { get => _Items; set => Set(ref _Items, value); } | ||
private ObservableCollection<TabNameModel> _Items; | ||
|
||
[DataMember] | ||
public bool IsEnabled { get => _IsEnabled; set => Set(ref _IsEnabled, value); } | ||
private bool _IsEnabled; | ||
|
||
|
||
public SettingsModel() => Init(); | ||
|
||
[OnDeserializing] | ||
private void OnDeserializing(StreamingContext sc) => Init(); | ||
private void Init() | ||
{ | ||
IsEnabled = true; | ||
Items = new ObservableCollection<TabNameModel> | ||
{ | ||
new TabNameModel("ソリューション エクスプローラー", "ソリューション"), | ||
new TabNameModel("チーム エクスプローラー", "チーム"), | ||
new TabNameModel("サーバー エクスプローラー", "サーバー"), | ||
new TabNameModel("SQL Server オブジェクト エクスプローラー", "SQL Server オブジェクト"), | ||
new TabNameModel("ソース管理エクスプローラー", "ソース管理"), | ||
new TabNameModel("タスク ランナー エクスプローラー", "タスク ランナー"), | ||
new TabNameModel("テスト エクスプローラー", "テスト"), | ||
new TabNameModel("ライブ プロパティ エクスプローラー", "ライブ プロパティ"), | ||
}; | ||
} | ||
// 重複を削除 上が優先 | ||
public void Distinct() | ||
{ | ||
var d = Items.GroupBy(x => x.TargetName).Select(x => x.First()); | ||
Items = new ObservableCollection<TabNameModel>(d); | ||
} | ||
} | ||
} |
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,53 @@ | ||
using Microsoft.VisualStudio.Shell; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Runtime.InteropServices; | ||
using System.Windows; | ||
|
||
namespace AutoHideTabRename | ||
{ | ||
public delegate void TabNameEventHandler(object sender, TabNameEventArgs e); | ||
|
||
[ClassInterface(ClassInterfaceType.AutoDual)] | ||
[Guid("E294381C-B0B4-472E-8267-6D9F819F1F58")] | ||
public sealed class SettingsPage : UIElementDialogPage | ||
{ | ||
public event TabNameEventHandler NameChanged; | ||
|
||
protected override UIElement Child => view; | ||
|
||
private readonly SettingsControl view = new SettingsControl(); | ||
private readonly ViewModel vm = new ViewModel(); | ||
|
||
private bool saved = true; | ||
|
||
|
||
public SettingsPage() => view.DataContext = vm; | ||
|
||
public IReadOnlyDictionary<string, string> GetNames() => vm.GetNames(); | ||
|
||
public override void LoadSettingsFromStorage() | ||
{ | ||
Debug.WriteLine("LoadSettingsFromStorage"); | ||
|
||
vm.Load(); | ||
base.LoadSettingsFromStorage(); | ||
|
||
if(saved) | ||
{ | ||
NameChanged?.Invoke(this, new TabNameEventArgs(GetNames())); | ||
saved = false; | ||
} | ||
} | ||
public override void SaveSettingsToStorage() | ||
{ | ||
Debug.WriteLine("SaveSettingsToStorage"); | ||
|
||
saved = true; | ||
vm.Save(); | ||
|
||
base.SaveSettingsToStorage(); | ||
} | ||
} | ||
} |
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,32 @@ | ||
using AutoHideTabRename.Utility; | ||
using System; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.Serialization; | ||
|
||
namespace AutoHideTabRename | ||
{ | ||
[DataContract] | ||
public class TabNameModel : Observable | ||
{ | ||
[DataMember] | ||
public string TargetName { get => _TargetName; set => SetNotNullOrEmpty(ref _TargetName, value); } | ||
private string _TargetName; | ||
|
||
[DataMember] | ||
public string NewName { get => _NewName; set => SetNotNullOrEmpty(ref _NewName, value); } | ||
private string _NewName; | ||
|
||
|
||
public TabNameModel(string targetName, string newName) | ||
=> (TargetName, NewName) = (targetName, newName); | ||
|
||
|
||
private void SetNotNullOrEmpty(ref string storage, string value, [CallerMemberName] string propertyName = null) | ||
{ | ||
if(value.IsNullOrEmpty()) throw new ArgumentNullException(nameof(propertyName)); | ||
Set(ref storage, value, propertyName); | ||
} | ||
|
||
public override string ToString() => $"{TargetName} -> {NewName}"; | ||
} | ||
} |
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,38 @@ | ||
using AutoHideTabRename.Utility; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace AutoHideTabRename | ||
{ | ||
public class ViewModel : Observable | ||
{ | ||
// オプションページが閉じたときにまるごと上書き(キャンセルでも) | ||
public SettingsModel Settings { get => _Settings; set => Set(ref _Settings, value); } | ||
private SettingsModel _Settings; | ||
|
||
// 開いた時にOneTimeで強制選択 選択がないとUIがわかりにくいかと | ||
// (Editに入れてAddみたいに思われそう 空の時はどうしようもないが。。 | ||
public int Index { get; } = 0; | ||
|
||
|
||
public ViewModel() => Load(); | ||
|
||
public void Load() | ||
{ | ||
Settings = SerializeHelper.LoadOrDefault<SettingsModel>(); | ||
Settings.Distinct(); | ||
} | ||
public void Save() | ||
{ | ||
Settings.Distinct(); | ||
SerializeHelper.Save(Settings); | ||
} | ||
|
||
public IReadOnlyDictionary<string, string> GetNames() | ||
{ | ||
return Settings.IsEnabled | ||
? Settings.Items.ToDictionary(x => x.TargetName, x => x.NewName) | ||
: new Dictionary<string, string>(); | ||
} | ||
} | ||
} |
Oops, something went wrong.