//===========================================================================================//

        public async Task StartAsync()
        {
            IsRunning = true;

            images = Directory.GetFiles(ImagesPath);

            Photos = await GenerateImagesFromPathsAsync();

            Photos = await RemoveRecognizedImagesAsync();

            if (Photos.Count == 0)
            {
                IsRunning = false;
                return;
            }

            ImagesCount   = Photos.Count;
            ImagesCounter = 0;

            await server.StartAsync(await PrepareDataForSendingAsync(onnxModelPath, Photos));

            IsStopping = true;

            await server.SaveAsync();

            Photos.Clear();

            IsStopping = false;
            IsRunning  = false;
        }
Beispiel #2
0
        public async Task GetPhotos()
        {
            if (IsBusy)
            {
                return;
            }

            Exception error = null;

            try
            {
                IsBusy = true;
                var items = await mobileService.GetPhotos();

                Photos.Clear();
                foreach (var item in items)
                {
                    Photos.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error: " + ex);
                error = ex;
            }
            finally
            {
                IsBusy = false;
            }

            if (error != null)
            {
                dialogService.ShowError("Error! " + error.Message + " OK");
            }
        }
Beispiel #3
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Photos.Clear();

                var photos = await restService.GetPhotos();

                foreach (var photo in photos)
                {
                    Photos.Add(photo);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Beispiel #4
0
 public void FillPage()
 {
     if (Exhibit.Photos?.Count != 0)
     {
         Photos.Clear();
         foreach (var photo in Exhibit.Photos)
         {
             if (photo?.Photo != null)
             {
                 Photos.Add(ImageSource.FromStream(() => new MemoryStream(photo.Photo)));
             }
         }
         CarouselVisibility = true;
         if (Photos.Count == 1)
         {
             IndicatorVisibility = false;
         }
         else
         {
             IndicatorVisibility = true;
         }
     }
     else
     {
         CarouselVisibility = false;
     }
     Title = Exhibit.Title;
     Text  = Exhibit.Text;
 }
        /// <summary>
        /// Updates <see cref="Photos"/> so it holds the CurrentFolder's Files - Photos.
        /// </summary>
        private void UpdatePhotos(DoWorkEventArgs e)
        {
            // First clear the current photos
            System.Windows.Application.Current.Dispatcher.BeginInvoke((Action)(() => Photos.Clear()), DispatcherPriority.Background);

            // Check if the folder was created/loaded before
            if (!this.photoDictionary.ContainsKey(CurrentFolder))
            {
                // This is the first time initialization of the CurrentFolder's Photos OR the dictionary has removed some key-value pairs and needs reinitialization
                this.photoDictionary[CurrentFolder] = new List <Photo>();
            }

            for (int i = 0; i < CurrentFolder.Files.Count; i++)
            {
                if (this.refreshWorker.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }

                FileInfo file  = CurrentFolder.Files[i];
                Photo    photo = new Photo(new Uri(file.FullName), file.Name, file.Extension);

                if (this.photoDictionary[CurrentFolder].Contains(photo))
                {
                    // Work was cancelled, but photo was already created, so no need to do it twice. Go to the next iteration and check the next photo
                    continue;
                }
                photo.RefreshBitmapSource(BitmapType.Thumbnail);
                this.photoDictionary[CurrentFolder].Add(photo);

                int progressPercentage = i + 1 / CurrentFolder.Files.Count;
                this.refreshWorker.ReportProgress(progressPercentage, photo);
            }
        }
Beispiel #6
0
        protected async Task RefreshView()
        {
            Photos.Clear();


            await LoadPhotos();
        }
Beispiel #7
0
        public void OnAppearing()
        {
            eventAggregator.GetEvent <TabActivatedEvent>().Publish(nameof(HomePageViewModel));

            if (!hasAppeared)
            {
                hasAppeared = true;

                Task.Run(async() =>
                {
                    var photos = await unsplashService.GetRandomPhotosAsync(10);

                    if (photos != null)
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            Photos.Clear();
                            foreach (var photo in photos)
                            {
                                Photos.Add(photo);
                            }
                        });
                    }
                });
            }
        }
Beispiel #8
0
 private void UpdateList(IEnumerable <Photo> photos)
 {
     Photos.Clear();
     foreach (var photo in photos)
     {
         Photos.Add(photo);
     }
 }
