Beispiel #1
0
void
Border::OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error)
{
	if (args->GetProperty ()->GetOwnerType() != Type::BORDER) {
		FrameworkElement::OnPropertyChanged (args, error);
		return;
	}
	
	if (args->GetId () == Border::ChildProperty){
		if (args->GetOldValue() && args->GetOldValue()->AsUIElement()) {
			ElementRemoved (args->GetOldValue()->AsUIElement ());
			SetSubtreeObject (NULL);
			if (args->GetOldValue()->Is(GetDeployment (), Type::FRAMEWORKELEMENT)) {
				args->GetOldValue()->AsFrameworkElement()->SetLogicalParent (NULL, error);
				if (error->number)
					return;
			}
				
		}
		if (args->GetNewValue() && args->GetNewValue()->AsUIElement()) {
			SetSubtreeObject (args->GetNewValue()->AsUIElement());
			ElementAdded (args->GetNewValue()->AsUIElement ());
			if (args->GetNewValue()->Is(GetDeployment (), Type::FRAMEWORKELEMENT)) {
				FrameworkElement *fwe = args->GetNewValue()->AsFrameworkElement ();
				if (fwe->GetLogicalParent() && fwe->GetLogicalParent() != this) {
					MoonError::FillIn (error, MoonError::ARGUMENT, "Content is already a child of another element");
					return;
				}

				args->GetNewValue()->AsFrameworkElement()->SetLogicalParent (this, error);
				if (error->number)
					return;
			}
		}

		UpdateBounds ();
		InvalidateMeasure ();
	}
	else if (args->GetId () == Border::PaddingProperty
		 || args->GetId () == Border::BorderThicknessProperty) {
		InvalidateMeasure ();
	} else if (args->GetId () == Border::BackgroundProperty) {
		Invalidate ();
	} else if (args->GetId () == Border::BorderBrushProperty) {
		Invalidate ();
	}
	NotifyListenersOfPropertyChange (args, error);
}
Beispiel #2
0
void
Control::OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error)
{
    if (args->GetProperty ()->GetOwnerType() != Type::CONTROL) {
        FrameworkElement::OnPropertyChanged (args, error);
        return;
    }

    if (args->GetId () == Control::TemplateProperty) {
        if (GetSubtreeObject ())
            ElementRemoved ((UIElement *) GetSubtreeObject ());
        InvalidateMeasure ();
    }
    else if (args->GetId () == Control::PaddingProperty
             || args->GetId () == Control::BorderThicknessProperty) {
        InvalidateMeasure ();
    } else if (args->GetId () == Control::IsEnabledProperty) {
        if (!args->GetNewValue ()->AsBool ()) {
            Surface *surface = Deployment::GetCurrent ()->GetSurface ();
            if (surface && surface->GetFocusedElement () == this) {
                // Ensure this element loses focus, then try to focus the next suitable element
                surface->FocusElement (NULL);
                TabNavigationWalker::Focus (this, true);
            }
            ReleaseMouseCapture ();
        }
        PropertyChangedEventArgs *pargs = new PropertyChangedEventArgs (args->GetProperty(),
                args->GetId (),
                args->GetOldValue(),
                args->GetNewValue());
        EmitAsync (IsEnabledChangedEvent, pargs);
    } else if (args->GetId () == Control::HorizontalContentAlignmentProperty
               || args->GetId () == Control::VerticalContentAlignmentProperty) {
        InvalidateArrange ();
    }
    NotifyListenersOfPropertyChange (args, error);
}