Exemple #1
0
 public string Translate(string jp, JORControl context)
 {
     // might need context at some point if we want to deal with ex labels that have wide-ranging %d params
     return(Translate(jp));
 }
Exemple #2
0
        private Control MakeControl(JORControl jorControl)
        {
            if (jorControl.Type == "LABL")
            {
                var   jorLabel = jorControl as JORControlLabel;
                Label label    = new Label();

                SyncLabelFromJOR(label, jorLabel);

                return(label);
            }
            else if (jorControl.Type == "BUTN")
            {
                var    jorButton = jorControl as JORControlButton;
                Button button    = new Button();
                button.Text = transDict.Translate(jorControl.Name, jorButton);
                button.Tag  = jorControl;
                SyncButtonFromJOR(button, jorButton);
                jorButton.Updated += () =>
                {
                    SyncButtonFromJOR(button, jorButton);
                };

                button.Click += OnButtonClick;
                return(button);
            }
            else if (jorControl.Type == "CHBX")
            {
                var      jorCheckBox = jorControl as JORControlCheckBox;
                CheckBox checkBox    = new CheckBox();
                checkBox.Tag  = jorCheckBox;
                checkBox.Text = transDict.Translate(jorCheckBox.Name, jorCheckBox);
                SyncCheckBoxFromJOR(checkBox, jorCheckBox);
                jorCheckBox.Updated += () =>
                {
                    SyncCheckBoxFromJOR(checkBox, jorCheckBox);
                };

                checkBox.CheckedChanged += OnCheckboxChecked;
                return(checkBox);
            }
            else if (jorControl.Type == "RNGi")
            {
                var jorRange = jorControl as JORControlRangeInt;
                var table    = new TableLayoutPanel();
                table.RowCount    = 1;
                table.ColumnCount = 2;
                var label = new Label();
                label.Width = jorControl.Location.Width / 2;
                label.Text  = jorRange.Name; // intentionally not translating here for now to avoid table explosion
                table.Controls.Add(label);
                TrackBar trackBar = new TrackBar();
                trackBar.Width = jorControl.Location.Width / 2;
                trackBar.Tag   = jorRange;
                SyncRangeIntFromJOR(trackBar, jorRange);
                jorRange.Updated += () =>
                {
                    SyncRangeIntFromJOR(trackBar, jorRange);
                };

                table.Controls.Add(trackBar);
                trackBar.ValueChanged += OnSliderChangedInt;
                return(table);
            }
            else if (jorControl.Type == "RNGf")
            {
                var jorRange = jorControl as JORControlRangeFloat;
                var table    = new TableLayoutPanel();
                table.RowCount    = 1;
                table.ColumnCount = 2;
                var label = new Label();
                label.Width = jorControl.Location.Width / 2;
                label.Text  = jorRange.Name; // intentionally not translating here for now to avoid table explosion
                table.Controls.Add(label);
                TrackBar trackBar = new TrackBar();
                trackBar.Width = jorControl.Location.Width / 2;
                trackBar.Tag   = jorRange;
                SyncRangeFloatFromJOR(trackBar, jorRange);
                jorRange.Updated += () =>
                {
                    SyncRangeFloatFromJOR(trackBar, jorRange);
                };

                trackBar.ValueChanged += OnSliderChangedFloat;
                table.Controls.Add(trackBar);
                return(table);
            }
            else if (jorControl.Type == "CMBX")
            {
                var jorSelector = jorControl as JORControlSelector;
                var comboBox    = new ComboBox();
                comboBox.Tag           = jorSelector;
                comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
                comboBox.Text          = transDict.Translate(jorSelector.Name, jorSelector);
                foreach (var item in jorSelector.Items)
                {
                    comboBox.Items.Add(transDict.Translate(item.Name, jorSelector)); // use outer control as context
                }
                SyncComboBoxFromJOR(comboBox, jorSelector);
                jorSelector.Updated += () =>
                {
                    SyncComboBoxFromJOR(comboBox, jorSelector);
                };

                comboBox.SelectedIndexChanged += OnComboBoxSelectedIndexChanged;
                return(comboBox);
            }
            else if (jorControl.Type == "RBTN")
            {
                var jorSelector = jorControl as JORControlSelector;
                var groupBox    = new GroupBox();
                groupBox.Tag  = jorSelector;
                groupBox.Text = transDict.Translate(jorSelector.Name, jorSelector);
                foreach (var item in jorSelector.Items)
                {
                    var radioButton = new RadioButton();
                    radioButton.CheckedChanged += OnRadioButtonCheckedChanged;
                    radioButton.Text            = transDict.Translate(item.Name, jorSelector); // use outer control as context
                    radioButton.Tag             = item;
                    groupBox.Controls.Add(radioButton);
                }

                SyncRadioButtonFromJOR(groupBox, jorSelector);
                jorSelector.Updated = () =>
                {
                    SyncRadioButtonFromJOR(groupBox, jorSelector);
                };

                return(groupBox);
            }
            else if (jorControl.Type == "EDBX") // *don't* translate these
            {
                var jorEditBox = jorControl as JORControlEditBox;
                var table      = new TableLayoutPanel();
                table.RowCount    = 1;
                table.ColumnCount = 2;
                var label = new Label();
                label.Text = jorEditBox.Name;
                table.Controls.Add(label);
                var textBox = new TextBox();
                textBox.Tag = jorEditBox;

                SyncEditBoxFromJOR(textBox, jorEditBox);
                jorEditBox.Updated = () =>
                {
                    SyncEditBoxFromJOR(textBox, jorEditBox);
                };

                textBox.TextChanged += OnTextBoxTextChanged;
                return(table);
            }
            else if (jorControl.Type == "GRBX")
            {
                var g = new GroupBox();
                g.Text = transDict.Translate(jorControl.Name, jorControl); // i guess groupboxes can have text? uh guess we'll translate
                return(g);
            }
            else
            {
                throw new Exception("Unimplemented control!");
            }
        }