Skip to content

Commit

Permalink
Wpf froozing due visibility (#622)
Browse files Browse the repository at this point in the history
* Create draft PR for #620

* +wpf disposing fixed

* - removed unused converters
* wpf clean up

---------

Co-authored-by: peterbarancek <[email protected]>
  • Loading branch information
peterbarancek and peterbarancek authored Jul 21, 2023
1 parent cd4baa6 commit 11645e6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 102 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
xmlns:local="clr-namespace:TcoDrivesBeckhoff"
xmlns:materialdesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:tcoCore="http://vortex.mts/xaml"
xmlns:tcodrivesbeckhoff="clr-namespace:TcoDrivesBeckhoff"
xmlns:vortex="http://vortex.mts/xaml"
xmlns:inxton="http://vortex.mts/xaml"
mc:Ignorable="d">
<d:UserControl.DataContext>
<local:TcoDriveSimpleServiceViewModel/>
Expand All @@ -19,38 +17,38 @@

</UserControl.Resources>
<vortex:TcoComponentView >
<tcoCore:TcoComponentView.ComponentHeader>
<vortex:TcoComponentView.ComponentHeader>

<WrapPanel VerticalAlignment="Center" HorizontalAlignment="Left" DataContext="{Binding Component}" >
<WrapPanel.Resources>
<Style TargetType="TextBlock" BasedOn="{StaticResource MaterialDesignBody1TextBlock}"/>
</WrapPanel.Resources>
<WrapPanel DataContext="{Binding _axisStatus.Disabled}" Visibility="{Binding Cyclic, Converter={tcoCore:BooleanToVisibilityConverter}}" Margin=" 5,0">

<WrapPanel DataContext="{Binding _axisStatus.Disabled}" Visibility="{Binding Cyclic, Converter={vortex:BooleanToVisibilityConverter}}" Margin=" 5,0">
<materialdesign:PackIcon Kind="WarningBox" Foreground="{StaticResource Warning}" VerticalAlignment="Center"/>
<TextBlock Text="Disabled" Foreground="{StaticResource Warning}"/>
</WrapPanel>
<WrapPanel DataContext="{Binding _axisStatus.Operational}" Visibility="{Binding Cyclic, Converter={tcoCore:BooleanToVisibilityConverter}}" Margin=" 5,0">
<WrapPanel DataContext="{Binding _axisStatus.Operational}" Visibility="{Binding Cyclic, Converter={vortex:BooleanToVisibilityConverter}}" Margin=" 5,0">
<materialdesign:PackIcon Kind="CheckBox" Foreground="{StaticResource Notification}" VerticalAlignment="Center"/>
<TextBlock Text="Ready" Foreground="{StaticResource Notification}"/>
</WrapPanel>
<WrapPanel DataContext="{Binding _axisStatus.Homed}" Visibility="{Binding Cyclic, Converter={tcoCore:BooleanToVisibilityConverter}}" Margin=" 5,0">
<WrapPanel DataContext="{Binding _axisStatus.Homed}" Visibility="{Binding Cyclic, Converter={vortex:BooleanToVisibilityConverter}}" Margin=" 5,0">
<materialdesign:PackIcon Kind="CheckBox" Foreground="{StaticResource Notification}" VerticalAlignment="Center"/>
<TextBlock Text="Homed" Foreground="{StaticResource Notification}"/>
</WrapPanel>
<WrapPanel DataContext="{Binding _axisStatus.Homed}" Visibility="{Binding Cyclic, Converter={tcoCore:BooleanToVisibilityConverter},ConverterParameter=false}" Margin=" 5,0">
<WrapPanel DataContext="{Binding _axisStatus.Homed}" Visibility="{Binding Cyclic, Converter={vortex:BooleanToVisibilityConverter},ConverterParameter=false}" Margin=" 5,0">
<materialdesign:PackIcon Kind="CheckBox" Foreground="{StaticResource Warning}" VerticalAlignment="Center"/>
<TextBlock Text="Not Homed!" Foreground="{StaticResource Warning}"/>
</WrapPanel>
<WrapPanel Visibility="{Binding _axisStatus.Error.Cyclic, Converter={tcoCore:BooleanToVisibilityConverter}}" Margin=" 5,0">
<WrapPanel Visibility="{Binding _axisStatus.Error.Cyclic, Converter={vortex:BooleanToVisibilityConverter}}" Margin=" 5,0">
<materialdesign:PackIcon Kind="AlertBox" Foreground="{StaticResource Errors}" VerticalAlignment="Center"/>
<TextBlock VerticalAlignment="Center" Text="{Binding _axisStatus.ErrorId.Cyclic}" Foreground="{StaticResource Errors}" Visibility="{Binding _axisStatus.Error.Cyclic, Converter={tcoCore:BoolToVisibilityConverter}}"/>
<TextBlock VerticalAlignment="Center" Text="{Binding _axisStatus.ErrorId.Cyclic}" Foreground="{StaticResource Errors}" Visibility="{Binding _axisStatus.Error.Cyclic, Converter={vortex:BooleanToVisibilityConverter}}"/>
</WrapPanel>


</WrapPanel>

</tcoCore:TcoComponentView.ComponentHeader>
</vortex:TcoComponentView.ComponentHeader>
<vortex:TcoComponentView.ComponentDetails>
<ScrollViewer MaxHeight="1000" HorizontalScrollBarVisibility="Disabled" DataContext="{Binding Component}">
<Grid>
Expand Down Expand Up @@ -81,7 +79,7 @@



<TextBlock Margin="5" Style="{StaticResource MaterialDesignBody1TextBlock}" Visibility="{Binding _axisStatus.Error.Cyclic ,Converter={tcoCore:BooleanToVisibilityConverter }}" Foreground="{StaticResource OnErrors}" Background="{StaticResource Errors}" TextWrapping="WrapWithOverflow" Text="{Binding _axisStatus.ErrorId.Cyclic, Converter={local:ErrorIdToDescriptionConverter}}"></TextBlock>
<TextBlock Margin="5" Style="{StaticResource MaterialDesignBody1TextBlock}" Visibility="{Binding _axisStatus.Error.Cyclic ,Converter={vortex:BooleanToVisibilityConverter }}" Foreground="{StaticResource OnErrors}" Background="{StaticResource Errors}" TextWrapping="WrapWithOverflow" Text="{Binding _axisStatus.ErrorId.Cyclic, Converter={local:ErrorIdToDescriptionConverter}}"></TextBlock>

</StackPanel>

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ namespace TcoInspectors
/// <summary>
/// Interaction logic for InspectorDialogueWindow.xaml
/// </summary>
public partial class TcoInspectorDialogDialogView : Window
public partial class TcoInspectorDialogDialogView : Window, IDisposable
{
private TcoInspectorDialogDialogViewModel context;

public TcoInspectorDialogDialogView()
{
InitializeComponent();
Expand All @@ -30,7 +32,7 @@ public TcoInspectorDialogDialogView()

private void TcoInspectorDialogView_DataContextChanged(object sender, System.Windows.DependencyPropertyChangedEventArgs e)
{
var context = this.DataContext as TcoInspectorDialogDialogViewModel;
context = this.DataContext as TcoInspectorDialogDialogViewModel;
if (context != null)
{
context.CloseRequestEventHandler += (s, ev) => this.Close();
Expand All @@ -46,5 +48,14 @@ private void Window_TouchDown(object sender, TouchEventArgs e)
{
this.CaptureTouch(e.TouchDevice);
}
}
}

public void Dispose()
{
this.DataContextChanged -= TcoInspectorDialogView_DataContextChanged;
if (context != null)
{
context.CloseRequestEventHandler -= (s, ev) => this.Close();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using TcOpen.Inxton.Input;
using Vortex.Connector;
using Vortex.Connector.Identity;
using Vortex.Connector.ValueTypes;

namespace TcoInspectors
{
Expand All @@ -23,6 +24,8 @@ public TcoInspectorDialogDialogViewModel()

dispatcherTimer.Start();



RetryCommand = new RelayCommand((a) => { Dialog._dialogueRetry.Synchron = true; CloseRequestEventHandler(this, new EventArgs()); },
(b) => Dialog != null && !Dialog._isOverInspected.Synchron,
() => TcOpen.Inxton.TcoAppDomain.Current.Logger.Information($"{nameof(RetryCommand)} of {Dialog.HumanReadable} was executed @{{payload}}.", new { Dialog.Symbol }));
Expand All @@ -34,6 +37,7 @@ public TcoInspectorDialogDialogViewModel()
() => TcOpen.Inxton.TcoAppDomain.Current.Logger.Information($"{nameof(OverrideCommand)} of {Dialog.HumanReadable} was executed @{{payload}}.", new { Dialog.Symbol }));
}


List<IVortexObject> _inspectorsList;
public IEnumerable<IVortexObject> Inspectors
{
Expand Down Expand Up @@ -98,7 +102,7 @@ private void dispatcherTimer_Tick(object sender, EventArgs e)
if (Dialog._dialogueRetry.LastValue || Dialog._dialogueTerminate.LastValue)
{
Dialog._dialogIsClosed.Synchron = true;
CloseRequestEventHandler?.Invoke(sender, e);
CloseRequestEventHandler?.Invoke(this, e);

if (dispatcherTimer != null)
{
Expand All @@ -116,6 +120,7 @@ public void Dispose()
dispatcherTimer.Stop();
dispatcherTimer.Tick -= dispatcherTimer_Tick;


}
}
}
Expand Down

0 comments on commit 11645e6

Please sign in to comment.