Beispiel #1
0
        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();
            }
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            this.calendar2.Items.Clear();
            if (tasks == null || tasks.Count == 0)
            {
                MessageBox.Show("Click in Planificar first to create a virtual schedule. Then Click Here to produce a Calendar.");
                return;
            }
            var list   = new List <CalendarItem>();
            var random = new Random();

            foreach (var task in tasks)
            {
                var taskColor = indexcolors[random.Next(indexcolors.Length)];

                foreach (var bk in task.Breaks)
                {
                    var name = task.task.Name + " - " + task.task.Assignments.First().Resource.Name;
                    var ut   = new System.Windows.Forms.Calendar.CalendarItem(this.calendar2, bk.Start, bk.End, name);
                    ut.BackgroundColor = System.Drawing.ColorTranslator.FromHtml(taskColor);
                    list.Add(ut);
                }
            }

            this.calendar2.Items.AddRange(list);
        }
Beispiel #3
0
        private void calendar1_DragDrop(object sender, DragEventArgs e)
        {
            // Course c = _currentSchool.AddCourse("test");

               // Promotion p = _currentSchool.FindPromotion(calendar1.Text);

               // c.AddPromotion(p);

            calendar1.Text = e.Data.GetData(DataFormats.Text).ToString();

               Point Point = calendar1.PointToClient(new Point(e.X, e.Y));
               CalendarItem mytest = calendar1.ItemAt(Point);

            if(mytest == null)
            {
                ICalendarSelectableElement element = calendar1.HitTest(Point);
                CalendarItem cal = new CalendarItem(calendar1, element.Date, element.Date.AddHours(1), calendar1.Text);
                calendar1.Items.Add(cal);
            }
            else
            {
                string initial_content = mytest.Text;
                string additionnal_content = calendar1.Text;

                mytest.Text = initial_content + '\n' + additionnal_content;
                calendar1.Items.Add(mytest);
            }
        }
Beispiel #4
0
 internal void AddPassingItem(CalendarItem item)
 {
     if (!PassingItems.Contains(item))
     {
         PassingItems.Add(item);
     }
 }
Beispiel #5
0
		private void PlaceItems()
		{
			calendar1.Items.Clear();
			_calendarItems = new List<CalendarItem>();
			foreach (ScheduledItem item in _data.ScheduledItems) {
				string name = item.ItemFilePath.Substring(item.ItemFilePath.LastIndexOf("\\") + 1);
				string finalname = name.Substring(0, name.LastIndexOf(".")) + "\r\nDuration:  " + item.RunLength.ToString("c");

				CalendarItem ci = new CalendarItem(calendar1, item.ScheduledItemStartDate, item.RunLength, finalname)
				                  	{Tag = item.Id};
				_calendarItems.Add(ci);
				calendar1.Items.Add(ci);
			}
		}
        public override void OnDrawItemText(CalendarRendererBoxEventArgs e)
        {
            CalendarItem item = e.Tag as CalendarItem;

            if (item != null)
            {
                if (item.IsDragging)
                {
                    e.TextColor = Color.FromArgb(120, e.TextColor);
                }
            }

            base.OnDrawItemText(e);
        }
        private void calendar1_MouseMove(object sender, MouseEventArgs e)
        {
            System.Windows.Forms.Calendar.CalendarItem i = calendar1.ItemAt(calendar1.PointToClient(Cursor.Position));

            if (i == null)
            {
                toolTip1.Active = false;
                toolTip1.Hide(this);
            }
            else if (toolTip1.Active == false && calendar1.State != Calendar.CalendarState.DraggingItem &&
                     calendar1.State != Calendar.CalendarState.ResizingItem)
            {
                toolTip1.Active = true;
                Point tooltipPosition = PointToClient(Cursor.Position);
                toolTip1.Show(i.Text, this, tooltipPosition);
            }
        }
        /// <summary>
        /// Clone this instance.
        /// </summary>
        /// <returns></returns>
        public CalendarItem Clone()
        {
            CalendarItem newItem = new CalendarItem(this.Calendar, _startDate, _endDate, Subject);

            newItem.AditionalBounds = this.AditionalBounds;
            newItem.BackColor       = this.BackColor;
            newItem.BorderColor     = this.BorderColor;
            newItem.Bounds          = this.Bounds;
            newItem.Image           = this.Image;
            newItem.ImageAlign      = this.ImageAlign;
            newItem.Pattern         = this.Pattern;
            newItem.PatternColor    = this.PatternColor;
            newItem.Selected        = false;
            newItem.Tag             = this.Tag;
            newItem.UnitsPassing    = this.UnitsPassing;
            newItem.Values          = this.Values;

            return(newItem);
        }
        private void addToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CalendarItem item = ReturnCalendarItem();

            if (item != null && item.Tag != null)
            {
                MessageBox.Show("Item already exists.\r\n" + "If you wish to change date/time just drag and drop where you want the item to be.",
                    "Item Exists", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                item = new CalendarItem(calendar1, calendar1.SelectedElementStart.Date, calendar1.SelectedElementEnd.Date, "New Item to Add");

                using (ConfigureScheduledItems csi = new ConfigureScheduledItems(item))
                {
                    if (csi.ShowDialog() == DialogResult.OK)
                    {
                        _data.ScheduledItems.Add(csi._scheduledItem);
                        PlaceItems();
                    }
                }
            }
        }
