public VideoStreamDisplay(System.Windows.Controls.Image img, int rotationAngle, Uri streamUri)
 {
     _dispImage = img;
     _rotationAngle = rotationAngle;
     _streamUri = streamUri;
     _decoder.FrameReady += handleFrameFn;
 }
        // Deserializes a serialized grid tile, making it fit for use in our editor grid.
        public GridTile DeserializeGridTile(GridTileSerializable tile)
        {
            if (tile.Image == null) return null;

            try
            {
                // Effectively creating an image out of the byte array in the serialized grid tile.
                Image myImage = new Image();
                using (MemoryStream stream = new MemoryStream(tile.Image))
                {
                    PngBitmapDecoder decoder = new PngBitmapDecoder(stream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad);
                    BitmapSource bitmapSource = decoder.Frames[0];
                    myImage.Source = bitmapSource;
                }

                return new GridTile(tile.Rotation, tile.Id, myImage, tile.CollisionMap)
                {
                    Row = tile.Row,
                    Column = tile.Column,
                    CollisionMap = tile.CollisionMap
                };
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return null;
            }
        }
Ejemplo n.º 3
0
        private static void ViewCursor(Image img, string source)
        {
            var cursor = GetCursor(source);
            if (cursor == null)
            {
                return;
            }

            using (var bmp = new Bitmap(cursor.Size.Width, cursor.Size.Height))
            {
                using (var g = Graphics.FromImage(bmp))
                {
                    var drawingRect = new Rectangle(0, 0, cursor.Size.Width, cursor.Size.Height);
                    g.FillRectangle(Brushes.White, drawingRect);
                    cursor.Draw(g, drawingRect);
                }
                var ms = new MemoryStream();
                bmp.Save(ms, ImageFormat.Bmp);
                ms.Seek(0, SeekOrigin.Begin);
                var bi = new BitmapImage();
                bi.BeginInit();
                bi.StreamSource = ms;
                bi.EndInit();
                img.Source = bi;
            }
        }
Ejemplo n.º 4
0
 private void Chooser_Load(object sender, EventArgs e)
 {
     //label2.Text = CardName;
     Guid card = Guid.Empty;
     string[] list = new string[SetList.Count];
     int i = 0;
     foreach (CardModel Card in SetList)
     {
         Set CardSet = Card.Set;
         list[i] = CardSet.Name;
         i++;
     }
     List<string> unique = new List<string>();
     unique.AddRange(list.Distinct());
     comboChooser.Sorted = true;
     foreach (string setname in unique) { comboChooser.Items.Add(setname); }
     comboChooser.Text = comboChooser.Items[0].ToString();
     // Default Image
     GamesRepository proxy = new GamesRepository();
     Game mygame = proxy.Games[GameIndex];
     card = SetList[0].Id;
     label2.Text = SetList[0].Name;
     BitmapImage img = new BitmapImage();
     System.Windows.Controls.Image CardImage = new System.Windows.Controls.Image();
     mtgPicture1.Image = SourceConvert.BitmapFromUri(img != null ? CardModel.GetPictureUri(mygame,
         mygame.GetCardById(card).Set.Id, mygame.GetCardById(card).ImageUri) : mygame.GetCardBackUri());
     selectedCard = card;
 }
Ejemplo n.º 5
0
		public static Image GetWpfCompatibleImage(System.Drawing.Image image, int newWidth = -1, int maxHeight = -1, string cachedName = null)
		{
			Image result = null;
			string uriPath;
			var filePath = GetImageFilePath(cachedName, out uriPath);

			try
			{
				if (image != null)
				{
					if (!File.Exists(filePath))
					{
						var img = newWidth > 0
							? Shared.Utility.ResizeImage(image, newWidth, maxHeight)
							: image;
						img.Save(filePath, ImageFormat.Png);
					}
					result = new Image { Source = new BitmapImage(new Uri(filePath)) };
				}
			}
			catch (Exception e)
			{
				Logger.TraceErr(MethodBase.GetCurrentMethod(), e);
			}
			return result;
		}
Ejemplo n.º 6
0
        private int _refresherY; //HAND coordinate

        #endregion Fields

        #region Constructors

        public Radar(Image imageBox)
        {
            ImageBox = imageBox;

            _bitmapWidth = (int)imageBox.Width;
            _bitmapHeight = (int)imageBox.Height;

            _offset = (_bitmapWidth - Constans.RADAR_WIDTH) / 2;

            //create Bitmap
            Bmp = new Bitmap(_bitmapHeight, _bitmapWidth);

            //center
            _centerX = (int)imageBox.Height / 2;
            _centerY = (int)imageBox.Width / 2;

            //initial degree of HAND
            _currentDegree = 0;

            //timer
            _timer.Interval = 1; //in millisecond
            _timer.Tick += ReloadRadar;

            _landscape = LandscapeProvider.CreateLandscape();

            //Draw start position of radar
            ReloadRadar(null, null);
        }
