private static void SetReadValue(ICustomControl r, String value)
        {
            if (r is CComboBox)
            {
                if (!String.IsNullOrEmpty(r.cd.Format))
                {
                    string formattedValue = StringFormatter.GetFormattedText(value, r.cd.Format);
                    formattedValue = TokenControlTranslator.TranslateFromControl(formattedValue);
                    formattedValue = TokenTextTranslator.TranslateFromTextFile(formattedValue);

                    int index = r.cd.comboBoxConfigItems.IndexOf(formattedValue);
                    if ((r as ComboBox).Items.Count >= index)
                    {
                        (r as ComboBox).SelectedIndex = index;
                    }
                }
                else
                {
                    int index = r.cd.comboBoxConfigItems.IndexOf(value);
                    if (index == -1)
                    {
                        index = r.cd.comboBoxItems.IndexOf(value);
                    }
                    if ((r as ComboBox).Items.Count >= index)
                    {
                        (r as ComboBox).SelectedIndex = index;
                    }
                }
            }
            else if (r is CCheckBox)
            {
                if (!String.IsNullOrEmpty(r.cd.Format))
                {
                    value = StringFormatter.GetFormattedText(value, r.cd.Format);
                }

                if (value.Equals(r.cd.checkBoxCheckedValue, StringComparison.OrdinalIgnoreCase))
                {
                    (r as CCheckBox).CheckState = CheckState.Checked;
                }
                else
                {
                    (r as CCheckBox).CheckState = CheckState.Unchecked;
                }
            }
            else
            if (!String.IsNullOrEmpty(r.cd.Format))
            {
                r.cd.Text = StringFormatter.GetFormattedText(value, r.cd.Format);
            }
            else
            {
                r.cd.Text = value;
            }
        }
Exemple #2
0
 private void SetInfoLabelText(String hint)
 {
     this.infoLabel.Text = "";
     this.infoLabel.Text = hint;
     if (this.infoLabel.Text != "")
     {
         this.infoLabel.Text      = TokenControlTranslator.TranslateFromControl(this.infoLabel.Text);
         this.infoLabel.Text      = TokenTextTranslator.TranslateFromTextFile(this.infoLabel.Text);
         this.infoLabel.BackColor = System.Drawing.Color.Lavender;
     }
 }
Exemple #3
0
        // Adding the new item
        private void AddButton_Click(object sender, EventArgs e)
        {
            int index = 0;

            if ((cb as ComboBox).Items.Count > 1)
            {
                index = (cb as ComboBox).SelectedIndex;
            }

            if (!String.IsNullOrEmpty(shownTextBox.Text) && !String.IsNullOrEmpty(configTextBox.Text))
            {
                if (!ItemAlreadyExists(ADDING_NEW_ITEM))
                {
                    String translated = TokenTextTranslator.TranslateFromTextFile(shownTextBox.Text);
                    translated = TokenControlTranslator.TranslateFromControl(translated);

                    cb.cd.comboBoxItems.Add(translated);
                    cb.cd.comboBoxRealItems.Add(shownTextBox.Text);
                    cb.cd.comboBoxConfigItems.Add(configTextBox.Text);
                }
            }
            else if (!String.IsNullOrEmpty(shownTextBox.Text) && String.IsNullOrEmpty(configTextBox.Text))
            {
                if (!shownValues.Items.Contains(shownTextBox.Text))
                {
                    String translated = TokenTextTranslator.TranslateFromTextFile(shownTextBox.Text);
                    translated = TokenControlTranslator.TranslateFromControl(translated);

                    cb.cd.comboBoxItems.Add(translated);
                    cb.cd.comboBoxRealItems.Add(shownTextBox.Text);
                    cb.cd.comboBoxConfigItems.Add(String.Empty);
                }
            }

            RefreshItemLists();
            SetMoveButtons();
            SetButtons();
            RefreshActualComboBox();

            if ((cb as ComboBox).Items.Count == 1)
            {
                (cb as ComboBox).SelectedIndex = 0;
                shownValues.SelectedIndex      = 0;
            }
            else
            {
                (cb as ComboBox).SelectedIndex = index;
                shownValues.SelectedIndex      = (cb as ComboBox).Items.Count - 1;
            }

            shownTextBox.Text  = "";
            configTextBox.Text = "";
        }
        private static void TranslateComboBoxItems(ICustomControl r)
        {
            int index = (r as ComboBox).SelectedIndex;

            r.cd.comboBoxItems.Clear();
            (r as ComboBox).Items.Clear();
            (r as ComboBox).BeginUpdate();

            for (int i = 0; i < r.cd.comboBoxRealItems.Count; i++)
            {
                String text = TokenControlTranslator.TranslateFromControl(r.cd.comboBoxRealItems[i]);
                text = TokenTextTranslator.TranslateFromTextFile(text);

                (r as ComboBox).Items.Add(text);
                r.cd.comboBoxItems.Add(text);
                System.Diagnostics.Debug.WriteLine(">> TRANSLATED item: " + text + " for " + r.cd.Name);
            }

            (r as ComboBox).EndUpdate();
            (r as ComboBox).SelectedIndex = index;
            System.Diagnostics.Debug.WriteLine(">> SELECTED item: " + index + " for " + r.cd.Name);

            //if(!HasLoopRelation(r)) (r as ComboBox).SelectedIndex = index;
        }
