Exemple #1
0
        public void LoadAllCategoryFromFile()
        {
            if (!File.Exists(ClinicConstant.Categories_FileName))
            {
                templateCategories = new TemplateCategories();
                templateCategories.ListTemplateCategory = new List<TemplateCategory>();
                TemplateCategory categoryTongQuat = new TemplateCategory();
                categoryTongQuat.NameCategory = "Siêu Âm Tổng Quát";
                ControlSieuAm controlSieuAm = new ControlSieuAm();
                controlSieuAm.NameControlDisplayed = "Gan";
                controlSieuAm.ListDefaultValue = new List<string>(){"Cấu trúc echo đồng nhất, mặt gan phẳng, bờ gan đều, kích thước bình thường."};
                controlSieuAm.TypeControl = typeof(TextBox).ToString();
                categoryTongQuat.ListControl = new List<ControlSieuAm>();
                categoryTongQuat.ListControl.Add(controlSieuAm);
                templateCategories.ListTemplateCategory.Add(categoryTongQuat);

                using (StreamWriter sw = new StreamWriter(ClinicConstant.Categories_FileName))
                {
                    XmlSerializer serializer = new XmlSerializer(TemplateCategories.GetType());

                    serializer.Serialize(sw, TemplateCategories);
                }
            }
            TemplateCategories result;
            using (StreamReader sr = new StreamReader(ClinicConstant.Categories_FileName))
            {
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(TemplateCategories));
                 result = xmlSerializer.Deserialize(sr) as TemplateCategories;
            }
            this.templateCategories= result;
        }
Exemple #2
0
        private void LoadControlsFromSpecicalCategory(TemplateCategory templateCategory)
        {
            this.coTableLayoutPanelSieuAm.RowStyles.Clear();
            foreach (ControlSieuAm eachControl in templateCategory.ListControl)
            {
                var controlType = typeof(Control).Assembly.GetType(eachControl.TypeControl, true);
                Control control = Activator.CreateInstance(controlType) as Control;
                control.Text = eachControl.ListDefaultValue[0];
                control.Dock = DockStyle.Fill;
                (control as TextBox).Multiline = true;
                //var numberOfLines = SendMessage((control as TextBox).Handle.ToInt32(), EM_GETLINECOUNT, 0, 0);
                //(control as TextBox).Height = ((control as TextBox).Font.Height + 2) * numberOfLines;
                this.coTableLayoutPanelSieuAm.RowCount++;
                int index= this.coTableLayoutPanelSieuAm.RowCount;
                Label label = new Label();
                label.Text = eachControl.NameControlDisplayed;

                this.coTableLayoutPanelSieuAm.Controls.Add(label, 0, index-1);
                this.coTableLayoutPanelSieuAm.Controls.Add(control, 1, index-1);
                this.coTableLayoutPanelSieuAm.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent,40F));
            }
        }