///<summary>Returns true when all of the sheet fields with IsRequired set to true have a value set. Otherwise, a message box shows and false is returned.</summary>
 private bool VerifyRequiredFields()
 {
     FillFieldsFromControls();
     foreach (Control control in panelMain.Controls)
     {
         if (control.Tag == null)
         {
             continue;
         }
         if (control.GetType() == typeof(RichTextBox))
         {
             SheetField field = (SheetField)control.Tag;
             if (field.FieldType != SheetFieldType.InputField)
             {
                 continue;
             }
             RichTextBox inputBox = (RichTextBox)control;
             if (field.IsRequired && inputBox.Text.Trim() == "")
             {
                 MessageBox.Show(Lan.g(this, "You must enter a value for") + " " + field.FieldName + " " + Lan.g(this, "before continuing."));
                 return(false);
             }
         }
         else if (control.GetType() == typeof(OpenDental.UI.SignatureBoxWrapper))
         {
             SheetField field = (SheetField)control.Tag;
             if (field.FieldType != SheetFieldType.SigBox)
             {
                 continue;
             }
             OpenDental.UI.SignatureBoxWrapper sigBox = (OpenDental.UI.SignatureBoxWrapper)control;
             if (field.IsRequired && (!sigBox.IsValid || sigBox.SigIsBlank))
             {
                 MsgBox.Show(this, "Signature required");
                 return(false);
             }
         }
         else if (control.GetType() == typeof(SheetCheckBox))              //Radio button groups or misc checkboxes
         {
             SheetField field = (SheetField)control.Tag;
             if (field.IsRequired && field.FieldValue != "X")                  //required but this one not checked
             //first, checkboxes that are not radiobuttons.  For example, a checkbox at bottom of web form used in place of signature.
             {
                 if (field.RadioButtonValue == "" &&                   //doesn't belong to a built-in group
                     field.RadioButtonGroup == "")                              //doesn't belong to a custom group
                 {
                     //field.FieldName is always "misc"
                     //int widthActual=(SheetCur.IsLandscape?SheetCur.Height:SheetCur.Width);
                     //int heightActual=(SheetCur.IsLandscape?SheetCur.Width:SheetCur.Height);
                     //int topMidBottom=(heightActual/3)
                     MessageBox.Show(Lan.g(this, "You must check the required checkbox."));
                     return(false);
                 }
                 else                                                 //then radiobuttons (of both kinds)
                                                                      //All radio buttons within a group should either all be marked required or all be marked not required.
                                                                      //Not the most efficient check, but there won't usually be more than a few hundred items so the user will not ever notice. We can speed up later if needed.
                 {
                     bool valueSet        = false;                    //we will be checking to see if at least one in the group has a value
                     int  numGroupButtons = 0;                        //a count of the buttons in the group
                     foreach (Control control2 in panelMain.Controls) //loop through all controls in the sheet
                     {
                         if (control2.GetType() != typeof(SheetCheckBox))
                         {
                             continue;                                    //skip everything that's not a checkbox
                         }
                         SheetField field2 = (SheetField)control2.Tag;
                         //whether built-in or custom, this makes sure it's a match.
                         //the other comparison will also match because they are empty strings
                         if (field2.RadioButtonGroup.ToLower() == field.RadioButtonGroup.ToLower() &&                          //if they are in the same group ("" for built-in, some string for custom group)
                             field2.FieldName == field.FieldName)                                     //"misc" for custom group, some string for built in groups.
                         {
                             numGroupButtons++;
                             if (field2.FieldValue == "X")
                             {
                                 valueSet = true;
                                 break;
                             }
                         }
                     }
                     if (numGroupButtons > 0 && !valueSet)                          //there is not at least one radiobutton in the group that's checked.
                     {
                         if (field.RadioButtonGroup != "")                          //if they are in a custom group
                         {
                             MessageBox.Show(Lan.g(this, "You must select a value for radio button group") + " '" + field.RadioButtonGroup + "'. ");
                         }
                         else
                         {
                             MessageBox.Show(Lan.g(this, "You must select a value for radio button group") + " '" + field.FieldName + "'. ");
                         }
                         return(false);
                     }
                 }
             }
         }
     }
     return(true);
 }
