示例#1
0
        public MainWindow()
        {
            InitializeComponent();

            // On crée notre collection d'image et on y ajoute deux images
            imageCollection1 = new ImageCollection();
            imageCollection1.Add(new ImageObjet("Chrysanthemum",
                                                lireFichier(@"d:\Chrysanthemum.jpg")));
            imageCollection1.Add(new ImageObjet("Hydrangeas",
                                                lireFichier(@"d:\Hydrangeas.jpg")));
            // On lie la collection ObjectDataProvider déclaré dans le fichier XAML
            ObjectDataProvider imageSource = (ObjectDataProvider)FindResource("ImageCollection1");

            imageSource.ObjectInstance = imageCollection1;

            // On crée notre collection d'image et on y ajoute deux images
            imageCollection2 = new ImageCollection();
            imageCollection2.Add(new ImageObjet("Penguins",
                                                lireFichier(@"d:\Penguins.jpg")));
            imageCollection2.Add(new ImageObjet("Koala",
                                                lireFichier(@"d:\Koala.jpg")));
            // On lie la collectionau ObjectDataProvider déclaré dans le fichier XAML
            ObjectDataProvider imageSource2 = (ObjectDataProvider)FindResource("ImageCollection2");

            imageSource2.ObjectInstance = imageCollection2;
        }
示例#2
0
 private void DisplayPicSet(int i)
 {
     ic.SetGen(i - iCurPic); //Set generation
     ic.Rinse(3, ImageCollection.imType.Resized);
     for (int a = 0; a < 3; a++)
     {
         if (id.Length > i + a)
         {
             ic.Add(id[i + a].sHash, id[i + a].sPath,
                    +a, ImageCollection.imType.Resized);
         }
         if (i - a >= 0)
         {
             ic.Add(id[i - a].sHash, id[i - a].sPath,
                    -a, ImageCollection.imType.Resized);
         }
     }
     iCurPic    = i;       //Set new opened image
     bSetNewPic = true;    //We need to update display
     if (!DisplayPicSet()) //Image not in bm cache
     {
         ic.Prio(id[i].sHash, ImageCollection.imType.Resized);
         ic.Load();         //Prioritize and init load of opened image
     }
     pbDisp.Visible = true; //We are displaying an image
     ShowPanel(pnDisp);     //Show display in GUI
 }
示例#3
0
        //protected override void Dispose(bool disposing)
        //{
        //    if (disposing)
        //    {
        //        if (this.device != null) this.device.Close();
        //        if (this.acquisition != null) this.acquisition.Dispose();
        //    }
        //    base.Dispose(disposing);
        //}

        #endregion

        #region Atalasoft Image/Scan Events

        private void acquisition_ImageAcquired(object sender, AcquireEventArgs e)
        {
            Bitmap bitmap = e.Image;

            switch (getCheckedMenuItemIndex(miRotation))
            {
            case 1: bitmap.RotateFlip(RotateFlipType.Rotate90FlipNone); break;

            case 2: bitmap.RotateFlip(RotateFlipType.Rotate180FlipNone); break;

            case 3: bitmap.RotateFlip(RotateFlipType.Rotate270FlipNone); break;
            }
            int page = tViewer.Items.Count + 1;

            AtalaImage atalaImage = AtalaImage.FromBitmap(bitmap);

            ScannedImages.Add(atalaImage);

            Atalasoft.Imaging.WinControls.Thumbnail thumbnail = new Atalasoft.Imaging.WinControls.Thumbnail(atalaImage, "", "");
            thumbnail.Selected = true;

            tViewer.Items.Add(thumbnail);

            RefreshView(tViewer.Items.Count - 1);
        }
示例#4
0
        private async Task GetImages(string searchString, bool pagination)
        {
            List <ImageItem> items = await _imageGalleryManager.GetImages(searchString, pagination);

            if (items.Count == 0)
            {
                return;
            }

            List <ImageDataItem> imageList = new List <ImageDataItem>();
            List <Task <bool> >  taskList  = new List <Task <bool> >();

            int index = ImageCollection.Count;

            for (int i = 0; i < items.Count; i++)
            {
                ImageDataItem dataItem = new ImageDataItem(index++, items[i].Title, items[i].Url, ActiveService, _imageCreator);
                imageList.Add(dataItem);
                Task <bool> task = dataItem.Init();
            }

            await Task.WhenAll(taskList.ToArray());

            if (!pagination)
            {
                ImageCollection.Clear();
            }

            foreach (var dataItem in imageList)
            {
                ImageCollection.Add(dataItem);
            }
        }