Ejemplo n.º 7
0
 public ProcessInfo(string processName, int processId, string processPath, Image processIcon)
 {
     ProcessName = processName;
     ProcessPath = processPath;
     ProcessId = processId;
     ProcessIcon = processIcon;
 }
Ejemplo n.º 8
0
 public ProcessInfo()
 {
     ProcessName = "processName";
     ProcessPath = "processPath";
     ProcessId = 0;
     ProcessIcon = new Image();
 }
Ejemplo n.º 9
0
 public WebCamWindow(string applicationName)
 {
     InitializeComponent();
     _webCam = new WebCamCapture { FrameNumber = ((0ul)), TimeToCapture_milliseconds = FrameNumber };
     _webCam.ImageCaptured += webCam_ImageCaptured;
     _frameImage = SourceImage;
     _applicationName = applicationName;
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Adds the picture to the rich textbox.
 /// </summary>
 /// <param name="imagelocation">The imagelocation.</param>
 private void AddPicture(string imagelocation)
 {
     var bitmap = new BitmapImage(new Uri(imagelocation));
     var image = new Image {Source = bitmap, Width = 35};
     var uiContainer = new InlineUIContainer(image);
     var tp = txtMessageToSend.CaretPosition;
     if (tp.Paragraph != null) tp.Paragraph.Inlines.Add(uiContainer);
 }
Ejemplo n.º 11
0
 private static UIElement PrintPage(BitmapSource bitmap)
 {
     var bitmapSize = new System.Windows.Size(bitmap.PixelWidth, bitmap.PixelHeight);
     var image = new System.Windows.Controls.Image { Source = bitmap };
     image.Measure(bitmapSize);
     image.Arrange(new System.Windows.Rect(new System.Windows.Point(0, 0), bitmapSize));
     return image;
 }
Ejemplo n.º 12
0
        private System.Windows.Media.ImageSource convertDrawingImageToWPFImage(System.Drawing.Image gdiImg)
        {
            System.Windows.Controls.Image img = new System.Windows.Controls.Image();

              System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(gdiImg);
              IntPtr hBitmap = bmp.GetHbitmap();
              return System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
        }
Ejemplo n.º 13
0
        internal void PrintImage()
        {
            PrintImage pi = new PrintImage();
              System.Windows.Controls.Image pImage = new System.Windows.Controls.Image();
              pImage.Source = ImageCtrl.Source;

              pi.Print(pImage);
        }
Ejemplo n.º 14
0
 public void InitializeWebCam(ref System.Windows.Controls.Image ImageControl)
 {
     webcam = new WebCamCapture();
     webcam.FrameNumber = ((ulong)(0ul));
     webcam.TimeToCapture_milliseconds = FrameNumber;
     webcam.ImageCaptured += new WebCamCapture.WebCamEventHandler(webcam_ImageCaptured);
     _FrameImage = ImageControl;
 }
Ejemplo n.º 15
0
        protected override void UpdateWhiskerPositions(System.Windows.Controls.Image image, SizeChangedEventArgs e)
        {
            foreach (WhiskerAngleFrameViewModel whisker in Frames)
            {
                whisker.UpdatePositions(LastKnownImageWidth, LastKnownImageHeight);
            }

            CreateCenterLine();
        }
Ejemplo n.º 16
0
 public Metodos(Reader objReader, System.Windows.Controls.Image pbFingerprint)
 {
     variables = new Variables();
     variables.patchCapturaHuella = "c:\\Huellas\\";
     device = new SelectorHuella.Metodos();
     variables.currentReader = objReader;
     variables.pbFingerprint = pbFingerprint;
     device.InitializeDevice(ref objReader);
 }
Ejemplo n.º 17
0
 private void LeftMouseDownOnWheel(Image image)
 {
     if (image is IInputElement element)
     {
         _isLeftMouseOnWheelPressed = true;
         Mouse.Capture(element);
         SelectColorOnWheel(element);
     }
 }
Ejemplo n.º 18
0
        private void ChangeBitMap(Image image)
        {
            if (image is IInputElement element)
            {
                MouseElement = element;

                _clickAction.Action(this);
            }
        }
Ejemplo n.º 19
0
 private static void DisplayPicture(System.Windows.Controls.Image photo, string path, Action callback)
 {
     Application.Current.Dispatcher.BeginInvoke(
         DispatcherPriority.Background, new Action(() => {
         photo.Visibility = Visibility.Visible;
         photo.Source     = new BitmapImage(new Uri(path));
         callback?.Invoke();
     }));
 }
Ejemplo n.º 20
0
        public SkeletonDraw(KinectSensor sensor, System.Windows.Controls.Image Image)
        {
            this.sensor  = sensor;
            this.Image   = Image;
            drawingGroup = new DrawingGroup();
            imageSource  = new DrawingImage(drawingGroup);

            Image.Source = imageSource;
        }
Ejemplo n.º 21
0
        public void SizeChanged(object sender, SizeChangedEventArgs e)
        {
            System.Windows.Controls.Image image = (System.Windows.Controls.Image)sender;

            LastKnownImageWidth  = image.ActualWidth;
            LastKnownImageHeight = image.ActualHeight;

            UpdateWhiskerPositions(image.ActualWidth, image.ActualHeight);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Convert the icon in a WPF-Image
        /// </summary>
        /// <param name="icon"></param>
        /// <param name="width">Width of new Image</param>
        /// <param name="height">Height of new Image</param>
        /// <returns>WPF-Image-Control</returns>
        public static System.Windows.Controls.Image ToWPFImage(this Icon icon, int width, int height)
        {
            System.Windows.Controls.Image img = new System.Windows.Controls.Image();
            img.Width = width;
            img.Height = height;
            img.Source = icon.ToBitmapSource();

            return img;
        }
Ejemplo n.º 23
0
 public GameOver(Image canvas, Bitmap prevState, Game game, IGameScreen screen)
 {
     _canvas    = canvas;
     _prevState = prevState;
     _game      = game;
     _screen    = screen;
     _buffer    = new Bitmap(180, 360);
     Redraw();
 }
Ejemplo n.º 24
0
        public RenderObject(GameObject GameObject, System.Windows.UIElement element, RenderObjectType objectType, Dimension Size, System.Windows.Controls.Canvas Canvas, Renderer controller)
        {
            //Create new UI Element
            if (element is null)
            {
                switch (objectType)
                {
                case RenderObjectType.rectangle:
                    element = new System.Windows.Shapes.Rectangle()
                    {
                        Width                 = Size.Width,
                        Height                = Size.Height,
                        Fill                  = new System.Windows.Media.SolidColorBrush(GameObject.color),
                        Stroke                = new System.Windows.Media.SolidColorBrush(GameObject.color),
                        RenderTransform       = new System.Windows.Media.TransformGroup(),
                        RenderTransformOrigin = new System.Windows.Point(0.5, 0.5)
                    };
                    System.Windows.Media.TransformGroup transformGroup = (System.Windows.Media.TransformGroup)element.RenderTransform;
                    rotateTransform = new System.Windows.Media.RotateTransform(90);     //Rotation is different system than used
                    transformGroup.Children.Add(rotateTransform);
                    translateTransform = new System.Windows.Media.TranslateTransform(GameObject.position.x * Renderer.FieldSize, GameObject.position.y * Renderer.FieldSize);
                    transformGroup.Children.Add(translateTransform);
                    element.RenderTransform = transformGroup;
                    break;

                case RenderObjectType.image:
                    element = new System.Windows.Controls.Image()
                    {
                        Width                 = Size.Width * Renderer.FieldSize, //TODO: Fix the difference in size between the two types
                        Height                = Size.Height * Renderer.FieldSize,
                        Source                = Renderer.BitmapToImageSource(new System.Drawing.Bitmap(((ImageEntity)GameObject).CurrentImage())),
                        RenderTransform       = new System.Windows.Media.TransformGroup(),
                        RenderTransformOrigin = new System.Windows.Point(0.5, 0.5)
                    };
                    transformGroup  = (System.Windows.Media.TransformGroup)element.RenderTransform;
                    rotateTransform = new System.Windows.Media.RotateTransform(90);     //Rotation is different system than used
                    transformGroup.Children.Add(rotateTransform);
                    translateTransform = new System.Windows.Media.TranslateTransform(GameObject.position.x * Renderer.FieldSize, GameObject.position.y * Renderer.FieldSize);
                    transformGroup.Children.Add(translateTransform);
                    element.RenderTransform = transformGroup;
                    break;

                default:
                    break;
                }
            }

            gameObject = GameObject;
            uIElement  = element;
            type       = objectType;
            size       = Size;
            renderer   = controller;
            canvas     = Canvas;

            Canvas.Children.Add(uIElement);
        }
        public GameBoyPrinterEmulatorWindow(IControllerReader reader)
        {
            if (Properties.Settings.Default.UpgradeRequired)
            {
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.UpgradeRequired = false;
                Properties.Settings.Default.Save();
            }

            InitializeComponent();
            DataContext = this;

            _reader = reader ?? throw new ArgumentNullException(nameof(reader));

            SelectedPalette = Properties.Settings.Default.SelectedPalette;
            PrintSize       = Properties.Settings.Default.PrintSize;

            using (Bitmap bmp = new Bitmap(Properties.Resources.PrintImage))
            {
                _imageBuffer = new BitmapPixelMaker(480, 432);

                _imageBuffer.SetColor(palettes[SelectedPalette][0][3], palettes[SelectedPalette][1][3], palettes[SelectedPalette][2][3]);

                for (int i = 0; i < bmp.Width; ++i)
                {
                    for (int j = 0; j < bmp.Height; ++j)
                    {
                        System.Drawing.Color pixel = bmp.GetPixel(i, j);
                        if (pixel.R == 255 && pixel.G == 255 && pixel.B == 255)
                        {
                            _imageBuffer.SetRed(i, j, palettes[SelectedPalette][0][0]);
                            _imageBuffer.SetGreen(i, j, palettes[SelectedPalette][1][0]);
                            _imageBuffer.SetBlue(i, j, palettes[SelectedPalette][2][0]);
                        }
                    }
                }

                WriteableBitmap wbitmap = _imageBuffer.MakeBitmap(96, 96);

                // Create an Image to display the bitmap.
                _image = new System.Windows.Controls.Image
                {
                    Stretch = Stretch.None,
                    Margin  = new Thickness(0)
                };

                _             = GameBoyPrinterEmulatorWindowGrid.Children.Add(_image);
                _image.Source = wbitmap;

                _reader.ControllerStateChanged += Reader_ControllerStateChanged;
                _reader.ControllerDisconnected += Reader_ControllerDisconnected;

                CheckPalette(SelectedPalette);
                CheckSize(PrintSize);
            }
        }
Ejemplo n.º 26
0
        private void SetIcon(MessageWindowIcon icon)
        {
            IconBox.Visibility = Visibility.Visible;
            IconBox.Width      = 32;
            IconBox.Height     = 32;
            var img = new Image();

            switch (icon)
            {
            case MessageWindowIcon.Error:
                img.Source = ConvertBitmap(SystemIcons.Error.ToBitmap());
                SystemSounds.Hand.Play();
                IconBox.Content = img;
                break;

            case MessageWindowIcon.Exclamation:
                img.Source = ConvertBitmap(SystemIcons.Exclamation.ToBitmap());
                SystemSounds.Exclamation.Play();
                IconBox.Content = img;
                break;

            case MessageWindowIcon.Info:
                img.Source      = ConvertBitmap(SystemIcons.Information.ToBitmap());
                IconBox.Content = img;
                SystemSounds.Asterisk.Play();
                break;

            case MessageWindowIcon.Question:
                img.Source      = ConvertBitmap(SystemIcons.Question.ToBitmap());
                IconBox.Content = img;
                SystemSounds.Question.Play();
                break;

            case MessageWindowIcon.Warning:
                img.Source      = ConvertBitmap(SystemIcons.Warning.ToBitmap());
                IconBox.Content = img;
                SystemSounds.Exclamation.Play();
                break;

            case MessageWindowIcon.PDFCreator:
                IconBox.Width   = 45;
                IconBox.Height  = 45;
                IconBox.Content = FindResource("PDFCreatorLogo");
                break;

            case MessageWindowIcon.PDFForge:
                IconBox.Width   = 45;
                IconBox.Height  = 45;
                IconBox.Content = FindResource("RedFlame");
                break;

            case MessageWindowIcon.None:
                IconBox.Visibility = Visibility.Collapsed;
                break;
            }
        }
Ejemplo n.º 27
0
        //public static List<Hyperlink> GetHyperLinksContainingSelection(this TextSelection pos)
        //{
        //    var results = new List<Hyperlink>();

        //    foreach (var inline in pos.Start.Paragraph.Inlines)
        //    {
        //        if (inline is Hyperlink link)
        //        {
        //            try
        //            {
        //                if (link.Inlines.Contains((Inline)pos.Start.Parent))
        //                    results.Add(link);
        //            }
        //            catch (InvalidCastException ex)
        //            {
        //                MessageBox.Show(ex.ToString());
        //            }
        //        }
        //    }

        //    return results;
        //}

        public static void InsertAdornedImage(this FlowDocument document, System.Windows.Controls.Image image)
        {
            image.LostFocus += OnLostFocus;
            image.MouseDown += OnMouseDown;
            image.Stretch    = System.Windows.Media.Stretch.None;

            var imageContainer = new BlockUIContainer(image);

            document.Blocks.Add(imageContainer);
        }
Ejemplo n.º 28
0
 public ImageProcessingNetwork(System.Windows.Controls.Image picture,
                               System.Windows.Controls.Button button1,
                               System.Windows.Controls.Button button2,
                               ITargetBlock <string> targetBlock)
 {
     image            = picture;
     toolStripButton1 = button1;
     toolStripButton2 = button2;
     headBlock        = targetBlock;
 }
Ejemplo n.º 29
0
        private System.Windows.Point EndPosition;           // 本次移动结束时的坐标点位置

        /// <summary>
        /// 按下鼠标左键,准备开始拖动图片
        /// </summary>
        /// <param name="p"></param>
        private void MouseLeftButtonDownCommand(object[] p)
        {
            object sender          = p[0];
            MouseButtonEventArgs e = p[1] as MouseButtonEventArgs;

            System.Windows.Controls.Image img = sender as System.Windows.Controls.Image;

            movingObject  = img;
            StartPosition = e.GetPosition(img);
        }
Ejemplo n.º 30
0
            public static System.Windows.Controls.Image CaptureScreenAsImage()
            {
                var bmp = CaptureScreen();

                var img = new System.Windows.Controls.Image();

                img.Source = bmp;

                return(img);
            }
Ejemplo n.º 31
0
 public static void AgregarEventoCambiarImagen(System.Windows.Controls.Image controlImage)
 {
     controlImage.MouseDown  += controlImage_MouseDown;
     controlImage.DataContext = false;
     controlImage.ToolTip     = "Click izquierdo para cambiar | Click derecho para borrar";
     if (controlImage.Source == null)
     {
         AsignarFondoBlancoImage(controlImage);
     }
 }
 private void OnMoreInfoImageTouched(object sender, TouchEventArgs e)
 {
     System.Windows.Controls.Image img = e.OriginalSource as System.Windows.Controls.Image;
     if (img == null)
     {
         return;
     }
     StartupManagerTask.ShowDetail(img);
     e.Handled = true;
 }
Ejemplo n.º 33
0
 private Smiley CreateSmiley(string name, string directory)
 {
     System.Windows.Controls.Image image = new System.Windows.Controls.Image();
     image.Source = GetImage(new string[] { "Smileys", directory, name });
     return(new Smiley
     {
         Name = name.Split('.')[0],
         Pic = image
     });
 }
Ejemplo n.º 34
0
        static Action <VideoFrame> UpdateImage(System.Windows.Controls.Image img)
        {
            var wbmp = img.Source as WriteableBitmap;

            return(new Action <VideoFrame>(frame =>
            {
                var rect = new Int32Rect(0, 0, frame.Width, frame.Height);
                wbmp.WritePixels(rect, frame.Data, frame.Stride * frame.Height, frame.Stride);
            }));
        }
Ejemplo n.º 35
0
        public override FrameworkElement Draw(int pageNr)
        {
            var bitmap  = new BitmapImage(new Uri(Reference, UriKind.Relative));
            var control = new System.Windows.Controls.Image()
            {
                Source = bitmap, Height = bitmap.Height
            };

            return(control);
        }
Ejemplo n.º 36
0
        /// <summary> Initializes a new instance of the <see cref="UntiledCanvas"/> class. If the parameter
        /// <paramref name="addToMap"/> is set to true, the new canvas instance is added to the parent map. </summary>
        /// <param name="mapView"> The parent map instance. </param>
        /// <param name="untiledProvider"> The instance of the provider delivering bitmaps of a map. </param>
        /// <param name="addToMap"> Indicates that the map should be inserted to the parent map initially. </param>
        public UntiledCanvas(MapView mapView, IUntiledProvider untiledProvider, bool addToMap)
            : base(mapView, addToMap)
        {
            this.untiledProvider = untiledProvider;
            mapImage             = new Image {
                IsHitTestVisible = false
            };

            Children.Add(mapImage);
        }
Ejemplo n.º 37
0
 public override UIElement Draw()
 {
     System.Windows.Controls.Image myImage = new System.Windows.Controls.Image();
     myImage.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Path, UriKind.RelativeOrAbsolute));
     myImage.Width  = this.Width;
     myImage.Height = this.Heigth;
     System.Windows.Controls.Canvas.SetLeft(myImage, this.Left);
     System.Windows.Controls.Canvas.SetTop(myImage, this.Top);
     return((UIElement)myImage);
 }
