コード例 #1
0
        private async void Thumbnails_DownloadPhotos(object sender, RoutedEventArgs e)
        {
            if (!await PhotosceneProperties(_photosceneid))
            {
                return;
            }

            Thumbnails.ItemsSource = new ObservableCollection <ReCapPhotoItem> ();
            dynamic response = _recap.response();
            dynamic files    = response.Photoscenes.Photoscene.Files;
            string  dlFolder = System.IO.Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory) + response.Photoscenes.Photoscene.photosceneid;

            if (!Directory.Exists(dlFolder))
            {
                Directory.CreateDirectory(dlFolder);
            }
            foreach (KeyValuePair <string, object> pair in files.Dictionary)
            {
                dynamic            fnode = pair.Value;
                AdskReCap.FileType type  = (AdskReCap.FileType)Enum.Parse(typeof(AdskReCap.FileType), fnode.type, true);
                if (fnode.fileid == "" || type != AdskReCap.FileType.Image)
                {
                    continue;
                }
                string location = dlFolder + @"\" + fnode.filename;
                if (File.Exists(location))
                {
                    ObservableCollection <ReCapPhotoItem> items = new ObservableCollection <ReCapPhotoItem> ((IEnumerable <ReCapPhotoItem>)Thumbnails.ItemsSource);
                    items.Add(new ReCapPhotoItem()
                    {
                        Name  = System.IO.Path.GetFileNameWithoutExtension(fnode.filename),
                        Type  = System.IO.Path.GetExtension(fnode.filename),
                        Image = location
                    });
                    Thumbnails.ItemsSource = items;
                    continue;
                }

                if (!await _recap.GetFile(fnode.fileid, type))
                {
                    continue;
                }
                dynamic fileResponse = _recap.response();
                dynamic file         = fileResponse.Files.file;
                string  link         = file.filelink;

                DownloadFileWnd wnd = new DownloadFileWnd(link, location);
                wnd._callback = new DownloadFileCompletedDelegate(this.DownloadFileCompleted);
                wnd.Owner     = this;
                wnd.Show();
            }
        }
コード例 #2
0
        protected async Task <ProgressInfo> PhotosceneProgress(string photosceneid)
        {
            if (!ConnectWithReCap())
            {
                return(null);
            }

            if (!await _recap.SceneProgress(photosceneid))
            {
                return(null);
            }
            int     pct      = 0;
            string  msg      = "";
            dynamic response = _recap.response();

            try {
                pct = (int)Convert.ToDouble(response.Photoscene.progress);
                msg = response.Photoscene.progressmsg;
            } catch {
            }
            return(new ProgressInfo(pct, msg));
        }
コード例 #3
0
        protected async Task <bool> TestConnection()
        {
            // Test connection
            LogInfo("Test Connection", LogIndent.PostIndent);
            if (!await _recap.ServerTime())
            {
                connectedLabel.Content     = "Connection to ReCap Server failed!";
                connectedTimeLabel.Content = "";
                LogError("ReCap Error: Connection to ReCap Server failed!", LogIndent.PostUnindent);
                MessageBox.Show("ReCap Error: Connection to ReCap Server failed!", "WpfReCap", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            // XML sample
            //XmlDocument doc =_recap.xml () ;
            //XmlNode node =doc.SelectSingleNode ("/Response/date") ; // doc.DocumentElement.SelectSingleNode ("/Response/date/text()").Value
            //DateTime dt =DateTime.Parse (node.InnerText) ;

            // XML LINQ sample
            //XDocument doc =_recap.xmlLinq () ;
            //XElement node =doc.Element ("Response").Element ("date") ;
            //DateTime dt =(DateTime)node ;

            // JSON sample (would require to use true in the call of _recap.ServerTime (true))
            //JObject doc =_recap.json () ;
            //JToken node =doc2 ["Response"] ["date"] ;
            //DateTime dt =(DateTime)node2 ;

            // ReCap Reponse dynamic object sample
            dynamic  response = _recap.response();
            DateTime dt       = DateTime.Parse(response.date);

            connectedLabel.Content     = dt.ToLongDateString();
            connectedTimeLabel.Content = dt.ToLongTimeString();
            LogInfo("ReCap Server date: " + dt.ToLongDateString() + " " + dt.ToLongTimeString(), LogIndent.PostUnindent);
            return(true);
        }