08-11-2015, 02:42 PM
Hi
I have an Image inside the zoompanel:
<ab2d:ZoomPanel Name="ZoomPanel" Margin="5,5,5,5" Height="600" Width="800"
IsViewboxLimited="True" ViewboxMinSize="0.0078125, 0.0078125" ViewboxLimits="0, 0, 1, 1"
RenderOptions.BitmapScalingMode="NearestNeighbor" ZoomMode="Move" ZoomFactor="1" >
<Image Name="ZoomImage" MouseMove="ZoomImage_MouseMove" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
</ab2d:ZoomPanel>
I need to draw on top of my image and tried using an adorner for this.
When panning the ZoomPanel the adorner can extend outside the ZoomPanel.
Adorner:
class ROI : Adorner
{
double X,Y,W,H;
public ROI(System.Windows.UIElement adornerElement, double x, double y, double w, double h)
: base(adornerElement)
{
X = x;
Y = y;
W = w;
H = h;
}
protected override void OnRender(DrawingContext drawingContext)
{
System.Windows.Rect rect = new System.Windows.Rect(X, Y, W, H);
System.Windows.Media.Pen streg = new System.Windows.Media.Pen(Brushes.Red, 1);
drawingContext.DrawRectangle(null, streg, rect);
drawingContext.PushClip(new RectangleGeometry(new Rect(0, 0, this.AdornedElement.RenderSize.Width, this.AdornedElement.RenderSize.Height)));
drawingContext.Pop();
}
}
I tried PushClip and Pop for the adorner but that did not help.
Is there a way to avoid the adorner extending outside the ZoomPanel?
Thanks.
I have an Image inside the zoompanel:
<ab2d:ZoomPanel Name="ZoomPanel" Margin="5,5,5,5" Height="600" Width="800"
IsViewboxLimited="True" ViewboxMinSize="0.0078125, 0.0078125" ViewboxLimits="0, 0, 1, 1"
RenderOptions.BitmapScalingMode="NearestNeighbor" ZoomMode="Move" ZoomFactor="1" >
<Image Name="ZoomImage" MouseMove="ZoomImage_MouseMove" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
</ab2d:ZoomPanel>
I need to draw on top of my image and tried using an adorner for this.
When panning the ZoomPanel the adorner can extend outside the ZoomPanel.
Adorner:
class ROI : Adorner
{
double X,Y,W,H;
public ROI(System.Windows.UIElement adornerElement, double x, double y, double w, double h)
: base(adornerElement)
{
X = x;
Y = y;
W = w;
H = h;
}
protected override void OnRender(DrawingContext drawingContext)
{
System.Windows.Rect rect = new System.Windows.Rect(X, Y, W, H);
System.Windows.Media.Pen streg = new System.Windows.Media.Pen(Brushes.Red, 1);
drawingContext.DrawRectangle(null, streg, rect);
drawingContext.PushClip(new RectangleGeometry(new Rect(0, 0, this.AdornedElement.RenderSize.Width, this.AdornedElement.RenderSize.Height)));
drawingContext.Pop();
}
}
I tried PushClip and Pop for the adorner but that did not help.
Is there a way to avoid the adorner extending outside the ZoomPanel?
Thanks.