Beispiel #9
0
 public void FillPage()
 {
     Photos.Clear();
     foreach (var photo in Exhibit.Photos)
     {
         Photos.Add(photo);
     }
     Title = Exhibit.Title;
 }
 protected override void ClearForm(object obj)
 {
     Title             = string.Empty;
     SelectedCategory  = null;
     SelectedDaysCount = null;
     Photos.Clear();
     Description = string.Empty;
     StartBid    = string.Empty;
 }
        private void LoadImageList()
        {
            Photos.Clear();
            var data = inOutService.LoadPhotoData();

            foreach (var photoData in data)
            {
                Photos.Add(photoViewModelFactory.CreatePhotoViewModel(photoData));
            }
        }
        void SortByTime()
        {
            List <PhotosListModel> listModels = Photos.ToList();

            listModels.Sort((emp1, emp2) => emp1.CreationTime.CompareTo(emp2.CreationTime));
            Photos.Clear();
            foreach (var photosListModel in listModels)
            {
                Photos.Add(photosListModel);
            }
        }
        public void OnLoad()
        {
            Photos.Clear();

            var photos = photoRepository.GetAll();

            foreach (var photo in photos)
            {
                Photos.Add(photo);
            }
        }
Beispiel #14
0
 private void textBox1_TextChanged(object sender, EventArgs e)
 {
     progress.Hide();
     Photos.Clear();
     listBox1.Items.Clear();
     button1.Enabled = true;
     button2.Visible = false;
     Offset          = 0;
     allcount        = 0;
     count           = 0;
 }
        public async Task ClearAsync()
        {
            IsClearing = true;

            await server.ClearAsync();

            Recognitions.Clear();
            Photos.Clear();
            ImagesCounter = 0;

            IsClearing = false;
        }
Beispiel #16
0
        private async void Search(string searchTerm)
        {
            IsBusy      = true;
            _searchTerm = searchTerm;

            _currentPage = 1;
            Photos.Clear();

            var results = await _flickrApi.SearchPhotos(_searchTerm, _currentPage, PageSize);

            foreach (var photo in results)
            {
                Photos.Add(photo);
            }
            IsBusy = false;
        }
