private async void uxButtonSave_Click(object sender, EventArgs e) { var item = uxListViewSecrets.FirstSelectedItem; if (null != item) { PropertyObject po = null; using (var op = NewUxOperationWithProgress(uxButtonSave, uxMenuItemSave)) await op.Invoke($"get {item.Kind} from", async() => { po = await item.GetAsync(op.CancellationToken); }); uxSaveFileDialog.FileName = po.GetFileName(); uxSaveFileDialog.DefaultExt = po.GetContentType().ToExtension(); uxSaveFileDialog.FilterIndex = po.GetContentType().ToFilterIndex(); if (uxSaveFileDialog.ShowDialog() == DialogResult.OK) { po.SaveToFile(uxSaveFileDialog.FileName); } } }
private async void uxListViewSecrets_ItemDrag(object sender, ItemDragEventArgs e) { using (var op = NewUxOperation(uxButtonSave, uxMenuItemSave)) { _ctrlKeyPressed = (ModifierKeys & Keys.Control) != 0; _shiftKeyPressed = (ModifierKeys & Keys.Shift) != 0; List <string> filesList = new List <string>(); foreach (var item in uxListViewSecrets.SelectedItems.Cast <ListViewItemBase>()) { PropertyObject po = null; await op.Invoke("get item from", async() => po = await item.GetAsync(op.CancellationToken)); // Pick .kv-secret or .kv-certificate or .url extension if CTRL and SHIFT are pressed var filename = po.Name + (_ctrlKeyPressed & _shiftKeyPressed ? ContentType.KeyVaultLink.ToExtension() : _ctrlKeyPressed ? po.GetKeyVaultFileExtension() : po.GetContentType().ToExtension()); var fullName = Path.Combine(Path.GetTempPath(), filename); po.SaveToFile(fullName); filesList.Add(fullName); } var dataObject = new DataObject(DataFormats.FileDrop, filesList.ToArray()); uxListViewSecrets.DoDragDrop(dataObject, DragDropEffects.Move); } }