Beispiel #10
0
        public void MakeRefreshOnBooking()
        {
            var bk = vc.BookingsToCalendar();

            List<ItemInfo> lst = new List<ItemInfo>();

            foreach (Booking item in bk)
            {

                lst.Add(new ItemInfo(item.StartTime, item.EndTime, item.Firstname, item.Surname, item.Types));

            }

            foreach (ItemInfo item in lst)
            {

                CalendarItem cal = new CalendarItem(calendar1, item.StartTime, item.EndTime, item.FirstName);

                _items.Add(cal);

            }

            PlaceItems();
        }
Beispiel #11
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            ICalendarSelectableElement hitted = HitTest(e.Location);
            CalendarItem hittedItem = hitted as CalendarItem;
            bool shiftPressed = (ModifierKeys & Keys.Shift) == Keys.Shift;

            if (!Focused)
            {
                Focus();
            }

            switch (State)
            {
                case CalendarState.Idle:
                    if (hittedItem != null)
                    {
                        if (!shiftPressed)
                            ClearSelectedItems();

                        hittedItem.SetSelected(true);
                        Invalidate(hittedItem);
                        OnItemSelected(new CalendarItemEventArgs(hittedItem));

                        itemOnState = hittedItem;
                        itemOnStateChanged = false;

                        if (AllowItemEdit)
                        {
                            if (itemOnState.ResizeStartDateZone(e.Location) && AllowItemResize)
                            {
                                SetState(CalendarState.ResizingItem);
                                itemOnState.SetIsResizingStartDate(true);
                            }
                            else if (itemOnState.ResizeEndDateZone(e.Location) && AllowItemResize)
                            {
                                SetState(CalendarState.ResizingItem);
                                itemOnState.SetIsResizingEndDate(true);
                            }
                            else
                            {
                                SetState(CalendarState.DraggingItem);
                            } 
                        }

                        SetSelectionRange(null, null);
                    }
                    else
                    {
                        ClearSelectedItems();

                        if (shiftPressed)
                        {
                            if (hitted != null && SelectedElementEnd == null && !SelectedElementEnd.Equals(hitted))
                                SelectedElementEnd = hitted;
                        }
                        else
                        {
                            if (SelectedElementStart == null || (hitted != null && !SelectedElementStart.Equals(hitted)))
                            {
                                SetSelectionRange(hitted, hitted);
                            }
                        }

                        SetState(CalendarState.DraggingTimeSelection);
                    }
                    break;
                case CalendarState.DraggingTimeSelection:
                    break;
                case CalendarState.DraggingItem:
                    break;
                case CalendarState.ResizingItem:
                    break;
                case CalendarState.EditingItemText:
                    break;
                    
            }
        }
