Example #1
0
        private void editButton_Click(object sender, EventArgs e)
        {
            int index = shownValues.SelectedIndex;

            if (index != -1)
            {
                if (!ItemAlreadyExists(EDITING_ITEM) && shownTextBox.Text != "")
                {
                    String translated = TokenTextTranslator.TranslateFromTextFile(shownTextBox.Text);
                    translated = TokenControlTranslator.TranslateFromControl(translated);

                    cb.cd.comboBoxConfigItems[index] = configTextBox.Text;
                    cb.cd.comboBoxRealItems[index]   = shownTextBox.Text;
                    cb.cd.comboBoxItems[index]       = translated;
                }
            }

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

            shownValues.SelectedItem = shownTextBox.Text;

            if ((cb as ComboBox).Items.Count == 1)
            {
                (cb as ComboBox).SelectedIndex = 0;
            }
            else
            {
                (cb as ComboBox).SelectedIndex = index;
            }
        }
        private static void SaveControlChanges(ICustomControl c)
        {
            //if (c.cd.Type == "CComboBox" || c.cd.Type == "CTextBox" || c.cd.Type == "CCheckBox")
            //{
            String fileType = c.cd.MainDestination.Substring(c.cd.MainDestination.Length - 4, 4);

            String path = TokenTextTranslator.TranslateFromTextFile(c.cd.RealSubDestination);

            path = TokenControlTranslator.TranslateFromControl(path).TrimStart('\\');

            String value = GetValueToSave(c);

            if (c.cd.DestinationType == ".INI")
            {
                SaveINIFile(c, path, value);
            }
            else if (fileType == ".xml" && c.cd.DestinationType == ".XML")
            {
                SaveXMLFile(c, path, value);
            }
            else if (c.cd.DestinationType == "REG")
            {
                SaveRegistryKey(c, path, value);
            }
            else
            {
                Model.getInstance().logCreator.Append("[ERROR] Destination file and type not matching for " + c.cd.Name);
                System.Diagnostics.Debug.WriteLine("!ERROR : Destination file and type not matching for " + c.cd.Name);
            }
            //}
        }
        private static void TranslateText(ICustomControl r)
        {
            String text = TokenControlTranslator.TranslateFromControl(r.cd.RealText);

            text = TokenTextTranslator.TranslateFromTextFile(text);

            r.cd.Text = text;
        }
        private static void TranslateSubDestination(ICustomControl r)
        {
            String text = TokenControlTranslator.TranslateFromControl(r.cd.RealSubDestination);

            text = TokenTextTranslator.TranslateFromTextFile(text);

            r.cd.SubDestination = text;
        }
