本文整理汇总了C#中System.Windows.Media.ScaleTransform.Freeze方法的典型用法代码示例。如果您正苦于以下问题:C# ScaleTransform.Freeze方法的具体用法?C# ScaleTransform.Freeze怎么用?C# ScaleTransform.Freeze使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.ScaleTransform
的用法示例。
在下文中一共展示了ScaleTransform.Freeze方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DpiDecorator
public DpiDecorator()
{
this.Loaded += (s, e) =>
{
Matrix m = PresentationSource.FromVisual(this).CompositionTarget.TransformToDevice;
ScaleTransform dpiTransform = new ScaleTransform(1 / m.M11, 1 / m.M22);
if (dpiTransform.CanFreeze)
dpiTransform.Freeze();
this.LayoutTransform = dpiTransform;
};
}
示例2: DpiDecorator
public DpiDecorator()
{
this.Loaded += (RoutedEventHandler)((s, e) =>
{
Matrix transformToDevice = PresentationSource.FromVisual((Visual)this).CompositionTarget.TransformToDevice;
ScaleTransform scaleTransform = new ScaleTransform(1.0 / transformToDevice.M11, 1.0 / transformToDevice.M22);
if (scaleTransform.CanFreeze)
scaleTransform.Freeze();
this.LayoutTransform = (Transform)scaleTransform;
});
}
示例3: InitializeTransform
/// <summary> </summary>
public override void InitializeTransform()
{
double mercatorSize = 360;
TranslateTransform translateTransform = new TranslateTransform(MapView.ReferenceSize / 2 - 180, MapView.ReferenceSize / 2 - 180);
ScaleTransform zoomTransform = new ScaleTransform(MapView.ZoomAdjust * MapView.ReferenceSize / mercatorSize, MapView.ZoomAdjust * MapView.ReferenceSize / mercatorSize, MapView.ReferenceSize / 2, MapView.ReferenceSize / 2);
TransformGroup transformGroup = new TransformGroup();
transformGroup.Children.Add(translateTransform);
transformGroup.Children.Add(zoomTransform);
zoomTransform.Freeze();
translateTransform.Freeze();
transformGroup.Freeze();
this.RenderTransform = transformGroup;
}
示例4: DpiDecorator
public DpiDecorator()
{
Loaded += (s, e) =>
{
var presentationSource = PresentationSource.FromVisual(this);
if (presentationSource == null) return;
if (presentationSource.CompositionTarget == null) return;
var matrix = presentationSource.CompositionTarget.TransformToDevice;
var dpiTransform = new ScaleTransform(1 / matrix.M11, 1 / matrix.M22);
if (dpiTransform.CanFreeze)
dpiTransform.Freeze();
LayoutTransform = dpiTransform;
};
}
示例5: ScaleRect
partial static void ScaleRect(ref Rect rect, ref Transform transform)
{
// Scales the RectangleGeometry to compensate inaccurate hit testing in WPF.
// See http://stackoverflow.com/a/19335624/1136211
rect.Scale(1e6, 1e6);
var scaleTransform = new ScaleTransform(1e-6, 1e-6); // reverts rect scaling
scaleTransform.Freeze();
var transformGroup = new TransformGroup();
transformGroup.Children.Add(scaleTransform);
transformGroup.Children.Add(transform);
transform = transformGroup;
}
示例6: SetScaleTransform
void SetScaleTransform(DependencyObject textObj, DependencyObject vc, double scale) {
Debug.Assert(textObj != this || !wpfSupportsPerMonitorDpi);
if (vc == null || textObj == null)
return;
if (scale == 1)
vc.SetValue(LayoutTransformProperty, Transform.Identity);
else {
var st = new ScaleTransform(scale, scale);
st.Freeze();
vc.SetValue(LayoutTransformProperty, st);
}
SetTextFormattingMode(textObj, scale);
}
示例7: CreateFlipXTransform
private static ScaleTransform CreateFlipXTransform()
{
var flipXTransform = new ScaleTransform(-1, 1);
flipXTransform.Freeze();
return flipXTransform;
}
示例8: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
var renderSize = this.RenderSize;
var document = editor.Document;
var textView = editor.TextArea.TextView;
double documentHeight = textView.DocumentHeight;
foreach (var marker in textMarkerService.TextMarkers) {
if (!IsVisibleInAdorner(marker))
continue;
var location = document.GetLocation(marker.StartOffset);
double visualTop = textView.GetVisualTopByDocumentLine(location.Line);
double renderPos = visualTop / documentHeight * renderSize.Height;
var brush = GetBrush(marker.MarkerColor);
bool isLineOrCircle = false;
if ((marker.MarkerTypes & (TextMarkerTypes.LineInScrollBar)) != 0) {
drawingContext.DrawRectangle(brush, null, new Rect(3, renderPos - 1, renderSize.Width - 6, 2));
isLineOrCircle = true;
}
if ((marker.MarkerTypes & (TextMarkerTypes.CircleInScrollBar)) != 0) {
const double radius = 3;
drawingContext.DrawEllipse(brush, null, new Point(renderSize.Width / 2, renderPos), radius, radius);
isLineOrCircle = true;
}
if (!isLineOrCircle) {
var translateTransform = new TranslateTransform(6, renderPos);
translateTransform.Freeze();
drawingContext.PushTransform(translateTransform);
if ((marker.MarkerTypes & (TextMarkerTypes.ScrollBarLeftTriangle)) != 0) {
var scaleTransform = new ScaleTransform(-1, 1);
scaleTransform.Freeze();
drawingContext.PushTransform(scaleTransform);
drawingContext.DrawGeometry(brush, null, triangleGeometry);
drawingContext.Pop();
}
if ((marker.MarkerTypes & (TextMarkerTypes.ScrollBarRightTriangle)) != 0) {
drawingContext.DrawGeometry(brush, null, triangleGeometry);
}
drawingContext.Pop();
}
}
}
示例9: ChangeDisplayWidth
private void ChangeDisplayWidth(double newDisplayWidth)
{
oldDisplayWidthInSecs = newDisplayWidthInSecs;
newDisplayWidthInSecs = newDisplayWidth;
XScaleSecsToInches = Viewer.ViewportWidth / newDisplayWidthInSecs;
Transform t = new ScaleTransform(XScaleSecsToInches, XScaleSecsToInches, Viewer.ContentHorizontalOffset + Viewer.ViewportWidth / 2, 0D);
t.Freeze();
ViewerGrid.LayoutTransform = t; //new transform: keep scale seconds
//NB: must also scale vertically (and correct later) to keep drawing pen circular!
//Now change horizontal scroll to make inflation/deflation around center point;
Viewer.ScrollToHorizontalOffset(XScaleSecsToInches * (newDisplayOffsetInSecs + (oldDisplayWidthInSecs - newDisplayWidthInSecs) / 2D));
}
示例10: Viewer_SizeChanged
//----> ScrollViewer change routines are here: lead to redraws of window
private void Viewer_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (e.HeightChanged || e.WidthChanged)
{
IndexLine.Y2 = e.NewSize.Height - ScrollBarSize;
// reDrawGrid(e.NewSize.Height - ScrollBarSize);
double w = e.NewSize.Width;
XScaleSecsToInches = w / newDisplayWidthInSecs;
//rescale axes, so that X-scale units remain seconds
Transform t = new ScaleTransform(XScaleSecsToInches, XScaleSecsToInches);
t.Freeze();
ViewerGrid.LayoutTransform = t;
Viewer.ScrollToHorizontalOffset(newDisplayOffsetInSecs * XScaleSecsToInches); //this will signal the redraw
}
}
示例11: SetScaleValue
void SetScaleValue(TabState tabState, double scale) {
var scaleElem = tabState.ScaleElement;
if (scaleElem == null)
return;
if (scale == 1) {
scaleElem.LayoutTransform = Transform.Identity;
scaleElem.ClearValue(TextOptions.TextFormattingModeProperty);
}
else {
if (scale < MIN_ZOOM)
scale = MIN_ZOOM;
else if (scale > MAX_ZOOM)
scale = MAX_ZOOM;
// We must set it to Ideal or the text will be blurry
TextOptions.SetTextFormattingMode(scaleElem, TextFormattingMode.Ideal);
var st = new ScaleTransform(scale, scale);
st.Freeze();
scaleElem.LayoutTransform = st;
}
}
示例12: RenderAeroNormalColor
private void RenderAeroNormalColor(DrawingContext dc)
{
Size size = RenderSize;
bool horizontal = Orientation == Orientation.Horizontal;
bool isClickable = IsClickable && IsEnabled;
bool isHovered = isClickable && IsHovered;
bool isPressed = isClickable && IsPressed;
ListSortDirection? sortDirection = SortDirection;
bool isSorted = sortDirection != null;
bool isSelected = IsSelected;
bool hasBevel = (!isHovered && !isPressed && !isSorted && !isSelected);
EnsureCache((int)AeroFreezables.NumFreezables);
if (horizontal)
{
// When horizontal, rotate the rendering by -90 degrees
Matrix m1 = new Matrix();
m1.RotateAt(-90.0, 0.0, 0.0);
Matrix m2 = new Matrix();
m2.Translate(0.0, size.Height);
MatrixTransform horizontalRotate = new MatrixTransform(m1 * m2);
horizontalRotate.Freeze();
dc.PushTransform(horizontalRotate);
double temp = size.Width;
size.Width = size.Height;
size.Height = temp;
}
if (hasBevel)
{
// This is a highlight that can be drawn by just filling the background with the color.
// It will be seen through the gab between the border and the background.
LinearGradientBrush bevel = (LinearGradientBrush)GetCachedFreezable((int)AeroFreezables.NormalBevel);
if (bevel == null)
{
bevel = new LinearGradientBrush();
bevel.StartPoint = new Point();
bevel.EndPoint = new Point(0.0, 1.0);
bevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF), 0.0));
bevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF), 0.4));
bevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFC, 0xFC, 0xFD), 0.4));
bevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFB, 0xFC, 0xFC), 1.0));
bevel.Freeze();
CacheFreezable(bevel, (int)AeroFreezables.NormalBevel);
}
dc.DrawRectangle(bevel, null, new Rect(0.0, 0.0, size.Width, size.Height));
}
// Fill the background
AeroFreezables backgroundType = AeroFreezables.NormalBackground;
if (isPressed)
{
backgroundType = AeroFreezables.PressedBackground;
}
else if (isHovered)
{
backgroundType = AeroFreezables.HoveredBackground;
}
else if (isSorted || isSelected)
{
backgroundType = AeroFreezables.SortedBackground;
}
LinearGradientBrush background = (LinearGradientBrush)GetCachedFreezable((int)backgroundType);
if (background == null)
{
background = new LinearGradientBrush();
background.StartPoint = new Point();
background.EndPoint = new Point(0.0, 1.0);
switch (backgroundType)
{
case AeroFreezables.NormalBackground:
background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF), 0.0));
background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF), 0.4));
background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF7, 0xF8, 0xFA), 0.4));
background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF1, 0xF2, 0xF4), 1.0));
break;
case AeroFreezables.PressedBackground:
background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xBC, 0xE4, 0xF9), 0.0));
background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xBC, 0xE4, 0xF9), 0.4));
background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x8D, 0xD6, 0xF7), 0.4));
background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x8A, 0xD1, 0xF5), 1.0));
break;
case AeroFreezables.HoveredBackground:
background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xE3, 0xF7, 0xFF), 0.0));
background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xE3, 0xF7, 0xFF), 0.4));
background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xBD, 0xED, 0xFF), 0.4));
background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xB7, 0xE7, 0xFB), 1.0));
break;
case AeroFreezables.SortedBackground:
background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF2, 0xF9, 0xFC), 0.0));
//.........这里部分代码省略.........
示例13: InitializeImage
Image InitializeImage(Image image) {
image.Stretch = Filter(imageSourceService.Stretch);
image.StretchDirection = Filter(imageSourceService.StretchDirection);
image.Opacity = FilterOpacity(imageSourceService.Opacity);
image.Source = imageSourceService.ImageSource;
image.MaxHeight = FilterLength(imageSourceService.MaxHeight);
image.MaxWidth = FilterLength(imageSourceService.MaxWidth);
image.ClearValue(FrameworkElement.HeightProperty);
image.ClearValue(FrameworkElement.WidthProperty);
double scale = FilterZoom(imageSourceService.Zoom) / 100;
if (scale == 1)
image.LayoutTransform = Transform.Identity;
else {
var scaleTransform = new ScaleTransform(scale, scale);
scaleTransform.Freeze();
image.LayoutTransform = scaleTransform;
}
UpdateImagePosition(image);
return image;
}