Beispiel #12
0
 /// <summary>
 /// Adds an item to the <see cref="ContainedItems"/> list if not in yet
 /// </summary>
 /// <param name="item"></param>
 internal void AddContainedItem(CalendarItem item)
 {
     if (!ContainedItems.Contains(item))
     {
         ContainedItems.Add(item);
     }
 }
        /// <summary>
        /// Recursive method that collects items intersecting on time, to graphically represent-them on the layout
        /// </summary>
        /// <param name="calendarItem"></param>
        /// <param name="items"></param>
        /// <param name="grouped"></param>
        private void CollectIntersectingGroup(CalendarItem calendarItem, List<CalendarItem> items, List<CalendarItem> grouped)
        {
            if (!grouped.Contains(calendarItem))
                grouped.Add(calendarItem);

            foreach (CalendarItem item in items)
            {
                if (!grouped.Contains(item) &&
                    calendarItem.IntersectsWith(item.StartDate.TimeOfDay, item.EndDate.TimeOfDay))
                {
                    grouped.Add(item);

                    CollectIntersectingGroup(item, items, grouped);
                }
            }
        }
Beispiel #14
0
        /// <summary>
        /// Invalidates the area of the specified item
        /// </summary>
        /// <param name="item"></param>
        public void Invalidate(CalendarItem item)
        {
            Rectangle r = item.Bounds;

            foreach (Rectangle bounds in item.GetAllBounds())
            {
                r = Rectangle.Union(r, bounds);
            }

            r.Inflate(Renderer.ItemShadowPadding + Renderer.ItemInvalidateMargin, Renderer.ItemShadowPadding + Renderer.ItemInvalidateMargin);
            Invalidate(r);
        }
Beispiel #15
0
        /// <summary>
        /// Creates a new item on the current selection. 
        /// If there's no selection, this will be ignored.
        /// </summary>
        /// <param name="itemText">Text of the item</param>
        /// <param name="editMode">If <c>true</c> activates the edit mode so user can edit the text of the item.</param>
        public void CreateItemOnSelection(string itemText, bool editMode)
        {
            if (SelectedElementEnd == null || SelectedElementStart == null) return;

            CalendarTimeScaleUnit unitEnd = SelectedElementEnd as CalendarTimeScaleUnit;
            CalendarDayTop dayTop = SelectedElementEnd as CalendarDayTop;
            CalendarDay day = SelectedElementEnd as CalendarDay;
            TimeSpan duration = unitEnd != null ? unitEnd.Duration : new TimeSpan(23, 59, 59);
            CalendarItem item = new CalendarItem(this);

            DateTime dstart = SelectedElementStart.Date;
            DateTime dend = SelectedElementEnd.Date;

            if (dend.CompareTo(dstart) < 0)
            {
                DateTime dtmp = dend;
                dend = dstart;
                dstart = dtmp;
            }

            item.StartDate = dstart;
            item.EndDate = dend.Add(duration);
            item.Text = itemText;

            CalendarItemCancelEventArgs evtA = new CalendarItemCancelEventArgs(item);

            OnItemCreating(evtA);

            if (!evtA.Cancel)
            {
                Items.Add(item);

                if (editMode)
                {
                    _creatingItem = true;
                    ActivateEditMode(item);
                }
            }

            
        }
 /// <summary>
 /// Creates a new <see cref="CalendarItemEventArgs"/>
 /// </summary>
 /// <param name="item">Related Item</param>
 public CalendarItemEventArgs(CalendarItem item)
 {
     _item = item;
 }
Beispiel #17
0
        // loads events to calendar-view.
        private void Calendar_LoadItems(object sender, CalendarLoadEventArgs e)
        {
            foreach (Event @event in this._events) // loop through events.
            {
                CalendarItem c = new CalendarItem(this.Calendar, @event.Time.LocalTime, @event.Time.LocalTime.AddHours(1), @event.FullTitle); // create a calendar item.

                if (Calendar.ViewIntersects(c)) // if the event intersects view calendars current view range (start day-end day).
                {
                    c.Tag = @event; // store event on the tag.
                    c.ToolTipText = @event.FullTitle; // item tooltip.
                    Calendar.Items.Add(c); // add it to calendar.
                }

                // we don't need to add this event to calendar as the calendar view does not interesect event date & time.
                // (The calendar will explicitly re-ask us the events list when it's view range changes).
                else c = null;
            }
        }
Beispiel #18
0
 public CalendarRendererItemEventArgs(CalendarRendererEventArgs original, CalendarItem item)
     : base(original)
 {
     _item = item;
 }
        private bool RemoveVacationByItem(CalendarItem item, Person p)
        {
            bool trouve = false;
            DateTime deb = item.StartDate;
            DateTime fin = item.EndDate;

            Vacation vac = p.Vacations.Where(a => a.Debut == deb && a.Fin == fin).FirstOrDefault();
            if (vac != null)
            {
                p.Vacations.Remove(vac);
                trouve = true;
            }

            return trouve;
        }
        private bool RemoveAppointmentByItem(CalendarItem item, Employee emp, Contact con)
        {
            bool trouveE = false;
            bool trouveC = false;

            DateTime deb = item.StartDate;
            DateTime fin = item.EndDate;

            Appointment apEmp = emp.Appointments.Where(a => a.Debut == deb && a.Fin == fin).FirstOrDefault();
            if (apEmp != null)
            {
                emp.Appointments.Remove(apEmp);
                trouveE = true;
            }

            Appointment apCon = con.Appointments.Where(a => a.Debut == deb && a.Fin == fin).FirstOrDefault();
            if (apCon != null)
            {
                con.Appointments.Remove(apCon);
                trouveC = true;
            }

            if (trouveC && trouveE) return true;
            else return false;
        }
        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();
        }
Beispiel #22
0
        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 { }
        }
Beispiel #23
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);

            ICalendarSelectableElement hitted = HitTest(e.Location, State == CalendarState.DraggingTimeSelection);
            CalendarItem hittedItem = hitted as CalendarItem;
            CalendarDay hittedDay = hitted as CalendarDay;
            bool shiftPressed = (ModifierKeys & Keys.Shift) == Keys.Shift;

            switch (State)
            {
                case CalendarState.Idle:
                    
                    break;
                case CalendarState.DraggingTimeSelection:
                    if (SelectedElementStart == null || (hitted != null && !SelectedElementEnd.Equals(hitted)))
                    {
                        SelectedElementEnd = hitted;
                    }
                    if (hittedDay != null)
                    {
                        if (hittedDay.HeaderBounds.Contains(e.Location))
                        {
                            OnDayHeaderClick(new CalendarDayEventArgs(hittedDay));
                        }
                    }
                    break;
                case CalendarState.DraggingItem:
                    if(itemOnStateChanged)
                        OnItemDatesChanged(new CalendarItemEventArgs(itemOnState));
                    break;
                case CalendarState.ResizingItem:
                    if (itemOnStateChanged)
                        OnItemDatesChanged(new CalendarItemEventArgs(itemOnState));
                    break;
                case CalendarState.EditingItemText:
                    break;
            }

            if (itemOnState != null)
            {
                itemOnState.SetIsDragging(false);
                itemOnState.SetIsResizingEndDate(false);
                itemOnState.SetIsResizingStartDate(false);
                Invalidate(itemOnState);
                OnItemClick(new CalendarItemEventArgs(itemOnState));
                itemOnState = null;
            }
            SetState(CalendarState.Idle);
        }
Beispiel #24
0
        /// <summary>
        /// Activates the edit mode on the specified item
        /// </summary>
        /// <param name="item"></param>
        public void ActivateEditMode(CalendarItem item)
        {
            CalendarItemCancelEventArgs evt = new CalendarItemCancelEventArgs(item);

            if (!_creatingItem)
            {
                OnItemEditing(evt);
            }

            if (evt.Cancel)
            {
                return;
            }

            _editModeItem = item;
            TextBox = new CalendarTextBox(this);
            TextBox.KeyDown += new KeyEventHandler(TextBox_KeyDown);
            TextBox.LostFocus += new EventHandler(TextBox_LostFocus);
            Rectangle r = item.Bounds;
            r.Inflate(-2, -2);
            TextBox.Bounds = r;
            TextBox.BorderStyle = BorderStyle.None;
            TextBox.Text = item.Text;
            TextBox.Multiline = true;

            Controls.Add(TextBox);
            TextBox.Visible = true;
            TextBox.Focus();
            TextBox.SelectionStart = TextBox.Text.Length;

            SetState(CalendarState.EditingItemText);
        }
Beispiel #25
0
		private void contextMenuStrip1_Opening(object sender, System.ComponentModel.CancelEventArgs e)
		{
			contextItem = calendar1.ItemAt(contextMenuStrip1.Bounds.Location);
		}
Beispiel #26
0
        /// <summary>
        /// Finalizes editing the <see cref="EditModeItem"/>.
        /// </summary>
        /// <param name="cancel">Value indicating if edition of item should be canceled.</param>
        public void FinalizeEditMode(bool cancel)
        {
            if (!EditMode || EditModeItem == null || _finalizingEdition) return;

            _finalizingEdition = true;

            string cancelText = _editModeItem.Text;
            CalendarItem itemBuffer = _editModeItem;
            _editModeItem = null;
            CalendarItemCancelEventArgs evt = new CalendarItemCancelEventArgs(itemBuffer);

            if(!cancel)
                itemBuffer.Text = TextBox.Text.Trim();

            if (TextBox != null)
            {
                TextBox.Visible = false;
                Controls.Remove(TextBox);
                TextBox.Dispose();
            }
            
            if(_editModeItem != null)
                Invalidate(itemBuffer);

            _textBox = null;

            if (_creatingItem)
            {
                OnItemCreated(evt);
            }
            else
            {
                OnItemEdited(evt);
            }

            if (evt.Cancel)
            {
                itemBuffer.Text = cancelText;
            }


            _creatingItem = false;
            _finalizingEdition = false;

            if (State == CalendarState.EditingItemText)
            {
                SetState(CalendarState.Idle);
            }
        }
 public CalendarItemEventArgs(CalendarItem item, MouseEventArgs mouseEventArgs)
 {
     _item           = item;
     _mouseEventArgs = mouseEventArgs;
 }
Beispiel #28
0
 /// <summary>
 /// Returns a value indicating if the view range intersect the date range of the specified item
 /// </summary>
 /// <param name="item"></param>
 public bool ViewIntersects(CalendarItem item)
 {
     return ViewIntersects(item.StartDate, item.EndDate);
 }
 public CalendarRendererItemEventArgs(CalendarRendererEventArgs original, CalendarItem item)
     : base(original)
 {
     _item = item;
 }
 /// <summary>
 /// Comparison delegate to sort items
 /// </summary>
 /// <param name="item1"></param>
 /// <param name="item2"></param>
 /// <returns></returns>
 private static int CompareItems(CalendarItem item1, CalendarItem item2)
 {
     return item1.StartDate.CompareTo(item2.StartDate) * -1;
 }
Beispiel #31
0
        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;
            });
        }
Beispiel #32
0
        private void CargarEventosCalendario()
        {
            Cargando.Mostrar();

            // Se obtienen los datos
            List<ProveedoresComprasView> oEventos;
            if (this.chkCppSoloProveedorSel.Checked)
            {
                if (this.Proveedor == null || this.Proveedor.ProveedorID <= 0)
                {
                    UtilLocal.MensajeAdvertencia("No hay ningún Proveedor seleccionado.");
                    Cargando.Cerrar();
                    return;
                }
                oEventos = Datos.GetListOf<ProveedoresComprasView>(c => c.Saldo > 0 && c.ProveedorID == this.Proveedor.ProveedorID
                    && !c.MovimientoAgrupadorID.HasValue);
            }
            else
            {
                oEventos = Datos.GetListOf<ProveedoresComprasView>(c => c.Saldo > 0 && !c.MovimientoAgrupadorID.HasValue);
            }

            this.oEventosCalendario = new List<CalendarItem>();
            foreach (var oReg in oEventos)
            {
                // Se obtiene el día de pago
                DateTime dPago = AdmonProc.SugerirVencimientoCompra(oReg.Fecha.Valor(), oReg.DiasPlazo.Valor());

                var citemp = new CalendarItem(this.calProveedor, dPago, dPago.AddMinutes(30)
                    , string.Format("{0} - {1}\n{2}\n{3}", oReg.Proveedor, oReg.Saldo.Valor().ToString(GlobalClass.FormatoMoneda), dPago, "FECHA DE PAGO"));
                citemp.Tag = oReg.Saldo;
                this.oEventosCalendario.Add(citemp);
            }
            this.CalendarioEstablecerRangoMostrado(this.mvCalendarioProveedor.SelectionStart, this.mvCalendarioProveedor.SelectionEnd);

            Cargando.Cerrar();
        }
 /// <summary>
 /// Creates a new <see cref="CalendarItemEventArgs"/>
 /// </summary>
 /// <param name="item">Related Item</param>
 /// <param name="state">Currently item state</param>
 public CalendarItemEventArgs(CalendarItem item, States state)
 {
     Item  = item;
     State = state;
 }
        private void loadVisits()
        {
            DataTable dt1 = Visit.GetDataTableForDayByUser(userID, calendar1.ViewStart);

            calendar1.Items.Clear();

            foreach (DataRow row in dt1.Rows)
            {
                DateTime date1 = Convert.ToDateTime(row.ItemArray[2].ToString());
                DateTime date2 = Convert.ToDateTime(date1.Year.ToString() + "-" + date1.Month.ToString() + "-" + date1.Day.ToString() + " " + (date1.Hour + 1).ToString() + ":00");

                CalendarItem item = new CalendarItem(calendar1, date1, date2, row.ItemArray[6].ToString() + " - " + row.ItemArray[5].ToString(), row.ItemArray[0].ToString());
                if (row.ItemArray[3].ToString() == "Не выполнено")
                    item.BackgroundColor = Color.Red;
                if (row.ItemArray[3].ToString() == "Выполнено")
                    item.BackgroundColor = Color.Green;
                calendar1.Items.Add(item);
            }
        }
Beispiel #35
0
        /// <summary>
        /// Refresh the items on the calendar
        /// </summary>
        public void RefreshItems()
        {
            if (DesignMode)
            {
                return;
            }

            serviceuser_calendar.Items.Clear();

            if (_ServiceUser == null)
            {
                return;
            }

            Cursor = Cursors.WaitCursor;

            foreach (CalendarDay day in serviceuser_calendar.Days)
            {
                day.Image = null;

                if (day.Date > _ServiceUser.ServiceBegins_Clean && day.Date < _ServiceUser.ServiceEnds)
                {
                    day.Image     = Properties.Resources.lightning_go;
                    day.Image.Tag = "service period";
                }
            }

            try
            {
                foreach (Call call in _ServiceUser.Calls.Where(c => !c.MarkedForDeletion))
                {
                    if (!ValidFiltered(call))
                    {
                        continue;
                    }

                    DateTime fakeTime;

                    int hoursToRemove   = call.time.Hour;
                    int minutesToRemove = call.time.Minute;

                    int addition = 1;

                    if (call.time.Hour >= 18)
                    {
                        //evening
                        fakeTime = call.time.AddHours(-hoursToRemove + 3).AddMinutes(-minutesToRemove);
                    }
                    else if (call.time.Hour >= 15)
                    {
                        if (call.TimeTo.Hour >= 18)
                        {
                            addition += 1;
                        }
                        //afternoon
                        fakeTime = call.time.AddHours(-hoursToRemove + 2).AddMinutes(-minutesToRemove);
                    }
                    else if (call.time.Hour >= 12)
                    {
                        if (call.TimeTo.Hour >= 15)
                        {
                            addition += 1;
                        }
                        if (call.TimeTo.Hour >= 18)
                        {
                            addition += 1;
                        }
                        //lunch
                        fakeTime = call.time.AddHours(-hoursToRemove + 1).AddMinutes(-minutesToRemove);
                    }
                    else
                    {
                        if (call.TimeTo.Hour >= 12)
                        {
                            addition += 1;
                        }
                        if (call.TimeTo.Hour >= 15)
                        {
                            addition += 1;
                        }
                        if (call.TimeTo.Hour >= 18)
                        {
                            addition += 1;
                        }
                        //morning
                        fakeTime = call.time.AddHours(-hoursToRemove + 0).AddMinutes(-minutesToRemove);
                    }

                    string covertxt;

                    if (call.Workers.Count == 0)
                    {
                        covertxt = "Uncovered";
                    }
                    else
                    {
                        covertxt = "";

                        foreach (Worker worker in call.Workers)
                        {
                            covertxt += worker.Name + ",";
                        }

                        covertxt = covertxt.Trim(new char[] { ',' });
                    }

                    CalendarItem newitem = new System.Windows.Forms.Calendar.CalendarItem(
                        serviceuser_calendar,
                        fakeTime,
                        fakeTime.AddHours(addition),
                        call.time.ToString("HH:mm") + "\r\n" + call.Duration)
                    {
                        Tag        = call,
                        Image      = call.Image,
                        ImageAlign = System.Windows.Forms.Calendar.CalendarItemImageAlign.East
                    };


                    if (!call.HasFullWorkers)
                    {
                        newitem.BackgroundColor        = Color.White;
                        newitem.BackgroundColorLighter = Color.White;
                    }

                    serviceuser_calendar.Items.Add(newitem);
                }

                //callsTxt.Text = (ServiceUser.TotalCallTime_Mins_ForWeek(StartDate) / 60).ToString("0.00");
                //assignedTxt.Text = (ServiceUser.TotalCallTimeCovered_Mins_ForWeek(StartDate) / 60).ToString("0.00");
                //unassignedTxt.Text = (ServiceUser.TotalCallTimeUnCovered_Mins_ForWeek(StartDate) / 60).ToString("0.00");
            }
            catch (Exception ex)
            {
                Cura.Common.Common.LogError("There was an error refreshing service user call items", ex);
            }
            Cursor = Cursors.Default;
        }
