/// <summary> /// Associates the target component with teh source UI element /// </summary> /// <param name="component"></param> /// <param name="value"></param> public void SetTargetComponent(T component, MgComponent value) { if (value == null) { //Un-bind existing component if it exists, otherwise nothing needs to be done if (_bindings.ContainsKey(component)) { TeardownComponent(component, _bindings[component]); _bindings.Remove(component); } } else { if (_bindings.ContainsKey(component)) { TeardownComponent(component, _bindings[component]); _bindings[component] = value; SetupComponent(component, value); } else { _bindings[component] = value; SetupComponent(component, value); } } }
/// <summary> /// Performs component teardown /// </summary> /// <param name="component"></param> /// <param name="value"></param> protected override void TeardownComponent(ToolStripButton component, MgComponent value) { var listener = component.Tag as ToolbarButtonComponentBinding; if (listener != null) { value.RemoveListener(listener); } base.TeardownComponent(component, value); }
/// <summary> /// Performs component setup /// </summary> /// <param name="component"></param> /// <param name="value"></param> protected override void SetupComponent(ToolStripButton component, MgComponent value) { component.ToolTipText = value.ToolTipText; component.Text = value.Label; component.Image = value.Icon; var listener = new ToolbarButtonComponentBinding(component, value); component.Tag = listener; value.AddListener(listener); base.SetupComponent(component, value); }
/// <summary> /// Performs component setup /// </summary> /// <param name="component"></param> /// <param name="value"></param> protected virtual void SetupComponent(T component, MgComponent value) { component.Click += OnComponentClicked; }
public MenuItemComponentBinding(ToolStripMenuItem item, MgComponent component) : base(component) { _item = item; }
public ToolbarButtonComponentBinding(ToolStripButton item, MgComponent component) : base(component) { _item = item; }
protected ComponentBinding(MgComponent component) { this.Component = component; }
/// <summary> /// Performs component teardown /// </summary> /// <param name="component"></param> /// <param name="value"></param> protected virtual void TeardownComponent(T component, MgComponent value) { component.Click -= OnComponentClicked; }