Esempio n. 1
0
        protected override void UpdateSetting()
        {
            MultipleSelectionList msl = (MultipleSelectionList)_setting;

            msl.SelectedIndices = FindSelectedIndices();
            base.UpdateSetting();
        }
Esempio n. 2
0
        protected override void SettingChanged()
        {
            MultipleSelectionList msl = (MultipleSelectionList)_setting;

            _selectedIndices = msl.SelectedIndices;
            base.SettingChanged();
        }
Esempio n. 3
0
 protected override void UpdateItemsList()
 {
     _items.Clear();
     if (_setting != null)
     {
         MultipleSelectionList msl = (MultipleSelectionList)_setting;
         int current = 0;
         foreach (IResourceString item in msl.Items)
         {
             ListItem listItem = new ListItem(KEY_NAME, item)
             {
                 Selected = _selectedIndices.Contains(current)
             };
             listItem.SelectedProperty.Attach(OnSelectionChanged);
             _items.Add(listItem);
             current++;
         }
     }
     _items.FireChange();
 }
Esempio n. 4
0
        /// <summary>
        /// Builds the specified node to a Panel.
        /// </summary>
        /// <param name="node">Node to build to the Panel.</param>
        /// <param name="position">Defines the positioning parameters.</param>
        /// <returns></returns>
        private Panel BuildToPanel(IConfigurationNode node, Position position)
        {
            Panel panel = new Panel();

            panel.Tag      = node == null ? null : node.ConfigObj;
            panel.AutoSize = false;
            panel.Height   = 0;
            panel.Width    = position.FullWidth;
            panel.Padding  = new Padding(0, 0, 0, 0);
            panel.Margin   = new Padding(0, 0, 0, 0);
            if (node == null || node.ConfigObj == null)
            {
                return(panel); // Return empty panel
            }
            panel.Name = string.Format("{0}_{1}", node.Location, node.ConfigObj);
            // Add heading
            if (node.ConfigObj is ConfigGroup)
            {
                panel.Controls.Add(CreateHeading(position, node.ConfigObj.Text.Evaluate()));
                position.LinePosition += position.LineHeight;
            }
            // Add subcontrols
            foreach (IConfigurationNode subNode in node.ChildNodes)
            {
                if (subNode.ConfigObj.Hidden)
                {
                    continue;
                }
                if (subNode.ConfigObj is ConfigGroup)
                {
                    Position pos = (Position)position.Clone();
                    pos.StartColumnOne += pos.Indent; // indent the first column
                    pos.WidthColumnOne -= pos.Indent; // shorten the width, so it doesn't overlap with column two
                    pos.LinePosition    = 0;          // reset linePosition, this is relative to the new control
                    // Make a recursive call to process the group to a Panel
                    Panel subPanel = BuildToPanel(subNode, pos);
                    subPanel.Anchor   = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                    subPanel.Location = new Point(0, position.LinePosition);
                    subPanel.Enabled  = !subNode.ConfigObj.Disabled;
                    panel.Controls.Add(subPanel);
                    position.LinePosition += pos.LinePosition;
                }
                else if (subNode.ConfigObj is ConfigSetting)
                {
                    ConfigSetting setting = (ConfigSetting)subNode.ConfigObj;
                    setting.OnChangeEvent += _configChangedHandler;
                    if (setting is Entry)
                    {
                        panel.Controls.Add(CreateLabel(position, setting.Text.Evaluate()));
                        TextBox txt = CreateTextBox(position, setting.Columns);
                        txt.Text = ((Entry)setting).Value;
                        txt.Tag  = setting;
                        SetHelp(txt, setting.Help.Evaluate());
                        txt.Enabled = !setting.Disabled;
                        panel.Controls.Add(txt);
                        position.LinePosition += position.LineHeight + position.Margin;
                    }
                    else if (setting is LimitedNumberSelect)
                    {
                        int height;
                        panel.Controls.Add(CreateLabel(position, setting.Text.Evaluate(), position.Width, out height));
                        panel.Controls.Add(CreateLimitedNumberSelect(position, (LimitedNumberSelect)setting));
                        position.LinePosition += height + position.Margin;
                    }
                    else if (setting is MultipleEntryList)
                    {
                        panel.Controls.Add(CreateLabel(position, setting.Text.Evaluate()));
                        position.LinePosition += position.LineHeight;
                        TextBox txt = CreateMultiLineTextBox(position, setting.Rows);
                        txt.Tag = setting;
                        MultipleEntryList entryList = (MultipleEntryList)setting;
                        txt.Lines = new string[entryList.Lines.Count];
                        for (int i = 0; i < txt.Lines.Length; i++)
                        {
                            txt.Lines[i] = entryList.Lines[i];
                        }
                        SetHelp(txt, setting.Help.Evaluate());
                        txt.Enabled = !setting.Disabled;
                        panel.Controls.Add(txt);
                        position.LinePosition += txt.Height + position.Margin;
                    }
                    else if (setting is MultipleSelectionList)
                    {
                        int lblHeight;
                        panel.Controls.Add(CreateLabel(position, setting.Text.Evaluate(), position.WidthColumnOne,
                                                       out lblHeight));
                        position.LinePosition += lblHeight + position.Margin;
                        CheckedListBox        chk  = CreateCheckedListBox(position);
                        MultipleSelectionList list = ((MultipleSelectionList)setting);
                        for (int i = 0; i < list.Items.Count; i++)
                        {
                            chk.Items.Add(list.Items[i], list.SelectedIndices.Contains(i));
                        }
                        chk.Enabled = !setting.Disabled;
                        panel.Controls.Add(chk);
                        position.LinePosition += chk.Height + position.Margin;
                    }
                    else if (setting is NumberSelect)
                    {
                        int height;
                        panel.Controls.Add(CreateLabel(position, setting.Text.Evaluate(), position.Width, out height));
                        panel.Controls.Add(CreateNumberSelect(position, (NumberSelect)setting));
                        position.LinePosition += height + position.Margin;
                    }
                    else if (setting is Path)
                    {
                        int height;
                        panel.Controls.Add(CreateLabel(position, setting.Text.Evaluate(), position.Width, out height));
                        position.LinePosition += height + position.Margin;
                        Panel browse = CreateBrowseEntry(position, (Path)setting);
                        panel.Controls.Add(browse);
                        position.LinePosition += browse.Height + position.Margin;
                    }
                    else if (setting is PreferenceList)
                    {
                        int height;
                        panel.Controls.Add(CreateLabel(position, setting.Text.Evaluate(), position.Width, out height));
                        position.LinePosition += height + position.Margin;
                        Panel list = CreatePreferenceList(position, (PreferenceList)setting);
                        panel.Controls.Add(list);
                        position.LinePosition += list.Height + position.Margin;
                    }
                    else if (setting is SingleSelectionList)
                    {
                        int lblHeight;
                        panel.Controls.Add(CreateLabel(position, setting.Text.Evaluate(), position.WidthColumnOne,
                                                       out lblHeight));
                        lblHeight += position.Margin;
                        if (((SingleSelectionList)setting).Items.Count > 3) // ComboBox
                        {
                            ComboBox cmb = CreateComboBox(position);
                            foreach (IResourceString item in ((SingleSelectionList)setting).Items)
                            {
                                cmb.Items.Add(item.Evaluate());
                            }
                            cmb.SelectedIndex = ((SingleSelectionList)setting).Selected;
                            cmb.Tag           = setting;
                            SetHelp(cmb, setting.Help.Evaluate());
                            cmb.Enabled = !setting.Disabled;
                            panel.Controls.Add(cmb);
                            if (lblHeight > position.LineHeight)
                            {
                                position.LinePosition += (position.ItemHeight * (lblHeight / (position.ItemHeight * 2)));
                            }
                            position.LinePosition += position.LineHeight;
                        }
                        else // 3 or less items:            Radiobuttons
                        {
                            Panel radioPanel = CreateRadioPanel(position, (SingleSelectionList)setting);
                            panel.Enabled = !setting.Disabled;
                            panel.Controls.Add(radioPanel);
                            position.LinePosition += radioPanel.Height + position.Margin;
                        }
                    }
                    else if (setting is YesNo)
                    {
                        int lblHeight;
                        panel.Controls.Add(CreateLabel(position, setting.Text.Evaluate(), position.WidthColumnOne, out lblHeight));
                        lblHeight += position.Margin;
                        CheckBox chk = CreateCheckBox(position);
                        chk.Checked = ((YesNo)setting).Yes;
                        chk.Tag     = setting;
                        SetHelp(chk, setting.Help.Evaluate());
                        chk.Enabled = !setting.Disabled;
                        panel.Controls.Add(chk);
                        if (lblHeight > position.LineHeight)
                        {
                            position.LinePosition += (position.ItemHeight * (lblHeight / (position.ItemHeight * 2)));
                        }
                        position.LinePosition += position.LineHeight;
                    }
                }
            }
            panel.Height = position.LinePosition;
            return(panel);
        }
        protected void OnSelectionChanged(AbstractProperty property, object oldValue)
        {
            MultipleSelectionList msl = (MultipleSelectionList)_setting;

            _selectedIndices = FindSelectedIndices();
        }