Ejemplo n.º 38
0
		/// <summary>
		/// Gets the image from web.
		/// </summary>
		/// <param name="url">The URL.</param>
		/// <returns>System.Windows.Controls.Image.</returns>
		private System.Windows.Controls.Image GetImageFromWeb(string url)
		{
			var image = new System.Windows.Controls.Image();

			var uri = new Uri(url, UriKind.Absolute);

			image.Source = new BitmapImage(uri);

			return image;
		}
Ejemplo n.º 39
0
 public Window1()
 {
     InitializeComponent();
     BitmapImg = ImageToBitmapImage(System.Drawing.Image.FromFile(@"C:\some.img"));
     Img       = new System.Windows.Controls.Image()
     {
         Source = BitmapImg
     };
     DataContext = this;
 }
Ejemplo n.º 40
0
 private void OnMoreInfoImageMouseDown(object sender, MouseButtonEventArgs e)
 {
     System.Windows.Controls.Image img = e.OriginalSource as System.Windows.Controls.Image;
     if (img == null)
     {
         return;
     }
     OpenWithTask.ShowDetail(img);
     e.Handled = true;
 }
Ejemplo n.º 41
0
        /// <summary>
        /// Gets the image from web.
        /// </summary>
        /// <param name="url">The URL.</param>
        /// <returns>System.Windows.Controls.Image.</returns>
        private System.Windows.Controls.Image GetImageFromWeb(string url)
        {
            var image = new System.Windows.Controls.Image();

            var uri = new Uri(url, UriKind.Absolute);

            image.Source = new BitmapImage(uri);

            return(image);
        }
