Esempio n. 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ImageServiceClientManager   manager        = (ImageServiceClientManager)Session["Manager"];
        IEnumerable <ImageFileData> imagesFileData = (IEnumerable <ImageFileData>)Session["ImagesFileData"];

        if (manager == null || imagesFileData == null)
        {
            return;
        }
        string fileName = Request.QueryString["fileName"];

        byte[] imageData = null;

        ImageFileData imageFileData = imagesFileData.SingleOrDefault(p => p.FileName == fileName);

        if (imageFileData != null && imageFileData.ImageData != null)
        {
            imageData = imageFileData.ImageData;
        }
        else
        {
            imageData = manager.DownloadImage(fileName);
        }
        if (imageData != null)
        {
            Response.BinaryWrite(imageData);
        }
    }
Esempio n. 2
0
        private void imageFilesGrid_MouseDoubleClick_1(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            string imageName = string.Empty;

            byte[] imageData = ((ImageFileData)((DataGrid)sender).SelectedItem).ImageData;
            if (imageData == null)
            {
                imageData = manager.DownloadImage(((ImageFileData)((DataGrid)sender).SelectedItem).FileName);
            }
            if (imageData == null)
            {
                return;
            }
            BitmapImage  bitmap = new BitmapImage();
            MemoryStream ms     = new MemoryStream(imageData);

            bitmap.BeginInit();
            bitmap.CacheOption  = BitmapCacheOption.OnLoad;
            bitmap.StreamSource = ms;
            bitmap.EndInit();
            ImageViewer1.Source = bitmap;
        }