copy all selected items on syslog page to clipboard
authorStricted <info@stricted.de>
Sun, 10 Jan 2016 11:13:50 +0000 (12:13 +0100)
committerStricted <info@stricted.de>
Sun, 10 Jan 2016 11:13:50 +0000 (12:13 +0100)
SpeedportHybridControl/Model/SyslogList.cs
SpeedportHybridControl/PageModel/SyslogPageModel.cs
SpeedportHybridControl/page/SyslogPage.xaml

index a77d167466fb1b89b6b8434b2e814225d1dcbaf2..d25a1223a9fd38f3d9a5cee2457feedd87d79273 100644 (file)
@@ -8,6 +8,7 @@ namespace SpeedportHybridControl.Model {
        public class SyslogList : SuperViewModel {
                private string _message;
                private string _timestamp;
+               private bool _isSelected;
 
                public string message {
                        get { return _message; }
@@ -19,6 +20,12 @@ namespace SpeedportHybridControl.Model {
                        set { SetProperty(ref _timestamp, value); }
                }
 
+               public bool IsSelected
+               {
+                       get { return _isSelected; }
+                       set { SetProperty(ref _isSelected, value); }
+               }
+
                public override string ToString () {
                        return string.Concat(timestamp, ": ", message);
                }
index 0239332ddde9241074c85da207e2e221b5171b62..f7586643f267ab4075ec02ded8f23c1a7b9ff0ae 100644 (file)
@@ -14,7 +14,7 @@ namespace SpeedportHybridControl.PageModel {
                private DelegateCommand _clearCommand;
 
                private string _searchText;
-               private SyslogList _selectedItem;
+               private SyslogList _selectedItems;
 
                private List<SyslogList> _syslogList;
                private List<SyslogList> _filteredList;
@@ -43,9 +43,10 @@ namespace SpeedportHybridControl.PageModel {
                        }
                }
 
-               public SyslogList SelectedItem {
-                       get { return _selectedItem; }
-                       set { SetProperty(ref _selectedItem, value); }
+               public SyslogList SelectedItems
+               {
+                       get { return _selectedItems; }
+                       set { SetProperty(ref _selectedItems, value); }
                }
 
                public List<SyslogList> syslogList {
@@ -70,8 +71,18 @@ namespace SpeedportHybridControl.PageModel {
                        new Thread(() => { SpeedportHybrid.initSyslog(); }).Start();
                }
 
+               public IEnumerable<SyslogList> SelectedItens
+               {
+                       get { return filteredList.Where(o => o.IsSelected); }
+               }
+
                private void OnCopyCommandExecute () {
-                       Clipboard.SetText(SelectedItem.ToString());
+                       string text = string.Empty;
+                       foreach (SyslogList item in SelectedItens) {
+                               text = string.Concat(text, Environment.NewLine, item.ToString());
+                       }
+
+                       Clipboard.SetText(text);
                }
 
                private void OnClearCommandExecute () {
index 2c3fa524efe6262d3d2abca8be64f40fd274b512..c04aaed554cf93e2ebf44a9d23966d10f51827d3 100644 (file)
         <TextBlock HorizontalAlignment="Right" Margin="0,0,124,0" Text="Suche:" VerticalAlignment="Top"/>
         <TextBox x:Name="tbSearch" HorizontalAlignment="Right" VerticalAlignment="Top" Width="120" Text="{Binding Path=SearchText, UpdateSourceTrigger=PropertyChanged}"/>
 
-        <ListView ItemsSource="{Binding filteredList}" SelectedItem="{Binding Path=SelectedItem, UpdateSourceTrigger=PropertyChanged}" x:Name="listView" Margin="0,23,0,39">
+        <ListView ItemsSource="{Binding filteredList}" SelectedItem="{Binding Path=SelectedItems, UpdateSourceTrigger=PropertyChanged}" x:Name="listView" Margin="0,23,0,39">
+            <ListBox.ItemContainerStyle>
+                <Style TargetType="{x:Type ListBoxItem}">
+                    <Setter Property="IsSelected" Value="{Binding Mode=TwoWay, Path=IsSelected}"/>
+                </Style>
+            </ListBox.ItemContainerStyle>
             <ListView.ContextMenu>
                 <ContextMenu>
                     <MenuItem Header="Copy" Command="{Binding Path=CopyCommand, NotifyOnTargetUpdated=True}"/>