public MarkdownList(bool numbered, IEnumerable<UIElement> elements) { InitializeComponent(); int number = 1; int rowCount = 0; foreach (var element in elements) { theGrid.RowDefinitions.Add(new RowDefinition()); var text = new TextBlock { TextWrapping = System.Windows.TextWrapping.Wrap, Margin = new Thickness(5, 0, 15, 0), Text = numbered ? (number++).ToString() + "." : "\u25CF" }; text.SetValue(Grid.RowProperty, rowCount); text.SetValue(Grid.ColumnProperty, 0); element.SetValue(Grid.RowProperty, rowCount++); element.SetValue(Grid.ColumnProperty, 1); if (element is RichTextBox) { element.SetValue(FrameworkElement.MarginProperty, new Thickness(-8, 0, 0, 0)); } else { element.SetValue(FrameworkElement.MarginProperty, new Thickness(4, 0, 0, 0)); } theGrid.Children.Add(text); theGrid.Children.Add(element); } }
// Update children (letter TextBlocks) placement after changing orientation // Just update visual representation // Caller is responsible for all other tasks (check placement, redraw background grind if layout bounding rectangle has changed, undo support) internal void RebuildCanvasAfterOrientationSwap() { for (int i = 0; i < wp.Word.Length; i++) { TextBlock tb = Children[i] as TextBlock; double top = wp.IsVertical ? UnitSize * i : 0; double left = wp.IsVertical ? 0 : UnitSize * i; tb?.SetValue(LeftProperty, left); tb?.SetValue(TopProperty, top); } }
private void fachpicker_SelectionChanged(object sender, SelectionChangedEventArgs e) { Fach f = fachpicker.SelectedItem as Fach; if (f.lektion == Lektion.Anderes && f.customfach == null) { if (fächeradded) { } else { //benutzerdefiniertes Fach fächer = new TextBlock() { Text = "Fach: ", FontSize = 34, Margin = new Thickness(7,0,0,0) }; fächer.SetValue(Grid.RowProperty, 1); fächer2 = new TextBox(); fächer2.SetValue(Grid.RowProperty, 1); fächer2.SetValue(Grid.ColumnProperty, 1); ContentPanel.Children.Add(fächer); ContentPanel.Children.Add(fächer2); fächeradded = true; } } else { Lehrperson.Text = f.Lehrer; Farbe.SelectedIndex = f.color; if (fächeradded) { ContentPanel.Children.Remove(fächer); ContentPanel.Children.Remove(fächer2); fächeradded = false; } } }
private void OnDownloaded(object sender, DownloadStringCompletedEventArgs args) { entradas = parse(args.Result); for (int j = 1, i = entradas.Count - 5; i < entradas.Count; i++) { if (i < 0) continue; TextBlock emprestimoBlock = new TextBlock(); TextBlock nameBlock = new TextBlock(); TextBlock devolucaoBlock = new TextBlock(); emprestimoBlock.SetValue(Grid.ColumnProperty, 0); nameBlock.SetValue(Grid.ColumnProperty, 1); devolucaoBlock.SetValue(Grid.ColumnProperty, 2); emprestimoBlock.SetValue(Grid.RowProperty, j); nameBlock.SetValue(Grid.RowProperty, j); devolucaoBlock.SetValue(Grid.RowProperty, j); emprestimoBlock.HorizontalAlignment = HorizontalAlignment.Center; nameBlock.HorizontalAlignment = HorizontalAlignment.Center; devolucaoBlock.HorizontalAlignment = HorizontalAlignment.Center; emprestimoBlock.VerticalAlignment = VerticalAlignment.Center; nameBlock.VerticalAlignment = VerticalAlignment.Center; devolucaoBlock.VerticalAlignment = VerticalAlignment.Center; emprestimoBlock.Text = entradas[i].emprestimo; nameBlock.Text = entradas[i].nome; devolucaoBlock.Text = entradas[i].devolucao; nameBlock.TextAlignment = TextAlignment.Center; nameBlock.FontStyle = FontStyles.Italic; ContentPanel.Children.Add(emprestimoBlock); ContentPanel.Children.Add(nameBlock); ContentPanel.Children.Add(devolucaoBlock); j++; } }
void InitEW() { mediaAct.Upload(videoIntro, "Start_VideoIntro.mp4"); mediaAct.Upload(videoStudentStart, "Start_VideoStudentStart.mp4"); mediaAct.Upload(soundFalse, "Start_SoundFalse.wav"); mediaAct.Upload(soundStart, "Start_SoundStart.mp3"); mediaAct.Upload(soundTrue, "Start_SoundTrue.wav"); mediaAct.Upload(soundFinish, "Start_SoundFinish.mp3"); mediaAct.Upload(soundIntro, "Start_SoundIntro.mp3"); for (int i = 0; i < 4; i++) { TextBlock txtBlockStudentName = new TextBlock { Text = "Thi Sinh" + (i + 1).ToString(), FontWeight = FontWeights.DemiBold, FontFamily = new FontFamily("Open Sans"), Foreground = Brushes.White, FontSize = 28, TextAlignment = TextAlignment.Center, VerticalAlignment = VerticalAlignment.Bottom }; //Viewbox viewboxStudentName = new Viewbox(); //viewboxStudentName.Child = txtBlockStudentName; //viewboxStudentName.SetValue(Grid.ColumnProperty, i + 1); txtBlockStudentName.SetValue(Grid.ColumnProperty, i + 1); txtBlockStudentName.SetValue(Grid.RowProperty, 0); txtBlockStudentName.SetValue(Grid.RowSpanProperty, 2); gridStudentsName.Children.Add(txtBlockStudentName); txtBlockStudentNameList.Add(txtBlockStudentName); TextBlock txtBlockStudentPoint = new TextBlock { Text = "0", FontWeight = FontWeights.DemiBold, FontFamily = new FontFamily("Open Sans"), FontSize = 25, Foreground = Brushes.White, TextAlignment = TextAlignment.Center, VerticalAlignment = VerticalAlignment.Top }; txtBlockStudentPoint.SetValue(Grid.ColumnProperty, i + 1); txtBlockStudentPoint.SetValue(Grid.RowProperty, 1); txtBlockStudentPoint.SetValue(Grid.RowSpanProperty, 2); txtBlockStudentPointList.Add(txtBlockStudentPoint); gridStudentsName.Children.Add(txtBlockStudentPoint); } HideAll(); }
private void Display([NotNull] XElement root) { Debug.ArgumentNotNull(root, nameof(root)); textBoxes.Clear(); Grid.Children.Clear(); var row = 0; foreach (var element in root.Elements().OrderBy(e => e.GetAttributeValue("language"))) { var languageName = element.GetAttributeValue("language"); var displayName = element.GetAttributeValue("name"); var textBlock = new TextBlock(new Run(languageName + @":")); textBlock.SetValue(Grid.ColumnProperty, 0); textBlock.SetValue(Grid.RowProperty, row); textBlock.VerticalAlignment = VerticalAlignment.Center; textBlock.Margin = new Thickness(0, 2, 8, 2); Grid.Children.Add(textBlock); var textBox = new TextBox(); textBox.Text = displayName; textBox.Tag = languageName; textBox.VerticalAlignment = VerticalAlignment.Center; textBox.Margin = new Thickness(0, 2, 0, 2); textBox.SetValue(Grid.ColumnProperty, 1); textBox.SetValue(Grid.RowProperty, row); Grid.Children.Add(textBox); textBoxes.Add(textBox); Grid.RowDefinitions.Add(new RowDefinition()); row++; } }
private bool GeneratePage(Canvas printSurface, Thickness pageMargins, Size pageSize) { // Find the starting coordinate. double topPosition = pageMargins.Top + extraMargin; // Begin looping through the list. while (listPrintIndex < lst.Items.Count) { // Create a TextBlock for each line, with a 30-pixel font. TextBlock txt = new TextBlock(); txt.FontSize = 30; txt.Text = lst.Items[listPrintIndex].ToString(); // If the new line doesn't fit, stop printing this page, // but request another page. double measuredHeight = txt.ActualHeight; if (measuredHeight > (pageSize.Height - topPosition - extraMargin)) { return(true); } // Place the TextBlock on the Canvas. txt.SetValue(Canvas.TopProperty, topPosition); txt.SetValue(Canvas.LeftProperty, pageMargins.Left + extraMargin); printSurface.Children.Add(txt); // Move to the next line. listPrintIndex++; topPosition = topPosition + measuredHeight; } // The printing code has reached the end of the list. // No more pages are needed. return(false); }
private void gui() { char[, ] key = Algorithm.Playfair.Key(_input_word); key_gui_grid.Children.Clear(); for (int i = 0; i < 5; ++i) { for (int j = 0; j < 5; ++j) { TextBlock tb = new TextBlock(); tb.SetValue(Grid.RowProperty, i); tb.SetValue(Grid.ColumnProperty, j); tb.SetValue(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Center); tb.SetValue(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center); tb.Text = key[i, j].ToString(); if (key[i, j].Equals('I')) { tb.Text = tb.Text + "/J"; } tb.Foreground = new SolidColorBrush(Colors.White); tb.FontSize = 24; key_gui_grid.Children.Add(tb); } } }
private static void AddChangeoverRow(Grid grid, Changeover changeover) { RowDefinition row = new RowDefinition(); TextBlock datebloc = new TextBlock(); datebloc.Text = changeover.DateContent.ToString("dd.MM.yyyy") + (changeover.IsNight ? " Noční" : " Denní"); TextBlock vehiclebloc = new TextBlock(); vehiclebloc.Text = changeover.VehicleNumber; TextBlock worktypebloc = new TextBlock(); worktypebloc.Text = changeover.WorkTypeName; TextBlock descriptionbloc = new TextBlock(); descriptionbloc.TextWrapping = TextWrapping.Wrap; descriptionbloc.Text = changeover.Description; datebloc.Margin = new Thickness(0, 10, 0, 0); vehiclebloc.Margin = new Thickness(10, 10, 0, 0); worktypebloc.Margin = new Thickness(10, 10, 0, 0); descriptionbloc.Margin = new Thickness(10, 10, 0, 0); datebloc.SetValue(Grid.RowProperty, grid.RowDefinitions.Count); datebloc.SetValue(Grid.ColumnProperty, 0); vehiclebloc.SetValue(Grid.RowProperty, grid.RowDefinitions.Count); vehiclebloc.SetValue(Grid.ColumnProperty, 1); worktypebloc.SetValue(Grid.RowProperty, grid.RowDefinitions.Count); worktypebloc.SetValue(Grid.ColumnProperty, 2); descriptionbloc.SetValue(Grid.RowProperty, grid.RowDefinitions.Count); descriptionbloc.SetValue(Grid.ColumnProperty, 3); grid.Children.Add(datebloc); grid.Children.Add(vehiclebloc); grid.Children.Add(worktypebloc); grid.Children.Add(descriptionbloc); grid.RowDefinitions.Add(row); }
public void SetHighlightTextBlockTextProperty(object dataItem, TextBlock textBlock) { if (this.DataMemberBinding != null) { var content = this.GetCellContent(dataItem); if (content != null) { textBlock.SetValue(TextBlock.TextProperty, string.Format("{0}", content)); } } else { textBlock.ClearValue(TextBlock.TextProperty); } }
void DoStuff(object sender, EventArgs e) { //<SnippetProceduralPropertySet> Canvas myC = new Canvas(); myC.Width = 200.0; //</SnippetProceduralPropertySet> //<SnippetProceduralPropertyGet> double whatWidth; whatWidth = myC.Width; //</SnippetProceduralPropertyGet> double checkWidth; //<SnippetPropertyMixedDeclProcCB> checkWidth = myC.Width; if (checkWidth == 200.0) { anotherButton.Width = 300.0; } //</SnippetPropertyMixedDeclProcCB> myC.Height = myC.Width; root.Children.Add(myC); TextBlock tb = new TextBlock(); tb.Text = "Hello"; tb.SetValue(Canvas.LeftProperty, 10.0); tb.SetValue(Canvas.TopProperty, 200.0); myC.Children.Add(tb); TextBlock tb2 = new TextBlock(); tb2.Text = "Hello"; tb2.SetValue(Canvas.LeftProperty, 40.0); tb2.SetValue(Canvas.TopProperty, 300.0); myC.Children.Add(tb2); }
private void MenuItem_Click_添加角色(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog(); dialog.Filter = "Cookie文件|Cookie"; if (dialog.ShowDialog() == true) { string path = dialog.FileName; string[] authtext = File.ReadAllLines(path); foreach (string s in authtext) { string[] l = s.Split(new char[] { ';' }); void addcharacter(object value) { center.AddCharacter((string[])value); Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { lock (center.handle.characterList) { CharacterList.Items.Clear(); foreach (KeyValuePair <string, Character> character in center.handle.characterList) { Grid grid = new Grid(); CheckBox box = new CheckBox(); TextBlock text = new TextBlock(); box.IsChecked = true; text.Text = character.Key; text.Tag = character.Value; box.Tag = character.Value; text.MouseLeftButtonDown += CharacterBox_Click; grid.Children.Add(box); grid.Children.Add(text); box.SetValue(Grid.ColumnProperty, 0); text.SetValue(Grid.ColumnProperty, 1); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions[0].Width = GridLength.Auto; grid.ColumnDefinitions[1].Width = GridLength.Auto; CharacterList.Items.Add(grid); } } })); } Thread thread = new Thread(new ParameterizedThreadStart(addcharacter)); thread.Start(l); } } }
internal static TextBlock CreateTextBlock() { var textBlock = new TextBlock { Foreground = TEXTBRUSH }; textBlock.SetValue(Panel.ZIndexProperty, 3); textBlock.UseLayoutRounding = true; textBlock.Effect = new DropShadowEffect { ShadowDepth = 2, BlurRadius = 2, Opacity = 0.6 }; textBlock.FontFamily = new FontFamily("Lucidia Console"); textBlock.Margin = new Thickness(0); textBlock.VerticalAlignment = VerticalAlignment.Center; return(textBlock); }
public void AddHeader([NotNull] string text) { Assert.ArgumentNotNull(text, nameof(text)); var textBlock = new TextBlock { Text = text, Margin = new Thickness(4, 4, 4, 4), TextWrapping = TextWrapping.Wrap, FontWeight = FontWeights.Bold }; textBlock.SetValue(Grid.ColumnSpanProperty, 2); Grid.Children.Add(textBlock); }
private void InsertWeekDaysToGrid() { for (int i = 0; i < 7; i++) { Collection <string> dayNames = Utilities.DayNames; TextBlock textBlockDayName = new TextBlock { Text = dayNames[i] }; Border borderDayName = new Border(); textBlockDayName.SetValue(Grid.ColumnProperty, i); borderDayName.SetValue(Grid.ColumnProperty, i); BodyGrid.Children.Add(textBlockDayName); BodyGrid.Children.Add(borderDayName); } }
public static void Main() { Project.App app = new Project.App(); app.InitializeComponent(); MainWindow mainWindow = new MainWindow(); TextBlock HelloFromMain = new TextBlock(); HelloFromMain.Text = "Hello from Main!"; HelloFromMain.FontSize = 18; HelloFromMain.HorizontalAlignment = HorizontalAlignment.Center; HelloFromMain.SetValue(DockPanel.DockProperty, Dock.Top); mainWindow.HelloMainContainer.Children.Add(HelloFromMain); app.Run(mainWindow); }
private static UIElement CreateTextBlock(string text, int zIndex, Brush fill = null) { TextBlock block = new TextBlock { Text = text, TextAlignment = TextAlignment.Center, VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch, TextWrapping = TextWrapping.Wrap, Background = fill ?? Brushes.Transparent }; block.SetValue(Panel.ZIndexProperty, zIndex); return(block); }
/// <summary> /// Generates the value stamps. /// </summary> /// <param name="stampValuesCount">Values count.</param> private void generateValueStamps(int stampValuesCount) { for (int i = 0; i < stampValuesCount; i++) { TextBlock tmpStamp = new TextBlock(); tmpStamp.TextAlignment = TextAlignment.Center; tmpStamp.FontSize = 10; tmpStamp.SetBinding(TextBlock.ForegroundProperty, valueForegroundBinding); tmpStamp.VerticalAlignment = VerticalAlignment.Center; tmpStamp.HorizontalAlignment = HorizontalAlignment.Center; tmpStamp.SetValue(Panel.ZIndexProperty, 3); stampValues.Add(tmpStamp); scaleGrid.Children.Add(tmpStamp); } }
public void AddTitle(Grid grid, string msg, DateTime date) { grid.RowDefinitions.Add(new RowDefinition()); TextBlock title = new TextBlock { Text = msg + "\n" + date.StartOfWeek().ToString("d MMM yyyy") + " - " + date.StartOfWeek().AddDays(7).ToString(("d MMM yyyy")), Foreground = TextOnBackgroundColorBrush, FontSize = 30, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, TextWrapping = TextWrapping.WrapWholeWords, }; title.SetValue(Grid.RowProperty, 0); grid.Children.Add(title); }
/// <summary> /// Adds a column to a grid /// </summary> /// <param name="grid">Grid to add the column to</param> /// <param name="columnIndex">Index of the column</param> /// <param name="column">Source column defintition which will be used to calculate the width of the column</param> private void AddTableColumn(Grid grid, double totalColumnWidth, int columnIndex, DataGridColumn column) { double proportion = column.Width.Value / (this.PageSize.Width - (this.PageMargin.Left + this.PageMargin.Right)); ColumnDefinition colDefinition = new ColumnDefinition(); colDefinition.Width = new GridLength(proportion, GridUnitType.Star); grid.ColumnDefinitions.Add(colDefinition); TextBlock text = new TextBlock(); text.Style = this.TableHeaderTextStyle; text.TextTrimming = TextTrimming.CharacterEllipsis; text.Text = column.Header.ToString(); text.SetValue(Grid.ColumnProperty, columnIndex); grid.Children.Add(text); _tableColumnDefinitions.Add(colDefinition); }
public void AddPageTitle(Grid grid, string msg) { grid.RowDefinitions.Add(new RowDefinition()); TextBlock textBlock = new TextBlock { Text = msg, Foreground = TextOnBackgroundColorBrush, FontSize = 30, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, TextWrapping = TextWrapping.WrapWholeWords, }; textBlock.SetValue(Grid.RowProperty, 0); grid.Children.Add(textBlock); }
private void SetKebiaoGridBorder(int week) { //边框 //for (int i = 0; i < kebiaoGrid.RowDefinitions.Count; i++) //{ // for (int j = 0; j < kebiaoGrid.ColumnDefinitions.Count; j++) // { // var border = new Border() { BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(0.5) }; // Grid.SetRow(border, i); // Grid.SetColumn(border, j); // kebiaoGrid.Children.Add(border); // } //} //星期背景色 if (week == 0) { Grid backgrid = new Grid(); backgrid.Background = new SolidColorBrush(Color.FromArgb(255, 254, 245, 207)); backgrid.SetValue(Grid.RowProperty, 0); backgrid.SetValue(Grid.ColumnProperty, (Int16.Parse(Utils.GetWeek()) + 6) % 7); backgrid.SetValue(Grid.RowSpanProperty, 12); kebiaoGrid.Children.Add(backgrid); backweekgrid.Background = new SolidColorBrush(Color.FromArgb(255, 254, 245, 207)); backweekgrid.SetValue(Grid.ColumnProperty, (Int16.Parse(Utils.GetWeek()) == 0 ? 7 : Int16.Parse(Utils.GetWeek()))); KebiaoWeekGrid.Children.Remove(backweekgrid); KebiaoWeekGrid.Children.Add(backweekgrid); } else { backweekgrid.Background = new SolidColorBrush(Color.FromArgb(255, 248, 248, 248)); backweekgrid.SetValue(Grid.ColumnProperty, (Int16.Parse(Utils.GetWeek()) == 0 ? 7 : Int16.Parse(Utils.GetWeek()))); KebiaoWeekGrid.Children.Remove(backweekgrid); KebiaoWeekGrid.Children.Add(backweekgrid); } TextBlock KebiaoWeek = new TextBlock(); KebiaoWeek.Text = Utils.GetWeek(2); KebiaoWeek.FontSize = 20; KebiaoWeek.Foreground = new SolidColorBrush(Colors.Black); KebiaoWeek.FontWeight = FontWeights.Light; KebiaoWeek.VerticalAlignment = VerticalAlignment.Center; KebiaoWeek.HorizontalAlignment = HorizontalAlignment.Center; KebiaoWeek.SetValue(Grid.ColumnProperty, (Int16.Parse(Utils.GetWeek()) == 0 ? 7 : Int16.Parse(Utils.GetWeek()))); KebiaoWeekGrid.Children.Add(KebiaoWeek); }
private void BuildEvents() { if (EventsBuilt) { return; } var events = Countdown.GetCountdowns().Where(cd => cd.IsEventOccuringOnDay(Date)).ToArray(); int count = events.Length; var summary = new TextBlock() { Text = "Event Summary", FontSize = 36 }; var row = new RowDefinition();// { Height = new GridLength(summary.Height + 2) }; ContentPanel.RowDefinitions.Add(row); summary.SetValue(Grid.RowProperty, 0); ContentPanel.Children.Add(summary); if (count > 0) { var sc = new StringCreator().AddParameter(StringParam.COUNT, count); string text = sc.BuildString(AppResources.DayEventsSummary); summary.Text = text; int rowCount = 1; foreach (var cd in events) { var eventBlock = new TextBlock() { Text = cd.Title, FontSize = 22, Tag = cd }; eventBlock.Tap += EventBlock_Tap; var eventRow = new RowDefinition();// { Height = new GridLength(eventBlock.Height + 2) }; ContentPanel.RowDefinitions.Add(eventRow); eventBlock.SetValue(Grid.RowProperty, rowCount); ContentPanel.Children.Add(eventBlock); rowCount++; } } else { summary.Text = AppResources.DayNoEventsSummary; } EventsBuilt = true; }
/// <summary> /// Build the user customization box. /// </summary> private void BuildCustomizeGroup() { GroupBox box = new GroupBox() { Header = "Acount Information", Padding = new Thickness(5) }; StackPanel panel = new StackPanel(); DockPanel expiresPanel = new DockPanel(); CheckBox mustChangePassword = new CheckBox() { Content = "User must change password at next logon", IsEnabled = false, Margin = new Thickness(0, 3, 0, 3) }; TextBlock expiresText = new TextBlock() { Text = "Password expires:", Margin = new Thickness(0, 0, 3, 0) }; DialogDatePicker passwordExpires = new DialogDatePicker() { Margin = new Thickness(0, 3, 0, 3) }; CheckBox accountDisabled = new CheckBox() { Content = "Account is disabled", Margin = new Thickness(0, 3, 0, 3) }; mustChangePassword.SetBinding(CheckBox.IsCheckedProperty, new Binding("IsPasswordExpired") { Mode = BindingMode.OneWay }); passwordExpires.SetBinding(DialogDatePicker.DateTimeProperty, new Binding("PasswordExpires") { Mode = BindingMode.TwoWay }); accountDisabled.SetBinding(CheckBox.IsCheckedProperty, new Binding("AccountDisabled")); expiresText.SetValue(DockPanel.DockProperty, Dock.Left); passwordExpires.SetValue(DockPanel.DockProperty, Dock.Right); expiresPanel.Children.Add(expiresText); expiresPanel.Children.Add(passwordExpires); panel.Children.Add(expiresPanel); panel.Children.Add(mustChangePassword); panel.Children.Add(accountDisabled); box.Content = panel; this.customizePanel.Children.Add(box); }
public async Task order1_MouseDoubleClickAsync(object se, RoutedEventArgs es, int accnum) { tempID = accnum; textBox.Text = Convert.ToString(accnum); SqlConnection connection = new SqlConnection("Data Source=mycsdb.civb68g6fy4p.us-east-2.rds.amazonaws.com;Initial Catalog=warehouse;User ID=masterUser;Password=master1234;"); using (connection) { await connection.OpenAsync(); using (SqlCommand getRoute = new SqlCommand("SELECT route_id FROM routelist WHERE acc_id = " + accnum + ";", connection)) { tempRoute = Convert.ToInt32(await getRoute.ExecuteScalarAsync()); } using (SqlCommand getProducts = new SqlCommand("SELECT prod_name, quantity FROM orders WHERE acc_id = " + accnum + ";", connection)) { using (SqlDataReader reader = await getProducts.ExecuteReaderAsync()) { if (listBox.Items.Count != 0) { listBox.Items.Clear(); } while (reader.Read()) { System.Windows.Controls.ListBoxItem edit = new ListBoxItem(); System.Windows.Controls.StackPanel stk = new StackPanel(); stk.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal); stk.SetValue(StackPanel.HorizontalAlignmentProperty, HorizontalAlignment.Left); edit.SetValue(ListBoxItem.HorizontalContentAlignmentProperty, HorizontalAlignment.Left); System.Windows.Controls.TextBlock prod = new TextBlock(); prod.Width = 370; prod.FontSize = 12; prod.SetValue(TextBlock.TextAlignmentProperty, TextAlignment.Left); prod.Text = reader.GetString(0); System.Windows.Controls.TextBlock quant = new TextBlock(); quant.Width = 80; quant.FontSize = 12; quant.SetValue(TextBlock.TextAlignmentProperty, TextAlignment.Right); quant.Text = Convert.ToString(reader.GetInt32(1)); stk.Children.Add(prod); stk.Children.Add(quant); edit.Content = stk; listBox.Items.Add(edit); } } } connection.Close(); } }
/// <summary> /// Scale [1.0, 3.0] /// </summary> /// <param name="scale"></param> public void UpdateCurveScale(double scale) { if (scale < 1.0 || scale > 3.0) { return; } if (Math.Abs(this.currentScale - scale) < double.Epsilon) { return; } this.currentScale = scale; if (curve == null) { return; } this.centerX = timeLine.X1; double y = double.NaN; if (this.GetY(this.centerX, out y)) { this.centerY = y; } else { this.centerY = this.Height / 2; } curve.RenderTransform = new ScaleTransform(scale, scale, this.centerX, this.centerY); //int i = 0; foreach (var g in this.Graduations) { Line l = g.Value.Line; l.Y1 = l.Y2 = (g.Value.Pos - centerY) * this.currentScale + centerY; } foreach (var g in this.GraduationTexts) { TextBlock l = g.Value.Text; double pos = (g.Value.Pos - centerY) * this.currentScale + centerY; l.SetValue(Canvas.TopProperty, (double)pos); } }
public override void LoadWindowControls(StackPanel control, string parent, string name, Type type, object[] attributes, Loc member) { LoadLabelControl(control, name); Avalonia.Controls.Grid innerPanel = getSharedRowPanel(4); TextBlock lblX = new TextBlock(); lblX.Text = "X:"; lblX.VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center; lblX.HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Right; innerPanel.Children.Add(lblX); innerPanel.ColumnDefinitions[0].Width = new GridLength(30); lblX.SetValue(Avalonia.Controls.Grid.ColumnProperty, 0); NumericUpDown nudValueX = new NumericUpDown(); nudValueX.Margin = new Thickness(4, 0, 0, 0); nudValueX.Minimum = Int32.MinValue; nudValueX.Maximum = Int32.MaxValue; nudValueX.Value = member.X; innerPanel.Children.Add(nudValueX); nudValueX.SetValue(Avalonia.Controls.Grid.ColumnProperty, 1); TextBlock lblY = new TextBlock(); lblY.Margin = new Thickness(8, 0, 0, 0); lblY.Text = "Y:"; lblY.VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center; lblY.HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Right; innerPanel.Children.Add(lblY); innerPanel.ColumnDefinitions[2].Width = new GridLength(30); lblY.SetValue(Avalonia.Controls.Grid.ColumnProperty, 2); NumericUpDown nudValueY = new NumericUpDown(); nudValueY.Margin = new Thickness(4, 0, 0, 0); nudValueY.Minimum = Int32.MinValue; nudValueY.Maximum = Int32.MaxValue; nudValueY.Value = member.Y; innerPanel.Children.Add(nudValueY); nudValueY.SetValue(Avalonia.Controls.Grid.ColumnProperty, 3); control.Children.Add(innerPanel); }
public override List <TextBlock> PreviewGroupBox() { List <TextBlock> liste = new List <TextBlock>(); TextBlock TBC; TBC = new TextBlock() { Text = this.CON_LIBELLE }; TBC.SetValue(Grid.ColumnProperty, 0); liste.Add(TBC); return(liste); }
private void addHeaderLabel(double left, string text, int offset) { var textBlock = new TextBlock() { Foreground = GridBrush, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Center, Text = text, Width = 80, FontSize = 12, Margin = new Thickness(LABELS_WIDTH + left - offset, 0, 0, 0) }; Headers.Add(textBlock); textBlock.SetValue(Panel.ZIndexProperty, 10); contentHeader.Children.Add(textBlock); }
public MainPage() { this.InitializeComponent(); this.NavigationCacheMode = NavigationCacheMode.Required; foreach (var month in _monthsList) { var textBlock = new TextBlock { Text = month }; textBlock.SetValue(AutomationProperties.NameProperty, month); // ReSharper disable once PossibleNullReferenceException this.ListBox.Items.Add(textBlock); } }
private void CreateGripperDisplay() { if (_gripperDisplay == null) { _gripperDisplay = new TextBlock { FontFamily = new FontFamily(GripperDisplayFont), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Foreground = GripperForeground, Text = _resizeDirection == GridResizeDirection.Columns ? GripperBarVertical : GripperBarHorizontal }; _gripperDisplay.SetValue( Windows.UI.Xaml.Automation.AutomationProperties.AccessibilityViewProperty, Windows.UI.Xaml.Automation.Peers.AccessibilityView.Raw); } }
private void GetValue(StackPanel grid, string name, object value, string key) { var printKey = "Print" + key; var print = (bool)properties.GetValueOrDefault(printKey, true); if (!print) { if (priceTagSettings.HideNotPrinted) { return; } value = ""; } var label = new TextBlock { Style = styles.GetValueOrDefault(key), Text = (value ?? "").ToString(), Margin = new Thickness(0), Padding = new Thickness(0) }; if (!String.IsNullOrEmpty(name)) { var dockPanel = new DockPanel { Width = 162, Children = { new Label { VerticalAlignment = VerticalAlignment.Center, Content = name, FontSize = 9, Margin = new Thickness(0), Padding = new Thickness(0), }, label } }; label.SetValue(DockPanel.DockProperty, Dock.Right); grid.Children.Add(dockPanel); } else { grid.Children.Add(label); } }
private static void CreateDate(Grid pagegrid, Date date) { pagegrid.RowDefinitions.Add(new RowDefinition()); TextBlock datebloc = new TextBlock(); datebloc.Text = "Směna : " + date.DateContent.ToString("dd.MMMM.yyyy") + (date.IsNight ? " Noční" : " Denní"); datebloc.Margin = new Thickness(0, 15, 0, 15); datebloc.HorizontalAlignment = HorizontalAlignment.Center; datebloc.FontWeight = FontWeights.Bold; datebloc.FontSize = 15; datebloc.SetValue(Grid.RowProperty, 0); pagegrid.Children.Add(datebloc); pagegrid.Measure(measuresize); measuredheight = pagegrid.DesiredSize.Height; avalableheight = pagesize.Height - pagegrid.DesiredSize.Height; }
// Constructor public MainPage() { InitializeComponent(); // Set the data context of the listbox control to the sample data DataContext = App.ViewModel; // Sample code to localize the ApplicationBar //BuildLocalizedApplicationBar(); foreach (var month in _monthsList) { var textBlock = new TextBlock { Text = month }; textBlock.SetValue(AutomationProperties.NameProperty, month); // ReSharper disable once PossibleNullReferenceException this.ListBox.Items.Add(textBlock); } }
partial void InitializeBusyIndicator() { if (_busyIndicator != null) { return; } _grid = new Grid(); _grid.RowDefinitions.Add(new RowDefinition {Height = new GridLength(1, GridUnitType.Star)}); _grid.RowDefinitions.Add(new RowDefinition {Height = new GridLength(1, GridUnitType.Auto)}); _grid.RowDefinitions.Add(new RowDefinition {Height = new GridLength(1, GridUnitType.Auto)}); _grid.RowDefinitions.Add(new RowDefinition {Height = new GridLength(1, GridUnitType.Star)}); var backgroundBorder = new Border(); backgroundBorder.Background = new SolidColorBrush(Colors.Gray); backgroundBorder.Opacity = 0.5; backgroundBorder.SetValue(Grid.RowSpanProperty, 4); _grid.Children.Add(backgroundBorder); _statusTextBlock = new TextBlock(); //_statusTextBlock.Style = (Style)Application.Current.Resources["PhoneTextNormalStyle"]; _statusTextBlock.HorizontalAlignment = HorizontalAlignment.Center; _statusTextBlock.SetValue(Grid.RowProperty, 1); _grid.Children.Add(_statusTextBlock); _busyIndicator = ConstructorBusyIndicator(); _busyIndicator.SetValue(Grid.RowProperty, 2); _grid.Children.Add(_busyIndicator); _containerPopup = new Popup(); _containerPopup.VerticalAlignment = VerticalAlignment.Center; _containerPopup.HorizontalAlignment = HorizontalAlignment.Center; _containerPopup.Child = _grid; double rootWidth = Window.Current.Bounds.Width; double rootHeight = Window.Current.Bounds.Height; _busyIndicator.Width = rootWidth; _grid.Width = rootWidth; _grid.Height = rootHeight; _containerPopup.UpdateLayout(); }
public static void SetCollapseOnEmpty(TextBlock element, bool value) { element.SetValue(CollapseOnEmptyProperty, value); }
private void BuildMessageBox( string messageBoxText, string caption, MessageBoxServiceButton button, List<string> customLabels) { var rootVisual = this.FindRootVisual(); if (null != rootVisual) { var bgColor = (Color)Application.Current.Resources["PhoneBackgroundColor"]; var overlayColor = Color.FromArgb(127, bgColor.R, bgColor.G, bgColor.B); var fgColor = (Color)Application.Current.Resources["PhoneForegroundColor"]; var opacityColor = Color.FromArgb(200, bgColor.R, bgColor.G, bgColor.B); this._rootElement = new Grid { Background = new SolidColorBrush(overlayColor) }; this._rootElement.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); this._rootElement.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); this._mbsRoot = new Grid { Background = new SolidColorBrush(overlayColor), Projection = new PlaneProjection() }; this._mbsRoot.ColumnDefinitions.Add( new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); this._mbsRoot.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); this._mbsRoot.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); this._rootElement.Children.Add(this._mbsRoot); // Make sure that our grid spans all rows and columns of it's parent, if the // parent is a Grid. if (rootVisual is Grid) { var parent = (Grid)rootVisual; int columnCount = parent.ColumnDefinitions.Count; if (columnCount > 0) { this._rootElement.SetValue(Grid.ColumnSpanProperty, columnCount); } int rowCount = parent.RowDefinitions.Count; if (rowCount > 0) { this._rootElement.SetValue(Grid.RowSpanProperty, rowCount); } } Border background = new Border { Background = new SolidColorBrush(fgColor) }; background.SetValue(Grid.ColumnSpanProperty, 2); background.SetValue(Grid.RowSpanProperty, 2); this._mbsRoot.Children.Add(background); Border opaqueOverlay = new Border { Background = new SolidColorBrush(opacityColor) }; opaqueOverlay.SetValue(Grid.ColumnSpanProperty, 2); opaqueOverlay.SetValue(Grid.RowSpanProperty, 2); this._mbsRoot.Children.Add(opaqueOverlay); // Add the caption. StackPanel container = new StackPanel { Margin = new Thickness(12, 0, 12, 12) }; container.SetValue(Grid.ColumnSpanProperty, 2); TextBlock title = new TextBlock { FontFamily = new FontFamily("Segoe WP Semibold"), FontSize = 32, Margin = new Thickness(12), Text = caption, TextWrapping = TextWrapping.Wrap }; title.SetValue(TextOptions.TextHintingModeProperty, TextHintingMode.Animated); container.Children.Add(title); // Add the message text. TextBlock message = new TextBlock { FontSize = 24, Margin = new Thickness(12, 0, 12, 0), Text = messageBoxText, TextWrapping = TextWrapping.Wrap }; container.Children.Add(message); this._mbsRoot.Children.Add(container); rootVisual.Children.Add(this._rootElement); // Add the required buttons. switch (button) { case MessageBoxServiceButton.OK: this.CreateOKButton( null == customLabels ? MessageBoxServiceStrings.OK : customLabels[0], 2); container.SetValue(Grid.ColumnSpanProperty, 1); break; case MessageBoxServiceButton.OKCancel: this._mbsRoot.ColumnDefinitions.Add( new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); this.CreateOKButton( null == customLabels ? MessageBoxServiceStrings.OK : customLabels[0]); this.CreateCancelButton( null == customLabels ? MessageBoxServiceStrings.Cancel : customLabels[1], 1); break; case MessageBoxServiceButton.YesNoCancel: this._mbsRoot.ColumnDefinitions.Add( new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); this._mbsRoot.ColumnDefinitions.Add( new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); background.SetValue(Grid.ColumnSpanProperty, 3); opaqueOverlay.SetValue(Grid.ColumnSpanProperty, 3); container.SetValue(Grid.ColumnSpanProperty, 3); this.CreateYesButton( null == customLabels ? MessageBoxServiceStrings.Yes : customLabels[0]); this.CreateNoButton( null == customLabels ? MessageBoxServiceStrings.No : customLabels[1], 3); this.CreateCancelButton( null == customLabels ? MessageBoxServiceStrings.Cancel : customLabels[2], 2); break; case MessageBoxServiceButton.YesNo: this._mbsRoot.ColumnDefinitions.Add( new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); this.CreateYesButton( null == customLabels ? MessageBoxServiceStrings.Yes : customLabels[0]); this.CreateNoButton( null == customLabels ? MessageBoxServiceStrings.No : customLabels[1]); break; default: // Not possible to hit this. break; } // Update and start the storyboard to show the message box. foreach (var timeline in this._showStoryboard.Children) { Storyboard.SetTarget(timeline, this._mbsRoot); } // Once the elements are ready, start the storyboard to show them. this._mbsRoot.InvokeOnLayoutUpdated(() => { this._showStoryboard.Begin(); }); } }
private void fachpicker_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (fachpicker.SelectedIndex == 0) { //frei Zimmernummer.IsEnabled = false; Lehrperson.IsEnabled = false; Lehrperson.Text = ""; Fach f = fachpicker.SelectedItem as Fach; try { Farbe.SelectedIndex = f.color; } catch { } if (fächeradded) { ContentPanel.Children.Remove(fächer); ContentPanel.Children.Remove(fächer2); fächeradded = false; } } else { Zimmernummer.IsEnabled = true; Lehrperson.IsEnabled = true; if (fachpicker.SelectedIndex == fachpicker.Items.Count - 1) { if (fächeradded) { } else { Zimmernummer.Text = ""; Lehrperson.Text = ""; //benutzerdefiniertes Fach fächer = new TextBlock() { Text = "Fach: ", FontSize = 34, Margin = new Thickness(7, 0, 0, 0) }; fächer.SetValue(Grid.RowProperty, 3); fächer2 = new TextBox(); fächer2.SetValue(Grid.RowProperty, 3); fächer2.SetValue(Grid.ColumnProperty, 1); ContentPanel.Children.Add(fächer); ContentPanel.Children.Add(fächer2); Lehrperson.Text = ""; fächeradded = true; } } else { Fach f = fachpicker.SelectedItem as Fach; Lehrperson.Text = f.Lehrer; Farbe.SelectedIndex = f.color; if (fächeradded) { ContentPanel.Children.Remove(fächer); ContentPanel.Children.Remove(fächer2); fächeradded = false; } } } }
// Calculated content height protected virtual void initialChildren() { double w = System.Windows.Application.Current.Host.Content.ActualWidth; topShadow = GetTemplateChild("TopShadow") as Rectangle; bottomShadow = GetTemplateChild("BottomShadow") as Rectangle; contentView = GetTemplateChild("ContentView") as Grid; buttonContainer = GetTemplateChild("ButtonContainer") as StackPanel; curtain = GetTemplateChild("Curtain") as Rectangle; // Add an optional title label titleLabel = null; if (title != null) { titleLabel = new TextBlock(); titleLabel.Text = title; titleLabel.Foreground = new SolidColorBrush(Color.FromArgb(0xff, 0x00, 0xd9, 0xf3)); titleLabel.FontSize = 42; titleLabel.HorizontalAlignment = HorizontalAlignment.Center; titleLabel.TextWrapping = TextWrapping.Wrap; titleLabel.TextAlignment = TextAlignment.Center; titleLabel.Margin = new Thickness(0, 8, 0, 8); titleLabel.SetValue(Grid.RowProperty, 0); contentView.Children.Add(titleLabel); } // Add any custom content if (contentElement != null) { contentElement.SetValue(Grid.RowProperty, 1); contentView.Children.Add(contentElement); contentView.InvalidateArrange(); contentView.UpdateLayout(); double measuredWidth = contentElement.ActualWidth + contentElement.Margin.Left + contentElement.Margin.Right; double measuredHeight = 0; if (titleLabel != null) { measuredHeight += titleLabel.ActualHeight; } double contentHeight = Math.Max(contentElement.ActualHeight, contentElement.Height); if(!double.IsNaN(contentHeight)) measuredHeight += contentHeight + contentElement.Margin.Top + contentElement.Margin.Bottom; else measuredHeight += 240 + contentElement.Margin.Top + contentElement.Margin.Bottom; expectedContentSize = new Size(measuredWidth, measuredHeight); } else { expectedContentSize = new Size(w, 240); } // Add custom buttons if (buttonTitles.Count > 0) { foreach (string buttonTitle in buttonTitles) { var button = new Avarice.Controls.Button(); button.Content = buttonTitle; button.Margin = new Thickness(20, 0, 20, 0); button.HorizontalAlignment = HorizontalAlignment.Right; buttonContainer.Children.Add(button); button.Click += OnButtonClick; } } else if(Buttons.Count > 0) { foreach (var button in Buttons) { button.Margin = new Thickness(20, 0, 20, 0); button.HorizontalAlignment = HorizontalAlignment.Right; buttonContainer.Children.Add(button); button.Click += OnButtonClick; } } }
private void initRdvOpti() { List<Meeting>tmp = new List<Meeting>(); RowDefinition tmpRow; tmp=myRoadM.OptimizedMeetingOrder; for (int i = 0; i < tmp.Count; i++) { if (i == 0) { tmpRow = new RowDefinition(); tmpRow.Height = GridLength.Auto; gr_InfoRDOpti.RowDefinitions.Add(tmpRow); flbI_InfoRdv = new FlecheBasInfo(); flbI_InfoRdv._EnabledAnimation = false; flbI_InfoRdv.SujetRdv = "Départ"; flbI_InfoRdv.AdrRdv = tmp[i].City; flbI_InfoRdv.InitInfo(); flbI_InfoRdv.Margin = new Thickness(1, 1, 1, 1); flbI_InfoRdv.SetValue(Grid.RowProperty, i); gr_InfoRDOpti.Children.Add(flbI_InfoRdv); continue; } if (tmp[i].Subject != "Départ" && tmp[i].Subject != "Arrivée") { tmpRow = new RowDefinition(); tmpRow.Height = GridLength.Auto; gr_InfoRDOpti.RowDefinitions.Add(tmpRow); flbI_InfoRdv._EnabledAnimation = false; flbI_InfoRdv = new FlecheBasInfo(); flbI_InfoRdv.SujetRdv = tmp[i].Subject + " (" + tmp[i].DateTime.TimeOfDay + ")"; flbI_InfoRdv.AdrRdv = tmp[i].Address; flbI_InfoRdv.InitInfo(); flbI_InfoRdv.SetValue(Grid.RowProperty, i); flbI_InfoRdv.Margin = new Thickness(1, 5, 1, 5); gr_InfoRDOpti.Children.Add(flbI_InfoRdv); } if (i == tmp.Count - 1) { var monTxt = new TextBlock(); tmpRow = new RowDefinition(); tmpRow.Height = GridLength.Auto; gr_InfoRDOpti.RowDefinitions.Add(tmpRow); monTxt.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; monTxt.SetValue(Grid.RowProperty, i+1); monTxt.Text = "Arrivée"; monTxt.FontSize = 35; System.Windows.Shapes.Rectangle monRect = new System.Windows.Shapes.Rectangle(); monRect.Height = 45; monRect.Width =340; monRect.SetValue(Grid.RowProperty, i+1); monRect.SetValue(System.Windows.Shapes.Rectangle.FillProperty, App.Current.Resources["PhoneAccentBrush"]); gr_InfoRDOpti.Children.Add(monRect); gr_InfoRDOpti.Children.Add(monTxt); monTxt = new TextBlock(); tmpRow = new RowDefinition(); tmpRow.Height = GridLength.Auto; gr_InfoRDOpti.RowDefinitions.Add(tmpRow); tmpRow = new RowDefinition(); tmpRow.Height = GridLength.Auto; gr_InfoRDOpti.RowDefinitions.Add(tmpRow); monTxt.SetValue(Grid.RowProperty, i+2); monTxt.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; monTxt.Text = tmp[i].City; monTxt.FontSize = 20; gr_InfoRDOpti.Children.Add(monTxt); } } }
private void InitGrid() { Trip monTrip; RowDefinition tmpRow; double tpsTot=0; if (m != null) { for (int i = 0; i < m.Count; i++) { monTrip =myRoadM.Trips.Where(o => o.Start.Equals(m[i])).FirstOrDefault(); if (monTrip != null && !m[i].IsLocationFail) { if (i == 0) { tmpRow = new RowDefinition(); tmpRow.Height = GridLength.Auto; gr_InfoRD.RowDefinitions.Add(tmpRow); flbI_InfoRdv = new FlecheBasInfo(); flbI_InfoRdv.SujetRdv = "Départ"; flbI_InfoRdv.AdrRdv = m[i].City; flbI_InfoRdv.Distance = monTrip.Distance + " km"; flbI_InfoRdv.TpsTrajet = monTrip.Duration + " min"; tpsTot = tpsTot + monTrip.Duration; flbI_InfoRdv.ConSomation = Math.Round(((monTrip.Distance * (double)settings["ConsoCarburant"]) / 100), 2) + " L"; flbI_InfoRdv.Cout =Math.Round((((monTrip.Distance * (double)settings["ConsoCarburant"]) / 100) * (double)settings["PrixCarburant"]),2) + " €"; flbI_InfoRdv.IsTripFail1 = monTrip.IsTripFail; flbI_InfoRdv.InitInfo(); //flbI_InfoRdv.Margin = new Thickness(1, 1, 1, 1); flbI_InfoRdv.SetValue(Grid.RowProperty, i); flbI_InfoRdv.Margin = new Thickness(1, 5, 1, 5); gr_InfoRD.Children.Add(flbI_InfoRdv); continue; } tmpRow = new RowDefinition(); tmpRow.Height = GridLength.Auto; gr_InfoRD.RowDefinitions.Add(tmpRow); flbI_InfoRdv = new FlecheBasInfo(); flbI_InfoRdv.SujetRdv = m[i].Subject+" ("+m[i].DateTime.ToShortTimeString()+")"; flbI_InfoRdv.AdrRdv = m[i].Address; flbI_InfoRdv.Distance = monTrip.Distance + " km"; flbI_InfoRdv.TpsTrajet = monTrip.Duration + " min"; tpsTot = tpsTot + monTrip.Duration; flbI_InfoRdv.IsTripFail1 = monTrip.IsTripFail; flbI_InfoRdv.ConSomation = Math.Round(((monTrip.Distance * (double)settings["ConsoCarburant"])/100),2) + " L"; flbI_InfoRdv.Cout = Math.Round((((monTrip.Distance * (double)settings["ConsoCarburant"]) / 100) * (double)settings["PrixCarburant"]), 2) + " €"; flbI_InfoRdv.InitInfo(); flbI_InfoRdv.SetValue(Grid.RowProperty, i); flbI_InfoRdv.Margin = new Thickness(1, 5, 1, 5); gr_InfoRD.Children.Add(flbI_InfoRdv); } if (i == m.Count - 1) { var monTxt = new TextBlock(); tmpRow = new RowDefinition(); tmpRow.Height = GridLength.Auto; gr_InfoRD.RowDefinitions.Add(tmpRow); monTxt.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; monTxt.SetValue(Grid.RowProperty, i); monTxt.Text = "Arrivée"; System.Windows.Shapes.Rectangle monRect = new System.Windows.Shapes.Rectangle(); monRect.Height = 45; monRect.Width = 340; monRect.SetValue(Grid.RowProperty, i); monRect.SetValue(System.Windows.Shapes.Rectangle.FillProperty, App.Current.Resources["PhoneAccentBrush"]); gr_InfoRD.Children.Add(monRect); gr_InfoRD.Children.Add(monTxt); monTxt = new TextBlock(); tmpRow = new RowDefinition(); tmpRow.Height = GridLength.Auto; gr_InfoRD.RowDefinitions.Add(tmpRow); monTxt.SetValue(Grid.RowProperty, i+2); monTxt.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; monTxt.Text = m[i].City; monTxt.FontSize = 18.75; monTxt.FontFamily = new System.Windows.Media.FontFamily("Segoe UI Light"); gr_InfoRD.Children.Add(monTxt); } } rt_ConsoTrajet.tb_info2.Text = Math.Round(((myRoadM.Distance * (double)settings["ConsoCarburant"]) / 100), 2) + " L"; ; rt_CoutTot.tb_info2.Text = Math.Round((((myRoadM.Distance * (double)settings["ConsoCarburant"]) / 100) * (double)settings["PrixCarburant"]), 2) + " €"; ; rt_DistRdv.tb_info2.Text = myRoadM.Distance+"km"; rt_nbrRdv.tb_info2.Text = myRoadM.Meetings.Count-2+""; rt_TpsTrajetRdv.tb_info2.Text =tpsTot+" min"; } initRdvOpti(); indicator.IsIndeterminate = false; indicator.IsVisible = false; }
private void InitPopup() { popup = new Popup(); popup.Opened += popup_Opened; Binding backgroundBinding = new Binding("Background"); backgroundBinding.Source = this; Binding foregroundBinding = new Binding("Foreground"); foregroundBinding.Source = this; Grid border = new Grid(); border.Background = new SolidColorBrush(Color.FromArgb(200, 0, 0, 0)); border.Width = Application.Current.Host.Content.ActualWidth; border.Height = Application.Current.Host.Content.ActualHeight; Grid container = new Grid(); CompositeTransform transform = new CompositeTransform() { TranslateY = -Application.Current.Host.Content.ActualHeight }; container.RenderTransform = transform; container.VerticalAlignment = System.Windows.VerticalAlignment.Top; container.SetBinding(Grid.BackgroundProperty, backgroundBinding); #region init grid rows RowDefinition row1 = new RowDefinition() { Height = GridLength.Auto }; container.RowDefinitions.Add(row1); RowDefinition row2 = new RowDefinition() { Height = GridLength.Auto }; container.RowDefinitions.Add(row2); RowDefinition row3 = new RowDefinition() { Height = GridLength.Auto }; container.RowDefinitions.Add(row3); #endregion TextBlock title = new TextBlock() { Margin = new Thickness(12), FontSize = 30, FontWeight = FontWeights.Black }; Binding titleBinding = new Binding("Title"); titleBinding.Source = this; title.SetBinding(TextBlock.TextProperty, titleBinding); title.SetBinding(TextBlock.ForegroundProperty, foregroundBinding); container.Children.Add(title); TextBlock content = new TextBlock() { Margin = new Thickness(12), FontSize = 26, FontWeight = FontWeights.Medium }; Binding contentBinding = new Binding("Content"); contentBinding.Source = this; content.SetBinding(TextBlock.TextProperty, contentBinding); content.SetBinding(TextBlock.ForegroundProperty, foregroundBinding); content.SetValue(Grid.RowProperty, 1); container.Children.Add(content); switch (MessageBoxButtons) { case MessageBoxButton.OK: { Button btn = new Button() { Content = "OK", Margin = new Thickness(0, 0, 0, 10) }; btn.Click += (s, args) => { var handler = OKClick; if (null != handler) { handler(this, new RoutedEventArgs()); } GetCloseAnimation(); }; btn.SetValue(Grid.RowProperty, 2); container.Children.Add(btn); } break; case MessageBoxButton.OKCancel: { Grid btnGrid = new Grid(); btnGrid.Margin = new Thickness(0, 0, 0, 10); btnGrid.SetValue(Grid.RowProperty, 2); ColumnDefinition column1 = new ColumnDefinition(); ColumnDefinition column2 = new ColumnDefinition(); btnGrid.ColumnDefinitions.Add(column1); btnGrid.ColumnDefinitions.Add(column2); Button btnOK = new Button() { Content = "OK" }; btnOK.Click += (s, args) => { var handler = OKClick; if (null != handler) { handler(this, new RoutedEventArgs()); } GetCloseAnimation(); }; btnGrid.Children.Add(btnOK); Button btnCancel = new Button() { Content = "Cancel" }; btnCancel.Click += (s, args) => { var handler = CancelClick; if (null != handler) { handler(this, new RoutedEventArgs()); } GetCloseAnimation(); }; btnCancel.SetValue(Grid.ColumnProperty, 1); btnGrid.Children.Add(btnCancel); container.Children.Add(btnGrid); } break; } border.Children.Add(container); popup.Child = border; }
/// <summary> /// Meat and potatoes, draw the graph /// </summary> private void CreateGraph() { if (graphData == null || rootElement == null) { return; } // Determine which of the graphData sets we should use for this creation // IE, what quality of detail we need (less during manipulation by user) double scaleX = graphWidth / (maxX == minX ? 1 : maxX - minX); double zoom = scaleX == 0 ? 1 : scale.ScaleX / scaleX; int targetPoints = (int)(MaxNumPoints * zoom); int graphIndex = graphData.Length - 1; // Determine which graph to draw from. targetPoints is our estimate for the target number of points in the graph // we want to select. It unfairly assumes the distribution of points is pretty regular (which was true for me when // I created this custom control, but may not be for you) while (graphIndex > 0 && graphData[graphIndex].Count < targetPoints) { graphIndex--; } List<Point> dataPoints = new List<Point>(); List<PointF> targetGraph = graphData[graphIndex]; graphArea.Children.Clear(); // Compute boundaries of the data to graph minWorldX = ScreenToWorldX(0); maxWorldX = ScreenToWorldX(graphWidth); int startIndex = FindNearestPoint(minWorldX, graphIndex); int endIndex = Math.Min(FindNearestPoint(maxWorldX, graphIndex) + 1, targetGraph.Count - 1); // Only one point to draw, no graph here, I suppose we could draw the single point... if (endIndex == startIndex) { return; } // First point may be drawn off screen, if so, do some simple math to add an intermediate point at x = 0 Point point1 = WorldToScreenOptimized(targetGraph[startIndex].X, targetGraph[startIndex].Y); if (point1.X < 0) { Point point2 = WorldToScreenOptimized(targetGraph[startIndex + 1].X, targetGraph[startIndex + 1].Y); double slope = (point2.Y - point1.Y) / (point2.X - point1.X); point1.Y -= slope * point1.X; point1.X = 0; } dataPoints.Add(point1); // Also add all of the interior points for (int i = startIndex + 1; i < endIndex; i ++) { dataPoints.Add(WorldToScreenOptimized(targetGraph[i].X, targetGraph[i].Y)); } // Add the last point and check to see if it is off the screen, if so, again do some scaling // to put the last point on the line that connects to it on the graph. dataPoints.Add(WorldToScreenOptimized(targetGraph[endIndex].X, targetGraph[endIndex].Y)); int numPoints = dataPoints.Count; Point prevPoint = dataPoints[numPoints - 2]; Point endPoint = dataPoints[numPoints - 1]; if (endPoint.X > graphWidth) { dataPoints.RemoveAt(numPoints - 1); double slope = (endPoint.Y - prevPoint.Y) / (endPoint.X - prevPoint.X); endPoint.Y = prevPoint.Y + slope * (graphWidth - prevPoint.X); endPoint.X = graphWidth; dataPoints.Add(endPoint); } // Create the polygon that will be our graph if we are drawing a fill graph if (!lineGraph) { graphPoly = new Polygon() { Stroke = (SolidColorBrush)App.Current.Resources["PhoneBorderBrush"], Fill = this.fillBrush, StrokeThickness = 0 }; } // Draw the actual graph data - the lines for the line graph or add the points to plot the fill graph Point lastPoint = dataPoints[0]; SolidColorBrush accentBrush = new SolidColorBrush(AccentColor); for (int i = 0; i < numPoints - 1; i++) { Point currPoint = dataPoints[i + 1]; #if DEBUG // A data point outside the bounds of the graph area at this point indicates an // error in assumptions I made about the data for optimizations. This would be // a poor user experience. if ((int)lastPoint.X > graphWidth || (int)currPoint.X > graphWidth || (int)lastPoint.X < 0 || (int)currPoint.X < 0 || (int)lastPoint.Y < 0 || (int)currPoint.Y < 0 || (int)lastPoint.Y > graphHeight || (int)currPoint.Y > graphHeight) { throw new Exception("Graph tried to add a point outside of graph bounds."); } #endif // Create a line for a line graph if (lineGraph) { if (lastPoint.X != currPoint.X) { Line line = new Line() { Stroke = accentBrush, StrokeThickness = 3, X1 = lastPoint.X, X2 = currPoint.X }; line.Y1 = lastPoint.Y; line.Y2 = currPoint.Y; graphArea.Children.Add(line); } } else { if (graphPoly.Points.Count == 0) { graphPoly.Points.Add(new Point(0, graphHeight)); graphPoly.Points.Add(lastPoint); } graphPoly.Points.Add(currPoint); } lastPoint = currPoint; } if (!lineGraph) { graphPoly.Points.Add(new Point(graphWidth, graphHeight)); graphArea.Children.Add(graphPoly); } double fontSize = (double)this.Resources["PhoneFontSizeSmall"]; ; SolidColorBrush contrastBgBrush = (SolidColorBrush)this.Resources["PhoneContrastBackgroundBrush"]; // Draw the labels on left side bar to show the y scale of the graph GenerateLeftBorder(); if (horizontalGrid != null) { int len = horizontalGrid.Count; for (int i = 0; i < len; i++) { graphArea.Children.Add(horizontalGrid[i]); } } // Only need to recompute the X-Axis labels if the x axis changed by translating or scaling if (scale.CenterX != lastScale.CenterX || scale.ScaleX != lastScale.ScaleX) { bottomBorder.Children.Clear(); // Draw the labels on bottom bar to show the x scale of the graph if (!computedSpacePerGridLine) { // Step through a few dozen points determining the average and standard deviation of the width // required to draw their X-Axis label const int targetNumCompute = 40; int numCompute = GraphData.Count <= targetNumCompute ? GraphData.Count : targetNumCompute; if (numCompute > 0) { double stdDev = 0; double totalWidth = 0; double avg = 0; double[] widths = new double[numCompute]; int step = GraphData.Count / numCompute; for (int i = 0; i < numCompute; i++) { TextBlock xKey1 = new TextBlock() { FontSize = fontSize, Text = GraphData[0].GetXText(GraphData[i * step].GetX()) }; widths[i] = xKey1.ActualWidth; totalWidth += widths[i]; } avg = totalWidth / numCompute; if (numCompute > 1) { for (int i = 0; i < numCompute; i++) { stdDev += Math.Pow(widths[i] - avg, 2); } stdDev = Math.Sqrt(stdDev / (numCompute - 1)); spacePerGridLine = (int)(Math.Ceiling(avg + stdDev * 4) + 12); } else { spacePerGridLine = (int)(Math.Ceiling(avg * .65) + 12); } computedSpacePerGridLine = true; } } // Good - we have computed the avg and deviation of the space required to draw a label on the // x-axis, now lets add some labels and grid lines! double screenX = spacePerGridLine; double endLastX = 0; while (true) { double x = ScreenToWorldX(screenX); TextBlock xKey = new TextBlock() { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Top, FontSize = fontSize, Text = GraphData[0].GetXText(x) }; double actualWidth = xKey.ActualWidth; xKey.SetValue(Canvas.LeftProperty, screenX - (actualWidth / 2)); xKey.SetValue(Canvas.TopProperty, 2.0); double endX = screenX + actualWidth / 2; if (endX >= graphWidth) { // No space left in the bottom grid area for another label break; } if (endX - actualWidth >= endLastX + 10) { endLastX = endX; bottomBorder.Children.Add(xKey); } screenX += spacePerGridLine; } } // We computed the X-Axis labels which are TextBlocks that live inside "bottomBorder", now draw the corresponding grid lines for the labels int lastBottomIndex = bottomBorder.Children.Count; for (int i = 0; i < lastBottomIndex; i++) { UIElement elem = bottomBorder.Children[i]; double screenX = (double)elem.GetValue(Canvas.LeftProperty) + (double)elem.GetValue(TextBlock.ActualWidthProperty) / 2; Line line = new Line() { X1 = screenX, X2 = screenX, Y1 = 0, Y2 = graphHeight, Stroke = contrastBgBrush, StrokeThickness = 1 }; graphArea.Children.Add(line); } // Draw the highlighted point if there is one DrawHighlightedPoint(); lastScale.ScaleX = scale.ScaleX; lastScale.CenterX = scale.CenterX; }
/// <summary> /// Generate the Y-Axis border of the graph. This can be done once for the graph since the Y-Axis does not scale or transform in this version. /// </summary> private void GenerateLeftBorder() { // The Y-Axis stays constant, so we only need to generate the y-grid a single time and save it to the 'horizontalGrid' List if (GraphData != null && horizontalGrid == null && !double.IsNaN(graphWidth)) { //rootElement.ColumnDefinitions[0].SetValue(ColumnDefinition.WidthProperty, new GridLength(0.0)); const int spacePerElem = 40; double maxWidth = 0; int numElems = (int)graphHeight / spacePerElem; double startY = (graphHeight - numElems * spacePerElem) / 2 + spacePerElem / 2; double colWidth = rootElement.ColumnDefinitions[0].Width.Value; double rowHeight = rootElement.RowDefinitions[0].Height.Value; double fontSize = (double)this.Resources["PhoneFontSizeSmall"]; horizontalGrid = new Collection<UIElement>(); // Two Passes; // Pass 0: Determine the maximum width required to draw the y-axis scale // Pass 1: Actually draw the Y Scale for (int pass = 0; pass < 2; pass++) { for (int i = 0; i < numElems; i++) { double screenY = startY + i * spacePerElem; double worldY = ((graphHeight - screenY) / graphHeight) * (maxY - minY) + minY; TextBlock yKey = new TextBlock() { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Top, FontSize = fontSize, Text = GraphData[0].GetYText(worldY) }; maxWidth = Math.Max(maxWidth, yKey.ActualWidth); // Do the actual drawing if (pass == 1) { yKey.SetValue(Canvas.LeftProperty, colWidth - yKey.ActualWidth - 2); yKey.SetValue(Canvas.TopProperty, rowHeight - yKey.ActualHeight / 2 + screenY); leftBorder.Children.Add(yKey); Line line = new Line() { Y1 = screenY, Y2 = screenY, X1 = 0, X2 = graphWidth, Stroke = (SolidColorBrush)this.Resources["PhoneContrastBackgroundBrush"], StrokeThickness = 1 }; graphArea.Children.Add(line); horizontalGrid.Add(line); } } // Resize elements inside the graph to hold the y-scale if (pass == 0) { rootElement.ColumnDefinitions[0].SetValue(ColumnDefinition.WidthProperty, new GridLength(maxWidth + 10.0)); colWidth = rootElement.ColumnDefinitions[0].Width.Value; graphWidth = Width - colWidth - 2; } } } }
private void RenderViewItem(Item item) { // get the item type ItemType itemType = null; if (ItemType.ItemTypes.TryGetValue(item.ItemTypeID, out itemType) == false) return; // create a list of all the first subitems in each of the sublists of the item (e.g. Contacts, Places, etc) var subLists = App.ViewModel.Items.Where(i => i.ParentID == item.ID && i.IsList == true).ToList(); var subItems = new List<Item>(); foreach (var subList in subLists) { var itemRef = App.ViewModel.Items.FirstOrDefault(i => i.ParentID == subList.ID && i.ItemTypeID == SystemItemTypes.Reference); if (itemRef != null) { var target = App.ViewModel.Items.FirstOrDefault(i => i.ID == itemRef.ItemRef); if (target != null) subItems.Add(target); } } // render fields int row = 0; foreach (ActionType action in App.ViewModel.Constants.ActionTypes.OrderBy(a => a.SortOrder)) { FieldValue fieldValue = item.FieldValues.FirstOrDefault(fv => fv.FieldName == action.FieldName); if (fieldValue == null) { bool found = false; foreach (var i in subItems) { fieldValue = i.FieldValues.FirstOrDefault(fv => fv.FieldName == action.FieldName); if (fieldValue != null) { found = true; break; } } // if fieldvalue isn't found on this item or other subitems, don't process the action if (found == false) continue; } // get the value of the property string currentValue = fieldValue.Value; // for our purposes, an empty value is the same as null if (currentValue == "") currentValue = null; // render this property if it's not null/empty if (currentValue != null) { // first make sure that we do want to render (type-specific logic goes here) switch (action.ActionName) { case "Postpone": // if the date is already further in the future than today, omit adding this action if (Convert.ToDateTime(currentValue).Date > DateTime.Today.Date) continue; break; } // add a new row ViewGrid.RowDefinitions.Add(new RowDefinition() { MaxHeight = 72 }); Thickness margin = new Thickness(12, 20, 0, 0); // bounding rectangle of padding // create a new buton for the action (verb) var button = new Button() { Content = action.DisplayName, MinWidth = 200 }; button.SetValue(Grid.ColumnProperty, 0); button.SetValue(Grid.RowProperty, row); ViewGrid.Children.Add(button); // create a label which holds the noun the verb will act upon // usually extracted from the item field's contents var valueTextBlock = new TextBlock() { DataContext = fieldValue, Style = (Style)App.Current.Resources["PhoneTextNormalStyle"], Margin = margin, }; //value.SetBinding(TextBlock.TextProperty, new Binding(pi.Name)); valueTextBlock.SetValue(Grid.ColumnProperty, 1); valueTextBlock.SetValue(Grid.RowProperty, row++); ViewGrid.Children.Add(valueTextBlock); // render the action based on the action type switch (action.ActionName) { case ActionNames.Navigate: try { Item targetList = App.ViewModel.Items.Single(i => i.ID == Guid.Parse(currentValue)); //valueTextBlock.Text = String.Format("to {0}", targetList.Name); button.Click += new RoutedEventHandler(delegate { // trace page navigation TraceHelper.StartMessage("Item: Navigate to List"); // Navigate to the new page NavigationService.Navigate( new Uri(String.Format("/ListPage.xaml?type=Folder&ID={0}&ParentID={1}", targetList.FolderID, targetList.ID), UriKind.Relative)); }); } catch (Exception) { valueTextBlock.Text = "(list not found)"; } break; case ActionNames.Postpone: valueTextBlock.Text = "to tomorrow"; button.Click += new RoutedEventHandler(delegate { item.DueDate = DateTime.Today.Date.AddDays(1.0).ToString("yyyy-MM-dd"); folder.NotifyPropertyChanged("FirstDue"); folder.NotifyPropertyChanged("FirstDueColor"); }); break; case ActionNames.AddToCalendar: valueTextBlock.DataContext = item; valueTextBlock.SetBinding(TextBlock.TextProperty, new Binding("DueDisplay")); button.Click += new RoutedEventHandler(delegate { folder.NotifyPropertyChanged("FirstDue"); folder.NotifyPropertyChanged("FirstDueColor"); }); break; case ActionNames.Map: valueTextBlock.SetBinding(TextBlock.TextProperty, new Binding("Value")); button.Click += new RoutedEventHandler(delegate { #if WINPHONE7 // Pre-MANGO string mapUrl = "maps:"; bool space = false; foreach (string part in valueString.Split(' ')) { if (space == true) mapUrl += "%20"; mapUrl += part; space = true; } WebBrowserItem mapItem = new WebBrowserItem() { Uri = new Uri(mapUrl) }; #else // MANGO BingMapsTask mapItem = new BingMapsTask() { SearchTerm = currentValue }; #endif mapItem.Show(); }); break; case ActionNames.Call: valueTextBlock.SetBinding(TextBlock.TextProperty, new Binding("Value")); button.Click += new RoutedEventHandler(delegate { PhoneCallTask phoneCallTask = new PhoneCallTask() { PhoneNumber = (string)currentValue }; phoneCallTask.Show(); }); break; case ActionNames.TextMessage: valueTextBlock.SetBinding(TextBlock.TextProperty, new Binding("Value")); button.Click += new RoutedEventHandler(delegate { SmsComposeTask smsTask = new SmsComposeTask() { To = (string)currentValue }; smsTask.Show(); }); break; case ActionNames.Browse: valueTextBlock.SetBinding(TextBlock.TextProperty, new Binding("Value")); button.Click += new RoutedEventHandler(delegate { string url = (string)currentValue; if (url.Substring(1, 4) != "http") url = String.Format("http://{0}", url); WebBrowserTask browserTask = new WebBrowserTask() { Uri = new Uri(url) }; browserTask.Show(); }); break; case ActionNames.SendEmail: valueTextBlock.SetBinding(TextBlock.TextProperty, new Binding("Value")); button.Click += new RoutedEventHandler(delegate { EmailComposeTask emailItem = new EmailComposeTask() { To = (string)currentValue }; emailItem.Show(); }); break; } } } }
private TextBlock CreateNewTextBlock() { var oTextBlock = new TextBlock(); oTextBlock.Name = ("m_oPriceTextBlock" + m_iItemNumber); oTextBlock.TextWrapping = TextWrapping.NoWrap; if (App.InventoryVM.SelectedProduct != null) { var oTempText = App.InventoryVM.SelectedProduct.Name.ToString(); var oType = oTextBlock.Text.GetType(); var oResult = new StringTrimConverter().Convert(oTempText, oType, null, new CultureInfo("en-US")) as string; oTextBlock.Text = oResult; } else { oTextBlock.Text = "Item"; } oTextBlock.Style = Application.Current.Resources["CalcLabelStyle"] as Style; oTextBlock.FontWeight = FontWeights.ExtraBold; oTextBlock.SetValue(Grid.RowProperty, m_iItemCount); return oTextBlock; }
private void displayEventList(List<Event> events, bool noStartHour, bool noEndhour) { // if the event last all day, only 1 iteration int _maxHour = (noStartHour && noEndhour) ? 1 : 24; // display the events that starts and ends at the selected date for (int i = 0; i < _maxHour; i++) { foreach (Event e in events) { int _startHour = noStartHour ? 0 :Int32.Parse(e.Start.DateTime.Substring(11, 2)); int _endHour = noEndhour ? 0 : Int32.Parse(e.End.DateTime.Substring(11, 2)); if (_startHour == i) { // filling the tab of the day cal with the current event int k = 0; while (eventTabFill[i, k] != false) { k++; } int _nbHour = _endHour == 00 ? 24 - _startHour : _endHour - _startHour; for (int j = 0; j < _nbHour; j++) { eventTabFill[i + j, k] = true; } // getting R G B from the colorID of the event string _eventColor = calendar.getEventColorById(e.ColorId != null ? e.ColorId : "1").Background; int _red = Int32.Parse(_eventColor.Substring(1, 2), NumberStyles.AllowHexSpecifier); int _green = Int32.Parse(_eventColor.Substring(3, 2), NumberStyles.AllowHexSpecifier); int _blue = Int32.Parse(_eventColor.Substring(5, 2), NumberStyles.AllowHexSpecifier); // creating a rectangle colored with the event's color if (_nbHour > 12) { Rectangle _rect = new Rectangle(); _rect.Height = 12 * 100; _rect.Width = 10; _rect.SetValue(Rectangle.FillProperty, new SolidColorBrush(Color.FromArgb((BitConverter.GetBytes(255))[0], (BitConverter.GetBytes(_red))[0], (BitConverter.GetBytes(_green))[0], (BitConverter.GetBytes(_blue))[0]))); _rect.Visibility = Visibility.Visible; _rect.Margin = new Thickness((k * eventWidth), i * 100, 0, 0); _rect.VerticalAlignment = VerticalAlignment.Top; _rect.HorizontalAlignment = HorizontalAlignment.Left; Rectangle _rect2 = new Rectangle(); _rect2.Height = (_nbHour - 12) * 100; _rect2.Width = 10; _rect2.SetValue(Rectangle.FillProperty, new SolidColorBrush(Color.FromArgb((BitConverter.GetBytes(255))[0], (BitConverter.GetBytes(_red))[0], (BitConverter.GetBytes(_green))[0], (BitConverter.GetBytes(_blue))[0]))); _rect2.Visibility = Visibility.Visible; _rect2.Margin = new Thickness((k * eventWidth), i * 100 + 1200, 0, 0); _rect2.VerticalAlignment = VerticalAlignment.Top; _rect2.HorizontalAlignment = HorizontalAlignment.Left; Events.Children.Add(_rect); Events.Children.Add(_rect2); } else { Rectangle _rect = new Rectangle(); _rect.Height = _nbHour == 0 ? 30 : _nbHour * 100; _rect.Width = 10; _rect.SetValue(Rectangle.FillProperty, new SolidColorBrush(Color.FromArgb((BitConverter.GetBytes(255))[0], (BitConverter.GetBytes(_red))[0], (BitConverter.GetBytes(_green))[0], (BitConverter.GetBytes(_blue))[0]))); _rect.Visibility = Visibility.Visible; _rect.Margin = new Thickness((k * eventWidth), i * 100, 0, 0); _rect.VerticalAlignment = VerticalAlignment.Top; _rect.HorizontalAlignment = HorizontalAlignment.Left; Events.Children.Add(_rect); } // creating the textblock for the title of the event (clickable) colored with the event's color TextBlock _title = new TextBlock(); _title.DataContext = e; _title.SetBinding(TextBlock.TextProperty, new Binding("Summary")); _title.SetValue(TextBlock.ForegroundProperty, new SolidColorBrush(Color.FromArgb((BitConverter.GetBytes(255))[0], (BitConverter.GetBytes(_red))[0], (BitConverter.GetBytes(_green))[0], (BitConverter.GetBytes(_blue))[0]))); _title.Height = 30; _title.Width = eventWidth - 10; _title.Margin = new Thickness((k * eventWidth) + 13, i * 100 + 3, 3, 3); _title.VerticalAlignment = VerticalAlignment.Top; _title.HorizontalAlignment = HorizontalAlignment.Left; _title.TextWrapping = TextWrapping.Wrap; _title.MouseLeftButtonDown += new MouseButtonEventHandler(title_MouseLeftButtonDown); // creating the textblock for the description of the event TextBlock _desc = new TextBlock(); _desc.DataContext = e; _desc.SetBinding(TextBlock.TextProperty, new Binding("Description")); _desc.Height = _nbHour == 0 ? 30 : 70 + ((_nbHour - 1) * 100); _desc.Width = eventWidth - 10; _desc.Margin = new Thickness((k * eventWidth) + 13, (i * 100) + 33, 3, 3); _desc.VerticalAlignment = VerticalAlignment.Top; _desc.HorizontalAlignment = HorizontalAlignment.Left; _desc.TextWrapping = TextWrapping.Wrap; Events.Children.Add(_title); Events.Children.Add(_desc); } } } }
public static void NOPH_Graphics_drawTextAngle(int c_graphics, int c_text, int x, int y, int flags, int angle) { // mre.Reset(); int copy_graphics, copy_c_text, copy_x, copy_y, copy_flags, copy_angle; copy_graphics = c_graphics; copy_c_text = c_text; copy_x = x; copy_y = y; copy_flags = flags; copy_angle = angle; Color curr_pen = curr_color; int font_size = currFontSize; //todomt2 - what about flags? String text = CRunTime.charPtrToString(copy_c_text); System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => { Canvas graphics = (Canvas)CRunTime.getRegisteredObject(copy_graphics); if (copy_angle == 0) { TextBlock tb = new TextBlock(); tb.FontFamily = new FontFamily("FreeSans"); tb.FontSize = font_size; tb.FontStyle = FontStyles.Normal; tb.Foreground = new SolidColorBrush(curr_pen); tb.Text = NBidi.NBidi.LogicalToVisual(text); tb.SetValue(Canvas.LeftProperty, (double)(copy_x));// - (tb.ActualWidth / 2))); tb.SetValue(Canvas.TopProperty, (double)(copy_y - tb.ActualHeight + 5 )); children_list.Add(tb); } else { TextBlock tb = new TextBlock(); tb.FontFamily = new FontFamily("FreeSans"); tb.FontSize = font_size; tb.FontStyle = FontStyles.Normal; tb.Foreground = new SolidColorBrush(curr_pen); tb.SetValue(Canvas.LeftProperty, (double)(copy_x));// - (tb.ActualWidth / 2))); tb.SetValue(Canvas.TopProperty, (double)(copy_y - tb.ActualHeight - 20.0)); tb.Text = NBidi.NBidi.LogicalToVisual(text); RotateTransform rt = new RotateTransform(); rt.Angle = copy_angle; tb.RenderTransform = rt; children_list.Add(tb); } //mre.Set(); }); //mre.WaitOne(); }
protected Grid CreatePostButton(String image, String text, Object context, RoutedEventHandler onClick) { int buttonSize = 72; ImageBrush buttonImageBrush = new ImageBrush() { ImageSource = new BitmapImage(new Uri("/MitbbsReader;component/Images/" + image, UriKind.Relative)), Stretch = Stretch.None }; Button button = new Button() { Style = (Style)Application.Current.Resources["ImageButton"], Content = buttonImageBrush, Padding = new Thickness(0), BorderThickness = new Thickness(0), Margin = new Thickness(0), Width = buttonSize, Height = buttonSize, DataContext = context }; button.Click += (s, e) => { HideButtonPanel(); onClick(s, e); }; GestureListener gl2 = GestureService.GetGestureListener(button); gl2.Tap += new EventHandler<Microsoft.Phone.Controls.GestureEventArgs>(GeneralButton_Tapped); TextBlock buttonText = new TextBlock() { Text = text }; buttonText.SetValue(TiltEffect.IsTiltEnabledProperty, true); buttonText.VerticalAlignment = System.Windows.VerticalAlignment.Center; buttonText.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; buttonText.DataContext = context; buttonText.Tap += (s, e) => { HideButtonPanel(); onClick(button, e); }; Grid buttonRow = new Grid(); buttonRow.ColumnDefinitions.Add( new ColumnDefinition() { Width = new GridLength(buttonSize, GridUnitType.Pixel), } ); buttonRow.ColumnDefinitions.Add( new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star), } ); button.SetValue(Grid.ColumnProperty, 0); buttonRow.Children.Add(button); buttonText.SetValue(Grid.ColumnProperty, 1); buttonRow.Children.Add(buttonText); return buttonRow; }
/// <summary> /// Draw an empty graph with "No data to display" text /// </summary> private void ClearGraph() { leftBorder.Children.Clear(); bottomBorder.Children.Clear(); graphArea.Children.Clear(); TextBlock noData = new TextBlock() { Text = "No data to display" }; double width = noData.ActualWidth; double height = noData.ActualHeight; if (width < graphWidth && height < graphHeight) { noData.SetValue(Canvas.LeftProperty, (double)(graphWidth / 2 - width / 2) - rootElement.ColumnDefinitions[0].Width.Value / 2); noData.SetValue(Canvas.TopProperty, (double)(graphHeight / 2 - height / 2) + rootElement.RowDefinitions[2].Height.Value / 2); graphArea.Children.Add(noData); } }
private void RenderViewTask(Task task) { int row = 0; // render fields foreach (TaskStoreClientEntities.Action action in App.ViewModel.Constants.Actions.OrderBy(a => a.SortOrder)) { PropertyInfo pi; // make sure the property exists on the local type try { pi = task.GetType().GetProperty(action.FieldName); if (pi == null) continue; // see comment below } catch (Exception) { // we can't do anything with this property since we don't have it on the local type // this indicates that the phone software isn't caught up with the service version // but that's ok - we can keep going continue; } // get the value of the property var val = pi.GetValue(task, null); // for our purposes, an empty value is the same as null if (val != null && val.GetType() == typeof(String)) if ((string)val == "") val = null; // render this property if it's not null/empty if (val != null) { // first make sure that we do want to render (type-specific logic goes here) switch (action.ActionType) { case "Postpone": // if the date is already further in the future than today, omit adding this action if (((DateTime)val).Date > DateTime.Today.Date) continue; break; } // add a new row ViewGrid.RowDefinitions.Add(new RowDefinition() { MaxHeight = 72 }); string valueString = val.ToString(); Thickness margin = new Thickness(12, 20, 0, 0); // bounding rectangle of padding // create a new buton for the action (verb) var button = new Button() { Content = action.DisplayName, MinWidth = 200 }; button.SetValue(Grid.ColumnProperty, 0); button.SetValue(Grid.RowProperty, row); ViewGrid.Children.Add(button); // create a label which holds the noun the verb will act upon // usually extracted from the task field's contents var valueTextBlock = new TextBlock() { DataContext = task, Style = (Style)App.Current.Resources["PhoneTextNormalStyle"], Margin = margin, }; //value.SetBinding(TextBlock.TextProperty, new Binding(pi.Name)); valueTextBlock.SetValue(Grid.ColumnProperty, 1); valueTextBlock.SetValue(Grid.RowProperty, row++); ViewGrid.Children.Add(valueTextBlock); // render the action based on the action type switch (action.ActionType) { case "Navigate": try { TaskList tl = App.ViewModel.TaskLists.Single(t => t.ID == (Guid)val); valueTextBlock.Text = String.Format("to {0}", tl.Name); button.Click += new RoutedEventHandler(delegate { // trace page navigation TraceHelper.StartMessage("Task: Navigate to TaskList"); // Navigate to the new page //NavigationService.Navigate(new Uri("/TaskListPage.xaml?type=TaskList&ID=" + tl.ID.ToString(), UriKind.Relative)); NavigationService.Navigate(new Uri("/ListPage.xaml?type=TaskList&ID=" + tl.ID.ToString(), UriKind.Relative)); }); } catch (Exception) { valueTextBlock.Text = "(list not found)"; } break; case "Postpone": valueTextBlock.Text = "to tomorrow"; button.Click += new RoutedEventHandler(delegate { pi.SetValue(task, DateTime.Today.Date.AddDays(1.0), null); taskList.NotifyPropertyChanged("FirstDue"); taskList.NotifyPropertyChanged("FirstDueColor"); }); break; case "AddToCalendar": valueTextBlock.SetBinding(TextBlock.TextProperty, new Binding("DueDisplay")); button.Click += new RoutedEventHandler(delegate { taskList.NotifyPropertyChanged("FirstDue"); taskList.NotifyPropertyChanged("FirstDueColor"); }); break; case "Map": valueTextBlock.SetBinding(TextBlock.TextProperty, new Binding(pi.Name)); button.Click += new RoutedEventHandler(delegate { #if WINPHONE7 // Pre-MANGO string mapUrl = "maps:"; bool space = false; foreach (string part in valueString.Split(' ')) { if (space == true) mapUrl += "%20"; mapUrl += part; space = true; } WebBrowserTask mapTask = new WebBrowserTask() { Uri = new Uri(mapUrl) }; #else // MANGO BingMapsTask mapTask = new BingMapsTask() { SearchTerm = valueString }; #endif mapTask.Show(); }); break; case "Phone": // format as phone number valueTextBlock.SetBinding(TextBlock.TextProperty, new Binding(pi.Name)); button.Click += new RoutedEventHandler(delegate { PhoneCallTask phoneCallTask = new PhoneCallTask() { PhoneNumber = (string)val }; phoneCallTask.Show(); }); break; case "TextMessage": valueTextBlock.SetBinding(TextBlock.TextProperty, new Binding(pi.Name)); button.Click += new RoutedEventHandler(delegate { SmsComposeTask smsTask = new SmsComposeTask() { To = (string)val }; smsTask.Show(); }); break; case "Browse": valueTextBlock.SetBinding(TextBlock.TextProperty, new Binding(pi.Name)); button.Click += new RoutedEventHandler(delegate { string url = (string)val; if (url.Substring(1, 4) != "http") url = String.Format("http://{0}", url); WebBrowserTask browserTask = new WebBrowserTask() { Uri = new Uri(url) }; browserTask.Show(); }); break; case "Email": valueTextBlock.SetBinding(TextBlock.TextProperty, new Binding(pi.Name)); button.Click += new RoutedEventHandler(delegate { EmailComposeTask emailTask = new EmailComposeTask() { To = (string)val }; emailTask.Show(); }); break; } } } }
private void InitPopup() { Binding fontSizeBinding = new Binding("FontSize"); fontSizeBinding.Source = this; Binding fontWeightBinding = new Binding("FontWeight"); fontWeightBinding.Source = this; Binding foregroundBinding = new Binding("Foreground"); foregroundBinding.Source = this; popup = new Popup(); popup.VerticalOffset = SystemTray.IsVisible ? 30 : 0; Grid grid = new Grid(); grid.MinHeight = MinHeight; grid.Width = Application.Current.Host.Content.ActualWidth; PlaneProjection projection = new PlaneProjection() { RotationX = -90 }; grid.Projection = projection; Binding backBinding = new Binding("Background"); backBinding.Source = this; grid.SetBinding(Grid.BackgroundProperty, backBinding); ColumnDefinition col1 = new ColumnDefinition() { Width = GridLength.Auto }; ColumnDefinition col2 = new ColumnDefinition() { Width = GridLength.Auto }; ColumnDefinition col3 = new ColumnDefinition(); grid.ColumnDefinitions.Add(col1); grid.ColumnDefinitions.Add(col2); grid.ColumnDefinitions.Add(col3); Image imgIcon = new Image(); imgIcon.Margin = new Thickness(4); Binding imgBinding = new Binding("Icon"); imgBinding.Source = this; var imageMaxWidthBinding = new Binding("MinHeight"); imageMaxWidthBinding.Source = this; imgIcon.SetBinding(Image.MaxWidthProperty, imageMaxWidthBinding); imgIcon.Stretch = Stretch.Fill; imgIcon.SetBinding(Image.SourceProperty, imgBinding); grid.Children.Add(imgIcon); TextBlock tbkTitle = new TextBlock(); tbkTitle.VerticalAlignment = System.Windows.VerticalAlignment.Center; tbkTitle.Margin = new Thickness(4); Binding titleBinding = new Binding("Title"); titleBinding.Source = this; tbkTitle.SetBinding(TextBlock.TextProperty, titleBinding); tbkTitle.SetBinding(TextBlock.FontSizeProperty, fontSizeBinding); tbkTitle.SetBinding(TextBlock.FontWeightProperty, fontWeightBinding); tbkTitle.SetBinding(TextBlock.ForegroundProperty, foregroundBinding); tbkTitle.SetValue(Grid.ColumnProperty, 1); grid.Children.Add(tbkTitle); TextBlock tbkContent = new TextBlock(); tbkContent.VerticalAlignment = System.Windows.VerticalAlignment.Center; tbkContent.Margin = new Thickness(4); Binding contentBinding = new Binding("Content"); contentBinding.Source = this; tbkContent.SetBinding(TextBlock.TextProperty, contentBinding); tbkContent.SetBinding(TextBlock.FontSizeProperty, fontSizeBinding); tbkContent.SetBinding(TextBlock.FontWeightProperty, fontWeightBinding); tbkContent.SetBinding(TextBlock.ForegroundProperty, foregroundBinding); tbkContent.SetValue(Grid.ColumnProperty, 2); grid.Children.Add(tbkContent); popup.Child = grid; }
public static void SetHideOnNullOrEmpty(TextBlock element, bool value) { element.SetValue(HideOnNullOrEmptyProperty, value); }
private void InitPopup() { popup = new Popup(); popup.Width = App.Current.Host.Content.ActualWidth; popup.Height = App.Current.Host.Content.ActualHeight; Grid grid = new Grid() { Background = new SolidColorBrush(Colors.Transparent) }; grid.Width = popup.Width; grid.Height = popup.Height; grid.Background = App.Current.Resources["BackgroundBrush"] as ImageBrush; Grid contentContainer = new Grid(); contentContainer.HorizontalAlignment = HorizontalAlignment.Center; contentContainer.VerticalAlignment = VerticalAlignment.Center; contentContainer.Margin = new Thickness(5); contentContainer.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); contentContainer.RowDefinitions.Add(new RowDefinition()); contentContainer.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(80) }); contentContainer.ColumnDefinitions.Add(new ColumnDefinition()); grid.Children.Add(contentContainer); Image image = new Image(); image.SetValue(Grid.RowSpanProperty, 2); contentContainer.Children.Add(image); if ((Constants.OpeningTime - DateTime.Now).Days > 0) { TextBlock tbkOpeningTimeTitle = new TextBlock() { Text = AppResources.TimeDownTip }; tbkOpeningTimeTitle.FontSize = 30; tbkOpeningTimeTitle.VerticalAlignment = VerticalAlignment.Center; tbkOpeningTimeTitle.SetValue(Grid.ColumnProperty, 1); tbkOpeningTimeTitle.Foreground = App.Current.Resources["PopupTextBrush"] as SolidColorBrush; contentContainer.Children.Add(tbkOpeningTimeTitle); TextBlock tbkDays = new TextBlock() { Text = String.Format(AppResources.Days, (Constants.OpeningTime - DateTime.Now).Days) }; tbkDays.SetValue(Grid.ColumnProperty, 1); tbkDays.SetValue(Grid.RowProperty, 1); tbkDays.FontSize = 50; tbkDays.FontWeight = FontWeights.Black; tbkDays.Foreground = App.Current.Resources["PopupTextBrush"] as SolidColorBrush; tbkDays.HorizontalAlignment = HorizontalAlignment.Center; tbkDays.VerticalAlignment = VerticalAlignment.Center; contentContainer.Children.Add(tbkDays); } else { List<MatchItem> items = FindMatchingMatch(); StackPanel sp = new StackPanel(); sp.SetValue(Grid.RowProperty, 1); sp.SetValue(Grid.ColumnSpanProperty, 2); foreach (var item in items) { MatchItemControl wic = new MatchItemControl(); wic.DataContext = item; sp.Children.Add(wic); } contentContainer.Children.Add(sp); } popup.Child = grid; popup.IsOpen = true; var ob = Observable.GenerateWithTime(0, x => x < 1, x => x, x => TimeSpan.FromSeconds(5), x => x + 1); ob.ObserveOnDispatcher().Subscribe(x => { popup.IsOpen = false; InitApplicationBar(); }); }