1 //------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //------------------------------------------------------------
5 namespace System.Activities.Core.Presentation
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;
16 partial class StartSymbol
19 public static readonly DependencyProperty TextProperty =
20 DependencyProperty.Register("Text", typeof(string), typeof(StartSymbol));
24 get { return (string)GetValue(TextProperty); }
25 set { SetValue(TextProperty, value); }
28 public static StartSymbol CreateStartSymbol(EditingContext context)
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;
43 InitializeComponent();
46 protected override void OnContextMenuOpening(ContextMenuEventArgs e)
51 protected override void OnPreviewKeyDown(KeyEventArgs e)
53 if (e.Key == Key.Delete)
55 Selection selection = this.Context.Items.GetValue<Selection>();
57 if (selection.SelectionCount == 1)
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.
65 base.OnPreviewKeyDown(e);