private TabItem GetAddRouteTab() { Label lblPoints = new Label(); lblPoints.Content = "Points:"; lblPoints.Foreground = Brushes.White; StackPanel points = new StackPanel(); points.Children.Add(lblPoints); points.Children.Add(GetPosDirField()); points.Children.Add(GetPosDirField()); StackPanel addRoutePanel = new StackPanel(); Button addPointButton = new Button(); addPointButton.Content = "Add point"; addPointButton.Foreground = Brushes.White; addPointButton.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#323236")); addPointButton.BorderBrush = Brushes.Transparent; addPointButton.Margin = new Thickness(5, 5, 5, 5); addPointButton.Click += new RoutedEventHandler((object sender, RoutedEventArgs e) => { points.Children.Add(GetPosDirField()); }); Button removePointButton = new Button(); removePointButton.Content = "Remove point"; removePointButton.Foreground = Brushes.White; removePointButton.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#323236")); removePointButton.BorderBrush = Brushes.Transparent; removePointButton.Margin = new Thickness(5, 5, 5, 5); removePointButton.Click += new RoutedEventHandler((object sender, RoutedEventArgs e) => { if (points.Children.Count > 3) { points.Children.RemoveAt(points.Children.Count - 1); } }); addRoutePanel.Children.Add(points); StackPanel addRoad = new StackPanel(); addRoad.Children.Add(GetComboBoxField("Diffuse:", Assets.DiffuseTextures)); addRoad.Children.Add(GetComboBoxField("Normal:", Assets.NormalMaps)); addRoad.Children.Add(GetComboBoxField("Specular:", Assets.SpecularMaps)); addRoad.Children.Add(GetInputField("Heightoffset:", "0,01", true)); addRoad.Visibility = Visibility.Collapsed; addRoad.Margin = new Thickness(0, 0, 0, 5); CheckBox hasRoad = new CheckBox(); hasRoad.Foreground = Brushes.White; hasRoad.Content = "Has road"; hasRoad.Margin = new Thickness(0, 5, 0, 5); hasRoad.Checked += new RoutedEventHandler((object sender, RoutedEventArgs e) => { addRoad.Visibility = Visibility.Visible; }); hasRoad.Unchecked += new RoutedEventHandler((object sender, RoutedEventArgs e) => { addRoad.Visibility = Visibility.Collapsed; }); addRoutePanel.Children.Add(addPointButton); addRoutePanel.Children.Add(removePointButton); addRoutePanel.Children.Add(hasRoad); addRoutePanel.Children.Add(addRoad); Button addRouteButton = new Button(); addRouteButton.Content = "Add route"; addRouteButton.Foreground = Brushes.White; addRouteButton.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#323236")); addRouteButton.BorderBrush = Brushes.Transparent; addRouteButton.Margin = new Thickness(5, 5, 5, 5); addRouteButton.Click += new RoutedEventHandler((object sender, RoutedEventArgs e) => { //---------------------- Route ---------------------- Route route = new Route(this.session); for (int i = 1; i < points.Children.Count; i++) { Vector3 position = new Vector3(float.Parse(((((points.Children[i] as WrapPanel).Children[0] as StackPanel).Children[1]) as TextBox).Text), float.Parse(((((points.Children[i] as WrapPanel).Children[1] as StackPanel).Children[1]) as TextBox).Text), float.Parse(((((points.Children[i] as WrapPanel).Children[2] as StackPanel).Children[1]) as TextBox).Text)); Vector3 direction = new Vector3(float.Parse(((((points.Children[i] as WrapPanel).Children[3] as StackPanel).Children[1]) as TextBox).Text), float.Parse(((((points.Children[i] as WrapPanel).Children[4] as StackPanel).Children[1]) as TextBox).Text), float.Parse(((((points.Children[i] as WrapPanel).Children[5] as StackPanel).Children[1]) as TextBox).Text)); route.AddRouteNode(new Route.RouteNode(position, direction)); } //--------------------------------------------------- //---------------------- Road ---------------------- if (hasRoad.IsChecked == true) { string diffuse = ((addRoad.Children[0] as StackPanel).Children[1] as ComboBox).SelectedItem.ToString(); string normal = ((addRoad.Children[1] as StackPanel).Children[1] as ComboBox).SelectedItem.ToString(); string specular = ((addRoad.Children[2] as StackPanel).Children[1] as ComboBox).SelectedItem.ToString(); float heightOffset = float.Parse(((addRoad.Children[3] as StackPanel).Children[1] as TextBox).Text); Road road = new Road(diffuse, normal, specular, heightOffset, route, this.session); route.SetRoad(road); } //-------------------------------------------------- TreeViewItem treeViewItem = new TreeViewItem(); treeViewItem.Header = "Route"; treeViewItem.Foreground = Brushes.White; treeViewItem.MouseDoubleClick += new MouseButtonEventHandler((object s, MouseButtonEventArgs args) => { Route sceneRoute; this.routeTree.TryGetValue(treeViewItem, out sceneRoute); if (this.currentNode != null) { Task.Run(() => this.currentNode.FollowRoute(sceneRoute, 2.0f, new Vector3(0, 0, 0), new Vector3(0, 0, 0))); } }); this.routes.Items.Add(treeViewItem); this.routeTree.Add(treeViewItem, route); Task.Run(() => this.session.GetScene().AddRoute(route)); }); addRoutePanel.Children.Add(addRouteButton); TabItem addRoute = new TabItem(); addRoute.Header = "Add Route"; addRoute.Content = addRoutePanel; addRoute.Foreground = Brushes.White; addRoute.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#323236")); addRoute.BorderBrush = Brushes.Transparent; return(addRoute); }