public static void OpenUsingDefaultAction([NotNull] ItemUri itemUri, [NotNull] string itemName = "") { Assert.ArgumentNotNull(itemUri, nameof(itemUri)); Assert.ArgumentNotNull(itemName, nameof(itemName)); DefaultActionPipeline.Run().WithParameters(new ItemSelectionContext(new ItemDescriptor(itemUri, itemName))); }
private void DoubleClick([NotNull] object sender, [NotNull] MouseButtonEventArgs e) { Debug.ArgumentNotNull(sender, nameof(sender)); Debug.ArgumentNotNull(e, nameof(e)); var pipeline = DefaultActionPipeline.Run().WithParameters(GetContext()); e.Handled = pipeline.Handled; }
public override void Execute(object parameter) { var context = parameter as IItemSelectionContext; if (context == null) { return; } var itemUri = context.Items.FirstOrDefault(); if (itemUri == null) { return; } var d = new AddInsertOptionDialog(); d.NewItemName.Text = string.Format(Resources.InsertOptions_CreateItem_New__0_, TemplateHeader.Name); if (AppHost.Shell.ShowDialog(d) != true) { return; } var newItemUri = AppHost.Server.AddFromTemplate(itemUri.ItemUri, TemplateHeader.TemplateUri, d.ItemName); if (newItemUri == ItemUri.Empty) { return; } var itemVersionUri = new ItemVersionUri(newItemUri, LanguageManager.CurrentLanguage, Version.Latest); Notifications.RaiseItemAdded(this, itemVersionUri, itemUri.ItemUri); if (AppHost.CurrentContentTree != null) { AppHost.CurrentContentTree.Locate(newItemUri); } DefaultActionPipeline.Run().WithParameters(new ItemSelectionContext(new TemplatedItemDescriptor(itemVersionUri.ItemUri, d.ItemName, TemplateHeader.TemplateUri.ItemId, TemplateHeader.Name))); }
private void HandleKeyDown([NotNull] object sender, [NotNull] KeyEventArgs e) { Debug.ArgumentNotNull(sender, nameof(sender)); Debug.ArgumentNotNull(e, nameof(e)); if (e.Key == Key.F2) { SetCurrentItemInEditMode(true); return; } if (e.Key != Key.Enter || Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl) || Keyboard.IsKeyDown(Key.LeftAlt) || Keyboard.IsKeyDown(Key.RightAlt) || Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)) { return; } var context = new ContentTreeContext(this, TreeView.GetSelectedItems(null)); var pipeline = DefaultActionPipeline.Run().WithParameters(context); e.Handled = pipeline.Handled; }
private void HandleDoubleClick([NotNull] object sender, [NotNull] MouseButtonEventArgs e) { Debug.ArgumentNotNull(sender, nameof(sender)); Debug.ArgumentNotNull(e, nameof(e)); var selectedItem = TreeView.SelectedItem as TreeViewItem; if (selectedItem == null) { return; } var itemHeader = selectedItem.Tag as ItemHeader; if (itemHeader == null) { return; } DefaultActionPipeline.Run().WithParameters(new ItemSelectionContext(new TemplatedItemDescriptor(itemHeader.ItemUri, string.Empty, itemHeader.TemplateId, itemHeader.TemplateName))); }
public static void OpenUsingDefaultAction([NotNull] ITemplatedItem item) { Assert.ArgumentNotNull(item, nameof(item)); DefaultActionPipeline.Run().WithParameters(new ItemSelectionContext(item)); }
public override void Execute(object parameter) { var context = parameter as ContentTreeContext; if (context == null) { return; } var parent = context.SelectedItems.FirstOrDefault() as ItemTreeViewItem; if (parent == null) { return; } var dialog = new AddFromTemplateDialog { DatabaseUri = parent.ItemUri.DatabaseUri }; if (AppHost.Shell.ShowDialog(dialog) != true) { return; } var template = dialog.SelectedTemplate; if (template == null) { return; } var items = new List <ItemVersionUri>(); foreach (var itemName in dialog.ItemNames) { ItemUri itemUri; if (template.IsBranch) { itemUri = parent.ItemUri.Site.DataService.AddFromMaster(parent.ItemUri, template.TemplateUri, itemName); } else { itemUri = parent.ItemUri.Site.DataService.AddFromTemplate(parent.ItemUri, template.TemplateUri, itemName); } if (itemUri == ItemUri.Empty) { continue; } var itemVersionUri = new ItemVersionUri(itemUri, LanguageManager.CurrentLanguage, Version.Latest); items.Add(itemVersionUri); } if (dialog.AddInsertOptionsCheckBox.IsChecked == true) { AddInsertOption(parent.Item, template.TemplateUri); } parent.RefreshAndExpand(false); if (items.Count() == 1) { var item = items.First(); var treeView = parent.GetAncestor <ItemTreeView>(); if (treeView != null) { treeView.ExpandTo(item.ItemUri); } DefaultActionPipeline.Run().WithParameters(new ItemSelectionContext(new TemplatedItemDescriptor(item.ItemUri, string.Empty, template.TemplateId, template.Name))); } else { var list = items.Select(i => i.ItemUri).ToList(); foreach (var o in parent.Items) { var item = o as ItemTreeViewItem; if (item == null) { continue; } if (list.Contains(item.Item.ItemUri)) { item.IsSelected = true; item.Focus(); } } AppHost.Windows.OpenContentEditor(items, LoadItemsOptions.Default); } foreach (var itemVersionUri in items) { Notifications.RaiseItemAdded(this, itemVersionUri, parent.ItemUri); } }