Exemple #5
0
        private void SetControlSpecificProperties(ICustomControl c, XElement i)
        {
            if (c is CComboBox)
            {
                // Fill out the lists of items inside combo box
                ComboBox cb = c as ComboBox;
                foreach (XElement e in i.Element("Items").Descendants("Item"))
                {
                    String value = e.Value.ToString();
                    c.cd.comboBoxRealItems.Add(value);
                    value = TokenTextTranslator.TranslateFromTextFile(value);
                    value = TokenControlTranslator.TranslateFromControl(value);
                    c.cd.comboBoxItems.Add(value);
                }

                foreach (XElement e in i.Element("ConfigItems").Descendants("Item"))
                {
                    c.cd.comboBoxConfigItems.Add(e.Value.ToString());
                }

                // Fill out the comboBox
                foreach (String s in c.cd.comboBoxItems)
                {
                    cb.Items.Add(s);
                }

                try
                {
                    if (!i.Element("Items").Element("Selected").IsEmpty)
                    {
                        String value = TokenTextTranslator.TranslateFromTextFile(i.Element("Items").Element("Selected").Value);
                        value           = TokenControlTranslator.TranslateFromControl(value);
                        cb.SelectedItem = value;
                    }
                }
                catch (NullReferenceException)
                {
                    System.Diagnostics.Debug.WriteLine("*** INFO *** Problem reading " + c.cd.Name + " Attributes. No items defined?");
                }
            }
            else if (c is CCheckBox)
            {
                CheckBox cb = c as CheckBox;
                try
                {
                    c.cd.checkBoxCheckedValue   = i.Element("Settings").Element("CheckedValue").Value;
                    c.cd.checkBoxUncheckedValue = i.Element("Settings").Element("UncheckedValue").Value;
                }
                catch
                {
                    System.Diagnostics.Debug.WriteLine("*** INFO *** Problem reading CheckBox Attributes");
                }
            }
            else if (c is CButton)
            {
                try
                {
                    CButton b = c as CButton;
                    b.cd.RealPath   = i.Element("Settings").Element("ExePath").Value;
                    b.cd.Parameters = i.Element("Settings").Element("CallParameters").Value;
                }
                catch
                {
                    System.Diagnostics.Debug.WriteLine("*** INFO *** Problem reading Exe Path for Button");
                }
            }
            else if (c is CBitmap)
            {
                try
                {
                    CBitmap m = c as CBitmap;
                    m.cd.RealPath = i.Element("Settings").Element("Path").Value;
                }
                catch
                {
                    System.Diagnostics.Debug.WriteLine("*** INFO *** Problem reading Exe Path for Button");
                }
            }
        }
        private static string GetValueToSave(ICustomControl c)
        {
            String value = "";

            try
            {
                if (c is CComboBox)
                {
                    if (!String.IsNullOrEmpty(c.cd.Format))
                    {
                        String unformatted  = ReadRelationManager.GetUnformattedValue(c);
                        String currentValue = c.cd.comboBoxConfigItems[(c as CComboBox).SelectedIndex];
                        value = StringFormatter.GetUnFormattedText(currentValue, unformatted, c.cd.Format);
                        value = TokenControlTranslator.TranslateFromControl(value);
                        value = TokenTextTranslator.TranslateFromTextFile(value);
                    }
                    else
                    {
                        if (c.cd.comboBoxConfigItems.Count > 0 && (c as CComboBox).SelectedIndex != -1)
                        {
                            value = c.cd.comboBoxConfigItems[(c as CComboBox).SelectedIndex];
                            if (String.IsNullOrEmpty(value))
                            {
                                value = c.cd.comboBoxItems[(c as CComboBox).SelectedIndex];
                            }
                        }
                    }
                }
                else if (c is CTextBox)
                {
                    if (!String.IsNullOrEmpty(c.cd.Format))
                    {
                        String unformatted  = ReadRelationManager.GetUnformattedValue(c);
                        String currentValue = c.cd.Text;
                        value = StringFormatter.GetUnFormattedText(currentValue, unformatted, c.cd.Format);
                        value = TokenControlTranslator.TranslateFromControl(value);
                        value = TokenTextTranslator.TranslateFromTextFile(value);
                    }
                    else
                    {
                        value = c.cd.Text;
                    }
                }
                else if (c is CCheckBox)
                {
                    if (!String.IsNullOrEmpty(c.cd.Format))
                    {
                        String unformatted  = ReadRelationManager.GetUnformattedValue(c);
                        String currentValue = c.cd.checkBoxUncheckedValue;
                        if ((c as CCheckBox).CheckState == System.Windows.Forms.CheckState.Checked)
                        {
                            currentValue = c.cd.checkBoxCheckedValue;
                        }
                        else
                        {
                            currentValue = c.cd.checkBoxUncheckedValue;
                        }
                        value = StringFormatter.GetUnFormattedText(currentValue, unformatted, c.cd.Format);
                    }
                    else
                    {
                        value = c.cd.checkBoxUncheckedValue;
                        if ((c as CCheckBox).CheckState == System.Windows.Forms.CheckState.Checked)
                        {
                            value = c.cd.checkBoxCheckedValue;
                        }
                        else
                        {
                            value = c.cd.checkBoxUncheckedValue;
                        }
                    }
                }
                else
                {
                    if (!String.IsNullOrEmpty(c.cd.Format))
                    {
                        String unformatted  = ReadRelationManager.GetUnformattedValue(c);
                        String currentValue = c.cd.Text;
                        value = StringFormatter.GetUnFormattedText(currentValue, unformatted, c.cd.Format);
                        value = TokenControlTranslator.TranslateFromControl(value);
                        value = TokenTextTranslator.TranslateFromTextFile(value);
                    }
                    else
                    {
                        String t = TokenControlTranslator.TranslateFromControl(c.cd.RealText);
                        t     = TokenTextTranslator.TranslateFromTextFile(t);
                        value = t;
                    }
                }
            }
            catch (Exception)
            {
                System.Diagnostics.Debug.WriteLine("*** ERROR *** There was an exception while getting value to save for: " + c.cd.Name);
            }
            return(value);
        }