Skip to content

Commit

Permalink
code cleanup and added some safety checks
Browse files Browse the repository at this point in the history
  • Loading branch information
okieselbach committed Jun 17, 2021
1 parent db1997c commit 59b00f2
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 24 deletions.
14 changes: 7 additions & 7 deletions SyncMLViewer/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
IsReadOnly="True"/>
<Button x:Name="ButtonClearStream" Content="_Clear Stream" Margin="0,0,112,9.8" Click="ButtonClear_Click" Height="29" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="97" IsEnabled="{Binding Path=SyncMlProgress.NotInProgress}" ToolTip="Clear the SyncML stream."/>
<Button x:Name="ButtonSaveAs" Content="_Save As" Margin="0,0,10,9.8" Click="ButtonSaveAs_Click" Height="29" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="97" IsEnabled="{Binding Path=SyncMlProgress.NotInProgress}" ToolTip="Save SyncML stream as xml file."/>
<CheckBox x:Name="CheckBoxShowTraceEvents" Content="Show _TraceEvents" HorizontalAlignment="Left" Margin="10,0,0,10" Height="15" VerticalAlignment="Bottom" ToolTip="Show additional ETW Trace Events."/>
</Grid>
</TabItem>
<TabItem Header="SyncML Sessions/Messages">
Expand Down Expand Up @@ -81,22 +80,23 @@
</TabControl>
<Menu Height="21" VerticalAlignment="Top" Background="White" Margin="0,0,-0.4,0">
<MenuItem Header="_File">
<MenuItem Header="_Open..." Click="MenuItemOpen_Click"/>
<MenuItem Header="_Save As..." Click="ButtonSaveAs_Click"/>
<MenuItem Header="_Open..." IsEnabled="{Binding Path=SyncMlProgress.NotInProgress}" Click="MenuItemOpen_Click"/>
<MenuItem Header="_Save As..." IsEnabled="{Binding Path=SyncMlProgress.NotInProgress}" Click="ButtonSaveAs_Click"/>
<Separator />
<MenuItem Header="_Exit" Click="MenuItemExit_OnClick"/>
</MenuItem>
<MenuItem Header="_Options">
<MenuItem x:Name="menuItemAlwaysOnTop" Header="_Always on Top" IsCheckable="True" IsChecked="false" Checked="MenuItemAlwaysOnTop_Checked" Unchecked="MenuItemAlwaysOnTop_Unchecked"/>
<MenuItem x:Name="menuItemAutoScroll" Header="Auto _Scroll" IsCheckable="True" IsChecked="false" />
<Separator />
<MenuItem x:Name="menuItemTimestamps" Header="_Enable Timestamps" IsCheckable="True" IsChecked="True" ToolTip="Enables additional xml comments with timestamps for each SyncML message"/>
<MenuItem x:Name="menuItemBackgroundLogging" Header="Enable _Background Logging Mode" IsCheckable="True" IsChecked="False" ToolTip="Output transferred to file, no SyncML output will be displayed in the UI" Checked="MenuItemBackgroundLogging_Checked" Unchecked="MenuItemBackgroundLogging_Unchecked"/>
<MenuItem x:Name="menuItemTraceEvents" Header="_Enable additional ETW trace events info" IsCheckable="True" IsEnabled="{Binding Path=SyncMlProgress.NotInProgress}" IsChecked="false" ToolTip="Shows additional ETW TraceEvents like OmaDmClientExeStart etc."/>
<MenuItem x:Name="menuItemTimestamps" Header="_Enable Timestamps" IsCheckable="True" IsEnabled="{Binding Path=SyncMlProgress.NotInProgress}" IsChecked="True" ToolTip="Enables additional xml comments with timestamps for each SyncML message"/>
<MenuItem x:Name="menuItemBackgroundLogging" Header="Enable _Background Logging Mode" IsEnabled="{Binding Path=SyncMlProgress.NotInProgress}" IsCheckable="True" IsChecked="False" ToolTip="Output transferred to file, no SyncML output will be displayed in the UI" Checked="MenuItemBackgroundLogging_Checked" Unchecked="MenuItemBackgroundLogging_Unchecked"/>
</MenuItem>
<MenuItem Header="_Actions">
<MenuItem Header="_Sync" Click="ButtonSync_Click"/>
<MenuItem Header="_Sync" IsEnabled="{Binding Path=SyncMlProgress.NotInProgress}" Click="ButtonSync_Click"/>
<Separator />
<MenuItem Header="_Clear Stream" Click="ButtonClear_Click"/>
<MenuItem Header="_Clear Stream" IsEnabled="{Binding Path=SyncMlProgress.NotInProgress}" Click="ButtonClear_Click"/>
<Separator />
<MenuItem Header="Run" StaysOpenOnClick="True"/>
<MenuItem Header="-> _MdmDiagnosticsTool (incl. MDM report, events, ...)" Click="MenuItemMdmDiagnostics_OnClick"/>
Expand Down
14 changes: 3 additions & 11 deletions SyncMLViewer/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ public partial class MainWindow

private readonly MdmDiagnostics _mdmDiagnostics = new MdmDiagnostics();

private SyncMlProgress SyncMlProgress { get; }
public SyncMlProgress SyncMlProgress { get; set; }
public ObservableCollection<SyncMlSession> SyncMlSessions { get; }
public ObservableCollection<SyncMlMessage> SyncMlMlMessages { get; set; }

