public void SetupMenu(SkyhunterCanvas canvas, MenuLocation location, MenuButtonControl externalButton) { MyCanvas = canvas; MyLocation = location; ExternalButton = externalButton; ExternalButton.MyButton.Click += SurfaceButton_Click; //disable shadow ApplyTemplate(); this.Background = new SolidColorBrush(Colors.Transparent); this.BorderBrush = new SolidColorBrush(Colors.Transparent); ShowsActivationEffects = false; Microsoft.Surface.Presentation.Generic.SurfaceShadowChrome ssc; ssc = (Microsoft.Surface.Presentation.Generic.SurfaceShadowChrome)this.Template.FindName("shadow", this); ssc.Visibility = Visibility.Hidden; switch (location) { case MenuLocation.Top: this.Orientation = 180.0; this.Center = new Point(canvas.CanvasWidth / 2, this.ActualHeight / 2); break; case MenuLocation.Right: this.Orientation = 270.0; this.Center = new Point(canvas.CanvasWidth - this.ActualHeight / 2, canvas.CanvasHeight / 2); break; case MenuLocation.Bottom: this.Orientation = 0.0; this.Center = new Point(canvas.CanvasWidth / 2, canvas.CanvasHeight - this.ActualHeight / 2); break; case MenuLocation.Left: this.Orientation = 90.0; this.Center = new Point(this.ActualHeight / 2, canvas.CanvasHeight / 2); break; } IsOpen = false; }
public Menu(SkyhunterCanvas canvas, MenuLocation location, MenuButtonControl externalButton) { InitializeComponent(); Loaded += OnLoaded; SetupMenu(canvas, location, externalButton); }