当前位置: 首页>>代码示例>>C#>>正文


C# Image.SetValue方法代码示例

本文整理汇总了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);

                }
            }
        }
开发者ID:OneOne,项目名称:trash-2012,代码行数:31,代码来源:Map.xaml.cs

示例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);
                    }
                }
            }
        }
开发者ID:Kopacb007,项目名称:Lineage_2,代码行数:34,代码来源:MainWindow.xaml.cs

示例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();
        }
开发者ID:jhy871167495,项目名称:Bornander.UI.AnimationsCS,代码行数:29,代码来源:GridBackground.xaml.cs

示例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);
                }
            }
        }
开发者ID:tiagobabo,项目名称:windows-phone-gallery,代码行数:32,代码来源:LocalStorage.xaml.cs

示例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;
        }
开发者ID:JeroenEgelmeers,项目名称:Sokoban,代码行数:29,代码来源:GameLayer.cs

示例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;
        }
开发者ID:DeveloperSkeletor,项目名称:QuickStarters,代码行数:56,代码来源:ButtonOption.cs

示例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;
        }
开发者ID:rringham,项目名称:XamarinOffice365,代码行数:52,代码来源:StartupPage.cs

示例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;

        }
开发者ID:GentleMime,项目名称:QuickStarters,代码行数:52,代码来源:HubPanel.cs

示例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);
        }
开发者ID:koty,项目名称:ImageComparer,代码行数:15,代码来源:MainWindow.xaml.cs

示例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;
        }
开发者ID:donie81,项目名称:ia-licence-plate-detection,代码行数:34,代码来源:Form1.cs

示例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);
            }

        }
开发者ID:chandrachivukula,项目名称:hue,代码行数:25,代码来源:LightOverviewControl.xaml.cs

示例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");
        }
开发者ID:remingtonsteel,项目名称:accord-net-extensions,代码行数:26,代码来源:TestPerformance.cs

示例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);
        }
开发者ID:Hagser,项目名称:csharp,代码行数:25,代码来源:MouseMove.xaml.cs

示例14: SetSource

 public static void SetSource(Image img, string value)
 {
     if (img != null)
     {
         img.SetValue(SourceProperty, value);
     }
 }
开发者ID:kamaelyoung,项目名称:Ichongli.Rosi,代码行数:7,代码来源:ThinkImage.cs

示例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++;
 }
开发者ID:tjpiggott,项目名称:PhotoBook,代码行数:16,代码来源:MediaGallery.cs


注:本文中的Image.SetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。