Skip to content

Commit 585dbc7

Browse files
committed
add binding status for data source button
1 parent 92f7569 commit 585dbc7

2 files changed

Lines changed: 28 additions & 3 deletions

File tree

src/XamlViewer/ViewModels/TabsViewModel.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ public bool IsOpenDataSource
8282
_eventAggregator.GetEvent<OpenDataSourceEvent>().Publish(value);
8383
}
8484
}
85+
86+
private bool _isSyncDataSource;
87+
public bool IsSyncDataSource
88+
{
89+
get { return _isSyncDataSource; }
90+
private set { SetProperty(ref _isSyncDataSource, value); }
91+
}
8592

8693
private Action<int, int> _moveTabPosAction = null;
8794
public Action<int, int> MoveTabPosAction
@@ -106,6 +113,7 @@ public Action<int, int> MoveTabPosAction
106113
private void InitEvent()
107114
{
108115
_eventAggregator.GetEvent<InitWorkAreaEvent>().Subscribe(OnInitWorkArea);
116+
_eventAggregator.GetEvent<SyncDataSourceEvent>().Subscribe(OnSyncDataSource);
109117
}
110118

111119
private void InitCommand()
@@ -139,6 +147,7 @@ private void InitCommand()
139147
private void InitData()
140148
{
141149
_appData.DealExistedFileAction = DealExistedFile;
150+
IsSyncDataSource = _appData.Config.IsSyncDataSource;
142151

143152
XamlTabs = new ObservableCollection<TabViewModel>(_appData.Config.Files.Select(f => new TabViewModel(f, CloseXamlTab)));
144153
if (XamlTabs.Count == 0)
@@ -388,6 +397,11 @@ private void OnInitWorkArea()
388397
SaveAllCommand.RaiseCanExecuteChanged();
389398
}
390399

400+
private void OnSyncDataSource(string jsonString)
401+
{
402+
IsSyncDataSource = !string.IsNullOrWhiteSpace(jsonString);
403+
}
404+
391405
#endregion
392406

393407
#region Func

src/XamlViewer/Views/TabsControl.xaml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,22 @@
6767
</controls:DrawingIcon>
6868
</controls:StatusToggle.UnCheckedContent>
6969
</controls:StatusToggle>
70-
<ToggleButton Grid.Column="2" Width="35" ToolTip="Data Source"
70+
<ToggleButton Grid.Column="2" Width="35"
7171
IsChecked="{Binding IsOpenDataSource,Mode=TwoWay}"
7272
Style="{StaticResource {x:Static themes:ResourceKeys.NormalToggleButtonStyleKey}}">
73-
<Path Fill="{Binding Foreground, RelativeSource={RelativeSource AncestorType=ToggleButton}}"
74-
Data="M1,9 L1,10 5,10 5,9 z M0,8 L11,8 11,11 0,11 z M1,5 L1,6 5,6 5,5 z M0,4 L11,4 11,7 0,7 z M1,1 L1,2 5,2 5,1 z M0,0 L11,0 11,3 0,3 z"/>
73+
<ToggleButton.ToolTip>
74+
<StackPanel Orientation="Horizontal">
75+
<TextBlock Grid.Row="0" Grid.Column="0" Text="Data Source"/>
76+
<TextBlock Grid.Row="0" Grid.Column="1" Text=" [Binding]" HorizontalAlignment="Left"
77+
Visibility="{Binding IsSyncDataSource,Converter={StaticResource boolToVisibilityConverter}}"/>
78+
</StackPanel>
79+
</ToggleButton.ToolTip>
80+
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
81+
<Path Fill="{Binding Foreground, RelativeSource={RelativeSource AncestorType=ToggleButton}}"
82+
Data="M1,9 L1,10 5,10 5,9 z M0,8 L11,8 11,11 0,11 z M1,5 L1,6 5,6 5,5 z M0,4 L11,4 11,7 0,7 z M1,1 L1,2 5,2 5,1 z M0,0 L11,0 11,3 0,3 z"/>
83+
<Ellipse Height="7" Width="7" StrokeThickness="1" Stroke="#EFEFF2" Fill="#FF02D002" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,-2,-2,0"
84+
Visibility="{Binding IsSyncDataSource,Converter={StaticResource boolToVisibilityConverter}}"/>
85+
</Grid>
7586
</ToggleButton>
7687
<Path Grid.ColumnSpan="3" Stretch="Fill" Height="2" Stroke="#007ACC" StrokeThickness="2" Data="M0,0 1,0" VerticalAlignment="Bottom"/>
7788
<Popup Placement="Bottom" StaysOpen="False" AllowsTransparency="True"

0 commit comments

Comments
 (0)