コード例 #1
0
    private static void Callback(object state)
    {
        DirectoryInfo myDirectory = new DirectoryInfo(dir);

        FileInfo[] _files = myDirectory.GetFiles();
        foreach (FileInfo file in _files)
        {
            String s;
            Thumb  thumb = new Thumb(file.FullName);
            if (thumb.Exists() == 0)
            {
                thumb.Generate();
            }
            s = thumb.Preview;
            TableImage i = new TableImage(s);
            items.Add(i);
        }


        imageTable.ItemSize(96, 96);
        imageTable.HorizSpacer = 10;
        imageTable.VertSpacer  = 10;
        imageTable.Resize(640 - 70 - 2, 480 - 37 - 2);
        Box box_images = (Box)Application.EE.DataGet("box_images");

        box_images.Show();
        System.GC.KeepAlive(imageTable);
    }
コード例 #2
0
        private TableImage CreateImage(IFormFile logoFile, EnumImageType imageType)
        {
            if (logoFile != null && (logoFile.ContentType == "image/png" || logoFile.ContentType == "image/jpeg"))
            {
                var image = new TableImage
                {
                    ImageType = imageType,
                    FileName  = logoFile.FileName,
                    SavedAt   = DateTime.Now,
                };

                byte[] imageData;

                using (var stream = logoFile.OpenReadStream())
                {
                    using (MemoryStream ms = new MemoryStream())
                    {
                        stream.CopyTo(ms);
                        imageData = ms.ToArray();
                    }
                }

                if (imageData.Length == 0)
                {
                    return(null);
                }

                image.File = ImageHelper.ReduceImage(imageData);

                return(image);
            }

            return(null);
        }
コード例 #3
0
    public static void Main(string [] args)
    {
        Enlightenment.Ecore.MainLoop.Init();
        Enlightenment.Ecore.Canvas.Init();

        EE.SoftwareX11New(":0", IntPtr.Zero, 0, 0, app_w, app_h);
        EE.Title = "Sharp Table";
        EE.NameClassSet("sharp_container", "sharp_container");
        EE.ResizeEvent += new Enlightenment.Ecore.Canvas.EventHandler(AppResizeHandler);
        EE.Show();

        Enlightenment.Ecore.Events.SignalExitEvent += new Enlightenment.Ecore.Events.EventHandler(AppSignalExitHandler);

        Rectangle bg_rect = new Rectangle(EE.Get());

        bg_rect.Move(0, 0);
        bg_rect.Color = new Color(228, 226, 212, 255);
        bg_rect.Resize(app_w, app_h);
        bg_rect.Lower();
        bg_rect.Show();

        Rectangle left_toolbar = new Rectangle(EE.Get());

        left_toolbar.Move(0, 0);
        left_toolbar.Resize(100, app_h);
        left_toolbar.Color = new Color(124, 126, 101, 200);
        left_toolbar.Show();

        Rectangle top_toolbar = new Rectangle(EE.Get());

        top_toolbar.Move(0, 0);
        top_toolbar.Resize(app_w, 50);
        top_toolbar.Color = new Color(124, 126, 101, 200);
        top_toolbar.Show();


        DirectoryInfo myDirectory = new DirectoryInfo(args[0]);

        FileInfo[] _files = myDirectory.GetFiles();
        foreach (FileInfo file in _files)
        {
            TableImage i = new TableImage(file);
            items.Add(i);
        }


        EE.DataSet("bg_rect", bg_rect);
        EE.DataSet("left_toolbar", left_toolbar);
        EE.DataSet("top_toolbar", top_toolbar);

        WaitCallback callback = new WaitCallback(DrawGui);

        ThreadPool.QueueUserWorkItem(callback);


        Enlightenment.Ecore.MainLoop.Begin();
    }
コード例 #4
0
        public string DeleteImg(int Id)
        {
            TableImage image = db.TableImages.Single(TableImage => TableImage.Id == Id);

            Uri                uri           = new Uri(image.ImagePath);
            string             filename      = System.IO.Path.GetFileName(uri.LocalPath);
            CloudBlobContainer blobContainer = _blobServices.GetCloudBlobContainer();
            CloudBlockBlob     blob          = blobContainer.GetBlockBlobReference(filename);

            blob.Delete();
            _imageService.DeleteImage(Id);
            return("File Successfully Deleted");
        }