示例#5
0
        public static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("ERROR: No output filename specified");
                return;
            }

            if (args.Length < 2)
            {
                Console.WriteLine("ERROR: At least one input file must be specified");
                return;
            }

            using(ImageCollection collection = new ImageCollection())
            {
                string outputFilename = args[0];

                foreach(var fn in args.Skip(1))
                {
                    collection.Add(new Bitmap(fn));
                }

                using(Bitmap b = collection.Render())
                {
                    VHDLConverter c = new VHDLConverter(b);

                    c.Save(outputFilename);
                }

                Console.WriteLine("Output written to {0}", outputFilename);
            }
        }
 public CarouselViewModel()
 {
     ImageCollection.Add(new CarouselModel("image1.png"));
     ImageCollection.Add(new CarouselModel("image2.png"));
     ImageCollection.Add(new CarouselModel("image3.png"));
     ImageCollection.Add(new CarouselModel("image4.png"));
     ImageCollection.Add(new CarouselModel("image5.png"));
 }
示例#7
0
        public void Images()
        {
            string          imagePath  = @"G:\trenningC#\ConvertJpegOnDoc";
            ImageCollection collection = new ImageCollection();

            collection.Add(imagePath);
            _cleanupFile.CleaningImage(collection);
        }
示例#8
0
 public RotatorViewModel()
 {
     ImageCollection.Add(new RotatorModel("movie1.png"));
     ImageCollection.Add(new RotatorModel("movie2.png"));
     ImageCollection.Add(new RotatorModel("movie3.png"));
     ImageCollection.Add(new RotatorModel("movie4.png"));
     ImageCollection.Add(new RotatorModel("movie5.png"));
 }
 /// <summary>
 /// ViewModel Constructor
 /// </summary>
 public ViewModel()
 {
     ImageCollection.Add(new Model("movie1.png"));
     ImageCollection.Add(new Model("movie2.png"));
     ImageCollection.Add(new Model("movie3.png"));
     ImageCollection.Add(new Model("movie4.png"));
     ImageCollection.Add(new Model("movie5.png"));
     ImageCollection.Add(new Model("movie6.png"));
 }
示例#10
0
        /// <summary>
        /// Occurs when drag n drop event start
        /// </summary>
        /// <param name="arg"></param>
        public void AddImage(DragEventArgs arg)
        {
            var g = arg.Data.GetDataPresent(DataFormats.FileDrop);

            string[] files = (string[])arg.Data.GetData(DataFormats.FileDrop);

            for (int i = 0; i < files.Length; i++)
            {
                ImageCollection.Add(new Image(files[i], this));
            }
        }
示例#11
0
 public RotatorViewModel()
 {
     if (Device.OS == TargetPlatform.Android || Device.OS == TargetPlatform.iOS)
     {
         ImageCollection.Add(new RotatorModel("movie1.png"));
         ImageCollection.Add(new RotatorModel("movie2.png"));
         ImageCollection.Add(new RotatorModel("movie3.png"));
         ImageCollection.Add(new RotatorModel("movie6.png"));
         ImageCollection.Add(new RotatorModel("movie4.png"));
         ImageCollection.Add(new RotatorModel("movie5.png"));
     }
 }
示例#12
0
 public RotatorViewModel()
 {
     if (Device.RuntimePlatform == Device.Android || Device.RuntimePlatform == Device.iOS)
     {
         ImageCollection.Add(new RotatorModel("movie1.png"));
         ImageCollection.Add(new RotatorModel("movie2.png"));
         ImageCollection.Add(new RotatorModel("movie3.png"));
         ImageCollection.Add(new RotatorModel("movie6.png"));
         ImageCollection.Add(new RotatorModel("movie4.png"));
         ImageCollection.Add(new RotatorModel("movie5.png"));
     }
 }
示例#13
0
        public UploadImageSetViewModel()
        {
            SelectImageFromExplorerCommand = new ActionCommand <int>(OpenExplorerAndSetImage);
            ReturnResultsCommand           = new ActionCommand <Window>(CloseWindowAndReturnTrue, CanReturnResult);

            // We need to pre-initialize the elements so we can work wíth indices right off the bat, our view binds to 0-7, and we assign new values to these elements by number.
            // Note: We already know what size this collection needs to be, but can't use arrays since they don't implement INotifyCollectionChanged
            for (int i = 0; i < ImageSetSize; i++)
            {
                ImageCollection.Add(null);
            }
        }
示例#14
0
 public RotatorViewModel()
 {
     if (Device.RuntimePlatform == Device.Android || Device.RuntimePlatform == Device.iOS)
     {
         ImageCollection.Add(new RotatorModel("Duck0.png"));
         ImageCollection.Add(new RotatorModel("Duck1.png"));
         ImageCollection.Add(new RotatorModel("Duck2.png"));
         ImageCollection.Add(new RotatorModel("Duck3.png"));
         ImageCollection.Add(new RotatorModel("Duck4.png"));
         ImageCollection.Add(new RotatorModel("Duck5.png"));
     }
 }
示例#15
0
        /// <summary>
        /// 初始化加载图标资源
        /// </summary>
        /// <returns></returns>
        private DXImageGalleryLoader LoadData()
        {
            this.ImageCollection = new Dictionary <string, GalleryItem>();
            this.Categories      = new List <string>();
            this.Collection      = new List <string>();
            this.Size            = new List <string>();

            using (System.Resources.ResourceReader reader = GetResourceReader(DevExpress.Utils.DxImageAssemblyUtil.ImageAssembly))
            {
                System.Collections.IDictionaryEnumerator dict = reader.GetEnumerator();
                while (dict.MoveNext())
                {
                    string key = (string)dict.Key as string;
                    if (!DevExpress.Utils.DxImageAssemblyUtil.ImageProvider.IsBrowsable(key))
                    {
                        continue;
                    }
                    if (key.EndsWith(".png", StringComparison.Ordinal))
                    {
                        string reg            = @"(?<collection>\S*?)/(?<category>\S*?)/(?<name>\S*)";
                        var    collectionItem = CRegex.GetText(key, reg, "collection");
                        var    categoryItem   = CRegex.GetText(key, reg, "category");
                        string sizeReg        = @"_(?<size>\S*)\.";
                        var    sizeItem       = CRegex.GetText(key, sizeReg, "size");

                        if (!this.Collection.Contains(collectionItem))
                        {
                            this.Collection.Add(collectionItem);
                        }
                        if (!this.Categories.Contains(categoryItem))
                        {
                            this.Categories.Add(categoryItem);
                        }
                        if (!this.Size.Contains(sizeItem))
                        {
                            this.Size.Add(sizeItem);
                        }

                        Image image = GetImageFromStream((System.IO.Stream)dict.Value);
                        if (image != null)
                        {
                            var item = new DevExpress.XtraBars.Ribbon.GalleryItem(image, key, key);
                            if (!ImageCollection.ContainsKey(key))
                            {
                                ImageCollection.Add(key, item);
                            }
                        }
                    }
                }
            }
            return(this);
        }
示例#16
0
        public MainWindow()
        {
            InitializeComponent();

            // On crée notre collection d'image et on y ajoute deux images
            imageCollection1 = new ImageCollection();
            imageCollection1.Add(new ImageObjet("Chrysanthemum",
            lireFichier(@"d:\Chrysanthemum.jpg")));
            imageCollection1.Add(new ImageObjet("Hydrangeas",
            lireFichier(@"d:\Hydrangeas.jpg")));
            // On lie la collection ObjectDataProvider déclaré dans le fichier XAML
            ObjectDataProvider imageSource = (ObjectDataProvider)FindResource("ImageCollection1");
            imageSource.ObjectInstance = imageCollection1;

            // On crée notre collection d'image et on y ajoute deux images
            imageCollection2 = new ImageCollection();
            imageCollection2.Add(new ImageObjet("Penguins",
            lireFichier(@"d:\Penguins.jpg")));
            imageCollection2.Add(new ImageObjet("Koala",
            lireFichier(@"d:\Koala.jpg")));
            // On lie la collectionau ObjectDataProvider déclaré dans le fichier XAML
            ObjectDataProvider imageSource2 = (ObjectDataProvider)FindResource("ImageCollection2");
            imageSource2.ObjectInstance = imageCollection2;
        }
示例#17
0
        /// <summary>
        /// 提取为序列图格式
        /// </summary>
        /// <param name="source">压缩源</param>
        /// <param name="path">关键字</param>
        /// <returns></returns>
        private ImageCollection ExtractToImageCollection(SevenZipArchive source, string path)
        {
            ImageCollection collection = new ImageCollection();
            MemoryStream    stream;

            foreach (ArchiveEntry entry in source)
            {
                if (!entry.IsDirectory && entry.FileName.Contains(path))
                {
                    stream = new MemoryStream();
                    entry.Extract(stream);
                    collection.Add(stream);
                }
            }
            return(collection);
        }
        public bool AddRecordToRepo(LogbookImage image)
        {
            if (image == null)
            {
                throw new ArgumentNullException("Error: The argument is Null");
            }

            image.Comment = GetImageCommentMetadata(image.FileName);

            if (image.Comment.Contains("GPXManager"))
            {
                ImageCollection.Add(image);
            }


            return(EditSuccess);
        }
 public override ImageCollection GetImagesByCategoryId(int categoryId, bool activeOnly)
 {
     using (IDataReader reader = _procedures.GetImageCategory(categoryId, activeOnly, BlogId))
     {
         var ic = new ImageCollection();
         while (reader.Read())
         {
             ic.Category = reader.ReadLinkCategory();
             break;
         }
         reader.NextResult();
         while (reader.Read())
         {
             ic.Add(reader.ReadImage());
         }
         return(ic);
     }
 }
        public static void LoadImages()
        {
            var retrievedImages = DatabaseService.GetAllImages();
            ImageCollection.Clear();

            foreach (var dao in retrievedImages)
            {
                var img = ImageEncodingService.Base64ToSKImage(dao.Base64);
                var galleryImageEntry = new ImageEntry(img, dao.Name, dao.CreationTime, dao.Id);
                if (ImageCollection.ContainsKey(dao.CreationTime.Date))
                {
                    ImageCollection[dao.CreationTime.Date].Add(galleryImageEntry);
                }
                else
                {
                    ImageCollection.Add(dao.CreationTime.Date, new GalleryImageSection(dao.CreationTime.Date));
                    ImageCollection[dao.CreationTime.Date].Add(galleryImageEntry);
                }
            }
        }
        public async void AddMemeAsync()
        {
            try
            {
                if (!string.IsNullOrEmpty(url))
                {
                    var value = await _tronaldDumpService.GetMemeAsync(url);

                    if (value != null)
                    {
                        var id = 1;

                        if (ImageCollection.Count > 0)
                        {
                            id = ImageCollection.Last().Id + 1;
                        }

                        var meme = new MemeDbItem
                        {
                            Id    = id,
                            Image = value
                        };

                        ImageCollection.Add(meme);
                        if (Device.RuntimePlatform == Device.Android || Device.RuntimePlatform == Device.UWP)
                        {
                            await _databaseService.AddMeme(meme);
                        }
                    }
                    else
                    {
                        _toastMessage.ShowToast(commonErrorMessage);
                    }
                }
                else
                {
                    _toastMessage.ShowToast(apiErrorMessage);
                }
            }
            catch { _toastMessage.ShowToast(commonErrorMessage); }
        }
        /// <summary>
        /// Selects the Chart resource.
        /// </summary>
        public static Stream SelectChartResource()
        {
            string[] chartResourceNames = DemosResourcesManager.FindResourceNames("Chart_");

            // if collection of chart images is not created
            if (_chartImages == null)
            {
                // create collection of chart images
                _chartImages = new ImageCollection();
                _chartImages.LayoutSettingsRequest += ChartImages_LayoutSettingsRequest;
                foreach (string chartResourceName in chartResourceNames)
                {
                    _chartImages.Add(DemosResourcesManager.GetResourceAsStream(chartResourceName), true);
                }
            }
            if (_chartImages.Count == 0)
            {
                throw new Exception("Chart resources was not found.");
            }

            // create "Select image" form
            SelectImageForm selectImageForm = new SelectImageForm(_chartImages);

            selectImageForm.Size = new Size(900, 550);
            selectImageForm.ImagePreviewViewer.ThumbnailSize      = new Size(200, 200);
            selectImageForm.ImagePreviewViewer.ThumbnailFlowStyle = ThumbnailFlowStyle.WrappedRows;
            selectImageForm.ImagePreviewViewer.SelectedThumbnailAppearance.BorderColor = Color.Black;
            selectImageForm.ImagePreviewViewer.FocusedThumbnailAppearance = selectImageForm.ImagePreviewViewer.SelectedThumbnailAppearance;
            selectImageForm.Text    = "Select a chart";
            selectImageForm.TopMost = true;

            if (selectImageForm.ShowDialog() != DialogResult.OK)
            {
                return(null);
            }

            string selectedChartResourceName = chartResourceNames[selectImageForm.SelectedImageIndex];

            return(DemosResourcesManager.GetResourceAsStream(selectedChartResourceName));
        }
示例#23
0
        public HomePage()
        {
            InitializeComponent();
            BindingContext = this;
            if (Device.RuntimePlatform == Device.Android || Device.RuntimePlatform == Device.iOS)
            {
                ImageCollection.Add(new RotatorModel("Confeccion.jpg"));
                ImageCollection.Add(new RotatorModel("Tejeduria.jpg"));
                ImageCollection.Add(new RotatorModel("Tintoreria.jpg"));
                ImageCollection.Add(new RotatorModel("Rama.jpg"));
                ImageCollection.Add(new RotatorModel("Lavanderias.jpg"));
            }
            //var ImageCollection = new List<RotatorModel> {
            //new RotatorModel ("Confeccion.jpg"),
            //new RotatorModel ("Tejeduria.jpg"),
            //new RotatorModel ("Tintoreria.jpg"),
            //new RotatorModel ("Rama.jpg"),
            //new RotatorModel ("Lavanderias.jpg"),
            //};

            //rotator.ItemsSource = ImageCollection;
        }
示例#24
0
        private void ShowPics(string[] sFiles)
        {
            bool[] bAdd = new bool[sFiles.Length]; int iAdd = 0;
            for (int a = 0; a < sFiles.Length; a++)
            {
                sFiles[a] = sFiles[a].ToLower();
                if (sFiles[a].EndsWith(".png") ||
                    sFiles[a].EndsWith(".jpg") ||
                    sFiles[a].EndsWith(".gif"))
                {
                    bAdd[a] = true;
                    iAdd++;
                }
            }
            int iCnt = 0;

            id = new ImageData[iAdd];
            for (int a = 0; a < sFiles.Length; a++)
            {
                if (bAdd[a])
                {
                    id[iCnt]       = new ImageData();
                    id[iCnt].sPath = sFiles[a];
                    id[iCnt].sHash = sFiles[a];
                    iCnt++;
                }
            }
            for (int a = 0; a < id.Length; a++)
            {
                th.Add(id[a].sHash, id[a].sPath, 0,
                       ImageCollection.imType.Thumbnail);
            }
            thViewer.DrawControls(id.Length);
            thViewer.FlushDisplay();
            Application.DoEvents();
            th.Load();
            thViewer.DisplayImages(new Point(0, id.Length), id, th);
            tShowThumbs.Start();
        }
示例#25
0
        public void Cleaning()
        {
            using (ImageCollection images = new ImageCollection())
            {
                images.Add(pathImage + "photo.jpg");

                try
                {
                    try
                    {
                        foreach (VintasoftImage image in images)
                        {
                            ExecuteCommand(new AutoInvertCommand(), image);                  //invert an image if image is inverted
                            ExecuteCommand(new BorderClearCommand(), image);                 //clear noise on a border of the image
                            ExecuteCommand(new HalftoneRemovalCommand(), image);             //remove halftone from the image
                            ExecuteCommand(new DeskewCommand(), image);                      // detect the correct orientation of the image
                            ExecuteCommand(new HolePunchRemovalCommand(), image);            // remove hole punches on image
                            ExecuteCommand(new LineRemovalCommand(LinesType.Tables), image); //remove tables on image
                            ExecuteCommand(new AutoTextInvertCommand(),
                                           image);                                           // invert inverted text regions on an image
                            ExecuteCommand(new DespeckleCommand(), image);                   // remove noise from the image
                            ExecuteCommand(new BorderRemovalCommand(), image);               // remove border around the image
                        }
                    }
                    catch (ImageProcessingException ex)
                    {
                        Console.WriteLine(ex.Message);
                        return;
                    }

                    images.SaveAsync(pathImage + "image.tif");
                }
                finally
                {
                    images.ClearAndDisposeItems();
                }
            }
        }
        public void ConvertToGrayScale(string sourceFile, string targetFile)
        {
            MultiFramedImageEncoder encoder = new TiffEncoder();

            using (ImageSource src = new FileSystemImageSource(sourceFile, true))
            {
                ImageCollection images = new ImageCollection();

                while (src.HasMoreImages())
                {
                    AtalaImage img = src.AcquireNext();

                    img = img.GetChangedPixelFormat(PixelFormat.Pixel8bppGrayscale);
                    images.Add(img);
                    //img.Dispose();
                }

                using (Stream s = File.Create(targetFile))
                {
                    encoder.Save(s, images, null);
                }
            }
        }
示例#27
0
        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(tbSearch.Text))
            {
                // Effectively reset the results when searching for nothing
                DataGridSource = Images;
                ClearDataGridSearch();
            }
            else
            {
                List <string>   searchTerms   = tbSearch.Text.Split(',').ToList();
                ImageCollection searchResults = new ImageCollection();

                foreach (string term in searchTerms)
                {
                    Regex pattern = new Regex(term.ToLower().Trim());
                    foreach (ImageModel model in Images)
                    {
                        bool matchWasFound = IsPatternMatch(pattern, model.Author.ToLower()) ||
                                             IsPatternMatch(pattern, model.Title.ToLower()) ||
                                             IsPatternMatch(pattern, model.Description.ToLower()) ||
                                             IsPatternMatch(pattern, model.Keywords.ToLower());

                        bool unique = !searchResults.ContainsId(model.Id);

                        if (matchWasFound && unique)
                        {
                            searchResults.Add(model);
                        }
                    }
                }

                DataGridSource = searchResults;
                dataGridImageCollection.ItemsSource = DataGridSource;
                dataGridImageCollection.Items.Refresh();
            }
        }
        public TronaldDumpMemePageViewModel(ITronaldDumpService tronaldDumpService, IDatabaseService databaseService, ISettingsService settingsService, IToastMessage toastMessage)
        {
            _tronaldDumpService = tronaldDumpService;
            _databaseService    = databaseService;
            _settingsService    = settingsService;
            _toastMessage       = toastMessage;

            OnAddMemeCommand    = new DelegateCommand(AddMemeAsync, CanAddMemeAsync);
            OnDeleteMemeCommand = new DelegateCommand(DeleteMeme, CanDeleteMeme);

            ImageCollection.CollectionChanged += ImageCollection_CollectionChanged;

            var dbJokes = _databaseService.GetMemes();

            if (dbJokes != null)
            {
                foreach (var item in dbJokes)
                {
                    ImageCollection.Add(item);
                }
            }

            LoadSettings();
        }
示例#29
0
        void IDropTarget.Drop(IDropInfo dropInfo)
        {
            dropInfo.Effects = DragDropEffects.Copy;

            var dragFileList = ((DataObject)dropInfo.Data).GetFileDropList();

            String[] fileList = (string[])((DataObject)dropInfo.Data).GetData(DataFormats.FileDrop);

            ImageCollection.Clear();
            for (int i = 0; i < dragFileList.Count; i++)
            {
                ImageCollection.Add(new ImageObject
                {
                    displayName = dragFileList[i],
                    location    = dragFileList[i]
                });
            }

            if (fileList.Count() > 0)
            {
                // backend.HandleFileDrop(SaveMainImage, fileList, UpdateConsole);
                backend.HandleFileDrop(SaveMainImage, fileList);
            }
        }
 private void button1_Click_1(object sender, RoutedEventArgs e)
 {
     imageCollection1 = new ImageCollection();
     ObjectDataProvider imageSource1 = (ObjectDataProvider)FindResource("ImageCollection1");
     imageSource1.ObjectInstance = imageCollection1;
     String[] photos = client.getAlbumPhotos(comboBox1.Text);
     for (int i = 0; i < photos.Length; i++)
     {
         WebServeur.ImageInfo info = new WebServeur.ImageInfo();
         info.imageID = photos[i];
         Stream stream = client.DownloadImage(info);
         MemoryStream imageStreamEnMemoire = new MemoryStream();
         stream.CopyTo(imageStreamEnMemoire);
         Byte[] bytes = imageStreamEnMemoire.ToArray();
         imageCollection1.Add(new ImageObjet(photos[i], bytes));
     }
 }
示例#31
0
文件: TiXMain.cs 项目: RyuaNerin/QIT
        static int Main(string[] args)
        {
            if ((args.Length == 4) && args[0].Equals("install", StringComparison.OrdinalIgnoreCase))
                return (int)ShellExtension.Install(args[1] == "1", args[2] == "1", args[3], true);

            if (args.Length == 1 && args[0].Equals("uninstall", StringComparison.OrdinalIgnoreCase))
                return (int)ShellExtension.Uninstall(true);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            TiX.ExternalLibrary.Resolver.Init(typeof(Properties.Resources));
            CrashReport.Init();

            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            #if !DEBUG
            System.Net.HttpWebRequest.DefaultWebProxy = null;
            #endif
            System.Net.HttpWebRequest.DefaultCachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
            System.Net.ServicePointManager.MaxServicePoints = 20;

            Settings.Load();
            TiXMain.Twitter.UserToken  = Settings.UToken;
            TiXMain.Twitter.UserSecret = Settings.USecret;

            int i;

            if (args.Length >= 1 && args[0].Equals("stasis", StringComparison.OrdinalIgnoreCase))
            {
                Image cropedImage;
                using (var stasisForm = new Stasisfield())
                {
                    Application.Run(stasisForm);
                    cropedImage = stasisForm.CropedImage;
                }

                if (cropedImage != null)
                {
                    if (args.Length == 3)
                        TweetModerator.Tweet(cropedImage, false, "캡처 화면 전송중", args[1], args[2]);
                    else
                        TweetModerator.Tweet(cropedImage, false, "캡처 화면 전송중");
                }

                return 0;
            }
            else if (args.Length >= 1)
            {
                var data = new ImageCollection();
                bool autoStart = args.Any(e => e.Equals("--notext", StringComparison.OrdinalIgnoreCase));

                var lst = new List<string>(args.Length);

                if (args.Any(e => e.Equals("--pipe", StringComparison.OrdinalIgnoreCase)))
                {
                    var reader = new StreamReader(Console.OpenStandardInput(), Encoding.UTF8);
                    string path;
                    while (true)
                    {
                        path = reader.ReadLine();
                        if (string.IsNullOrEmpty(path)) break;

                        if (CheckFile(path))
                            lst.Add(path);
                    }
                }
                else
                {
                    for (i = 0; i < args.Length; ++i)
                        if (CheckFile(args[i]))
                            lst.Add(args[i]);
                }

                if (lst.Count == 0) return 0;

                data.Add(lst);

                Application.Run(new frmUpload(data, true) { AutoStart = autoStart });
                return 0;
            }

            Form frm;
            using (var instance = new InstanceHelper(InstanceName))
            {
                if (instance.Check())
                {
                    if (String.IsNullOrEmpty(Settings.UToken) | String.IsNullOrEmpty(Settings.USecret))
                    {
                        using (frm = new frmPin())
                        {
                            Application.Run(instance.MainWindow = frm);

                            if (frm.DialogResult != DialogResult.OK)
                                return 0;
                        }
                    }

                    frm = new frmMain();
                    Application.Run(instance.MainWindow = frm);
                }
            }

            return 0;
        }
