示例#1
0
 public void SetAction(ExcelInterop.Range range, IBindingContextElement catchingContextElement, IBindingContextElement currentContextItem)
 {
     //ExcelTemplateDefinitionPart currentTemplateDefinition = catchingContextElement.ParentPart.TemplateDefinitionPart as ExcelTemplateDefinitionPart;
     if (MethodInfo != null)
     {
         object concernedObject = MethodInfo.IsStatic ? null : catchingContextElement.DataSource;
         int    nbrParameters   = MethodInfo.GetParameters().Count();
         if (nbrParameters == 3)
         {
             Action = () => MethodInfo.Invoke(concernedObject, new object[] { range, catchingContextElement.DataSource, currentContextItem.DataSource });
         }
         else if (nbrParameters == 2)
         {
             Action = () => MethodInfo.Invoke(concernedObject, new object[] { catchingContextElement.DataSource, currentContextItem.DataSource });
         }
         else if (nbrParameters == 1)
         {
             Action = () => MethodInfo.Invoke(concernedObject, new object[] { catchingContextElement.DataSource });
         }
         else
         {
             Action = () => MethodInfo.Invoke(concernedObject, null);
         }
     }
 }
示例#2
0
        public ExcelContextItemButton(IBindingContextElement parent, IBindingDefinition bindingDefinition)
            : base(parent, bindingDefinition)
        {
            CanNotify = bindingDefinition?.CanNotify ?? false;
            excelBindingDefinitionButton = bindingDefinition as ExcelBindingDefinitionButton;

            if (CanNotify)
            {
                objectsToNotify = excelBindingDefinitionButton.GetObjectsToNotify(DataSource);
                if (objectsToNotify != null)
                {
                    foreach (INotifyPropertyChanged obj in objectsToNotify)
                    {
                        obj.PropertyChanged += OnPropertyChanged;
                    }
                }
            }

            if (excelBindingDefinitionButton.EnablePropertyInfo != null)
            {
                EnablePropertyGet = excelBindingDefinitionButton.EnablePropertyInfo.GetGetMethod();
                if (EnablePropertyGet != null)
                {
                    if (!EnablePropertyGet.IsStatic)
                    {
                        if (ParentElement.DataSource != null && ParentElement.DataSource is INotifyPropertyChanged)
                        {
                            EnableProperty = (INotifyPropertyChanged)ParentElement.DataSource;
                            EnableProperty.PropertyChanged += OnPropertyChanged;
                        }
                    }
                }
            }
        }
示例#3
0
 public override void Invoke(object sender, IBindingContextElement catchingContextElement, IBindingContextItem currentContextItem)
 {
     object[] methodParams = null;
     if (Parameters != null && Parameters.Any())
     {
         methodParams = new object[Parameters.Count()];
         int i = 0;
         foreach (SpecificEventCallbackParameter param in Parameters)
         {
             if (param.IsSender)
             {
                 methodParams[i++] = sender;
                 continue;
             }
             if (param.IsCatchingContextElement)
             {
                 methodParams[i++] = catchingContextElement;
                 continue;
             }
             if (param.IsCurrentContextItem)
             {
                 methodParams[i++] = currentContextItem;
                 continue;
             }
             methodParams[i++] = param.ParameterValue;
         }
     }
     Callback.Invoke(null, methodParams);
 }
        public IBindingContextItem ContextItemFactory(IBindingContextElement owner)
        {
            string name;
            IBindingContextItem nestedContextItem = NestedBindingDefinition?.ContextItemFactory(owner);

            if (nameBindingDefinition != null)
            {
                object obj = nameBindingDefinition.ResolveBinding(owner.DataSource);
                name = rootName.EmptyIfNull() + (obj?.ToString() ?? string.Empty);
            }
            else
            {
                if (usePos)
                {
                    name = definition.Name.Replace(POS_KEYWORD, "_" + owner == null ? string.Empty : owner.Index.ToString());
                }
                else if (useAllPos)
                {
                    StringBuilder          nameBuilder  = new StringBuilder();
                    IBindingContextElement currentOwner = owner;
                    while (currentOwner != null)
                    {
                        nameBuilder.Insert(0, "_" + currentOwner.Index);
                        currentOwner = currentOwner.ParentPart.ParentContext.Parent;
                    }
                    nameBuilder.Insert(0, definition.Name.Replace(ALL_POS_KEYWORD, string.Empty));
                    name = nameBuilder.ToString();
                }
                else
                {
                    name = definition.Name;
                }
            }
            return(new ExcelContextItemNamedRange(owner, name, this, nestedContextItem));
        }
