Advertisement
Guest User

Untitled

a guest
Sep 1st, 2015
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.05 KB | None | 0 0
  1. Frame 1: Connecting
  2. Frame 2: Connecting.
  3. Frame 3: Connecting..
  4. Frame 4: Connecting...
  5. Go to frame 1 if connection isn't established yet.
  6. When connection is established: display "Connected".
  7.  
  8. <Window x:Class="radar_test_ui.SerialConnectionWindow"
  9. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  10. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  11. Title="Connection" SizeToContent="WidthAndHeight">
  12. <Grid>
  13. <Grid.RowDefinitions>
  14. <RowDefinition Height="Auto" />
  15. <RowDefinition Height="Auto" />
  16. <RowDefinition Height="Auto" />
  17. <RowDefinition Height="Auto" />
  18. <RowDefinition Height="Auto" />
  19. <RowDefinition Height="Auto" />
  20. </Grid.RowDefinitions>
  21. <Grid.ColumnDefinitions>
  22. <ColumnDefinition Width="Auto" />
  23. </Grid.ColumnDefinitions>
  24. <Label Grid.Row="0" Content="COM:" Margin="5,0,5,0" />
  25. <ComboBox Grid.Row="1" Margin="10,0,10,0">
  26. <ComboBoxItem Content="COM1" IsSelected="True" />
  27. <ComboBoxItem Content="COM2" />
  28. <ComboBoxItem Content="COM3" />
  29. </ComboBox>
  30. <Label Grid.Row="2" Content="Baud rate:" Margin="5,10,5,0" />
  31. <ComboBox Grid.Row="3" Margin="10,0,10,0">
  32. <ComboBoxItem Content="9600" IsSelected="True" />
  33. <ComboBoxItem Content="19200" />
  34. </ComboBox>
  35. <Separator Grid.Row="4" Margin="0,15,0,15" />
  36. <Grid Grid.Row="5" Margin="10,0,10,10">
  37. <Grid.RowDefinitions>
  38. <RowDefinition Height="*" />
  39. </Grid.RowDefinitions>
  40. <Grid.ColumnDefinitions>
  41. <ColumnDefinition Width="*" />
  42. <ColumnDefinition Width="Auto" />
  43. <ColumnDefinition Width="Auto" />
  44. </Grid.ColumnDefinitions>
  45. <Label Content="Connecting..." FontSize="10" Width="100" VerticalAlignment="Bottom" Margin="0,0,0,-5" Name="LabelStatus" />
  46. <Button Grid.Column="1" Content="Connect" Padding="10,3,10,3" Margin="0,0,10,0" Click="ConnectClick" />
  47. <Button Grid.Column="2" Content="Cancel" Padding="10,3,10,3" Click="CancelClick" />
  48. </Grid>
  49. </Grid>
  50. </Window>
  51.  
  52. <Label Name="LabelStatus" FontSize="10" Width="100" VerticalAlignment="Bottom" Margin="0,0,0,-5">
  53. <Label.Style>
  54. <Style TargetType="Label">
  55. <Setter Property="Content" Value="Connecting..."/>
  56. <Style.Triggers>
  57. <DataTrigger Binding="{Binding Connecting}" Value="True">
  58. <DataTrigger.EnterActions>
  59. <BeginStoryboard>
  60. <Storyboard Storyboard.TargetProperty="Content">
  61. <ObjectAnimationUsingKeyFrames Duration="00:00:04"
  62. RepeatBehavior="Forever">
  63. <DiscreteObjectKeyFrame KeyTime="00:00:00"
  64. Value="Connecting"/>
  65. <DiscreteObjectKeyFrame KeyTime="00:00:01"
  66. Value="Connecting."/>
  67. <DiscreteObjectKeyFrame KeyTime="00:00:02"
  68. Value="Connecting.."/>
  69. <DiscreteObjectKeyFrame KeyTime="00:00:03"
  70. Value="Connecting..."/>
  71. </ObjectAnimationUsingKeyFrames>
  72. </Storyboard>
  73. </BeginStoryboard>
  74. </DataTrigger.EnterActions>
  75. <DataTrigger.ExitActions>
  76. <BeginStoryboard>
  77. <Storyboard Storyboard.TargetProperty="Content">
  78. <ObjectAnimationUsingKeyFrames Duration="00:00:00">
  79. <DiscreteObjectKeyFrame KeyTime="00:00:00"
  80. Value="Connected"/>
  81. </ObjectAnimationUsingKeyFrames>
  82. </Storyboard>
  83. </BeginStoryboard>
  84. </DataTrigger.ExitActions>
  85. </DataTrigger>
  86. </Style.Triggers>
  87. </Style>
  88. </Label.Style>
  89. </Label>
  90. <Button Grid.Column="1" Content="Connect" Padding="10,3,10,3" Margin="0,0,10,0"
  91. Click="ConnectClick"/>
  92.  
  93. public MainWindow()
  94. {
  95. InitializeComponent();
  96. this.DataContext = this;
  97. }
  98.  
  99. private bool _connecting;
  100. public bool Connecting
  101. {
  102. get { return _connecting; }
  103. set
  104. {
  105. _connecting = value;
  106. OnPropertyChanged("Connecting");
  107. }
  108. }
  109.  
  110. private void ConnectClick(object sender, RoutedEventArgs e)
  111. {
  112. Connecting = !Connecting;
  113. }
  114.  
  115. public event PropertyChangedEventHandler PropertyChanged;
  116. private void OnPropertyChanged(string propertyName)
  117. {
  118. if (PropertyChanged != null)
  119. {
  120. PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
  121. }
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement