本文整理汇总了C#中System.Windows.Controls.Canvas.UpdateLayout方法的典型用法代码示例。如果您正苦于以下问题:C# Canvas.UpdateLayout方法的具体用法?C# Canvas.UpdateLayout怎么用?C# Canvas.UpdateLayout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.Canvas
的用法示例。
在下文中一共展示了Canvas.UpdateLayout方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Export
/// <summary>
/// Exports the specified plot model to an xps file.
/// </summary>
/// <param name="model">The model.</param>
/// <param name="fileName">The file name.</param>
/// <param name="width">The width.</param>
/// <param name="height">The height.</param>
/// <param name="background">The background color.</param>
public static void Export(IPlotModel model, string fileName, double width, double height, OxyColor background)
{
using (var xpsPackage = Package.Open(fileName, FileMode.Create, FileAccess.ReadWrite))
{
using (var doc = new XpsDocument(xpsPackage))
{
var canvas = new Canvas { Width = width, Height = height, Background = background.ToBrush() };
canvas.Measure(new Size(width, height));
canvas.Arrange(new Rect(0, 0, width, height));
var rc = new ShapesRenderContext(canvas);
#if !NET35
rc.TextFormattingMode = TextFormattingMode.Ideal;
#endif
model.Update(true);
model.Render(rc, width, height);
canvas.UpdateLayout();
var xpsdw = XpsDocument.CreateXpsDocumentWriter(doc);
xpsdw.Write(canvas);
}
}
}
示例2: loader_RunWorkerCompleted
void loader_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
buff.UpdateLayout();
Canvas canvas = new Canvas();
canvas.Children.Add(buff);
canvas.Width = 512 * 13;
canvas.Height = 512 * 7;
canvas.UpdateLayout();
canvas.Measure(new Size((int)canvas.Width, (int)canvas.Height));
canvas.Arrange(new Rect(new Size((int)canvas.Width, (int)canvas.Height)));
int Height = ((int)(canvas.ActualHeight));
int Width = ((int)(canvas.ActualWidth));
RenderTargetBitmap _RenderTargetBitmap = new RenderTargetBitmap(Width, Height, 96, 96, PixelFormats.Pbgra32);
_RenderTargetBitmap.Render(buff);
Image img = new Image();
img.Source = _RenderTargetBitmap;
Viewer.PanoramaImage = _RenderTargetBitmap;
Title = "Demo.StreetView, enjoy! ;}";
}
示例3: RenderToRaster
private void RenderToRaster(IViewport viewport, ILayer layer, out IFeatures features)
{
var canvas = new Canvas();
MapRenderer.RenderLayer(canvas, viewport, layer);
canvas.UpdateLayout();
var bitmap = BitmapRendering.BitmapConverter.ToBitmapStream(canvas, viewport.Width, viewport.Height);
features = new Features { new Feature { Geometry = new Raster(bitmap, viewport.Extent) } };
}
示例4: CreateImage
/// <summary>
/// Renders a UI control into an image.
/// </summary>
/// <param name="control"></param>
/// <param name="isWideTile"></param>
/// <returns></returns>
public static void CreateImage(UIElement control, string imagePath, int width, int height, SolidColorBrush tileBackgroundColor)
{
// 1. Setup dimensions for wide tile.
var bmp = new WriteableBitmap(width, height);
// 2. Get the name of the background image based on theme
var canvas = new System.Windows.Controls.Canvas();
canvas.Width = width;
canvas.Height = height;
canvas.Background = tileBackgroundColor;
canvas.Children.Add(control);
canvas.Measure(new Size(width, height));
canvas.Arrange(new Rect(0, 0, width, height));
canvas.UpdateLayout();
// 4. Now output the control as text.
bmp.Render(canvas, null);
bmp.Invalidate();
// 8. Now save the image to local folder.
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
// FileMode.Open, FileAccess.Read, FileShare.Read,
using (var st = new IsolatedStorageFileStream(imagePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite, store))
{
bmp.SaveJpeg(st, width, height, 0, 100);
st.Close();
}
}
try
{
bmp = null;
canvas.Children.Clear();
GC.Collect();
GC.WaitForPendingFinalizers();
}
catch (Exception ex)
{
Slate.Core.Logging.Logger.Error("Create image", "Warning, attempt to clear up memory for tile image failed", ex);
}
}
示例5: Export
/// <summary>
/// Exports the specified plot model to a stream.
/// </summary>
/// <param name="model">The plot model.</param>
/// <param name="stream">The stream to write to.</param>
/// <param name="width">The width of the export image.</param>
/// <param name="height">The height of the exported image.</param>
/// <param name="background">The background.</param>
public static void Export(IPlotModel model, Stream stream, double width, double height, OxyColor background)
{
var canvas = new Canvas { Width = width, Height = height };
if (background.IsVisible())
{
canvas.Background = background.ToBrush();
}
canvas.Measure(new Size(width, height));
canvas.Arrange(new Rect(0, 0, width, height));
var rc = new SilverlightRenderContext(canvas);
model.Update(true);
model.Render(rc, width, height);
canvas.UpdateLayout();
var image = canvas.ToImage();
image.WriteToStream(stream);
}
示例6: MergeImages
public void MergeImages(string fl)
{
Canvas canvas = new Canvas();
if (zoom == 3)
{
canvas.Width = 512 * 6.5;
canvas.Height = 512 * 3.25;
}
else if (zoom == 2)
{
canvas.Width = 512 * 3.25;
canvas.Height = 512 * 1.625;
}
canvas.Measure(new Size((int)canvas.Width, (int)canvas.Height));
canvas.Arrange(new Rect(new Size((int)canvas.Width, (int)canvas.Height)));
int Height = ((int)(canvas.ActualHeight));
int Width = ((int)(canvas.ActualWidth));
StackPanel mainPanel = new StackPanel();
mainPanel.Orientation = Orientation.Vertical;
for (int j = 0; j < limitY; j++)
{
StackPanel ph = new StackPanel();
ph.Orientation = Orientation.Horizontal;
for (int k = 0; k < limitX; k++)
{
Image stackImg = new Image();
stackImg.Source = FromStream(previousJumpBuffStream[j][k]);
ph.Children.Add(stackImg);
}
mainPanel.Children.Add(ph);
}
mainPanel.UpdateLayout();
canvas.Children.Add(mainPanel);
canvas.UpdateLayout();
RenderTargetBitmap _RenderTargetBitmap = new RenderTargetBitmap((int)Width, (int)Height, 96, 96, PixelFormats.Pbgra32);
_RenderTargetBitmap.Render(mainPanel);
ImageSource mergedImages = _RenderTargetBitmap;
SaveImg(mergedImages, fl);
Stream s = File.OpenRead(fl);
buffStream.Add(s);
}
示例7: ExportToBitmap
/// <summary>
/// Exports the specified plot model to a bitmap.
/// </summary>
/// <param name="model">The plot model.</param>
/// <param name="width">The width.</param>
/// <param name="height">The height.</param>
/// <param name="background">The background.</param>
/// <param name="dpi">The resolution.</param>
/// <returns>A bitmap.</returns>
public static BitmapSource ExportToBitmap(PlotModel model, int width, int height, OxyColor background = null, int dpi = 96)
{
var canvas = new Canvas { Width = width, Height = height, Background = background.ToBrush() };
canvas.Measure(new Size(width, height));
canvas.Arrange(new Rect(0, 0, width, height));
var rc = new ShapesRenderContext(canvas) { RendersToScreen = false };
model.Update();
model.Render(rc, width, height);
canvas.UpdateLayout();
var bmp = new RenderTargetBitmap(width, height, dpi, dpi, PixelFormats.Pbgra32);
bmp.Render(canvas);
return bmp;
// alternative implementation:
// http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.rendertargetbitmap.aspx
// var dv = new DrawingVisual();
// using (var ctx = dv.RenderOpen())
// {
// var vb = new VisualBrush(canvas);
// ctx.DrawRectangle(vb, null, new Rect(new Point(), new Size(width, height)));
// }
// bmp.Render(dv);
}
示例8: DrawLines
private BitmapSource DrawLines(string transformedText, double scaleX, double scaleY)
{
var bitmap = new RenderTargetBitmap((int)(LayoutRoot.ActualWidth * scaleX), (int)(LayoutRoot.ActualHeight * scaleY), 96, 96, PixelFormats.Pbgra32);
Rect? lastRect = null;
var result = new byte[(int)(LayoutRoot.ActualWidth * scaleX) * 4 * (int)(LayoutRoot.ActualHeight * scaleY)];
foreach (var symbol in transformedText)
{
if (symbol < '1' || symbol > '9') continue;
var rect = ConvertNumberToCellCoords(symbol - '1');
rect.X *= scaleX;
rect.Y *= scaleY;
rect.Width *= scaleX;
rect.Height *= scaleY;
var color = new Color
{
A = 255,
R = LineColor.SelectedColor.Value.R,
G = LineColor.SelectedColor.Value.G,
B = LineColor.SelectedColor.Value.B
};
if (lastRect != null)
{
if (lastRect == rect)
{
var canvas = new Canvas();
var circle = new Ellipse
{
Stroke = new SolidColorBrush(color),
StrokeThickness = (LineSize.Value + 2) * (scaleX + scaleY) / 2
};
circle.Width = (LineSize.Value + 2) * 2 * scaleX;
circle.Height = (LineSize.Value + 2) * 2 * scaleY;
Canvas.SetLeft(circle, rect.Width / 2 - (LineSize.Value + 2) * scaleX + rect.Left);
Canvas.SetTop(circle, rect.Height / 2 - (LineSize.Value + 2) * scaleY + rect.Top);
canvas.Children.Add(circle);
canvas.Measure(new Size(rect.Width, rect.Height));
canvas.Arrange(new Rect(new Size(rect.Width, rect.Height)));
canvas.UpdateLayout();
bitmap.Render(canvas);
}
else
{
var lineLength =
Math.Sqrt(
Math.Abs(rect.Left - lastRect.Value.Left) *
Math.Abs(rect.Left - lastRect.Value.Left) +
Math.Abs(rect.Top - lastRect.Value.Top) *
Math.Abs(rect.Top - lastRect.Value.Top));
var proportion = lineLength / Math.Sin(Math.PI / 180 * 90);
var angle = Math.Asin(Math.Abs(rect.Top - lastRect.Value.Top) / proportion) * (180 / Math.PI);
if (rect.Left > lastRect.Value.Left && rect.Top == lastRect.Value.Top)
{
angle += 90;
}
if (rect.Left < lastRect.Value.Left && rect.Top == lastRect.Value.Top)
{
angle -= 90;
}
if (rect.Left == lastRect.Value.Left && rect.Top > lastRect.Value.Top)
{
angle += 90;
}
if (rect.Left == lastRect.Value.Left && rect.Top < lastRect.Value.Top)
{
angle -= 90;
}
if (rect.Left > lastRect.Value.Left && rect.Top > lastRect.Value.Top)
{
angle += 90;
}
if (rect.Left > lastRect.Value.Left && rect.Top < lastRect.Value.Top)
{
angle = Math.Asin(Math.Abs(rect.Left - lastRect.Value.Left) / proportion) * (180 / Math.PI);
}
if (rect.Left < lastRect.Value.Left && rect.Top < lastRect.Value.Top)
{
angle -= 90;
}
if (rect.Left < lastRect.Value.Left && rect.Top > lastRect.Value.Top)
{
angle = Math.Asin(Math.Abs(rect.Left - lastRect.Value.Left) / proportion) * (180 / Math.PI);
angle -= 180;
}
var canvas = new Canvas();
//.........这里部分代码省略.........
示例9: InsertBackgroundImage
public Image InsertBackgroundImage (Canvas BackGroundFrame, String BackgroundFileName)
{
Image BackgroundImage = new Image ();
BackgroundImage.Stretch = Stretch.UniformToFill;
BackGroundFrame.Children.Insert (0, BackgroundImage);
String BackgroundPath = BackgroundFileName;
if (!System.IO.Path.IsPathRooted (BackgroundPath))
BackgroundPath = System.IO.Path.Combine
(ProcessableDirectories [DirectoryToProcessIndex], BackgroundFileName);
if (!File.Exists (BackgroundPath))
return null;
BitmapImage BackgroundBitmap = new BitmapImage ();
BackgroundBitmap.BeginInit ();
BackgroundBitmap.UriSource = new Uri (BackgroundPath);
BackgroundBitmap.EndInit ();
BackgroundImage.Source = BackgroundBitmap;
BackGroundFrame.UpdateLayout ();
double CalculationWidth;
double CalculationHeight;
if (BackGroundFrame.ActualWidth > 1)
CalculationWidth = BackGroundFrame.ActualWidth;
else
CalculationWidth = BackGroundFrame.Width;
if (BackGroundFrame.ActualHeight > 1)
CalculationHeight = BackGroundFrame.ActualHeight;
else
CalculationHeight = BackGroundFrame.Height;
double SourceAspectRatio = BackgroundBitmap.Width / BackgroundBitmap.Height;
double TargetAspectRatio = CalculationWidth / CalculationHeight;
double TopPosition = 0;
double LeftPosition = 0;
if (SourceAspectRatio == TargetAspectRatio)
{
BackgroundImage.Width = CalculationWidth;
}
if (SourceAspectRatio < TargetAspectRatio)
{
BackgroundImage.Height = CalculationHeight;
BackgroundImage.UpdateLayout ();
LeftPosition = (CalculationWidth - (CalculationHeight * SourceAspectRatio)) / 2;
}
if (SourceAspectRatio > TargetAspectRatio)
{
BackgroundImage.Width = CalculationWidth;
BackgroundImage.UpdateLayout ();
TopPosition = (CalculationHeight - (CalculationWidth / SourceAspectRatio)) / 2;
}
Canvas.SetTop (BackgroundImage, TopPosition);
Canvas.SetLeft (BackgroundImage, LeftPosition);
return BackgroundImage;
}
示例10: InsertBackgroundData
BitmapImage InsertBackgroundData (Canvas ForecastFrame, String BackgroundName)
{
Image BackgroundImage = null;
if (ForecastFrame.Children.Count > 0)
BackgroundImage= (Image)ForecastFrame.Children [0];
if (BackgroundImage == null)
{
BackgroundImage = new Image ();
BackgroundImage.Stretch = Stretch.UniformToFill;
ForecastFrame.Children.Add (BackgroundImage);
}
String BackgroundPath = System.IO.Path.Combine (m_ProgrammRoot + "\\WeatherPictures", BackgroundName);
if (!File.Exists (BackgroundPath))
return null;
BitmapImage BackgroundBitmap = new BitmapImage ();
BackgroundBitmap.BeginInit ();
BackgroundBitmap.UriSource = new Uri (BackgroundPath);
BackgroundBitmap.EndInit ();
ForecastFrame.UpdateLayout ();
BackgroundImage.Width = ForecastFrame.ActualWidth;
BackgroundImage.Source = BackgroundBitmap;
BackgroundImage.UpdateLayout ();
double TopPosition = (ForecastFrame.ActualHeight - BackgroundImage.ActualHeight) / 2;
Canvas.SetTop (BackgroundImage, TopPosition);
return BackgroundBitmap;
}
示例11: InsertWeatherDetails
void InsertWeatherDetails (Canvas FramingCanvas, XmlNode Location, XmlNode ForecastNode, int LocationIndex, int WeatherIndex)
{
String [] PositionsTable = (String []) m_Districts [LocationIndex];
FramingCanvas.UpdateLayout ();
foreach (String Entry in PositionsTable)
{
String [] Elements = Entry.Split (';');
double WidthPercentage = Convert.ToDouble (Elements [0]);
double HeightPercentage = Convert.ToDouble (Elements [1]);
double TextSizePercentage = Convert.ToDouble (Elements [3]);
double IconWidthPercentage = Convert.ToDouble (Elements [4]);
if (WeatherIndex == 0)
SetAnimationParameter (FramingCanvas, (FrameworkElement)InsertCanvasPositionedText
(FramingCanvas, Elements [2], WidthPercentage, HeightPercentage,
TextSizePercentage, "Bold", "Black"), new PropertyPath (Image.OpacityProperty));
else
{
String WeatherName = "icon_" + ForecastNode.SelectSingleNode ("child::iconcode").InnerText + ".png";
SetAnimationParameter (FramingCanvas, (FrameworkElement)InsertCanvasPositionedIcons (FramingCanvas, WeatherName,
WidthPercentage, HeightPercentage, IconWidthPercentage), new PropertyPath (Image.OpacityProperty));
}
}
String [] SymbolsTable = (String [])m_Symbole [LocationIndex];
foreach (String SymbolEntry in SymbolsTable)
{
String [] SymbolElements = SymbolEntry.Split (';');
double SymbolWidthPercentage = Convert.ToDouble (SymbolElements [0]);
double SymbolHeightPercentage = Convert.ToDouble (SymbolElements [1]);
String TypeOfEntry = SymbolElements [2];
double TextSizePercentage = Convert.ToDouble (SymbolElements [3]);
double IconWidthPercentage = Convert.ToDouble (SymbolElements [4]);
if (WeatherIndex == 0)
continue;
if (TypeOfEntry == "WindRose")
{
String WindDirName = "wind_" + ForecastNode.SelectSingleNode
("child::winddir_text").InnerText + ".png";
SetAnimationParameter (FramingCanvas, (FrameworkElement)InsertCanvasPositionedIcons (FramingCanvas, WindDirName,
SymbolWidthPercentage, SymbolHeightPercentage, IconWidthPercentage),
new PropertyPath (Image.OpacityProperty));
}
if (TypeOfEntry == "WindGeschwindigkeit")
{
String WindSpeed = ForecastNode.SelectSingleNode ("child::windspeed").InnerText;
String WindSpeedString = WindSpeed + " km/h";
SetAnimationParameter (FramingCanvas, (FrameworkElement)InsertCanvasPositionedText (FramingCanvas, WindSpeedString,
SymbolWidthPercentage, SymbolHeightPercentage,
TextSizePercentage, "Bold", WeatherTextColor),
new PropertyPath (TextBlock.OpacityProperty));
}
if (TypeOfEntry == "WindRichtung")
{
String WindDir = ForecastNode.SelectSingleNode ("child::winddir_text").InnerText;
String WindDirText = "Wind aus " + WindDir;
SetAnimationParameter (FramingCanvas, (FrameworkElement)InsertCanvasPositionedText (FramingCanvas, WindDirText,
SymbolWidthPercentage, SymbolHeightPercentage,
TextSizePercentage, "Bold", WeatherTextColor),
new PropertyPath (TextBlock.OpacityProperty));
}
if (TypeOfEntry == "Temperatur")
{
String TempMin = ForecastNode.SelectSingleNode ("child::temp_min").InnerText;
String TempMax = ForecastNode.SelectSingleNode ("child::temp_max").InnerText;
String TempString;
if (String.Compare (TempMin, TempMax) != 0)
TempString = "Temp: " + TempMin + "° - " + TempMax + "°";
else
TempString = "Temp: " + TempMax + "°";
SetAnimationParameter (FramingCanvas, (FrameworkElement)InsertCanvasPositionedText (FramingCanvas, TempString,
SymbolWidthPercentage, SymbolHeightPercentage,
TextSizePercentage, "Bold", WeatherTextColor),
new PropertyPath (TextBlock.OpacityProperty));
}
}
}
示例12: InsertCanvasPositionedPicture
public Image InsertCanvasPositionedPicture (Canvas FramingCanvas, String Base64Input,
double LeftPercentage,
double TopPercentage,
double ImageWidthPercentage,
double ImageHeightPercentage)
{
Image PictureImage = new Image ();
FramingCanvas.Children.Add (PictureImage);
FramingCanvas.UpdateLayout ();
double ActCanvasHeight = FramingCanvas.ActualHeight;
double ActCanvasWidth = FramingCanvas.ActualWidth;
byte [] ImageBytes = System.Convert.FromBase64String (Base64Input);
MemoryStream ImageDataStream = new MemoryStream ();
ImageDataStream.Write (ImageBytes, 0, ImageBytes.Length);
ImageDataStream.Seek (0, SeekOrigin.Begin);
BitmapImage DrawingBitmap = new BitmapImage ();
//DrawingBitmap.CacheOption = BitmapCacheOption.OnLoad;
DrawingBitmap.BeginInit ();
DrawingBitmap.StreamSource = ImageDataStream;
DrawingBitmap.EndInit ();
if (ImageWidthPercentage > 0)
{
DrawingBitmap.DecodePixelWidth = (int)(ActCanvasWidth * ImageWidthPercentage / 100);
PictureImage.Width = ActCanvasWidth * ImageWidthPercentage / 100;
}
if (ImageHeightPercentage > 0)
{
DrawingBitmap.DecodePixelHeight = (int)(ActCanvasHeight * ImageHeightPercentage / 100);
PictureImage.Height = ActCanvasHeight * ImageHeightPercentage / 100;
}
PictureImage.Source = DrawingBitmap;
//PictureImage.Width = ActCanvasWidth * ImageWidthPercentage / 100;
PictureImage.UpdateLayout ();
//double ActIconHeight = PictureImage.ActualHeight;
//double ActIconWidth = PictureImage.ActualWidth;
Canvas.SetTop (PictureImage, ((ActCanvasHeight * TopPercentage) / 100));
Canvas.SetLeft (PictureImage, ((ActCanvasWidth * LeftPercentage) / 100));
return PictureImage;
}
示例13: DrawProgress
/// <summary>
/// Draw processing progress
/// </summary>
/// <param name="canvas">canvas where the progress will be drawn</param>
/// <param name="pp">active processing progress</param>
public static void DrawProgress(Canvas canvas, ProcessingProgress pp)
{
canvas.Background = ProfileManager.MinimalView ? System.Windows.Media.Brushes.Transparent : ProfileManager.ActiveProfile.BackgroundColor;
String currentOperationName = pp.CurrentOperationName;
Double currentOperation = ((Double)pp.CurrentOperationElement * 100 / (Double)pp.CurrentOperationTotalElements);
String currentOperationProgress = String.Format("{0:00.00}", currentOperation) + " %";
String overallOperationName = pp.OverallOperationName;
Double overallOperation = ((Double)pp.OverallOperationElement * 100 / (Double)pp.OverallOperationTotalElements);
String overallOperationProgress = String.Format("{0:00.00}", overallOperation) + " %";
canvas.Children.Clear();
double sixth = canvas.Height / 6;
double tenth = canvas.Width / 10;
//current
System.Windows.Shapes.Rectangle currentOperationOuterRect = new System.Windows.Shapes.Rectangle();
currentOperationOuterRect.Width = canvas.Width - tenth;
currentOperationOuterRect.Height = sixth;
currentOperationOuterRect.Stroke = ProfileManager.ActiveProfile.SecondaryColor;
currentOperationOuterRect.StrokeThickness = 2;
currentOperationOuterRect.Fill = ProfileManager.ActiveProfile.BackgroundColor;
currentOperationOuterRect.Margin = new Thickness(tenth / 2, sixth, 0, 0);
System.Windows.Shapes.Rectangle currentOperationInnerRect = new System.Windows.Shapes.Rectangle();
currentOperationInnerRect.Width = ((canvas.Width - tenth - 6) * currentOperation) / 100;
currentOperationInnerRect.Height = sixth - 6;
currentOperationInnerRect.Stroke = ProfileManager.ActiveProfile.BackgroundColor;
currentOperationInnerRect.StrokeThickness = 2;
currentOperationInnerRect.Fill = ProfileManager.ActiveProfile.SecondaryColor;
currentOperationInnerRect.Margin = new Thickness((tenth + 6) / 2, sixth + 3, 0, 0);
TextBlock currentOperationTextBlock = new TextBlock();
currentOperationTextBlock.Text = currentOperationName + " [ " + currentOperationProgress + " ]";
currentOperationTextBlock.Foreground = ProfileManager.ActiveProfile.SecondaryColor;
currentOperationTextBlock.FontSize = sixth / 1.5;
currentOperationTextBlock.Width = canvas.Width;
currentOperationTextBlock.FontFamily = new System.Windows.Media.FontFamily("Century Gothic");
currentOperationTextBlock.TextAlignment = TextAlignment.Center;
//overall
System.Windows.Shapes.Rectangle overallOperationOuterRect = new System.Windows.Shapes.Rectangle();
overallOperationOuterRect.Width = canvas.Width - tenth;
overallOperationOuterRect.Height = sixth;
overallOperationOuterRect.Stroke = ProfileManager.ActiveProfile.PrimaryColor;
overallOperationOuterRect.StrokeThickness = 2;
overallOperationOuterRect.Fill = ProfileManager.ActiveProfile.BackgroundColor;
overallOperationOuterRect.Margin = new Thickness(tenth / 2, 4 * sixth, 0, 0);
System.Windows.Shapes.Rectangle overallOperationInnerRect = new System.Windows.Shapes.Rectangle();
overallOperationInnerRect.Width = ProfileManager.MinimalView ? ((canvas.Width - tenth) * overallOperation) / 100 : ((canvas.Width - tenth - 6) * overallOperation) / 100;
overallOperationInnerRect.Height = ProfileManager.MinimalView ? sixth - 2 : sixth - 6;
overallOperationInnerRect.Stroke = ProfileManager.ActiveProfile.BackgroundColor;
overallOperationInnerRect.StrokeThickness = ProfileManager.MinimalView ? 0 : 2;
overallOperationInnerRect.Fill = ProfileManager.ActiveProfile.PrimaryColor;
overallOperationInnerRect.Margin = ProfileManager.MinimalView ? new Thickness(tenth / 2 + 1, 4 * sixth + 1, 0, 0) : new Thickness((tenth + 6) / 2, 4 * sixth + 3, 0, 0);
TextBlock overallOperationTextBlock = new TextBlock();
overallOperationTextBlock.Text = overallOperationName + " [ " + overallOperationProgress + " ]";
overallOperationTextBlock.Foreground = ProfileManager.ActiveProfile.PrimaryColor;
overallOperationTextBlock.FontSize = sixth / 1.5;
overallOperationTextBlock.Width = canvas.Width;
overallOperationTextBlock.Margin = new Thickness(0, 3 * sixth, 0, 0);
overallOperationTextBlock.FontFamily = new System.Windows.Media.FontFamily("Century Gothic");
overallOperationTextBlock.TextAlignment = TextAlignment.Center;
if (!ProfileManager.MinimalView) canvas.Children.Add(currentOperationTextBlock);
if (!ProfileManager.MinimalView) canvas.Children.Add(currentOperationOuterRect);
if (!ProfileManager.MinimalView) canvas.Children.Add(currentOperationInnerRect);
if (!ProfileManager.MinimalView) canvas.Children.Add(overallOperationTextBlock);
canvas.Children.Add(overallOperationOuterRect);
canvas.Children.Add(overallOperationInnerRect);
canvas.UpdateLayout();
canvas.Refresh();
}
示例14: Print
/// <summary>
/// Prints the specified plot model.
/// </summary>
/// <param name="model">The model.</param>
public void Print(IPlotModel model)
{
PrintDocumentImageableArea area = null;
var xpsDocumentWriter = PrintQueue.CreateXpsDocumentWriter(ref area);
if (xpsDocumentWriter != null)
{
var width = this.Width;
var height = this.Height;
if (double.IsNaN(width))
{
width = area.MediaSizeWidth;
}
if (double.IsNaN(height))
{
height = area.MediaSizeHeight;
}
var canvas = new Canvas { Width = width, Height = height, Background = this.Background.ToBrush() };
canvas.Measure(new Size(width, height));
canvas.Arrange(new Rect(0, 0, width, height));
var rc = new ShapesRenderContext(canvas);
#if !NET35
rc.TextFormattingMode = this.TextFormattingMode;
#endif
model.Update(true);
model.Render(rc, width, height);
canvas.UpdateLayout();
xpsDocumentWriter.Write(canvas);
}
}
示例15: Export
/// <summary>
/// Exports the specified plot model to a xml writer.
/// </summary>
/// <param name="model">The model.</param>
/// <param name="writer">The xml writer.</param>
/// <param name="width">The width.</param>
/// <param name="height">The height.</param>
/// <param name="background">The background.</param>
private static void Export(IPlotModel model, XmlWriter writer, double width, double height, OxyColor background)
{
var c = new Canvas();
if (background.IsVisible())
{
c.Background = background.ToBrush();
}
c.Measure(new Size(width, height));
c.Arrange(new Rect(0, 0, width, height));
var rc = new CanvasRenderContext(c) { UseStreamGeometry = false };
rc.TextFormattingMode = TextFormattingMode.Ideal;
model.Update(true);
model.Render(rc, width, height);
c.UpdateLayout();
XamlWriter.Save(c, writer);
}