+
+
+ private void ChangeParent(Control new_parent) {
+ bool pre_enabled;
+ bool pre_visible;
+ Font pre_font;
+ Color pre_fore_color;
+ Color pre_back_color;
+ RightToLeft pre_rtl;
+
+ // These properties are inherited from our parent
+ // Get them pre parent-change and then send events
+ // if they are changed after we have our new parent
+ pre_enabled = Enabled;
+ pre_visible = Visible;
+ pre_font = Font;
+ pre_fore_color = ForeColor;
+ pre_back_color = BackColor;
+ pre_rtl = RightToLeft;
+ // MS doesn't seem to send a CursorChangedEvent
+
+ parent = new_parent;
+
+ if (IsHandleCreated && (new_parent != null) && new_parent.IsHandleCreated) {
+ XplatUI.SetParent(Handle, new_parent.Handle);
+ }
+
+ OnParentChanged(EventArgs.Empty);
+
+ if (pre_enabled != Enabled) {
+ OnEnabledChanged(EventArgs.Empty);
+ }
+
+ if (pre_visible != Visible) {
+ OnVisibleChanged(EventArgs.Empty);
+ }
+
+ if (pre_font != Font) {
+ OnFontChanged(EventArgs.Empty);
+ }
+
+ if (pre_fore_color != ForeColor) {
+ OnForeColorChanged(EventArgs.Empty);
+ }
+
+ if (pre_back_color != BackColor) {
+ OnBackColorChanged(EventArgs.Empty);
+ }
+
+ if (pre_rtl != RightToLeft) {
+ // MS sneaks a OnCreateControl and OnHandleCreated in here, I guess
+ // because when RTL changes they have to recreate the win32 control
+ // We don't really need that (until someone runs into compatibility issues)
+ OnRightToLeftChanged(EventArgs.Empty);
+ }
+
+ if ((new_parent != null) && new_parent.Created && !Created) {
+ CreateControl();
+ }
+
+ if ((binding_context == null) && Created) {
+ OnBindingContextChanged(EventArgs.Empty);
+ }
+ }
+
+ private void UpdateDistances() {
+ if ((parent != null) && (parent.layout_suspended == 0)) {
+ dist_left = bounds.X;
+ dist_top = bounds.Y;
+ dist_right = parent.ClientSize.Width - bounds.X - bounds.Width;
+ dist_bottom = parent.ClientSize.Height - bounds.Y - bounds.Height;
+ }
+ }