コード例 #5
0
        private IEnumerable <TableImage> ParseImages(IEnumerable <XElement> imagesTags)
        {
            foreach (var imagesTag in imagesTags)
            {
                var tableImage = new TableImage();
                var styleAttr  = imagesTag.Attribute("style").Value;
                if (!string.IsNullOrWhiteSpace(styleAttr))
                {
                    var styles = styleAttr
                                 .ToLower()
                                 .Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)
                                 .Select(
                        style => style
                        .Trim()
                        .Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries)
                        .Select(part => part.Trim()))
                                 .ToDictionary(item => item.ElementAt(0), item => item.ElementAt(1));

                    try
                    {
                        tableImage.Height = int.Parse(styles["height"].Replace("px", string.Empty));
                    }
                    catch (Exception exception)
                    {
                        throw new FormatException("Can't parse image height.", exception);
                    }

                    try
                    {
                        tableImage.Width = int.Parse(styles["width"].Replace("px", string.Empty));
                    }
                    catch (Exception exception)
                    {
                        throw new FormatException("Can't parse image width.", exception);
                    }

                    try
                    {
                        tableImage.Left = int.Parse(styles["left"].Replace("px", string.Empty));
                    }
                    catch (Exception exception)
                    {
                        throw new FormatException("Can't parse image left.", exception);
                    }

                    try
                    {
                        tableImage.Top = int.Parse(styles["top"].Replace("px", string.Empty));
                    }
                    catch (Exception exception)
                    {
                        throw new FormatException("Can't parse image top.", exception);
                    }
                }
                else
                {
                    throw new FormatException("Can't parse img style attribute.");
                }

                var src = imagesTag.Attribute("src").Value;
                if (!string.IsNullOrWhiteSpace(src))
                {
                    var path = _resolvePath(src);
                    if (!File.Exists(path))
                    {
                        throw new FileNotFoundException("Can't find image", path);
                    }

                    tableImage.ImagePath = path;
                }
                else
                {
                    throw new FormatException("Can't parse img src attribute.");
                }

                yield return(tableImage);
            }
        }
コード例 #6
0
ファイル: image_test_simple.cs プロジェクト: emtees/old-code
  public static void Main(string [] args)
  {	
    Enlightenment.Ecore.MainLoop.Init();
    Enlightenment.Ecore.Canvas.Init();
			
    EE.SoftwareX11New(":0", IntPtr.Zero, 0, 0, app_w, app_h);
    EE.Title = "Sharp Table";
    EE.NameClassSet("sharp_container","sharp_container");
    EE.ResizeEvent += new Enlightenment.Ecore.Canvas.EventHandler(AppResizeHandler);
    EE.Show();
	
    Enlightenment.Ecore.Events.SignalExitEvent += new Enlightenment.Ecore.Events.EventHandler(AppSignalExitHandler);
	
    Rectangle bg_rect = new Rectangle(EE.Get());
    bg_rect.Move(0, 0);
    bg_rect.Color = new Color(228, 226, 212, 255);
    bg_rect.Resize(app_w, app_h);
    bg_rect.Lower();
    bg_rect.Show();
	
    Rectangle left_toolbar = new Rectangle(EE.Get());
    left_toolbar.Move(0, 0);
    left_toolbar.Resize(100, app_h);
    left_toolbar.Color = new Color(124, 126, 101, 200);
    left_toolbar.Show();
	
    Rectangle top_toolbar = new Rectangle(EE.Get());
    top_toolbar.Move(0, 0);
    top_toolbar.Resize(app_w, 50);
    top_toolbar.Color = new Color(124, 126, 101, 200);
    top_toolbar.Show();	
	
	
    DirectoryInfo myDirectory = new DirectoryInfo(args[0]);
    FileInfo[] _files = myDirectory.GetFiles();
    foreach (FileInfo file in _files)
    {
      TableImage i = new TableImage(file);
      items.Add(i);
    }

		              
    EE.DataSet("bg_rect", bg_rect);
    EE.DataSet("left_toolbar", left_toolbar);
    EE.DataSet("top_toolbar", top_toolbar);
	
    WaitCallback callback = new WaitCallback(DrawGui);
    ThreadPool.QueueUserWorkItem(callback);
	

    Enlightenment.Ecore.MainLoop.Begin();
	
  }   
コード例 #7
0
ファイル: image_test_eblocks.cs プロジェクト: emtees/old-code
  private static void Callback(object state)
  {	
    DirectoryInfo myDirectory = new DirectoryInfo(dir);
    FileInfo[] _files = myDirectory.GetFiles();
    foreach (FileInfo file in _files)
    {
      String s;
      Thumb thumb = new Thumb(file.FullName);
      if(thumb.Exists() == 0)
	thumb.Generate();
      s = thumb.Preview;
      TableImage i = new TableImage(s);
      items.Add(i);
    }

	
    imageTable.ItemSize(96, 96);
    imageTable.HorizSpacer = 10;
    imageTable.VertSpacer = 10;
    imageTable.Resize(640 - 70 - 2, 480 - 37 - 2);
    Box box_images = (Box)Application.EE.DataGet("box_images");
    box_images.Show();	
    System.GC.KeepAlive(imageTable);
  }