1 //------------------------------------------------------------ 2 // Copyright (c) Microsoft Corporation. All rights reserved. 3 //------------------------------------------------------------ 4 5 namespace System.Activities.Core.Presentation 6 { 7 using System.Linq; 8 using System.Runtime; 9 using System.Windows; 10 using System.Windows.Controls; 11 using System.Windows.Input; 12 using System.Activities.Presentation; 13 using System.Activities.Presentation.View; 14 using System.Activities.Presentation.Model; 15 16 partial class StartSymbol 17 { 18 19 public static readonly DependencyProperty TextProperty = 20 DependencyProperty.Register("Text", typeof(string), typeof(StartSymbol)); 21 22 public string Text 23 { 24 get { return (string)GetValue(TextProperty); } 25 set { SetValue(TextProperty, value); } 26 } 27 CreateStartSymbol(EditingContext context)28 public static StartSymbol CreateStartSymbol(EditingContext context) 29 { 30 StartSymbol start = new StartSymbol(); 31 FakeRoot fakeRoot = new FakeRoot { StartNode = new StartNode() }; 32 ModelTreeManager manager = context.Services.GetService<ModelTreeManager>(); 33 start.ModelItem = new FakeModelItemImpl(manager, typeof(FakeRoot), fakeRoot, null).Properties["StartNode"].Value; 34 start.Name = "StartSymbol"; 35 start.Focusable = true; 36 start.Context = context; 37 start.DataContext = start; 38 return start; 39 } 40 StartSymbol()41 StartSymbol() 42 { 43 InitializeComponent(); 44 } 45 OnContextMenuOpening(ContextMenuEventArgs e)46 protected override void OnContextMenuOpening(ContextMenuEventArgs e) 47 { 48 e.Handled = true; 49 } 50 OnPreviewKeyDown(KeyEventArgs e)51 protected override void OnPreviewKeyDown(KeyEventArgs e) 52 { 53 if (e.Key == Key.Delete) 54 { 55 Selection selection = this.Context.Items.GetValue<Selection>(); 56 57 if (selection.SelectionCount == 1) 58 { 59 Fx.Assert(selection.PrimarySelection.Parent.ItemType == typeof(FakeRoot), "StartNode should have a fakeroot."); 60 // Avoid calling the delete command, if only the start node is selected. 61 e.Handled = true; 62 } 63 } 64 65 base.OnPreviewKeyDown(e); 66 } 67 } 68 69 70 } 71