コード例 #1
0
 /// <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);
         }
     }
 }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
 /// <summary>
 /// Performs component setup
 /// </summary>
 /// <param name="component"></param>
 /// <param name="value"></param>
 protected virtual void SetupComponent(T component, MgComponent value)
 {
     component.Click += OnComponentClicked;
 }
コード例 #5
0
 public MenuItemComponentBinding(ToolStripMenuItem item, MgComponent component)
     : base(component)
 {
     _item = item;
 }
コード例 #6
0
 public ToolbarButtonComponentBinding(ToolStripButton item, MgComponent component)
     : base(component)
 {
     _item = item;
 }
コード例 #7
0
 protected ComponentBinding(MgComponent component)
 {
     this.Component = component;
 }
コード例 #8
0
 /// <summary>
 /// Performs component teardown
 /// </summary>
 /// <param name="component"></param>
 /// <param name="value"></param>
 protected virtual void TeardownComponent(T component, MgComponent value)
 {
     component.Click -= OnComponentClicked;
 }