Пример #1
0
        private async void EditItemAsync(PasswordViewItem item)
        {
            try
            {
                if (item == null)
                {
                    return;
                }
                if (!ReenterPassword())
                {
                    return;
                }
                var oldurl = item.Password.Url;
                var w      = new EditWindow(this, Properties.Resources.TITLE_EDIT, item.Image, item.Password);
                if (w.ShowDialog() == true)
                {
                    passwordRepository.Update(w.Password);
                    item.Update(w.Password);
                    UpdateControls();
                    if (!string.Equals(oldurl, w.Password.Url))
                    {
                        if (thumbnailCache != null &&
                            !string.IsNullOrEmpty(item.Password.Url))
                        {
                            var image    = imageKey16x16;
                            var filename = await thumbnailCache.GetImageFileNameAsync(item.Password.Url);

                            if (!string.IsNullOrEmpty(filename))
                            {
                                item.Image = new BitmapImage(new Uri(filename));
                            }
                        }
                    }
                    SortListView();
                    listView.ScrollIntoView(item);
                }
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
Пример #2
0
        private async void AddItemAsync()
        {
            try
            {
                if (!ReenterPassword())
                {
                    return;
                }
                EditWindow w = new EditWindow(this, Properties.Resources.TITLE_ADD, imageKey16x16);
                if (w.ShowDialog() == true)
                {
                    passwordRepository.Add(w.Password);
                    var item = new PasswordViewItem(w.Password, imageKey16x16);
                    listView.Items.Add(item);
                    listView.SelectedItem = item;
                    listView.ScrollIntoView(item);
                    UpdateControls();
                    if (thumbnailCache != null &&
                        !string.IsNullOrEmpty(w.Password.Url))
                    {
                        var filename = await thumbnailCache.GetImageFileNameAsync(w.Password.Url);

                        if (!string.IsNullOrEmpty(filename))
                        {
                            item.Image = new BitmapImage(new Uri(filename));
                        }
                    }
                    SortListView();
                    listView.ScrollIntoView(item);
                }
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }