void MakeExpander() { //Create containing stack panel and assign to Grid row/col StackPanel sp = new StackPanel(); Grid.SetRow(sp, 0); Grid.SetColumn(sp, 1); sp.Background = Brushes.LightSalmon; //Create column title TextBlock colTitle = new TextBlock(); colTitle.Text = "EXPANDER CREATED FROM CODE"; colTitle.HorizontalAlignment= HorizontalAlignment.Center; colTitle.Margin.Bottom.Equals(20); sp.Children.Add(colTitle); //Create Expander object Expander exp = new Expander(); //Create Bullet Panel for Expander Header BulletDecorator bp = new BulletDecorator(); Image i = new Image(); BitmapImage bi= new BitmapImage(); bi.UriSource = new Uri(@"pack://application:,,/images/icon.jpg"); i.Source = bi; i.Width = 10; bp.Bullet = i; TextBlock tb = new TextBlock(); tb.Text = "My Expander"; tb.Margin = new Thickness(20,0,0,0); bp.Child = tb; exp.Header = bp; //Create TextBlock with ScrollViewer for Expander Content StackPanel spScroll = new StackPanel(); TextBlock tbc = new TextBlock(); tbc.Text = "Lorem ipsum dolor sit amet, consectetur adipisicing elit," + "sed do eiusmod tempor incididunt ut labore et dolore magna" + "aliqua. Ut enim ad minim veniam, quis nostrud exercitation" + "ullamco laboris nisi ut aliquip ex ea commodo consequat." + "Duis aute irure dolor in reprehenderit in voluptate velit" + "esse cillum dolore eu fugiat nulla pariatur. Excepteur sint" + "occaecat cupidatat non proident, sunt in culpa qui officia" + "deserunt mollit anim id est laborum."; tbc.TextWrapping = TextWrapping.Wrap; spScroll.Children.Add(tbc); ScrollViewer scr = new ScrollViewer(); scr.Content = spScroll; scr.Height = 50; exp.Content = scr; exp.Width=200; exp.HorizontalContentAlignment= HorizontalAlignment.Stretch; //Insert Expander into the StackPanel and add it to the //Grid sp.Children.Add(exp); myGrid.Children.Add(sp); }
private void LoadTreeViewCategory(XmlReader reader, TreeViewItem categoryItem) { int itemCount = 0; while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (String.Equals(reader.Name, "test", StringComparison.OrdinalIgnoreCase)) { TestInfo testInfo = new TestInfo(reader); if (!testInfo.IsEmpty) { TextBlock headerText = new TextBlock(); headerText.Text = String.Format("({0:D3}) - {1}", itemCount, testInfo.Title); headerText.Margin = new Thickness(3, 0, 0, 0); Ellipse bullet = new Ellipse(); bullet.Height = 16; bullet.Width = 16; bullet.Fill = testInfo.StateBrush; bullet.Stroke = Brushes.DarkGray; bullet.StrokeThickness = 1; BulletDecorator decorator = new BulletDecorator(); decorator.Bullet = bullet; decorator.Margin = new Thickness(0, 0, 10, 0); decorator.Child = headerText; TreeViewItem treeItem = new TreeViewItem(); treeItem.Header = decorator; treeItem.Padding = new Thickness(3); treeItem.FontSize = 12; treeItem.FontWeight = FontWeights.Normal; treeItem.Tag = testInfo; categoryItem.Items.Add(treeItem); itemCount++; } } } else if (reader.NodeType == XmlNodeType.EndElement) { if (String.Equals(reader.Name, "category", StringComparison.OrdinalIgnoreCase)) { break; } } } }
private void LoadTreeView(XmlReader reader) { treeView.BeginInit(); treeView.Items.Clear(); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element && String.Equals(reader.Name, "category", StringComparison.OrdinalIgnoreCase)) { // <category label="Animations"> string category = reader.GetAttribute("label"); if (!String.IsNullOrEmpty(category)) { TextBlock headerText = new TextBlock(); headerText.Text = category; headerText.Margin = new Thickness(3, 0, 0, 0); BulletDecorator decorator = new BulletDecorator(); if (_folderClose != null) { Image image = new Image(); image.Source = _folderClose; decorator.Bullet = image; } else { Ellipse bullet = new Ellipse(); bullet.Height = 16; bullet.Width = 16; bullet.Fill = Brushes.Goldenrod; bullet.Stroke = Brushes.DarkGray; bullet.StrokeThickness = 1; decorator.Bullet = bullet; } decorator.Margin = new Thickness(0, 0, 10, 0); decorator.Child = headerText; TreeViewItem categoryItem = new TreeViewItem(); categoryItem.Header = decorator; categoryItem.Margin = new Thickness(0, 3, 0, 3); categoryItem.FontSize = 14; categoryItem.FontWeight = FontWeights.Bold; treeView.Items.Add(categoryItem); LoadTreeViewCategory(reader, categoryItem); } } } treeView.EndInit(); }
public SvgDrawingCanvas() { _drawForInteractivity = true; _drawObjects = new List<Drawing>(); _linkObjects = new List<Drawing>(); _displayTransform = Transform.Identity; // Create a tooltip and set its position. _tooltip = new ToolTip(); _tooltip.Placement = PlacementMode.MousePoint; _tooltip.PlacementRectangle = new Rect(50, 0, 0, 0); _tooltip.HorizontalOffset = 20; _tooltip.VerticalOffset = 20; _tooltipText = new TextBlock(); _tooltipText.Text = String.Empty; _tooltipText.Margin = new Thickness(6, 0, 0, 0); //Create BulletDecorator and set it as the tooltip content. Ellipse bullet = new Ellipse(); bullet.Height = 10; bullet.Width = 10; bullet.Fill = Brushes.LightCyan; BulletDecorator decorator = new BulletDecorator(); decorator.Bullet = bullet; decorator.Margin = new Thickness(0, 0, 10, 0); decorator.Child = _tooltipText; _tooltip.Content = decorator; _tooltip.IsOpen = false; _tooltip.Visibility = Visibility.Hidden; //Finally, set tooltip on this canvas this.ToolTip = _tooltip; this.Background = Brushes.Transparent; _animationCanvas = new SvgAnimationLayer(this); }
public void VerticalAlignmentTest () { BulletDecorator b = new BulletDecorator (); Assert.AreEqual (b.VerticalAlignment, VerticalAlignment.Stretch); }
private void FillTreeView(string sourceDir, string[] svgFiles, TreeViewItem treeItem) { if (svgFiles != null && svgFiles.Length != 0) { for (int i = 0; i < svgFiles.Length; i++) { string svgFile = svgFiles[i]; TextBlock itemText = new TextBlock(); itemText.Text = String.Format("({0:D3}) - {1}", i, IoPath.GetFileName(svgFile)); itemText.Margin = new Thickness(3, 0, 0, 0); BulletDecorator fileItem = new BulletDecorator(); if (_fileThumbnail != null) { Image image = new Image(); image.Source = _fileThumbnail; image.Height = 16; image.Width = 16; fileItem.Bullet = image; } else { Ellipse bullet = new Ellipse(); bullet.Height = 16; bullet.Width = 16; bullet.Fill = Brushes.Goldenrod; bullet.Stroke = Brushes.DarkGray; bullet.StrokeThickness = 1; fileItem.Bullet = bullet; } fileItem.Margin = new Thickness(0, 0, 10, 0); fileItem.Child = itemText; TreeViewItem item = new TreeViewItem(); item.Tag = svgFile; item.Header = fileItem; item.Margin = new Thickness(0); item.Padding = new Thickness(2); item.FontSize = 12; item.FontWeight = FontWeights.Normal; treeItem.Items.Add(item); } } if (String.IsNullOrEmpty(sourceDir) || !Directory.Exists(sourceDir)) { return; } string[] directories = Directory.GetDirectories(sourceDir); if (directories != null && directories.Length != 0) { for (int i = 0; i < directories.Length; i++) { string directory = directories[i]; svgFiles = Directory.GetFiles(directory, "*.svg", SearchOption.TopDirectoryOnly); { DirectoryInfo directoryInfo = new DirectoryInfo(directory); TextBlock headerText = new TextBlock(); headerText.Text = directoryInfo.Name; headerText.Margin = new Thickness(3, 0, 0, 0); BulletDecorator decorator = new BulletDecorator(); if (_folderClose != null) { Image image = new Image(); image.Source = _folderClose; decorator.Bullet = image; } else { Ellipse bullet = new Ellipse(); bullet.Height = 16; bullet.Width = 16; bullet.Fill = Brushes.Goldenrod; bullet.Stroke = Brushes.DarkGray; bullet.StrokeThickness = 1; decorator.Bullet = bullet; } decorator.Margin = new Thickness(0, 0, 10, 0); decorator.Child = headerText; TreeViewItem categoryItem = new TreeViewItem(); categoryItem.Tag = String.Empty; categoryItem.Header = decorator; categoryItem.Margin = new Thickness(0); categoryItem.Padding = new Thickness(3); categoryItem.FontSize = 14; categoryItem.FontWeight = FontWeights.Bold; treeItem.Items.Add(categoryItem); FillTreeView(directory, svgFiles, categoryItem); if (!categoryItem.HasItems) { treeItem.Items.Remove(categoryItem); } } } } }
private void FillTreeView(string sourceDir) { if (String.IsNullOrEmpty(sourceDir) || !Directory.Exists(sourceDir)) { return; } string[] svgFiles = Directory.GetFiles(sourceDir, "*.svg", SearchOption.TopDirectoryOnly); treeView.BeginInit(); treeView.Items.Clear(); DirectoryInfo directoryInfo = new DirectoryInfo(sourceDir); TextBlock headerText = new TextBlock(); headerText.Text = directoryInfo.Name; headerText.Margin = new Thickness(3, 0, 0, 0); BulletDecorator decorator = new BulletDecorator(); if (_folderClose != null) { Image image = new Image(); image.Source = _folderClose; decorator.Bullet = image; } else { Ellipse bullet = new Ellipse(); bullet.Height = 16; bullet.Width = 16; bullet.Fill = Brushes.Goldenrod; bullet.Stroke = Brushes.DarkGray; bullet.StrokeThickness = 1; decorator.Bullet = bullet; } decorator.Margin = new Thickness(0, 0, 10, 0); decorator.Child = headerText; TreeViewItem categoryItem = new TreeViewItem(); categoryItem.Tag = String.Empty; categoryItem.Header = decorator; categoryItem.Margin = new Thickness(0); categoryItem.Padding = new Thickness(3); categoryItem.FontSize = 14; categoryItem.FontWeight = FontWeights.Bold; treeView.Items.Add(categoryItem); FillTreeView(sourceDir, svgFiles, categoryItem); categoryItem.IsExpanded = true; treeView.EndInit(); leftExpander.IsExpanded = true; }