Beispiel #2
0
 private void InitializeComponent()
 {
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormCommItem));
     this.label1              = new System.Windows.Forms.Label();
     this.label6              = new System.Windows.Forms.Label();
     this.butOK               = new OpenDental.UI.Button();
     this.butCancel           = new OpenDental.UI.Button();
     this.butDelete           = new OpenDental.UI.Button();
     this.label2              = new System.Windows.Forms.Label();
     this.listType            = new System.Windows.Forms.ListBox();
     this.textDateTime        = new System.Windows.Forms.TextBox();
     this.listMode            = new System.Windows.Forms.ListBox();
     this.label3              = new System.Windows.Forms.Label();
     this.listSentOrReceived  = new System.Windows.Forms.ListBox();
     this.label4              = new System.Windows.Forms.Label();
     this.textNote            = new OpenDental.ODtextBox();
     this.textPatientName     = new System.Windows.Forms.TextBox();
     this.label5              = new System.Windows.Forms.Label();
     this.textUser            = new System.Windows.Forms.TextBox();
     this.label16             = new System.Windows.Forms.Label();
     this.labelCommlogNum     = new System.Windows.Forms.Label();
     this.textCommlogNum      = new System.Windows.Forms.TextBox();
     this.signatureBoxWrapper = new OpenDental.UI.SignatureBoxWrapper();
     this.butNow              = new OpenDental.UI.Button();
     this.butNowEnd           = new OpenDental.UI.Button();
     this.textDateTimeEnd     = new System.Windows.Forms.TextBox();
     this.labelDateTimeEnd    = new System.Windows.Forms.Label();
     this.SuspendLayout();
     //
     // label1
     //
     this.label1.Location  = new System.Drawing.Point(1, 33);
     this.label1.Name      = "label1";
     this.label1.Size      = new System.Drawing.Size(81, 18);
     this.label1.TabIndex  = 0;
     this.label1.Text      = "Date / Time";
     this.label1.TextAlign = System.Drawing.ContentAlignment.TopRight;
     //
     // label6
     //
     this.label6.Location  = new System.Drawing.Point(80, 80);
     this.label6.Name      = "label6";
     this.label6.Size      = new System.Drawing.Size(82, 16);
     this.label6.TabIndex  = 5;
     this.label6.Text      = "Type";
     this.label6.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
     //
     // butOK
     //
     this.butOK.AdjustImageLocation = new System.Drawing.Point(0, 0);
     this.butOK.Anchor       = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     this.butOK.Autosize     = true;
     this.butOK.BtnShape     = OpenDental.UI.enumType.BtnShape.Rectangle;
     this.butOK.BtnStyle     = OpenDental.UI.enumType.XPStyle.Silver;
     this.butOK.CornerRadius = 4F;
     this.butOK.Location     = new System.Drawing.Point(564, 515);
     this.butOK.Name         = "butOK";
     this.butOK.Size         = new System.Drawing.Size(75, 25);
     this.butOK.TabIndex     = 6;
     this.butOK.Text         = "&OK";
     this.butOK.Click       += new System.EventHandler(this.butOK_Click);
     //
     // butCancel
     //
     this.butCancel.AdjustImageLocation = new System.Drawing.Point(0, 0);
     this.butCancel.Anchor       = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     this.butCancel.Autosize     = true;
     this.butCancel.BtnShape     = OpenDental.UI.enumType.BtnShape.Rectangle;
     this.butCancel.BtnStyle     = OpenDental.UI.enumType.XPStyle.Silver;
     this.butCancel.CornerRadius = 4F;
     this.butCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
     this.butCancel.Location     = new System.Drawing.Point(564, 548);
     this.butCancel.Name         = "butCancel";
     this.butCancel.Size         = new System.Drawing.Size(75, 25);
     this.butCancel.TabIndex     = 7;
     this.butCancel.Text         = "&Cancel";
     this.butCancel.Click       += new System.EventHandler(this.butCancel_Click);
     //
     // butDelete
     //
     this.butDelete.AdjustImageLocation = new System.Drawing.Point(0, 0);
     this.butDelete.Anchor       = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     this.butDelete.Autosize     = true;
     this.butDelete.BtnShape     = OpenDental.UI.enumType.BtnShape.Rectangle;
     this.butDelete.BtnStyle     = OpenDental.UI.enumType.XPStyle.Silver;
     this.butDelete.CornerRadius = 4F;
     this.butDelete.Image        = global::OpenDental.Properties.Resources.deleteX;
     this.butDelete.ImageAlign   = System.Drawing.ContentAlignment.MiddleLeft;
     this.butDelete.Location     = new System.Drawing.Point(27, 544);
     this.butDelete.Name         = "butDelete";
     this.butDelete.Size         = new System.Drawing.Size(81, 25);
     this.butDelete.TabIndex     = 17;
     this.butDelete.Text         = "&Delete";
     this.butDelete.Click       += new System.EventHandler(this.butDelete_Click);
     //
     // label2
     //
     this.label2.Location  = new System.Drawing.Point(81, 197);
     this.label2.Name      = "label2";
     this.label2.Size      = new System.Drawing.Size(82, 16);
     this.label2.TabIndex  = 18;
     this.label2.Text      = "Note";
     this.label2.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
     //
     // listType
     //
     this.listType.Location              = new System.Drawing.Point(82, 98);
     this.listType.Name                  = "listType";
     this.listType.Size                  = new System.Drawing.Size(120, 95);
     this.listType.TabIndex              = 20;
     this.listType.SelectedIndexChanged += new System.EventHandler(this.listType_SelectedIndexChanged);
     //
     // textDateTime
     //
     this.textDateTime.Location     = new System.Drawing.Point(82, 31);
     this.textDateTime.Name         = "textDateTime";
     this.textDateTime.Size         = new System.Drawing.Size(205, 20);
     this.textDateTime.TabIndex     = 21;
     this.textDateTime.TextChanged += new System.EventHandler(this.textDateTime_TextChanged);
     //
     // listMode
     //
     this.listMode.Location              = new System.Drawing.Point(215, 98);
     this.listMode.Name                  = "listMode";
     this.listMode.Size                  = new System.Drawing.Size(73, 95);
     this.listMode.TabIndex              = 23;
     this.listMode.SelectedIndexChanged += new System.EventHandler(this.listMode_SelectedIndexChanged);
     //
     // label3
     //
     this.label3.Location  = new System.Drawing.Point(214, 81);
     this.label3.Name      = "label3";
     this.label3.Size      = new System.Drawing.Size(82, 16);
     this.label3.TabIndex  = 22;
     this.label3.Text      = "Mode";
     this.label3.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
     //
     // listSentOrReceived
     //
     this.listSentOrReceived.Location              = new System.Drawing.Point(303, 98);
     this.listSentOrReceived.Name                  = "listSentOrReceived";
     this.listSentOrReceived.Size                  = new System.Drawing.Size(87, 43);
     this.listSentOrReceived.TabIndex              = 25;
     this.listSentOrReceived.SelectedValueChanged += new System.EventHandler(this.listSentOrReceived_SelectedValueChanged);
     //
     // label4
     //
     this.label4.Location  = new System.Drawing.Point(302, 80);
     this.label4.Name      = "label4";
     this.label4.Size      = new System.Drawing.Size(142, 16);
     this.label4.TabIndex  = 24;
     this.label4.Text      = "Sent or Received";
     this.label4.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
     //
     // textNote
     //
     this.textNote.AcceptsReturn  = true;
     this.textNote.Location       = new System.Drawing.Point(82, 217);
     this.textNote.Multiline      = true;
     this.textNote.Name           = "textNote";
     this.textNote.QuickPasteType = OpenDentBusiness.QuickPasteType.CommLog;
     this.textNote.ScrollBars     = System.Windows.Forms.ScrollBars.Vertical;
     this.textNote.Size           = new System.Drawing.Size(557, 209);
     this.textNote.TabIndex       = 27;
     this.textNote.TextChanged   += new System.EventHandler(this.textNote_TextChanged);
     //
     // textPatientName
     //
     this.textPatientName.Location = new System.Drawing.Point(82, 7);
     this.textPatientName.Name     = "textPatientName";
     this.textPatientName.ReadOnly = true;
     this.textPatientName.Size     = new System.Drawing.Size(205, 20);
     this.textPatientName.TabIndex = 30;
     //
     // label5
     //
     this.label5.Location  = new System.Drawing.Point(4, 9);
     this.label5.Name      = "label5";
     this.label5.Size      = new System.Drawing.Size(78, 18);
     this.label5.TabIndex  = 29;
     this.label5.Text      = "Patient";
     this.label5.TextAlign = System.Drawing.ContentAlignment.TopRight;
     //
     // textUser
     //
     this.textUser.Location = new System.Drawing.Point(402, 7);
     this.textUser.Name     = "textUser";
     this.textUser.ReadOnly = true;
     this.textUser.Size     = new System.Drawing.Size(119, 20);
     this.textUser.TabIndex = 103;
     //
     // label16
     //
     this.label16.Location  = new System.Drawing.Point(327, 8);
     this.label16.Name      = "label16";
     this.label16.Size      = new System.Drawing.Size(73, 16);
     this.label16.TabIndex  = 102;
     this.label16.Text      = "User";
     this.label16.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
     //
     // labelCommlogNum
     //
     this.labelCommlogNum.Location  = new System.Drawing.Point(154, 552);
     this.labelCommlogNum.Name      = "labelCommlogNum";
     this.labelCommlogNum.Size      = new System.Drawing.Size(96, 16);
     this.labelCommlogNum.TabIndex  = 104;
     this.labelCommlogNum.Text      = "CommlogNum";
     this.labelCommlogNum.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
     //
     // textCommlogNum
     //
     this.textCommlogNum.Location = new System.Drawing.Point(256, 549);
     this.textCommlogNum.Name     = "textCommlogNum";
     this.textCommlogNum.ReadOnly = true;
     this.textCommlogNum.Size     = new System.Drawing.Size(188, 20);
     this.textCommlogNum.TabIndex = 105;
     //
     // signatureBoxWrapper
     //
     this.signatureBoxWrapper.BackColor         = System.Drawing.SystemColors.ControlDark;
     this.signatureBoxWrapper.LabelText         = null;
     this.signatureBoxWrapper.Location          = new System.Drawing.Point(82, 432);
     this.signatureBoxWrapper.Name              = "signatureBoxWrapper";
     this.signatureBoxWrapper.Size              = new System.Drawing.Size(364, 81);
     this.signatureBoxWrapper.TabIndex          = 106;
     this.signatureBoxWrapper.SignatureChanged += new System.EventHandler(this.signatureBoxWrapper_SignatureChanged);
     //
     // butNow
     //
     this.butNow.AdjustImageLocation = new System.Drawing.Point(0, 0);
     this.butNow.Autosize            = true;
     this.butNow.BtnShape            = OpenDental.UI.enumType.BtnShape.Rectangle;
     this.butNow.BtnStyle            = OpenDental.UI.enumType.XPStyle.Silver;
     this.butNow.CornerRadius        = 4F;
     this.butNow.Location            = new System.Drawing.Point(293, 31);
     this.butNow.Name     = "butNow";
     this.butNow.Size     = new System.Drawing.Size(48, 21);
     this.butNow.TabIndex = 107;
     this.butNow.Text     = "Now";
     this.butNow.Click   += new System.EventHandler(this.butNow_Click);
     //
     // butNowEnd
     //
     this.butNowEnd.AdjustImageLocation = new System.Drawing.Point(0, 0);
     this.butNowEnd.Autosize            = true;
     this.butNowEnd.BtnShape            = OpenDental.UI.enumType.BtnShape.Rectangle;
     this.butNowEnd.BtnStyle            = OpenDental.UI.enumType.XPStyle.Silver;
     this.butNowEnd.CornerRadius        = 4F;
     this.butNowEnd.Location            = new System.Drawing.Point(293, 55);
     this.butNowEnd.Name     = "butNowEnd";
     this.butNowEnd.Size     = new System.Drawing.Size(48, 21);
     this.butNowEnd.TabIndex = 110;
     this.butNowEnd.Text     = "Now";
     this.butNowEnd.Click   += new System.EventHandler(this.butNowEnd_Click);
     //
     // textDateTimeEnd
     //
     this.textDateTimeEnd.Location = new System.Drawing.Point(82, 55);
     this.textDateTimeEnd.Name     = "textDateTimeEnd";
     this.textDateTimeEnd.Size     = new System.Drawing.Size(205, 20);
     this.textDateTimeEnd.TabIndex = 109;
     //
     // labelDateTimeEnd
     //
     this.labelDateTimeEnd.Location  = new System.Drawing.Point(1, 57);
     this.labelDateTimeEnd.Name      = "labelDateTimeEnd";
     this.labelDateTimeEnd.Size      = new System.Drawing.Size(81, 18);
     this.labelDateTimeEnd.TabIndex  = 108;
     this.labelDateTimeEnd.Text      = "End";
     this.labelDateTimeEnd.TextAlign = System.Drawing.ContentAlignment.TopRight;
     //
     // FormCommItem
     //
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
     this.ClientSize        = new System.Drawing.Size(662, 594);
     this.Controls.Add(this.butNowEnd);
     this.Controls.Add(this.textDateTimeEnd);
     this.Controls.Add(this.labelDateTimeEnd);
     this.Controls.Add(this.butNow);
     this.Controls.Add(this.signatureBoxWrapper);
     this.Controls.Add(this.textCommlogNum);
     this.Controls.Add(this.labelCommlogNum);
     this.Controls.Add(this.textUser);
     this.Controls.Add(this.label16);
     this.Controls.Add(this.textPatientName);
     this.Controls.Add(this.label5);
     this.Controls.Add(this.textNote);
     this.Controls.Add(this.listSentOrReceived);
     this.Controls.Add(this.label4);
     this.Controls.Add(this.listMode);
     this.Controls.Add(this.label3);
     this.Controls.Add(this.textDateTime);
     this.Controls.Add(this.listType);
     this.Controls.Add(this.label2);
     this.Controls.Add(this.butDelete);
     this.Controls.Add(this.butCancel);
     this.Controls.Add(this.butOK);
     this.Controls.Add(this.label6);
     this.Controls.Add(this.label1);
     this.Icon          = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.Name          = "FormCommItem";
     this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
     this.Text          = "Communication Item";
     this.Load         += new System.EventHandler(this.FormCommItem_Load);
     this.ResumeLayout(false);
     this.PerformLayout();
 }
        ///<summary>Triggered when any field value changes.  This immediately invalidates signatures.  It also causes fields to grow as needed and deselects other radiobuttons in a group.</summary>
        private void text_TextChanged(object sender, EventArgs e)
        {
            foreach (Control control in panelMain.Controls)
            {
                if (control.GetType() != typeof(OpenDental.UI.SignatureBoxWrapper))
                {
                    continue;
                }
                if (control.Tag == null)
                {
                    continue;
                }
                SheetField field = (SheetField)control.Tag;
                OpenDental.UI.SignatureBoxWrapper sigBox = (OpenDental.UI.SignatureBoxWrapper)control;
                sigBox.SetInvalid();
            }
            if (sender.GetType() == typeof(SheetCheckBox))
            {
                SheetCheckBox checkbox = (SheetCheckBox)sender;
                if (checkbox.Tag == null)
                {
                    return;
                }
                if (!checkbox.IsChecked)                 //if user unchecked a radiobutton, nothing else happens
                {
                    return;
                }
                SheetField fieldThis = (SheetField)checkbox.Tag;
                if (fieldThis.RadioButtonGroup == "" && fieldThis.RadioButtonValue == "")            //if it's a checkbox instead of a radiobutton
                {
                    return;
                }
                foreach (Control control in panelMain.Controls)                 //set some other radiobuttons to be not checked
                {
                    if (control.GetType() != typeof(SheetCheckBox))
                    {
                        continue;
                    }
                    if (control.Tag == null)
                    {
                        continue;
                    }
                    if (control == sender)
                    {
                        continue;
                    }
                    SheetField fieldOther = (SheetField)control.Tag;
                    if (fieldThis.FieldName != fieldOther.FieldName)                   //different radio group
                    {
                        continue;
                    }
                    //If both checkbox field names are set to "misc" then we instead use the RadioButtonGroup as the actual radio button group name.
                    if (fieldThis.FieldName == "misc" && fieldThis.RadioButtonGroup != fieldOther.RadioButtonGroup)
                    {
                        continue;
                    }
                    ((SheetCheckBox)control).IsChecked = false;
                }
                return;
            }
            if (sender.GetType() != typeof(RichTextBox))
            {
                //since CheckBoxes also trigger this event for sig invalid.
                return;
            }
            //everything below here is for growth calc.
            RichTextBox textBox = (RichTextBox)sender;
            //remember where we were
            int cursorPos = textBox.SelectionStart;
            //int boxX=textBox.Location.X;
            //int boxY=textBox.Location.Y;
            //string originalFieldValue=((SheetField)((RichTextBox)control).Tag).FieldValue;
            SheetField fld = (SheetField)textBox.Tag;

            if (fld.GrowthBehavior == GrowthBehaviorEnum.None)
            {
                return;
            }
            fld.FieldValue = textBox.Text;
            Graphics  g         = this.CreateGraphics();
            FontStyle fontstyle = FontStyle.Regular;

            if (fld.FontIsBold)
            {
                fontstyle = FontStyle.Bold;
            }
            Font font  = new Font(fld.FontName, fld.FontSize, fontstyle);
            int  calcH = GraphicsHelper.MeasureStringH(g, fld.FieldValue, font, fld.Width);

            //(int)(g.MeasureString(fld.FieldValue,font,fld.Width).Height * 1.133f);//Seems to need 2 pixels per line of text to prevent hidden text due to scroll.
            calcH += font.Height + 2;        //add one line just in case.
            g.Dispose();
            if (calcH <= fld.Height)         //no growth needed
            {
                return;
            }
            //the field height needs to change, so:
            int amountOfGrowth = calcH - fld.Height;

            fld.Height = calcH;
            FillFieldsFromControls();            //We already changed the value of this field manually,
            //but if the other fields don't get changed, they will erroneously 'reset'.
            if (fld.GrowthBehavior == GrowthBehaviorEnum.DownGlobal)
            {
                SheetUtil.MoveAllDownBelowThis(SheetCur, fld, amountOfGrowth);
            }
            else if (fld.GrowthBehavior == GrowthBehaviorEnum.DownLocal)
            {
                SheetUtil.MoveAllDownWhichIntersect(SheetCur, fld, amountOfGrowth);
            }
            LayoutFields();
            //find the original textbox, and put the cursor back where it belongs
            foreach (Control control in panelMain.Controls)
            {
                if (control.GetType() == typeof(RichTextBox))
                {
                    if ((SheetField)(control.Tag) == fld)
                    {
                        ((RichTextBox)control).Select(cursorPos, 0);
                        ((RichTextBox)control).Focus();
                        //((RichTextBox)control).SelectionStart=cursorPos;
                    }
                }
            }
        }
        private bool TryToSaveData()
        {
            if (!butOK.Enabled)             //if the OK button is not enabled, user does not have permission.
            {
                return(true);
            }
            if (textShowInTerminal.errorProvider1.GetError(textShowInTerminal) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return(false);
            }
            DateTime dateTimeSheet = DateTime.MinValue;

            try{
                dateTimeSheet = DateTime.Parse(textDateTime.Text);
            }
            catch {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return(false);
            }
            SheetCur.DateTimeSheet  = dateTimeSheet;
            SheetCur.Description    = textDescription.Text;
            SheetCur.InternalNote   = textNote.Text;
            SheetCur.ShowInTerminal = PIn.Byte(textShowInTerminal.Text);
            FillFieldsFromControls();            //But SheetNums will still be 0 for a new sheet.
            bool isNew = SheetCur.IsNew;

            if (isNew)
            {
                Sheets.Insert(SheetCur);
            }
            else
            {
                Sheets.Update(SheetCur);
            }
            List <SheetField> drawingList = new List <SheetField>();

            foreach (SheetField fld in SheetCur.SheetFields)
            {
                if (fld.FieldType == SheetFieldType.SigBox)
                {
                    continue;                    //done in a separate step
                }
                if (fld.FieldType == SheetFieldType.Image ||
                    fld.FieldType == SheetFieldType.Rectangle ||
                    fld.FieldType == SheetFieldType.Line)
                {
                    if (!fld.IsNew)
                    {
                        continue;                        //it only saves them when the sheet is first created because user can't edit anyway.
                    }
                }
                fld.SheetNum = SheetCur.SheetNum;              //whether or not isnew
                if (fld.FieldType == SheetFieldType.Drawing)
                {
                    fld.IsNew = true;
                    drawingList.Add(fld);
                }
                else
                {
                    if (fld.IsNew)
                    {
                        SheetFields.Insert(fld);
                    }
                    else
                    {
                        SheetFields.Update(fld);
                    }
                }
            }
            if (drawingsAltered)
            {
                //drawings get saved as a group rather than with the other fields.
                SheetFields.SetDrawings(drawingList, SheetCur.SheetNum);
            }
            if (isNew)
            {
                Sheets.SaveParameters(SheetCur);
            }
            //SigBoxes must come after ALL other types in order for the keyData to be in the right order.
            SheetField field;

            foreach (Control control in panelMain.Controls)
            {
                if (control.GetType() != typeof(OpenDental.UI.SignatureBoxWrapper))
                {
                    continue;
                }
                if (control.Tag == null)
                {
                    continue;
                }
                field = (SheetField)control.Tag;
                OpenDental.UI.SignatureBoxWrapper sigBox = (OpenDental.UI.SignatureBoxWrapper)control;
                if (sigBox.GetSigChanged())
                {
                    //refresh the fields so they are in the correct order
                    SheetFields.GetFieldsAndParameters(SheetCur);
                    bool   sigIsTopaz = sigBox.GetSigIsTopaz();
                    string keyData    = Sheets.GetSignatureKey(SheetCur);
                    string signature  = sigBox.GetSignature(keyData);
                    field.FieldValue = "";
                    if (signature != "")
                    {
                        if (sigIsTopaz)
                        {
                            field.FieldValue += "1";
                        }
                        else
                        {
                            field.FieldValue += "0";
                        }
                        field.FieldValue += signature;
                    }
                }
                field.SheetNum = SheetCur.SheetNum; //whether or not isnew
                if (isNew)                          //is this really testing the proper object?
                {
                    SheetFields.Insert(field);
                }
                else
                {
                    SheetFields.Update(field);
                }
            }
            return(true);
        }
        ///<summary>Runs as the final step of loading the form, and also immediately after fields are moved down due to growth.</summary>
        private void LayoutFields()
        {
            panelMain.Controls.Clear();
            RichTextBox   textbox;          //has to be richtextbox due to MS bug that doesn't show cursor.
            FontStyle     style;
            SheetCheckBox checkbox;

            //first, draw images---------------------------------------------------------------------------------------
            //might change this to only happen once when first loading form:
            if (pictDraw != null)
            {
                if (panelMain.Controls.Contains(pictDraw))
                {
                    Controls.Remove(pictDraw);
                }
                pictDraw = null;
            }
            imgDraw  = null;
            pictDraw = new PictureBox();
            if (SheetCur.IsLandscape)
            {
                imgDraw         = new Bitmap(SheetCur.Height, SheetCur.Width);
                pictDraw.Width  = SheetCur.Height;
                pictDraw.Height = SheetCur.Width;
            }
            else
            {
                imgDraw         = new Bitmap(SheetCur.Width, SheetCur.Height);
                pictDraw.Width  = SheetCur.Width;
                pictDraw.Height = SheetCur.Height;
            }
            pictDraw.Location = new Point(0, 0);
            pictDraw.Image    = (Image)imgDraw.Clone();
            pictDraw.SizeMode = PictureBoxSizeMode.StretchImage;
            panelMain.Controls.Add(pictDraw);
            panelMain.SendToBack();
            Graphics pictGraphics = Graphics.FromImage(imgDraw);

            foreach (SheetField field in SheetCur.SheetFields)
            {
                if (field.FieldType != SheetFieldType.Image)
                {
                    continue;
                }
                string filePathAndName = ODFileUtils.CombinePaths(SheetUtil.GetImagePath(), field.FieldName);
                Image  img             = null;
                if (field.FieldName == "Patient Info.gif")
                {
                    img = Properties.Resources.Patient_Info;
                }
                else if (File.Exists(filePathAndName))
                {
                    img = Image.FromFile(filePathAndName);
                }
                else
                {
                    continue;
                }
                pictGraphics.DrawImage(img, field.XPos, field.YPos, field.Width, field.Height);
            }
            pictGraphics.Dispose();
            //Set mouse events for the pictDraw
            pictDraw.MouseDown += new MouseEventHandler(pictDraw_MouseDown);
            pictDraw.MouseMove += new MouseEventHandler(pictDraw_MouseMove);
            pictDraw.MouseUp   += new MouseEventHandler(pictDraw_MouseUp);
            //draw drawings, rectangles, and lines-----------------------------------------------------------------------
            RefreshPanel();
            //draw textboxes----------------------------------------------------------------------------------------------
            foreach (SheetField field in SheetCur.SheetFields)
            {
                if (field.FieldType != SheetFieldType.InputField &&
                    field.FieldType != SheetFieldType.OutputText &&
                    field.FieldType != SheetFieldType.StaticText)
                {
                    continue;
                }
                textbox             = new RichTextBox();
                textbox.BorderStyle = BorderStyle.None;
                textbox.TabStop     = false;          //Only input fields allow tab stop (set below for input text).
                //textbox.Multiline=true;//due to MS malfunction at 9pt which cuts off the bottom of the text.
                if (field.FieldType == SheetFieldType.OutputText ||
                    field.FieldType == SheetFieldType.StaticText)
                {
                    //textbox.BackColor=Color.White;
                    //textbox.BackColor=Color.FromArgb(245,245,200);
                }
                else if (field.FieldType == SheetFieldType.InputField)
                {
                    textbox.BackColor = Color.FromArgb(245, 245, 200);
                    textbox.TabStop   = (field.TabOrder == 0?false:true);
                    textbox.TabIndex  = field.TabOrder;
                }
                textbox.Location   = new Point(field.XPos, field.YPos);
                textbox.Width      = field.Width;
                textbox.ScrollBars = RichTextBoxScrollBars.None;
                textbox.Text       = field.FieldValue;
                style = FontStyle.Regular;
                if (field.FontIsBold)
                {
                    style = FontStyle.Bold;
                }
                textbox.Font = new Font(field.FontName, field.FontSize, style);
                if (field.Height < textbox.Font.Height + 2)
                {
                    textbox.Multiline = false;
                    //textbox.AcceptsReturn=false;
                }
                else
                {
                    textbox.Multiline = true;
                    //textbox.AcceptsReturn=true;
                }
                textbox.Height = field.Height;
                //textbox.ScrollBars=RichTextBoxScrollBars.None;
                textbox.Tag          = field;
                textbox.TextChanged += new EventHandler(text_TextChanged);
                panelMain.Controls.Add(textbox);
                textbox.BringToFront();
            }
            //draw checkboxes----------------------------------------------------------------------------------------------
            foreach (SheetField field in SheetCur.SheetFields)
            {
                if (field.FieldType != SheetFieldType.CheckBox)
                {
                    continue;
                }
                checkbox = new SheetCheckBox();
                if (field.FieldValue == "X")
                {
                    checkbox.IsChecked = true;
                }
                checkbox.Location = new Point(field.XPos, field.YPos);
                checkbox.Width    = field.Width;
                checkbox.Height   = field.Height;
                checkbox.Tag      = field;
                checkbox.Click   += new EventHandler(text_TextChanged);
                checkbox.TabStop  = (field.TabOrder == 0?false:true);
                checkbox.TabIndex = field.TabOrder;
                panelMain.Controls.Add(checkbox);
                checkbox.BringToFront();
            }
            //draw signature boxes----------------------------------------------------------------------------------------------
            foreach (SheetField field in SheetCur.SheetFields)
            {
                if (field.FieldType != SheetFieldType.SigBox)
                {
                    continue;
                }
                OpenDental.UI.SignatureBoxWrapper sigBox = new OpenDental.UI.SignatureBoxWrapper();
                sigBox.Location = new Point(field.XPos, field.YPos);
                sigBox.Width    = field.Width;
                sigBox.Height   = field.Height;
                if (field.FieldValue.Length > 0)               //a signature is present
                {
                    bool sigIsTopaz = false;
                    if (field.FieldValue[0] == '1')
                    {
                        sigIsTopaz = true;
                    }
                    string signature = "";
                    if (field.FieldValue.Length > 1)
                    {
                        signature = field.FieldValue.Substring(1);
                    }
                    string keyData = Sheets.GetSignatureKey(SheetCur);
                    sigBox.FillSignature(sigIsTopaz, keyData, signature);
                }
                sigBox.Tag      = field;
                sigBox.TabStop  = (field.TabOrder == 0?false:true);
                sigBox.TabIndex = field.TabOrder;
                panelMain.Controls.Add(sigBox);
                sigBox.BringToFront();
            }
        }
		private void InitializeComponent(){
			System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormCommItem));
			this.label1 = new System.Windows.Forms.Label();
			this.label6 = new System.Windows.Forms.Label();
			this.butOK = new OpenDental.UI.Button();
			this.butCancel = new OpenDental.UI.Button();
			this.butDelete = new OpenDental.UI.Button();
			this.label2 = new System.Windows.Forms.Label();
			this.listType = new System.Windows.Forms.ListBox();
			this.textDateTime = new System.Windows.Forms.TextBox();
			this.listMode = new System.Windows.Forms.ListBox();
			this.label3 = new System.Windows.Forms.Label();
			this.listSentOrReceived = new System.Windows.Forms.ListBox();
			this.label4 = new System.Windows.Forms.Label();
			this.textNote = new OpenDental.ODtextBox();
			this.textPatientName = new System.Windows.Forms.TextBox();
			this.label5 = new System.Windows.Forms.Label();
			this.textUser = new System.Windows.Forms.TextBox();
			this.label16 = new System.Windows.Forms.Label();
			this.labelCommlogNum = new System.Windows.Forms.Label();
			this.textCommlogNum = new System.Windows.Forms.TextBox();
			this.signatureBoxWrapper = new OpenDental.UI.SignatureBoxWrapper();
			this.butNow = new OpenDental.UI.Button();
			this.butNowEnd = new OpenDental.UI.Button();
			this.textDateTimeEnd = new System.Windows.Forms.TextBox();
			this.labelDateTimeEnd = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(1,33);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(81,18);
			this.label1.TabIndex = 0;
			this.label1.Text = "Date / Time";
			this.label1.TextAlign = System.Drawing.ContentAlignment.TopRight;
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(80,80);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(82,16);
			this.label6.TabIndex = 5;
			this.label6.Text = "Type";
			this.label6.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
			// 
			// butOK
			// 
			this.butOK.AdjustImageLocation = new System.Drawing.Point(0,0);
			this.butOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
			this.butOK.Autosize = true;
			this.butOK.BtnShape = OpenDental.UI.enumType.BtnShape.Rectangle;
			this.butOK.BtnStyle = OpenDental.UI.enumType.XPStyle.Silver;
			this.butOK.CornerRadius = 4F;
			this.butOK.Location = new System.Drawing.Point(564,515);
			this.butOK.Name = "butOK";
			this.butOK.Size = new System.Drawing.Size(75,25);
			this.butOK.TabIndex = 6;
			this.butOK.Text = "&OK";
			this.butOK.Click += new System.EventHandler(this.butOK_Click);
			// 
			// butCancel
			// 
			this.butCancel.AdjustImageLocation = new System.Drawing.Point(0,0);
			this.butCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
			this.butCancel.Autosize = true;
			this.butCancel.BtnShape = OpenDental.UI.enumType.BtnShape.Rectangle;
			this.butCancel.BtnStyle = OpenDental.UI.enumType.XPStyle.Silver;
			this.butCancel.CornerRadius = 4F;
			this.butCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.butCancel.Location = new System.Drawing.Point(564,548);
			this.butCancel.Name = "butCancel";
			this.butCancel.Size = new System.Drawing.Size(75,25);
			this.butCancel.TabIndex = 7;
			this.butCancel.Text = "&Cancel";
			this.butCancel.Click += new System.EventHandler(this.butCancel_Click);
			// 
			// butDelete
			// 
			this.butDelete.AdjustImageLocation = new System.Drawing.Point(0,0);
			this.butDelete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
			this.butDelete.Autosize = true;
			this.butDelete.BtnShape = OpenDental.UI.enumType.BtnShape.Rectangle;
			this.butDelete.BtnStyle = OpenDental.UI.enumType.XPStyle.Silver;
			this.butDelete.CornerRadius = 4F;
			this.butDelete.Image = global::OpenDental.Properties.Resources.deleteX;
			this.butDelete.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butDelete.Location = new System.Drawing.Point(27,544);
			this.butDelete.Name = "butDelete";
			this.butDelete.Size = new System.Drawing.Size(81,25);
			this.butDelete.TabIndex = 17;
			this.butDelete.Text = "&Delete";
			this.butDelete.Click += new System.EventHandler(this.butDelete_Click);
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(81,197);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(82,16);
			this.label2.TabIndex = 18;
			this.label2.Text = "Note";
			this.label2.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
			// 
			// listType
			// 
			this.listType.Location = new System.Drawing.Point(82,98);
			this.listType.Name = "listType";
			this.listType.Size = new System.Drawing.Size(120,95);
			this.listType.TabIndex = 20;
			this.listType.SelectedIndexChanged += new System.EventHandler(this.listType_SelectedIndexChanged);
			// 
			// textDateTime
			// 
			this.textDateTime.Location = new System.Drawing.Point(82,31);
			this.textDateTime.Name = "textDateTime";
			this.textDateTime.Size = new System.Drawing.Size(205,20);
			this.textDateTime.TabIndex = 21;
			this.textDateTime.TextChanged += new System.EventHandler(this.textDateTime_TextChanged);
			// 
			// listMode
			// 
			this.listMode.Location = new System.Drawing.Point(215,98);
			this.listMode.Name = "listMode";
			this.listMode.Size = new System.Drawing.Size(73,95);
			this.listMode.TabIndex = 23;
			this.listMode.SelectedIndexChanged += new System.EventHandler(this.listMode_SelectedIndexChanged);
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(214,81);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(82,16);
			this.label3.TabIndex = 22;
			this.label3.Text = "Mode";
			this.label3.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
			// 
			// listSentOrReceived
			// 
			this.listSentOrReceived.Location = new System.Drawing.Point(303,98);
			this.listSentOrReceived.Name = "listSentOrReceived";
			this.listSentOrReceived.Size = new System.Drawing.Size(87,43);
			this.listSentOrReceived.TabIndex = 25;
			this.listSentOrReceived.SelectedValueChanged += new System.EventHandler(this.listSentOrReceived_SelectedValueChanged);
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(302,80);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(142,16);
			this.label4.TabIndex = 24;
			this.label4.Text = "Sent or Received";
			this.label4.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
			// 
			// textNote
			// 
			this.textNote.Location = new System.Drawing.Point(82,217);
			this.textNote.Multiline = true;
			this.textNote.Name = "textNote";
			this.textNote.QuickPasteType = OpenDentBusiness.QuickPasteType.CommLog;
			this.textNote.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical;
			this.textNote.Size = new System.Drawing.Size(557,209);
			this.textNote.TabIndex = 27;
			this.textNote.TextChanged += new System.EventHandler(this.textNote_TextChanged);
			// 
			// textPatientName
			// 
			this.textPatientName.Location = new System.Drawing.Point(82,7);
			this.textPatientName.Name = "textPatientName";
			this.textPatientName.ReadOnly = true;
			this.textPatientName.Size = new System.Drawing.Size(205,20);
			this.textPatientName.TabIndex = 30;
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(4,9);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(78,18);
			this.label5.TabIndex = 29;
			this.label5.Text = "Patient";
			this.label5.TextAlign = System.Drawing.ContentAlignment.TopRight;
			// 
			// textUser
			// 
			this.textUser.Location = new System.Drawing.Point(402,7);
			this.textUser.Name = "textUser";
			this.textUser.ReadOnly = true;
			this.textUser.Size = new System.Drawing.Size(119,20);
			this.textUser.TabIndex = 103;
			// 
			// label16
			// 
			this.label16.Location = new System.Drawing.Point(327,8);
			this.label16.Name = "label16";
			this.label16.Size = new System.Drawing.Size(73,16);
			this.label16.TabIndex = 102;
			this.label16.Text = "User";
			this.label16.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// labelCommlogNum
			// 
			this.labelCommlogNum.Location = new System.Drawing.Point(154,552);
			this.labelCommlogNum.Name = "labelCommlogNum";
			this.labelCommlogNum.Size = new System.Drawing.Size(96,16);
			this.labelCommlogNum.TabIndex = 104;
			this.labelCommlogNum.Text = "CommlogNum";
			this.labelCommlogNum.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// textCommlogNum
			// 
			this.textCommlogNum.Location = new System.Drawing.Point(256,549);
			this.textCommlogNum.Name = "textCommlogNum";
			this.textCommlogNum.ReadOnly = true;
			this.textCommlogNum.Size = new System.Drawing.Size(188,20);
			this.textCommlogNum.TabIndex = 105;
			// 
			// signatureBoxWrapper
			// 
			this.signatureBoxWrapper.BackColor = System.Drawing.SystemColors.ControlDark;
			this.signatureBoxWrapper.LabelText = null;
			this.signatureBoxWrapper.Location = new System.Drawing.Point(82,432);
			this.signatureBoxWrapper.Name = "signatureBoxWrapper";
			this.signatureBoxWrapper.Size = new System.Drawing.Size(364,81);
			this.signatureBoxWrapper.TabIndex = 106;
			this.signatureBoxWrapper.SignatureChanged += new System.EventHandler(this.signatureBoxWrapper_SignatureChanged);
			// 
			// butNow
			// 
			this.butNow.AdjustImageLocation = new System.Drawing.Point(0,0);
			this.butNow.Autosize = true;
			this.butNow.BtnShape = OpenDental.UI.enumType.BtnShape.Rectangle;
			this.butNow.BtnStyle = OpenDental.UI.enumType.XPStyle.Silver;
			this.butNow.CornerRadius = 4F;
			this.butNow.Location = new System.Drawing.Point(293,31);
			this.butNow.Name = "butNow";
			this.butNow.Size = new System.Drawing.Size(48,21);
			this.butNow.TabIndex = 107;
			this.butNow.Text = "Now";
			this.butNow.Click += new System.EventHandler(this.butNow_Click);
			// 
			// butNowEnd
			// 
			this.butNowEnd.AdjustImageLocation = new System.Drawing.Point(0,0);
			this.butNowEnd.Autosize = true;
			this.butNowEnd.BtnShape = OpenDental.UI.enumType.BtnShape.Rectangle;
			this.butNowEnd.BtnStyle = OpenDental.UI.enumType.XPStyle.Silver;
			this.butNowEnd.CornerRadius = 4F;
			this.butNowEnd.Location = new System.Drawing.Point(293,55);
			this.butNowEnd.Name = "butNowEnd";
			this.butNowEnd.Size = new System.Drawing.Size(48,21);
			this.butNowEnd.TabIndex = 110;
			this.butNowEnd.Text = "Now";
			this.butNowEnd.Click += new System.EventHandler(this.butNowEnd_Click);
			// 
			// textDateTimeEnd
			// 
			this.textDateTimeEnd.Location = new System.Drawing.Point(82,55);
			this.textDateTimeEnd.Name = "textDateTimeEnd";
			this.textDateTimeEnd.Size = new System.Drawing.Size(205,20);
			this.textDateTimeEnd.TabIndex = 109;
			// 
			// labelDateTimeEnd
			// 
			this.labelDateTimeEnd.Location = new System.Drawing.Point(1,57);
			this.labelDateTimeEnd.Name = "labelDateTimeEnd";
			this.labelDateTimeEnd.Size = new System.Drawing.Size(81,18);
			this.labelDateTimeEnd.TabIndex = 108;
			this.labelDateTimeEnd.Text = "End";
			this.labelDateTimeEnd.TextAlign = System.Drawing.ContentAlignment.TopRight;
			// 
			// FormCommItem
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5,13);
			this.ClientSize = new System.Drawing.Size(662,594);
			this.Controls.Add(this.butNowEnd);
			this.Controls.Add(this.textDateTimeEnd);
			this.Controls.Add(this.labelDateTimeEnd);
			this.Controls.Add(this.butNow);
			this.Controls.Add(this.signatureBoxWrapper);
			this.Controls.Add(this.textCommlogNum);
			this.Controls.Add(this.labelCommlogNum);
			this.Controls.Add(this.textUser);
			this.Controls.Add(this.label16);
			this.Controls.Add(this.textPatientName);
			this.Controls.Add(this.label5);
			this.Controls.Add(this.textNote);
			this.Controls.Add(this.listSentOrReceived);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.listMode);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.textDateTime);
			this.Controls.Add(this.listType);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.butDelete);
			this.Controls.Add(this.butCancel);
			this.Controls.Add(this.butOK);
			this.Controls.Add(this.label6);
			this.Controls.Add(this.label1);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Name = "FormCommItem";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "Communication Item";
			this.Load += new System.EventHandler(this.FormCommItem_Load);
			this.ResumeLayout(false);
			this.PerformLayout();

		}
		///<summary>Runs as the final step of loading the form, and also immediately after fields are moved down due to growth.</summary>
		private void LayoutFields() {
			panelMain.Controls.Clear();
			RichTextBox textbox;//has to be richtextbox due to MS bug that doesn't show cursor.
			FontStyle style;
			SheetCheckBox checkbox;
			//first, draw images---------------------------------------------------------------------------------------
			//might change this to only happen once when first loading form:
			if(pictDraw!=null) {
				if(panelMain.Controls.Contains(pictDraw)) {
					Controls.Remove(pictDraw);
				}
				pictDraw=null;
			}
			imgDraw=null;
			pictDraw=new PictureBox();
			if(SheetCur.IsLandscape) {
				imgDraw=new Bitmap(SheetCur.Height,SheetCur.Width);
				pictDraw.Width=SheetCur.Height;
				pictDraw.Height=SheetCur.Width;
			}
			else {
				imgDraw=new Bitmap(SheetCur.Width,SheetCur.Height);
				pictDraw.Width=SheetCur.Width;
				pictDraw.Height=SheetCur.Height;
			}
			pictDraw.Location=new Point(0,0);
			pictDraw.Image=(Image)imgDraw.Clone();
			pictDraw.SizeMode=PictureBoxSizeMode.StretchImage;
			panelMain.Controls.Add(pictDraw);
			panelMain.SendToBack();
			Graphics pictGraphics=Graphics.FromImage(imgDraw);
			foreach(SheetField field in SheetCur.SheetFields) {
				if(field.FieldType!=SheetFieldType.Image) {
					continue;
				}
				string filePathAndName=ODFileUtils.CombinePaths(SheetUtil.GetImagePath(),field.FieldName);
				Image img=null;
				if(field.FieldName=="Patient Info.gif") {
					img=Properties.Resources.Patient_Info;
				}
				else if(File.Exists(filePathAndName)) {
					img=Image.FromFile(filePathAndName);
				}
				else {
					continue;
				}
				pictGraphics.DrawImage(img,field.XPos,field.YPos,field.Width,field.Height);
			}
			pictGraphics.Dispose();
			//Set mouse events for the pictDraw
			pictDraw.MouseDown+=new MouseEventHandler(pictDraw_MouseDown);
			pictDraw.MouseMove+=new MouseEventHandler(pictDraw_MouseMove);
			pictDraw.MouseUp+=new MouseEventHandler(pictDraw_MouseUp);
			//draw drawings, rectangles, and lines-----------------------------------------------------------------------
			RefreshPanel();
			//draw textboxes----------------------------------------------------------------------------------------------
			foreach(SheetField field in SheetCur.SheetFields) {
				if(field.FieldType!=SheetFieldType.InputField
					&& field.FieldType!=SheetFieldType.OutputText
					&& field.FieldType!=SheetFieldType.StaticText) {
					continue;
				}
				textbox=new RichTextBox();
				textbox.BorderStyle=BorderStyle.None;
				textbox.TabStop=false;//Only input fields allow tab stop (set below for input text).
				//textbox.Multiline=true;//due to MS malfunction at 9pt which cuts off the bottom of the text.
				if(field.FieldType==SheetFieldType.OutputText
					|| field.FieldType==SheetFieldType.StaticText) {
					//textbox.BackColor=Color.White;
					//textbox.BackColor=Color.FromArgb(245,245,200);
				}
				else if(field.FieldType==SheetFieldType.InputField) {
					textbox.BackColor=Color.FromArgb(245,245,200);
					textbox.TabStop=(field.TabOrder==0?false:true);
					textbox.TabIndex=field.TabOrder;
				}
				textbox.Location=new Point(field.XPos,field.YPos);
				textbox.Width=field.Width;
				textbox.ScrollBars=RichTextBoxScrollBars.None;
				textbox.Text=field.FieldValue;
				style=FontStyle.Regular;
				if(field.FontIsBold) {
					style=FontStyle.Bold;
				}
				textbox.Font=new Font(field.FontName,field.FontSize,style);
				if(field.Height<textbox.Font.Height+2) {
					textbox.Multiline=false;
					//textbox.AcceptsReturn=false;
				}
				else {
					textbox.Multiline=true;
					//textbox.AcceptsReturn=true;
				}
				textbox.Height=field.Height;
				//textbox.ScrollBars=RichTextBoxScrollBars.None;
				textbox.Tag=field;
				textbox.TextChanged+=new EventHandler(text_TextChanged);
				panelMain.Controls.Add(textbox);
				textbox.BringToFront();
			}
			//draw checkboxes----------------------------------------------------------------------------------------------
			foreach(SheetField field in SheetCur.SheetFields) {
				if(field.FieldType!=SheetFieldType.CheckBox) {
					continue;
				}
				checkbox=new SheetCheckBox();
				if(field.FieldValue=="X") {
					checkbox.IsChecked=true;
				}
				checkbox.Location=new Point(field.XPos,field.YPos);
				checkbox.Width=field.Width;
				checkbox.Height=field.Height;
				checkbox.Tag=field;
				checkbox.Click+=new EventHandler(text_TextChanged);
				checkbox.TabStop=(field.TabOrder==0?false:true);
				checkbox.TabIndex=field.TabOrder;
				panelMain.Controls.Add(checkbox);
				checkbox.BringToFront();
			}
			//draw signature boxes----------------------------------------------------------------------------------------------
			foreach(SheetField field in SheetCur.SheetFields) {
				if(field.FieldType!=SheetFieldType.SigBox) {
					continue;
				}
				OpenDental.UI.SignatureBoxWrapper sigBox=new OpenDental.UI.SignatureBoxWrapper();
				sigBox.Location=new Point(field.XPos,field.YPos);
				sigBox.Width=field.Width;
				sigBox.Height=field.Height;
				if(field.FieldValue.Length>0) {//a signature is present
					bool sigIsTopaz=false;
					if(field.FieldValue[0]=='1') {
						sigIsTopaz=true;
					}
					string signature="";
					if(field.FieldValue.Length>1) {
						signature=field.FieldValue.Substring(1);
					}
					string keyData=Sheets.GetSignatureKey(SheetCur);
					sigBox.FillSignature(sigIsTopaz,keyData,signature);
				}
				sigBox.Tag=field;
				sigBox.TabStop=(field.TabOrder==0?false:true);
				sigBox.TabIndex=field.TabOrder;
				panelMain.Controls.Add(sigBox);
				sigBox.BringToFront();
			}
		}
