aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineVersionDialog.xaml
blob: b047206472cd705cbcddf5b3ef424dfd882e4632 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<UserControl x:Class="Tango.MachineStudio.MachineDesigner.Views.MachineVersionDialog"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls"
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
             xmlns:autoComplete="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:providers="clr-namespace:Tango.MachineStudio.MachineDesigner.AutoComplete"
             xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI"
             xmlns:local="clr-namespace:Tango.MachineStudio.MachineDesigner.Views"
             mc:Ignorable="d" Width="530" Height="239" Background="{StaticResource Dialog.Background}" Foreground="{StaticResource Dialog.Foreground}">

    <UserControl.Resources>
        <providers:MachineVersionsProvider x:Key="VersionsProvider"></providers:MachineVersionsProvider>
    </UserControl.Resources>
    
    <Grid>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="50"/>
                <RowDefinition Height="1*"/>
            </Grid.RowDefinitions>

            <Grid>
                <StackPanel Orientation="Horizontal" Margin="10">
                    <materialDesign:PackIcon Width="24" Height="24" Kind="Verified" VerticalAlignment="Center"></materialDesign:PackIcon>
                    <TextBlock Text="Default Version Configuration" VerticalAlignment="Center" Margin="10 0 0 0" FontSize="16"></TextBlock>
                </StackPanel>
            </Grid>

            <Grid Grid.Row="1" Margin="10">
                <Grid.RowDefinitions>
                    <RowDefinition Height="1*"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>

                <Grid>
                    <StackPanel Margin="10">
                        <TextBlock>Version</TextBlock>
                        <ComboBox ItemsSource="{Binding Adapter.MachineVersions}" Text="{Binding Version}" DisplayMemberPath="Version" SelectedItem="{Binding SelectedVersion}" IsEditable="True" materialDesign:HintAssist.Hint="Select or enter a new version name"></ComboBox>
                        <TextBlock Margin="0 10 0 0">Name</TextBlock>
                        <TextBox materialDesign:HintAssist.Hint="Version name" Text="{Binding VersionName}">
                            <TextBox.Style>
                                <Style TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
                                    <Setter Property="IsEnabled" Value="False"></Setter>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding SelectedVersion}" Value="{x:Null}">
                                            <Setter Property="IsEnabled" Value="True"></Setter>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBox.Style>
                        </TextBox>
                        </StackPanel>
                </Grid>

                <Grid Grid.Row="1">
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Right" DockPanel.Dock="Bottom">
                        <Button Command="{Binding AcceptCommand}" Style="{StaticResource MaterialDesignFlatButton}" IsDefault="True" Margin="0 8 8 0">
                            ACCEPT
                        </Button>
                        <Button Command="{Binding CancelCommand}" Style="{StaticResource MaterialDesignFlatButton}" IsCancel="False" Margin="0 8 8 0">
                            CANCEL
                        </Button>
                    </StackPanel>
                </Grid>
            </Grid>
        </Grid>
    </Grid>
</UserControl>
span class="k">using Tango.MachineStudio.Logging.Views; using Tango.SharedUI; namespace Tango.MachineStudio.Logging.ViewModels { public class EmbeddedLogsViewVM : ViewModel { private EmbeddedLogFileParser _parser; private List<LogFile> _logFiles; private INotificationProvider _notification; private bool _dialog_shown; private ControlledObservableCollection<LogItemBase> _realTimeLogs; private List<LogItemBase> _pausedLogs; private ControlledObservableCollection<LogItemBase> _logs; public ControlledObservableCollection<LogItemBase> Logs { get { return _logs; } set { _logs = value; RaisePropertyChangedAuto(); } } private LogItemBase _selectedLog; public LogItemBase SelectedLog { get { return _selectedLog; } set { _selectedLog = value; RaisePropertyChangedAuto(); OnSelectedLogChanged(); } } private ObservableCollection<DateTime> _dates; public ObservableCollection<DateTime> Dates { get { return _dates; } set { _dates = value; RaisePropertyChangedAuto(); } } private DateTime _selectedDate; public DateTime SelectedDate { get { return _selectedDate; } set { _selectedDate = value; RaisePropertyChangedAuto(); OnSelectedDateChanged(); } } private DateTime _minDate; public DateTime MinDate { get { return _minDate; } set { _minDate = value; RaisePropertyChangedAuto(); } } private DateTime _maxDate; public DateTime MaxDate { get { return _maxDate; } set { _maxDate = value; RaisePropertyChangedAuto(); } } private bool _isRealTime; public bool IsRealTime { get { return _isRealTime; } set { _isRealTime = value; RaisePropertyChangedAuto(); OnSelectedDateChanged(); } } private bool _realTimePaused; public bool RealTimePaused { get { return _realTimePaused; } set { _realTimePaused = value; RaisePropertyChangedAuto(); if (!_realTimePaused) { _realTimeLogs.InsertRange(0, _pausedLogs); _pausedLogs.Clear(); } } } public RelayCommand NavigateToHomeCommand { get; set; } public RelayCommand ToggleRealTimePaused { get; set; } public RelayCommand ClearRealTimeLogsCommand { get; set; } public EmbeddedLogsViewVM(LoggingNavigationManager navigation, IStudioApplicationManager application, INotificationProvider notification) { _notification = notification; NavigateToHomeCommand = new RelayCommand(() => navigation.NavigateTo(LoggingNavigationView.HomeView)); _parser = new EmbeddedLogFileParser(); _logFiles = _parser.GetLogFiles(); Dates = new ObservableCollection<DateTime>(_logFiles.Select(x => x.DateTime).OrderBy(x => x)); _realTimeLogs = new ControlledObservableCollection<LogItemBase>(); _pausedLogs = new List<LogItemBase>(); IsRealTime = true; RealTimePaused = true; SelectedDate = Dates.LastOrDefault(); if (Dates.Count > 0) { MinDate = Dates.Min(); MaxDate = Dates.Max(); } MachineOperator.EmbeddedLogManager.NewLog += EmbeddedLogManager_NewLog; ToggleRealTimePaused = new RelayCommand(() => RealTimePaused = !RealTimePaused); ClearRealTimeLogsCommand = new RelayCommand(() => { _realTimeLogs.Clear(); }); } private void EmbeddedLogManager_NewLog(object sender, LogItemBase log) { if (!RealTimePaused) { InvokeUI(() => { _realTimeLogs.Insert(0, log); }); } else { _pausedLogs.Add(log); } } private async void OnSelectedDateChanged() { if (IsRealTime) { Logs = _realTimeLogs; } else { List<LogItemBase> logs = new List<LogItemBase>(); using (_notification.PushTaskItem("Loading embedded device logs...")) { await Task.Factory.StartNew(() => { foreach (var logFile in _logFiles.Where(x => x.DateTime.Date == SelectedDate.Date)) { logs.AddRange(_parser.Parse(logFile)); } }); } Logs = new ControlledObservableCollection<LogItemBase>(logs); } } private void OnSelectedLogChanged() { if (SelectedLog != null && !_dialog_shown) { _dialog_shown = true; _notification.ShowModalDialog<LogDetailsViewVM, EmbeddedLogDetailsView>(new LogDetailsViewVM(SelectedLog), (x) => { }, () => { _dialog_shown = false; }); } } } }