private void Initialize(BackgroundCanvas mainCanvas) { _mainCanvas = mainCanvas; _parentGroup = null; Background = new SolidColorBrush(_defaultColor); _displayState = DisplayState.Grid; Selected = SelectionState.None; _tagTextBox = new TextBox(); Children.Add(_tagTextBox); _tagTextBox.KeyDown += TextBoxKeyDownHandler; _splitButton = new Button(); _splitButton.Content = @"/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/"; _splitButton.FontSize = 4; Children.Add(_splitButton); _splitButton.RenderTransform = new RotateTransform(90); _splitButton.Click += SplitButtonClickHandler; HideSplitIcon(null); _activeFace = null; MouseLeftButtonDown += MouseLeftButtonDownHandler; MouseLeftButtonUp += MouseLeftButtonUpHandler; MouseRightButtonDown += MouseRightButtonDownHandler; MouseMove += MouseMoveEventHandler; LayoutUpdated += LayoutChangedHandler; }
/// <summary> /// Reparent s group /// </summary> /// <param name="newParent">My new parent</param> public void AddToGroup(Panel newParent) { if (newParent == _mainCanvas) { _parentGroup = null; } else { _parentGroup = (IDisplayableElement)newParent; } }
/// <summary> /// Rebuild my parent hierachy, typically following deserialization /// </summary> /// <param name="backgroundCanvas"></param> public void RebuildTree(BackgroundCanvas backgroundCanvas) { _mainCanvas = backgroundCanvas; _parentGroup = (Group)_mainCanvas.FindParent(_parentGroupID); }