private void RetrieveDecorator()
 {
     if (!string.IsNullOrEmpty(TemplateOption.DecoratorIdent))
     {
         Decorator = DecoratorsManager.GetDecorator(TemplateOption.DecoratorIdent) as ExcelRangeDecorator;
     }
 }
示例#2
0
        public override void LoadItems()
        {
            Debug.Assert(DecoratorsManager != null, "DecoratorsManager must be set prior to loading items.");
            Items.Clear();

            foreach (ImageDecorator borderDecorator in DecoratorsManager.GetImageDecoratorsFromGroup(ImageDecoratorsManager.BORDER_GROUP))
            {
                if (borderDecorator.Command.Enabled && borderDecorator.Command.On)
                {
                    items.Add(new GalleryItem(borderDecorator.DecoratorName, borderDecorator.IconLarge, borderDecorator.Id));
                }
            }

            base.LoadItems();

            OnStateChanged(EventArgs.Empty);
        }
        private BindingDefinitionDescription(ITemplateDefinition templateDefinition, string bindingExpression, bool isConst, List <string> options)
        {
            BindingExpression = bindingExpression;
            IsConst           = isConst;
            if (options != null)
            {
                IsReadOnly = options.Contains("R");
                options.Remove("R");

                if (options.Count > 0)
                {
                    foreach (string option in options)
                    {
                        // Formula
                        if (option.StartsWith("F="))
                        {
                            Formula = option.Substring(2);
                            continue;
                        }

                        // Description
                        if (option.StartsWith("D="))
                        {
                            Description = option.Substring(2);
                            continue;
                        }
                        // Name
                        if (option.StartsWith("N="))
                        {
                            Name = option.Substring(2);
                            continue;
                        }
                        // Decorator
                        if (option.StartsWith("DEC="))
                        {
                            string decoratorIdent = option.Substring(4);
                            Decorator = DecoratorsManager.GetDecorator(decoratorIdent);
                            continue;
                        }
                        // Decorator 2
                        if (option.StartsWith("DEC2="))
                        {
                            string decoratorDescription = option.Substring(5);
                            Decorator = DecoratorsManager.CreateSimpleDecorator(templateDefinition, decoratorDescription);
                            continue;
                        }
                        // On Selection
                        if (option.StartsWith("S="))
                        {
                            string methodInfoName = option.Substring(2);
                            OnSelection = RetrieveMethodInfo(templateDefinition, option, methodInfoName);
                            continue;
                        }
                        // On double left click
                        if (option.StartsWith("LDC="))
                        {
                            string methodInfoName = option.Substring(4);
                            OnLeftDoubleClick = RetrieveMethodInfo(templateDefinition, option, methodInfoName);
                            continue;
                        }
                        // MultiLine based on the number of line passed as parameter
                        if (option.StartsWith("M="))
                        {
                            IsMultiLine = true;
                            string factor = option.Substring(2);
                            double multiLineFactor;
                            if (!string.IsNullOrEmpty(factor) && double.TryParse(factor, out multiLineFactor))
                            {
                                MultiLineFactor = multiLineFactor;
                            }
                            else
                            {
                                MultiLineFactor = 1.5;
                            }
                            continue;
                        }
                        // MultiLine where the number of line is determinated by a callback invocation
                        if (option.StartsWith("ME="))
                        {
                            string methodInfoName = option.Substring(3);
                            if (!string.IsNullOrEmpty(methodInfoName))
                            {
                                try
                                {
                                    MultiLineFactorResolver = RetrieveMethodInfo(templateDefinition, null, methodInfoName);
                                    if (MultiLineFactorResolver != null)
                                    {
                                        if (!MultiLineFactorResolver.IsNotDotNet)
                                        {
                                            int parametersCpt = MultiLineFactorResolver.Callback.GetParameters().Length;
                                            if (MultiLineFactorResolver.Callback.ReturnType != typeof(int) || parametersCpt > 1 || (parametersCpt == 1 && !(MultiLineFactorResolver.Callback.GetParameters()[0].ParameterType.IsAssignableFrom(typeof(object)))))
                                            {
                                                throw new Exception("The function prototype must be defined as 'int <Function Name>([param]) with 'param' inheriting from 'system.object'");
                                            }
                                        }
                                        IsMultiLine = true;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    throw new Exception($"Cannot resolve the 'ME' attribute for the binding definition '{bindingExpression}'", ex);
                                }
                            }
                        }
                        // On double left click, Show/Hide the x following/preceding colums/rows. Start hidden
                        if (option.StartsWith("SH_COL_S="))
                        {
                            string numberOfConcernedColumns = option.Substring(9);
                            int    wrk;
                            if (!string.IsNullOrEmpty(numberOfConcernedColumns) && int.TryParse(numberOfConcernedColumns, out wrk))
                            {
                                SpecificEventCallback callback      = EventCallbacksManager.GetRegisteredCallback("ETK_ShowHideColumns") as SpecificEventCallback;
                                SpecificEventCallback callbackToUse = new SpecificEventCallback(callback);
                                callbackToUse.Parameters = new[] { new SpecificEventCallbackParameter {
                                                                       IsSender = true
                                                                   },
                                                                   new SpecificEventCallbackParameter {
                                                                       ParameterValue = wrk
                                                                   } };
                                OnLeftDoubleClick = callbackToUse;
                                continue;
                            }
                            throw new Exception("The 'Show/Hide' prototype must be defined as 'SH_COL_S=<int>' where '<int>' is a integer");
                        }
                        // On double left click, Show/Hide the x following/preceding colums/rows. Start shown
                        if (option.StartsWith("SH_COL_H="))
                        {
                            string numberOfConcernedColumns = option.Substring(9);
                            int    wrk;
                            if (!string.IsNullOrEmpty(numberOfConcernedColumns) && int.TryParse(numberOfConcernedColumns, out wrk))
                            {
                                SpecificEventCallback callback      = EventCallbacksManager.GetRegisteredCallback("ETK_ShowHideColumns") as SpecificEventCallback;
                                SpecificEventCallback callbackToUse = new SpecificEventCallback(callback);
                                callbackToUse.Parameters = new[] { new SpecificEventCallbackParameter {
                                                                       IsSender = true
                                                                   },
                                                                   new SpecificEventCallbackParameter {
                                                                       ParameterValue = wrk
                                                                   } };
                                OnLeftDoubleClick = callbackToUse;
                                OnAfterRendering  = callbackToUse;
                                continue;
                            }
                            throw new Exception("The 'Show/Hide' columns prototype must be defined as 'SH_COL_H==<int>' where '<int>' is a integer");
                        }
                    }
                }
            }
        }