Ejemplo n.º 42
0
        private static void Sample2()
        {
            var application = new Application();
            var window      = new Window()
            {
                Height = 600, Width = 800,
            };
            var stackPanel = new System.Windows.Controls.StackPanel();

            window.Content = stackPanel;
            SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(application.Dispatcher));

            var urls = new[]
            {
                "http://weblogs.asp.net/blogs/nmarun/image_thumb_283DC50D.png",
                "http://weblogs.asp.net/blogs/nmarun/image_thumb_09FFF1D5.png",
                "http://weblogs.asp.net/blogs/nmarun/image_thumb_420B7DCA.png",
                "http://weblogs.asp.net/blogs/nmarun/image_thumb_5615AE0E.png",
            };

            var imageDownloader     = new TransformBlock <string, System.Drawing.Image>(url => DownloadImage(url));
            var bitmapSourceCreater = new TransformBlock <System.Drawing.Image, BitmapSource>(image =>
            {
                var bitmap       = new System.Drawing.Bitmap(image);
                var bmpPtr       = bitmap.GetHbitmap();
                var bitmapSource = Imaging.CreateBitmapSourceFromHBitmap(bmpPtr, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());

                //freeze bitmapSource and clear memory to avoid memory leaks
                bitmapSource.Freeze();
                DeleteObject(bmpPtr);

                return(bitmapSource);
            });
            var blockOptions = new ExecutionDataflowBlockOptions {
                TaskScheduler = TaskScheduler.FromCurrentSynchronizationContext(),
            };
            var uiOperator = new ActionBlock <BitmapSource>(bitmapSource =>
            {
                var image = new System.Windows.Controls.Image()
                {
                    Source = bitmapSource, Height = 100,
                };
                stackPanel.Children.Add(image);
            }, blockOptions);

            imageDownloader.LinkTo(bitmapSourceCreater);
            bitmapSourceCreater.LinkTo(uiOperator);

            foreach (string url in urls)
            {
                imageDownloader.Post(url);
            }

            application.Run(window);
        }
