Exemplo n.º 1
0
        public ToolStripItem Render(object item, TSIContext context)
        {
            Type tipo = ((item != null) ? item.GetType() : null);

            // Si esta en la tsiCache y lo puede renderizar, utiliza la tsiCache (por tipo).
            if ((tipo != null) && this.tsiCache.ContainsKey(tipo))
            {
                TSIRender render = this.tsiCache[tipo];
                if (render.IsRenderable(item))
                {
                    return(render.Render(item, context));
                }
            }

            // Se busca entre los tsiRenders.
            foreach (TSIRender render in this.tsiRenders)
            {
                if (render.IsRenderable(item))
                {
                    // Si no esta en la tsiCache, se añade a la tsiCache (por tipo).
                    if ((tipo != null) && !this.tsiCache.ContainsKey(tipo))
                    {
                        this.tsiCache.Add(tipo, render);
                    }
                    return(render.Render(item, context));
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        public override LabelValueToolStrip Render(IProperty property, TSIContext context)
        {
            LabelValueToolStrip tsItem = new LabelValueToolStrip();

            Set(tsItem, property, context);

            tsItem.Enabled         = property.Enabled;
            tsItem.ValueIsEditable = property.Editable;

            tsItem.Label = property.NameUI;

            int labelWidth = 50;
            int valueWidth = 50;

            if (context.PropertiesProvider != null)
            {
                PropertyProperties props = context.PropertiesProvider.FindProperties <PropertyProperties>(property) ?? PropertyProperties.Empty;
                labelWidth = props.LabelWidth;
                valueWidth = props.ValueWidth;
            }
            tsItem.LabelWidth = labelWidth;
            tsItem.ValueWidth = valueWidth;

            // Se asocian el ToolStripItem a la propiedad.
            Link.Build(tsItem, property, context);
            return(tsItem);
        }
Exemplo n.º 3
0
        public override ToolStripLabel Render(Label action, TSIContext context)
        {
            ToolStripLabel tsItem = new ToolStripLabel();

            Set(tsItem, action, context);

            return(tsItem);
        }
Exemplo n.º 4
0
        public override ToolStripDropDownItem Render(IComposedComponentUI composed, TSIContext context)
        {
            ToolStripDropDownItem tsDropDownItem = new ToolStripDropDownButton();

            Set(tsDropDownItem, composed, context);
            tsDropDownItem.DisplayStyle = context.CurrentDisplayStyle;

            // Se asocian el ToolStripItem a la accion.
            Link.Build(tsDropDownItem, composed, context);
            return(tsDropDownItem);
        }
Exemplo n.º 5
0
        public override ToolStripMenuItem Render(IAction action, TSIContext context)
        {
            ToolStripMenuItem tsItem = new ToolStripMenuItem();

            tsItem.Tag = action;

            Set(tsItem, action, context);
            tsItem.DisplayStyle = context.CurrentDisplayStyle;

            // Se asocian el ToolStripItem a la accion.
            Link.Build(tsItem, action, context);
            return(tsItem);
        }
Exemplo n.º 6
0
        public override ToolStripItem Render(object obj, TSIContext context)
        {
            ToolStripItem tsItem = new ToolStripMenuItem();

            tsItem.Tag          = null;
            tsItem.Name         = "<Error>";
            tsItem.DisplayStyle = ToolStripItemDisplayStyle.None;
            tsItem.Text         = "<Error>";
            tsItem.AutoToolTip  = false;
            tsItem.ToolTipText  = "<Error>";
            tsItem.Image        = null;
            //tsItem.Click = null;
            return(tsItem);
        }
Exemplo n.º 7
0
        protected static void Set(ToolStripItem tsItem, IAction accion, TSIContext context)
        {
            Set(tsItem, (IComponentUI)accion, context);
            tsItem.Enabled = accion.Enabled;

            // NOTA: la primera vez que se pinta, se actualiza 'Enabled'.
            PaintEventHandler[] update = new PaintEventHandler[1];
            update[0] = (sender, args) =>
            {
                ActionUtils.NotifyUpdateState(accion);
                tsItem.Enabled = accion.Enabled;

                tsItem.Paint -= update[0];
            };
            tsItem.Paint += update[0];
        }
Exemplo n.º 8
0
        protected static void Set(ToolStripItem tsItem, IComponentUI component, TSIContext context)
        {
            tsItem.Tag               = component;
            tsItem.Name              = component.Name;
            tsItem.Text              = component.NameUI;
            tsItem.ToolTipText       = component.DescriptionUI;
            tsItem.DisplayStyle      = ToolStripItemDisplayStyle.ImageAndText;
            tsItem.AutoToolTip       = false;
            tsItem.TextImageRelation = context.TextImageRelation;

            if (component.IconUI != null)
            {
                tsItem.Image = component.IconUI.ToImage(context.CurrentIconSize);
            }
            else if (context.CurrentDisplayStyle == ToolStripItemDisplayStyle.Image)
            {
                tsItem.Image = MainResources.icon_not_found.ToImage(context.CurrentIconSize);
            }

            tsItem.AutoSize     = true;
            tsItem.ImageScaling = ToolStripItemImageScaling.None;
        }
Exemplo n.º 9
0
 public IEnumerable <ToolStripItem> RenderRange(TSIContext context, IEnumerable <object> components)
 {
     return(components.Select(c => this.Render(c, context)));
 }
Exemplo n.º 10
0
 /// <summary>
 ///     Renderiza el objeto.
 /// </summary>
 /// <param name="obj">Objeto.</param>
 /// <param name="context">Contexto.</param>
 /// <returns>ToolStripItem.</returns>
 public abstract ToolStripItem Render(object obj, TSIContext context);
Exemplo n.º 11
0
        public override ToolStripSeparator Render(Separator accion, TSIContext context)
        {
            ToolStripSeparator tsItem = new ToolStripSeparator();

            return(tsItem);
        }
Exemplo n.º 12
0
 private Link(ToolStripDropDownItem tsItem, IComposedComponentUI item, TSIContext context)
     : base(tsItem, item, context)
 {
     this.TSItem.DropDown.Name = item.Name;
     this.UpdateComponents();
 }
Exemplo n.º 13
0
 /// <summary>
 ///     Crea una asociacion.
 /// </summary>
 public static void Build(LabelValueToolStrip tsItem, IProperty item, TSIContext context)
 {
     new Link(tsItem, item, context);
 }
Exemplo n.º 14
0
 private Link(ToolStripMenuItem tsItem, IAction item, TSIContext context)
     : base(tsItem, item, context)
 {
 }
Exemplo n.º 15
0
 /// <summary>
 ///     Crea una asociacion.
 /// </summary>
 public static void Build(ToolStripMenuItem tsItem, IAction item, TSIContext context)
 {
     new Link(tsItem, item, context);
 }
Exemplo n.º 16
0
 /// <summary>
 ///     Crea una asociacion.
 /// </summary>
 public static void Build(ToolStripDropDownItem tsItem, IComposedComponentUI item, TSIContext context)
 {
     new Link(tsItem, item, context);
 }
Exemplo n.º 17
0
 private Link(LabelValueToolStrip tsItem, IProperty item, TSIContext context)
     : base(tsItem, item, context)
 {
     this.UpdateControl();
 }
Exemplo n.º 18
0
 protected Link(TTSItem tsItem, T item, TSIContext context)
 {
     this.context = (TSIContext)context.Clone();
     this.TSItem  = tsItem;
     this.Item    = item;
 }
Exemplo n.º 19
0
 private Link(ToolStripDropDownItem tsItem, IComposedAction item, TSIContext context)
     : base(tsItem, item, context)
 {
     this.TSItem.DropDown.Name = tsItem.Name;
     this.UpdateActions();
 }