예제 #1
0
        private void editButton_Click(object sender, EventArgs e)
        {
            if (codeListBox.SelectedIndex == -1)
            {
                return;
            }

            CodePiece newCode = allActions[eventListBox.SelectedIndex][codeListBox.SelectedIndex].Copy();

            newCode.actualCode = true;
            if (newCode.customForm == null)
            {
                if ((new EditForm(newCode)).ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
                {
                    return;
                }
            }
            else
            {
                newCode.customForm.Tag = newCode;
                if ((newCode.customForm.ShowDialog() == System.Windows.Forms.DialogResult.Cancel))
                {
                    return;
                }
            }

            if (newCode != null)
            {
                allActions[eventListBox.SelectedIndex][codeListBox.SelectedIndex] = newCode;
                refreshCodeBox(eventListBox.SelectedIndex);
            }
        }
예제 #2
0
        private void AddCode(CodePiece codePiece)
        {
            CodePiece newCode = codePiece.Copy();

            newCode.actualCode = true;
            if (newCode.showEditForm)
            {
                if (newCode.customForm == null)
                {
                    if ((new EditForm(newCode)).ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
                    {
                        return;
                    }
                }
                else
                {
                    newCode.customForm.Tag = newCode;
                    if ((newCode.customForm.ShowDialog() == System.Windows.Forms.DialogResult.Cancel))
                    {
                        return;
                    }
                }
            }

            if (newCode != null)
            {
                allActions[eventListBox.SelectedIndex].Insert(Math.Max(codeListBox.SelectedIndex + 1, 0), newCode);
                refreshCodeBox(eventListBox.SelectedIndex);
                codeListBox.SelectedIndex += 1;
            }
        }
예제 #3
0
        public CodePiece Copy()
        {
            CodePiece n = (CodePiece)this.MemberwiseClone();

            n.branchType = n.branchType.Copy();
            return((CodePiece)n);
        }
예제 #4
0
        private void moveDownButton_Click(object sender, EventArgs e)
        {
            CodePiece c = allActions[eventListBox.SelectedIndex][codeListBox.SelectedIndex];

            allActions[eventListBox.SelectedIndex].RemoveAt(codeListBox.SelectedIndex);
            allActions[eventListBox.SelectedIndex].Insert(codeListBox.SelectedIndex + 1, c);
            refreshCodeBox(eventListBox.SelectedIndex);
            codeListBox.SelectedIndex++;
        }
예제 #5
0
 private void Button2_Click(object sender, EventArgs e)
 {
     DialogResult = System.Windows.Forms.DialogResult.Cancel;
     target       = null;
     Close();
 }
예제 #6
0
        public EditForm(CodePiece target)
        {
            InitializeComponent();

            this.target = target;

            if (target.noRelative)
            {
                relativeBox.Enabled = false;
            }

            if (target.is16Bit && target.enumerations == null)
            {
                show16BitBox = true;
            }
            if (target.enumerations == null)
            {
                showVarBox = true;
            }
            if (target.enumerations == null)
            {
                showHexBox = true;
            }
            if (target.enumerations != CodePiece.trueFalse && target.isStatement == false)
            {
                showNotBox = true;
            }
            if (target.isStatement && target.enumerations == null)
            {
                showRelativeBox = true;
            }
            if (target.enumerations == null)
            {
                showSignedBox = true;
            }


            int height = 0;

            queryString.Text = target.queryStr;
            height          += queryString.Bottom + queryString.Margin.Bottom + queryString.Margin.Top + 16;

            TextBox1.Top  = TextBox1.Margin.Top + height;
            comboBox1.Top = comboBox1.Margin.Top + height;

            varBox.Checked = !target.usesConstant;

            if (target.inputCount >= 1)
            {
                Label1.Visible   = true;
                Label1.Text      = target.inputStr1;
                TextBox1.Visible = true;
                Label1.Top       = height + Label1.Margin.Top;
                height           = Label1.Bottom + Label1.Margin.Bottom;
                //TextBox1.Text = target.ValueToString(target.value).TrimStart('#').TrimStart('$');
                TextBox1.Text = target.value.ToString();
            }

            if (target.inputCount >= 2)
            {
                Label2.Visible   = true;
                Label2.Text      = target.inputStr2;
                TextBox2.Visible = true;
                Label2.Top       = height + Label2.Margin.Top;
            }

            height = TextBox1.Bottom + TextBox1.Margin.Bottom;

            varBox.Top = hexBox.Top = height;

            if (showVarBox)
            {
                varBox.Visible = true;
            }
            if (showHexBox)
            {
                hexBox.Visible = true;
            }
            if (showVarBox || showHexBox)
            {
                height += varBox.Height + varBox.Margin.Top + varBox.Margin.Bottom;
            }

            notBox.Top = relativeBox.Top = height;

            if (showNotBox)
            {
                notBox.Visible = true;
            }
            if (showRelativeBox)
            {
                relativeBox.Visible = true;
            }
            if (showNotBox || showRelativeBox)
            {
                height += notBox.Height + notBox.Margin.Top + notBox.Margin.Bottom;
            }

            is16BitBox.Top = signedBox.Top = height;

            if (show16BitBox)
            {
                is16BitBox.Visible = true;
            }
            if (showSignedBox)
            {
                signedBox.Visible = true;
            }
            if (show16BitBox || showSignedBox)
            {
                height += signedBox.Height + signedBox.Margin.Top + signedBox.Margin.Bottom;
            }


            if (target.enumerations != null)
            {
                comboBox1.Visible = true;
                TextBox1.Visible  = false;
                for (int i = 0; i < target.enumerations.Length; i++)
                {
                    comboBox1.Items.Add(target.enumerations[i]);
                }
                comboBox1.SelectedIndex = target.value;
                notBox.Checked          = target.branchType.ct == ComparisonType.NotEqual;
            }
            else
            {
                comboBox1.Visible = false;
                TextBox1.Visible  = true;
            }

            if (TextBox2.Visible)
            {
                TextBox2.Top = height + TextBox2.Margin.Top;
                height       = TextBox2.Bottom + TextBox2.Margin.Top + TextBox2.Margin.Bottom;
            }

            if (!showNotBox)
            {
                relativeBox.Left = notBox.Left;
            }

            if (target.isStatement == false && target.enumerations == null)
            {
                GroupBox1.Top = height + GroupBox1.Margin.Top;
                height        = GroupBox1.Bottom + GroupBox1.Margin.Top + GroupBox1.Margin.Bottom;
                switch (target.branchType.ct)
                {
                case ComparisonType.Equal:
                    equalButton.Checked = true; break;

                case ComparisonType.Greater:
                case ComparisonType.SignGreater:
                    greaterButton.Checked = true; break;

                case ComparisonType.Less:
                case ComparisonType.SignLess:
                    lessButton.Checked = true; break;

                case ComparisonType.Negative:
                    negativeButton.Checked = true; break;

                case ComparisonType.NotEqual:
                    notEqualButton.Checked = true; break;

                case ComparisonType.Positive:
                    positiveButton.Checked = true; break;
                }
            }
            else
            {
                GroupBox1.Visible = false;
            }


            is16BitBox.Checked  = target.is16Bit;
            relativeBox.Checked = target.relative;
            varBox.Checked      = !target.usesConstant;
            signedBox.Checked   = target.allowNegative;
            hexBox.Checked      = target.usingHex;

            height += 10;

            if (!target.usesConstant)
            {
                TextBox1.Text = target.ValueToString(target.value).TrimStart('$');
            }

            Button2.Top = Button1.Top = height + Button1.Margin.Top;

            height = Button1.Bottom + Button1.Margin.Bottom + this.Padding.Bottom;

            UpdateTextBoxLengths();

            this.Height = height + this.Padding.Bottom + 40;
        }