Ejemplo n.º 43
0
 private void ResetImageStrethch(System.Windows.Controls.Image img, Bitmap bImg)
 {
     if (bImg.Width <= img.Width)
     {
         img.Stretch = Stretch.None;
     }
     else
     {
         img.Stretch = Stretch.Fill;
     }
 }
        //render image using bytes
        private void RenderImageBytes(System.Windows.Controls.Image control, byte[] bytes)
        {
            MemoryStream byteStream  = new MemoryStream(bytes);
            BitmapImage  imageSource = new BitmapImage();

            imageSource.BeginInit();
            imageSource.StreamSource = byteStream;
            imageSource.EndInit();

            control.Source = imageSource;
        }
Ejemplo n.º 45
0
        /// <summary>
        /// Show the Default Splash Screen
        /// </summary>
        private void ShowDefaultSplashScreen()
        {
            Uri path = new Uri("pack://application:,,,/Resources/splash.jpg");

            this.splashScreen = new System.Windows.Controls.Image()
            {
                Name   = "Splash",
                Source = new BitmapImage(path)
            };
            this.Scene.Children.Add(this.splashScreen);
        }
Ejemplo n.º 46
0
        private static UIElement PrintPage(BitmapSource bitmap)
        {
            var bitmapSize = new System.Windows.Size(bitmap.PixelWidth, bitmap.PixelHeight);
            var image      = new System.Windows.Controls.Image {
                Source = bitmap
            };

            image.Measure(bitmapSize);
            image.Arrange(new System.Windows.Rect(new System.Windows.Point(0, 0), bitmapSize));
            return(image);
        }
