Skip to content

Instantly share code, notes, and snippets.

@Spraynard
Last active February 14, 2019 03:36
Show Gist options
  • Select an option

  • Save Spraynard/44ff6c24c93d6a0469cb411395579b53 to your computer and use it in GitHub Desktop.

Select an option

Save Spraynard/44ff6c24c93d6a0469cb411395579b53 to your computer and use it in GitHub Desktop.

Revisions

  1. Spraynard revised this gist Feb 14, 2019. No changes.
  2. Spraynard revised this gist Feb 14, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion insertingImageControl_Basic.cs
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@

    BitmapImage bitmapImg = new BitmapImage();
    bitmapImg.BeginInit()
    bitmap.UriSource = new Uri(imgInfo.Fullname);
    bitmap.UriSource = new Uri(imgInfo.FullName);
    bitmap.EndInit();

    myImage.Source = bitmapImg;
  3. Spraynard revised this gist Feb 14, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion insertingImageControl_Basic.cs
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@

    BitmapImage bitmapImg = new BitmapImage();
    bitmapImg.BeginInit()
    bitmap.uriSource = new Uri(imgInfo.Fullname);
    bitmap.UriSource = new Uri(imgInfo.Fullname);
    bitmap.EndInit();

    myImage.Source = bitmapImg;
  4. Spraynard revised this gist Feb 14, 2019. 1 changed file with 21 additions and 4 deletions.
    25 changes: 21 additions & 4 deletions insertingImageControl_Basic.cs
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,30 @@
    using System.Windows.Controls;
    using System.Windows.Documents
    using System.Windows.Documents;
    ...

    FileInfo imgInfo = new FileInfo(path_to_img)

    // Create Our Image
    // Control type
    Image myImage = new Image();
    // Set image properties here, such as Source

    BitmapImage bitmapImg = new BitmapImage();
    bitmapImg.BeginInit()
    bitmap.uriSource = new Uri(imgInfo.Fullname);
    bitmap.EndInit();

    myImage.Source = bitmapImg;

    // Changing our rotation transform's origin from top left to center of image
    transform.CenterX = myImage.ActualWidth / 2;
    transform.CenterY = myImage.ActualHeight / 2;

    // Applying transform on image control
    myImage.RenderTransform = transform;

    // Create our BlockUIContainer
    BlockUIContainer container = new BlockUIContainer();
    container.Child = myImage;

    // Adding our "container" to a flow document through FlowDocument.Blocks.Add(BlockContainer) will now display our image.
    // Insert container with image into the document.
    FlowDocument doc = new FlowDocument();
    doc.Blocks.Add(container);
  5. Spraynard renamed this gist Feb 14, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  6. Spraynard created this gist Feb 14, 2019.
    13 changes: 13 additions & 0 deletions insertingImageControl.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    using System.Windows.Controls;
    using System.Windows.Documents
    ...

    // Create Our Image
    Image myImage = new Image();
    // Set image properties here, such as Source

    // Create our BlockUIContainer
    BlockUIContainer container = new BlockUIContainer();
    container.Child = myImage;

    // Adding our "container" to a flow document through FlowDocument.Blocks.Add(BlockContainer) will now display our image.