Exemple #1
0
    public void GetAvatarList(bool forceDownload = false)
    {
        if (!forceDownload)
        {
            if (Database.GetString(Database.Key.IMAGES_INFO) != "")
            {
                Debug.Log("File is there");

                string    allImagesData = Database.GetString(Database.Key.IMAGES_INFO);
                AllImages allImages     = JsonUtility.FromJson <AllImages>(allImagesData);
                for (int i = 0; i < allImages.result.Length; i++)
                {
                    Debug.Log(allImages.result[i].name);
                }
                return;
            }
        }
        Web.Create()
        .SetUrl(Configuration.Instance.GetApi(Configuration.ApiKey.AVATAR_LIST), Web.RequestType.POST, Web.ResponseType.TEXT)

        //.AddHeader("Content-Type", "application/x-www-form-urlencoded")
        .AddHeader("access_token", Database.GetString(Database.Key.ACCESS_TOKEN))
        .SetOnSuccessDelegate((Web _web, Response _response) =>
        {
            JSONNode data = JSONNode.Parse(_response.GetText());
            Database.PutString(Database.Key.IMAGES_INFO, _response.GetText());
            _web.Close();
        })
        .SetOnFailureDelegate((Web _web, Response _response) =>
        {
            Debug.Log(_response.GetText());
            _web.Close();
        })
        .Connect();
    }
Exemple #2
0
        public Tuple <double[, , , ], double[, ]> GetNextEpoch()
        {
            if (AllImages == null)
            {
                throw new Exception("未进行数据初始化");
            }
            if (Index * Epoch > AllImages.Length)
            {
                Index = 0;
            }
            string[] images = AllImages.Skip(Index * Epoch).Take(Epoch).ToArray();
            int      len    = images.Length;

            double[,,,] result = new double[len, 3, ImageHeight, ImageWidth];
            double[,] label    = new double[len, 2];
            for (int index = 0; index < len; index++)
            {
                string filepath = images[index];
                if (filepath.Contains("test_img2"))
                {
                    label[index, 1] = 1;
                }
                else
                {
                    label[index, 0] = 1;
                }
                ConverBitmap(result, index, filepath);
            }
            return(new Tuple <double[, , , ], double[, ]>(result, label));
        }
Exemple #3
0
        public async Task UpdateQueryAsync()
        {
            var raw = await DatabaseAccessService.GetVirtualfolderImagesWithGroupsAndTags(DatabaseId);

            var currentIds = AllImages.Select(i => i.DatabaseId).ToList();
            var rawCount   = raw.Count;

            for (int i = rawCount - 1; i >= 0; i--)
            {
                for (int j = currentIds.Count - 1; j >= 0; j--)
                {
                    if (raw[i].Id == currentIds[j])
                    {
                        raw.RemoveAt(i);
                        currentIds.RemoveAt(j);
                        break;
                    }
                }
            }

            AllImages.RemoveAll(i => currentIds.Contains(i.DatabaseId));

            foreach (var item in raw)
            {
                AllImages.Add(await ImageItem.FromDatabaseImage(item, viewMode: ImageItem.Options.None));
            }

            ReorderImages();
        }
Exemple #4
0
 private void ReportProgressForImageSearch(TheImage obj)
 {
     foundImageCount = (foundImageCount + obj.ImageDirTotalImages);
     //TODO : write here invoke required and invoke to display images found count on form
     //if(InvokeRequired)
     //    Invoke(new Action(() => label13.Text = foundImageCount.ToString() + " images found"));
     AllImages.Add(obj);
 }
        public async void UploadFile(object param)
        {
            if (!CrossMedia.Current.IsPickPhotoSupported)
            {
                await Application.Current.MainPage.DisplayAlert("File Not Supported.", "Permission not granted to files.", "STÄNG");

                return;
            }

            var file = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions
            {
                PhotoSize = PhotoSize.Large,
            });

            if (file != null)
            {
                string[] temp       = file.Path.Split('/');
                string[] tempName   = temp[temp.Length - 1].Split('.');
                string   filename   = tempName[0];
                string   foldername = DateTime.Now.ToString("yyyy-MM-dd") + "/" + DateTime.Now.ToString("H-mm-ss");
                string   filePath   = "Files/NyKvalitetsRapport/" + Application.Current.Properties["CompanyId"].ToString() + "/" + Application.Current.Properties["OfficeId"].ToString() + "/" + foldername + "/" + temp[temp.Length - 1];

                var        content = new MultipartFormDataContent();
                Uri        host    = new Uri("http://www.bisoft.se/Bisoft/receiver.ashx");
                UriBuilder ub      = new UriBuilder(host)
                {
                    Query = string.Format("filename={0}", filePath)
                };

                Stream data = file.GetStream();

                WebClient c = new WebClient();
                c.OpenWriteCompleted += (sender, e) =>
                {
                    PushData(data, e.Result);
                    e.Result.Close();
                    data.Close();

                    if (AllImages == null)
                    {
                        AllImages = new ObservableCollection <QRAttachedFile>();
                    }

                    QRAttachedFile phfile = new QRAttachedFile();
                    phfile.FileName = filename;
                    phfile.FilePath = filePath;
                    phfile.Id       = 0;

                    AllImages.Add(phfile);
                    UpdateUploadedFiles();
                };
                c.OpenWriteAsync(ub.Uri);
            }
            else
            {
                await Application.Current.MainPage.DisplayAlert("File not supported.", "Ingen fil vald.", "STÄNG");
            }
        }