Ejemplo n.º 47
0
            /**
             * The constructor
             */
            public Image()
            {
                mImage = new System.Windows.Controls.Image();
                mStretch = new System.Windows.Media.Stretch();

                mImage.HorizontalAlignment = HorizontalAlignment.Left;
                mImage.VerticalAlignment = VerticalAlignment.Top;

                mStretch = System.Windows.Media.Stretch.None;
                mImage.Stretch = mStretch;

                View = mImage;
            }
Ejemplo n.º 48
0
 public MainWindow()
 {
     boton_elegir = new System.Windows.Controls.Image();
     boton_video = new System.Windows.Controls.Image();
     cargar_imagenes(1);
     Tangulo.Interval = 1000;
     Tvideo.Interval = 1000;
     Tdisfraz.Interval = 1000;
     Tangulo.Elapsed += new System.Timers.ElapsedEventHandler(Tangulo_Elapsed);
     Tvideo.Elapsed += new System.Timers.ElapsedEventHandler(Tvideo_Elapsed);
     Tdisfraz.Elapsed += new System.Timers.ElapsedEventHandler(Tdisfraz_Elapsed);
     InitializeComponent();
     this.Unloaded += new RoutedEventHandler(MainWindow_Unloaded);
 }
Ejemplo n.º 49
0
        /// <summary>
        ///     Loads the BowIcon from resources and colors it according to the current theme
        /// </summary>
        /// <returns></returns>
        public static RenderTargetBitmap GenerateWindowIcon()
        {
            var iconImage = new System.Windows.Controls.Image
            {
                Source = (DrawingImage) Application.Current.MainWindow.Resources["BowIcon"],
                Stretch = Stretch.Uniform,
                Margin = new Thickness(20)
            };

            iconImage.Arrange(new Rect(0, 0, 100, 100));
            var bitmap = new RenderTargetBitmap(100, 100, 96, 96, PixelFormats.Pbgra32);
            bitmap.Render(iconImage);
            return bitmap;
        }
