本文整理汇总了C#中System.Windows.Size类的典型用法代码示例。如果您正苦于以下问题:C# Size类的具体用法?C# Size怎么用?C# Size使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Size类属于System.Windows命名空间,在下文中一共展示了Size类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Create
public static Uri Create(string filename, string text, SolidColorBrush backgroundColor, double textSize, Size size)
{
var background = new Rectangle();
background.Width = size.Width;
background.Height = size.Height;
background.Fill = backgroundColor;
var textBlock = new TextBlock();
textBlock.Width = 500;
textBlock.Height = 500;
textBlock.TextWrapping = TextWrapping.Wrap;
textBlock.Text = text;
textBlock.FontSize = textSize;
textBlock.Foreground = new SolidColorBrush(Colors.White);
textBlock.FontFamily = new FontFamily("Segoe WP");
var tileImage = "/Shared/ShellContent/" + filename;
using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
{
var bitmap = new WriteableBitmap((int)size.Width, (int)size.Height);
bitmap.Render(background, new TranslateTransform());
bitmap.Render(textBlock, new TranslateTransform() { X = 39, Y = 88 });
var stream = store.CreateFile(tileImage);
bitmap.Invalidate();
bitmap.SaveJpeg(stream, (int)size.Width, (int)size.Height, 0, 99);
stream.Close();
}
return new Uri("ms-appdata:///local" + tileImage, UriKind.Absolute);
}
开发者ID:halllo,项目名称:DailyQuote,代码行数:29,代码来源:LockScreenImage.cs
示例2: XmlRenderer
public XmlRenderer(System.Windows.Size size)
{
Size = size;
m_stream = new MemoryStream();
m_writer = new XmlTextWriter(m_stream, Encoding.UTF8);
m_writer.Formatting = Formatting.Indented;
}
开发者ID:csuffyy,项目名称:circuitdiagram,代码行数:7,代码来源:XmlRenderer.cs
示例3: PreparePrinting
public void PreparePrinting(PrintTicket printTicket, Size pageSize)
{
printTicket.PageOrientation = pageSize.Height >= pageSize.Width ? PageOrientation.Portrait : PageOrientation.Landscape;
var printExtension = _reportProvider as IReportPrintExtension;
if (printExtension != null)
printExtension.PreparePrinting(printTicket, pageSize);
}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:7,代码来源:ReportViewModel.cs
示例4: MeasureOverride
protected override Size MeasureOverride(Size availableSize)
{
m_itemHeight = ItemRender.ItemHeight;
ScrollMax = Math.Max(0, m_itemHeight* (m_list == null? 0 : m_list.Count) - m_clipSize.Height + 2 * m_itemHeight);
ViewportSize = m_clipSize.Height;
return new Size(Width, ScrollMax );
}
开发者ID:grarup,项目名称:SharpE,代码行数:7,代码来源:FastListView.cs
示例5: MeasureOverride
protected override Size MeasureOverride(Size availableSize)
{
Size infiniteSize = new Size(double.PositiveInfinity, double.PositiveInfinity);
double curX = 0, curY = 0, curLineHeight = 0;
foreach (UIElement child in Children)
{
child.Measure(infiniteSize);
if (curX + child.DesiredSize.Width > availableSize.Width)
{ //Wrap to next line
curY += curLineHeight;
curX = 0;
curLineHeight = 0;
}
curX += child.DesiredSize.Width;
if (child.DesiredSize.Height > curLineHeight)
curLineHeight = child.DesiredSize.Height;
}
curY += curLineHeight;
Size resultSize = new Size();
resultSize.Width = double.IsPositiveInfinity(availableSize.Width)
? curX : availableSize.Width;
resultSize.Height = double.IsPositiveInfinity(availableSize.Height)
? curY : availableSize.Height;
return resultSize;
}
开发者ID:kiri11,项目名称:DrawTogether,代码行数:30,代码来源:AnimatedWrapPanel.cs
示例6: MeasureOverride
/// <summary>
/// Measures the size required for all the child elements in this panel.
/// </summary>
/// <param name="constraint">The size constraint given by our parent.</param>
/// <returns>The requested size for this panel including all children</returns>
protected override Size MeasureOverride(Size constraint)
{
double col1Width = 0;
double col2Width = 0;
RowHeights.Clear();
// First, measure all the left column children
for (int i = 0; i < VisualChildrenCount; i += 2)
{
var child = Children[i];
child.Measure(constraint);
col1Width = Math.Max(child.DesiredSize.Width, col1Width);
RowHeights.Add(child.DesiredSize.Height);
}
// Then, measure all the right column children, they get whatever remains in width
var newWidth = Math.Max(0, constraint.Width - col1Width - ColumnSpacing);
Size newConstraint = new Size(newWidth, constraint.Height);
for (int i = 1; i < VisualChildrenCount; i += 2)
{
var child = Children[i];
child.Measure(newConstraint);
col2Width = Math.Max(child.DesiredSize.Width, col2Width);
RowHeights[i / 2] = Math.Max(RowHeights[i / 2], child.DesiredSize.Height);
}
Column1Width = col1Width;
return new Size(
col1Width + ColumnSpacing + col2Width,
RowHeights.Sum() + ((RowHeights.Count - 1) * RowSpacing));
}
开发者ID:mikel785,项目名称:Logazmic,代码行数:34,代码来源:TwoColumnGrid.cs
示例7: ArrangeOverride
protected override Size ArrangeOverride (Size finalSize)
{
Tester.WriteLine ("ArrangeOverride input = " + finalSize.ToString ());
Size output = base.MeasureOverride (finalSize);
Tester.WriteLine ("ArrangeOverride output = " + output.ToString ());
return output;
}
开发者ID:dfr0,项目名称:moon,代码行数:7,代码来源:ShapeTest.cs
示例8: MeasureOverride
/// <summary>
/// Calculate the actual size because it is unknown otherwise, since we
/// are using a canvas.
/// </summary>
protected override Size MeasureOverride(Size constraint)
{
Size size = new Size();
foreach (UIElement element in this.InternalChildren)
{
double left = Canvas.GetLeft(element);
double top = Canvas.GetTop(element);
left = double.IsNaN(left) ? 0 : left;
top = double.IsNaN(top) ? 0 : top;
//measure desired size for each child
element.Measure(constraint);
Size desiredSize = element.DesiredSize;
if (!double.IsNaN(desiredSize.Width) && !double.IsNaN(desiredSize.Height))
{
size.Width = Math.Max(size.Width, left + desiredSize.Width);
size.Height = Math.Max(size.Height, top + desiredSize.Height);
}
}
// add margin
size.Width += 10;
size.Height += 10;
return size;
}
开发者ID:apoorv-vijay-joshi,项目名称:FSE-2011-PDE,代码行数:30,代码来源:GraphicalDepenedenciesCanvas.cs
示例9: PageCompositor
public PageCompositor(BookModel book, int fontSize, Size pageSize, IList<BookImage> images)
{
_book = book;
_fontSize = fontSize;
_pageSize = pageSize;
_images = images;
}
开发者ID:karbazol,项目名称:FBReaderCS,代码行数:7,代码来源:PageCompositor.cs
示例10: ArrangeOverride
protected override Size ArrangeOverride(Size finalSize)
{
if(ParentRow == null)
return base.ArrangeOverride(finalSize);
double totalWidth = 0d;
Children.OfType<TimespanHeaderCell>().ToList().ForEach(cell =>
{
double width = cell.DesiredSize.Width;
double x = totalWidth + ParentRow.CellBorderThickness.Left + ParentRow.CellBorderThickness.Right;
if (x + width > finalSize.Width)
{
width -= (x + width) - finalSize.Width;
}
if (width < 0)
width = 0;
cell.Arrange(new Rect(x, 0, width, finalSize.Height));
totalWidth += width;
}
);
return finalSize;
}
开发者ID:jogibear9988,项目名称:SlGanttChart,代码行数:28,代码来源:TimespanHeaderCellsPresenter.cs
示例11: ArrangeOverride
protected override Size ArrangeOverride( Size finalSize ) {
foreach ( UIElement child in this.InternalChildren ) {
child.Arrange( new Rect( new Point( 0, 0 ), child.DesiredSize ) );
}
return finalSize;
}
开发者ID:AIBrain,项目名称:gold_mine,代码行数:7,代码来源:stock.cs
示例12: MeasureOverride
//-------------------------------------------------------------------
//
// Protected Methods
//
//-------------------------------------------------------------------
#region Protected Methods
/// <summary>
/// Content measurement.
/// </summary>
/// <param name="constraint">Constraint size.</param>
/// <returns>Computed desired size.</returns>
protected sealed override Size MeasureOverride(Size constraint)
{
Size desiredSize = new Size();
if (_suspendLayout)
{
desiredSize = this.DesiredSize;
}
else if (Document != null)
{
// Create bottomless formatter, if necessary.
EnsureFormatter();
// Format bottomless content.
_formatter.Format(constraint);
// DesiredSize is set to the calculated size of the page.
// If hosted by ScrollViewer, desired size is limited to constraint.
if (_scrollData != null)
{
desiredSize.Width = Math.Min(constraint.Width, _formatter.DocumentPage.Size.Width);
desiredSize.Height = Math.Min(constraint.Height, _formatter.DocumentPage.Size.Height);
}
else
{
desiredSize = _formatter.DocumentPage.Size;
}
}
return desiredSize;
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:43,代码来源:FlowDocumentView.cs
示例13: MeasureOverride
protected override Size MeasureOverride(Size availableSize)
{
onPreApplyTemplate();
Size theChildSize = getItemSize();
foreach (UIElement child in Children)
{
child.Measure(theChildSize);
}
int childrenPerRow;
// Figure out how many children fit on each row
if (availableSize.Width == Double.PositiveInfinity)
{
childrenPerRow = this.Children.Count;
}
else
{
childrenPerRow = Math.Max(1, (int)Math.Floor(availableSize.Width / this.ItemWidth));
}
// Calculate the width and height this results in
double width = childrenPerRow * this.ItemWidth;
var fudge = (width - childrenPerRow * ItemWidth) / childrenPerRow;
double height = (this.ItemHeight +fudge )* (Math.Floor((double)(this.Children.Count +childrenPerRow - 1) / childrenPerRow) );
height = (height.IsValid()) ? height : 0;
return new Size(width, height);
}
开发者ID:heartszhang,项目名称:WeiZhi3,代码行数:31,代码来源:AnimatingTilePanel.cs
示例14: OnSourceInitialized
/// <inheritdoc/>
protected override void OnSourceInitialized(EventArgs e) {
base.OnSourceInitialized(e);
var hwndSource = PresentationSource.FromVisual(this) as HwndSource;
Debug.Assert(hwndSource != null);
if (hwndSource != null) {
hwndSource.AddHook(WndProc);
wpfDpi = new Size(96.0 * hwndSource.CompositionTarget.TransformToDevice.M11, 96.0 * hwndSource.CompositionTarget.TransformToDevice.M22);
var w = Width;
var h = Height;
WindowDpi = GetDpi(hwndSource.Handle) ?? wpfDpi;
// For some reason, we can't initialize the non-fit-to-size property, so always force
// manual mode. When we're here, we should already have a valid Width and Height
Debug.Assert(h > 0 && !double.IsNaN(h));
Debug.Assert(w > 0 && !double.IsNaN(w));
SizeToContent = SizeToContent.Manual;
if (!wpfSupportsPerMonitorDpi) {
double scale = DisableDpiScalingAtStartup ? 1 : WpfPixelScaleFactor;
Width = w * scale;
Height = h * scale;
if (WindowStartupLocation == WindowStartupLocation.CenterOwner || WindowStartupLocation == WindowStartupLocation.CenterScreen) {
Left -= (w * scale - w) / 2;
Top -= (h * scale - h) / 2;
}
}
}
WindowUtils.UpdateWin32Style(this);
}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:34,代码来源:MetroWindow.cs
示例15: MeasureOverride
protected override Size MeasureOverride (Size availableSize)
{
Tester.WriteLine ("MeasureOverride input = " + availableSize.ToString ());
Size output = base.MeasureOverride (availableSize);
Tester.WriteLine ("MeasureOverride output = " + output.ToString ());
return output;
}
开发者ID:dfr0,项目名称:moon,代码行数:7,代码来源:ShapeTest.cs
示例16: ZoomableInlineAdornment
public ZoomableInlineAdornment(UIElement content, ITextView parent, Size desiredSize) {
_parent = parent;
Debug.Assert(parent is IInputElement);
_originalSize = _desiredSize = new Size(
Math.Max(double.IsNaN(desiredSize.Width) ? 100 : desiredSize.Width, 10),
Math.Max(double.IsNaN(desiredSize.Height) ? 100 : desiredSize.Height, 10)
);
// First time through, we want to reduce the image to fit within the
// viewport.
if (_desiredSize.Width > parent.ViewportWidth) {
_desiredSize.Width = parent.ViewportWidth;
_desiredSize.Height = _originalSize.Height / _originalSize.Width * _desiredSize.Width;
}
if (_desiredSize.Height > parent.ViewportHeight) {
_desiredSize.Height = parent.ViewportHeight;
_desiredSize.Width = _originalSize.Width / _originalSize.Height * _desiredSize.Height;
}
ContextMenu = MakeContextMenu();
Focusable = true;
MinWidth = MinHeight = 50;
Children.Add(content);
GotFocus += OnGotFocus;
LostFocus += OnLostFocus;
}
开发者ID:omnimark,项目名称:PTVS,代码行数:29,代码来源:ZoomableInlineAdornment.cs
示例17: MeasureOverride
protected override Size MeasureOverride(Size availableSize)
{
dynamicOrder.Clear();
foreach (UIElement e in Children)
e.Measure(infiniteSize);
if (RowsToRender == 2)
{
Size size = FitsInDynamicRows(availableSize, 2, Children);
if (!size.IsEmpty)
return size;
}
else
{
List<UIElement> ordered = (from UIElement e in Children orderby e.DesiredSize.Width descending select e).ToList();
bool swap = false;
IEnumerable<UIElement> elements;
while ((elements = Get3Elements(ordered, swap)) != null)
{
swap ^= true;
foreach (UIElement e in elements)
dynamicOrder.Add(e);
}
Size size = FitsInDynamicRows(availableSize, 3, dynamicOrder);
if (!size.IsEmpty)
return size;
}
return new Size(48, 3*MaxSmallHeight);
}
开发者ID:CarverLab,项目名称:onCore.root,代码行数:32,代码来源:InternalGroupPanel.cs
示例18: Print
/// <summary>
/// Prints this instance.
/// </summary>
public bool Print()
{
try
{
PrintDialog printDlg = new System.Windows.Controls.PrintDialog();
bool? results = printDlg.ShowDialog();
if (results == null || results == false) return false;
//get selected printer capabilities
System.Printing.PrintCapabilities capabilities = printDlg.PrintQueue.GetPrintCapabilities(printDlg.PrintTicket);
//get the size of the printer page
System.Windows.Size printSize = new System.Windows.Size(
capabilities.PageImageableArea.ExtentHeight, capabilities.PageImageableArea.ExtentWidth);
// Build print view
this.Height = printSize.Height;
this.Width = printSize.Width;
Measure(printSize);
Arrange(new System.Windows.Rect(printSize));
XpsDocumentWriter xpsdw = PrintQueue.CreateXpsDocumentWriter(printDlg.PrintQueue);
printDlg.PrintTicket.PageOrientation = PageOrientation.Landscape;
xpsdw.WriteAsync(this);
}
catch (Exception ex)
{
MessageBox.Show(ex.GetBaseException().Message, "Printing Error", MessageBoxButton.OK, MessageBoxImage.Error);
return false;
}
return true;
}
开发者ID:bradsjm,项目名称:LaJustPowerMeter,代码行数:35,代码来源:GameImpactPrintView.xaml.cs
示例19: OnRender
protected override void OnRender(DrawingContext dc)
{
Size size = new Size(base.ActualWidth, base.ActualHeight);
int tickCount = (int)((this.Maximum - this.Minimum) / this.TickFrequency) + 1;
if ((this.Maximum - this.Minimum) % this.TickFrequency == 0)
tickCount -= 1;
Double tickFrequencySize;
// Calculate tick's setting
tickFrequencySize = (size.Width * this.TickFrequency / (this.Maximum - this.Minimum));
string text = "";
FormattedText formattedText = null;
double num = this.Maximum - this.Minimum;
int i = 0;
// Draw each tick text
for (i = 0; i <= tickCount; i++)
{
text = Convert.ToString(Convert.ToInt32(this.Minimum + this.TickFrequency * i), 10);
//g.DrawString(text, font, brush, drawRect.Left + tickFrequencySize * i, drawRect.Top + drawRect.Height/2, stringFormat);
formattedText = new FormattedText(text, CultureInfo.GetCultureInfo("ru-Ru"), FlowDirection.LeftToRight, new Typeface("Arial"), 8, Brushes.Black);
dc.DrawText(formattedText, new Point((tickFrequencySize * i), 30));
}
}
开发者ID:leks4leks,项目名称:ProgressoExpert,代码行数:25,代码来源:NumberedTickBar.cs
示例20: AddAsHtml
public IClipboardObject AddAsHtml(FrameworkElement fe, Size imageSize, Size imageElementSize)
{
if (fe == null)
throw new NullReferenceException(nameof(fe));
var bmp = fe.RenderToBitmap(imageSize);
var img_src = string.Empty;
var use_inline_image = false;
if (use_inline_image)
{
// Inline images are not actually supported by Office applications, so don't use it.
// maybe in future...
var img_data = bmp.ToBitmap().ToArray();
var base64_img_data = Convert.ToBase64String(img_data);
img_src = $"data:image/png;charset=utf-8;base64, {base64_img_data}";
}
else
{
// create a temp file with image and use it as a source
var tmp = Path.GetTempFileName();
bmp.Save(tmp);
img_src = new Uri(tmp, UriKind.Absolute).ToString();
}
var html_data = CF_HTML.PrepareHtmlFragment($"<img height=\"{imageElementSize.Height}\" width=\"{imageElementSize.Width}\" src=\"{img_src}\" />");
Data.SetData(DataFormats.Html, html_data);
return this;
}
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:32,代码来源:IClipboardService.cs
注:本文中的System.Windows.Size类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论