private void SendDanmu() { TextBlock text = new TextBlock(); text.Text = danMu; text.AddHandler(TextBlock.LoadedEvent, new RoutedEventHandler(GetActualWidthOfDanMu)); text.FontSize = 30; //text.Style = Resources["TextBlockStyle"] as Style; text.Style = (Style)this.FindResource("TextBlockStyle"); //text.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("White")); //System.Windows.Media.Effects.DropShadowEffect ds = new System.Windows.Media.Effects.DropShadowEffect(); //ds.Color = (Color)ColorConverter.ConvertFromString("#FF616161"); //ds.ShadowDepth = 1.5; //ds.Opacity = 1; //text.Effect = ds; myCanvas.Children.Add(text); DoubleAnimation doubleAnimation = new DoubleAnimation(); doubleAnimation.From = myWin.ActualWidth; doubleAnimation.To = -danMuActualWidth; doubleAnimation.Duration = TimeSpan.FromSeconds(10); text.BeginAnimation(Canvas.LeftProperty, doubleAnimation); }
private void Button_Click_1(object sender, RoutedEventArgs e) { TextBlock mytext = new TextBlock(); container.Children.Add(mytext); mytext.FontSize = _fontSize; mytext.Foreground = _fontColor; mytext.Text = TextIn.Text; mytext.VerticalAlignment = System.Windows.VerticalAlignment.Center; mytext.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; mytext.SetValue(Canvas.TopProperty, (double)imgbk.GetValue(Canvas.HeightProperty) / 2); mytext.SetValue(Canvas.LeftProperty, (double)imgbk.GetValue(Canvas.WidthProperty) / 2); mytext.AddHandler(System.Windows.Controls.Button.MouseLeftButtonDownEvent, new MouseButtonEventHandler(Element_MouseLeftButtonDown), true); mytext.AddHandler(System.Windows.Controls.Button.MouseMoveEvent, new System.Windows.Input.MouseEventHandler(Element_MouseMove), true); mytext.AddHandler(System.Windows.Controls.Button.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Element_MouseLeftButtonUp), true); _myLstText.Add(mytext); }
private Control MakeItem(string hellooo, Action <object, object> action) { var txt = new TextBlock { Text = hellooo }; txt.AddHandler(TappedEvent, action); return(txt); }
private void AddRowHeadersAndData() { // Iterate through the rows (row 0 done above). for (int rowsIndex = 1; rowsIndex < this.NumberOfRows; rowsIndex++) { // Iterate through the columns. for (int columnIndex = 0; columnIndex < this.NumberOfColumns; columnIndex++) { // If in the first column, add the size info. if (columnIndex == 0) { // Row size text box. var tb = new TextBlock { Tag = rowsIndex - 1, Margin = new Thickness(5), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Text = this.ParseGridLength(this.RowHeightsCollection[rowsIndex]), ToolTip = "Right click to edit this row's size" }; // Right Mouse Button Down event tb.AddHandler(MouseRightButtonDownEvent, new MouseButtonEventHandler(this.RowTextBlock_MouseRightButtonDownEvent)); // Set the row property. tb.SetValue(Grid.RowProperty, rowsIndex); // Set the column property. tb.SetValue(Grid.ColumnProperty, columnIndex); // Add to the RowHeaderTextBlockCollection. this.RowHeaderTextBlockCollection.Add(tb); // tb to the Grid. this.gridLayout.Children.Add(tb); } else { // Else clause takes care of columns 1 and above. // if the GridCellCollection does not have the row/column key, add it. if (!this.GridCellCollection.ContainsKey(this.MakeKey(rowsIndex, columnIndex))) { this.GridCellCollection.Add(this.MakeKey(rowsIndex, columnIndex), new CellContent(rowsIndex, columnIndex)); } var gridCellEditor = new GridCellEditor(); gridCellEditor.SetValue(Grid.RowProperty, rowsIndex); gridCellEditor.SetValue(Grid.ColumnProperty, columnIndex); // The DataContext of the gridCellEditor is set to the // CellContent object for this row and column. This should // allow the SelectedItem of the combo box to bind to the // ControlType property of the CellContent object. gridCellEditor.DataContext = this.GridCellCollection[this.MakeKey(rowsIndex, columnIndex)]; // cell editor into the Grid. this.gridLayout.Children.Add(gridCellEditor); } } } }
private void AddColumnHeaders() { // Starting in column 1 (because 0 row and column are used for size // configuration) add elements to the column headers. for (int i = 1; i < this.gridLayout.ColumnDefinitions.Count; i++) { // Create and add the combo box. var cbo = new ComboBox { FontSize = 10, VerticalAlignment = VerticalAlignment.Top, Margin = new Thickness(10), IsTabStop = false, Tag = i }; // Create a list of names from the enumeration string[] ary = Enum.GetNames(typeof(ControlType)); Array.Sort(ary); // Create the values for the comboBox string nextString = string.Empty; string currentString = string.Empty; for (int j = 0; j < ary.Length; j++) { if (nextString == string.Empty) { nextString = "Select"; } if (ary[j] == "None") { ary[j] = nextString; break; } currentString = ary[j]; ary[j] = nextString; nextString = currentString; } cbo.ItemsSource = ary; // Needs to follow above loop to have something to select cbo.SelectedValue = "Select"; cbo.AddHandler(Selector.SelectionChangedEvent, new SelectionChangedEventHandler(this.cboColumnHeader_SelectionChanged)); this.ColumnHeaderComboBoxCollection.Add(cbo); // Create the root element of the editor. var sp = new StackPanel(); // cbo goes into a StackPanel. sp.Children.Add(cbo); // Create and add a text block to show the width of the column. var tb = new TextBlock { Tag = i - 1, Margin = new Thickness(5), HorizontalAlignment = HorizontalAlignment.Center, Text = this.ParseGridLength(this.ColumnWidthsCollection[i]), ToolTip = "Right click to edit this column's size" }; tb.AddHandler(MouseRightButtonDownEvent, new MouseButtonEventHandler(this.ColumnTextBlock_MouseRightButtonDown)); this.ColumnHeaderTextBlockCollection.Add(tb); // tb goes into the StackPanel sp.Children.Add(tb); // Set the column property of the stack panel. sp.SetValue(Grid.ColumnProperty, i); // StackPanel into the grid. this.gridLayout.Children.Add(sp); } }
void getRequestForYou(int howMany) { if (howMany == 0) { howMany = howManyRequests; } for (int i = 0; i < howMany; i++) { TextBlock text = new TextBlock(); if (howMany == 1) { text.Text = requestG; } else { text.Text = "bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla"; } text.Width = 0.45 * widthScreen; text.Height = 0.1 * heightScreen; text.Padding = new Thickness(0, 0, 0, 0); text.TextWrapping = TextWrapping.Wrap; text.Margin = new Thickness(0, 0, 0, 0); text.AddHandler(PointerReleasedEvent, new PointerEventHandler(checkDetails), true); Button newButton = new Button(); newButton.Content = "YES"; newButton.Name = i + "yes"; // newButton.IsChecked = true; newButton.Width = 0.2 * widthScreen; newButton.Height = 0.1 * heightScreen; // newButton.AddHandler(PointerReleasedEvent, new PointerEventHandler(changeValue), true); Thickness margin = newButton.Margin; Button newButton2 = new Button(); newButton2.Content = "NO"; newButton2.Name = i + "no"; // newButton.IsChecked = true; newButton2.Width = 0.2 * widthScreen; newButton2.Height = 0.1 * heightScreen; // newButton.AddHandler(PointerReleasedEvent, new PointerEventHandler(changeValue), true); Border theLine = new Border(); theLine.Width = 1.1 * widthScreen; theLine.Height = 0.1 * heightScreen; theLine.BorderThickness = new Thickness(1); Windows.UI.Xaml.Media.SolidColorBrush colorForChat = new Windows.UI.Xaml.Media.SolidColorBrush(); Windows.UI.Xaml.Media.SolidColorBrush colorForChat2 = new Windows.UI.Xaml.Media.SolidColorBrush(); Windows.UI.Color actualColors = new Windows.UI.Color(); actualColors.R = 0; actualColors.G = 0; actualColors.B = 0; actualColors.A = 255; colorForChat.Color = actualColors; theLine.BorderBrush = colorForChat; margin.Left = widthScreen * 0.75; // margin.Top = -(scrollView.Height/2)+ ((i+ totalRequests )* (0.25 * heightScreen)); margin.Top = ((i + totalRequests) * (0.15 * heightScreen)); newButton.Margin = margin; margin.Left = 0.05 * widthScreen; newButton2.Margin = margin; margin.Left = -0.125 * widthScreen; text.Margin = margin; margin.Left = -0.2 * widthScreen; // theLine.Margin = new Thickness(0, 0.15 * heightScreen, 0,0); theLine.Margin = margin; // buttons.Add(newButton); // this.Controls.Add(newButton); requestSpace.Children.Add(newButton); requestSpace.Children.Add(newButton2); requestSpace.Children.Add(text); requestSpace.Children.Add(theLine); // Debug.WriteLine("size " + ((Button)requestSpace.Children[0]).Width); if (passedParameter == "0") { newButton.AddHandler(PointerReleasedEvent, new PointerEventHandler(setAnswer), true); newButton2.AddHandler(PointerReleasedEvent, new PointerEventHandler(setAnswer), true); } else { newButton.IsEnabled = false; newButton2.IsEnabled = false; } // requestSpace.Children[0].lo // this.cont actualColors.R = 255; actualColors.G = 255; actualColors.B = 255; actualColors.A = 255; colorForChat.Color = actualColors; newButton.Background = colorForChat; newButton2.Background = colorForChat; newButton.VerticalAlignment = VerticalAlignment.Top; newButton2.VerticalAlignment = VerticalAlignment.Top; text.VerticalAlignment = VerticalAlignment.Top; theLine.VerticalAlignment = VerticalAlignment.Top; requestText.Background = colorForChat; actualColors.R = 0; actualColors.G = 0; actualColors.B = 0; actualColors.A = 255; colorForChat2.Color = actualColors; theLine.BorderBrush = colorForChat2; requestSpace.Height += (0.2 * heightScreen); } totalRequests += howMany; scrollView.ScrollToVerticalOffset(requestSpace.Height); }