File

projects/wms-framework/src/lib/media/VisualTreeHelper.ts

Description

VisualTreeHelper class

Index

Methods

Methods

Static FindElementsInHostCoordinates
FindElementsInHostCoordinates(point, element)

Find elements in host coordinates

Parameters :
Name Optional
point No
element No

{Iterable}

Static GetChild
GetChild(obj: DependencyObject, idx: number)

Gets the child element at the index position

Parameters :
Name Type Optional
obj DependencyObject No
idx number No
Returns : DependencyObject

{DependencyObject}

Static GetChildrenCount
GetChildrenCount(obj: DependencyObject)

Method o know the amount of children the parent has

Parameters :
Name Type Optional
obj DependencyObject No
Returns : number

{number}

Static GetParent
GetParent(obj: DependencyObject)
Parameters :
Name Type Optional
obj DependencyObject No
Returns : UIElement
import { Control } from '../basecomponentmodel/Control';
import { DependencyObject } from '../basecomponentmodel/DependencyObject';
import { FrameworkElement } from '../basecomponentmodel/FrameworkElement';
import { UIElement } from '../basecomponentmodel/UIElement';
import { Debugger } from '../diagnostics/Debugger';

/**
 * VisualTreeHelper class
 *
 * @export
 * @class VisualTreeHelper
 * @wType System.Windows.Media.VisualTreeHelper
 */
export class VisualTreeHelper {
  /**
   * Gets the child element at the index position
   *
   * @static
   * @param {DependencyObject} obj
   * @param {number} idx
   * @return {*}  {DependencyObject}
   * @memberof VisualTreeHelper
   */
  public static GetChild(obj: DependencyObject, idx: number): DependencyObject {
    if (
      obj instanceof Control &&
      obj.templateModel &&
      obj.templateModel.GetChild
    ) {
      return obj.templateModel.GetChild(idx);
    } else if (obj instanceof FrameworkElement) {
      return obj.GetChild(idx);
    }
    return null;
  }
  /**
   * Method o know the amount of children the parent has
   *
   * @static
   * @param {DependencyObject} obj
   * @return {*}  {number}
   * @memberof VisualTreeHelper
   */
  public static GetChildrenCount(obj: DependencyObject): number {
    if (
      obj instanceof Control &&
      obj.templateModel &&
      obj.templateModel.GetChildrenCount
    ) {
      return obj.templateModel.GetChildrenCount();
    } else {
      return obj.GetChildrenCount();
    }
  }
  public static GetParent(obj: DependencyObject): UIElement {
    if (obj instanceof FrameworkElement) {
      return obj.Parent;
    }
    return null;
  }

  /**
   * Find elements in host coordinates
   *
   * @static
   * @param {*} point
   * @param {*} element
   * @return {*}  {Iterable<UIElement>}
   * @memberof VisualTreeHelper
   * @wNoMap
   */
  public static FindElementsInHostCoordinates(
    point,
    element
  ): Iterable<UIElement> {
    Debugger.Throw('Not implemented');
    return null;
  }
}

result-matching ""

    No results matching ""