Exemplo n.º 1
0
        public FileItem(DeviceObject deviceObject, ICameraDevice device)
        {
            Device = device;
            DeviceObject = deviceObject;
            ItemType = FileItemType.CameraObject;
            FileName = deviceObject.FileName;
            FileDate = deviceObject.FileDate;
            IsChecked = true;
            IsLiked = false;
            IsUnLiked = false;
            if (deviceObject.ThumbData != null && deviceObject.ThumbData.Length > 4)
            {
                try
                {
                    var stream = new MemoryStream(deviceObject.ThumbData, 0, deviceObject.ThumbData.Length);

                    using (var bmp = new Bitmap(stream))
                    {
                        Thumbnail = BitmapSourceConvert.ToBitmapSource(bmp);
                    }
                    stream.Close();
                }
                catch (Exception exception)
                {
                    Log.Debug("Error loading device thumb ", exception);
                }
            }
        }
Exemplo n.º 2
0
        public override AsyncObservableCollection<DeviceObject> GetObjects(object storageId, bool loadThumbs)
        {
            AsyncObservableCollection<DeviceObject> res = new AsyncObservableCollection<DeviceObject>();
            MTPDataResponse response = ExecuteReadDataEx(CONST_CMD_GetObjectHandles, 0xFFFFFFFF);
            if (response.Data == null)
            {
                Log.Debug("Get object error :" + response.ErrorCode.ToString("X"));
                ErrorCodes.GetException(response.ErrorCode);
                return res;
            }
            int objCount = BitConverter.ToInt32(response.Data, 0);
            for (int i = 0; i < objCount; i++)
            {
                DeviceObject deviceObject = new DeviceObject();
                uint handle = BitConverter.ToUInt32(response.Data, 4*i + 4);
                deviceObject.Handle = handle;
                MTPDataResponse objectdata = ExecuteReadDataEx(CONST_CMD_GetObjectInfo, handle);
                if (objectdata.Data != null)
                {
                    uint objFormat = BitConverter.ToUInt16(objectdata.Data, 4);
                    if (objFormat == 0x3000 || objFormat == 0x3801 || objFormat == 0x3800)
                    {
                        deviceObject.FileName = Encoding.Unicode.GetString(objectdata.Data, 53, 12*2);
                        if (deviceObject.FileName.Contains("\0"))
                            deviceObject.FileName = deviceObject.FileName.Split('\0')[0];
                        try
                        {
                            string datesrt = Encoding.Unicode.GetString(objectdata.Data, 53 + (12*2) + 3, 30);
                            //datesrt = datesrt.Replace("T", "");
                            DateTime date = DateTime.MinValue;
                            if (DateTime.TryParseExact(datesrt, "yyyyMMddTHHmmss", CultureInfo.InvariantCulture,
                                                       DateTimeStyles.None, out date))
                            {
                                deviceObject.FileDate = date;
                            }
                        }
                        catch (Exception)
                        {
                        }

                        if (loadThumbs)
                        {
                            MTPDataResponse thumbdata = ExecuteReadDataEx(CONST_CMD_GetThumb, handle);
                            deviceObject.ThumbData = thumbdata.Data;
                        }
                        res.Add(deviceObject);
                    }
                }
            }
            return res;
        }
Exemplo n.º 3
0
 public override bool DeleteObject(DeviceObject deviceObject)
 {
     uint res = ExecuteWithNoData(CONST_CMD_DeleteObject, (uint) deviceObject.Handle);
     return res == 0 || res == ErrorCodes.MTP_OK;
 }
Exemplo n.º 4
0
 public FileItem(DeviceObject deviceObject, ICameraDevice device)
 {
     Device = device;
     DeviceObject = deviceObject;
     ItemType = FileItemType.CameraObject;
     FileName = deviceObject.FileName;
     Name = FileName;
     FileDate = deviceObject.FileDate;
     IsChecked = true;
     IsLiked = false;
     IsUnLiked = false;
     ThumbData = deviceObject.ThumbData;
 }
 public virtual bool DeleteObject(DeviceObject deviceObject)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
        //public override event PhotoCapturedEventHandler PhotoCaptured;
        public override bool DeleteObject(DeviceObject deviceObject)
        {
            string id = (string)((object[]) (deviceObject.Handle))[1];
            for (int j = 1; j <= Device.Items.Count; j++)
            {
                if (Device.Items[j].ItemID == id)
                {
                    Device.Items.Remove(j);
                    break;
                }

            }
            return true;
        }
Exemplo n.º 7
0
        public override AsyncObservableCollection<DeviceObject> GetObjects(object storageId, bool loadThumbs)
        {
            var res = new AsyncObservableCollection<DeviceObject>();
            SendCommand(1283, "\\/var\\/www\\/DCIM\\/100MEDIA/");
            _listingEvent.Reset();
            SendCommand(1282, " -D -S");
            _listingEvent.WaitOne(2500);
            dynamic resp = JsonConvert.DeserializeObject(_lastData);
            WebClient client = new WebClient();
            foreach (JObject o in resp.listing)
            {
                var k = o.ToObject<Dictionary<string, string>>();
                string v = k.First().Value;
                var file = new DeviceObject();
                file.FileName = k.First().Key;
                if (file.FileName.ToLower().Contains("thm"))
                    continue;
                file.Handle = file.FileName;
                try
                {
                    if (loadThumbs)
                    {
                        if (file.FileName.Contains(".jpg"))
                            file.ThumbData =
                                client.DownloadData(string.Format("http://{0}/DCIM/100MEDIA/{1}?type=thumb", Protocol.Ip,
                                    file.FileName));
                        if (file.FileName.Contains(".mp4"))
                            file.ThumbData =
                                client.DownloadData(string.Format("http://{0}/DCIM/100MEDIA/{1}?type=thumb", Protocol.Ip,
                                    file.FileName.Replace("mp4", "THM")));
                    }
                    if (v.Contains("|"))
                        file.FileDate = DateTime.ParseExact(v.Split('|')[1], "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
                }
                catch (Exception)
                {

                }
                res.Add(file);
            }
            return res;
        }
Exemplo n.º 8
0
 public override bool DeleteObject(DeviceObject deviceObject)
 {
     SendCommand(1283, "\\/var\\/www\\/DCIM\\/100MEDIA/");
     SendCommand(1281, (string) deviceObject.Handle);
     return true;
 }
Exemplo n.º 9
0
 public override bool DeleteObject(DeviceObject deviceObject)
 {
     if (deviceObject.Handle is IntPtr)
     {
         Camera.DeleteItem((IntPtr)deviceObject.Handle);
     }
     return true;
 }