Created
October 1, 2011 20:12
-
-
Save schuster-rainer/1256598 to your computer and use it in GitHub Desktop.
prototyping panel with fsi and WPF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if INTERACTIVE | |
#load "load-wpf.fsx" | |
#endif | |
// === WPF === | |
open System.Windows | |
open System.Windows.Controls | |
open System.Windows.Media.Imaging | |
// Create Window and StackPanel | |
let window = new Window(Title = "Prototyping") | |
window.Show() | |
let scroll = new ScrollViewer() | |
let panel = new WrapPanel() | |
panel.Orientation <- Orientation.Horizontal | |
panel.ItemWidth <- 350.0 | |
panel.HorizontalAlignment = HorizontalAlignment.Left; | |
panel.VerticalAlignment = VerticalAlignment.Top; | |
scroll.Content <- panel | |
window.Content <- scroll | |
let stack content = | |
panel.Children.Add content | |
let stackImage (img:System.Drawing.Image) = | |
let bi = new BitmapImage() | |
bi.BeginInit() | |
let ms = new MemoryStream() | |
img.Save (ms, ImageFormat.Bmp) | |
let offset = ms.Seek (0L, SeekOrigin.Begin) | |
bi.StreamSource <- ms | |
bi.EndInit() | |
bi.Freeze() | |
let imageControl = new Image() | |
imageControl.Source <- bi | |
stack imageControl | |
// === WPF === |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment