private void Form1_Load(object sender, EventArgs e) { if (ItemsFile.Exists) { List<ItemInfo> lst = new List<ItemInfo>(); XmlSerializer xml = new XmlSerializer(lst.GetType()); using (Stream s = ItemsFile.OpenRead()) { lst = xml.Deserialize(s) as List<ItemInfo>; } foreach (ItemInfo item in lst) { CalendarItem cal = new CalendarItem(calendar1, item.StartTime, item.EndTime, item.Text); if (!(item.R == 0 && item.G == 0 && item.B == 0)) { cal.ApplyColor(Color.FromArgb(item.A, item.R, item.G, item.B)); } _items.Add(cal); } PlaceItems(); } }
public void SetCalendarItems(System.Collections.Generic.IEnumerable<DealProjectCalendarItemViewModel> calendarItems) { this.InvokeIfRequired(() => { this.comboBoxProjects.Items.Clear(); this.comboBoxProjects.Items.Add(string.Empty); this.calendarItems.Clear(); DateTime minDate = DateTime.Now; int colorCpt = 0; foreach (var item in calendarItems) { if (item.StartDate.Date.Equals(DateTime.MinValue)) { continue; } if (item.StartDate.Date < this.calendarProjects.ViewStart) { minDate = item.StartDate.Date; } var calendarItem = new System.Windows.Forms.Calendar.CalendarItem(this.calendarProjects, item.StartDate.Date, item.EndDate.Date.AddHours(23), item.Name); calendarItem.Tag = item.ProjectId; calendarItem.ApplyColor(this.calendarColors[colorCpt]); this.calendarItems.Add(calendarItem); this.comboBoxProjects.Items.Add(item.Name); colorCpt = (colorCpt + 1) % this.calendarColors.Length; } this.calendarProjects.SetViewRange(DateTime.Now, DateTime.Now.AddMonths(1)); this.calendarProjects.SetViewRange(minDate, minDate.AddMonths(1)); this.monthView.ViewStart = minDate; }); }
private void LoadCalendarByPerson(Person e) { _items.Clear(); Calendar_C.Items.Clear(); List<Vacation> vacs = e.Vacations; foreach (Vacation v in vacs) { CalendarItem cal = new CalendarItem(Calendar_C, v.Debut, v.Fin, "Vacations"); cal.ApplyColor(Color.Red); cal.Pattern = System.Drawing.Drawing2D.HatchStyle.ZigZag; _items.Add(cal); } List<Appointment> apps = e.Appointments; foreach (Appointment a in apps) { CalendarItem cal; if(e is Employee) cal = new CalendarItem(Calendar_C, a.Debut, a.Fin, a.Contact.Enterprise); else cal = new CalendarItem(Calendar_C, a.Debut, a.Fin, a.Employee.ToString()); cal.ApplyColor(Color.Black); cal.Pattern = System.Drawing.Drawing2D.HatchStyle.ZigZag; _items.Add(cal); } PlaceItems(); }
public Form1(int Authority, string name) { //init MainForm this.TopLevel = true; InitializeComponent(); //init delegate TuThuocForm.refreshMedicines4MainForm = new Clinic.TuThuocForm.RefreshMedicines4MainForm(InitComboboxMedicinesMySql); Services.refreshMedicines4MainForm = new Clinic.Services.RefreshMedicines4MainForm(InitComboboxMedicinesMySql); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); this.Text = "Phòng Khám -" + "User: "******"Loading Database"); //Load Settings if (mainFormSettings == null) { mainFormSettings = CreateMainFormSetttingsFromFile(); } this.checkBoxShowBigForm.Checked = mainFormSettings.ShowBigForm; this.checkBoxShow1Record.Checked = mainFormSettings.ShowOneRecord; this.checkBoxShowMedicines.Checked = mainFormSettings.ShowMedicines; this.Enabled = false; BackgroundWorker backgroundWorkerLoadingDatabase = new BackgroundWorker(); backgroundWorkerLoadingDatabase.WorkerSupportsCancellation = true; backgroundWorkerLoadingDatabase.DoWork += new DoWorkEventHandler(backgroundWorkerLoadingDatabase_DoWork); backgroundWorkerLoadingDatabase.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorkerLoadingDatabase_RunWorkerCompleted); backgroundWorkerLoadingDatabase.RunWorkerAsync(); this.textBoxReason.Visible = false; List<string> listLoaiKham = Helper.GetAllLoaiKham(this.db); this.comboBoxLoaiKham.Items.AddRange(listLoaiKham.ToArray()); comboBoxLoaiKham.Text = "Loại Khám: "; listDiagnosesFromHistory = Helper.GetAllDiagnosesFromHistory(this.db); this.txtBoxClinicRoomDiagnose.AutoCompleteCustomSource.AddRange(listDiagnosesFromHistory.ToArray()); this.StartPosition = FormStartPosition.CenterScreen; //this.WindowState = Clinic.Properties.Settings.Default.State; //if (this.WindowState == FormWindowState.Normal) this.Size = Clinic.Properties.Settings.Default.Size; this.Resize += new System.EventHandler(this.Form1_Resize); try { XmlSerializer xmlSerializer = new XmlSerializer(typeof(InfoClinic)); StreamReader sr = new StreamReader("Information.xml"); infoClinic = xmlSerializer.Deserialize(sr) as InfoClinic; textBoxNameClinic.Text = infoClinic.Name; textBoxAddressClinic.Text = infoClinic.Address; textBoxAdviceClinic.Text = infoClinic.Advice; textBoxSDT.Text = infoClinic.Sdt; textBoxBackupSource.Text = infoClinic.PathData; textBoxBackupTarget.Text = infoClinic.PathTargetBackup; textBoxBackupTimeAuto.Text = infoClinic.TimeBackup; bool temp = bool.Parse(infoClinic.CheckedBackup1.ToLower()); if (temp) { checkBoxAutoCopy.CheckState = CheckState.Checked; } sr.Close(); } catch (Exception exx) { } try { // do any background work //do not change InitComboboxMedicinesMySql(); InitClinicRoom(); dataGridView4.Visible = false; maxIdOfCalendarItem = Helper.SearchMaxValueOfTable(db,"calendar", "IdCalendar", "DESC"); // //Load calendar // List<ADate> listDate = Helper.GetAllDateOfUser(UserName, db); foreach (ADate item in listDate) { CalendarItem cal = new CalendarItem(calendar1, item.StartTime, item.EndTime, item.Text); cal.Tag = item.Id; if (item.color != 0) { cal.ApplyColor(Helper.ConvertCodeToColor(item.color)); } _items.Add(cal); } PlaceItems(); //load lichhen LoadLichHen(DateTime.Now); //xoa listtoday XoaListToday(); } catch (Exception ex) { // log errors } listPatientForm = new Clinic.ListPatientsTodayForm(); listPatientForm.sendCommandKham = new Clinic.ListPatientsTodayForm.SendCommandKham(KhamVaXoa); SearchForm.sendCommand = new Clinic.SearchForm.SendCommandProcessFromSearchForm(this.ProcessWhenUserDoubleClickOnSearch); ///favouriteForm.sendCommand = new Form2.SendCommand(PlayFromFavouriteForm); /// this.ColumnID.Width = 50; this.ColumnNamePatient.Width = 150; this.ColumnNgaySinh.Width = 100; this.ColumnNgayKham.Width = 100; this.ColumnAddress.Width = 100; this.ColumnSymtom.Width = 100; this.ColumnNhietDo.Width = 50; this.ColumnHuyetAp.Width = 50; this.ColumnDiagno.Width = 150; this.ColumnSearchValueMedicines.Width = 250; this.circularProgress1.Hide(); TimerGetId = new System.Windows.Forms.Timer(); TimerGetId.Tick+=new EventHandler(TimerGetId_Tick); TimerGetId.Interval = 2000; TimerGetId.Start(); try { SieuAmManager.Instance.Capture.PreviewWindow = this.panelPreviewVideo; } catch { } }
/// <summary> /// Formattage d'un Item du Calendrier /// </summary> /// <param name="_itemCal"></param> /// <param name="_itemEcole"></param> private void formatInfoCalendar(CalendarItem _itemCal, Ecole _itemEcole) { StringBuilder _infoText = new StringBuilder(); _infoText.AppendLine(_itemEcole.Libelle); _infoText.AppendLine("Ville : " + _itemEcole.Ville); _infoText.AppendLine("Photographe : " + p_applClass.Param.GetNamePhotoGrapheFromId(_itemEcole._planifEnCours.IdPhotographe)); _itemCal.Text = _infoText.ToString(); _itemCal.ApplyColor(Color.FromArgb(p_applClass.Param.GetColorFromId(_itemEcole._planifEnCours.IdPhotographe))); _itemCal.StartDate = _itemEcole._planifEnCours.StartDate; _itemCal.EndDate = _itemEcole._planifEnCours.EndDate; _itemCal.Tag = _itemEcole.IdEcole; if (_itemEcole.Confirme) { _itemCal.Image = imgList.Images[0]; _itemCal.ImageAlign = CalendarItemImageAlign.South; } else { _itemCal.Image = null; } }
/// <summary> /// Mise à jour du Control Calendar /// </summary> /// <param name="itemEcole"></param> public void updateCalendar(Ecole itemEcole, bool withShow) { StringBuilder _infoText = new StringBuilder(); if (itemEcole.isSchedule) { // On vérifie que le CalendarItem existe for (int i = 0; i < _itemsCalendar.Count; i++) { if ((string)_itemsCalendar[i].Tag == itemEcole.IdEcole) { _itemsCalendar[i].ApplyColor(Color.FromName(p_param.GetCoulorFromId(itemEcole.Photographe))); _itemsCalendar[i].StartDate = itemEcole.StartDate; _itemsCalendar[i].EndDate = itemEcole.EndDate; _infoText.AppendLine(itemEcole.Libelle); _itemsCalendar[i].Text = _infoText.ToString(); if (itemEcole.Confirme) { _itemsCalendar[i].Image = imgList.Images[0]; _itemsCalendar[i].ImageAlign = CalendarItemImageAlign.South; } else { _itemsCalendar[i].Image = null; } if (withShow) { this.setViewRangeFromDate(itemEcole.StartDate); } PlaceItems(); return; } } _infoText.AppendLine(itemEcole.Libelle); _infoText.AppendLine("Ville : " + itemEcole.Ville); _infoText.AppendLine("Photographe : " + p_param.GetNamePhotoGrapheFromId(itemEcole.Photographe)); CalendarItem cal = new CalendarItem(objCalendar, itemEcole.StartDate, itemEcole.EndDate, _infoText.ToString()); if (withShow) { this.setViewRangeFromDate(itemEcole.StartDate); } cal.ApplyColor(Color.FromName(p_param.GetCoulorFromId(itemEcole.Photographe))); cal.Tag = itemEcole.IdEcole; if (itemEcole.Confirme) { cal.Image = imgList.Images[0]; cal.ImageAlign = CalendarItemImageAlign.South; } else { cal.Image = null; } _itemsCalendar.Add(cal); PlaceItems(); } }