private void FormCommItem_Load(object sender, System.EventArgs e) { IsStartingUp = true; textPatientName.Text = Patients.GetLim(CommlogCur.PatNum).GetNameFL(); textUser.Text = Userods.GetName(CommlogCur.UserNum); //might be blank. textDateTime.Text = CommlogCur.CommDateTime.ToShortDateString() + " " + CommlogCur.CommDateTime.ToShortTimeString(); if (CommlogCur.DateTimeEnd.Year > 1880) { textDateTimeEnd.Text = CommlogCur.DateTimeEnd.ToShortDateString() + " " + CommlogCur.DateTimeEnd.ToShortTimeString(); } //there will usually be a commtype set before this dialog is opened for (int i = 0; i < DefC.Short[(int)DefCat.CommLogTypes].Length; i++) { listType.Items.Add(DefC.Short[(int)DefCat.CommLogTypes][i].ItemName); if (DefC.Short[(int)DefCat.CommLogTypes][i].DefNum == CommlogCur.CommType) { listType.SelectedIndex = i; } } for (int i = 0; i < Enum.GetNames(typeof(CommItemMode)).Length; i++) { listMode.Items.Add(Lan.g("enumCommItemMode", Enum.GetNames(typeof(CommItemMode))[i])); } listMode.SelectedIndex = (int)CommlogCur.Mode_; for (int i = 0; i < Enum.GetNames(typeof(CommSentOrReceived)).Length; i++) { listSentOrReceived.Items.Add (Lan.g("enumCommSentOrReceived", Enum.GetNames(typeof(CommSentOrReceived))[i])); } try{ listSentOrReceived.SelectedIndex = (int)CommlogCur.SentOrReceived; } catch { MessageBox.Show(((int)CommlogCur.SentOrReceived).ToString()); } //checkIsStatementSent.Checked=CommlogCur.IsStatementSent; textNote.Text = CommlogCur.Note; textNote.SelectionStart = textNote.Text.Length; #if !DEBUG labelCommlogNum.Visible = false; textCommlogNum.Visible = false; #endif textCommlogNum.Text = CommlogCur.CommlogNum.ToString(); if (!PrefC.GetBool(PrefName.DistributorKey)) { labelDateTimeEnd.Visible = false; textDateTimeEnd.Visible = false; butNow.Visible = false; butNowEnd.Visible = false; } textNote.Select(); string keyData = GetSignatureKey(); signatureBoxWrapper.FillSignature(CommlogCur.SigIsTopaz, keyData, CommlogCur.Signature); signatureBoxWrapper.BringToFront(); IsStartingUp = false; if (!Security.IsAuthorized(Permissions.CommlogEdit, CommlogCur.CommDateTime)) { if (IsNew) { DialogResult = DialogResult.Cancel; return; } butDelete.Enabled = false; butOK.Enabled = false; } }
///<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(); } }
///<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(); } }
///<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(); } }