Beispiel #8
0
		///<summary>Runs as the final step of loading the form, and also immediately after fields are moved down due to growth.</summary>
		private void LayoutFields() {
			List<SheetField> fieldsSorted=new List<SheetField>();
			fieldsSorted.AddRange(SheetCur.SheetFields);//Creates a sortable list that will not change sort order of the original list.
			fieldsSorted.Sort(SheetFields.SortDrawingOrderLayers);
			panelMain.Controls.Clear();
			RichTextBox textbox;//has to be richtextbox due to MS bug that doesn't show cursor.
			FontStyle style;
			SheetCheckBox checkbox;
			//first, draw images---------------------------------------------------------------------------------------
			//might change this to only happen once when first loading form:
			if(pictDraw!=null) {
				if(panelMain.Controls.Contains(pictDraw)) {
					Controls.Remove(pictDraw);
				}
				pictDraw=null;
			}
			imgDraw=null;
			pictDraw=new PictureBox();
			if(SheetCur.IsLandscape) {
				//imgDraw=new Bitmap(SheetCur.Height,SheetCur.Width);
				pictDraw.Width=SheetCur.Height;
				pictDraw.Height=SheetCur.Width;
			}
			else {
				//imgDraw=new Bitmap(SheetCur.Width,SheetCur.Height);
				pictDraw.Width=SheetCur.Width;
				pictDraw.Height=SheetCur.Height;
			}
			if(Sheets.CalculatePageCount(SheetCur,_printMargin)==1){
				pictDraw.Height=SheetCur.HeightPage;//+10 for HScrollBar
			}
			else {
				int pageCount=0;
				pictDraw.Height=SheetPrinting.bottomCurPage(SheetCur.HeightLastField,SheetCur,out pageCount);
			}
			//imgDraw.Dispose();//dispose of old image before setting it to a new image.
			imgDraw=new Bitmap(pictDraw.Width,pictDraw.Height);
			pictDraw.Location=new Point(0,0);
			pictDraw.Image=(Image)imgDraw.Clone();
			pictDraw.SizeMode=PictureBoxSizeMode.StretchImage;
			panelMain.Controls.Add(pictDraw);
			panelMain.SendToBack();
			Graphics pictGraphics=Graphics.FromImage(imgDraw);
			SheetPrinting.DrawImages(SheetCur,pictGraphics,true);
			pictGraphics.Dispose();
			//Set mouse events for the pictDraw
			pictDraw.MouseDown+=new MouseEventHandler(pictDraw_MouseDown);
			pictDraw.MouseMove+=new MouseEventHandler(pictDraw_MouseMove);
			pictDraw.MouseUp+=new MouseEventHandler(pictDraw_MouseUp);
			//draw drawings, rectangles, and lines-----------------------------------------------------------------------
			RefreshPanel();
			//draw textboxes----------------------------------------------------------------------------------------------
			foreach(SheetField field in SheetCur.SheetFields) {
				if(field.FieldType!=SheetFieldType.InputField
					&& field.FieldType!=SheetFieldType.OutputText
					&& field.FieldType!=SheetFieldType.StaticText) {
					continue;
				}
				textbox=new RichTextBox();
				textbox.BorderStyle=BorderStyle.None;
				textbox.TabStop=false;//Only input fields allow tab stop (set below for input text).
				//textbox.Multiline=true;//due to MS malfunction at 9pt which cuts off the bottom of the text.
				if(field.FieldType==SheetFieldType.OutputText
					|| field.FieldType==SheetFieldType.StaticText) {
					//textbox.BackColor=Color.White;
					//textbox.BackColor=Color.FromArgb(245,245,200);
				}
				else if(field.FieldType==SheetFieldType.InputField) {
					textbox.BackColor=Color.FromArgb(245,245,200);
					textbox.TabStop=(field.TabOrder==0?false:true);
					textbox.TabIndex=field.TabOrder;
				}
				textbox.Location=new Point(field.XPos,field.YPos);
				textbox.Width=field.Width;
				textbox.ScrollBars=RichTextBoxScrollBars.None;
				if(field.ItemColor!=Color.FromArgb(0)){
					textbox.ForeColor=field.ItemColor;
				}
				//textbox.Text=field.FieldValue;
				textbox.SelectionAlignment=field.TextAlign;
				textbox.SelectedText=field.FieldValue;
				style=FontStyle.Regular;
				if(field.FontIsBold) {
					style=FontStyle.Bold;
				}
				textbox.Font=new Font(field.FontName,field.FontSize,style);
				if(field.Height<textbox.Font.Height+2) {
					textbox.Multiline=false;
					//textbox.AcceptsReturn=false;
				}
				else {
					textbox.Multiline=true;
					//textbox.AcceptsReturn=true;
				}
				textbox.Height=field.Height;
				//textbox.ScrollBars=RichTextBoxScrollBars.None;
				textbox.Tag=field;
				textbox.TextChanged+=new EventHandler(text_TextChanged);
				panelMain.Controls.Add(textbox);
				textbox.BringToFront();
			}
			//draw checkboxes----------------------------------------------------------------------------------------------
			foreach(SheetField field in SheetCur.SheetFields) {
				if(field.FieldType!=SheetFieldType.CheckBox) {
					continue;
				}
				checkbox=new SheetCheckBox();
				if(field.FieldValue=="X") {
					checkbox.IsChecked=true;
				}
				checkbox.Location=new Point(field.XPos,field.YPos);
				checkbox.Width=field.Width;
				checkbox.Height=field.Height;
				checkbox.Tag=field;
				checkbox.MouseUp+=new MouseEventHandler(checkbox_MouseUp);
				checkbox.TabStop=(field.TabOrder==0?false:true);
				checkbox.TabIndex=field.TabOrder;
				panelMain.Controls.Add(checkbox);
				checkbox.BringToFront();
			}
			//draw signature boxes----------------------------------------------------------------------------------------------
			foreach(SheetField field in SheetCur.SheetFields) {
				if(field.FieldType!=SheetFieldType.SigBox) {
					continue;
				}
				OpenDental.UI.SignatureBoxWrapper sigBox=new OpenDental.UI.SignatureBoxWrapper();
				sigBox.Location=new Point(field.XPos,field.YPos);
				sigBox.Width=field.Width;
				sigBox.Height=field.Height;
				if(field.FieldValue.Length>0) {//a signature is present
					bool sigIsTopaz=false;
					if(field.FieldValue[0]=='1') {
						sigIsTopaz=true;
					}
					string signature="";
					if(field.FieldValue.Length>1) {
						signature=field.FieldValue.Substring(1);
					}
					string keyData=Sheets.GetSignatureKey(SheetCur);
					sigBox.FillSignature(sigIsTopaz,keyData,signature);
				}
				sigBox.Tag=field;
				sigBox.TabStop=(field.TabOrder==0?false:true);
				sigBox.TabIndex=field.TabOrder;
				panelMain.Controls.Add(sigBox);
				sigBox.BringToFront();
			}
		}