Example #5
0
        private void SetRealProperties(ICustomControl c, XElement i)
        {
            Font  newFont;
            Color newColor;

            if (!(c is CTextBox))
            {
                c.cd.RealText = i.Element("Text").Value;
            }

            String text = TokenTextTranslator.TranslateFromTextFile(c.cd.RealText);

            c.cd.Text = TokenControlTranslator.TranslateFromControl(text);

            c.cd.Hint = i.Element("Hint").Value;
            c.cd.Hint = c.cd.Hint.Replace("
", "\r\n");

            c.cd.ParentSection = Model.getInstance().sections.Find(se => se.Name == i.Element("Section").Value);

            c.cd.Top    = Convert.ToInt32(i.Element("Settings").Element("Top").Value);
            c.cd.Left   = Convert.ToInt32(i.Element("Settings").Element("Left").Value);
            c.cd.Width  = Convert.ToInt32(i.Element("Settings").Element("Width").Value);
            c.cd.Height = Convert.ToInt32(i.Element("Settings").Element("Height").Value);

            newFont          = (Font)fontConverter.ConvertFromString(i.Element("Settings").Element("Font").Value);
            c.cd.CurrentFont = newFont;

            colorConverter = TypeDescriptor.GetConverter(typeof(Color));
            newColor       = (Color)colorConverter.ConvertFromString(i.Element("Settings").Element("FontColor").Value);
            c.cd.ForeColor = newColor;

            String colorValue = i.Element("Settings").Element("BackColor").Value;

            if (colorValue != "")
            {
                c.cd.BackColor = (Color)colorConverter.ConvertFromString(colorValue);
            }
            else
            {
                c.cd.BackColor = System.Drawing.SystemColors.Control;
            }

            //newColor = (Color)colorConverter.ConvertFromString(i.Element("Settings").Element("BackColor").Value);
            //c.cd.BackColor = newColor;

            if (c is CLabel)
            {
                String align = (String)i.Element("Settings").Element("TextAlignment") ?? "TopLeft";
                SetTextAlignment(c, align);
            }

            c.cd.Format = i.Element("Settings").Element("Format").Value;

            // Get Display and Modification rights
            c.cd.DisplayRight      = i.Element("Settings").Element("DisplayRight").Value.Substring(2);
            c.cd.ModificationRight = i.Element("Settings").Element("ModificationRight").Value.Substring(2);
        }
Example #6
0
        private void SaveToControl()
        {
            String text = TokenTextTranslator.TranslateFromTextFile(this.textTextBox.Text);

            control.cd.Text        = TokenControlTranslator.TranslateFromControl(text);
            control.cd.RealText    = this.textTextBox.Text;
            control.cd.Type        = this.type;
            control.cd.Hint        = this.hintTextBox.Text;
            control.cd.CurrentFont = this.controlFont;
            control.cd.BackColor   = this.backColor;
            control.cd.ForeColor   = this.fontColor;
            control.cd.Width       = this.width;
            control.cd.Height      = this.height;
            control.cd.Top         = this.top;
            control.cd.Left        = this.left;

            control.cd.DestinationType     = this.destinationTypeComboBox.Text;
            control.cd.RealMainDestination = this.fileDestinationTextBox.Text;
            control.cd.RealSubDestination  = this.subDestinatonTextBox.Text;
            control.cd.Format = this.formattingTextBox.Text;

            control.cd.ModificationRight = this.modificationRightTextBox.Text.Substring(2);
            control.cd.DisplayRight      = this.displayRightTextBox.Text.Substring(2);

            if (control is CCheckBox)
            {
                control.cd.checkBoxCheckedValue   = this.checkedTextBox.Text;
                control.cd.checkBoxUncheckedValue = this.uncheckedTextBox.Text;
            }

            if (control is CLabel)
            {
                SetOrientationToLabel();
            }

            if (control is CButton)
            {
                control.cd.RealPath   = exePathTextBox.Text;
                control.cd.Parameters = exeArgumentsTextBox.Text;
            }

            if (control is CBitmap)
            {
                control.cd.RealPath = exePathTextBox.Text;
            }

            model.ApplyRelations(control);
            ReadRelationManager.ReadConfiguration(control as ICustomControl);

            if (control.cd.Format != null && control.cd.Format != "")
            {
                FormatValue(control);
            }

            model.uiChanged = true;
        }
        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;
            }
        }
Example #8
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;
     }
 }
Example #9
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 = "";
        }
Example #10
0
        public void ReadConfigurationFile()
        {
            if (configFileExists)
            {
                XDocument xdoc = this.configFile;

                this.headline = (String)xdoc.Element("ConfigurationManager").Element("Headline") ?? "Configuration Manager - DEFAULT HEADLINE";

                ReadSettingsSection(xdoc);
                ReadLanguagesSection(xdoc);
                ReadRightsSection(xdoc);
                ReadLogsSection(xdoc);

                this.args = Environment.GetCommandLineArgs();

                if (this.args != null)
                {
                    SetArguments();
                }

                if (this.createLogs)
                {
                    logCreator = new LogCreation("CM", 70, '#', this.createLogs);
                    logDeleter = new LogDeletion("ConfigurationManager", "CM", this.maxAgeOfLogs);
                }

                if (String.IsNullOrEmpty(this.textToken))
                {
                    TokenTextTranslator.SetTokenTextTranslator(null, this.textsFilePath);
                }
                else
                {
                    TokenTextTranslator.SetTokenTextTranslator(textToken, this.textsFilePath);
                }

                if (String.IsNullOrEmpty(this.controlToken))
                {
                    TokenControlTranslator.SetTokenKey("##");
                }
                else
                {
                    TokenControlTranslator.SetTokenKey(controlToken);
                }
            }
        }
Example #11
0
        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;
        }
Example #12
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);
        }