public MainWindow() { InitializeComponent(); allreadySetShips = new List <Ship>(); // UI Schiffe platzieren Fields = new Rectangle[boardLength, boardLength]; Grid uiGrid = new Grid(); for (int i = 0; i < boardLength; i++) { uiGrid.ColumnDefinitions.Add(new ColumnDefinition()); uiGrid.RowDefinitions.Add(new RowDefinition()); for (int j = 0; j < boardLength; j++) { Rectangle rec = new Rectangle(); Grid.SetRow(rec, i); Grid.SetColumn(rec, j); rec.Margin = margin; rec.Fill = new ImageBrush(new BitmapImage(new Uri(@"..\..\Images\Water.png", UriKind.Relative))); rec.AddHandler(UIElement.MouseDownEvent, new RoutedEventHandler(Click)); Fields[i, j] = rec; uiGrid.Children.Add(Fields[i, j]); } } uiGrid.Width = uiGrid.Height = GridLength; Grid.SetRow(uiGrid, 1); Grid.SetColumnSpan(uiGrid, 2); MyGrid.Children.Add(uiGrid); }
/// <summary> /// This event is called when the map is loaded /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void myMap_Loaded(object sender, RoutedEventArgs e) { // map center point myMap.Center = new Geopoint(new BasicGeoposition() { Altitude = 643, Latitude = 43.089863, Longitude = -77.669609 }); // map zoom level myMap.ZoomLevel = 10; var loc = await modelObject.getLocations(); var latandLong = JArray.Parse(loc); foreach (JObject root in latandLong) { try { double userLatitude = Convert.ToDouble(root["latitude"].ToString()); double userLongitude = Convert.ToDouble(root["longitude"].ToString()); string lastUpdated = root["lastUpdated"].ToString(); if ((userLatitude > -90) && (userLatitude < 90) && (userLongitude > -180) && (userLongitude < 180) && !lastUpdated.Equals("0000-00-00 00:00:00")) { rectangepos = new BasicGeoposition() { Latitude = Convert.ToDouble(root["latitude"].ToString()), Longitude = Convert.ToDouble(root["longitude"].ToString()) }; rectangle = new Rectangle(); rectangle.Name = root["first_name"].ToString() + " " + root["last_name"].ToString() + "\n" + "Last Updated: " + root["lastUpdated"].ToString(); rectangle.Tag = root["email"].ToString(); point = new Geopoint(rectangepos); rectangle.Width = 30; rectangle.Height = 30; img = new BitmapImage(new Uri("ms-appx:///Assets/redpin.png")); rectangle.Fill = new ImageBrush() { ImageSource = img }; MapControl.SetLocation(rectangle, point); MapControl.SetNormalizedAnchorPoint(rectangle, new Point(1.0, 0.5)); myMap.Children.Add(rectangle); rectangle.AddHandler(UIElement.TappedEvent, new TappedEventHandler(myMap_Tapped), true); } } catch (Exception ex) { String x = "" + ex; continue; } } }
private void randomCircle() { Random r = new Random(); int cx = r.Next() % x; int cy = r.Next() % y; int cr = r.Next() % 500 + 50; baseCanvas.Children.Clear(); Rectangle e = new Rectangle(); e.Height = cr; e.Width = cr; e.Stroke = new SolidColorBrush(Color.FromArgb((byte)(r.Next() % 200), (byte)(r.Next() % 200), (byte)(r.Next() % 200), (byte)(r.Next() % 200))); e.Fill = new SolidColorBrush(Color.FromArgb((byte)(r.Next() % 200), (byte)(r.Next() % 200), (byte)(r.Next() % 200), (byte)(r.Next() % 200))); e.SetValue(Canvas.LeftProperty, (double)cx); e.SetValue(Canvas.TopProperty, (double)cy); e.AddHandler(Button.MouseLeftButtonDownEvent, new MouseButtonEventHandler(e_MouseLeftButtonDown), true); baseCanvas.Children.Add(e); }
/// <summary> /// Constructor /// </summary> public Board() { // Initializing HitShips = new List <int>(); BoardGrid = new Grid(); OpenBoardGrid = new Grid(); // timer timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromSeconds(delay); timer.Tick += timer_Tick; // Generate fields/Board Fields = new Rectangle[boardLength, boardLength]; OpenBoardFields = new Rectangle[boardLength, boardLength]; for (int i = 0; i < boardLength; i++) { BoardGrid.ColumnDefinitions.Add(new ColumnDefinition()); BoardGrid.RowDefinitions.Add(new RowDefinition()); OpenBoardGrid.ColumnDefinitions.Add(new ColumnDefinition()); OpenBoardGrid.RowDefinitions.Add(new RowDefinition()); for (int j = 0; j < Fields.GetLength(1); j++) { Rectangle rec = new Rectangle(); Rectangle ofrec = new Rectangle(); rec.Margin = margin; ofrec.Margin = margin; Grid.SetRow(rec, i); Grid.SetColumn(rec, j); Grid.SetRow(ofrec, i); Grid.SetColumn(ofrec, j); rec.Fill = water; ofrec.Fill = water; OpenBoardFields[i, j] = ofrec; OpenBoardGrid.Children.Add(OpenBoardFields[i, j]); rec.AddHandler(UIElement.MouseDownEvent, new RoutedEventHandler(Click)); Fields[i, j] = rec; BoardGrid.Children.Add(Fields[i, j]); } } }
void InitFanTable() { canvas = new Canvas(); canvas.Height = chart._contents.ActualHeight; canvas.Width = chart._contents.ActualWidth; canvas.MouseEnter += Canvas_MouseEvent; canvas.MouseMove += Canvas_MouseEvent; canvas.MouseLeave += Canvas_MouseEvent; Rectangle rect = new Rectangle(); rect.Width = chart._contents.ActualWidth; rect.Height = chart._contents.ActualHeight; rect.Fill = new SolidColorBrush(Colors.White); rect.Opacity = 0.01; canvas.Children.Add(rect); //Init Lines line = new LineGraph(); line.Description = "Fan"; line.Stroke = new SolidColorBrush(Colors.Black); line.StrokeThickness = 1; //Init TD points foreach (TD point in fanTable.points) { var btn = new Rectangle(); btn.Width = 15; btn.Height = 15; btn.Stroke = new SolidColorBrush(Colors.Black); btn.Fill = new SolidColorBrush(Colors.White); btn.AddHandler(FrameworkElement.MouseDownEvent, new MouseButtonEventHandler(Btn_MouseDown)); btn.AddHandler(FrameworkElement.MouseUpEvent, new MouseButtonEventHandler(Btn_MouseUp)); btn.AddHandler(FrameworkElement.MouseMoveEvent, new MouseEventHandler(Btn_MouseMove)); setButtonPos(btn, point); canvas.Children.Add(btn); Btns.Add(btn, point); } updateLine(); Config config = SingleInstanceManager.Instance.cfg; //Init FanTable Settings setting_panel = new StackPanel(); setting_panel.Margin = new Thickness(2); //Fixed checkbox CheckBox isFixed = new CheckBox(); isFixed.Click += IsFixed_Click; isFixed.IsChecked = fanTable.isFixed; isFixed.Content = "isFixed"; TextBlock tooltip = new TextBlock(); tooltip.Text = "Set if the FanTable Auto Change Duty base on the circuit power"; isFixed.ToolTip = tooltip; ToolTipService.SetShowDuration(isFixed, 10000); setting_panel.Children.Add(isFixed); //Cpu proportion TextBlock Desc = new TextBlock(); Desc.Text = "Cpu"; setting_panel.Children.Add(Desc); //TextBox TextBox prop = new TextBox(); prop.Name = "Cpu"; prop.Text = fanTable.CpuProportion.ToString(); prop.LostFocus += Prop_LostFocus; tooltip = new TextBlock(); tooltip.Text = "Set the proportion it takes when calc Fan Duty"; prop.ToolTip = tooltip; ToolTipService.SetShowDuration(prop, 10000); setting_panel.Children.Add(prop); if (config.GpuCount >= 1) { //Gpu_1 proportion Desc = new TextBlock(); Desc.Text = "Gpu 1"; setting_panel.Children.Add(Desc); //TextBox prop = new TextBox(); prop.Name = "Gpu_1"; prop.Text = fanTable.Gpu_1_Proportion.ToString(); prop.LostFocus += Prop_LostFocus; tooltip = new TextBlock(); tooltip.Text = "Set the proportion it takes when calc Fan Duty"; prop.ToolTip = tooltip; ToolTipService.SetShowDuration(prop, 10000); setting_panel.Children.Add(prop); } if (config.GpuCount == 2) { //Gpu_2 proportion Desc = new TextBlock(); Desc.Text = "Gpu 2"; setting_panel.Children.Add(Desc); //TextBox prop = new TextBox(); prop.Name = "Gpu_2"; prop.Text = fanTable.Gpu_2_Proportion.ToString(); prop.LostFocus += Prop_LostFocus; tooltip = new TextBlock(); tooltip.Text = "Set the proportion it takes when calc Fan Duty"; prop.ToolTip = tooltip; ToolTipService.SetShowDuration(prop, 5000); setting_panel.Children.Add(prop); } //Starting Duty Desc = new TextBlock(); Desc.Text = "Starting\nDuty"; setting_panel.Children.Add(Desc); //TextBox prop = new TextBox(); prop.Name = "StartingDuty"; prop.Text = fanTable.StartingDuty.ToString(); prop.LostFocus += Prop_LostFocus; tooltip = new TextBlock(); tooltip.Text = "Set the fan starting duty"; prop.ToolTip = tooltip; ToolTipService.SetShowDuration(prop, 10000); setting_panel.Children.Add(prop); }