private async void BUpdate_Click(object sender, RoutedEventArgs e) { Controller.GenerateTestData(); //Snapshot.Current.LastUpdate = DateTimeOffset.Now; //Message.Show(Controller.Serialize(), ""); //Message.Show(JsonConvert.SerializeObject(Platform.Current.Models.First().Objects.First().Properties[3]), ""); if ((sender as Button) != null) { var path = new Path(); path.SetResourceReference(Path.DataProperty, "Loading"); path.SetResourceReference(Shape.FillProperty, "MainColor"); var but = new Border { Child = path }; var da = new DoubleAnimation(0, 359, new Duration(TimeSpan.FromMilliseconds(600))); var rt = new RotateTransform(); but.RenderTransform = rt; but.RenderTransformOrigin = new Point(0.5, 0.5); da.RepeatBehavior = RepeatBehavior.Forever; ((Button)sender).Content = but; rt.BeginAnimation(RotateTransform.AngleProperty, da); } await Task.Run(async() => { try { //Network.GetDataFromServer(); await Dispatcher.BeginInvoke(new Action(delegate { DGProp.ItemsSource = View.ModelToView(); Lmodels.ItemsSource = Platform.Current.Models; if (Lobjects.SelectedItem != null) { stackscroll.Content = View.GetDashboard(Lobjects.SelectedItem as Object); } })); } catch { Message.Show((string)Application.Current.Resources["Dialogid7"], (string)Application.Current.Resources["Dialogid5"]); } }); if ((sender as Button) != null) { var path = new Path(); path.SetResourceReference(Path.DataProperty, "Update"); path.SetResourceReference(Shape.FillProperty, "MainColor"); var but = new Border { Child = path }; ((Button)sender).Content = but; } }
private async void BUpload_Click(object sender, RoutedEventArgs e) { if (sender != null) { var path = new Path(); path.SetResourceReference(Path.DataProperty, "Loading"); path.SetResourceReference(Shape.FillProperty, "MainColor"); var but = new Border { Child = path }; var da = new DoubleAnimation(0, 359, new Duration(TimeSpan.FromMilliseconds(600))); var rt = new RotateTransform(); but.RenderTransform = rt; but.RenderTransformOrigin = new Point(0.5, 0.5); da.RepeatBehavior = RepeatBehavior.Forever; var button = sender as Button; if (button != null) { button.Content = but; } rt.BeginAnimation(RotateTransform.AngleProperty, da); } await Task.Run(() => { try { Network.SendDataToServer(); } catch { Message.Show((string)Application.Current.Resources["Dialogid8"], (string)Application.Current.Resources["Dialogid5"]); } }); if (sender != null) { var path = new Path(); path.SetResourceReference(Path.DataProperty, "Upload"); path.SetResourceReference(Shape.FillProperty, "MainColor"); var but = new Border { Child = path }; var button = sender as Button; if (button != null) { button.Content = but; } } }
private static UIElement GetPropertyView(Property prop) { var child = new StackPanel() { Orientation = Orientation.Horizontal }; var l = new Label() { Content = prop.Name, HorizontalContentAlignment = HorizontalAlignment.Right, VerticalContentAlignment = VerticalAlignment.Center, FontSize = 14, Width = 200 }; l.SetResourceReference(Control.ForegroundProperty, "OnLightFontColor"); child.Children.Add(l); switch (prop.Type) { case 3: if (bool.Parse(prop.Value)) { var yes = new Path() { Fill = System.Windows.Media.Brushes.LightGreen }; yes.SetResourceReference(Path.DataProperty, "Yes"); var IYes = new Border() { Child = yes, Padding = new Thickness(0, 10, 0, 10) }; child.Children.Add(IYes); } else { var no = new Path() { Fill = System.Windows.Media.Brushes.Red }; no.SetResourceReference(Path.DataProperty, "No"); var INo = new Border() { Child = no, Padding = new Thickness(0, 10, 0, 10) }; child.Children.Add(INo); } break; case 9: case 7: case 11: case 10: case 8: case 12: case 14: case 15: case 13: l = new Label() { Content = double.Parse(prop.Value), HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center, FontSize = 20, FontFamily = new System.Windows.Media.FontFamily("Consolas") }; l.SetResourceReference(Control.ForegroundProperty, "MainColor"); child.Children.Add(l); break; case 18: l = new Label() { Content = "\"" + prop.Value + "\"", HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center, FontSize = 12, FontFamily = new System.Windows.Media.FontFamily("Consolas") }; l.SetResourceReference(Control.ForegroundProperty, "OnLightFontColor"); child.Children.Add(l); break; } return(child); }