public override void Execute(object parameter) { var context = parameter as ContentEditorContext; if (context == null) { return; } context.ContentEditor.ContentModel.GetChanges(); var shortHelp = GetSelectedItems(context, "__Short description"); var longHelp = GetSelectedItems(context, "__Long description"); var d = new SetHelpDialog(); d.Initialize(shortHelp, longHelp); if (AppHost.Shell.ShowDialog(d) != true) { return; } SetSelectedItems(context, "__Short description", d.ShortHelp.Text); SetSelectedItems(context, "__Long description", d.LongHelp.Text); context.ContentEditor.ContentModel.IsModified = true; }
protected void SetHelp(ItemVersionUri itemUri) { var item = itemUri.Site.DataService.GetItemFields(itemUri); var shortHelpField = item.Fields.FirstOrDefault(f => f != null && f.Name == "__Short description"); var longHelpField = item.Fields.FirstOrDefault(f => f != null && f.Name == "__Long description"); var shortHelp = shortHelpField != null ? shortHelpField.Value : string.Empty; var longHelp = longHelpField != null ? longHelpField.Value : string.Empty; var d = new SetHelpDialog(); d.Initialize(shortHelp, longHelp); if (AppHost.Shell.ShowDialog(d) != true) { return; } var shortProperty = d.GetType().GetField("ShortHelp", BindingFlags.NonPublic | BindingFlags.Instance); var shortHelpTextBox = shortProperty.GetValue(d) as TextBox; if (shortHelpTextBox != null) { shortHelp = shortHelpTextBox.Text ?? string.Empty; } var longProperty = d.GetType().GetField("LongHelp", BindingFlags.NonPublic | BindingFlags.Instance); var longHelpTextBox = longProperty.GetValue(d) as TextBox; if (longHelpTextBox != null) { longHelp = longHelpTextBox.Text ?? string.Empty; } ItemModifier.Edit(itemUri, "__Short description", shortHelp); ItemModifier.Edit(itemUri, "__Long description", longHelp); }