Skip to content

Commit 727f99e

Browse files
committed
feat: allow hide the icon of the session in tab view, close #715
1 parent 220fbe7 commit 727f99e

File tree

4 files changed

+99
-47
lines changed

4 files changed

+99
-47
lines changed

Ui/Service/ConfigurationService.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ public class GeneralConfig
4545
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
4646
public bool ShowSessionIconInSessionWindow = true;
4747

48+
[DefaultValue(true)]
49+
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
50+
public bool TabHeaderShowIconButton = true;
4851
[DefaultValue(true)]
4952
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
5053
public bool TabHeaderShowCloseButton = true;

Ui/View/Host/ProtocolHosts/HostBase.cs

Lines changed: 79 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Windows;
44
using System.Windows.Controls;
5+
using System.Windows.Controls.Ribbon;
56
using System.Windows.Data;
67
using System.Windows.Interop;
78
using _1RM.Model;
@@ -103,51 +104,85 @@ protected HostBase(ProtocolBase protocolServer, bool canFullScreen = false)
103104
});
104105
}
105106

106-
{
107-
var cb = new CheckBox
108-
{
109-
Content = IoC.Translate("Show XXX button", IoC.Translate("Reconnect") ?? ""),
110-
IsHitTestVisible = false,
111-
};
112-
113-
var binding = new Binding("TabHeaderShowReConnectButton")
114-
{
115-
Source = SettingsPage,
116-
Mode = BindingMode.TwoWay,
117-
UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
118-
};
119-
cb.SetBinding(CheckBox.IsCheckedProperty, binding);
120-
MenuItems.Add(new System.Windows.Controls.MenuItem()
121-
{
122-
Header = cb,
123-
Command = new RelayCommand((_) => { SettingsPage.TabHeaderShowReConnectButton = !SettingsPage.TabHeaderShowReConnectButton; }),
124-
});
125-
}
107+
MenuItems.Add(new Separator());
126108

127109
{
128-
var cb = new CheckBox
129-
{
130-
Content = IoC.Translate("Show XXX button", IoC.Translate("Close") ?? ""),
131-
IsHitTestVisible = false,
132-
};
133-
134-
var binding = new Binding("TabHeaderShowCloseButton")
135-
{
136-
Source = SettingsPage,
137-
Mode = BindingMode.TwoWay,
138-
UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
139-
};
140-
cb.SetBinding(CheckBox.IsCheckedProperty, binding);
141-
MenuItems.Add(new System.Windows.Controls.MenuItem()
142-
{
143-
Header = cb,
144-
Command = new RelayCommand((_) => { SettingsPage.TabHeaderShowCloseButton = !SettingsPage.TabHeaderShowCloseButton; }),
145-
});
146-
}
147-
148-
//MenuItems.Add(new RibbonApplicationSplitMenuItem());
149-
150-
var actions = protocolServer.GetActions(true);
110+
var subMenu = new System.Windows.Controls.MenuItem()
111+
{
112+
Header = IoC.Translate("Custom"),
113+
};
114+
115+
116+
{
117+
var cb = new CheckBox
118+
{
119+
Content = IoC.Translate("Show XXX button", IoC.Translate("Reconnect") ?? ""),
120+
IsHitTestVisible = false,
121+
};
122+
123+
var binding = new Binding("TabHeaderShowReConnectButton")
124+
{
125+
Source = SettingsPage,
126+
Mode = BindingMode.TwoWay,
127+
UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
128+
};
129+
cb.SetBinding(CheckBox.IsCheckedProperty, binding);
130+
subMenu.Items.Add(new System.Windows.Controls.MenuItem()
131+
{
132+
Header = cb,
133+
Command = new RelayCommand((_) => { SettingsPage.TabHeaderShowReConnectButton = !SettingsPage.TabHeaderShowReConnectButton; }),
134+
});
135+
}
136+
137+
{
138+
var cb = new CheckBox
139+
{
140+
Content = IoC.Translate("Show XXX button", IoC.Translate("Close") ?? ""),
141+
IsHitTestVisible = false,
142+
};
143+
144+
var binding = new Binding("TabHeaderShowCloseButton")
145+
{
146+
Source = SettingsPage,
147+
Mode = BindingMode.TwoWay,
148+
UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
149+
};
150+
cb.SetBinding(CheckBox.IsCheckedProperty, binding);
151+
subMenu.Items.Add(new System.Windows.Controls.MenuItem()
152+
{
153+
Header = cb,
154+
Command = new RelayCommand((_) => { SettingsPage.TabHeaderShowCloseButton = !SettingsPage.TabHeaderShowCloseButton; }),
155+
});
156+
}
157+
158+
159+
{
160+
var cb = new CheckBox
161+
{
162+
Content = IoC.Translate("Show XXX button", "Icon"),
163+
IsHitTestVisible = false,
164+
};
165+
166+
var binding = new Binding("TabHeaderShowIconButton")
167+
{
168+
Source = SettingsPage,
169+
Mode = BindingMode.TwoWay,
170+
UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
171+
};
172+
cb.SetBinding(CheckBox.IsCheckedProperty, binding);
173+
subMenu.Items.Add(new System.Windows.Controls.MenuItem()
174+
{
175+
Header = cb,
176+
Command = new RelayCommand((_) => { SettingsPage.TabHeaderShowIconButton = !SettingsPage.TabHeaderShowIconButton; }),
177+
});
178+
}
179+
180+
MenuItems.Add(subMenu);
181+
}
182+
183+
MenuItems.Add(new Separator());
184+
185+
var actions = protocolServer.GetActions(true);
151186
foreach (var action in actions)
152187
{
153188
var tb = new TextBlock()
@@ -184,7 +219,7 @@ public string ConnectionId
184219
/// <summary>
185220
/// special menu for tab
186221
/// </summary>
187-
public List<System.Windows.Controls.MenuItem> MenuItems { get; set; } = new List<System.Windows.Controls.MenuItem>();
222+
public List<System.Windows.Controls.Control> MenuItems { get; set; } = new List<System.Windows.Controls.Control>();
188223

189224
/// <summary>
190225
/// since resizing when rdp is connecting would not tiger the rdp size change event

Ui/View/Host/TabWindowView.xaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,16 @@
134134
</Grid.ColumnDefinitions>
135135

136136
<!--header item icon-->
137-
<Border Grid.Column="1" Padding="4 0 4 0">
137+
<Border Grid.Column="1" Padding="4 0 0 0"
138+
Visibility="{Binding Content.SettingsPage.TabHeaderShowIconButton, Converter={StaticResource ConverterBool2Visible}}"
139+
>
138140
<Grid Width="20" Height="20" VerticalAlignment="Center" HorizontalAlignment="Center">
139141
<Image Source="{Binding IconImg}" Stretch="Uniform"></Image>
140142
</Grid>
141143
</Border>
142144

143145
<!--header item content-->
144-
<Border Grid.Column="2" Padding="0" Margin="0 0 5 0">
146+
<Border Grid.Column="2" Padding="0" Margin="4 0 4 0">
145147
<TextBlock HorizontalAlignment="Center"
146148
VerticalAlignment="Center"
147149
TextTrimming="CharacterEllipsis"
@@ -152,7 +154,7 @@
152154
</Border>
153155

154156
<!--header item placeholder(do not move or remove this)-->
155-
<Thumb Grid.Column="0" Grid.ColumnSpan="4" HorizontalAlignment="Stretch" VerticalContentAlignment="Stretch" x:Name="PART_Thumb">
157+
<Thumb Grid.Column="0" Grid.ColumnSpan="4" HorizontalAlignment="Stretch" VerticalContentAlignment="Stretch" x:Name="PART_Thumb">
156158
<Thumb.Style>
157159
<Style TargetType="{x:Type Thumb}">
158160
<Setter Property="Background" Value="Transparent" />

Ui/View/Settings/SettingsPageViewModel.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ public Visibility ProgressBarVisibility
100100
public LauncherSettingViewModel LauncherSettingViewModel => IoC.Get<LauncherSettingViewModel>();
101101

102102

103+
public bool TabHeaderShowIconButton
104+
{
105+
get => _configurationService.General.TabHeaderShowIconButton;
106+
set
107+
{
108+
if (SetAndNotifyIfChanged(ref _configurationService.General.TabHeaderShowIconButton, value))
109+
{
110+
_configurationService.Save();
111+
}
112+
}
113+
}
114+
103115
public bool TabHeaderShowCloseButton
104116
{
105117
get => _configurationService.General.TabHeaderShowCloseButton;

0 commit comments

Comments
 (0)