Beispiel #9
0
        public void SignatureBoxWrapper_FillSignature_GetNumberOfTabletPoints()
        {
            string     suffix          = "52";
            Patient    pat             = PatientT.CreatePatient(suffix);
            List <int> listFailedTests = new List <int>();

            OpenDental.UI.SignatureBoxWrapper sbw = new OpenDental.UI.SignatureBoxWrapper();
            //1: Normal signature with \r\n
            sbw.FillSignature(false, "15.4 Normal\r\n15.4 Normal\r\n15.4 Normal3", "AgsiXrWoTDupa0Nz19AoZ/HpRGAW+oJIvoAWqvJFFCPiLbBMa14AcopOYoS1OhIg0v5jQI9epUODrXtLElhyngtKMcnnvWZ9CqD3Jzolw7wik38VmpiWUSJiKUYMCzXEGQdkGnv6Sfa20I7XlYzlRhgRFizd5CuV6b/iuReK9PYj21gG0MxWq8r0f01BxkxSxrGO7kM0xnScd2MXcPx2y0sdXpo4fGOcFf9HPONca0YR3ihhloTNw9uPyvtSXUE0jjHSuE/XQBs/6za6T7FwnlFGlvJAq8AxvPKd2sPF7Li+ypa5Tb9mHhye6neMzsyoZHflDp9r7FipFrMJOiDvDTfThg4gU6KR5sTObNVBjB+uZClBJSRkNux9Q49nTUQlBnLEBPZreIkwl68bi6CW8o2cz4tJTQXUcCmzH4yxvo6DzAXSU4swPK67Lo9l0i+ZbeyicSmi77H+OVJb7w9e06PodWWYr9HpnuwwEvGtSUHyH3YatWF1/nXAWaNlwlsGSu0TzXVpGzCANzw/CmOtbYnNqyRvKTHY5pggs4Y/OFWtyMklSezdIpP/VPfLhTLcEuF15ybxi7z9GhjiSgu23T43LKu5D2E2g5L8AMkzgdk5oEgfMxPT1wxL4FYSXeGCHySNq5RXJvVw9sixv340hr4ht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o1o0WIStxTfBvk8iMuDqj0mAd17XBjGg/Qn2NyzjA7CLvTs+ocAYzvqAG1TfOHBaqD1K6d5bqzxRWTrjxVrMQU/L7988G4OIY8D63XQ02XtRcVWv46alUJMaETMg18ZjqGs70IxvrVVErxJMhXCQss7tHXp84wRGCNF5H+kwsUdQrl9ecHEy5cHHBR5iHz49m9RjM23VlWlhVgCXZWdiS9NRVsofv4LfU+YfquMkeBhAHoUG9rtLYBWD5oBpRqRtXm4G4M+S0HhFcht43YFKfBP1Jf+C6jPD7srPuyEoNXQBo/GGThl2+ER+a5bwMwwemudJktcl5wzzp9w3z3yQIiqsz+jAW+ARu5976JmHryI+OcN03AwWG//zfGUppxARR9Sy1QI/+kH22ypfwmhy3H++IoM5w7dS2FLbYYlzUQrx3SHXcD5uG0htbBwVvmzR0GiN7cZhejffH7VMG9HlG1nxbLJA4hwUeYWXo+jwNTORoDSLPRj/55PAiA6xiLEzcpMWVF367RvTw34bgJHHw==");
            if (sbw.GetNumberOfTabletPoints(false) == 0)
            {
                listFailedTests.Add(1);
            }
            //2: Normal signature, middle tier with \r\n
            sbw.FillSignature(false, "15.4 Normal MiddleTier\r\n15.4 Normal MiddleTier\r\n15.4 Normal MiddleTier3", "zlxsF/nXjLiICUGUQUQr8pm7l2fpLp+ls2xRhA5TWsR2KdEj1HMVC7r2DbyzyJT5HVPPSQv0TiulXk1yPw6p5OymPGtSgmwTdIHVGOpfwbd8f3jqXucncmwFsjjOu+EYRzy5DjsS9388NwxfHw6dg6BCPCQEHd9qbtIgWLuPEvB+foaQ97RLFmTqJojPxQac9emcymC7Y1eUQJ4AvA8NXHfuAnklJdpETC6Dds5XoiVuJNpc/eTz74JPhcxKLhJUsk4wHImsbSP5bDywEuN8GbDuUBdGxz9AwZ6ppAHdfd7nAy1j2MMXVOfE14zDWET3GJJa1nvWCDf0mLO6liqjByWeIIBJSNORaG9wk6FoMPQkytvOWXyKcpFPVfeHxku5HjUUbzJrrk4ctYZVpiCvDS+anhVjCta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fcPPnynoMnzBI");
            if (sbw.GetNumberOfTabletPoints(false) == 0)
            {
                listFailedTests.Add(2);
            }
            //3: Topaz signature with \r\n
            sbw.FillSignature(true, "15.4 Topaz\r\n15.4 Topaz\r\n15.4 Topaz3", "FFFFFFFFED1D7C6A37000000040000003E6A277C10525BF095781A4505E1A9814FB05B0B7930F49EDDE09B95B6743B4EF11B47C4E7DF151AA5C031BC4487067C897FA35C3E9A5FD9DAF32CEC3F9479C6CDB793CC5202BCE8714DDADDE228986E39440B31B76E940496E9F63EFFED1C3F896DE2B7EA5129CA08C9B22066C48CF27FEEBE00E107A3901498ABE9FA9F301FB028748CE0BBE01CC2A4628E94AF9854FFA4A15D60F3C488698D5F2F14379F99D764B27013B4FFB18336AA20B132DE18A85060544F5F92F4A259803FC2CA9384DF30B784703C80868C6F1D2EADCF55345F0380CC9A5F0C757594FF128F66E6F7BC6D655FF2592935EDB3CA52C642FC9C4A64B8623F43015F3810CC51A580081C50DC9FF1ADDFEF3FBD06E0C9E0DD47F1B87E1061C760099E6EA055A1533C6134700527723C62DDFD8B267D6CECC6399CCA149BA5B234B0A5EA44DF3223941DF7AFF6D4B5551366F71103B7B48EE7D2B6122B9495654DE257478FBED6680F4DE2A0C91EFFE5E95E785E7ADF0AED06BC384B69915DC4BA281980F9684AF119FB0B242EF4CCC82E3AE733C05F08933DD71E8D54F403C6C8A1A48D54F403C6C8A1A48D54F403C6C8A1A48D54F403C6C8A1A48D54F403C6C8A1A4");
            if (sbw.GetNumberOfTabletPoints(true) == 0)
            {
                listFailedTests.Add(3);
            }
            //4: Topaz signature, middle tier with \r\n
            sbw.FillSignature(true, "15.4 Topaz MiddleTier\r\n15.4 Topaz MiddleTier\r\n15.4 Topaz MiddleTier3", "FFFFFFFFAD1F4B693A00000000000000DEB4BBA8050C7F6E66DD8CC844BE7EEC6F3102C5E6B6F4977E482CE5F5E82ADCEEFFC822D77A6AB9529E824C363E0822ED65EBC841D98F55C7FF5CF269D8CBEF37B4E68BE56095D172699A8A58D8F71E366D6F65DA865F186454B4C9219D159147294001EBE30DF244B970B7B015C0FAEBC74BDDA61551412F6761D295D5C754A58B2B94781E067E7FEC2FEE0AAD6F0463D2C48F1EF21AD068CFE314CE2738949A01A19D29564D16A8C3D1CE462FEA754AD769CAFDEC057F9CF7AEB8BC68CDBDE965B83D75226294C44B14F4391BC07C32D908F409247E80C9C4C9DFE27C123459651FB5240C922841254DD77107DB1E6A5A525AFA10947BB1488D058C88E127DD6790A3F30A5013D9643AFDB03762875EA5D7D336EE6076B4AB7BD089872BD687300CF16AA32DC9606A91CD726E0244D91B760EA76C904B27180D271CCE952B80C4C65E39EBD2E41B84B7A7309AB3D953E673E788E063F624568F8C936B440254D832245B2DF3730066B0D32CBBD779AF1299037B3A14C72376D13B3B65E87D078FFB0FB98E2F53E6E02939A697AFAF585853EDB281D283765A15B1CE10060C4DC8A32D40884F8C4F5DEA3FA31345073F7C73434A9AE2913F7C73434A9AE2913F7C73434A9AE2913F7C73434A9AE291");
            if (sbw.GetNumberOfTabletPoints(true) == 0)
            {
                listFailedTests.Add(4);
            }
            //5: Normal signature with \n
            sbw.FillSignature(false, "15.4 Normal\n15.4 Normal\n15.4 Normal3", "AgsiXrWoTDupa0Nz19AoZ/HpRGAW+oJIvoAWqvJFFCPiLbBMa14AcopOYoS1OhIg0v5jQI9epUODrXtLElhyngtKMcnnvWZ9CqD3Jzolw7wik38VmpiWUSJiKUYMCzXEGQdkGnv6Sfa20I7XlYzlRhgRFizd5CuV6b/iuReK9PYj21gG0MxWq8r0f01BxkxSxrGO7kM0xnScd2MXcPx2y0sdXpo4fGOcFf9HPONca0YR3ihhloTNw9uPyvtSXUE0jjHSuE/XQBs/6za6T7FwnlFGlvJAq8AxvPKd2sPF7Li+ypa5Tb9mHhye6neMzsyoZHflDp9r7FipFrMJOiDvDTfThg4gU6KR5sTObNVBjB+uZClBJSRkNux9Q49nTUQlBnLEBPZreIkwl68bi6CW8o2cz4tJTQXUcCmzH4yxvo6DzAXSU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z41JVv4IObAl8yOPdap8igVMzaWQGpcdacAbU+Bge0gLT0n/fripC+WlNBQQ7XVfvqdu+FECtfX7piaE6FTcKlP8S6Rz3mXdMM9NyXQLM8TJ84sHHZh3CXsHJKARoc+Z1ekDzRr7Eg9CJqFDvMFYvuLbCp+YaWQWh18tSXbUGm83qFYDCz/GfZWfQOZBvRX9syyO8Nu42hcwsGaLrKYiN+dUvRENr/naBmNo1o0WIStxTfBvk8iMuDqj0mAd17XBjGg/Qn2NyzjA7CLvTs+ocAYzvqAG1TfOHBaqD1K6d5bqzxRWTrjxVrMQU/L7988G4OIY8D63XQ02XtRcVWv46alUJMaETMg18ZjqGs70IxvrVVErxJMhXCQss7tHXp84wRGCNF5H+kwsUdQrl9ecHEy5cHHBR5iHz49m9RjM23VlWlhVgCXZWdiS9NRVsofv4LfU+YfquMkeBhAHoUG9rtLYBWD5oBpRqRtXm4G4M+S0HhFcht43YFKfBP1Jf+C6jPD7srPuyEoNXQBo/GGThl2+ER+a5bwMwwemudJktcl5wzzp9w3z3yQIiqsz+jAW+ARu5976JmHryI+OcN03AwWG//zfGUppxARR9Sy1QI/+kH22ypfwmhy3H++IoM5w7dS2FLbYYlzUQrx3SHXcD5uG0htbBwVvmzR0GiN7cZhejffH7VMG9HlG1nxbLJA4hwUeYWXo+jwNTORoDSLPRj/55PAiA6xiLEzcpMWVF367RvTw34bgJHHw==");
            if (sbw.GetNumberOfTabletPoints(false) == 0)
            {
                listFailedTests.Add(5);
            }
            //6: Normal signature, middle tier with \n
            sbw.FillSignature(false, "15.4 Normal MiddleTier\n15.4 Normal MiddleTier\n15.4 Normal MiddleTier3", "zlxsF/nXjLiICUGUQUQr8pm7l2fpLp+ls2xRhA5TWsR2KdEj1HMVC7r2DbyzyJT5HVPPSQv0TiulXk1yPw6p5OymPGtSgmwTdIHVGOpfwbd8f3jqXucncmwFsjjOu+EYRzy5DjsS9388NwxfHw6dg6BCPCQEHd9qbtIgWLuPEvB+foaQ97RLFmTqJojPxQac9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BsnKjhFT58EAkrVlXMgp4Pv7t0Q9pKs8FdU/gjdfoJlq8JT3qvnjIO92ENsDN7aRhsk/QoNTr5mJiOV7UJkd9n3ZexFtojDXZCjHKADbsNaYd8aOJcRBP/tIaMMssseFaPhyqk24s65VBIWHCC3p31khnqKz5FeWRaraWlCDhMk7fV9NYcY/NvZFFUEs3Ze6DfJvzgTlTOaKVeiuTvj9mRBLS+fcPPnynoMnzBI");
            if (sbw.GetNumberOfTabletPoints(false) == 0)
            {
                listFailedTests.Add(6);
            }
            //7: Topaz signature with \n
            sbw.FillSignature(true, "15.4 Topaz\n15.4 Topaz\n15.4 Topaz3", "FFFFFFFFED1D7C6A37000000040000003E6A277C10525BF095781A4505E1A9814FB05B0B7930F49EDDE09B95B6743B4EF11B47C4E7DF151AA5C031BC4487067C897FA35C3E9A5FD9DAF32CEC3F9479C6CDB793CC5202BCE8714DDADDE228986E39440B31B76E940496E9F63EFFED1C3F896DE2B7EA5129CA08C9B22066C48CF27FEEBE00E107A3901498ABE9FA9F301FB028748CE0BBE01CC2A4628E94AF9854FFA4A15D60F3C488698D5F2F14379F99D764B27013B4FFB18336AA20B132DE18A85060544F5F92F4A259803FC2CA9384DF30B784703C80868C6F1D2EADCF55345F0380CC9A5F0C757594FF128F66E6F7BC6D655FF2592935EDB3CA52C642FC9C4A64B8623F43015F3810CC51A580081C50DC9FF1ADDFEF3FBD06E0C9E0DD47F1B87E1061C760099E6EA055A1533C6134700527723C62DDFD8B267D6CECC6399CCA149BA5B234B0A5EA44DF3223941DF7AFF6D4B5551366F71103B7B48EE7D2B6122B9495654DE257478FBED6680F4DE2A0C91EFFE5E95E785E7ADF0AED06BC384B69915DC4BA281980F9684AF119FB0B242EF4CCC82E3AE733C05F08933DD71E8D54F403C6C8A1A48D54F403C6C8A1A48D54F403C6C8A1A48D54F403C6C8A1A48D54F403C6C8A1A4");
            if (sbw.GetNumberOfTabletPoints(true) == 0)
            {
                listFailedTests.Add(7);
            }
            //8: Topaz signature, middle tier with \n
            sbw.FillSignature(true, "15.4 Topaz MiddleTier\n15.4 Topaz MiddleTier\n15.4 Topaz MiddleTier3", "FFFFFFFFAD1F4B693A00000000000000DEB4BBA8050C7F6E66DD8CC844BE7EEC6F3102C5E6B6F4977E482CE5F5E82ADCEEFFC822D77A6AB9529E824C363E0822ED65EBC841D98F55C7FF5CF269D8CBEF37B4E68BE56095D172699A8A58D8F71E366D6F65DA865F186454B4C9219D159147294001EBE30DF244B970B7B015C0FAEBC74BDDA61551412F6761D295D5C754A58B2B94781E067E7FEC2FEE0AAD6F0463D2C48F1EF21AD068CFE314CE2738949A01A19D29564D16A8C3D1CE462FEA754AD769CAFDEC057F9CF7AEB8BC68CDBDE965B83D75226294C44B14F4391BC07C32D908F409247E80C9C4C9DFE27C123459651FB5240C922841254DD77107DB1E6A5A525AFA10947BB1488D058C88E127DD6790A3F30A5013D9643AFDB03762875EA5D7D336EE6076B4AB7BD089872BD687300CF16AA32DC9606A91CD726E0244D91B760EA76C904B27180D271CCE952B80C4C65E39EBD2E41B84B7A7309AB3D953E673E788E063F624568F8C936B440254D832245B2DF3730066B0D32CBBD779AF1299037B3A14C72376D13B3B65E87D078FFB0FB98E2F53E6E02939A697AFAF585853EDB281D283765A15B1CE10060C4DC8A32D40884F8C4F5DEA3FA31345073F7C73434A9AE2913F7C73434A9AE2913F7C73434A9AE2913F7C73434A9AE291");
            if (sbw.GetNumberOfTabletPoints(true) == 0)
            {
                listFailedTests.Add(8);
            }
            //9:  Invalid Signature (wrong key)
            sbw.FillSignature(false, "15.4 Normal\r\n15.4 Normal\r\n15.4 Normal4", "AgsiXrWoTDupa0Nz19AoZ/HpRGAW+oJIvoAWqvJFFCPiLbBMa14AcopOYoS1OhIg0v5jQI9epUODrXtLElhyngtKMcnnvWZ9CqD3Jzolw7wik38VmpiWUSJiKUYMCzXEGQdkGnv6Sfa20I7XlYzlRhgRFizd5CuV6b/iuReK9PYj21gG0MxWq8r0f01BxkxSxrGO7kM0xnScd2MXcPx2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SZgvHH43cmY+2hZhDRdQAMxZ1fm/fa8VqugSAGocky1Rt2TP4kL66RFGP+3UcsC3Y67Ek1yMcOMNYr9Gn2HIMkXUDmeAYbk3Bllh+Z05NTc+ooJXl5bDzp+ZHce3wxHvXHbXYAT1hq8oTBGBf5farbDwhh5XGtw5aahpvNrDdQzjYtSM+noFmfirtW3SplfCvHxXJY5+6Ow0VOwtX6vTPHz41JVv4IObAl8yOPdap8igVMzaWQGpcdacAbU+Bge0gLT0n/fripC+WlNBQQ7XVfvqdu+FECtfX7piaE6FTcKlP8S6Rz3mXdMM9NyXQLM8TJ84sHHZh3CXsHJKARoc+Z1ekDzRr7Eg9CJqFDvMFYvuLbCp+YaWQWh18tSXbUGm83qFYDCz/GfZWfQOZBvRX9syyO8Nu42hcwsGaLrKYiN+dUvRENr/naBmNo1o0WIStxTfBvk8iMuDqj0mAd17XBjGg/Qn2NyzjA7CLvTs+ocAYzvqAG1TfOHBaqD1K6d5bqzxRWTrjxVrMQU/L7988G4OIY8D63XQ02XtRcVWv46alUJMaETMg18ZjqGs70IxvrVVErxJMhXCQss7tHXp84wRGCNF5H+kwsUdQrl9ecHEy5cHHBR5iHz49m9RjM23VlWlhVgCXZWdiS9NRVsofv4LfU+YfquMkeBhAHoUG9rtLYBWD5oBpRqRtXm4G4M+S0HhFcht43YFKfBP1Jf+C6jPD7srPuyEoNXQBo/GGThl2+ER+a5bwMwwemudJktcl5wzzp9w3z3yQIiqsz+jAW+ARu5976JmHryI+OcN03AwWG//zfGUppxARR9Sy1QI/+kH22ypfwmhy3H++IoM5w7dS2FLbYYlzUQrx3SHXcD5uG0htbBwVvmzR0GiN7cZhejffH7VMG9HlG1nxbLJA4hwUeYWXo+jwNTORoDSLPRj/55PAiA6xiLEzcpMWVF367RvTw34bgJHHw==");
            if (sbw.GetNumberOfTabletPoints(false) != 0)           //This test is meant to be invalid intentionally.
            {
                listFailedTests.Add(9);
            }
            Assert.AreEqual(0, listFailedTests.Count);
        }