本文整理汇总了C#中Image.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Image.SetValue方法的具体用法?C# Image.SetValue怎么用?C# Image.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image
的用法示例。
在下文中一共展示了Image.SetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetGrid
public void SetGrid()
{
for (int i = 0; i < MyCity.Width; i++)
{
for (int j = 0; j < MyCity.Height; j++)
{
Image img = new Image();
img.Width = 100;
img.Height = 100;
img.Stretch = Stretch.Uniform;
img.SetValue(Grid.ColumnProperty, j);
img.SetValue(Grid.RowProperty, i);
try
{
img.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
MyCity.Map[i, j].Tile.GetHbitmap(),
IntPtr.Zero,
Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions());
}
catch (Exception e)
{
Console.WriteLine("Error when converting ressource into image : " + e.Message);
}
RootGrid.Children.Add(img);
}
}
}
示例2: UpdatePlayerPositionUI
public void UpdatePlayerPositionUI()
{
// Firstly we need to clear our array
for (int row = 0; row < World.PlayerLayerArray.GetLength(0); row++)
{
for (int column = 0; column < World.PlayerLayerArray.GetLength(1); column++)
{
World.PlayerLayerArray[row, column] = null;
}
}
//Positioning the player on his own grid
for (int row = 0; row < World.GroundLayerArray.GetLength(0); row++)
{
for (int column = 0; column < World.GroundLayerArray.GetLength(1); column++)
{
if (World.LocationByID(World.GroundLayerArray[row, column]) == _player.CurrentLocation)
{
World.PlayerLayerArray[row, column] = _player;
Image finalImage = new Image();
finalImage.Width = 100;
finalImage.Height = 100;
finalImage.Source = new BitmapImage(Player.HeroUri);
finalImage.Margin = new Thickness(0);
finalImage.SetValue(Grid.RowProperty, row);
finalImage.SetValue(Grid.ColumnProperty, column);
gridPlayerLayer.Children.Clear();
gridPlayerLayer.Children.Add(finalImage);
}
}
}
}
示例3: GridBackground
public GridBackground()
{
InitializeComponent();
backgroundGrid.SizeChanged += GridBackground_SizeChanged;
backgroundGrid.Animator = new FractionDistanceAnimator(0.1);
foreach (string name in new[] { "Jellyfish", "Koala", "Penguins" })
{
backgrounds[name] = new List<UIElement>();
BitmapSource[,] tiles = SplitImage(LoadImage(String.Format(@"Images\{0}.jpg", name)), NumberOfRows, NumberOfColumns);
for (int row = 0; row < NumberOfRows; ++row)
{
for (int column = 0; column < NumberOfColumns; ++column)
{
Image image = new Image();
image.Source = tiles[row, column];
image.SetValue(Grid.RowProperty, row);
image.SetValue(Grid.ColumnProperty, column);
backgroundGrid.Children.Add(image);
backgrounds[name].Add(image);
}
}
}
RecalculateOffscreenPoints();
SizeChanged += (s, e) => RecalculateOffscreenPoints();
}
示例4: PopulateImageGrid
private void PopulateImageGrid()
{
MediaLibrary mediaLibrary = new MediaLibrary();
var pictures = mediaLibrary.Pictures;
for (int i = 0; i < pictures.Count; i += Utilities.ImagesPerRow)
{
RowDefinition rd = new RowDefinition();
rd.Height = new GridLength(Utilities.GridRowHeight);
grid1.RowDefinitions.Add(rd);
int maxPhotosToProcess = (i + Utilities.ImagesPerRow < pictures.Count ? i + Utilities.ImagesPerRow : pictures.Count);
int rowNumber = i / Utilities.ImagesPerRow;
for (int j = i; j < maxPhotosToProcess; j++)
{
BitmapImage image = new BitmapImage();
image.SetSource(pictures[j].GetImage());
Image img = new Image();
img.Height = Utilities.ImageHeight;
img.Stretch = Stretch.Fill;
img.Width = Utilities.ImageWidth;
img.HorizontalAlignment = HorizontalAlignment.Center;
img.VerticalAlignment = VerticalAlignment.Center;
img.Source = image;
img.SetValue(Grid.RowProperty, rowNumber);
img.SetValue(Grid.ColumnProperty, j - i);
img.Tap += Image_Tap;
grid1.Children.Add(img);
}
}
}
示例5: ShowGrid
public Grid ShowGrid()
{
Grid grid = new Grid();
for (var i = 0; i < tileLayer.Count; i++)
{
RowDefinition row = new RowDefinition();
grid.RowDefinitions.Add(row);
for (var j = 0; j < tileLayer[i].Count; j++)
{
ColumnDefinition col = new ColumnDefinition();
grid.ColumnDefinitions.Add(col);
List<Tile> sublist = tileLayer[i];
Tile temp = sublist[j];
Image img = new Image();
img.Source = temp.BackgroundImage;
img.SetValue(Grid.ColumnProperty, j);
img.SetValue(Grid.RowProperty, i);
img.Stretch = Stretch.UniformToFill;
grid.Children.Add(img);
}
}
return grid;
}
示例6: ButtonOption
public ButtonOption(string option, Action action)
{
this.grid = new Grid();
grid.HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center;
grid.VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Center;
grid.Width = 475;
grid.Height = 139;
grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Proportional) });
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) });
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Proportional) });
Button b_option = new Button()
{
Text = string.Empty,
IsBorder = false,
BackgroundImage = Directories.Textures + option + "_bt.png.wpk",
PressedBackgroundImage = Directories.Textures + option + "_bt_pressed.png.wpk",
VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Center,
HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center,
};
b_option.Click += (s, o) => action();
b_option.SetValue(GridControl.RowProperty, 0);
b_option.SetValue(GridControl.ColumnProperty, 0);
grid.Add(b_option);
TextBlock t_option = new TextBlock()
{
Width = 322,
Height = 65,
FontPath = WaveContent.Assets.Fonts.Gotham_Bold_16_ttf,
Text = option.ToUpper(),
VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Center,
HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center,
DrawOrder = 0.4f,
Margin = new WaveEngine.Framework.UI.Thickness(0, 13, 0,0)
};
t_option.SetValue(GridControl.RowProperty, 0);
t_option.SetValue(GridControl.ColumnProperty, 1);
grid.Add(t_option);
Image bg_option = new Image(WaveContent.Assets.Textures.bg_options_pause_PNG)
{
VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Center,
HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center,
Margin = new WaveEngine.Framework.UI.Thickness(-45,0,0,0),
DrawOrder = 0.9f,
};
bg_option.SetValue(GridControl.RowProperty, 0);
bg_option.SetValue(GridControl.ColumnProperty, 1);
grid.Add(bg_option);
this.entity = grid.Entity;
}
示例7: SetupContentView
private View SetupContentView()
{
Grid grid = new Grid {
VerticalOptions = LayoutOptions.FillAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
RowDefinitions = {
new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }
},
};
// Background.jpg: Macro Background Print 9 by Jason Weymouth Photography (https://www.flickr.com/photos/jason_weymouth/)
// License: Attribution-ShareAlike 2.0 Generic (https://creativecommons.org/licenses/by-sa/2.0/)
// Additional license information can be found in Background.jpg.license in root of repository.
Image backgroundImage = new Image { Source = "Background.jpg", HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, Aspect = Aspect.AspectFill, Opacity = 1 };
backgroundImage.SetValue(Grid.RowSpanProperty, 1);
backgroundImage.SetValue(Grid.ColumnSpanProperty, 1);
grid.Children.Add(backgroundImage);
StackLayout mask = new StackLayout { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Black, Opacity = 0.1 };
mask.SetValue(Grid.RowSpanProperty, 1);
mask.SetValue(Grid.ColumnSpanProperty, 1);
grid.Children.Add(mask);
ScrollView scrollView = new ScrollView
{
VerticalOptions = LayoutOptions.FillAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
Orientation = ScrollOrientation.Vertical
};
StackLayout loginLayout = new StackLayout
{
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center,
Spacing = 10
};
Label loginLabel = new Label { Text = "Login to Xamarin Office 365 Demo", TextColor = Color.White, FontSize = 24 };
loginLayout.Children.Add(new StackLayout { Children = { loginLabel }, Padding = new Thickness(0,0,0,30) });
Button loginButton = new Button { Text = "Log In", FontSize = 18, TextColor = Color.White, BackgroundColor = Color.FromRgb(45, 180, 40), BorderColor = Color.White, BorderRadius = 5, BorderWidth = 1 };
loginButton.Clicked += LoginButton_Clicked;
loginLayout.Children.Add(loginButton);
scrollView.Content = loginLayout;
grid.Children.Add(scrollView);
Label backgroundAttributionLabel = new Label { Text = "Macro Background Print 9 by Jason Weymouth Photography", TextColor = Color.White, FontSize = 12 };
grid.Children.Add(new StackLayout { Children = { backgroundAttributionLabel }, HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.End, Padding = new Thickness(10,0,0,6) });
return grid;
}
示例8: HubPanel
public HubPanel()
{
Grid grid = new Grid("HubPanel")
{
HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center,
VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Top,
Width = 800,
Height = 40,
};
grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Proportional) });
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Proportional) });
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Proportional) });
Image background = new Image(WaveContent.Assets.Textures.hubBackground_png);
background.SetValue(GridControl.RowProperty, 0);
background.SetValue(GridControl.ColumnProperty, 0);
grid.Add(background);
// Life
this.progressBar = new ProgressBar()
{
Height = 25,
Width = 300,
Foreground = Color.Gold,
Background = Color.Red,
HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center,
VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Center,
DrawOrder = -1
};
progressBar.SetValue(GridControl.RowProperty, 0);
progressBar.SetValue(GridControl.ColumnProperty, 0);
grid.Add(progressBar);
// Murders
this.murdersText = new TextBlock()
{
DrawOrder = -1,
FontPath = WaveContent.Assets.Fonts.Coalition_16_ttf,
Text = "#00",
HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center,
VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Bottom,
};
murdersText.SetValue(GridControl.RowProperty, 0);
murdersText.SetValue(GridControl.ColumnProperty, 1);
grid.Add(murdersText);
this.entity = grid.Entity;
}
示例9: moveImage
private static void moveImage(Image image, MouseEventArgs e, Point offset)
{
var canvas = image.Parent as Canvas;
if (canvas == null) return;
// Get the position of the mouse relative to the canvas
var mousePoint = e.GetPosition(canvas);
// Offset the mouse position by the original offset position
mousePoint.Offset(-offset.X, -offset.Y);
// Move the element on the canvas
image.SetValue(Canvas.LeftProperty, mousePoint.X);
image.SetValue(Canvas.TopProperty, mousePoint.Y);
}
示例10: FilterPlate
private static Image<Gray, Byte> FilterPlate(Image<Gray, Byte> plate)
{
Image<Gray, Byte> thresh = plate.ThresholdBinaryInv(new Gray(120), new Gray(255));
Image<Gray, Byte> plateMask = new Image<Gray, byte>(plate.Size);
Image<Gray, Byte> plateCanny = plate.Canny(new Gray(100), new Gray(50));
MemStorage stor = new MemStorage();
{
plateMask.SetValue(255.0);
for (
Contour<Point> contours = plateCanny.FindContours(
Emgu.CV.CvEnum.CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE,
Emgu.CV.CvEnum.RETR_TYPE.CV_RETR_EXTERNAL,
stor);
contours != null; contours = contours.HNext)
{
Rectangle rect = contours.BoundingRectangle;
if (rect.Height > (plate.Height >> 1))
{
rect.X -= 1; rect.Y -= 1; rect.Width += 2; rect.Height += 2;
rect.Intersect(plate.ROI);
plateMask.Draw(rect, new Gray(0.0), -1);
}
}
thresh.SetValue(0, plateMask);
}
thresh._Erode(1);
thresh._Dilate(1);
return thresh;
}
示例11: UpdateDisplayList
public void UpdateDisplayList()
{
List<int> hueList = new List<int>();
ThumbCanvas.Children.Clear();
foreach(var light in BridgeManager.Instance.CurrentBridge.LightList)
{
if (!hueList.Contains(light.Hue))
{
hueList.Add(light.Hue);
}
}
for (int i = 0; i < hueList.Count; i++ )
{
var thumb = new Image();
var offset = hueList[i] / (float)Light.MaxHue;
thumb.Source = new BitmapImage(new Uri("ms-appx:///Assets/LightOverviewThumb.png"));
thumb.Width = 10;
thumb.Height = 10;
thumb.SetValue(Canvas.LeftProperty, offset * ActualWidth);
ThumbCanvas.Children.Add(thumb);
}
}
示例12: TestChannelModifier
public static void TestChannelModifier()
{
var bmp = (System.Drawing.Bitmap)System.Drawing.Bitmap.FromFile(colorImgName);
var image = bmp.ToImage<Bgr, byte>();
UnmanagedImage uIm = UnmanagedImage.FromManagedImage(bmp);
measure(() =>
{
var hsvIm = image.Convert<Hsv, byte>();
var hue = new Image<Gray, byte>(hsvIm.Size);
hue.SetValue(180 / 2);
hsvIm[Hsv.IdxH] = hue;
var modifiedIm = hsvIm.Convert<Bgr, byte>();
},
() =>
{
AForge.Imaging.Filters.HueModifier hm = new AForge.Imaging.Filters.HueModifier(180);
hm.Apply(uIm);
},
100,
"Image<,> Hue modifier",
"AForge Hue modifier");
}
示例13: AddImage
private void AddImage(PhotoInfo photoInfo)
{
int imax = LayoutRoot.Children.Count;
int icnt = 0;
if (imax > 50)
{
LayoutRoot.Children.RemoveAt(1);
}
foreach (UIElement el in LayoutRoot.Children)
{
if (el.GetType() == typeof(Image))
{
icnt++;
Image elimg = (el as Image);
elimg.RenderTransform = new SkewTransform() { AngleX = 360 - (imax - icnt), AngleY = 360 - (imax - icnt) };
double dop = double.Parse(icnt.ToString()) / double.Parse(imax.ToString());
elimg.Opacity = dop;
}
}
Image img = new Image() { Source = photoInfo.ImageSource, Height = LayoutRoot.RowDefinitions[0].Height.Value,Margin=new Thickness(30), VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch, Stretch = Stretch.Uniform };
img.SetValue(Grid.RowProperty, 0);
LayoutRoot.Children.Add(img);
}
示例14: SetSource
public static void SetSource(Image img, string value)
{
if (img != null)
{
img.SetValue(SourceProperty, value);
}
}
示例15: addImageToGalleryCanvas
private void addImageToGalleryCanvas(BitmapImage bitmapImage, double positionFromLeft, double positionFromTop)
{
Image mediaGalleryItem = new Image
{
Source = bitmapImage,
Width = 150,
Height = 150,
Name = "image" + numberOfImages
};
mediaGalleryItem.SetValue(Canvas.LeftProperty, positionFromLeft);
mediaGalleryItem.SetValue(Canvas.TopProperty, positionFromTop);
mediaGalleryItem.Tap += mediaGalleryPictureTapped;
mediaGalleryCanvas.Children.Add(mediaGalleryItem);
picturesInCurrentRow++;
numberOfImages++;
}