public TextControl(string name, string value = "pending...") { var foreground = new SolidColorBrush((Color)FindResource(VsColors.CaptionTextKey)); _lblName = new Label(); _lblName.Padding = new Thickness(3, 3, 0, 3); _lblName.FontWeight = FontWeights.Bold; _lblName.Content = name + ": "; _lblName.SetResourceReference(TextBlock.ForegroundProperty, EnvironmentColors.ComboBoxFocusedTextBrushKey); Children.Add(_lblName); _lblValue = new Label(); _lblValue.Padding = new Thickness(0, 3, 10, 3); ; _lblValue.Content = value; _lblValue.SetResourceReference(TextBlock.ForegroundProperty, EnvironmentColors.ComboBoxFocusedTextBrushKey); Children.Add(_lblValue); }
private void lbContentBing(Label lb,string sourceKey) { object obj_Item = TryFindResource(sourceKey); if (obj_Item != null) { lb.SetResourceReference(Label.ContentProperty, sourceKey); } else { lb.Content = sourceKey + "_undefined"; } }
public void addItem(string str_key) { string str_Item = string.Empty; object obj_Item = TryFindResource(str_key); Label lb = new Label(); lb.Height = 35; if (obj_Item != null) { lb.SetResourceReference(Label.ContentProperty, str_key); } else { lb.Content = str_key + "_undefined"; } lb.FontSize = 14; lb.Foreground = Brushes.Black; lb.VerticalContentAlignment = VerticalAlignment.Center; lb.Margin = new Thickness(10, 0, 0, 0); Border bd = new Border(); bd.BorderBrush = new SolidColorBrush(Color.FromArgb(0xff, 0x90, 0x90, 0x90)); bd.Background = Brushes.White; bd.BorderThickness = new Thickness(1, 0, 1, 1); bd.Height = 35; bd.Width = bdMain.Width; bd.Child = lb; bd.Tag = _itemsCount; bd.MouseUp += new MouseButtonEventHandler(bd_MouseUp); sPanelItems.Children.Add(bd); _itemsCount++; }
public VisualMessage( string StreamerNick, SmilesDataDase Db, ChatMessage Data ) { this.Data = Data; List<Uri> Urls = new List<Uri>(); string UserText = Data.Text;// HttpUtility.HtmlDecode(Data.Text.Replace(":s:", " :s:").Replace(" ", " ")); UserText = UriDetector.Replace( UserText, new MatchEvaluator(( m ) => { Urls.Add(new Uri(m.Value, UriKind.RelativeOrAbsolute)); return LinkReplacer + " "; }) ); // parse text WrapPanel wp = new WrapPanel() { Orientation = System.Windows.Controls.Orientation.Horizontal, }; List<string> ttt = new List<string>(); // Тоже странный кусок: int nxd = UserText.IndexOf("<b>"); if (nxd >= 0) { int nxd2 = UserText.IndexOf("</b>"); TalkTo = UserText.Substring(nxd + 3, nxd2 - nxd - 3); if (UserText.Length <= (nxd2 + 6)) { UserText = ""; } else { UserText = UserText.Substring(nxd2 + 6); } if (TalkTo == StreamerNick) { wp.SetResourceReference(WrapPanel.StyleProperty, "StreamerContainer"); } else { wp.SetResourceReference(WrapPanel.StyleProperty, "NormalTextContainer"); } ttt.Add(TalkTo + ","); } else { TalkTo = ""; } ttt.AddRange(UserText.Split(' ')); // if (UseLabel) { Label name = new Label() { Content = Data.Name + ": " }; name.SetResourceReference(Label.StyleProperty, "LabelNameStyle"); wp.Children.Add(name); int linkIndex = 0; for (int j = 0; j < ttt.Count; ++j) { if (ttt[j] == LinkReplacer) { Label link = new Label() { Content = "link ", Cursor = Cursors.Hand, ToolTip = Urls[linkIndex], Tag = Urls[linkIndex] }; link.SetResourceReference(Label.StyleProperty, "LabelLinkStyle"); link.MouseLeftButtonUp += ( sender, b ) => { Uri u = ((Label)sender).Tag as Uri; System.Diagnostics.Process.Start(u.ToString()); }; wp.Children.Add(link); linkIndex++; } else { //if (j != (ttt.Count - 1)) ttt[j] += ' '; if (CreateSmile(Db, ttt[j], wp)) { // Ура смайл ебать есть } else { Label txt = new Label() { Content = ttt[j] }; if (TalkTo + ", " == ttt[j]) { txt.SetResourceReference(Label.StyleProperty, "LabelNameTextStyle"); } else { txt.SetResourceReference(Label.StyleProperty, "LabelTextStyle"); } wp.Children.Add(txt); } } } //} else { // TextBlock name = new TextBlock() { Text = Data.Name + ": " }; // name.SetResourceReference(TextBlock.StyleProperty, "NameStyle"); // wp.Children.Add(name); // int linkIndex = 0; // for (int j = 0; j < ttt.Count; ++j) { // if (ttt[j] == LinkReplacer) { // TextBlock link = new TextBlock() { // Text = "link ", // Cursor = Cursors.Hand, // ToolTip = Urls[linkIndex], // Tag = Urls[linkIndex] // }; // link.SetResourceReference(TextBlock.StyleProperty, "LinkStyle"); // link.MouseLeftButtonUp += ( sender, b ) => { // Uri u = ((TextBlock)sender).Tag as Uri; // System.Diagnostics.Process.Start(u.ToString()); // }; // wp.Children.Add(link); // linkIndex++; // } else { // //if (j != (ttt.Count - 1)) // ttt[j] += ' '; // if (CreateSmile(Db, ttt[j], wp)) { // // Ура смайл ебать есть // } else { // TextBlock txt = new TextBlock() { Text = ttt[j] }; // if (TalkTo + ", " == ttt[j]) { // txt.SetResourceReference(TextBlock.StyleProperty, "NameTextStyle"); // } else { // txt.SetResourceReference(TextBlock.StyleProperty, "TextStyle"); // } // wp.Children.Add(txt); // } // } // } //} Text = wp; }
private void SetIco_NoUpdate() { Grid grid = new Grid(); grid.Width = 100; grid.Height = 100; Label lb = new Label(); lb.SetResourceReference(Label.ContentProperty, "ico-noUpdate"); grid.Children.Add(lb); bd_1.Child = grid; }
private void AddWord( WrapPanel wp, List<string> ttt, int j ) { Label txt = new Label() { Content = ttt[j] }; if (TalkTo + ", " == ttt[j]) { txt.SetResourceReference(Label.StyleProperty, "LabelNameTextStyle"); } else { txt.SetResourceReference(Label.StyleProperty, "LabelTextStyle"); } wp.Children.Add(txt); }
private FrameworkElement BuildHeaderArea() { Grid header = new Grid(); header.ColumnDefinitions.Add(new ColumnDefinition()); header.ColumnDefinitions.Add(new ColumnDefinition {Width = GridLength.Auto}); header.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); //Move grip containing the icon and title Grid moveGrip = new Grid(); moveGrip.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); moveGrip.ColumnDefinitions.Add(new ColumnDefinition()); moveGrip.SetResourceReference(Border.BackgroundProperty, EnvironmentColors.ToolWindowBackgroundBrushKey); moveGrip.SetValue(Grid.ColumnProperty, 0); moveGrip.MouseLeftButtonDown += TitleBarLeftMouseButtonDown; Image icon = new Image { VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(10, 5, 4, 0) }; icon.SetBinding(Image.SourceProperty, new Binding { Source = this, Path = new PropertyPath("Icon"), Mode = BindingMode.OneWay }); moveGrip.Children.Add(icon); Label label = new Label { VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 2, 0, 0) }; label.SetValue(Grid.ColumnProperty, 1); label.SetBinding(ContentControl.ContentProperty, new Binding { Source = this, Path = new PropertyPath("Title"), Mode = BindingMode.OneWay }); label.SetResourceReference(ForegroundProperty, EnvironmentColors.MainWindowActiveCaptionTextBrushKey); moveGrip.Children.Add(label); header.Children.Add(moveGrip); //Close button FrameworkElement closeGlyph; Path buttonPath; GenerateCloseGlyph(out closeGlyph, out buttonPath); Style closeButtonStyle = new Style(typeof(Button)); closeButtonStyle.Setters.Add(new Setter(HeightProperty, (double)25)); closeButtonStyle.Setters.Add(new Setter(WidthProperty, (double)25)); closeButtonStyle.Setters.Add(new Setter(FocusVisualStyleProperty, null)); closeButtonStyle.Setters.Add(new Setter(ForegroundProperty, new DynamicResourceExtension(EnvironmentColors.MainWindowButtonActiveGlyphBrushKey))); closeButtonStyle.Setters.Add(new Setter(BackgroundProperty, null)); closeButtonStyle.Setters.Add(new Setter(BorderBrushProperty, new DynamicResourceExtension(EnvironmentColors.MainWindowButtonActiveBorderBrushKey))); closeButtonStyle.Setters.Add(new Setter(TemplateProperty, FindResource("FlatButton"))); Trigger closeButtonHoverTrigger = new Trigger { Property = IsMouseOverProperty, Value = true }; closeButtonHoverTrigger.Setters.Add(new Setter(ForegroundProperty, new DynamicResourceExtension(EnvironmentColors.MainWindowButtonHoverActiveGlyphBrushKey))); closeButtonHoverTrigger.Setters.Add(new Setter(BackgroundProperty, new DynamicResourceExtension(EnvironmentColors.MainWindowButtonHoverActiveBrushKey))); closeButtonHoverTrigger.Setters.Add(new Setter(BorderBrushProperty, new DynamicResourceExtension(EnvironmentColors.MainWindowButtonHoverActiveBorderBrushKey))); closeButtonStyle.Triggers.Add(closeButtonHoverTrigger); Trigger closeButtonPressTrigger = new Trigger { Property = ButtonBase.IsPressedProperty, Value = true }; closeButtonPressTrigger.Setters.Add(new Setter(ForegroundProperty, new DynamicResourceExtension(EnvironmentColors.MainWindowButtonDownGlyphBrushKey))); closeButtonPressTrigger.Setters.Add(new Setter(BackgroundProperty, new DynamicResourceExtension(EnvironmentColors.MainWindowButtonDownBrushKey))); closeButtonPressTrigger.Setters.Add(new Setter(BorderBrushProperty, new DynamicResourceExtension(EnvironmentColors.MainWindowButtonDownBorderBrushKey))); closeButtonStyle.Triggers.Add(closeButtonPressTrigger); Button closeButton = new Button { Style = closeButtonStyle, Name = "closeButton", Content = closeGlyph, HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center }; closeButton.SetValue(Grid.ColumnProperty, 2); header.Children.Add(closeButton); buttonPath.SetBinding(Shape.FillProperty, new Binding { Path = new PropertyPath("Foreground"), Source = closeButton, Mode = BindingMode.OneWay }); closeButton.Click += CloseButtonClick; return header; }
private void addItem(string str_key) { TabItem item = new TabItem(); item.Margin = new Thickness(0); item.Padding = new Thickness(0); item.Height = 0; string str_Item = string.Empty; object obj_Item = TryFindResource(str_key); Label lb_Item = new Label(); lb_Item.FontSize = 14; if (obj_Item != null) { lb_Item.SetResourceReference(Label.ContentProperty, str_key); } else { lb_Item.Content = str_key + "_undefined"; } lb_Item.Height = 35; lb_Item.VerticalContentAlignment = VerticalAlignment.Center; lb_Item.Margin = new Thickness(10, 0, 0, 0); item.Content = lb_Item; tbSelected.Items.Add(item); }