Beispiel #36
0
 /// <summary>
 /// Creates a new <see cref="CalendarItemEventArgs"/>
 /// </summary>
 /// <param name="item">Related Item</param>
 public CalendarItemCancelEventArgs(CalendarItem item)
 {
     _item = item;
 }
 /// <summary>
 /// Creates a new <see cref="CalendarItemEventArgs"/>
 /// </summary>
 /// <param name="item">Related Item</param>
 public CalendarItemEventArgs(CalendarItem item)
 {
     _item = item;
 }
Beispiel #38
0
        private void calendarReload()
        {
            calendar.SetViewRange(monthView1.SelectionStart, monthView1.SelectionEnd);
            _items.Clear();
            SqlConnection cn = new SqlConnection();
            try
            {
                DateTime start, end;
                CalendarItem ci;
                cn = DBDevite.DBOpen();

                //Task
                SqlCommand command = new SqlCommand("SELECT u.Users, c.Name, t.Date, t.TimeStart, t.TimeEnd, t.TaskStatus " +
                                                    "FROM tasks t " +
                                                    "LEFT JOIN users u ON t.userID = u.ID " +
                                                    "LEFT JOIN clients c ON t.clientID = c.ID " +
                                                    "WHERE t.TaskStatus = 'true'", cn);
                SqlDataReader reader = command.ExecuteReader();

                while (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        start = Convert.ToDateTime(reader.GetDateTime(2).ToString("dd-MM-yyyy") + " " + reader.GetString(3).Trim() + ":00");
                        end = Convert.ToDateTime(reader.GetDateTime(2).ToString("dd-MM-yyyy") + " " + reader.GetString(4).Trim() + ":00");
                        ci = new CalendarItem(calendar, start, end, reader.GetString(1) + "/" + reader.GetString(0));
                        _items.Add(ci);
                    }
                    reader.NextResult();
                }

                foreach (CalendarItem item in _items)
                {
                    if (calendar.ViewIntersects(item))
                    {
                        calendar.Items.Add(item);
                    }
                }
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                DBDevite.DBClose(cn);
            }
        }
Beispiel #39
0
        /// <summary>
        /// Clears existance of item from this unit and it's corresponding day.
        /// </summary>
        /// <param name="item"></param>
        internal void ClearItemExistance(CalendarItem item)
        {
            if (PassingItems.Contains(item))
            {
                PassingItems.Remove(item);
            }

            if (Day.ContainedItems.Contains(item))
            {
                Day.ContainedItems.Remove(item);
            }
        }
 public ConfigureScheduledItems(CalendarItem calendarItem)
     : this()
 {
     _calendarItem = calendarItem;
     startTimePicker.Value = _calendarItem.StartDate;
     _program = new Program();
 }