Exemple #1
0
 /// <summary>
 /// Binds a template with the data of the currently selected template.
 /// </summary>
 /// <param name="template"></param>
 public void Bind(FluidTemplate template, int index)
 {
     object item = GetItem(index);
     template.BeginInit();
     template.ItemIndex = index;
     template.Item = item;
     template.Container = this;
     template.Scale(ScaleFactor);
     template.Bounds = GetItemBounds(index);
     template.EndInit();
 }
Exemple #2
0
 /// <summary>
 /// Binds a template with the data of the currently selected template.
 /// </summary>
 /// <param name="template"></param>
 public void Bind(FluidTemplate template)
 {
     Bind(template, selectedItemIndex);
 }
Exemple #3
0
 private PointEventArgs TranslatePoint(FluidTemplate c, PointEventArgs p)
 {
     p.X -= c.Bounds.X;
     p.Y -= c.Bounds.Y;
     return p;
 }
Exemple #4
0
        private bool OnTemplateEvent(int index, EventArgs ea, TemplateEvent type)
        {
            bool result = false;
            // if (BindTemplate != null)
            {
                //                Debug.WriteLine("TemplateEvent: " + type.ToString());
                FluidTemplate template = GetTemplate(index);
                PointEventArgs e = ea as PointEventArgs;

                // set the selected template to this template. A template is always reused and the Index and ItemIndex might change
                // when it is not accessed within the OnBind method (e.g. on a TextChanged event of a TextBox in the template).
                // Therefore these two values are stored on any OnTemplate event, assuming that the control that has the focus and might raise
                // an event is always the control that is inside the template that lately received an event:
                selectedTemplate = template;
                selectedTemplateIndex = template != null ? template.ItemIndex : -1;

                if (template != null)
                {
                    PointEventArgs p = templatePointEventArg;
                    if (e != null)
                    {
                        template.BeginInit();
                        p.X = e.X;
                        p.Y = e.Y;
                        p.Gesture = e.Gesture;
                        p = TranslatePoint(template, p);
                        template.EndInit();
                    }
                    switch (type)
                    {
                        case TemplateEvent.Down:
                            templateIndex = index;
                            template.OnDown(p);
                            break;

                        case TemplateEvent.Up:
                            template.OnUp(p);
                            break;

                        case TemplateEvent.Release:
                            template.OnRelease(p);
                            templateIndex = -1;
                            break;

                        case TemplateEvent.Click:
                            result = template.OnClick(p);
                            break;

                        case TemplateEvent.Move:
                            template.OnMove(p);
                            break;

                        case TemplateEvent.KeyDown:
                            template.OnKeyDown(ea as KeyEventArgs);
                            break;

                        case TemplateEvent.KeyUp:
                            template.OnKeyUp(ea as KeyEventArgs);
                            break;

                        case TemplateEvent.KeyPress:
                            template.OnKeyPress(ea as KeyPressEventArgs);
                            break;

                    }

                }
            }
            return result;
        }
Exemple #5
0
 protected virtual void OnDataBound(FluidTemplate fluidTemplate)
 {
     if (DataBound != null)
     {
         TemplateEventArgs e = templateEventArgs;
         DataBound(this, e);
     }
 }
Exemple #6
0
 /// <summary>
 /// Occurs when to get and/or bind a template.
 /// The event is used for two reasons:
 /// a) To apply a custom template to the event other than the default template.
 /// b) assign the properties of all child controls of the template to the data specified as Item and/or ItemIndex. 
 /// </summary>
 /// <example>
 ///     for instance, if there is a Label control in the template you could assign the Text like followed: 
 ///     label.Text = (e.Item as MyValue).FirstName;
 /// </example>
 protected virtual FluidTemplate OnBindTemplate(int index, object item, FluidTemplate template)
 {
     if (item is IGroupHeader) return null;
     if (BindTemplate != null)
     {
         TemplateEventArgs e = templateEventArgs;
         e.ItemIndex = index;
         e.Item = item;
         e.Template = template;
         template.BeginInit();
         BindTemplate(this, e);
         template.EndInit();
         template = e.Template;
     }
     return template;
 }