Skip to content

Commit

Permalink
Opening configuration is not allowed when configuration is changed fr…
Browse files Browse the repository at this point in the history
…om tree view.
  • Loading branch information
dominikgolda committed May 30, 2019
1 parent cca22a1 commit 6156573
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/Soloplan.WhatsON.GUI/CustomTitleBar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
Kind="{Binding CustomButtonIcon}"
Visibility="{Binding CustomButtonVisible, Converter={StaticResource BoolToVis}}"
MouseDown="OnButtonClicked" />
<ContentControl Width="30" Height="30" Visibility="{Binding CustomButtonVisible, Converter={StaticResource InvertBoolToVis}}"/>

<Button Width="30"
Height="30"
Expand Down
4 changes: 2 additions & 2 deletions src/Soloplan.WhatsON.GUI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<DockPanel>
<local:CustomTitleBar ButtonClicked="OpenConfig"
CustomButtonIcon="SettingsOutline"
CustomButtonVisible="True"
CustomButtonVisible="{Binding ConfigurationModifiedFromTree, RelativeSource={RelativeSource AncestorType={x:Type local:MainWindow}}, Converter={StaticResource InvertBoolConverter}}"
DockPanel.Dock="Top"
ShowMinimizeButton="{Binding Path=ShowInTaskbar, RelativeSource={RelativeSource AncestorType={x:Type local:MainWindow}}}"
Window="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:MainWindow}}}" />
Expand Down Expand Up @@ -95,7 +95,7 @@
FontSize="18"
FontWeight="Bold"
Text="Loading..."
Visibility="{Binding IsTreeNotInitialized, Converter={StaticResource BoolToVis}}" />
Visibility="{Binding IsTreeInitialized, Converter={StaticResource InvertBoolToVis}}" />
</Grid>
</DockPanel>
</Window>
19 changes: 11 additions & 8 deletions src/Soloplan.WhatsON.GUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,9 @@ public bool IsTreeInitialized
{
this.initialized = value;
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(this.IsTreeInitialized)));
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(this.IsTreeNotInitialized)));
}
}

public bool IsTreeNotInitialized
{
get => !this.IsTreeInitialized;
}

/// <summary>
/// Gets or sets a value indicating whether configuration was modified from tree view.
/// </summary>
Expand Down Expand Up @@ -152,6 +146,11 @@ public void FocusSubject(Subject subject)

private void OpenConfig(object sender, EventArgs e)
{
if (this.ConfigurationModifiedFromTree)
{
return;
}

var configWindow = new ConfigWindow(this.config);
configWindow.Owner = this;
configWindow.ConfigurationApplied += (s, ev) =>
Expand Down Expand Up @@ -200,10 +199,14 @@ private void NewConnectorClick(object sender, RoutedEventArgs e)

private void MainTreeViewOnConfigurationChanged(object sender, EventArgs e)
{
var showAnimation = !this.ConfigurationModifiedFromTree;
this.ConfigurationModifiedFromTree = true;
if (this.FindResource("showStoryBoard") is Storyboard sb)
if (showAnimation)
{
this.BeginStoryboard(sb);
if (this.FindResource("showStoryBoard") is Storyboard sb)
{
this.BeginStoryboard(sb);
}
}
}

Expand Down

0 comments on commit 6156573

Please sign in to comment.