void TargetControl_PointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e) { IsActive = !IsActive; //IsActive = true; DesignActive.CurrentSelectedControl = TargetControl; if (TargetControl == null || TargetControl.Parent == null || !(TargetControl.Parent is Canvas)) { return; } TargetCanvas = TargetControl.Parent as Canvas; Canvas.SetZIndex(TargetControl, getTopIndex() + 1); if (DesignManager.SetCurrent != null) { if (TargetControl.DataContext != null && TargetControl.DataContext as DesignItem != null) { var ditem = TargetControl.DataContext as DesignItem; DesignManager.SetCurrent(ditem.TargetObject); } else { DesignManager.SetCurrent(TargetControl.DataContext); } } //e.Handled = true; }
void TargetDesignCanvas_PointerPressed(object sender, PointerRoutedEventArgs e) { if (createControlFunc == null) { foreach (var v in TargetDesignCanvas.Children) { if (v is ArrowCurveSegment) { (v as ArrowCurveSegment).ChangeActive(false); } if (v is DesignControl) { (v as DesignControl).ChangeActive(false); } } if (DesignManager.SetCurrent != null && Parent != null) { var p = Parent as FrameworkElement; DesignManager.SetCurrent(p.DataContext); } return; } if (DataContext == null) { return; } var dc = DataContext as DesignCanvasViewModel; if (dc == null) { return; } var control = createControlFunc(); if (control == null) { throw new Exception("Can not create control"); } var item = new DesignItem() { TargetControl = control, Left = e.GetCurrentPoint(TargetDesignCanvas).Position.X, Top = e.GetCurrentPoint(TargetDesignCanvas).Position.Y, Width = double.IsNaN(control.Width) ? 200 : control.Width, Height = double.IsNaN(control.Height) ? 150 : control.Height }; dc.ItemList.Add(item); var dcontrol = new DesignControl(); dcontrol.DataContext = item; TargetDesignCanvas.Children.Add(dcontrol); //RefreshDataContext(DataContext); createControlFunc = null; //e.Handled = true; }
private void ArrowLine_PointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e) { ChangeActive(true); if (DesignManager.SetCurrent != null) { if (DataContext is DesignLink) { DesignManager.SetCurrent((DataContext as DesignLink).TargetObject); } else { DesignManager.SetCurrent(DataContext); } } e.Handled = true; }