Exemple #6
0
        private UiImageData LocateMenuControls()
        {
            var result = new UiImageData();

            result.RightClickMenu.Drop = AllImages.Where(x => x.ImageName == "drop.bmp").FirstOrDefault();

            var menuControls = AllImages.Where(x => x.ImageName == "view pack contents.bmp" ||
                                               x.ImageName == "top left of chat-action window.bmp" ||
                                               x.ImageName == "combat menu.bmp" ||
                                               x.ImageName == "bottom left of full ui view.bmp"
                                               ).ToList();

            var menuControlsScanData = _imageProcessor.SearchScreenForImages(menuControls).ToList();

            foreach (var mcsd in menuControlsScanData)
            {
                switch (mcsd.ImageData.ImageName)
                {
                case "view pack contents.bmp":
                    result.PackContents = mcsd;
                    break;

                case "top left of chat-action window.bmp":
                    var chatWindow = AllImages.Where(x => x.ImageName == "full chat-action window.bmp").FirstOrDefault();
                    result.PerformActionOnAll = AddPoints(mcsd.MatchLocations.FirstOrDefault(), chatWindow.CenterOfImage);
                    break;

                case "combat menu.bmp":
                    var inventoryWindow = AllImages.Where(x => x.ImageName == "inventory list.bmp").FirstOrDefault();
                    mcsd.ImageData   = inventoryWindow;
                    result.Inventory = mcsd;
                    break;

                case "bottom left of full ui view.bmp":
                    var fullUiWindow = AllImages.Where(x => x.ImageName == "full ui view.bmp").FirstOrDefault();
                    var gameField    = AllImages.Where(x => x.ImageName == "gamefield view.bmp").FirstOrDefault();

                    var gameFieldData = new OsrsScanData {
                        ImageData = gameField
                    };
                    var gameFieldLocation =
                        new Point(mcsd.MatchLocations.FirstOrDefault().X,
                                  mcsd.MatchLocations.FirstOrDefault().Y - fullUiWindow.ImageBitmap.Height > 0 ?
                                  mcsd.MatchLocations.FirstOrDefault().Y - fullUiWindow.ImageBitmap.Height : 0);

                    gameFieldData.MatchLocations.Add(gameFieldLocation);

                    result.GameFieldView = gameFieldData;
                    break;

                default:
                    break;
                }
            }

            return(result);
        }
Exemple #7
0
        private void DoMoveImageUp(ImageReference image)
        {
            var index = AllImages.IndexOf(image);

            if (index <= 0)
            {
                return;
            }

            AllImages.Move(index, index - 1);
        }
Exemple #8
0
 public SectionModel ToModel()
 {
     return(new SectionModel()
     {
         Title = Title,
         TextContent = TextContent,
         ListItems = ListItems.GetModel(),
         Type = SectionType,
         AllImages = AllImages.Select(i => i.ToModel()).ToArray()
     });
 }
