Ejemplo n.º 1
0
        public override void LoadData()
        {
            if (Initialized)
            {
                return;
            }

            _allowHandleEvents = false;

            var item1State = TabState.Items.ElementAtOrDefault(0);

            if (item1State == null)
            {
                item1State = new IntegratedSolutionState.StatementItemState();
                TabState.Items.Add(item1State);
            }

            var item2State = TabState.Items.ElementAtOrDefault(1);

            if (item2State == null)
            {
                item2State = new IntegratedSolutionState.StatementItemState();
                TabState.Items.Add(item2State);
            }

            statementItemControl1.Init(TabInfo.ComboCheckbox1,
                                       TabInfo.Combo1Items,
                                       TabInfo.MemoPopupCheckbox1,
                                       TabInfo.MemoPopup1Items,
                                       item1State,
                                       TabInfo.Combo1Configuration,
                                       TabInfo.MemoPopup1Configuration,
                                       SlideContainer.StyleConfiguration,
                                       SlideContainer.ResourceManager);
            statementItemControl1.EditValueChanged += OnEditValueChanged;

            statementItemControl2.Init(TabInfo.ComboCheckbox2,
                                       TabInfo.Combo2Items,
                                       TabInfo.MemoPopupCheckbox2,
                                       TabInfo.MemoPopup2Items,
                                       item2State,
                                       TabInfo.Combo2Configuration,
                                       TabInfo.MemoPopup2Configuration,
                                       SlideContainer.StyleConfiguration,
                                       SlideContainer.ResourceManager);
            statementItemControl2.EditValueChanged += OnEditValueChanged;

            _allowHandleEvents = true;

            Initialized = true;
        }
        public void Init(
            CheckboxInfo comboToggleInfo,
            IList <ListDataItem> comboList,
            CheckboxInfo memoPopupToggleInfo,
            IList <ListDataItem> memoPopupList,
            IntegratedSolutionState.StatementItemState itemState,
            TextEditorConfiguration comboConfiguration,
            TextEditorConfiguration memoPopupConfiguration,
            MainFormStyleConfiguration styleConfiguration,
            ISolutionsResourceManager resourceManager)
        {
            _allowHandleEvents = false;

            _comboToggleInfo = comboToggleInfo;

            _comboList.Clear();
            _comboList.AddRange(comboList);

            _memoPopupList.Clear();
            _memoPopupList.AddRange(memoPopupList);

            _itemState = itemState;

            _styleConfiguration = styleConfiguration;

            comboBoxEditCombo.EnableSelectAll().RaiseNullValueIfEditorEmpty().AssignConfiguration(comboConfiguration);

            checkEditCombo.Text = String.Format("<color=gray>{0}</color>", comboToggleInfo.Title ?? "header");
            layoutControlItemToggleCombo.MinSize = new Size(checkEditCombo.Width, checkEditCombo.Height);
            layoutControlItemToggleCombo.MaxSize = new Size(checkEditCombo.Width, checkEditCombo.Height);

            comboBoxEditCombo.Properties.Items.Clear();
            comboBoxEditCombo.Properties.Items.AddRange(_comboList);
            comboBoxEditCombo.Properties.NullText =
                _comboList.FirstOrDefault(item => item.IsPlaceholder)?.Value ??
                comboBoxEditCombo.Properties.NullText;

            memoPopupEdit.Init(_memoPopupList,
                               _memoPopupList.FirstOrDefault(item => item.IsDefault || item.IsPlaceholder),
                               memoPopupConfiguration,
                               _styleConfiguration,
                               resourceManager);
            memoPopupEdit.EditValueChanged += OnEditValueChanged;

            if (_itemState.Combo != null)
            {
                checkEditCombo.Checked      = !String.IsNullOrEmpty(_itemState.Combo?.Value);
                comboBoxEditCombo.EditValue = _itemState.Combo;
            }
            else
            {
                checkEditCombo.Checked      = comboToggleInfo.Value;
                comboBoxEditCombo.EditValue = _comboList.FirstOrDefault(item => item.IsDefault && !item.IsPlaceholder);
            }

            if (_itemState.MemoPopup != null)
            {
                checkEditMemoPopup.Checked = !String.IsNullOrEmpty(_itemState.MemoPopup?.Value);
                memoPopupEdit.LoadData(_itemState.MemoPopup);
            }
            else
            {
                checkEditMemoPopup.Checked = memoPopupToggleInfo.Value;
            }

            _allowHandleEvents = true;
        }