本文整理汇总了C#中System.Windows.Controls.Image.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Image.SetValue方法的具体用法?C# Image.SetValue怎么用?C# Image.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.Image
的用法示例。
在下文中一共展示了Image.SetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDragVisual
private void CreateDragVisual()
{
ClearDragVisual();
var bitmap = new System.Windows.Media.Imaging.WriteableBitmap(this, null);
bitmap.Render(this, null);
bitmap.Invalidate();
_dragVisual = new System.Windows.Controls.Image();
_dragVisual.Source = bitmap;
// find topmost canvas.. (so we can add the drag visual as a child
// and ensure that it is on top of everything)
//
var canvas = this.GetTopmostParentOfType<Canvas>();
canvas.Children.Add(_dragVisual);
var point = this.GetRelativePosition(canvas);
_dragVisual.SetValue(Canvas.TopProperty, point.Y);
_dragVisual.SetValue(Canvas.LeftProperty, point.X);
// Really make sure the drag visual is on top
//
Canvas.SetZIndex(_dragVisual, Int16.MaxValue);
}
示例2: SetErrorDetected
internal static void SetErrorDetected(Image obj, bool value)
{
obj.SetValue(ErrorDetectedProperty, value);
}
示例3: SetIsLoading
internal static void SetIsLoading(Image obj, bool value)
{
obj.SetValue(IsLoadingProperty, value);
}
示例4: SetSource
public static void SetSource(Image obj, object value)
{
obj.SetValue(SourceProperty, value);
}
示例5: SetSourceType
public static void SetSourceType(Image obj, SourceType value)
{
obj.SetValue(SourceTypeProperty, value);
}
示例6: putImageData
public void putImageData(object imagedata, double dx, double dy)
{
if (double.IsNaN(dx) || double.IsInfinity(dx) || double.IsInfinity(dy) || double.IsNaN(dy))
{
throw new NotSupportedException(NOT_SUPPORTED_ERR);
}
if (!(imagedata is ImageData))
{
throw new Exception(TYPE_MISTMATCH_ERR);
}
var img = imagedata as ImageData;
// We are using 32 bit color.
int bytesPerPixel = 4;
// Where we are going to store our pixel information.
var pixels = new byte[img.height * img.width * bytesPerPixel];
byte[] data = Utils.ConvertJSArrayToByteArray(img.data);
for (int y = 0; y < img.height; y++)
{
for (int x = 0; x < img.width; x++)
{
int index = y * (int)img.width * 4 + x * 4;
pixels[index] = data[index];
pixels[index + 1] = data[index + 1];
pixels[index + 2] = data[index + 2];
pixels[index + 3] = data[index + 3];
}
}
// Where we are going to store our pixel information.
// Calculate the stride of the bitmap
int stride = (int)img.width * bytesPerPixel;
BitmapSource source = BitmapSource.Create((int)img.width, (int)img.height, 96, 96, PixelFormats.Pbgra32,
null,
pixels, stride);
source.Freeze();
var image = new Image();
image.Source = source;
image.SetValue(System.Windows.Controls.Canvas.TopProperty, dy);
image.SetValue(System.Windows.Controls.Canvas.LeftProperty, dx);
_surface.Children.Add(image);
}
示例7: SetDisplayWaitingAnimationDuringLoading
public static void SetDisplayWaitingAnimationDuringLoading(Image obj, bool value)
{
obj.SetValue(DisplayWaitingAnimationDuringLoadingProperty, value);
}
示例8: SetupCustomUIElements
public override void SetupCustomUIElements(Controls.dynNodeView nodeUI)
{
image1 = new System.Windows.Controls.Image
{
//Width = 320,
//Height = 240,
MaxWidth = 400,
MaxHeight = 400,
Margin = new Thickness(5),
HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
Name = "image1",
VerticalAlignment = System.Windows.VerticalAlignment.Center
};
//nodeUI.inputGrid.Children.Add(image1);
nodeUI.grid.Children.Add(image1);
image1.SetValue(Grid.RowProperty, 2);
image1.SetValue(Grid.ColumnProperty, 0);
image1.SetValue(Grid.ColumnSpanProperty, 3);
}
示例9: SetDisplayErrorThumbnailOnError
public static void SetDisplayErrorThumbnailOnError(Image obj, bool value)
{
obj.SetValue(DisplayErrorThumbnailOnErrorProperty, value);
}
示例10: drawImage
public void drawImage(object pImg, double dx, double dy, double dw, double dh)
{
if (pImg is ImageData)
{
var imageData = ((ImageData)pImg);
string url = imageData.src;
var image = new Image();
var imageSource = new BitmapImage();
if (_httpRegex.IsMatch(url))
{
var client = new WebClient();
byte[] bytes = client.DownloadData(url);
using (var memoryStream = new MemoryStream(bytes))
{
imageSource.BeginInit();
imageSource.StreamSource = memoryStream;
imageSource.EndInit();
}
}
else
{
imageSource = new BitmapImage();
imageSource.BeginInit();
imageSource.CacheOption = BitmapCacheOption.OnLoad;
imageSource.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
imageSource.UriSource = new Uri(url, UriKind.RelativeOrAbsolute);
imageSource.EndInit();
}
image.Source = imageSource;
image.SetValue(System.Windows.Controls.Canvas.TopProperty, dy);
image.SetValue(System.Windows.Controls.Canvas.LeftProperty, dx);
if (dw > 0 && dh > 0)
{
image.Width = dw;
image.Height = dh;
}
_surface.Children.Add(image);
imageData.width = (uint)image.Width;
imageData.height = (uint)image.Height;
}
if (OnPartialDraw != null)
{
OnPartialDraw();
}
}
示例11: OnArenaChange
public void OnArenaChange(object sender, EventArgs args)
{
BoardGrid.Children.Clear();
DisplayBoard();
DisplayBots();
DisplayBombs();
DisplayMissiles();
DisplayExplosions();
PlayersGrid.Children.Clear();
PlayersGrid.ColumnDefinitions.Clear();
for (int i = 0; i < _arena.Bots.Count; i++)
{
PlayersGrid.ColumnDefinitions.Add(new ColumnDefinition());
var botGrid = new Grid();
botGrid.SetValue(Grid.ColumnProperty, i);
var text = new TextBlock()
{
Text = _arena.Bots[i].Name,
Margin = new Thickness(1, 0, 0, 0),
FontSize = PlayersGrid.Height * 0.75
};
text.SetValue(Grid.ColumnProperty, 1);
var image = new Image()
{
Source = _arena.Bots[i].Image
};
image.SetValue(Grid.ColumnProperty, 0);
botGrid.Children.Add(image);
botGrid.Children.Add(text);
PlayersGrid.Children.Add(botGrid);
}
}
示例12: LoadImageFromUrl
private Size LoadImageFromUrl(string url, double dy, double dx)
{
var image = new Image();
//load image into Bitmap
Bitmap bmp = Utils.GetBitmapFromUrl(url);
var ms = new MemoryStream();
bmp.Save(ms, ImageFormat.Png);
//convert Drawing.Bitmap to Media.BitmapImage
var bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.StreamSource = ms;
bitmapImage.EndInit();
bitmapImage.Freeze();
//assign image's source
image.Source = bitmapImage;
image.SetValue(System.Windows.Controls.Canvas.TopProperty, dy);
image.SetValue(System.Windows.Controls.Canvas.LeftProperty, dx);
image.Width = bitmapImage.PixelWidth;
image.Height = bitmapImage.PixelHeight;
_surface.Children.Add(image);
return new Size(bitmapImage.PixelWidth, bitmapImage.PixelHeight);
}
示例13: makeApple
private Image makeApple(int numSides, int skip, double size, double spin, Point center, Brush brush,
Brush brushStroke, double strokeThickness, double opacity)
{
System.Windows.Controls.Image apple = new System.Windows.Controls.Image();
apple.Source = this.toBitmapImage(ShoopDoup.Properties.Resources.apple);
apple.SetValue(Canvas.LeftProperty, center.X);
apple.SetValue(Canvas.TopProperty, center.Y);
apple.Height = 150;
apples.Add(apple);
return apple;
}
示例14: SetDisplayOption
public static void SetDisplayOption(Image obj, DisplayOptions value)
{
obj.SetValue(DisplayOptionProperty, value);
}
示例15: PrepareImages
private void PrepareImages()
{
if (DesignerProperties.IsInDesignTool)
{
if (Film != null)
Film.Children.Clear();
offsetTop = 0;
for (int i = 1; i <= 200; i++)
{
imgNext = new System.Windows.Controls.Image();
imgNext.Source = new BitmapImage(new Uri("/Images/Effects/" + ImagesFolder + "/" + i + "." + ImageFilesExtension, UriKind.RelativeOrAbsolute));
imgNext.SetValue(Canvas.TopProperty, imageHeight * offsetTop++);
if (Film != null)
Film.Children.Add(imgNext);
}
if (Film != null)
Film.SetValue(Canvas.TopProperty, Math.Floor(CurrentImageNum - 1) * -imageHeight);
}
}