<pagemodel:OverviewPageModel x:Key="OverviewPageModel"></pagemodel:OverviewPageModel>
<pagemodel:DslPageModel x:Key="DslPageModel"></pagemodel:DslPageModel>
<pagemodel:LteInfoModel x:Key="LteInfoModel"></pagemodel:LteInfoModel>
+ <pagemodel:SyslogPageModel x:Key="SyslogPageModel"></pagemodel:SyslogPageModel>
- <model:SyslogData x:Key="SyslogData"></model:SyslogData>
<model:TR181 x:Key="TR181"></model:TR181>
<model:PhoneCallData x:Key="PhoneCallData"></model:PhoneCallData>
<model:DeviceData x:Key="DeviceData"></model:DeviceData>
if (SpeedportHybridAPI.getInstance().checkLogin().Equals(false))
return;
- SyslogData syslog = Application.Current.FindResource("SyslogData") as SyslogData;
+ SyslogPageModel syslog = Application.Current.FindResource("SyslogPageModel") as SyslogPageModel;
string response = SpeedportHybridAPI.getInstance().sendEnryptedRequest("data/SystemMessages.json");
if (response.IsNullOrEmpty())
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SpeedportHybridControl.Model {
+ public class SyslogList : SuperViewModel {
+ private string _message;
+ private string _timestamp;
+
+ public string message {
+ get { return _message; }
+ set { SetProperty(ref _message, value); }
+ }
+
+ public string timestamp {
+ get { return _timestamp; }
+ set { SetProperty(ref _timestamp, value); }
+ }
+
+ public override string ToString () {
+ return string.Concat(timestamp, ": ", message);
+ }
+
+ public SyslogList () {
+ }
+ }
+}
+++ /dev/null
-using System.Collections.Generic;
-
-namespace SpeedportHybridControl.Model {
- public class SyslogData : SuperViewModel {
- private List<SyslogList> _syslogList;
- private string _datetime;
-
- public List<SyslogList> syslogList {
- get { return _syslogList; }
- set { SetProperty(ref _syslogList, value); }
- }
-
- public string datetime {
- get { return _datetime; }
- set { SetProperty(ref _datetime, value); }
- }
-
- public SyslogData() {
- }
- }
-
- public class SyslogList : SuperViewModel {
- private string _message;
- private string _timestamp;
-
- public string message {
- get { return _message; }
- set { SetProperty(ref _message, value); }
- }
-
- public string timestamp {
- get { return _timestamp; }
- set { SetProperty(ref _timestamp, value); }
- }
-
- public override string ToString () {
- return string.Concat(timestamp, ": ", message);
- }
-
- public SyslogList() {
- }
- }
-}
--- /dev/null
+using SpeedportHybridControl.Model;
+using SpeedportHybridControl.Implementations;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using SpeedportHybridControl.Data;
+using System.Windows;
+
+namespace SpeedportHybridControl.PageModel {
+ class SyslogPageModel : SuperViewModel {
+ private DelegateCommand _reloadCommand;
+ private DelegateCommand _copyCommand;
+ private DelegateCommand _clearCommand;
+
+ private string _searchText;
+ private SyslogList _selectedItem;
+
+ private List<SyslogList> _syslogList;
+ private List<SyslogList> _filteredList;
+ private string _datetime;
+
+ public DelegateCommand ReloadCommand {
+ get { return _reloadCommand; }
+ set { SetProperty(ref _reloadCommand, value); }
+ }
+
+ public DelegateCommand CopyCommand {
+ get { return _copyCommand; }
+ set { SetProperty(ref _copyCommand, value); }
+ }
+
+ public DelegateCommand ClearCommand {
+ get { return _clearCommand; }
+ set { SetProperty(ref _clearCommand, value); }
+ }
+
+ public string SearchText {
+ get { return _searchText; }
+ set {
+ SetProperty(ref _searchText, value);
+ ApplyFilter();
+ }
+ }
+
+ public SyslogList SelectedItem {
+ get { return _selectedItem; }
+ set { SetProperty(ref _selectedItem, value); }
+ }
+
+ public List<SyslogList> syslogList {
+ get { return _syslogList; }
+ set {
+ SetProperty(ref _syslogList, value);
+ ApplyFilter();
+ }
+ }
+
+ public List<SyslogList> filteredList {
+ get { return _filteredList; }
+ set { SetProperty(ref _filteredList, value); }
+ }
+
+ public string datetime {
+ get { return _datetime; }
+ set { SetProperty(ref _datetime, value); }
+ }
+
+ private void OnReloadCommandExecute () {
+ new Thread(() => {
+ SpeedportHybrid.initSyslog();
+ }).Start();
+ }
+
+ private void OnCopyCommandExecute () {
+ Clipboard.SetText(SelectedItem.ToString());
+ }
+
+ private void OnClearCommandExecute () {
+ MessageBoxResult result = MessageBox.Show("Sollen die System-Informationen wirklich gelöscht werden?", "Confirmation", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
+ if (result.Equals(MessageBoxResult.Yes)) {
+ SpeedportHybridAPI.getInstance().clearSyslog();
+ SpeedportHybrid.initSyslog();
+ SearchText = string.Empty;
+ }
+ }
+
+ private void ApplyFilter () {
+ if (object.ReferenceEquals(syslogList, null).Equals(false)) {
+ List<SyslogList> tmp = syslogList;
+ filteredList = tmp.Where(item => SyslogFilter(item)).ToList();
+ }
+ }
+
+ private bool SyslogFilter (object item) {
+ if (SearchText.IsNullOrEmpty().Equals(false)) {
+ bool a = ((item as SyslogList).message.IndexOf(SearchText, StringComparison.OrdinalIgnoreCase) >= 0);
+ return a;
+ }
+
+ return true;
+ }
+
+ public SyslogPageModel () {
+ ReloadCommand = new DelegateCommand(new Action(OnReloadCommandExecute));
+ CopyCommand = new DelegateCommand(new Action(OnCopyCommandExecute));
+ ClearCommand = new DelegateCommand(new Action(OnClearCommandExecute));
+ }
+ }
+}
<Compile Include="Model\DeviceViewModel.cs" />
<Compile Include="Model\Line.cs" />
<Compile Include="Model\StatusPhoneListModel.cs" />
+ <Compile Include="Model\SyslogList.cs" />
<Compile Include="PageModel\DslPageModel.cs" />
<Compile Include="PageModel\LoginPageModel.cs" />
<Compile Include="PageModel\LteInfoModel.cs" />
</Page>
</ItemGroup>
<ItemGroup>
- <Compile Include="Model\SyslogViewModel.cs" />
<Compile Include="Model\TR181ViewModel.cs" />
<Compile Include="PageModel\OverviewPageModel.cs" />
<Compile Include="PageModel\StatusPageModel.cs" />
+ <Compile Include="PageModel\SyslogPageModel.cs" />
<Compile Include="page\AboutPage.xaml.cs">
<DependentUpon>AboutPage.xaml</DependentUpon>
</Compile>
mc:Ignorable="d"
Width="Auto" Height="Auto"
Title="SyslogPage">
- <Page.CommandBindings>
- <CommandBinding
- Command="ApplicationCommands.Copy"
- Executed="CommandBinding_Executed"/>
- </Page.CommandBindings>
- <Grid DataContext="{StaticResource SyslogData}">
+ <Grid DataContext="{StaticResource SyslogPageModel}">
<TextBlock HorizontalAlignment="Right" Margin="0,0,124,0" Text="Suche:" VerticalAlignment="Top"/>
- <TextBox x:Name="tbSearch" HorizontalAlignment="Right" VerticalAlignment="Top" Width="120" Text="" TextChanged="TextChanged"/>
+ <TextBox x:Name="tbSearch" HorizontalAlignment="Right" VerticalAlignment="Top" Width="120" Text="{Binding Path=SearchText, UpdateSourceTrigger=PropertyChanged}"/>
- <ListView ItemsSource="{Binding syslogList}" x:Name="listView" Margin="0,23,0,39">
+ <ListView ItemsSource="{Binding filteredList}" SelectedItem="{Binding Path=SelectedItem, UpdateSourceTrigger=PropertyChanged}" x:Name="listView" Margin="0,23,0,39">
<ListView.ContextMenu>
<ContextMenu>
- <MenuItem Header="Copy" Command="ApplicationCommands.Copy"/>
+ <MenuItem Header="Copy" Command="{Binding Path=CopyCommand, NotifyOnTargetUpdated=True}"/>
</ContextMenu>
</ListView.ContextMenu>
<ListView.Resources>
</ListView>
<TextBlock Text="{Binding datetime}" Margin="0,0,10,0" HorizontalAlignment="Right" VerticalAlignment="Bottom" />
- <Button x:Name="btnClear" Content="Leeren" Click="button_click" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="72"/>
+ <Button Command="{Binding Path=ClearCommand}" x:Name="btnClear" Content="Leeren" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="72"/>
- <Button x:Name="btnReload" Content="Aktualisieren" Margin="218,0,218,0" Click="button_click" VerticalAlignment="Bottom"/>
+ <Button Command="{Binding Path=ReloadCommand}" x:Name="btnReload" Content="Aktualisieren" Margin="218,0,218,0" VerticalAlignment="Bottom"/>
</Grid>
</Page>
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System;
-using SpeedportHybridControl.Model;
-using System.Threading.Tasks;
+using System.Windows.Controls;
namespace SpeedportHybridControl.page {
/// <summary>
public SyslogPage() {
InitializeComponent();
}
-
- public void init () {
- tbSearch.Text = string.Empty;
- }
-
- private bool SyslogFilter (object item) {
- //if (tbSearch.Text.IsNullOrEmpty().Equals(false)) {
- // return ((item as SyslogList).message.IndexOf(tbSearch.Text, StringComparison.OrdinalIgnoreCase) >= 0);
- //}
-
- return true;
- }
-
- private void button_click(object sender, RoutedEventArgs e) {
- /*
- if (sender.Equals(btnReload)) {
- SpeedportHybrid.initSyslog();
- TextChanged(null, null);
- }
- else if (sender.Equals(btnClear)) {
- MessageBoxResult result = MessageBox.Show("Sollen die System-Informationen wirklich gelöscht werden?", "Confirmation", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
- if (result.Equals(MessageBoxResult.Yes)) {
- SpeedportHybridAPI.getInstance().clearSyslog();
- util.init("Syslog");
- tbSearch.Text = string.Empty;
- }
- }
- */
- }
-
- public void TextChanged (object sender, TextChangedEventArgs e) {
- /*
- SyslogData syslog = Application.Current.FindResource("SyslogData") as SyslogData;
- CollectionView collectionView = CollectionViewSource.GetDefaultView(syslog.syslogList) as CollectionView;
- collectionView.Filter = SyslogFilter;
-
- CollectionViewSource.GetDefaultView(syslog.syslogList).Refresh();
- */
- }
-
- private void CommandBinding_Executed(object sender, RoutedEventArgs e) {
- string text = string.Empty;
-
- if (e.Source.Equals(listView)) {
- text = listView.SelectedItem.ToString();
- }
-
- Clipboard.SetText(text);
- text = null;
- }
}
}