public StationPresenter() { OverlayPanel overlay = new OverlayPanel(); // stretch to fit overlay.HorizontalAlignment = WindowlessControls.HorizontalAlignment.Stretch; overlay.VerticalAlignment = VerticalAlignment.Stretch; // dock the picture to the right and the info to the left DockPanel dock = new DockPanel(); StackPanel left = new StackPanel(); left.Layout = new DockLayout(new LayoutMeasurement(0, LayoutUnit.Star), DockStyle.Left); //m_Image.Layout = new DockLayout(new LayoutMeasurement(0, LayoutUnit.Star), DockStyle.Right); //m_Image.MaxHeight = 100; //m_Image.MaxWidth = 100; //dock.Controls.Add(m_Image); m_Distance.Layout = new DockLayout(new LayoutMeasurement(0, LayoutUnit.Star), DockStyle.Right); m_Distance.MaxHeight = 100; m_Distance.MaxWidth = 100; dock.Controls.Add(m_Distance); dock.Controls.Add(left); // 5 pixel border around the item contents dock.Margin = new Thickness(5, 5, 5, 5); // make the overlay fit the dock, so as to limit the size of the selection rectangle overlay.FitWidthControl = overlay.FitHeightControl = dock; // set up the rectangle color and make it fill the region m_Rectangle.Color = SystemColors.Highlight; m_Rectangle.HorizontalAlignment = WindowlessControls.HorizontalAlignment.Stretch; m_Rectangle.VerticalAlignment = VerticalAlignment.Stretch; // the rectangle does not paint by default m_Rectangle.PaintSelf = false; // add the extended info that is only visible when focused StackPanel nameAndNumber = new StackPanel(); nameAndNumber.Controls.Add(m_StationName); nameAndNumber.Controls.Add(m_StationNumber); m_ExtendedInfo.Visible = false; m_ExtendedInfo.Controls.Add(m_StationAddress); // set up the left side left.Controls.Add(nameAndNumber); left.Controls.Add(m_ExtendedInfo); // add the foreground and the background selection overlay.Controls.Add(m_Rectangle); overlay.Controls.Add(dock); // add the item Controls.Add(overlay); // this is the bottom border WindowlessRectangle bottomBorder = new WindowlessRectangle(Int32.MaxValue, 1, Color.Gray); Controls.Add(bottomBorder); }
public ButtonDemo() { InitializeComponent(); // we need to layer two controls on top of another: a background, with another panel containing more controls StackPanel stack = myHost.Control; OverlayPanel overlay = new OverlayPanel(); stack.Controls.Add(overlay); // set up the background bitmap and control PlatformBitmap backgroundBitmap = PlatformBitmap.FromResource("Wallpaper.jpg"); WindowlessImage background = new WindowlessImage(backgroundBitmap); background.Stretch = Stretch.Uniform; overlay.Controls.Add(background); // set up the foreground StackPanel foreground = new StackPanel(); overlay.Controls.Add(foreground); // load the transparent images PlatformBitmap users = PlatformBitmap.FromResource("users.png"); PlatformBitmap tip = PlatformBitmap.FromResource("tip.png"); // the two buttons will be placed in a WrapPanel // a wrap panel will horizontally or vertically lay out elements in a given direction until it runs out of room in that direction. // when it runs out of room, it will "wrap" to the next line. // since this wrap panel is contained in a vertical stack panel, it will lay out elements horizontally, and wrap vertically to the next line. WrapPanel wrap = new WrapPanel(); foreground.Controls.Add(wrap); // focus state bitmap PlatformBitmap focused = PlatformBitmap.FromResource("Btn1.png"); // normal unselected state bitmap PlatformBitmap unfocused = PlatformBitmap.FromResource("Btn1_Disabled.png"); // clicked state bitmap PlatformBitmap clicked = PlatformBitmap.FromResource("Btn1_Pushed.png"); // set up the image button by setting the properties manually ImageButton button1 = new ImageButton(unfocused, Stretch.None); button1.Control.FocusedBitmap = focused; button1.Control.ClickedBitmap = clicked; button1.BackColor = Color.Transparent; // OR set the button up by setting everything in the constructor ImageButton button2 = new ImageButton(unfocused, Stretch.None, focused, clicked); button2.BackColor = Color.Transparent; // add the buttons wrap.Controls.Add(button1); wrap.Controls.Add(button2); }
public DropdownControl(WindowlessControlHost dropdownSource, IWindowlessControl dropdownContent) { AutoScroll = true; Orientation = Orientation.Vertical; myDropdownSource = dropdownSource; OverlayPanel overlay = new OverlayPanel(); WindowlessRectangle rectangle = new WindowlessRectangle(); rectangle.Color = SystemColors.ControlDarkDark; rectangle.Filled = false; overlay.Controls.Add(rectangle); OverlayPanel inner = new OverlayPanel(); inner.Margin = new Thickness(1, 1, 1, 1); inner.Controls.Add(dropdownContent); overlay.Controls.Add(inner); overlay.FitHeightControl = overlay.FitWidthControl = inner; Control = overlay; }
public ImageGallery() { InitializeComponent(); VerticalStackPanelHost scrollHost = new VerticalStackPanelHost(); StackPanel stack = scrollHost.Control; stack.HorizontalAlignment = WindowlessControls.HorizontalAlignment.Stretch; myHost.Control.Controls.Add(scrollHost); myHost.AutoScroll = true; // we need to layer two controls on top of another: a background, with another panel containing more controls OverlayPanel overlay = new OverlayPanel(); stack.Controls.Add(overlay); // set up the background bitmap and control PlatformBitmap backgroundBitmap = PlatformBitmap.FromResource("Wallpaper.jpg"); WindowlessImage background = new WindowlessImage(backgroundBitmap); background.Stretch = Stretch.Uniform; overlay.Controls.Add(background); // set up the foreground StackPanel foreground = new StackPanel(); overlay.Controls.Add(foreground); // set up the ItemsControl which will hold the images myItemsControl.BackColor = Color.Transparent; // the images will be contained in a wrap panel myItemsControl.Control = new WrapPanel(); // this tells the ItemsControl what is used to represent the content items myItemsControl.ContentPresenter = typeof(ImageResourcePresenter); foreground.Controls.Add(myItemsControl); // let's get a list of image resources Assembly ass = Assembly.GetCallingAssembly(); string[] names = ass.GetManifestResourceNames(); foreach (string name in names) { foreach (string extension in imageExtensions) { if (name.EndsWith(extension, StringComparison.CurrentCultureIgnoreCase)) { myItemsControl.Items.Add(name); break; } } } // now let's search the file system for images foreach (string name in Directory.GetFiles("\\My Documents\\My Pictures")) { foreach (string extension in imageExtensions) { if (name.EndsWith(extension, StringComparison.CurrentCultureIgnoreCase)) { myItemsControl.Items.Add(name); break; } } } }