Exemple #9
0
        public void ReorderImages()
        {
            var tmp = AllImages.OrderByDescending(i => i.Group.Id).ToList();

            AllImages = tmp;
            FilteredImages.Clear();

            if (TagsToFilter is null || TagsToFilter.Count == 0)
            {
                FilteredImages.AddRange(AllImages);
            }
Exemple #10
0
        private void DoMoveImageDown(ImageReference image)
        {
            var index = AllImages.IndexOf(image);

            if (index >= AllImages.Count - 1)
            {
                return;
            }

            AllImages.Move(index, index + 1);
        }
Exemple #11
0
        public ActionResult Done(string passedPath)
        {
            AllImages allImages = new AllImages();

            allImages.Generate();
            allImages.Images.Add(passedPath);


            allImages.Calc();
            return(View(allImages));
        }
Exemple #12
0
        private void Done(bool IsWeb)
        {
            //if (System.Diagnostics.Debugger.IsAttached)
            //{
            //    if (AllImages.Count == 0)
            //    {
            //        MessageBox.Show("No Image Found, Error in Image search function.");
            //        //return;
            //    }
            //}

            foreach (var item in AllImages)
            {
                //Create Thumbnails
                Task task = new Task(async() =>
                {
                    await imageIO.DirectConn_CreateThumbnails(item);
                });
                task.Start();
                if (InvokeRequired)
                {
                    Invoke(new Action(() => ReportProgressForThumbnails(item.ImageDirName)));
                }
            }

            if (AllImages.Count != 0)
            {
                imageIO.BubbleSortImages(AllImages);
                AllImages.Reverse();
            }

            if (InvokeRequired)
            {
                Invoke(new Action(() => waiter.Close()));
                Invoke(new Action(() => RefreshGalleryNotify = true));
                if (fileChangedCounter > 1)
                {// again raise event.
                    Invoke(new Action(() => FilesChanged = true));
                }
                Invoke(new Action(() => fileChangedCounter = 0));
                Invoke(new Action(() => CheckForMaxImageWarning()));
            }
            else
            {
                waiter.Close();
                RefreshGalleryNotify = true;
                CheckForMaxImageWarning();
                if (fileChangedCounter > 1)
                {// again raise event.
                    FilesChanged = true;
                }
                fileChangedCounter = 0;
            }
        }
Exemple #13
0
        private void DoRemove(ImageReference image)
        {
            var index = AllImages.IndexOf(image);

            if (index == 0)
            {
                Image.Image = default(ImageData);
            }
            else if (index != -1)
            {
                AllImages.RemoveAt(index);
            }
        }
Exemple #14
0
 public void ClearCache()
 {
     AllSecureCommandVMs.Clear();
     AllRoomGroupVMs.Clear();
     AllRoomVMs.Clear();
     AllImages.Clear();
     AllGiftGroupVMs.Clear();
     AllGiftVMs.Clear();
     AllUserVMs.Clear();
     AllRoleVMs.Clear();
     AllCommandVMs.Clear();
     AllRoleCommandVMs.Clear();
     AllRoomRoleVMs.Clear();
     AllExchangeRateVMs.Clear();
 }
 private void Imagepage_Disappearing(object sender, EventArgs e)
 {
     if (SelectedImage != null)
     {
         if (ImagePageVM.DeletePhoto == true)
         {
             if (AllImages != null && AllImages.Count > 0 && AllImages.Contains(SelectedImage))
             {
                 AllImages.Remove(SelectedImage);
                 UpdateUploadedFiles();
                 SelectedImage = null;
             }
         }
     }
 }
Exemple #16
0
        public void LoadModel(SectionModel model)
        {
            Title       = model.Title;
            TextContent = model.TextContent;
            ListItems.LodeModel(model.ListItems);
            SectionType = model.Type;

            AllImages.Clear();

            foreach (var imageModel in model.AllImages)
            {
                AllImages.Add(ImageReference.FromModel(imageModel));
            }

            if (AllImages.Count < 0)
            {
                AllImages.Add(new ImageReference());
            }
        }
Exemple #17
0
        private void Done(bool IsWeb)
        {
            imageIO.BubbleSortImages(AllImages);

            foreach (var item in AllImages)
            {
                //TODO: #PPFunc:  Done call whole post processing function here, just thumbail func is enough
                //Create Thumbnails
                Task task = new Task(async() => { await imageIO.Wifi_PostProcessImages(item); });
                task.Start();
                task.Wait();
                //ReportProgressForThumbnails(item.ImageDirName);
            }

            AllImages.Reverse();
            if (InvokeRequired || waiter.InvokeRequired)
            {
                Invoke(new Action(() => waiter.Visible = false));
            }
            else
            {
                waiter.Visible = false;
            }
            if (IsWeb)
            {
                SimpleGallery gallery = new SimpleGallery
                {
                    WifiConnectHelpObject = this,
                    AnimationFormObject   = AnimationForm,
                    AllImages             = AllImages
                };
                this.Visible = false;
                gallery.Show();
            }
            else
            {
                DirectoryGallery gallery = new DirectoryGallery {
                    AllImages = AllImages
                };
                this.Visible = false;
                gallery.Show();
            }
        }
Exemple #18
0
    void GetAvatarData()
    {
        Web.Create()
        .SetUrl(Configuration.Instance.GetApi(Configuration.ApiKey.AVATAR_LIST), Web.RequestType.POST, Web.ResponseType.TEXT)

        .AddHeader("Content-Type", "application/x-www-form-urlencoded")
        .AddHeader("access_token", Database.GetString(Database.Key.ACCESS_TOKEN))
        .SetOnSuccessDelegate((Web _web, Response _response) =>
        {
            AllImages allImages = JsonUtility.FromJson <AllImages>(_response.GetText());
            string url          = "http://52.66.82.72:2095/images/avatar/";
            for (int i = 0; i < allImages.result.Length; i++)
            {
                StartCoroutine(DownloadImage(url + allImages.result[i].image, i, allImages.result[i]._id));
            }
            _web.Close();
        })
        .SetOnFailureDelegate((Web _web, Response _response) =>
        {
            Debug.Log(_response.GetText());
            _web.Close();
        })
        .Connect();
    }
Exemple #19
0
 private void DoAddImage()
 {
     AllImages.Add(new ImageReference());
 }
Exemple #20
0
    // Start is called before the first frame update
    public void Create(string pictureName)
    {
        var picture = AllImages.Where(x => x.name.Equals(pictureName)).FirstOrDefault();

        Create(picture);
    }