示例#1
0
        public void CreateControl(ExcelInterop.Range range)
        {
            ExcelBindingDefinitionCheckBox definition = (ExcelBindingDefinitionCheckBox)BindingDefinition;

            checkBox = new ExcelCheckBox(range, definition.Definition);

            ResolveBinding();
            checkBox.SetOnClick(() => definition.UpdateDataSource(this.DataSource, checkBox.IsChecked));
        }
        public static ExcelBindingDefinitionCheckBox CreateInstance(ExcelTemplateDefinition templateDefinition, string definition)
        {
            ExcelBindingDefinitionCheckBox ret = null;

            if (!string.IsNullOrEmpty(definition))
            {
                try
                {
                    ExcelCheckBoxDefinition      excelButtonDefinition = definition.Deserialize <ExcelCheckBoxDefinition>();
                    BindingDefinitionDescription definitionDescription = BindingDefinitionDescription.CreateBindingDescription(templateDefinition, excelButtonDefinition.Value, excelButtonDefinition.Value);
                    ret = new ExcelBindingDefinitionCheckBox(definitionDescription, templateDefinition, excelButtonDefinition);
                }
                catch (Exception ex)
                {
                    string message = $"Cannot retrieve the checkbox dataAccessor '{definition.EmptyIfNull()}'. {ex.Message}";
                    throw new EtkException(message);
                }
            }
            return(ret);
        }
示例#3
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;
                        }
                    }
                }
            }
        }