Ejemplo n.º 50
0
        private void AddImage(ImageBrowser browser, BitmapImage bitmapImage, string file)
        {
            var imageControl = new System.Windows.Controls.Image
            {
                Opacity = 0.5,
                Margin = new System.Windows.Thickness(10, 10, 10, 10),
                Source = bitmapImage,
                Tag = file
            };

            imageControl.MouseDown += ImageControlMouseDown;
            imageControl.MouseEnter += ImageControlMouseEnter;
            imageControl.MouseLeave += ImageControlMouseLeave;
            browser.Add(imageControl);
        }
Ejemplo n.º 51
0
        public Spel(System.Windows.Controls.Image tekenBlad)
        {
            _tekenBlad = tekenBlad;

            _monster_timer = new DispatcherTimer { Interval = new TimeSpan(0, 0, 0, 0, 100) };
            _monster_timer.Tick += MonsterTimerElapsed;

            _projectiel_timer = new DispatcherTimer { Interval = new TimeSpan(0, 0, 0, 0, 5) };
            _projectiel_timer.Tick += ProjectielTimerElapsed;

            _huidigeLevel = 1;
            HuidigeLevel = LevelFactory.CreateLevel(_huidigeLevel, this);

            StartLevel();
        }
Ejemplo n.º 52
0
 public static ImageSource GetImageByID(int ID)
 {
     Photo photo = null;
     foreach (var p in Entities.Photo)
         if (p.ID == ID)
             photo = p;
     
     BitmapImage PhotoBitmap = new BitmapImage();
     PhotoBitmap = LoadImage(photo.PhotoByte);
     System.Windows.Controls.Image PhotoImage = new System.Windows.Controls.Image();
     PhotoImage.Source = PhotoBitmap;
     PhotoImage.Stretch = Stretch.Uniform;
     PhotoImage.Margin = new Thickness(5);
     ImageSource source = PhotoBitmap;
     return source;
 }
Ejemplo n.º 53
0
        public ImageDatabase(string folder)
        {
            EntityStats = new Image {Source = new BitmapImage(new Uri(folder + "stats.png"))};
            EntityStatsClickThrou = new Image {Source = new BitmapImage(new Uri(folder + "stats_click_throu.png"))};
            Chrono = new Image {Source = new BitmapImage(new Uri(folder + "chrono.png"))};
            Chronobar = new Image {Source = new BitmapImage(new Uri(folder + "chronobar.png"))};
            Close = new Image {Source = new BitmapImage(new Uri(folder + "close.png"))};
            History = new Image {Source = new BitmapImage(new Uri(folder + "historic.png"))};
            Copy = new Image {Source = new BitmapImage(new Uri(folder + "copy.png"))};
            Config = new Image {Source = new BitmapImage(new Uri(folder + "config.png"))};
            Chat = new Image {Source = new BitmapImage(new Uri(folder + "chat.png"))};
            Link = new Image {Source = new BitmapImage(new Uri(folder + "link.png"))};

            Icon = new BitmapImage(new Uri(folder + "shinra.ico"));
            Tray = new Icon(folder + "shinra.ico");
        }