示例#5
0
 public BindingContextItem(IBindingContextElement parent, IBindingDefinition bindingDefinition)
 {
     ParentElement     = parent;
     BindingDefinition = bindingDefinition;
     CanNotify         = false;
     Name = BindingDefinition == null ? string.Empty : BindingDefinition.Name;
 }
示例#6
0
 public ExcelContextItemNamedRange(IBindingContextElement parent, string name, IBindingDefinition bindingDefinition, IBindingContextItem nestedContextItem)
     : base(parent, bindingDefinition)
 {
     this.name = name;
     excelBindingDefinitionNamedRange = bindingDefinition as ExcelBindingDefinitionNamedRange;
     CanNotify         = excelBindingDefinitionNamedRange.CanNotify;
     NestedContextItem = nestedContextItem;
 }
示例#7
0
        public void Invoke(EventCallback callback, object sender, IBindingContextElement catchingContextElement, IBindingContextItem currentContextItem)
        {
            if (callback.IsNotDotNet)
            {
                InvokeNotDotNet(callback, new [] { catchingContextElement?.DataSource, currentContextItem?.BindingDefinition?.Name });
            }

            callback.Invoke(sender, catchingContextElement, currentContextItem);
        }
示例#8
0
        /// <summary>
        /// Manage the views contextual menus (those that are defined in the templates)
        /// </summary>
        private IEnumerable <IContextualMenu> ManageViewsContextualMenu(ExcelInterop.Worksheet sheet, ExcelInterop.Range range)
        {
            List <IContextualMenu> menus = new List <IContextualMenu>();

            if (sheet != null && range != null)
            {
                ExcelInterop.Range targetRange = range.Cells[1, 1];

                lock (syncRoot)
                {
                    List <ExcelTemplateView> views;
                    if (viewsBySheet.TryGetValue(sheet, out views))
                    {
                        if (views != null)
                        {
                            foreach (ExcelTemplateView view in views.Where(v => v.IsRendered).Select(v => v))
                            {
                                ExcelInterop.Range intersect = ExcelApplication.Application.Intersect(view.RenderedRange, targetRange);
                                if (intersect != null)
                                {
                                    IBindingContextItem currentContextItem = view.GetConcernedContextItem(targetRange);
                                    if (currentContextItem != null)
                                    {
                                        // User contextual menu
                                        IBindingContextElement catchingContextElement = currentContextItem.ParentElement;
                                        do
                                        {
                                            ExcelTemplateDefinitionPart currentTemplateDefinition = catchingContextElement.ParentPart.TemplateDefinitionPart as ExcelTemplateDefinitionPart;
                                            if ((currentTemplateDefinition.Parent as ExcelTemplateDefinition).ContextualMenu != null)
                                            {
                                                ContextualMenu contextualMenu = (currentTemplateDefinition.Parent as ExcelTemplateDefinition).ContextualMenu as ContextualMenu;
                                                contextualMenu.SetAction(targetRange, catchingContextElement, currentContextItem.ParentElement);
                                                menus.Insert(0, contextualMenu);
                                            }
                                            catchingContextElement = catchingContextElement.ParentPart.ParentContext == null ? null : catchingContextElement.ParentPart.ParentContext.Parent;
                                        }while (catchingContextElement != null);

                                        // Etk sort, search and filter
                                        IContextualMenu searchSortAndFilterMenu = sortSearchAndFilterMenuManager.GetMenus(view, targetRange, currentContextItem);
                                        if (searchSortAndFilterMenu != null)
                                        {
                                            menus.Insert(0, searchSortAndFilterMenu);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                //ExcelApplication.ReleaseComObject(targetRange);
                targetRange = null;
            }
            return(menus);
        }
示例#9
0
        public BindingContextItemCanNotify(IBindingContextElement parent, IBindingDefinition bindingDefinition)
            : base(parent, bindingDefinition)
        {
            CanNotify = true;

            objectsToNotify = bindingDefinition.GetObjectsToNotify(DataSource);
            if (objectsToNotify != null)
            {
                foreach (INotifyPropertyChanged obj in objectsToNotify)
                {
                    obj.PropertyChanged += OnPropertyChanged;
                }
            }
        }
示例#10
0
        public virtual IBindingContextItem ContextItemFactory(IBindingContextElement parent)
        {
            BindingContextItem ret;

            if (parent.DataSource == null)
            {
                ret = new BindingContextItem(parent, this);
            }
            else
            {
                ret = CanNotify ? new BindingContextItemCanNotify(parent, this) : new BindingContextItem(parent, this);
            }
            ret.Init();
            return(ret);
        }
示例#11
0
 public void SetAction(ExcelInterop.Range range, IBindingContextElement catchingContextElement, IBindingContextElement currentContextItem)
 {
     if (Items != null)
     {
         foreach (IContextualPart part in Items)
         {
             if (part is ContextualMenu)
             {
                 (part as ContextualMenu).SetAction(range, catchingContextElement, currentContextItem);
             }
             else
             {
                 (part as ContextualMenuItem).SetAction(range, catchingContextElement, currentContextItem);
             }
         }
     }
 }
        public override IBindingContextItem ContextItemFactory(IBindingContextElement parent)
        {
            BindingContextItem ret;

            if (parent.DataSource == null)
            {
                ret = new BindingContextItem(parent, this);
            }
            else
            {
                IBindingDefinition realBindingDefinition = CreateRealBindingDefinition(parent.DataSource.GetType());
                ret = realBindingDefinition.CanNotify ? new BindingContextItemCanNotify(parent, realBindingDefinition)
                                                        : new BindingContextItem(parent, realBindingDefinition);
            }
            ret.Init();
            return(ret);
        }
        public static int ResolveMinOccurences(MethodInfo minOccurencesMethod, IBindingContextElement parentElement)
        {
            object invokeTarget  = minOccurencesMethod.IsStatic ? null : parentElement.DataSource;
            int    nbrParameters = minOccurencesMethod.GetParameters().Length;

            object[] parameters = null;
            switch (nbrParameters)
            {
            //case 2:
            //    parameters = new object[] { currentElement.DataSource, parentElement.DataSource };
            //break;
            case 1:
                parameters = new object[] { parentElement.DataSource };
                break;
            }

            return((int)minOccurencesMethod.Invoke(invokeTarget, parameters));
        }
示例#14
0
        public ExcelContextItemFormulaResult(IBindingContextElement parent, IBindingDefinition bindingDefinition)
            : base(parent, bindingDefinition)
        {
            excelBindingDefinitionFormulaResult = bindingDefinition as ExcelBindingDefinitionFormulaResult;
            CanNotify = excelBindingDefinitionFormulaResult.CanNotify;
            //NestedContextItem = nestedContextItem;

            if (CanNotify)
            {
                objectsToNotify = bindingDefinition.GetObjectsToNotify(DataSource);
                if (objectsToNotify != null)
                {
                    foreach (INotifyPropertyChanged obj in objectsToNotify)
                    {
                        obj.PropertyChanged += OnPropertyChanged;
                    }
                }
            }
        }
示例#15
0
        public virtual void Invoke(object sender, IBindingContextElement catchingContextElement, IBindingContextItem currentContextItem)
        {
            object invokeTarget  = Callback.IsStatic ? null : catchingContextElement.DataSource;
            int    nbrParameters = Callback.GetParameters().Length;

            if (nbrParameters > 3)
            {
                throw new Exception($"Method info '{Callback.Name}' signature is not correct");
            }

            object[] parameters;
            switch (nbrParameters)
            {
            //case 4:
            //    parameters = new object[] { catchingContextElement, catchingContextElement.DataSource, currentContextItem, currentContextItem.DataSource };
            //    break;
            case 3:
                parameters = new[] { sender, catchingContextElement.DataSource, currentContextItem.ParentElement.DataSource };
                break;

            case 2:
                if (Callback.GetParameters()[0].ParameterType == typeof(ITemplateView))
                {
                    parameters = new[] { catchingContextElement.ParentPart.ParentContext.Owner, catchingContextElement.DataSource }
                }
                ;
                else
                {
                    parameters = new[] { catchingContextElement.DataSource, currentContextItem.ParentElement.DataSource }
                };
                break;

            case 1:
                parameters = new[] { catchingContextElement.DataSource };
                break;

            default:
                parameters = null;
                break;
            }
            Callback.Invoke(invokeTarget, parameters);
        }
示例#16
0
        public static BindingContextPart CreateBodyBindingContextPart(BindingContext parent, ITemplateDefinitionPart templateDefinitionPart, List <object> dataSourceAsList, ISortersAndFilters externalSorterAndFilter, ISortersAndFilters templatedSorterAndFilter)
        {
            BindingContextPart ret = new BindingContextPart(parent, templateDefinitionPart, BindingContextPartType.Body);

            ret.ExternalSorterAndFilter = parent.ExternalSortsAndFilters;

            int elementIndex = 0;
            // Bug => Closure !!!!
            // ret.Elements = dataSourceAsList.Select(ds => new BindingContextElement(ret, ds, elementIndex++));
            List <IBindingContextElement> tmpElements = new List <IBindingContextElement>();

            foreach (object obj in dataSourceAsList)
            {
                tmpElements.Add(new BindingContextElement(ret, obj, elementIndex++));
            }
            ret.Elements = tmpElements;

            // The sorterers and filters defined outside templates have the priority
            if (parent.ExternalSortsAndFilters != null)
            {
                Dictionary <object, IBindingContextElement> contextItemByElement = ret.Elements.ToDictionary(e => e.Element, e => e);
                IEnumerable <object> elements = parent.ExternalSortsAndFilters.Execute(contextItemByElement.Keys) as IEnumerable <object>;
                ret.ElementsToRender = elements.Select(e => { IBindingContextElement el = null;
                                                              contextItemByElement.TryGetValue(e, out el);
                                                              return(el); });
            }
            else
            {
                ret.ElementsToRender = ret.Elements;
            }

            // Manage the filters defined in the templates
            if (templatedSorterAndFilter != null)
            {
                Dictionary <object, IBindingContextElement> contextItemByElement = ret.ElementsToRender.ToDictionary(e => e.Element, e => e);
                IEnumerable <object> elements = templatedSorterAndFilter.Execute(contextItemByElement.Keys) as IEnumerable <object>;
                ret.ElementsToRender = elements.Select(e => { IBindingContextElement el = null;
                                                              contextItemByElement.TryGetValue(e, out el);
                                                              return(el); });
            }
            return(ret);
        }
        // To redo !!!!
        private void ManageTemplatePart(ref int cpt, IBindingContextElement contextElement, List <IBindingContextItem> col, int colId, int startPos, int endPos)
        {
            ExcelInterop.Worksheet worksheetFrom = partToRenderDefinition.DefinitionFirstCell.Worksheet;
            ExcelInterop.Worksheet worksheetTo   = currentRenderingTo.Worksheet;

            int gap = endPos - startPos;

            ExcelInterop.Range source = worksheetFrom.Cells[partToRenderDefinition.DefinitionFirstCell.Row + startPos, partToRenderDefinition.DefinitionFirstCell.Column + colId];
            source = source.Resize[gap, 1];
            ExcelInterop.Range workingRange = currentRenderingTo.Resize[gap, 1];
            source.Copy(workingRange);

            for (int rowId = startPos; rowId < endPos; rowId++)
            {
                IBindingContextItem item = partToRenderDefinition.DefinitionParts[colId, rowId] == null ? null : contextElement.BindingContextItems[cpt++];
                if (item != null && ((item.BindingDefinition != null && item.BindingDefinition.IsEnum) || item is IExcelControl))
                {
                    ExcelInterop.Range range = worksheetTo.Cells[currentRenderingTo.Row + rowId, currentRenderingTo.Column];
                    if (item.BindingDefinition.IsEnum && !item.BindingDefinition.IsReadOnly)
                    {
                        enumManager.CreateControl(item, ref range);
                    }
                    else
                    {
                        ((IExcelControl)item).CreateControl(range);
                    }
                    range = null;
                }
                col.Add(item);
            }

            ExcelApplication.ReleaseComObject(worksheetFrom);
            ExcelApplication.ReleaseComObject(worksheetTo);
            worksheetFrom = null;
            worksheetTo   = null;

            //ExcelApplication.ReleaseComObject(source);
            //ExcelApplication.ReleaseComObject(workingRange);
            source       = null;
            workingRange = null;
        }
示例#18
0
        internal bool OnBeforeBoubleClick(ExcelInterop.Range target, ref bool cancel)
        {
            ExcelInterop.Range intersect = ETKExcel.ExcelApplication.Application.Intersect(RenderedRange, target);
            if (intersect == null)
            {
                return(false);
            }

            IBindingContextItem currentContextItem = GetConcernedContextItem(target);

            if (currentContextItem?.BindingDefinition != null)
            {
                if (currentContextItem.BindingDefinition.IsReadOnly)
                {
                    cancel = true;
                }

                // If the bound excelBindingDefinition contains a left double click callback: invoke it !
                if (currentContextItem.BindingDefinition.OnClick != null)
                {
                    ((ExcelTemplateManager)ETKExcel.TemplateManager).CallbacksManager.Invoke(currentContextItem.BindingDefinition.OnClick,
                                                                                             target, currentContextItem.ParentElement, currentContextItem);
                    cancel = true;
                }
                else
                {
                    IBindingContextElement currentContextElement = currentContextItem.ParentElement;
                    if (currentContextElement != null && currentContextElement.ParentPart != null && currentContextElement.ParentPart.PartType == BindingContextPartType.Header &&
                        ((TemplateDefinition)currentContextElement.ParentPart.TemplateDefinitionPart.Parent).TemplateOption.HeaderAsExpander != HeaderAsExpander.None)
                    {
                        if (CheckHeaderAsExpander(Renderer, target))
                        {
                            cancel = true;
                        }
                    }
                }
            }

            intersect = null;
            return(true);
        }
        protected BindingFilterContextItem(ITemplateView view, BindingFilterDefinition bindingFilterDefinition, IBindingContextElement bindingContextElement)
            : base(bindingContextElement, null)
        {
            this.view = (TemplateView)view;
            this.bindingFilterDefinition = bindingFilterDefinition;
            this.bindingContextElement   = bindingContextElement;

            Dictionary <BindingFilterDefinition, string> filterDefinitionByElement;

            if (!((TemplateView)view).FilterValueByFilterDefinitionByElement.TryGetValue(bindingContextElement.DataSource, out filterDefinitionByElement))
            {
                filterDefinitionByElement = new Dictionary <BindingFilterDefinition, string>();
                ((TemplateView)view).FilterValueByFilterDefinitionByElement[bindingContextElement.DataSource] = filterDefinitionByElement;
            }

            string filterValue;

            filterDefinitionByElement.TryGetValue(bindingFilterDefinition, out filterValue);

            FilterValue = filterValue;
        }
示例#20
0
        public ExcelContextItemCheckBox(IBindingContextElement parent, IBindingDefinition bindingDefinition)
            : base(parent, bindingDefinition)
        {
            if (bindingDefinition != null)
            {
                CanNotify = bindingDefinition.CanNotify;
                excelBindingDefinition = bindingDefinition as ExcelBindingDefinitionCheckBox;

                if (excelBindingDefinition != null)
                {
                    objectsToNotify = excelBindingDefinition.GetObjectsToNotify(DataSource);
                    if (objectsToNotify != null)
                    {
                        foreach (INotifyPropertyChanged obj in objectsToNotify)
                        {
                            obj.PropertyChanged += OnPropertyChanged;
                        }
                    }
                }
            }
        }
        public bool Resolve(object sender, IBindingContextElement element)
        {
            ExcelInterop.Range concernedRange = sender as ExcelInterop.Range;
            if (concernedRange == null)
            {
                return(false);
            }

            try
            {
                ExcelInterop.Range concernedRangeFirstCell = concernedRange.Cells[1, 1];

                // We delete the previous concernedRange comment
                ExcelInterop.Comment comment = concernedRangeFirstCell.Comment;
                comment?.Delete();

                // Invoke decorator resolver
                object result = EventCallbacksManager.DecoratorInvoke(Callback, concernedRange, element.DataSource, null);
                if (result != null)
                {
                    string commentStr = result as string;
                    if (!string.IsNullOrEmpty(commentStr))
                    {
                        concernedRange.AddComment(commentStr);
                        ExcelInterop.Comment   addedComment = concernedRange.Comment;
                        ExcelInterop.Shape     shape        = addedComment.Shape;
                        ExcelInterop.TextFrame textFrame    = shape.TextFrame;
                        textFrame.AutoSize = true;
                    }
                    return(commentStr != null);
                }
                return(false);
            }
            catch (Exception ex)
            {
                log.LogExceptionFormat(LogType.Error, ex, $"Cannot resolve decorator2 '{Ident}':{ex.Message}");
                return(false);
            }
        }
        public ExcelContextItemWithFormula(IBindingContextElement parent, IBindingDefinition bindingDefinition)
            : base(parent, bindingDefinition)
        {
            excelBindingDefinitionWithFormula = bindingDefinition as ExcelBindingDefinitionWithFormula;
            CanNotify = excelBindingDefinitionWithFormula.CanNotify;

            if (excelBindingDefinitionWithFormula.FormulaBindingDefinition != null)
            {
                formulaBindingContext = excelBindingDefinitionWithFormula.FormulaBindingDefinition.ContextItemFactory(parent);
            }

            if (CanNotify)
            {
                objectsToNotify = excelBindingDefinitionWithFormula.GetObjectsToNotify(DataSource);
                if (objectsToNotify != null)
                {
                    foreach (INotifyPropertyChanged obj in objectsToNotify)
                    {
                        obj.PropertyChanged += OnPropertyChanged;
                    }
                }
            }
        }
示例#23
0
 public ExcelElementDecorator(ExcelInterop.Range range, ExcelRangeDecorator decorator, IBindingContextElement contextElement)
 {
     this.range          = range;
     this.decorator      = decorator;
     this.contextElement = contextElement;
 }
示例#24
0
        public BindingContext(IBindingContextElement parent, ITemplateView owner, ITemplateDefinition templateDefinition, object dataSource, List <IFilterDefinition> templatedFilters)
        {
            try
            {
                if (owner == null)
                {
                    throw new ArgumentNullException("The parameter 'owner' cannot be null");
                }
                if (templateDefinition == null)
                {
                    throw new ArgumentNullException("The parameter 'templateDefinition' cannot be null");
                }

                Owner = owner;
                TemplateDefinition = templateDefinition;
                TemplatedFilters   = templatedFilters;
                IsExpanded         = TemplateDefinition.TemplateOption.HeaderAsExpander != HeaderAsExpander.StartClosed;

                //TemplatedSortsAndFilters = templatedSortsAndFilters;
                Parent     = parent;
                DataSource = dataSource;

                if (DataSource != null)
                {
                    List <object>      dataSourceAsList;
                    IBindingDefinition dataSourceType;
                    if (DataSource is IEnumerable)
                    {
                        dataSourceAsList = (DataSource as IEnumerable).Cast <object>().ToList();
                        dataSourceType   = BindingDefinitionRoot.CreateInstance(dataSourceAsList.GetType());
                    }
                    else
                    {
                        dataSourceAsList = new List <object>();
                        dataSourceAsList.Add(DataSource); //new object[] { DataSource };
                        dataSourceType = BindingDefinitionRoot.CreateInstance(DataSource.GetType());
                    }

                    if (TemplateDefinition.MainBindingDefinition != null)
                    {
                        CheckType(TemplateDefinition.MainBindingDefinition, dataSourceType);
                    }

                    ISortersAndFilters externalSortersAndFilters = null;
                    owner.ExternalSortersAndFilters?.TryGetValue(TemplateDefinition, out externalSortersAndFilters);

                    //Occurrences = dataSourceAsList.Count;
                    if (TemplateDefinition.Body != null)
                    {
                        IEnumerable <IFilterDefinition> templatedFiltersToTakeIntoAccount = null;
                        if (templatedFilters != null)
                        {
                            IEnumerable <IFilterDefinition> templatedFiltersToTakeIntoAccountFound = templatedFilters.Where(tf => tf.TemplateDefinition == templateDefinition);
                            if (templatedFiltersToTakeIntoAccountFound.Any())
                            {
                                templatedFiltersToTakeIntoAccount = templatedFiltersToTakeIntoAccountFound;
                            }
                        }

                        ISorterDefinition[] sortersDefinition = null;
                        if (((TemplateView)owner).SorterDefinition != null && ((TemplateView)owner).SorterDefinition.TemplateDefinition == templateDefinition)
                        {
                            sortersDefinition = new ISorterDefinition[] { ((TemplateView)owner).SorterDefinition }
                        }
                        ;

                        ISortersAndFilters sortersAndFilters = null;
                        if (templatedFilters != null || sortersDefinition != null)
                        {
                            sortersAndFilters = SortersAndFilterersFactory.CreateInstance(templateDefinition, templatedFiltersToTakeIntoAccount, sortersDefinition);
                        }
                        Body = BindingContextPart.CreateBodyBindingContextPart(this, TemplateDefinition.Body, dataSourceAsList, externalSortersAndFilters, sortersAndFilters);
                    }

                    if (TemplateDefinition.Header != null)
                    {
                        Header = BindingContextPart.CreateHeaderOrFooterBindingContextPart(this, TemplateDefinition.Header, BindingContextPartType.Header, DataSource);
                    }
                    if (TemplateDefinition.Footer != null)
                    {
                        Footer = BindingContextPart.CreateHeaderOrFooterBindingContextPart(this, TemplateDefinition.Footer, BindingContextPartType.Header, DataSource);
                    }
                }
            }
            catch (Exception ex)
            {
                string message = $"Create the 'BindingContext' for template '{(templateDefinition == null ? string.Empty : templateDefinition.Name)}' failed . {ex.Message}";
                throw new EtkException(message);
            }
        }
 protected BindingSearchContextItem(ITemplateView view, BindingSearchDefinition definition, IBindingContextElement parent)
     : base(parent, null)
 {
     this.view       = (TemplateView)view;
     this.definition = definition;
 }
 public abstract BindingSearchContextItem CreateContextItem(ITemplateView view, IBindingContextElement parent);
示例#27
0
 public override IBindingContextItem ContextItemFactory(IBindingContextElement parent)
 {
     //IBindingContextItem nestedContextItem = NestedBindingDefinition.ContextItemFactory(parent);
     return(new ExcelContextItemFormulaResult(parent, this));
 }
 public ExcelBindingSearchContextItem(ITemplateView view, BindingSearchDefinition definition, IBindingContextElement parent)
     : base(view, definition, parent)
 {
     ((ExcelTemplateView)view).RegisterSearchControl(this);
 }
 public override IBindingContextItem ContextItemFactory(IBindingContextElement parent)
 {
     return(new ExcelContextItemButton(parent, this));
 }
示例#30
0
 public ExcelBindingFilterContextItem(ITemplateView view, BindingFilterDefinition bindingFilterDefinition, IBindingContextElement bindingContextElement)
     : base(view, bindingFilterDefinition, bindingContextElement)
 {
 }