示例#1
0
        public void Restore(PBInstructionMemento Memento)
        {
            _Data                 = Memento.Data;
            LastGoodDataValue     = _Data;
            DataBox.ValueChanged -= DataBox_ValueChanged;
            DataBox.Value         = LastGoodDataValue;
            DataBox.ValueChanged += DataBox_ValueChanged;

            _Duration                    = Memento.Duration;
            LastGoodDurationText         = _Duration.ToString();
            DurationTextBox.TextChanged -= DurationTextBox_TextChanged;
            DurationTextBox.Text         = LastGoodDurationText;
            DurationTextBox.TextChanged += DurationTextBox_TextChanged;

            _Flags = Memento.Flags;
            for (int i = 0; i < FlagCheckBoxes.Length; i++)
            {
                if (FlagCheckBoxes[i] != null)
                {
                    FlagCheckBoxes[i].CheckedChanged -= FlagCheckBox_CheckedChanged;
                    FlagCheckBoxes[i].Checked         = ((_Flags & (1 << (23 - i))) != 0);
                    FlagCheckBoxes[i].CheckedChanged += FlagCheckBox_CheckedChanged;
                }
            }

            _OpCode = Memento.OpCode;
            OpCodeComboBox.SelectedIndexChanged -= OpCodeComboBox_SelectedIndexChanged;
            OpCodeComboBox.SelectedIndex         = OpCodeComboBox.FindString(_OpCode.ToString());
            OpCodeComboBox.SelectedIndexChanged += OpCodeComboBox_SelectedIndexChanged;

            _TimeUnit = Memento.TimeUnit;
            TimeUnitComboBox.SelectedIndexChanged -= TimeUnitComboBox_SelectedIndexChanged;
            TimeUnitComboBox.SelectedIndex         = TimeUnitComboBox.FindString(_TimeUnit.ToString());
            TimeUnitComboBox.SelectedIndexChanged += TimeUnitComboBox_SelectedIndexChanged;
        }
示例#2
0
        public PBInstructionBox()
        {
            InitializeComponent();

            // Number of TTL outputs on PulseBlaster is 24
            FlagCheckBoxes = new CheckBox[24];

            History = new Stack <PBInstructionMemento>();
            Future  = new Stack <PBInstructionMemento>();

            _Data             = DataDefault;
            LastGoodDataValue = _Data;

            _Duration            = DurationDefault;
            LastGoodDurationText = _Duration.ToString();

            _Flags = FlagsDefault;

            _OpCode = OpCodeDefault;

            _Style = FlagStyle.PB24;

            _TimeUnit = TimeUnitDefault;

            _Edited = true;

            DataBox.Value = LastGoodDataValue;

            DurationTextBox.Text = LastGoodDurationText;

            // Literal values for check box sizes were calculated by hand
            for (int i = 0; i < 24; i++)
            {
                FlagCheckBoxes[i]                 = new CheckBox();
                FlagCheckBoxes[i].Text            = (23 - i).ToString();
                FlagCheckBoxes[i].CheckAlign      = ContentAlignment.TopCenter;
                FlagCheckBoxes[i].TextAlign       = ContentAlignment.BottomCenter;
                FlagCheckBoxes[i].Checked         = (_Flags & (1 << (23 - i))) != 0;
                FlagCheckBoxes[i].Width           = 23;
                FlagCheckBoxes[i].Height          = 31;
                FlagCheckBoxes[i].Margin          = new Padding(0);
                FlagCheckBoxes[i].CheckedChanged += new EventHandler(FlagCheckBox_CheckedChanged);
                FlagsLayoutPanel.Controls.Add(FlagCheckBoxes[i]);
            }

            OpCodeComboBox.SelectedIndexChanged -= OpCodeComboBox_SelectedIndexChanged;
            OpCodeComboBox.DataSource            = Enum.GetValues(typeof(OpCode));
            OpCodeComboBox.SelectedIndex         = OpCodeComboBox.FindString(_OpCode.ToString());
            OpCodeComboBox.SelectedIndexChanged += OpCodeComboBox_SelectedIndexChanged;

            TimeUnitComboBox.SelectedIndexChanged -= TimeUnitComboBox_SelectedIndexChanged;
            TimeUnitComboBox.DataSource            = Enum.GetValues(typeof(TimeUnit));
            TimeUnitComboBox.SelectedIndex         = TimeUnitComboBox.FindString(_TimeUnit.ToString());
            TimeUnitComboBox.SelectedIndexChanged += TimeUnitComboBox_SelectedIndexChanged;
        }