private async void AddItem_Button_OnClick(object sender, RoutedEventArgs e) { AddItemName.Text = ""; AddItemName.Description = ""; AddItemAmount.Value = 1; if (await AddItemDialog.ShowAsync() != ContentDialogResult.Primary) { return; } try { var item = new ItemDTO() { Title = AddItemName.Text, Description = AddItemDesc.Text, Amount = (int)Math.Ceiling(AddItemAmount.Value) }; var newItem = await _service.AddPackingItem(_tripId, _sectionId, item); _items.Add(newItem); _tripDetailsPage.UpdateProgressBar(); Bindings.Update(); } catch { //TODO exception handling } }
private void ButtonAddItem_Click(object sender, RoutedEventArgs e) { var addItemWindow = new AddItemDialog((ProductType)ItemTypeComboBox.SelectedIndex); addItemWindow.ShowDialog(); LoadAllSources(); RefreshComboBoxItemsSources(); RefreshDataGrid(); }
private void AddItem(object sender, RoutedEventArgs e) { GroupElement groupElement = ItemGroups.SelectedItem as GroupElement; if (groupElement != null) { ItemGroupElement selElm = groupElement.ElementBase as ItemGroupElement; if (selElm != null) { if (!selElm.IsImported) { AddItemDialog dialog = new AddItemDialog(selElm.PredominateType); bool? dialogResult = dialog.ShowDialog(); if (!dialogResult.HasValue) { return; } if (dialogResult.Value) { //Catch any errors and display them to the user try { selElm.ItemGroup.AddNewItem(dialog.ItemName, "(Nothing)"); groupElement.Refresh(); } catch (System.Xml.XmlException ex) { ErrorDialog errorMessage = new ErrorDialog(ex.Message); errorMessage.ShowDialog(); } catch (ArgumentException ex) { ErrorDialog errorMessage = new ErrorDialog(ex.Message); errorMessage.ShowDialog(); } } } } else { AddItemBtn.IsEnabled = false; } } }
private async void AddItem() { AddItemDialog dialog = new AddItemDialog(Categories); ContentDialogResult result = await dialog.ShowAsync(); if (result == ContentDialogResult.Primary) { if (!String.IsNullOrEmpty(dialog.ItemName) && dialog.SelectedCategory != null) { Item itemToAdd = new Item(dialog.ItemName, dialog.SelectedCategory); int id = await _itemRepository.Add(itemToAdd); itemToAdd.Id = id; Items.Add(itemToAdd); BuildItemList(); } } }
private void QuickAddItem() { AddItemDialog.Show(); }
public void NewBitmapImage_Click(object sender, RoutedEventArgs e) { AddItemDialog.CreateFile(AddItemType.BitmapImage); }
public void NewTextDocument_Click(object sender, RoutedEventArgs e) { AddItemDialog.CreateFile(AddItemType.TextDocument); }
public void NewFolder_Click(object sender, RoutedEventArgs e) { AddItemDialog.CreateFile(AddItemType.Folder); }
private async void AddItemCommandHandler(object p) { // Prompt to create the new item var dialog = new AddItemDialog(); // Show the dialog and wait for a response var result = await dialog.ShowAsync(); if (result == ContentDialogResult.Primary) { try { // Get the category var category = p as ApiCategory; // Create an item var item = new ApiItem() { Name = dialog.ItemName }; // Save the item to the api var r = await KryptPadApi.SaveItemAsync(category.Id, item); // Set the item item.Id = r.Id; // If a template was selected, create a couple of fields to start with if (dialog.SelectedItemTemplate != null) { var templateFields = dialog.SelectedItemTemplate.Fields; // A template was selected, add all the fields from the template foreach (var templateField in templateFields) { // Create field var field = new ApiField() { Name = templateField.Name, FieldType = templateField.FieldType }; // Send to api await KryptPadApi.SaveFieldAsync(category.Id, item.Id, field); } } // Navigate to item edit page NavigationHelper.Navigate(typeof(NewItemPage), new EditItemPageParams() { Category = category, Item = item }); } catch (WebException ex) { // Something went wrong in the api await DialogHelper.ShowMessageDialogAsync(ex.Message); } catch (Exception ex) { // Failed await DialogHelper.ShowGenericErrorDialogAsync(ex); } } }
public override void Start() { base.Start(); addDialog = FindObjectOfType <AddItemDialog>(); InvokeRepeating("UploadMissingItems", missingItemsUploadRate, missingItemsUploadRate); }
void fileBrowser_NodeContextEvent(FileBrowserTree tree, string path, bool isDirectory, bool isTopLevel) { ContextMenu contextMenu = new ContextMenu(); if (isDirectory) { contextMenu.add(new ContextMenuItem("Create Directory", path, delegate(ContextMenuItem item) { InputBox.GetInput("Directory Name", "Please enter a name for the directory.", true, delegate(String result, ref String errorPrompt) { editorController.ResourceProvider.createDirectory(item.UserObject.ToString(), result); return(true); }); })); contextMenu.add(new ContextMenuItem("Add Item", path, delegate(ContextMenuItem item) { AddItemDialog.AddItem(editorController.ItemTemplates, (itemTemplate) => { try { ((ProjectItemTemplate)itemTemplate).createItem(path, editorController); } catch (Exception e) { MessageBox.show(String.Format("Error creating item.\n{0}", e.Message), "Error Creating Item", MessageBoxStyle.IconError | MessageBoxStyle.Ok); } }); })); contextMenu.add(new ContextMenuItem("Import Files", path, delegate(ContextMenuItem item) { FileOpenDialog fileDialog = new FileOpenDialog(MainWindow.Instance, "Choose files to import.", "", "", "", true); fileDialog.showModal((result, paths) => { if (result == NativeDialogResult.OK) { editorController.importFiles(paths, item.UserObject.ToString()); } }); })); contextMenu.add(new ContextMenuItem("Explore To", path, item => { OtherProcessManager.openLocalURL(editorController.ResourceProvider.getFullFilePath(item.UserObject.ToString())); })); } if (!isTopLevel) { contextMenu.add(new ContextMenuItem("Rename", path, delegate(ContextMenuItem item) { InputBox.GetInput("Rename", String.Format("Please enter a new name for {0}.", item.UserObject.ToString()), true, delegate(String result, ref String errorPrompt) { String originalExtension = Path.GetExtension(item.UserObject.ToString()); String targetName = Path.ChangeExtension(Path.Combine(Path.GetDirectoryName(item.UserObject.ToString()), result), originalExtension); if (editorController.ResourceProvider.exists(targetName)) { errorPrompt = String.Format("A file named {0} already exists. Please enter another name.", targetName); return(false); } editorController.ResourceProvider.move(path, targetName); return(true); }); })); contextMenu.add(new ContextMenuItem("Delete", path, delegate(ContextMenuItem item) { MessageBox.show(String.Format("Are you sure you want to delete {0}?", item.UserObject.ToString()), "Delete?", MessageBoxStyle.IconQuest | MessageBoxStyle.Yes | MessageBoxStyle.No, delegate(MessageBoxStyle result) { if (result == MessageBoxStyle.Yes) { editorController.ResourceProvider.delete(item.UserObject.ToString()); } }); })); } tree.showContextMenu(contextMenu); }