private CodeRow codeRow;              //the code row the codemaker uses
 public CodemakerEntry(int codeLength) //allows the codemaker to enter a code
 {
     InitializeComponent();
     rowContainer.AutoScroll = true;       //allow the user to scroll if their code length is too wide for the window
     ControlBox = false;                   //hide exit buttons
     codeRow    = new CodeRow(codeLength); //create a new coderow...
     rowContainer.Controls.Add(codeRow);   //and add it to the container
     codeRow.Location = new Point(0, 0);   //set its location
     codeRow.onClick += pegClickHandler;   //and subscribe to its click event
 }
        private ObservableCollection<CodeRow> PopulateDetails(ClaimModel claimModel)
        {
            ObservableCollection<CodeRow> details = new ObservableCollection<CodeRow>();
            details.Add(new CodeRow() { Code = string.Empty, Description = " " });
            foreach (ClaimDetailDto claimDetailDto in claimModel.HeaderDto.ClaimDetails)
            {
                CodeRow codeRow = new CodeRow();
                codeRow.Code = claimDetailDto.ClaimDetailData.ClaimDetailReference;
                codeRow.Description = claimDetailDto.ClaimDetailData.ClaimDetailReference + (!String.IsNullOrEmpty(claimDetailDto.ClaimDetailData.ClaimDetailTitle) ? (" - " + claimDetailDto.ClaimDetailData.ClaimDetailTitle) : string.Empty);
                details.Add(codeRow);
            }

            claimModel.InvokeCollectionChanged("ClaimEvent", claimModel.HeaderDto.Data.DataId);
            return details;
        }
 private void pegClickHandler(CodeRow sender, int pegNumber, bool leftClick)           //called when an active peg is clicked to be changed
 {
     if (leftClick)
     {
         sender.setPegColour(pegNumber,
                             (Colour)((int)(sender.getPegColour(pegNumber) + 1) %
                                      Enum.GetValues(typeof(Colour)).Length));     //set to the next colour in the enum
     }
     else
     {
         int length = Enum.GetValues(typeof(Colour)).Length; //number of members of the enum
         int value  = (int)(sender.getPegColour(pegNumber) - 1) %
                      length;                                //take one off and mod to ensure get within allowed range
         value = value < 0 ? value + length : value;         //c# mod is weird and gives -ve nos. this prevents that
         sender.setPegColour(pegNumber, (Colour)value);      //set to the previous colour in the enum
     }
 }
示例#4
0
 public PatternRow(CodeRow codeRow)
 {
     InitializeComponent();
     CodeRow  = codeRow;
     Elements = CodeRow.Bytes.Select(x => new PatternElement(x)).ToArray();
 }