Ejemplo n.º 54
0
            /**
             * The constructor
             */
            public Image()
            {
                mImage = new System.Windows.Controls.Image();
                mStretch = new System.Windows.Media.Stretch();

                mParentCanvas = new Grid();

                mImage.HorizontalAlignment = HorizontalAlignment.Left;
                mImage.VerticalAlignment = VerticalAlignment.Top;

                mStretch = System.Windows.Media.Stretch.None;
                mImage.Stretch = mStretch;

                mParentCanvas.Children.Add(mImage);
                View = mParentCanvas;
            }
Ejemplo n.º 55
0
        public System.Windows.Controls.Image ByteToWPFImage(byte[] blob)
        {
            MemoryStream stream = new MemoryStream();
            stream.Write(blob, 0, blob.Length);
            stream.Position = 0;

            System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
            System.Windows.Media.Imaging.BitmapImage bi = new System.Windows.Media.Imaging.BitmapImage();
            bi.BeginInit();

            MemoryStream ms = new MemoryStream();
            img.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
            ms.Seek(0, SeekOrigin.Begin);
            bi.StreamSource = ms;
            bi.EndInit();
            System.Windows.Controls.Image image2 = new System.Windows.Controls.Image() { Source = bi };
            return image2;
        }
Ejemplo n.º 56
0
        public NativeWPListViewCell(String cellId)
        {
            image = new Image();

            headingLabel = new Label()
            {
                FontAttributes = FontAttributes.Italic,
                TextColor = Color.Lime,
                BackgroundColor = Color.Default
            };

            subheadingLabel = new Label()
            {
                FontAttributes = FontAttributes.Bold,
                TextColor = Color.Lime,
                BackgroundColor = Color.Default
            };
        }
        /// <summary>
        /// Redraws the whole barcode
        /// </summary>
        public override void RedrawAll()
        {
            Children.Clear();

           
            if (Value != null)
            {
                var DrawObject = BarcodeDrawFactory.GetSymbology((BarcodeSymbology)(int)BarcodeSymbology);
                var img = DrawObject.Draw(Value.ToString(), 30);
                var bmpImage = ImageToBitmapImage(new Bitmap(img));

                var BarcodeImage = new Image();
                BarcodeImage.Stretch = Stretch.UniformToFill;
                BarcodeImage.Source = bmpImage;
                BarcodeImage.Width = this.Width;
                BarcodeImage.Height = this.Height;
                Children.Add(BarcodeImage);
            }  
        }
Ejemplo n.º 58
0
        public static System.Windows.Controls.Image ConvertDrawingImageToWPFImage(System.Drawing.Image gdiImg)
        {
            System.Windows.Controls.Image img = new System.Windows.Controls.Image();

            //convert System.Drawing.Image to WPF image
            using (System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(gdiImg))
            {
                IntPtr hBitmap = bmp.GetHbitmap();
                System.Windows.Media.ImageSource WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());

                img.Source = WpfBitmap;
                img.Width = 500;
                img.Height = 600;
                img.Stretch =  System.Windows.Media.Stretch.None;

                ScreenCapture.GDI32.DeleteObject(hBitmap);
            }
                return img;
        }
Ejemplo n.º 59
-1
        public void InitializeWebCam(Image videoOutput, Image diffOutput, Image rects)
        {
            this.webcam = new WebCamCapture
            {
                FrameNumber = 0,
                TimeToCapture_milliseconds = FrameNumber
            };

            this.webcam.ImageCaptured += this.webcam_ImageCaptured;
            this.videoOutput = videoOutput;
            this.diffOutput = diffOutput;

            this.rects = rects;
        }
Ejemplo n.º 60
-1
        public GdiMedia()
        {
            //Commands

            OpenFileCommand = new RelayCommand(o => { }, o => false);
            OpenDiscCommand = new RelayCommand(o => { }, o => false);
            OpenStreamCommand = new RelayCommand(o => { }, o => false);
            OpenDeviceCommand = new RelayCommand(o => { }, o => false);
            OpenProcessCommand = new RelayCommand(OpenProcess);

            _media = new Image();
            _timer = new DispatcherTimer(DispatcherPriority.Send);
            _timer.Interval = new TimeSpan(0, 0, 0, 0, 125);
            _timer.Tick += TimerOnTick;
        }