Example #1
0
 public void SetInstruction(Instruction inst)
 {
     this.timeBar.Value = DelayTable.delayToIndex(inst.value);
     this.time_value = inst.value;
     this.inst = inst;
     barChanged();
 }
Example #2
0
 private void okButton(object sender, EventArgs e)
 {
     this.Hide();
     if (this.inst == null)
     {
         return;
     }
     this.inst.value = this.time_value;
     this.programEditor.refreshInstruction(this.inst);
     this.inst = null;
 }
Example #3
0
 public void SetInstruction(Instruction inst)
 {
     if ((0 <= inst.value) && (inst.value <= 16))
     {
         this.valueBar.Value = inst.value;
     }
     else
     {
         this.valueBar.Value = 16;
     }
     this.inst = inst;
     barChanged();
 }
Example #4
0
 public void refreshInstruction(Instruction inst)
 {
     if (inst.t == InstructionType.InstructionTransition)
     {
         last_added_transition = inst;
     }
     if (inst.t == InstructionType.InstructionWait)
     {
         last_added_wait = inst;
     }
     int i, j = this.instructions.Items.Count;
     for (i = 0; i < j; i++)
     {
         InstructionEditor inst_ed = (InstructionEditor) this.instructions.Items[i];
         if (inst_ed.inst == inst)
         {
             this.instructions.Items.RemoveAt(i);
             if ((i + 1) == j)
             {
                 // Last member of list
                 this.instructions.Items.Add(inst_ed);
                 this.instructions.SetSelected(0, false);
             }
             else
             {
                 this.instructions.Items.Insert(i, inst_ed);
                 if (i < j)
                 {
                     this.instructions.SetSelected(i + 1, true);
                 }
             }
             revalidate();
             return;
         }
     }
 }
Example #5
0
 private void closeButton(object sender, FormClosingEventArgs e)
 {
     this.Hide();
     this.inst = null;
     e.Cancel = true;
 }
Example #6
0
 private void cancelButton(object sender, EventArgs e)
 {
     this.Hide();
     this.inst = null;
 }
Example #7
0
        public void decode(byte[] program_bytes)
        {
            byte[] slice = new byte[Instruction.max_inst_length];

            // decode each instruction in turn
            this.contents.Clear();
            for (int a = 0; (a < program_bytes.Length) && (a < Comms.max_program_size); )
            {
                Instruction inst = new Instruction();
                int i;
                for (i = 0; (i < Instruction.max_inst_length) && ((a + i) < program_bytes.Length); i++)
                {
                    slice[i] = program_bytes[a + i];
                }
                for (; i < Instruction.max_inst_length; i++)
                {
                    slice[i] = (byte)0;
                }
                int sz = inst.decode(slice);

                // detect illegal instruction or incomplete instruction
                if (inst.t == InstructionType.InstructionIllegal) break;

                if (sz <= 0)
                {
                    inst.t = InstructionType.InstructionIllegal;
                    break;
                }
                a += sz;

                // detect end of program (don't add to list)
                if (inst.t == InstructionType.InstructionRestart) break;

                // all other instructions go into the list
                this.contents.Add(inst);
            }

            // decode program name (if present)
            this.name = "";
            bool valid_name = false;
            for (int i = Comms.program_size - Comms.program_name_size; (i < program_bytes.Length) && (i < Comms.program_size); i++)
            {
                int ch = (int)program_bytes[i];
                if ((ch < 32) || (ch > 126))
                {
                    ch = (int)'?';
                } else if (ch > 32)
                {
                    valid_name = true;
                }
                this.name += (char)((byte)ch);
            }
            this.name = this.name.Trim();
            if (!valid_name)
            {
                this.name = "";
            }
            updateProperties();
        }
Example #8
0
 public InstructionEditor(Instruction inst)
 {
     this.inst = inst;
 }
Example #9
0
 private void insertAndEdit(Instruction inst)
 {
     InstructionEditor inst_ed = new InstructionEditor(inst);
     if (this.instructions.SelectedItems.Count != 0)
     {
         int i = this.instructions.SelectedIndex;
         this.instructions.Items.Insert(i, inst_ed);
     }
     else
     {
         this.instructions.Items.Add(inst_ed);
     }
     editItem(inst_ed);
 }
Example #10
0
 private void addWaitButton_Click(object sender, EventArgs e)
 {
     Instruction inst = new Instruction();
     inst.t = InstructionType.InstructionWait;
     if (last_added_wait != null)
     {
         inst.value = last_added_wait.value;
     }
     insertAndEdit(inst);
 }
Example #11
0
 private void addTransitionClicked(object sender, EventArgs e)
 {
     Instruction inst = new Instruction();
     inst.t = InstructionType.InstructionTransition;
     if (last_added_transition != null)
     {
         inst.r = last_added_transition.r;
         inst.g = last_added_transition.g;
         inst.b = last_added_transition.b;
         inst.value = last_added_transition.value;
     }
     insertAndEdit(inst);
 }
Example #12
0
 private void addDisplayButton(object sender, EventArgs e)
 {
     Instruction inst = new Instruction();
     inst.t = InstructionType.InstructionSetDisplay;
     insertAndEdit(inst);
 }