public MainWindow()
{
Expand All @@ -83,7 +82,6 @@ public MainWindow()

SyncMlProgress = new SyncMlProgress();
SyncMlSessions = new ObservableCollection<SyncMlSession>();
SyncMlMlMessages = new ObservableCollection<SyncMlMessage>();

_rs = RunspaceFactory.CreateRunspace();
_rs.Open();
Expand All @@ -103,7 +101,6 @@ public MainWindow()
ListBoxSessions.ItemsSource = SyncMlSessions;
ListBoxSessions.DisplayMemberPath = "Entry";

ListBoxMessages.ItemsSource = SyncMlMlMessages;
ListBoxMessages.DisplayMemberPath = "Entry";

ICSharpCode.AvalonEdit.Search.SearchPanel.Install(TextEditorStream);
Expand Down Expand Up @@ -187,7 +184,7 @@ private void WorkerProgressChanged(object sender, ProgressChangedEventArgs e)
throw new ArgumentException("No TraceEvent received.");

// show all events
if (CheckBoxShowTraceEvents.IsChecked == true)
if (menuItemTraceEvents.IsChecked == true)
{
// filter a bit otherwise too much noise...
if (!string.Equals(userState.EventName, "FunctionEntry",
Expand Down Expand Up @@ -290,7 +287,6 @@ private void WorkerProgressChanged(object sender, ProgressChangedEventArgs e)
{
var syncMlSession = new SyncMlSession(valueSessionId);
SyncMlSessions.Add(syncMlSession);
SyncMlMlMessages.Clear();
}

var valueMsgId = "0";
Expand Down Expand Up @@ -406,7 +402,6 @@ private void CheckBoxHtmlDecode_Checked(object sender, RoutedEventArgs e)
private void ButtonClear_Click(object sender, RoutedEventArgs e)
{
SyncMlSessions.Clear();
SyncMlMlMessages.Clear();

TextEditorMessages.Clear();
TextEditorStream.Clear();
Expand Down Expand Up @@ -797,7 +792,7 @@ private void MenuItemBackgroundLogging_Checked(object sender, RoutedEventArgs e)
Trace.AutoFlush = true;

SyncMlSessions.Clear();
SyncMlMlMessages.Clear();
ListBoxMessages.ItemsSource = null;

TextEditorStream.Clear();
TextEditorMessages.Clear();
Expand Down Expand Up @@ -836,7 +831,6 @@ private void MenuItemOpen_Click(object sender, RoutedEventArgs e)
TextEditorMessages.Clear();

SyncMlSessions.Clear();
SyncMlMlMessages.Clear();

var fileStream = openFileDialog.OpenFile();
using (StreamReader reader = new StreamReader(fileStream))
Expand All @@ -863,7 +857,6 @@ private void MenuItemOpen_Click(object sender, RoutedEventArgs e)
{
var syncMlSession = new SyncMlSession(valueSessionId);
SyncMlSessions.Add(syncMlSession);
SyncMlMlMessages.Clear();
}

var valueMsgId = "0";
Expand All @@ -874,7 +867,6 @@ private void MenuItemOpen_Click(object sender, RoutedEventArgs e)
var syncMlMessage = new SyncMlMessage(valueSessionId, valueMsgId, valueSyncMl);
SyncMlSessions.FirstOrDefault(item => item.SessionId == valueSessionId)?.Messages
.Add(syncMlMessage);
SyncMlMlMessages.Add(syncMlMessage);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions SyncMLViewer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.5.0")]
[assembly: AssemblyFileVersion("1.0.5.0")]
[assembly: AssemblyVersion("1.0.6.0")]
[assembly: AssemblyFileVersion("1.0.6.0")]
1 change: 1 addition & 0 deletions SyncMLViewer/SyncMLViewer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@
<None Include="dist\SyncMLViewer-v103.zip" />
<None Include="dist\SyncMLViewer-v104.zip" />
<None Include="dist\SyncMLViewer-v105.zip" />
<None Include="dist\SyncMLViewer-v106.zip" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
Expand Down
Binary file added SyncMLViewer/dist/SyncMLViewer-v106.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions SyncMLViewer/dist/update.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<LatestVersion>
<VersionNumber>1.0.5</VersionNumber>
<DownloadURL>https://github.com/okieselbach/SyncMLViewer/raw/master/SyncMLViewer/dist/SyncMLViewer-v105.zip</DownloadURL>
<VersionNumber>1.0.6</VersionNumber>
<DownloadURL>https://github.com/okieselbach/SyncMLViewer/raw/master/SyncMLViewer/dist/SyncMLViewer-v106.zip</DownloadURL>
</LatestVersion>
4 changes: 2 additions & 2 deletions SyncMLViewer/dist/update2.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<LatestVersion>
<VersionNumber>1.0.5</VersionNumber>
<DownloadURL>https://github.com/okieselbach/SyncMLViewer/raw/master/SyncMLViewer/dist/SyncMLViewer-v105.zip</DownloadURL>
<VersionNumber>1.0.6</VersionNumber>
<DownloadURL>https://github.com/okieselbach/SyncMLViewer/raw/master/SyncMLViewer/dist/SyncMLViewer-v106.zip</DownloadURL>
</LatestVersion>

0 comments on commit 59b00f2

Please sign in to comment.