示例#32
0
 public override ImageCollection GetImagesByCategoryID(int catID, bool activeOnly)
 {
     IDataReader reader = DbProvider.Instance().GetImagesByCategoryID(catID, activeOnly);
     try
     {
         ImageCollection ic = new ImageCollection();
         while(reader.Read())
         {
             ic.Category = DataHelper.LoadLinkCategory(reader);
             break;
         }
         reader.NextResult();
         while(reader.Read())
         {
             ic.Add(DataHelper.LoadImage(reader));
         }
         return ic;
     }
     finally
     {
         reader.Close();
     }
 }
示例#33
0
 public CarouselViewModel()
 {
     ImageCollection.Add(new CarouselModel("header_wallpaper.jpg"));
 }
 public override ImageCollection GetImagesByCategoryId(int categoryId, bool activeOnly)
 {
     using (IDataReader reader = _procedures.GetImageCategory(categoryId, activeOnly, BlogId))
     {
         var ic = new ImageCollection();
         while (reader.Read())
         {
             ic.Category = reader.ReadLinkCategory();
             break;
         }
         reader.NextResult();
         while (reader.Read())
         {
             ic.Add(reader.ReadImage());
         }
         return ic;
     }
 }
        /// <summary>
        /// Opens a form that allows to select image of image collection
        /// and returns image collection and selected index.
        /// </summary>
        /// <param name="filename">The filename of image file.</param>
        /// <param name="selectedIndex">Selected index.</param>
        /// <returns>Image collection.</returns>
        public static ImageCollection SelectImageFromFile(string filename, out int selectedIndex)
        {
            selectedIndex = -1;

            // create image collection
            ImageCollection images = new ImageCollection();

            DocumentPasswordForm.EnableAuthentication(images);
            try
            {
                try
                {
                    // add an image file to the image collection
                    images.Add(filename);
                }
                catch (Exception e)
                {
                    DemosTools.ShowErrorMessage(e);
                    return(null);
                }

                selectedIndex = 0;


                // if image file contains more than 1 image
                if (images.Count > 1)
                {
                    // create a dialog that allows to select image from multipage image file
                    using (SelectImageForm selectImageForm =
                               new SelectImageForm(images))
                    {
                        // show the dialog
                        DialogResult result = selectImageForm.ShowDialog();
                        // if image is selected
                        if (result == DialogResult.OK)
                        {
                            // get the selected index
                            selectedIndex = selectImageForm.SelectedImageIndex;
                        }
                        else
                        {
                            selectedIndex = -1;
                        }
                    }
                }
            }
            finally
            {
                DocumentPasswordForm.DisableAuthentication(images);

                // if image is not selected
                if (selectedIndex == -1)
                {
                    // clear and dispose images from the image collection
                    images.ClearAndDisposeItems();

                    // dispose image collection
                    images.Dispose();
                }
            }
            return(images);
        }
示例#36
0
 /// <summary>
 /// Rotator View Model Constructor.
 /// </summary>
 public RotatorViewModel()
 {
     ImageCollection.Add(new RotatorModel("image2.png"));
     ImageCollection.Add(new RotatorModel("image2.png"));
     ImageCollection.Add(new RotatorModel("image2.png"));
 }
示例#37
0
 public void ImportImages(string aLocation)
 {
     ImageCollection result = new ImageCollection();
     List<string> images = FileExtension.GetFiles(aLocation, "*.jpg");
     if (images.HasElement())
     {
         foreach (string item in images)
         {
             if (File.Exists(item))
             {
                 result.Add(new ImageDataModel() { FullName = item, FileName = Path.GetFileName(item) });
             }
         }
     }
     FImageList.Clear();
     FImageList.AddRange(result);
     CurrentImageIndex = -1;
 }
示例#38
0
 /// <summary>
 /// 提取为序列图格式
 /// </summary>
 /// <param name="source">压缩源</param>
 /// <param name="path">关键字</param>
 /// <returns></returns>
 private ImageCollection ExtractToImageCollection(SevenZipArchive source, string path)
 {
     ImageCollection collection = new ImageCollection();
     MemoryStream stream;
     foreach (ArchiveEntry entry in source)
     {
         if (!entry.IsDirectory && entry.FileName.Contains(path))
         {
             stream = new MemoryStream();
             entry.Extract(stream);
             collection.Add(stream);
         }
     }
     return collection;
 }