Пример #1
0
 public int addPhotoAlbumItem(int photo, int album)
 {
     PhotoAlbumItem photoAlbumItem = new PhotoAlbumItem();
     photoAlbumItem.PhotoId = photo;
     photoAlbumItem.PhotoAlbumId = album;
     this.db.PhotoAlbumItems.InsertOnSubmit(photoAlbumItem);
     this.db.SubmitChanges();
     return photoAlbumItem.PhotoAlbumItemId;
 }
Пример #2
0
 public PhotoAlbumItem getPhotoAlbumItem(int photoAlbumItemId)
 {
     PhotoAlbumItem result;
     try
     {
         PhotoAlbumItem photoAlbumItem = (
             from a in this.db.PhotoAlbumItems
             where a.PhotoAlbumItemId == photoAlbumItemId
             select a).FirstOrDefault<PhotoAlbumItem>();
         result = photoAlbumItem;
     }
     catch (ArgumentNullException)
     {
         result = new PhotoAlbumItem
         {
             PhotoAlbumItemId = -1
         };
     }
     return result;
 }
Пример #3
0
        public MainWindow()
        {
            InitializeComponent();

            if (CultureInfo.CurrentUICulture.TwoLetterISOLanguageName == "zh")
            {
                FontFamily = new FontFamily("Microsoft YaHei UI");
            }
            SharingPathBox.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            var letters = new List <char> {
                '—'
            };

            letters.AddRange(Enumerable.Range(68, 23).Select(x => (char)x));
            DriveLetters = letters.AsReadOnly();

            MountedCloudDrive.ItemsSource   = DriveLetters;
            MountedCloudDrive.SelectedIndex = 0;

            Connections = new ObservableCollection <StorageConnectionItem>();
            ConnectionList.ItemsSource = Connections;
            Albums = new ObservableCollection <PhotoAlbumItem>();
            AlbumList.ItemsSource = Albums;

            Task.Run(async() => {
                try
                {
                    var sharingEnabled = await Globals.CloudManager.InvokeAsync(x => x.IsFileSharingEnabled(null))
                                         .ConfigureAwait(false);
                    var sharingPath = await Globals.CloudManager.InvokeAsync(x => x.GetFileSharingRoot())
                                      .ConfigureAwait(false);

                    var deviceName = await Globals.CloudManager.InvokeAsync(x => x.GetDeviceName(null))
                                     .ConfigureAwait(false);
                    var cloudName = await Globals.CloudManager.InvokeAsync(x => x.GetPersonalCloudName(Globals.PersonalCloud.Value))
                                    .ConfigureAwait(false);

                    var mounted = await Globals.CloudManager.InvokeAsync(x => x.IsExplorerIntegrationEnabled())
                                  .ConfigureAwait(false);
                    var mountPoint = await Globals.CloudManager.InvokeAsync(x => x.GetMountPointForPersonalCloud(Globals.PersonalCloud.Value))
                                     .ConfigureAwait(false);

                    var connections = await Globals.CloudManager.InvokeAsync(x => x.GetConnectedServices(Globals.PersonalCloud.Value))
                                      .ConfigureAwait(false);
                    var albums = await Globals.CloudManager.InvokeAsync(x => x.GetAlbumSettings(Globals.PersonalCloud.Value))
                                 .ConfigureAwait(false);

                    await Dispatcher.InvokeAsync(() => {
                        SharingSwitch.IsChecked = sharingEnabled;
                        if (!string.IsNullOrEmpty(sharingPath))
                        {
                            SharingPathBox.Text = sharingPath;
                        }

                        DeviceNameBox.Text    = deviceName;
                        CloudNameBox.Text     = cloudName;
                        MountedCloudName.Text = cloudName;
                        MountSwitch.IsChecked = mounted;

                        if (mountPoint?.Length != 3)
                        {
                            MountedCloudDrive.SelectedIndex = 0;
                        }
                        else
                        {
                            var letterIndex = mountPoint[0] - 68 + 1;
                            MountedCloudDrive.SelectedIndex = letterIndex;
                        }

                        foreach (var item in connections)
                        {
                            var model = new StorageConnectionItem {
                                IsSelected = false,
                                Name       = item,
                                Type       = "Cloud Storage"
                            };
                            Connections.Add(model);
                        }
                        foreach (var item in albums)
                        {
                            var model = new PhotoAlbumItem {
                                IsSelected = false,
                                Name       = item.Name,
                                Path       = item.MediaFolder
                            };
                            Albums.Add(model);
                        }
                    });
                }
                catch
                {
                    // Todo
                }

                initialized = true;
            });
        }