Beispiel #17
0
        private async Task UpdatePhotosAsync(bool isForce = false)
        {
            IsProblem = false;
            try
            {
                DispatcherHelper.UIDispatcher.BeginInvoke(
                    delegate
                {
                    IsRefreshingPhotos = true;

                    if (Photos == null)
                    {
                        Photos = new ObservableCollection <Article>();
                    }
                    Photos.Clear();
                });
                var tempArticles = await _dataService.GetArticlesAsync(DataService.PHOTOS, isForce);

                if (tempArticles != null && tempArticles.Count > 0)
                {
                    DispatcherHelper.UIDispatcher.BeginInvoke(
                        delegate
                    {
                        if (Categories == null)
                        {
                            Categories = new ObservableCollection <Category>();
                            _dataService.ListOfCategories.ForEach(o => Categories.Add(o));
                        }
                        Category categoryDetails = Categories.FirstOrDefault(o => o.CategoryName.ToLower() == DataService.PHOTOS.ToLower());

                        foreach (var article in tempArticles.ToList())
                        {
                            Photos.Add(article);
                        }
                        IsRefreshingPhotos = false;
                    });
                }
                else
                {
                    IsProblem          = true;
                    IsRefreshingPhotos = false;
                }
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #18
0
        private void Refresh()
        {
            try
            {
                this.Cursor = Cursors.Wait;

                dpnlImageViewer.Visibility = Visibility.Hidden;
                btnBack.Visibility         = Visibility.Hidden;

                m_photos.Clear();

                if (trvRootData.SelectedItem == trvFavoriteData)
                {
                    foreach (TreeViewItem item in trvFavoriteData.Items)
                    {
                        AddPhotosInFolder(item.Tag as string);
                    }
                    mnuFavorites.IsEnabled = false;
                }
                else if (trvRootData.SelectedItem != trvFolderData)
                {
                    string folder = (trvRootData.SelectedItem as TreeViewItem).Tag as string;
                    AddPhotosInFolder(folder);

                    mnuFavorites.IsEnabled = true;

                    foreach (TreeViewItem item in trvFavoriteData.Items)
                    {
                        if (item.Header as string == folder)
                        {
                            mnuFavorites.Header = REMOVE_FAVORITES;
                            return;
                        }
                    }
                    mnuFavorites.Header = ADD_FAVORITES;
                }
            }
            finally
            {
                this.Cursor = Cursors.Arrow;
            }
        }
        void StartScan()
        {
            if (scanThread != null)
            {
                CancelScan();
            }
            if (activeSource == null)
            {
                return;
            }

            var source = activeSource.GetFileImportSource(
                App.Instance.Container.Resolve <IImageFileFactory> (),
                App.Instance.Container.Resolve <IFileSystem> ());

            Photos.Clear();

            scanTokenSource = new CancellationTokenSource();
            scanThread      = ThreadAssist.Spawn(() => DoScan(source, recurseSubdirectories, mergeRawAndJpeg, scanTokenSource.Token));
        }
Beispiel #20
0
        public async Task <Result> GetPhotosAsync()
        {
            Photos.Clear();


            IsBusy = true;

            var result = await _photoCameraRepository.GetMaxSolAsync(_citizen.NormalizedName);

            IsBusy = false;

            if (result.IsFailure)
            {
                return(Result.Fail(result.Error));
            }

            _currentSol = result.Value;



            GetPhotosForCurrentSolAsync();

            return(Result.Ok());
        }
 private void InitialiseProperty(property prop)
 {
     PropertyId = prop.property_id;
     Name       = prop.name;
     Area       = prop.area;
     LandPrice  = ( double )prop.min_price.plot_price;
     HousePrice = ( double )prop.min_price.apartment_price;
     Latitude   = prop.latitude;
     Longitude  = prop.longitude;
     SellerId   = prop.seller_id;
     Category   = prop.category;
     Type       = prop.category1.type;
     Status     = prop.propery_status.status;
     if (null != Photos)
     {
         Photos.Clear();
     }
     else
     {
         Photos = new List <string>();
     }
     foreach (var image in prop.images)
     {
         byte[] photo    = image.image1;
         string imageSrc = null;
         if (photo != null)
         {
             MemoryStream ms = new MemoryStream();
             ms.Write(photo, 0, photo.Length);
             //ms.Write( photo, 78, photo.Length - 78 ); // strip out 78 byte OLE header (don't need to do this for normal images)
             string imageBase64 = Convert.ToBase64String(ms.ToArray());
             imageSrc = string.Format("data:image/gif;base64,{0}", imageBase64);
             Photos.Add(imageSrc);
         }
     }
 }
        /// <summary>
        /// get the list of the photos
        /// </summary>
        private void getListPhotos()
        {
            List <PhotoWeb> list = new List <PhotoWeb>();

            if (DirectoryOutput != null)
            {
                string   path      = cutPath(DirectoryOutput, "C:", 2);
                string   outputDir = @"../../" + path;
                string[] files     = Directory.GetFiles(outputDir, "*", SearchOption.AllDirectories);
                Photos.Clear();
                foreach (string photo in files)
                {
                    string fileEnding = Path.GetExtension(photo);
                    if (fileEnding.Equals(".png", StringComparison.CurrentCultureIgnoreCase) ||
                        fileEnding.Equals(".gif", StringComparison.CurrentCultureIgnoreCase) ||
                        fileEnding.Equals(".jpg", StringComparison.CurrentCultureIgnoreCase) ||
                        fileEnding.Equals(".bmp", StringComparison.CurrentCultureIgnoreCase))
                    {
                        numOfPic++;
                        PhotoWeb temp = new PhotoWeb()
                        {
                            PhotoToShow = @"~/" + cutPath(getNamePath(photo), "ImageServiceWeb", 15),
                            Photo       = getNamePath(photo),
                            PhotoName   = newGetName(photo),
                            PhotoDate   = getDataFromPic(photo),
                            ThumbPhoto  = @"~/" + cutPath(photo, "ImageServiceWeb", 15),
                            FullPath    = photo
                        };
                        if (Photos != null && temp.ThumbPhoto.Contains("Thumbnail"))
                        {
                            Photos.Insert(0, temp);
                        }
                    }
                }
            }
        }
Beispiel #23
0
 private async void OnRefresh()
 {
     Photos.Clear();
     await Photos.Refresh();
 }
 protected virtual void ClearNavigationProperties()
 {
     Photos.Clear();
     Photos2Locations.Clear();
 }
Beispiel #25
0
        protected void FillSearchCriterias()
        {
            SortAscending = false;
            Countries.Clear();
            Groups.Clear();
            Genders.Clear();
            CalendarPrivacy.Clear();
            MeasurementPrivacy.Clear();
            Photos.Clear();
            Plans.Clear();
            SearchStatus = string.Empty;
            SortOrders.Clear();

            foreach (var test in Country.Countries)
            {
                CheckListItem <Country> item = new CheckListItem <Country>(test.DisplayName, test);
                Countries.Add(item);
            }

            foreach (UserSearchGroup test in Enum.GetValues(typeof(UserSearchGroup)))
            {
                var item = new CheckListItem <UserSearchGroup>(EnumLocalizer.Default.Translate(test), test);
                Groups.Add(item);
            }

            foreach (Gender test in Enum.GetValues(typeof(Gender)))
            {
                var item = new CheckListItem <Gender>(EnumLocalizer.Default.Translate(test), test);
                Genders.Add(item);
            }

            foreach (PrivacyCriteria test in Enum.GetValues(typeof(PrivacyCriteria)))
            {
                var item = new CheckListItem <PrivacyCriteria>(EnumLocalizer.Default.Translate(test), test);
                CalendarPrivacy.Add(item);
            }
            foreach (PrivacyCriteria test in Enum.GetValues(typeof(PrivacyCriteria)))
            {
                var item = new CheckListItem <PrivacyCriteria>(EnumLocalizer.Default.Translate(test), test);
                MeasurementPrivacy.Add(item);
            }

            foreach (UsersSortOrder test in Enum.GetValues(typeof(UsersSortOrder)))
            {
                var item = new CheckListItem <UsersSortOrder>(EnumLocalizer.Default.Translate(test), test);
                SortOrders.Add(item);
            }

            foreach (PictureCriteria test in Enum.GetValues(typeof(PictureCriteria)))
            {
                var item = new CheckListItem <PictureCriteria>(EnumLocalizer.Default.Translate(test), test);
                Photos.Add(item);
            }
            foreach (UserPlanCriteria test in Enum.GetValues(typeof(UserPlanCriteria)))
            {
                var item = new CheckListItem <UserPlanCriteria>(EnumLocalizer.Default.Translate(test), test);
                Plans.Add(item);
            }


            SelectedCalendarPrivacy    = PrivacyCriteria.All;
            SelectedMeasurementPrivacy = PrivacyCriteria.All;
            SelectedPhoto     = PictureCriteria.All;
            SelectedPlan      = UserPlanCriteria.All;
            SelectedSortOrder = UsersSortOrder.ByLastLoginDate;
        }
 protected virtual void ClearNavigationProperties()
 {
     AdditionalAttribute = null;
     Photos.Clear();
     ExifAttribute = null;
 }
Beispiel #27
0
        /// <summary>
        /// 写真読み込み家の初期化
        /// </summary>
        private void PhotoInitialize()
        {
            #region ファイル読み込み
            SelectPhotoDirCommand = new ReactiveCommand();
            SelectPhotoDirCommand.Subscribe(() => SelectDirectory(path => {
                Config.Value.PhotoDir = path;
                Config.ForceNotify();
            }));
            SelectExportDirCommand = new ReactiveCommand();
            SelectExportDirCommand.Subscribe(() => SelectDirectory(path => {
                Config.Value.ExportDir = path;
                Config.ForceNotify();
            }));
            ReadPhotoCommand = new ReactiveCommand();
            ReadPhotoCommand.Subscribe(async() => {
                IsPhotoUIEnable.Value = false;

                var photos = await LoadPhotos(new Progress <string>(msg => Log(msg)));
                //反映
                Photos.Clear();
                Tags.Clear();
                Photos.AddRangeOnScheduler(photos);
                Tags.AddRangeOnScheduler(Config.Value.Tags);

                IsPhotoUIEnable.Value = true;
                Log($"{photos.Length}枚の画像を読み込み。プレビュー画像が古い場合、{Config.Value.PreviewTempPath}を削除してから再度実行してください。");
            });
            #endregion

            // フィルタ
            IsPhotoUIEnable.PropertyChangedAsObservable()
            .Select(x => Photos.AsEnumerable())
            .CombineLatest(TagFilterAll, TagFilterNone, TagFilterTag, TagFilterSelectedTag,
                           (p, isAll, isNone, isTag, tagText) => {
                // RadioButtonが2回判定が来る, trueがふたつあるときは無視
                if ((isAll ? 1 : 0) + (isNone ? 1 : 0) + (isTag ? 1 : 0) > 1)
                {
                    return(null);
                }
                if (isAll)
                {
                    return(p);
                }
                else if (isNone)
                {
                    return(p.Where(x => x.TagDetails.Length == 0));
                }
                else if (isTag)
                {
                    return(p.Where(x => x.TagDetails.Any(t => t.ToString().Equals(tagText))));
                }
                else
                {
                    throw new NotImplementedException();
                }
            })
            .Where(photos => photos != null)
            .Subscribe(photos => {
                FilteredPhotos.Clear();
                FilteredPhotos.AddRangeOnScheduler(photos);
            });
            #region ファイル名変更
            SelectedPhoto.Where(x => x != null)
            .Subscribe(p => {
                ChangeFileName.Value = p.OriginalName;
            });
            ChangeFileNameCommand =
                ChangeFileName.Select(x => !string.IsNullOrWhiteSpace(x))
                .ToReactiveCommand();
            ChangeFileNameCommand.Subscribe(() => {
                var oldName = SelectedPhoto.Value.OriginalName;
                var newName = ChangeFileName.Value;
                var newPath = Path.GetFullPath($"{Config.Value.PhotoDir}/{newName}");
                if (File.Exists(newPath))
                {
                    Log("すでに存在するファイル名です");
                    return;
                }
                File.Move(SelectedPhoto.Value.OriginalPath, newPath);
                SelectedPhoto.Value.OriginalName = newName;
                // サムネが消えるのでリロードする
                SelectedPhoto.Value.GeneratePreviewImage();

                Log($"ファイル名を変更 {oldName} -> {newName}");
            });
            #endregion

            #region Tag
            AddTagCommand =
                NewTagName.Select(x => !string.IsNullOrWhiteSpace(x))
                .ToReactiveCommand(false);

            AddTagCommand.Subscribe(() => {
                var tag = Tags.FirstOrDefault(x => x.Name.Equals(NewTagName.Value));
                if (tag == null)
                {
                    Tags.AddOnScheduler(new Tag()
                    {
                        CreateAt    = DateTime.Now,
                        Name        = NewTagName.Value,
                        Description = NewTagDescription.Value,
                    });
                }
                else
                {
                    tag.Description = NewTagDescription.Value;
                }
            });
            ToggleTagCommand =
                SelectedPhoto.Select(x => x != null)
                .ToReactiveCommand <Tag>(false);
            //タグがある場合は削除、なければ追加
            ToggleTagCommand.Subscribe(t => {
                var tagList = SelectedPhoto.Value.TagDetails.ToList();
                var target  = tagList.FirstOrDefault(x => x.Name.Equals(t.Name));
                if (target != null)
                {
                    tagList.Remove(target);
                }
                else
                {
                    tagList.Add(t);
                }
                SelectedPhoto.Value.TagDetails = tagList.ToArray();
                SelectedPhoto.ForceNotify();
            });
            #endregion

            #region Export
            ExportCommand = IsPhotoUIEnable.ToReactiveCommand();
            ExportCommand.Subscribe(async() => {
                IsPhotoUIEnable.Value = false;
                // ファイルの削除
                if (Directory.Exists(Config.Value.ExportDir))
                {
                    Directory.Delete(Config.Value.ExportDir, true);
                    Log($"{Config.Value.ExportDir}を削除");
                }
                // データのエクスポート
                await ExportPhotos(new Progress <string>(msg => Log(msg)));
                // Webから参照するデータをエクスポートする
                var data    = new JObject() as dynamic;
                data.photos = JArray.FromObject(Photos.ToArray());
                data.tags   = JArray.FromObject(Tags.ToArray());
                data.update = DateTime.Now;
                var json    = JsonConvert.SerializeObject(data, Formatting.Indented);
                File.WriteAllText($"{Config.Value.ExportDir}/{Config.Value.ExportFileName}", json, Encoding.UTF8);
                Log($"{Config.Value.ExportFileName}に設定ファイルを出力");

                // 情報のエクスポート
                Config.Value.Photos = Photos.ToArray();
                Config.Value.Tags   = Tags.ToArray();
                SaveConfig();

                IsPhotoUIEnable.Value = true;
                Log("エクスポート完了");

                Process.Start(Config.Value.ExportDir);
            });

            #endregion

            ClosingCommand = new ReactiveCommand();
            ClosingCommand.Subscribe(() => {
                SaveConfig();
            });
        }
Beispiel #28
0
 private async void OnRefresh()
 {
     _telemetryClient.TrackEvent(TelemetryEvents.RefreshCommandInvoked);
     Photos.Clear();
     await Photos.Refresh();
 }