public void show() { Canvas canvas = new Canvas(); this.MainWindow.Content = canvas; Image backgroundImage = new Image { Name = "background", Source = new BitmapImage(new Uri("C:/tempConcours/newGameBackground.png", UriKind.Absolute)), }; backgroundImage.RenderTransform = MainScaleTransform; canvas.Children.Add(backgroundImage); Canvas.SetLeft(backgroundImage, 0); Canvas.SetTop(backgroundImage, 0); Label teamNameLabel = new Label { Name = "teamNameLabel", FontSize = 60, Content = "Nom de l'équipe" }; canvas.Children.Add(teamNameLabel); Canvas.SetTop(teamNameLabel, 650); Canvas.SetRight(teamNameLabel, 800); this.teamNameTextBox = new UbiTextBox { Name = "teamNameTextBox", Text = "nom", FontSize = 40, Width = 500, Height = 70 }; canvas.Children.Add(teamNameTextBox); Canvas.SetTop(teamNameTextBox, 670); Canvas.SetRight(teamNameTextBox, 250); TouchButton startButton = new TouchButton { Content = "Lancer le jeu", Width = 200, Height = 69 }; startButton.Background = Brushes.YellowGreen; startButton.ButtonTap += startButton_Tap; canvas.Children.Add(startButton); Canvas.SetTop(startButton, 661); Canvas.SetRight(startButton, 50); //this.startButton_Tap(null, null); }
private Connection AddLink(UIElement source,UIElement sink) { var con = new Connection() { RoutingStyle = new RoutingStraightLine(), VisualStyle = new VisualSimpleLine() { Stroke = new Pen() { Brush = Brushes.Gray, DashStyle = new DashStyle(new double[] { 5, 5 }, 0), Thickness = 3 } }, Source = source, Sink = sink, BeginCap = new GeometryDrawing( new SolidColorBrush(Color.FromArgb(255, 181, 243, 20)), new Pen(Brushes.Black, 4), Geometry.Parse("M -17,0 L -24,14 L 0,0 L -25,-14 Z") ), EndCap = new GeometryDrawing( new SolidColorBrush(Color.FromArgb(255, 181, 243, 20)), new Pen(Brushes.Black, 4), Geometry.Parse("M -17,0 L -24,14 L 0,0 L -25,-14 Z") ) }; AddGesture(con, con.BeginThumb); AddGesture(con, con.EndThumb); #region addTextbox var text = new UbiTextBox() { Padding = new Thickness(5), Background = Brushes.WhiteSmoke, Text = RandomHelper.GetRandomString(), FontSize = 12, MaxWidth = 150, MaxHeight = 100, AcceptsReturn = true, TextWrapping = TextWrapping.Wrap, TextAlignment = TextAlignment.Center, }; var border = new Border() { Child = text, BorderBrush = Brushes.Black, BorderThickness = new Thickness(2) }; var tap = new TapProcessor(); tap.Tap += delegate(object o, TapEventArgs arg) { if (!text.IsReadOnly) return; text.IsReadOnly = false; var key = KeyboardManager.RequestKeyboard(new KeyboardRequestArgs(text) { Position = arg.Transform.ConvertToVisual(text).Center /*GetCurrentPositionForElement(text)*/ }); key.KeyboardClosed += delegate(object oo, System.EventArgs ee) { text.IsReadOnly = true; }; }; TouchSurfaceWPF.GetOrCreateTouchSurface(border).AddGestureProcessor(tap); Connection.SetPlacementPercentage(text, 0.5); Connection.SetUseTangent(border, true); con.Children.Add(border); #endregion addTextbox conlayer.Children.Add(con); return con; }