Browse Source

fixed "Edit grid columns and rows"

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5347 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Siegfried Pammer 16 years ago
parent
commit
cf595b05cf
  1. 21
      src/AddIns/BackendBindings/XamlBinding/XamlBinding/PowerToys/Commands/EditGridColumnsAndRowsCommand.cs

21
src/AddIns/BackendBindings/XamlBinding/XamlBinding/PowerToys/Commands/EditGridColumnsAndRowsCommand.cs

@ -17,9 +17,6 @@ using ICSharpCode.XamlBinding.PowerToys.Dialogs;
namespace ICSharpCode.XamlBinding.PowerToys.Commands namespace ICSharpCode.XamlBinding.PowerToys.Commands
{ {
/// <summary>
/// Description of EditGridColumnsAndRowsCommand.
/// </summary>
public class EditGridColumnsAndRowsCommand : XamlMenuCommand public class EditGridColumnsAndRowsCommand : XamlMenuCommand
{ {
protected override bool Refactor(ITextEditor editor, XDocument document) protected override bool Refactor(ITextEditor editor, XDocument document)
@ -27,21 +24,21 @@ namespace ICSharpCode.XamlBinding.PowerToys.Commands
Location startLoc = editor.Document.OffsetToPosition(editor.SelectionStart); Location startLoc = editor.Document.OffsetToPosition(editor.SelectionStart);
Location endLoc = editor.Document.OffsetToPosition(editor.SelectionStart + editor.SelectionLength); Location endLoc = editor.Document.OffsetToPosition(editor.SelectionStart + editor.SelectionLength);
XElement selectedItem = (from item in document.Root.Descendants() XName[] names = CompletionDataHelper.WpfXamlNamespaces.Select(item => XName.Get("Grid", item)).ToArray();
where item.IsInRange(startLoc, endLoc) select item).FirstOrDefault();
if (selectedItem == null || CompletionDataHelper.WpfXamlNamespaces.Select(item => XName.Get("Grid", item)).Any(ns => ns == selectedItem.Name)) { XElement selectedItem = document.Root.Descendants()
selectedItem = document.Root.Elements().FirstOrDefault(); .FirstOrDefault(item => item.IsInRange(startLoc, endLoc) && names.Any(ns => ns == item.Name))
if (selectedItem == null || CompletionDataHelper.WpfXamlNamespaces.Select(item => XName.Get("Grid", item)).Any(ns => ns == selectedItem.Name)) { ?? document.Root.Elements().FirstOrDefault(i => names.Any(ns => ns == i.Name));
MessageService.ShowError("Please select a Grid!");
return false; if (selectedItem == null) {
} MessageService.ShowError("Please select a Grid!");
return false;
} }
EditGridColumnsAndRowsDialog dialog = new EditGridColumnsAndRowsDialog(selectedItem); EditGridColumnsAndRowsDialog dialog = new EditGridColumnsAndRowsDialog(selectedItem);
dialog.Owner = WorkbenchSingleton.MainWindow; dialog.Owner = WorkbenchSingleton.MainWindow;
if (dialog.ShowDialog() ?? false) { if (dialog.ShowDialog() == true) {
selectedItem.ReplaceWith(dialog.ConstructedTree); selectedItem.ReplaceWith(dialog.ConstructedTree);
return true; return true;
} }

Loading…
Cancel
Save