/// <summary> /// Determines whether the specified base anim is valid. /// </summary> /// <param name="baseAnim">The base anim.</param> /// <returns> /// <c>true</c> if the specified base anim is valid; otherwise, <c>false</c>. /// </returns> public bool IsValid(HtmlAnimation baseAnim) { if (baseAnim == null || baseAnim.ControlOwner == null) { return false; } if (this.HtmlElement == null) { this.HtmlElement = HtmlPage.Document.GetElementById(this.HtmlElementName); } if (this.HtmlContainer == null && !string.IsNullOrEmpty(this.HtmlContainerName)) { this.HtmlContainer = HtmlPage.Document.GetElementById(this.HtmlContainerName); if (this.HtmlContainer != null) { double ol = (double)this.HtmlContainer.GetProperty("offsetLeft"); double ot = (double)this.HtmlContainer.GetProperty("offsetTop"); this.htmlContainerOffset = new Point(ol, ot); } } if (this.SLElement == null) { this.SLElement = baseAnim.ControlOwner.FindName(this.SLElementName) as FrameworkElement; } if (this.HtmlElement != null && this.SLElement != null) { return true; } return false; }
public override void OnApplyTemplate() { base.OnApplyTemplate(); // Get the parts ElementRoot = GetTemplateChild(ElementRootName) as FrameworkElement; ElementPanelCommandContainer = GetTemplateChild(ElementPanelCommandContainerName) as Panel; ElementIframePlace = GetTemplateChild(ElementIframePlaceName) as FrameworkElement; ElementButtonBold = GetTemplateChild(ElementButtonBoldName) as Button; ElementButtonItalic = GetTemplateChild(ElementButtonItalicName) as Button; ElementButtonUnderline = GetTemplateChild(ElementButtonUnderlineName) as Button; ElementButtonIndent = GetTemplateChild(ElementButtonIndentName) as Button; ElementButtonOutdent = GetTemplateChild(ElementButtonOutdentName) as Button; ElementButtonAlignLeft = GetTemplateChild(ElementButtonAlignLeftName) as Button; ElementButtonAlignCenter = GetTemplateChild(ElementButtonAlignCenterName) as Button; ElementButtonAlignRight = GetTemplateChild(ElementButtonAlignRightName) as Button; ElementButtonAlignJustify = GetTemplateChild(ElementButtonAlignJustifyName) as Button; ElementButtonOrderedList = GetTemplateChild(ElementButtonOrderedListName) as Button; ElementButtonBulletedList = GetTemplateChild(ElementButtonBulletedListName) as Button; ElementButtonHorizontalRule = GetTemplateChild(ElementButtonHorizontalRuleName) as Button; ElementButtonSubscript = GetTemplateChild(ElementButtonSubscriptName) as Button; ElementButtonSuperscript = GetTemplateChild(ElementButtonSuperscriptName) as Button; ElementButtonHyperLink = GetTemplateChild(ElementButtonHyperLinkName) as Button; ElementButtonImage = GetTemplateChild(ElementButtonImageName) as Button; ElementButtonForeColor = GetTemplateChild(ElementButtonForeColorName) as ToggleButton; ElementForeColorPalette = GetTemplateChild(ElementForeColorPalettedName) as Panel; ElementButtonBackgroundColor = GetTemplateChild(ElementButtonBackgroundColorName) as ToggleButton; ElementBackgroundColorPalette = GetTemplateChild(ElementBackgroundColorPalettedName) as Panel; ElementIframePlace.SizeChanged += new SizeChangedEventHandler(ElementIframePlace_SizeChanged); if (ElementButtonBold != null) ElementButtonBold.Click += new RoutedEventHandler(ElementButtonCommand_Click); if (ElementButtonItalic != null) ElementButtonItalic.Click += new RoutedEventHandler(ElementButtonCommand_Click); if (ElementButtonUnderline != null) ElementButtonUnderline.Click += new RoutedEventHandler(ElementButtonCommand_Click); if (ElementButtonIndent != null) ElementButtonIndent.Click += new RoutedEventHandler(ElementButtonCommand_Click); if (ElementButtonOutdent != null) ElementButtonOutdent.Click += new RoutedEventHandler(ElementButtonCommand_Click); if (ElementButtonAlignLeft != null) ElementButtonAlignLeft.Click += new RoutedEventHandler(ElementButtonCommand_Click); if (ElementButtonAlignCenter != null) ElementButtonAlignCenter.Click += new RoutedEventHandler(ElementButtonCommand_Click); if (ElementButtonAlignRight != null) ElementButtonAlignRight.Click += new RoutedEventHandler(ElementButtonCommand_Click); if (ElementButtonAlignJustify != null) ElementButtonAlignJustify.Click += new RoutedEventHandler(ElementButtonCommand_Click); if (ElementButtonOrderedList != null) ElementButtonOrderedList.Click += new RoutedEventHandler(ElementButtonCommand_Click); if (ElementButtonBulletedList != null) ElementButtonBulletedList.Click += new RoutedEventHandler(ElementButtonCommand_Click); if (ElementButtonHorizontalRule != null) ElementButtonHorizontalRule.Click += new RoutedEventHandler(ElementButtonCommand_Click); if (ElementButtonSubscript != null) ElementButtonSubscript.Click += new RoutedEventHandler(ElementButtonCommand_Click); if (ElementButtonSuperscript != null) ElementButtonSuperscript.Click += new RoutedEventHandler(ElementButtonCommand_Click); if (ElementButtonHyperLink != null) ElementButtonHyperLink.Click += new RoutedEventHandler(ElementButtonCommand_Click); if (ElementButtonImage != null) ElementButtonImage.Click += new RoutedEventHandler(ElementButtonCommand_Click); if (ElementButtonForeColor != null) ElementButtonForeColor.Click += new RoutedEventHandler(ElementButtonForeColor_Click); if (ElementForeColorPalette != null) { foreach (var item in ElementForeColorPalette.Children) { Button button = item as Button; if (item != null) { button.Click += new RoutedEventHandler(ButtonColorForeColor_Click); } } } if (ElementButtonBackgroundColor != null) ElementButtonBackgroundColor.Click += new RoutedEventHandler(ElementButtonBackgroundColor_Click); if (ElementBackgroundColorPalette != null) { foreach (var item in ElementBackgroundColorPalette.Children) { Button button = item as Button; if (item != null) { button.Click += new RoutedEventHandler(ButtonColorBackgroundColor_Click); } } } HtmlAnimationIframePlace = ElementRoot.Resources[HtmlEditor.HtmlAnimationIframePlaceName] as HtmlAnimation; if (ElementPanelCommandContainer != null && IsReadOnly) { ElementPanelCommandContainer.Visibility = Visibility.Collapsed; } InitializeHtml(); }
/// <summary> /// Copies the silverlight properties to the HTML element. /// </summary> /// <param name="baseAnim">The base anim.</param> public void CopyToHtml(HtmlAnimation baseAnim) { if (baseAnim == null || baseAnim.ControlOwner == null) { return; } GeneralTransform transform = this.SLElement.TransformToVisual(Application.Current.RootVisual as UIElement); Point newLocation = transform.Transform(new Point()); Point newBottomRight = transform.Transform(new Point(this.SLElement.ActualWidth, this.SLElement.ActualHeight)); //Size newSize = new Size(this.SLElement.ActualWidth, this.SLElement.ActualHeight); Size newSize = new Size(newBottomRight.X - newLocation.X, newBottomRight.Y - newLocation.Y); if (newLocation != this.LastPosition || newSize != this.LastSize) { this.LastPosition = newLocation; this.LastSize = newSize; if (HtmlElement != null) { HtmlElement.SetStyleAttribute("left", ((int)(newLocation.X - this.htmlContainerOffset.X)).ToString() + "px"); HtmlElement.SetStyleAttribute("top", ((int)(newLocation.Y - this.htmlContainerOffset.Y)).ToString() + "px"); HtmlElement.SetStyleAttribute("width", ((int)newSize.Width).ToString() + "px"); HtmlElement.SetStyleAttribute("height", ((int)newSize.Height).ToString() + "px"); } } }