public override void LoadView()
        {
            base.LoadView();

            _calendarView = new CalendarView(new RectangleF(0, 0, Resources.MONTHVIEW_WIDTH, 200), this, DayOfWeek.Sunday);
            Add(_calendarView);
        }
コード例 #2
0
ファイル: WeekDayView.cs プロジェクト: huamanhtuyen/VNACCS
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="calendarView">CalendarView</param>
        /// <param name="eCalendarView"></param>
        public WeekDayView(CalendarView calendarView, eCalendarView eCalendarView)
            : base(calendarView, eCalendarView)
        {
            // Allocate our AllDayPanel

            _AllDayPanel = new AllDayPanel(this);
            _AllDayPanel.Displayed = true;

            // Set our non-client drawing info and CalendarColor

            NClientData = new NonClientData(
                eTabOrientation.Horizontal,
                (int)eCalendarWeekDayPart.OwnerTabBorder,
                (int)eCalendarWeekDayPart.OwnerTabForeground,
                (int)eCalendarWeekDayPart.OwnerTabBackground,
                (int)eCalendarWeekDayPart.OwnerTabContentBackground,
                (int)eCalendarWeekDayPart.OwnerTabSelectedForeground,
                (int)eCalendarWeekDayPart.OwnerTabSelectedBackground);

            CalendarColorTable = _ViewColor;

            // Hook onto our events

            HookEvents(true);
        }
コード例 #3
0
 private void CalendarView_CalendarViewDayItemChanging(CalendarView sender, CalendarViewDayItemChangingEventArgs args)
 {
     if(args.Item.Date.DayOfWeek == System.DayOfWeek.Saturday || args.Item.Date.DayOfWeek == System.DayOfWeek.Sunday)
     {
         args.Item.IsBlackout = grayOutWeekend;
     }
 }
コード例 #4
0
ファイル: TimeLineView.cs プロジェクト: huamanhtuyen/VNACCS
        public TimeLineView(CalendarView calendarView, eCalendarView eCalendarView)
            : base(calendarView, eCalendarView)
        {
            // Set our non-client drawing info and CalendarColor

            NClientData = new NonClientData(
                eTabOrientation.Vertical,
                (int)eCalendarWeekDayPart.OwnerTabBorder,
                (int)eCalendarWeekDayPart.OwnerTabForeground,
                (int)eCalendarWeekDayPart.OwnerTabBackground,
                (int)eCalendarWeekDayPart.OwnerTabContentBackground,
                (int)eCalendarWeekDayPart.OwnerTabSelectedForeground,
                (int)eCalendarWeekDayPart.OwnerTabSelectedBackground);

            CalendarColorTable = _ViewColor;

            // Hook onto our events

            HookEvents(true);

            if (calendarView.TimeLineHScrollPanel.ScrollBar != null)
            {
                _HScrollPos = -calendarView.TimeLineHScrollPanel.ScrollBar.Value *
                    calendarView.TimeLineColumnWidth;
            }
        }
コード例 #5
0
ファイル: CalendarPanel.cs プロジェクト: huamanhtuyen/VNACCS
        /// <summary>
        /// Constructor.
        /// This is the main container panel for all
        /// BaseView and TimeRulerPanel objects
        /// </summary>
        /// <param name="calendarView">CalendarView</param>
        public CalendarPanel(CalendarView calendarView)
        {
            _CalendarView = calendarView;

            SetIsContainer(true);

            _CalendarView.SelectedViewChanged += _CalendarView_SelectedViewChanged;
        }
コード例 #6
0
ファイル: TimeRulerPanel.cs プロジェクト: huamanhtuyen/VNACCS
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="calendarView"></param>
        public TimeRulerPanel(CalendarView calendarView)
        {
            _CalendarView = calendarView;

            Name = "TimeRulerPanel";

            HookEvents(true);
        }
コード例 #7
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="calendarView"></param>
        public TimeLineHeaderPanel(CalendarView calendarView)
        {
            _CalendarView = calendarView;

            MouseUpNotification = true;
            Name = "TimeLineHeaderPanel";

            HookEvents(true);
        }
コード例 #8
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="calendarView">_CalendarView</param>
        public TimeLineHScrollPanel(CalendarView calendarView)
        {
            _CalendarView = calendarView;
            Name = "TimeLineHScrollPanel";

            SetUpPanel();

            Visible = false;
        }
コード例 #9
0
        private void reloadedItems(CalendarView sender, CalendarViewDayItemChangingEventArgs e)
        {
            CalendarViewDayItem cvdi = e.Item;

            if (allTasks.Contains(cvdi.Date.Date))
            {
                cvdi.Background = new SolidColorBrush(Colors.Green);
                cvdi.BorderThickness = new Thickness(2, 2, 2, 2);
                var brush = new SolidColorBrush(Color.FromArgb(1, 59, 89, 152));
                cvdi.BorderBrush = new SolidColorBrush(Colors.Blue);

            }
        }
コード例 #10
0
        private void ThumbnailsView_CalendarViewDayItemChanging(CalendarView sender, CalendarViewDayItemChangingEventArgs args)
        {
            CalendarViewDayItem dayItem = args.Item;

            if (dayItem.DataContext == null)
            {
                dayItem.DataContext = dayItem;
            }

            int count = VisualTreeHelper.GetChildrenCount(dayItem);
            TextBlock numberTextBlock = VisualTreeHelper.GetChild(dayItem, count - 1) as TextBlock;
            if (numberTextBlock != null)
            {
                numberTextBlock.Visibility = Visibility.Collapsed;
            }
        }
コード例 #11
0
        private void KalenderPerbulan_SelectedDatesChanged(CalendarView sender, CalendarViewSelectedDatesChangedEventArgs args)
        {
            var dateSelect = sender.SelectedDates.Select(p => p.Date).FirstOrDefault();
            HariIni.Text = dateSelect.ToString("dd MMMM yyyy", kulturIndonesia);

            var query = koneksiKeDatabaseJadwalSholatSQLite.Table<jadwalSholat>();
            var ini = (from jadwalSholat u in query
                       where u.tanggal == dateSelect.ToString("d/M/yyyy")
                       select u).FirstOrDefault();
            if(ini != null)
            {
                WaktuSubuh.Text = ini.fajr;
                WaktuZuhur.Text = ini.zuhr;
                WaktuAshar.Text = ini.asr;
                WaktuMaghrib.Text = ini.maghrib;
                WaktuIsya.Text = ini.isha;
            }
        }
コード例 #12
0
        private void Calendar_SelectedDatesChanged(CalendarView sender, CalendarViewSelectedDatesChangedEventArgs args)
        {
            using (var context = new Context())
            {
                IQueryable <Notification> notifications;

                switch (SignInManager.CurrentUser.Role)
                {
                case RoleEnum.AreaManager:
                {
                    notifications = context.Notification.Include(x => x.Sender).Where(x => (x.RecipientId == SignInManager.CurrentUser.Id && x.SenderId != x.RecipientId || x.RecipientId != SignInManager.CurrentUser.Id && x.SenderId == x.RecipientId && x.Type != NotificationTypeEnum.Dic));

                    break;
                }

                case RoleEnum.DispatchClerk:
                {
                    notifications = context.Notification.Include(x => x.Sender).Where(x => (x.RecipientId == SignInManager.CurrentUser.Id && x.SenderId != x.RecipientId || x.RecipientId != SignInManager.CurrentUser.Id && x.SenderId == x.RecipientId && x.Type != NotificationTypeEnum.Order));

                    break;
                }

                case RoleEnum.Administrator:
                {
                    notifications = context.Notification.Include(x => x.Sender).Where(x => (x.RecipientId == SignInManager.CurrentUser.Id && x.SenderId != x.RecipientId || x.RecipientId != SignInManager.CurrentUser.Id && x.SenderId == x.RecipientId));

                    break;
                }

                // dealer
                // sales manager
                // storemen
                default:
                {
                    notifications = context.Notification.Include(x => x.Sender).Where(x => (x.RecipientId == SignInManager.CurrentUser.Id && x.SenderId != x.RecipientId || x.RecipientId != SignInManager.CurrentUser.Id && x.SenderId == x.RecipientId && x.Type != NotificationTypeEnum.Order && x.Type != NotificationTypeEnum.Dic));

                    break;
                }
                }

                this.notifications.UpdateObservableCollection(notifications.Where(x => x.Timestamp.Date == sender.SelectedDates.FirstOrDefault().Date));
            }
        }
コード例 #13
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Movimentacoes);

            txtEntrada = FindViewById <TextView>(Resource.Id.txtEntrada);
            txtSaida   = FindViewById <TextView>(Resource.Id.txtSaida);
            txtTotal   = FindViewById <TextView>(Resource.Id.txtTotal);

            calendar = FindViewById <CalendarView>(Resource.Id.data);
            list     = FindViewById <ListView>(Resource.Id.lista);

            calendar.DateChange += Calendar_DateChange;

            dataCalendar = DateTime.Today.ToString();

            BuscarData();
        }
コード例 #14
0
		protected override void OnModelChanged (VisualElement oldModel, VisualElement newModel)
		{
			_view = (CalendarView)newModel;

			base.OnModelChanged (oldModel, newModel);

			LayoutInflater inflatorservice = (LayoutInflater) Context.GetSystemService(Android.Content.Context.LayoutInflaterService);
			var containerView = (LinearLayout)inflatorservice.Inflate (Resource.Layout.calendar_picker, null, false);

			_pickerView = containerView.FindViewById<CalendarPickerView>(Resource.Id.calendar_view);
			_pickerView.Init (new DateTime (2014, 6, 1), new DateTime (2014, 6, 30))
				.InMode (CalendarPickerView.SelectionMode.Single);

			_pickerView.OnDateSelected += (s, e) => {
				_view.NotifyDateSelected(e.SelectedDate);
			};

			SetNativeControl (containerView);
		}
コード例 #15
0
        private void renderAppointments(CalendarView sender,
                                        CalendarViewDayItemChangingEventArgs args)
        {
            if (args.Phase == 0)
            {
                //<Render basic items of the calendar>
                // Register callback for next phase.
                args.RegisterUpdateCallback(renderAppointments);
            }
            else if (args.Phase == 1)
            {
                //Blackout dates past current date
                if (args.Item.Date < DateTimeOffset.Now.AddDays(-1))
                {
                    args.Item.IsBlackout = true;
                }
                // Register callback for next phase.
                args.RegisterUpdateCallback(renderAppointments);
            }
            else if (args.Phase == 2)
            {
                //List<Windows.UI.Color> densityColors = new List<Windows.UI.Color>();

                if (args.Item.Date > DateTimeOffset.Now.AddDays(-1))
                {
                    var listView = FindFirstChildOfType <ListView>(args.Item);   //find the listview control inside the calendarViewDayItem
                    listView.Items.Clear();

                    foreach (DataRow row in dtAppointments.Rows)
                    {
                        string itemDate   = Convert.ToDateTime(args.Item.Date.ToString()).ToShortDateString();
                        string recordDate = Convert.ToDateTime(row["DateStart"]).ToShortDateString();
                        if (itemDate == recordDate)
                        {
                            //densityColors.Add(Colors.Red);

                            listView.Items.Add(row["AppType"].ToString());   //add appointment items to listview
                        }
                    }
                    //args.Item.SetDensityColors(densityColors);
                }
            }
        }
コード例 #16
0
ファイル: YearView.cs プロジェクト: huamanhtuyen/VNACCS
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="calendarView">Parent CalendarView</param>
        public YearView(CalendarView calendarView)
            : base(calendarView, eCalendarView.Year)
        {
            // Set our non-client drawing info and our CalendarColor

            NClientData = new NonClientData(
                eTabOrientation.Horizontal,
                (int)eCalendarMonthPart.OwnerTabBorder,
                (int)eCalendarMonthPart.OwnerTabForeground,
                (int)eCalendarMonthPart.OwnerTabBackground,
                (int)eCalendarMonthPart.OwnerTabContentBackground,
                (int)eCalendarMonthPart.OwnerTabSelectedForeground,
                (int)eCalendarMonthPart.OwnerTabSelectedBackground);

            CalendarColorTable = _ViewColor;

            // Hook onto needed event

            HookEvents(true);
        }
コード例 #17
0
        public bool ActivityExists(string uniqueId, DateTime startDate, DateTime endDate)
        {
            bool result = false;

            CalendarView       c     = new CalendarView(startDate, endDate);
            List <Appointment> appts = _service.FindAppointments(WellKnownFolderName.Calendar, c).ToList <Appointment>();

            foreach (Appointment a in appts)
            {
                a.Load();
                if (a.Body.Text.Contains(uniqueId))
                {
                    // Match Found
                    result = true;
                    break;
                }
            }

            return(result);
        }
コード例 #18
0
        public AppointmentRepository()
        {
            var _service = new ExchangeService
            {
                UseDefaultCredentials = true
            };

            _service.AutodiscoverUrl(_userToImpersonate);

            var folderId = new FolderId(WellKnownFolderName.Calendar, _userWhoSharedCalendar);

            _calendarFolder = CalendarFolder.Bind(_service, folderId);
            _calendarView   = new CalendarView(_daysBefore, _daysAfter)
            {
                PropertySet = new PropertySet(
                    AppointmentSchema.Subject,
                    AppointmentSchema.Start,
                    AppointmentSchema.Duration)
            };
        }
コード例 #19
0
        /// <summary>
        /// Loads all of today's sticky entries.
        /// </summary>
        /// <seealso cref="FetchUpcomingEvents"/>
        /// <seealso cref="IsSticky"/>
        private void FetchStickyEntries()
        {
            CalendarFolder calendar = CalendarFolder.Bind(_exchange, WellKnownFolderName.Calendar);
            CalendarView   view     = new CalendarView(DateTime.Today, DateTime.Today.Add(_latestEndForStickyEvents))
            {
                PropertySet = new PropertySet(ItemSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End, AppointmentSchema.Location, AppointmentSchema.MyResponseType, AppointmentSchema.IsAllDayEvent)
            };
            FindItemsResults <Appointment> appointments = calendar.FindAppointments(view);

            StickyEvents = appointments
                           .Where(IsSticky)
                           .Select(ConvertToEvent)
                           .Where(x => x.ZoomId != default)
                           .OrderBy(x => x.Subject)
                           .ThenBy(x => x.MeetingResponseOrder)
                           .ThenBy(x => x.Start)
                           .ThenBy(x => x.End)
                           .ToList()
                           .AsReadOnly();
        }
コード例 #20
0
        protected override void OnElementChanged(ElementChangedEventArgs <View> e)
        {
            base.OnElementChanged(e);

            view = (CalendarView)Element;

            if (view != null)
            {
                calendarView                 = new CalendarMonthView(view?.SelectedDate ?? DateTime.Today, false);
                calendarView.SwipedUp       += view.Hide;
                calendarView.OnDateSelected += view.NotifyDateSelected;
                calendarView.MonthChanged   += view.NotifyMonthChanged;

                try {
                    SetNativeControl(calendarView);
                } catch {
                    // Hiding calendar causes null reference exception.
                }
            }
        }
コード例 #21
0
 protected override void DisposeManagedResources()
 {
     if (this.View != null)
     {
         this.view.PropertyChanged -= new PropertyChangedEventHandler(this.view_PropertyChanged);
         this.Calendar              = (RadCalendar)null;
         this.view = (CalendarView)null;
         if (this.tableElement != null)
         {
             this.tableElement.Dispose();
             this.tableElement = (CalendarTableElement)null;
         }
         if (this.titleElement != null)
         {
             this.titleElement.Dispose();
             this.titleElement = (TitleElement)null;
         }
     }
     base.DisposeManagedResources();
 }
コード例 #22
0
ファイル: Diary.xaml.cs プロジェクト: graverpl/Pamietnik
        private void MainCalendar_SelectedDatesChanged(CalendarView sender, CalendarViewSelectedDatesChangedEventArgs args)
        {
            try
            {
                date             = MainCalendar.SelectedDates[0].ToString("yyyy-MM-dd");
                currentEntryDate = MainCalendar.SelectedDates[0].ToString("d MMMM (dddd)");
                CurrentEntryDateTextBlock.Text = $"Twój wpis z dnia {currentEntryDate}:";
            }
            catch (System.Runtime.InteropServices.COMException) { }

            try
            {
                SetText(DbConnections.ShowEntry(DbConnections.user, date));
            }
            catch (MySqlException)
            {
                SetText("Nie można pobrać zawartości...");
                ErrorInfo(Messages.ConnectionError());
            }
        }
コード例 #23
0
        private void KalenderPerbulan_SelectedDatesChanged(CalendarView sender, CalendarViewSelectedDatesChangedEventArgs args)
        {
            var dateSelect = sender.SelectedDates.Select(p => p.Date).FirstOrDefault();

            HariIni.Text = dateSelect.ToString("dd MMMM yyyy", kulturIndonesia);

            var query = koneksiKeDatabaseJadwalSholatSQLite.Table <jadwalSholat>();
            var ini   = (from jadwalSholat u in query
                         where u.tanggal == dateSelect.ToString("d/M/yyyy")
                         select u).FirstOrDefault();

            if (ini != null)
            {
                WaktuSubuh.Text   = ini.fajr;
                WaktuZuhur.Text   = ini.zuhr;
                WaktuAshar.Text   = ini.asr;
                WaktuMaghrib.Text = ini.maghrib;
                WaktuIsya.Text    = ini.isha;
            }
        }
コード例 #24
0
        private void CalenderViewSingleDate_CalendarViewDayItemChanging(CalendarView sender, CalendarViewDayItemChangingEventArgs args)
        {
            //if (isPageLoaded == false) return;

            // Render basic day items.
            if (args.Phase == 0)
            {
                // Register callback for next phase.
                args.RegisterUpdateCallback(CalenderViewSingleDate_CalendarViewDayItemChanging);
            }

            if (args.Phase == 1)
            {
                Color[] barcolors = new Color[] { Colors.Red };
                if (MainModelView.Current.CountIngredientPurchase(args.Item.Date) > 0)
                {
                    args.Item.SetDensityColors(barcolors);
                }
            }
        }
コード例 #25
0
        /// <summary>
        /// Method which occurs when CalendarView is loading.
        /// Adds density to a CalendarViewDayItem if an event is scheduled.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void CalendarView_CalendarViewDayItemChanging(CalendarView sender, CalendarViewDayItemChangingEventArgs args)
        {
            IEnumerable <Event> absences = Singleton <ClientExtensions> .Instance.AccountDetails.AbsenceEvents.Where(item => args.Item != null && item.Date.Date.Equals(args.Item.Date.Date));

            List <Color> densityList = new List <Color>();

            foreach (Event absence in absences)
            {
                if (absence.IsJustified)
                {
                    densityList.Add((Color)Application.Current.Resources["SystemAccentColor"]);
                }
                else
                {
                    densityList.Add((Color)Application.Current.Resources["HighlightColor"]);
                }
            }

            args.Item?.SetDensityColors(densityList);
        }
コード例 #26
0
        private async void TermCalendarView_SelectedDatesChanged(CalendarView sender, CalendarViewSelectedDatesChangedEventArgs args)
        {
            try
            {
                var dateOffset = TermCalendarView.SelectedDates[0];
                var date       = dateOffset.ToString("yyyy-MM-dd");
                TermTextBlock.Text = "阳历:\n" + date + "\n\n阴历:\n" + LunarCalendar.GetChineseDateTime(Convert.ToDateTime(date));
            }
            catch (System.Runtime.InteropServices.COMException e0)
            {
            }
            catch (Exception e)
            {
                MessageDialog Dialog = new MessageDialog("日期选择发生错误。\n异常类型:" + e.GetType(), "发生异常");
                await Dialog.ShowAsync();
            }

            //var date = Convert.ToDateTime(dateOffset);
            //
        }
コード例 #27
0
        /// <summary>
        /// Perform the CalendarView search and set the return Appointment
        /// collection to be returned.
        /// </summary>
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                // If no folder has been identified, warn the user
                if (this.CurrentCalendar == null)
                {
                    ErrorDialog.ShowWarning("No calendar folder selected.");
                    this.DialogResult = DialogResult.None;
                    return;
                }


                DateTime start = Convert.ToDateTime(txtStartTime.Text);
                DateTime end   = Convert.ToDateTime(txtEndTime.Text);



                CalendarView view = new CalendarView(start, end, GlobalSettings.CalendarViewSize);
                view.PropertySet = new PropertySet(BasePropertySet.FirstClassProperties);

                FindItemsResults <Appointment> appts = this.CurrentService.FindAppointments(
                    this.CurrentCalendar,
                    view);

                this.AppointmentsFound = new List <Appointment>();
                this.AppointmentsFound.AddRange(appts.Items);

                // Warn the user if more results are available that we are not displaying
                if (appts.MoreAvailable)
                {
                    ErrorDialog.ShowWarning(string.Format(DisplayStrings.WARN_CALENDARVIEW_LIMT, GlobalSettings.CalendarViewSize));
                }
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
コード例 #28
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);

            //Creación de objetos traidos desde la vista
            Button       btn        = FindViewById <Button>(Resource.Id.btnConvertir); //Así llamo el objecto al codigo
            EditText     txt        = FindViewById <EditText>(Resource.Id.txtTelefono);
            TextView     lbl        = FindViewById <TextView>(Resource.Id.lblConvertido);
            SeekBar      SeekBar    = FindViewById <SeekBar>(Resource.Id.seekBar1);
            CalendarView calendario = new CalendarView(this);

            calendario.DateChange += Calendario_DateChange;
            //Evento clickdel botton
            btn.Click += (sender, e) =>
            {
                lbl.Text = "Hoola carajitos del señor xd";
                string translatedText = PhoneTranslator.ToNumber(txt.Text);
                if (string.IsNullOrWhiteSpace(translatedText))
                {
                    lbl.Text = string.Empty;
                }
                else
                {
                    lbl.Text = translatedText;
                }


                //Android.App.AlertDialog alerta = new Android.App.AlertDialog.Builder(this).Create();

                //alerta.SetTitle("Erros");
                //alerta.SetMessage("Prueba");
                //alerta.SetButton("Cancelar",
                //            (a, b) =>
                //            {

                //            });
                //alerta.Show();
            };
        }
コード例 #29
0
        public Calendar(ExchangeService instance, DateTime start, DateTime end)
        {
            _currentView    = new CalendarView(start, end);
            _calendarFolder = CalendarFolder.Bind(instance, WellKnownFolderName.Calendar);

            Events = new List <ExistingCalendarEvent>();

            var events       = _calendarFolder.FindAppointments(_currentView);
            var meetings     = new List <Appointment>();
            var appointments = new List <Appointment>();

            var propertySet = new PropertySet(BasePropertySet.FirstClassProperties);

            propertySet.RequestedBodyType = BodyType.Text;

            foreach (var item in events)
            {
                item.Load(propertySet);
                Events.Add(new ExistingCalendarEvent(item));
            }
        }
コード例 #30
0
        private void btnGetMeetingList_Click(object sender, EventArgs e)
        {
            initialMeetingList();
            CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar);
            CalendarView   cView    = new CalendarView(DateTime.Now.AddMonths(-6), DateTime.Now.AddYears(1), int.MaxValue);

            FindItemsResults <Appointment> appointments = calendar.FindAppointments(cView);
            var items = appointments.Items.OrderByDescending(x => x.DateTimeReceived);

            this.listViewMeeting.View = View.Details;
            this.listViewMeeting.Items.Clear();
            foreach (Appointment item in items)
            {
                var listViewItem = new ListViewItem(new[] { item.Id.UniqueId, item.Organizer.Name, item.DisplayTo, item.Subject, item.DateTimeReceived.ToString(), item.MyResponseType.ToString() });
                this.listViewMeeting.Items.Add(listViewItem);
            }

            GetReminders();
            this.txtLogForMeeting.Text = "Get meeting list success\r\nEWS API:CalendarFolder.Bind\r\nLocation:..\\EWS\\EWS\\Form1.cs line(112, 116, 132, 136)\r\n" +
                                         "EWS API:FindAppointments\r\nLocation:..\\EWS\\EWS\\Form1.cs line(112, 116, 132, 136)\r\n\r\n";
        }
コード例 #31
0
    private void MyCalendarView_SelectedDatesChanged(CalendarView sender, CalendarViewSelectedDatesChangedEventArgs args)
    {
        bool add = false;

        //If we double click the CalendarViewDayItem, the second time args.AddedDates.Count is 0
        if (args.AddedDates.Count >= 1)
        {
            var newDate = args.AddedDates[0];
            for (int i = 0; i < times.Count; i++)
            {
                if (newDate.Date.Year == times[i].MyDateTime.Year && newDate.Date.Month == times[i].MyDateTime.Month && newDate.Date.Day == times[i].MyDateTime.Day)
                {
                    add = true;
                }
            }
            if (!add)
            {
                times.Add(new DayItem(newDate.DateTime, Colors.Green));
            }
        }
    }
コード例 #32
0
 private void CalendarView_CalendarViewDayItemChanging(CalendarView sender,
                                                       CalendarViewDayItemChangingEventArgs args)
 {
     // Render basic day items.
     if (args.Phase == 0)
     {
         // Register callback for next phase.
         args.RegisterUpdateCallback(CalendarView_CalendarViewDayItemChanging);
     }
     // Set blackout dates.
     else if (args.Phase == 1)
     {
         // Blackout dates in the future
         if (args.Item.Date > DateTimeOffset.Now)
         {
             args.Item.IsBlackout = true;
         }
         // Register callback for next phase.
         args.RegisterUpdateCallback(CalendarView_CalendarViewDayItemChanging);
     }
 }
コード例 #33
0
        public CalendarPage()
        {
            InitializeComponent();
            _stacker = new StackLayout();
            Content  = _stacker;

            _calendarView = new CalendarView()
            {
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.CenterAndExpand
            };
            _stacker.Children.Add(_calendarView);
            _calendarView.DateSelected += (object sender, DateTime e) => {
                _stacker.Children.Add(new Label()
                {
                    Text              = "Date Was Selected" + e.ToString("d"),
                    VerticalOptions   = LayoutOptions.Start,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                });
            };
        }
コード例 #34
0
        private async void ExecuteCalendarDialog()
        {
            CalendarView view = new CalendarView
            {
                DataContext = new CalendarViewModel()
            };

            ((CalendarViewModel)view.DataContext).SelectedDate = TrackingDate;

            // show the dialog
            var result = await DialogHost.Show(view, "RootDialog");

            bool selectedOk = (bool)result;

            if (selectedOk)
            {
                TrackingDate = ((CalendarViewModel)view.DataContext).SelectedDate;
                TaskViewModelsView.Refresh();
                UpdateTotalTime();
            }
        }
コード例 #35
0
        private IList <IRoom> FillRoom(string room, CalendarView cv)
        {
            IList <IRoom> roomList = FillCalendarDay();

            String   mailboxToAccess  = room;
            FolderId calendarFolderId = new FolderId(WellKnownFolderName.Calendar, mailboxToAccess);

            IList <Appointment> appointments = _exchangeService.FindAppointments(calendarFolderId, cv).ToList();

            foreach (var appointment in appointments)
            {
                IRoom result = new Room();
                result.Organizer = appointment.Organizer.Name;
                result.Subject   = string.IsNullOrEmpty(appointment.Subject) ? "No subject" : appointment.Subject;
                result.Start     = appointment.Start.ToShortTimeString();
                result.End       = appointment.End.ToShortTimeString();
                result.IsFree    = false;
                roomList.Add(result);
            }
            return(roomList);
        }
コード例 #36
0
        private void WeekView_Click(object sender, RoutedEventArgs e)
        {
            localDateTime = DateTime.Now;
            try
            {
                webinars = WebinarApiInstance.GetWeekWebinars(token, StartOfWeek(localDateTime));
            }
            catch (Exception ex) { }

            weekendView = true;

            WeekView.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#0A67A3"));
            WeekView.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ffffff"));

            Date.Text    = StartOfWeek(localDateTime).ToString("dd") + " - " + EndOfWeek(localDateTime).ToString("dd") + " " + localDateTime.ToString("MMMM", CultureInfo.GetCultureInfo("ru-ru"));
            weekNum.Text = WeekNum(localDateTime) + " неделя";
            CalendarView.Navigate(new WeekCalendar(webinars, localDateTime));

            DayView.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF8E00"));
            DayView.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#000000"));
        }
コード例 #37
0
ファイル: HomeService.cs プロジェクト: aatkuri/GDPOfficeHours
        public List <EventsItem> LoadAppointments(string email, string password)
        {
            List <EventsItem> eventsItems = new List <EventsItem>();

            DateTime startDate = DateTime.Now;
            DateTime endDate   = startDate.AddDays(7);

            try
            {
                CalendarFolder calendar = FindNamedCalendarFolder("officehours", email, password);  // or
                //CalendarFolder calendar = FindDefaultCalendarFolder(email, password);

                CalendarView cView = new CalendarView(startDate, endDate, 50);
                cView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.When, AppointmentSchema.Start, AppointmentSchema.End, AppointmentSchema.Id);
                FindItemsResults <Appointment> appointments = calendar.FindAppointments(cView);

                if (appointments != null && appointments.Any())
                {
                    foreach (var appt in appointments)
                    {
                        eventsItems.Add(
                            new EventsItem
                        {
                            Id         = appt.Id.ToString(),
                            Subject    = appt.Subject,
                            EventDate  = DateTime.Parse(appt.Start.ToString()).Date,
                            EventDay   = DateTime.Parse(appt.Start.ToString()).DayOfWeek,
                            EventStart = DateTime.Parse(appt.Start.ToString()).ToString("t"),
                            EventEnd   = DateTime.Parse(appt.End.ToString()).ToString("t"),
                        });
                    }
                }

                return(eventsItems);
            }
            catch
            {
                throw;
            }
        }
コード例 #38
0
        /// <summary>
        /// Rechaza un Appointment
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="password"></param>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <param name="id"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public string DeclineAppointment(string userId, string password, string id, string mess)
        {
            try
            {
                Console.WriteLine("Init");
                service             = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
                credentials         = new WebCredentials(userId, password);
                service.Credentials = credentials;
                service.Url         = new Uri("https://mail.migesa.com.mx/ews/exchange.asmx");

                DateTime startDate = DateTime.Now.AddMonths(-6);
                DateTime endDate   = DateTime.Now.AddMonths(6);
                // Initialize the calendar folder object with only the folder ID.
                CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet());

                // Set the start and end time and number of appointments to retrieve.
                CalendarView cView = new CalendarView(startDate, endDate);

                // Limit the properties returned to the appointment's subject, start time, and end time.
                cView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End);

                // Retrieve a collection of appointments by using the calendar view.
                FindItemsResults <Microsoft.Exchange.WebServices.Data.Appointment> appointments = calendar.FindAppointments(cView);
                negocio.Entidades.Appointment appoint = null;
                foreach (Microsoft.Exchange.WebServices.Data.Appointment a in appointments)
                {
                    a.Load();
                    if (a.Id.ToString() == id)
                    {
                        a.Decline(true);
                    }
                }
                return("");
            }
            catch (Exception ex)
            {
                exchangeInitialized = false;
                return(ex.Message);
            }
        }
コード例 #39
0
        /// <summary>
        /// Sucht alle Termine von Heute bis 31.12. nächstes Jahr die die Kategorie "autogenerated by Arges IT"
        /// und im Subject entweder "Geburtstag von " oder "Jahrestag von " + übergebener Name stehen haben und löscht diese.
        /// </summary>
        /// <param name="name">Der Name des Kontaktes, dessen Geburtstag und Jahrestag gesucht wird.</param>
        public void deleteName(string name)
        {
            // Initialize values for the start and end times, and the number of appointments to retrieve.
            DateTime startDate = DateTime.Now;
            var      yearStr   = startDate.AddYears(1);
            var      yearStr2  = "12/31/" + yearStr.Year.ToString();
            DateTime endDate   = DateTime.ParseExact(yearStr2, "MM/dd/yyyy", CultureInfo.InvariantCulture);
            // Initialize the calendar folder object with only the folder ID.
            CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet());
            // Set the start and end time and number of appointments to retrieve.
            CalendarView cView = new CalendarView(startDate, endDate, 500);

            // Limit the properties returned to the appointment's subject, start time, and end time.
            cView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End, AppointmentSchema.Categories);
            // Retrieve a collection of appointments by using the calendar view.
            //FindItemsResults<Appointment> appointments = calendar.FindAppointments(cView);

            //Läuft über alle Kalendereinträge
            FindItemsResults <Appointment> appointments;
            var total = 0;

            do
            {
                appointments = calendar.FindAppointments(cView);

                //Läuft über alle Kalendereinträge
                foreach (Appointment a in appointments)
                {
                    if (a.Categories.Contains("autogenerated by Arges IT") && (a.Subject.Contains("Geburtstag von " + name) || a.Subject.Contains("Jahrestag von " + name)))
                    {
                        a.Delete(DeleteMode.HardDelete);
                    }
                }

                cView.StartDate = appointments.Items[appointments.Items.Count - 1].Start;
                total          += appointments.Items.Count;
            } while (appointments.MoreAvailable);

            //ExchangeSync.writeLog(SMTPAdresse + " - Geburtstage und Jahrestage von " + name + " wegen löschung in PublicFolder gelöscht");
        }
コード例 #40
0
 private void CalendarView_CalendarViewDayItemChanging(CalendarView sender,
                                                       CalendarViewDayItemChangingEventArgs args)
 {
     try
     {
         // Render basic day items.
         if (args.Phase == 0)
         {
             // Register callback for next phase.
             args.RegisterUpdateCallback(CalendarView_CalendarViewDayItemChanging);
         }
         // Set blackout dates.
         else if (args.Phase == 1)
         {
             // Blackout dates in the past, Sundays, and dates that are fully booked.
             if (args.Item.Date < DateTimeOffset.Now ||
                 args.Item.Date.DayOfWeek == DayOfWeek.Sunday)
             {
                 args.Item.IsBlackout = true;
             }
             // Register callback for next phase.
             args.RegisterUpdateCallback(CalendarView_CalendarViewDayItemChanging);
         }
         // Set density bars.
         else if (args.Phase == 2)
         {
             foreach (var Event in _sortedEvents)
             {
                 if (args.Item.Date.Equals(Event.Date))
                 {
                     args.Item.Background = red;
                 }
             }
         }
     }
     catch (Exception Expection)
     {
         // Handle the exception <3
     }
 }
コード例 #41
0
        public IHttpActionResult GetDetails(GetAppointmentsRequest request)
        {
            var startDate = DateTime.Parse(request.Start);
            var endDate   = DateTime.Parse(request.End);
            // Assuming 8 max per day * 5 (days/week) * 4 (weeks/month)
            const int NUM_APPTS = 160;
            var       calendar  = CalendarFolder.Bind(ExchangeServer.Open(), WellKnownFolderName.Calendar, new PropertySet());
            var       cView     = new CalendarView(startDate, endDate, NUM_APPTS);

            cView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End, AppointmentSchema.TimeZone);



            FindItemsResults <Appointment> appointments = calendar.FindAppointments(cView);

            var response = new GetAppointmentsResponse();
            var list     = new List <Interview>();

            foreach (var app in appointments)
            {
                var appointment = Appointment.Bind(ExchangeServer.Open(), app.Id);

                var attendees = new List <RequiredAttendees>();
                foreach (var required in appointment.RequiredAttendees)
                {
                    attendees.Add(new RequiredAttendees
                    {
                        Name     = required.Name,
                        Email    = required.Address,
                        Response = required.ResponseType.ToString()
                    });
                }

                list.Add(new Interview {
                    Start = app.Start, End = app.End, TimeZone = app.TimeZone, Attendees = attendees, Subject = app.Subject
                });
            }
            response.Appointments = list;
            return(Ok(response));
        }
コード例 #42
0
        private void calendar_SelectedDatesChanged(CalendarView sender, CalendarViewSelectedDatesChangedEventArgs args)
        {
            var calendar     = ((CalendarView)sender);
            var selectedDate = args.AddedDates?.FirstOrDefault();

            if (selectedDate == null || !selectedDate.HasValue || selectedDate.Value == DateTimeOffset.MinValue)
            {
                return;
            }
            var            flyout = new MenuFlyout();
            MenuFlyoutItem flyoutItem;
            var            eventsOfDay = CalendarEvents?.Where(x => x.EventDate.Day == selectedDate.Value.Day && x.EventDate.Month == selectedDate.Value.Month && x.EventDate.Year == selectedDate.Value.Year);

            if (eventsOfDay != null && eventsOfDay.Count() > 0)
            {
                calendar.ContextFlyout = flyout;
                foreach (var item in eventsOfDay)
                {
                    flyoutItem             = new MenuFlyoutItem();
                    flyoutItem.DataContext = item;
                    flyoutItem.Text        = item.EventName ?? " ";
                    flyoutItem.Click      += MenuFlyoutItem_Click;
                    flyoutItem.Foreground  = new SolidColorBrush(item.EventColor);
                    flyout.Items.Add(flyoutItem);
                }
            }
            calendar.ContextFlyout = flyout;
            flyoutItem             = new MenuFlyoutItem();
            flyoutItem.DataContext = new EventCalendarView {
                EventDate = selectedDate.Value.DateTime.Date, Contacts = new GeneralCategory {
                    Date = selectedDate.Value.DateTime, CategoryContacts = new List <CategoryContact>(), Color = "#FFFFFFFF"
                }, EventColor = Colors.LightGray
            };
            flyoutItem.Text       = "Добавить событие";
            flyoutItem.Click     += MenuFlyoutItem_Click;
            flyoutItem.Foreground = new SolidColorBrush(Colors.LightGray);
            flyout.Items.Add(flyoutItem);
            flyout.ShowAt(this, pointerPosition);
        }
コード例 #43
0
        public Week()
        {
            InitializeComponent();

            WebinarApiInstance = new WebinApi();
            UserApiInstance    = new UserApi();
            try
            {
                token    = Application.Current.Resources["token"].ToString();
                user     = UserApiInstance.GetUserInfo(token);
                webinars = WebinarApiInstance.GetWeekWebinars(token, StartOfWeek(localDateTime));
            } catch (Exception e) { }

            AccountName.Text = user.LastName + " " + user.FirstName;

            localWebinar = FindCurrentWebinar(webinars);
            InfoBlock.Navigate(new WebinarInfo(localWebinar));

            CalendarView.Navigate(new WeekCalendar(webinars, localDateTime));
            Date.Text    = StartOfWeek(localDateTime).ToString("dd") + " - " + EndOfWeek(localDateTime).ToString("dd") + " " + localDateTime.ToString("MMMM", CultureInfo.GetCultureInfo("ru-ru"));
            weekNum.Text = WeekNum(localDateTime) + " неделя";
        }
コード例 #44
0
        protected override void OnAppearing()
        {
            base.OnAppearing();

            var calendar = new CalendarView {
                HeightRequest = 350,
            };

            Content = new ScrollView
            {
                Content = new StackLayout
                {
                    Padding = 10,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    VerticalOptions = LayoutOptions.StartAndExpand,
                    Orientation = StackOrientation.Vertical,
                    Children = {
                        calendar
                    }
                }
            };
        }
コード例 #45
0
        private void CalendarView_SelectedDatesChanged(CalendarView sender, CalendarViewSelectedDatesChangedEventArgs args)
        {
            var selectedDates = sender.SelectedDates.Select(p => p.DateTime.Date);

            var tDates = from p in allTasks where p == selectedDates.First() select p;
            if(tDates.Count() == 0)
            {
                Page1.CurrentItem = null;
                this.Frame.Navigate(typeof(Page1));
            }
            else if(tDates.Count() == 1){
                
                Page1.CurrentItem = (from a in TTasks where a.datetime.Date == selectedDates.First() select a).First();
                this.Frame.Navigate(typeof(Page1));

            }
            else
            {
                Page4.taskdate = selectedDates.First();
                this.Frame.Navigate(typeof(Page4));
            }
            
            
        }
コード例 #46
0
 public WeekDayVScrollPanel(CalendarView calendarView)
     : base(calendarView)
 {
 }
コード例 #47
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="calendarView"></param>
 public TimeLineVScrollPanel(CalendarView calendarView)
     : base(calendarView)
 {
 }
コード例 #48
0
 private void Cl_SelectedDatesChanged(CalendarView sender, CalendarViewSelectedDatesChangedEventArgs args)
 {
     var x = sender.SelectedDates.Select(p => p.Date.Month.ToString() + "/" + p.Date.Day.ToString()).ToArray();
     Date.Text = String.Join(", ", x);
 }
コード例 #49
0
 private void MyCalendarView_SelectedDatesChanged(CalendarView sender, CalendarViewSelectedDatesChangedEventArgs args)
 {
     var selectedDates = sender.SelectedDates.Select(p => p.Date.Month.ToString() + "/" + p.Date.Day.ToString()).ToArray();
     var values = string.Join(", ", selectedDates);
     CalendarViewResultTextBlock.Text = values;
 }
コード例 #50
0
 private void Calendar_OnSelectedDatesChanged(CalendarView sender, CalendarViewSelectedDatesChangedEventArgs args)
 {
     calendar.Visibility = Visibility.Collapsed;
     gvHour.Visibility = Visibility.Visible;
     gvMinute.Visibility = Visibility.Collapsed;
 }
コード例 #51
0
 public YearVScrollPanel(CalendarView calendarView)
     : base(calendarView)
 {
 }
コード例 #52
0
ファイル: VScrollPanel.cs プロジェクト: huamanhtuyen/VNACCS
        private VScrollBarAdv _ScrollBar;       // Scroll bar
        #endregion

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="calendarView"></param>
        public VScrollPanel(CalendarView calendarView)
        {
            CalendarView = calendarView;

            SetUpScrollBar();
        }
コード例 #53
0
ファイル: TimeIndicator.cs プロジェクト: huamanhtuyen/VNACCS
        /// <summary>
        /// Gets whether the indicator is visible
        /// in the given view 
        /// </summary>
        /// <param name="calendarView"></param>
        /// <param name="view"></param>
        /// <returns></returns>
        internal bool IsVisible(CalendarView calendarView, BaseView view)
        {
            if (_Visibility == eTimeIndicatorVisibility.Hidden)
                return (false);

            if (_Visibility == eTimeIndicatorVisibility.AllResources)
                return (true);

            return ((calendarView == null || view.DisplayedOwnerKeyIndex == -1 ||
                calendarView.SelectedOwnerIndex == view.DisplayedOwnerKeyIndex));
        }
コード例 #54
0
        private void Calendar_CalendarViewDayItemChanging(CalendarView sender, CalendarViewDayItemChangingEventArgs args)
        {
            // Render basic day items.
            if (args.Phase == 0)
            {
                // Register callback for next phase.
                args.RegisterUpdateCallback(Calendar_CalendarViewDayItemChanging);
            }
            // Set blackout dates.
            else if (args.Phase == 1)
            {
                // Register callback for next phase.
                args.RegisterUpdateCallback(Calendar_CalendarViewDayItemChanging);
            }
            // Set density bars.
            else if (args.Phase == 2)
            {
                // Avoid unnecessary processing.
                // You don't need to set bars on past dates
                if (args.Item.Date >= DateTimeOffset.Now)
                {
                    var spEvents = (DataContext as CortanaCalendarViewModel).CortanaAppointments.Where(app => app.StartDate.Date == args.Item.Date.Date);

                    List<Color> densityColors = new List<Color>();
                    // Set a density bar color for each of the days bookings.
                    // It's assumed that there can't be more than 10 bookings in a day. Otherwise,
                    // further processing is needed to fit within the max of 10 density bars.
                    int cpt = 0;
                    foreach (var spEvent in spEvents.TakeWhile(a => cpt < 10))
                    {
                        cpt++;
                        densityColors.Add(Colors.Cyan);
                    }
                    args.Item.SetDensityColors(densityColors);
                }
            }
        }
コード例 #55
0
ファイル: WeekView.cs プロジェクト: huamanhtuyen/VNACCS
 public WeekView(CalendarView calendarView)
     : base(calendarView, eCalendarView.Week)
 {
 }
コード例 #56
0
 protected virtual DateTime GetDateForCalendar(CalendarView calendar)
 {
     return calendar.SelectedDates.Any()
         ? calendar.SelectedDates.First().Date
         : DateTime.MinValue;
 }
コード例 #57
0
ファイル: Scheduling.cs プロジェクト: matteomigliore/HSDK
		public static CalendarRange Range(
			DateTime date,
			CalendarView vista,
			DayOfWeek firstDayOfWeek = DayOfWeek.Monday,
			DayOfWeek lastDayOfWeek = DayOfWeek.Sunday)
		{
			var selectedDate = date.Date;

			var firstDay = selectedDate.FirstDayOfWeek();

			if (vista == CalendarView.Day)
			{
				firstDay = date;
			}

			if (vista != CalendarView.Month)
			{
				var dates =
					Enumerable
						.Range(0, (int)vista)
						.Select(dayCount => firstDay.AddDays(dayCount))
						.ToList();

				return new CalendarRange(dates.First(), dates.Last());
			}

			var firstDayOfMonth = date.FirstDayOfMonth();
			var first = firstDayOfMonth.FirstDayOfWeek(firstDayOfWeek);

			var lastDayOfMonth = date.LastDayOfMonth();
			var last = lastDayOfMonth.LastDayOfWeek(lastDayOfWeek);

			return new CalendarRange(first, last);
		}
コード例 #58
0
ファイル: MainPage.xaml.cs プロジェクト: danlo8600/Wallet
 private void selectedDate_Click(CalendarView sender, CalendarViewSelectedDatesChangedEventArgs args)
 {
 }
コード例 #59
0
        /// <summary>
        ///     Generates a new task panel
        /// </summary>
        /// <param name="cl">Class to generate it for</param>
        /// <param name="parent">ListView associated with the class</param>
        /// <param name="task">Task to add</param>
        /// <returns>A new ListViewItem for the task</returns>
        public static ListViewItem GenerateTaskPanel(Class cl, ListView parent, Task task)
        {
            #region Containers

            // Create the content area
            Grid content = new Grid
            {
                Margin = new Thickness(0),
                Height = 75,
                Background = MainPage.LightGrayBrush,
                Tag = "Task"
            };

            // Create the list of content items and a delegate to add them to the list
            List<UIElement> contentItems = new List<UIElement>();
            Action<UIElement> registerItem = i => { contentItems.Add(i); };

            // The main ListViewItem
            ListViewItem panel = new ListViewItem
            {
                Background = MainPage.TransparentBrush,
                Margin = new Thickness(0, 0, 0, 5),
                Height = 75,
                Tag = false, // Is Panel Expanded
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                VerticalContentAlignment = VerticalAlignment.Top,
                Padding = new Thickness(0),
                BorderBrush = MainPage.MediumGrayBrush,
                BorderThickness = new Thickness(1),
            };

            #endregion

            #region Title

            // Task title
            TextBlock title = new TextBlock
            {
                Text = task.Title.Trim(),
                TextAlignment = TextAlignment.Left,
                FontSize = 25,
                Foreground = MainPage.BlueBrush,
                Margin = new Thickness(5, 0, 0, 0)
            };
            // Sizing
            title.Measure(new Size(0, 0));
            title.Arrange(new Rect(0, 0, 0, 0));
            registerItem(title);

            #endregion

            #region Finish Button

            // The check mark that marks the task as completed
            Button finish = new Button
            {
                FontFamily = Icons.IconFont,
                Content = task.Complete == 1 ? Icons.Cancel : Icons.Accept,
                Margin = new Thickness(title.ActualWidth + 5, 5, 0, 0),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top,
                Background = MainPage.TransparentBrush
            };

            // Remove the task when the button is pressed
            finish.Tapped += (sender, args) => { TaskList.RemoveTask(cl, parent, panel, task); };
            registerItem(finish);

            #endregion

            #region Info Box

            // Info box
            TextBox info = new TextBox
            {
                TextAlignment = TextAlignment.Left,
                Foreground = new SolidColorBrush(Color.FromArgb(255, 50, 50, 50)),
                HorizontalAlignment = HorizontalAlignment.Left,
                TextWrapping = TextWrapping.Wrap,
                BorderThickness = new Thickness(0),
                AcceptsReturn = true,
                Width = parent.Width / 3 + 25,
                Tag = false, // Edit mode
                IsReadOnly = true, // Edit mode property
                Background = MainPage.TransparentBrush, // Edit mode property
                IsHitTestVisible = false // Edit mode property
            };

            // Add the text - only works if you append each character
            foreach (char c in task.Info)
            {
                info.Text += c.ToString();
            }

            // Border around the info box
            Border infoBorder = new Border
            {
                Child = info,
                Background = MainPage.MediumGrayBrush,
                Margin = new Thickness(5, 36, 0, 7),
                HorizontalAlignment = HorizontalAlignment.Left,
                BorderThickness = new Thickness(0),
                Padding = new Thickness(0)
            };
            registerItem(infoBorder);

            // Edit button for the info box
            Button edit = new Button
            {
                FontFamily = Icons.IconFont,
                Content = Icons.Edit,
                Width = 20,
                Height = 20,
                FontSize = 10,
                Padding = new Thickness(0),
                Background = MainPage.TransparentBrush,
                VerticalAlignment = VerticalAlignment.Bottom,
                HorizontalAlignment = HorizontalAlignment.Left,
                Margin = new Thickness(parent.Width / 3 + 10, 36, 0, 7)
            };

            // Toggles edit mode for the info box
            edit.Click += (sender, args) =>
            {
                if (!(bool) info.Tag)
                {
                    info.Tag = true;
                    edit.Content = Icons.Save;
                    info.IsReadOnly = false;
                    info.Background = new SolidColorBrush(Colors.White);
                    info.IsHitTestVisible = true;
                    info.Focus(FocusState.Pointer);
                    info.SelectionStart = info.Text.Length;
                    info.SelectionLength = 0;
                } else
                {
                    info.Tag = false;
                    edit.Content = Icons.Edit;
                    info.IsReadOnly = true;
                    info.Background = MainPage.MediumGrayBrush;
                    info.IsHitTestVisible = false;
                    DataHandler.EditTask(task.Id, "Info", info.Text);
                }
            };
            registerItem(edit);

            #endregion

            #region Circular Progress Bar

            // Progress bar background (gray)
            CircularProgressBar progressBack = new CircularProgressBar
            {
                Percentage = 100,
                SegmentColor = MainPage.MediumGrayBrush,
                Radius = 30,
                StrokeThickness = 5,
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment = VerticalAlignment.Top,
                Margin = new Thickness(0, 2.75, 2.75 + 30, 0)
            };
            registerItem(progressBack);

            // Progress bar foreground (blue)
            CircularProgressBar progressFront = new CircularProgressBar
            {
                Percentage = 0,
                SegmentColor = MainPage.BlueBrush,
                Radius = 30,
                StrokeThickness = 5,
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment = VerticalAlignment.Top,
                Margin = new Thickness(0, 2.75, 2.75 + 30, 0),
                Transitions = new TransitionCollection()
            };
            registerItem(progressFront);

            // Text inside the progress bar that shows the time remaining
            TextBlock timeLeft = new TextBlock
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                Text = string.Empty,
                FontSize = 12,
                Foreground = MainPage.BlueBrush,
                TextAlignment = TextAlignment.Center
            };

            // Helps with alignment for the progress bar
            Border border = new Border
            {
                BorderBrush = MainPage.BlueBrush,
                BorderThickness = new Thickness(0),
                Child = timeLeft,
                Height = 70,
                Width = 70,
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment = VerticalAlignment.Top,
                Margin = progressFront.Margin
            };
            registerItem(border);

            // Delegate for
            Action updateProgress = () =>
            {
                // Clamp the progress to 100%
                progressFront.Percentage = Math.Min(Util.GetPercentTime(task) * 100, 100);

                // Finished tasks get an orange color
                bool finished = false;
                if (progressFront.Percentage.Equals(100.0))
                {
                    finished = true;
                    progressFront.SegmentColor = MainPage.OrangeRedBrush;
                    timeLeft.Foreground = MainPage.OrangeRedBrush;
                }

                // Set the new text
                timeLeft.Text = $"{Util.GetTimeString(task)}{(finished ? " ago" : string.Empty)}";
            };
            updateProgress();

            // Update the progress every second
            ThreadPoolTimer.CreatePeriodicTimer(
                async poolTimer =>
                {
                    await progressFront.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { updateProgress(); });
                },
                new TimeSpan(0, 0, 0, 1));

            #endregion

            #region Assigned/Due Times

            // Assigned/due info
            RichTextBlock timeInfo = new RichTextBlock
            {
                FontSize = 14,
                Margin = new Thickness(-5),
                TextAlignment = TextAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Stretch,
                TextWrapping = TextWrapping.NoWrap
            };

            // "Assigned on" and "Due on" text
            // Separated with different colors
            Run assignedText = new Run
            {
                Text = "Assigned: ",
                Foreground = MainPage.BlueBrush
            };

            Run assignedDate = new Run
            {
                Text = $"{task.AssignedOn}",
                Foreground = MainPage.GreenBrush
            };

            Run dueText = new Run
            {
                Text = "Due: ",
                Foreground = MainPage.BlueBrush
            };

            Run dueDate = new Run
            {
                Text = $"{task.DueOn}",
                Foreground = MainPage.OrangeRedBrush
            };

            // Set up lines
            Paragraph p1 = new Paragraph();
            p1.Inlines.Add(assignedText);
            p1.Inlines.Add(assignedDate);

            Paragraph p2 = new Paragraph();
            p2.Inlines.Add(dueText);
            p2.Inlines.Add(dueDate);

            // Add the info to the text box
            timeInfo.Blocks.Add(p1);
            timeInfo.Blocks.Add(p2);

            // Container for time info
            Border timeInfoBorder = new Border
            {
                Child = timeInfo,
                BorderBrush = MainPage.BlueBrush,
                BorderThickness = new Thickness(0),
                Margin = new Thickness(parent.Width / 3 + 35, 36, 105, 5),
                Padding = new Thickness(0),
                VerticalAlignment = VerticalAlignment.Stretch
            };
            registerItem(timeInfoBorder);

            #endregion

            #region Expand Button

            // Button that expands the box
            Button expand = new Button
            {
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment = VerticalAlignment.Top,
                Height = 73,
                Width = 25,
                Margin = new Thickness(0, 0, 0, 0),
                Content = Icons.Down,
                FontFamily = Icons.IconFont,
                Padding = new Thickness(0)
            };

            // This makes sure all other task panels collapse smoothly if a new one is opened
            expand.Tapped += (sender, args) =>
            {
                // Get the new height based on the tag that tells you if the panel is open or closed
                int to = !(bool) panel.Tag ? 412 : 75;

                // Set the new button content to the opposite arrow
                expand.Content = !(bool) panel.Tag ? Icons.Up : Icons.Down;

                // If the panel is not opened
                if (!(bool) panel.Tag)
                {
                    // For each task that is open and has content
                    foreach (ListViewItem item in parent.Items.Cast<ListViewItem>()
                        .Where(item => (bool?) item.Tag ?? false && item.Content != null))
                    {
                        // If the grid content is not null and the grid tag is not null
                        if (!((item.Content as Grid)?.Tag as bool? ?? false))
                        {
                            // Find the button in the grid that has the Up icon
                            foreach (Button btn in (item.Content as Grid).Children.OfType<Button>()
                                .Where(btn => (string) btn.Content == Icons.Up))
                            {
                                // ... And change it to the down icon
                                btn.Content = Icons.Down;
                            }

                            // Collapse the panel
                            Util.CreateAnimation(150, item, null, 75, "Height").Begin();

                            // Set the tag to false indicating the panel is closed
                            item.Tag = false;
                        }
                    }
                }

                // Once all other panels have been collapsed, expand the new one
                Util.CreateAnimation(150, panel, null, to, "Height").Begin();

                // Set its tag appropriately
                panel.Tag = !(bool) panel.Tag;
            };

            registerItem(expand);

            #endregion

            #region Calendar

            // Calendar showing date assigned, date due, today
            CalendarView calendar = new CalendarView
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Top,
                SelectionMode = CalendarViewSelectionMode.None,
                BlackoutForeground = new SolidColorBrush(Colors.White),
                Background = MainPage.MediumGrayBrush,
                CalendarItemBackground = MainPage.TransparentBrush,
                BorderBrush = MainPage.TransparentBrush,
                CalendarItemBorderBrush = MainPage.TransparentBrush,
                OutOfScopeBackground = MainPage.TransparentBrush,
                OutOfScopeForeground = new SolidColorBrush(Colors.Gray),
                Margin = new Thickness(parent.Width / 3 + 35, 75, 3, 5),
            };

            // Override item rendering to change colors
            calendar.CalendarViewDayItemChanging += (sender, args) =>
            {
                if (args.Item == null)
                {
                    return;
                }
                DateTime day = args.Item.Date.DateTime;
                if (day.Date == DateTime.Parse(task.AssignedOn.ToString()).Date)
                {
                    args.Item.Background = MainPage.GreenBrush;
                    args.Item.IsBlackout = true; // Hack to change the foreground color
                } else if (day.Date == DateTime.Parse(task.DueOn.ToString()).Date)
                {
                    args.Item.Background = MainPage.OrangeRedBrush;
                    args.Item.IsBlackout = true;
                }
                if (day.Date == DateTime.Today)
                {
                    args.Item.IsBlackout = false;
                }
            };
            calendar.SetDisplayDate(DateTime.Today);
            registerItem(calendar);

            #endregion

            #region Sizing and Creation

            // Sizing
            parent.SizeChanged += (sender, args) =>
            {
                info.Width = args.NewSize.Width / 3 + 25;
                edit.Margin = new Thickness(args.NewSize.Width / 3 + 10, 36, 0, 7);
                calendar.Margin = new Thickness(args.NewSize.Width / 3 + 35, 75, 3, 5);
                timeInfoBorder.Margin = new Thickness(args.NewSize.Width / 3 + 35, 36, 105, 5);
            };

            panel.SizeChanged += (sender, args) => { content.Height = args.NewSize.Height; };

            // Add each element in the contentItems list
            foreach (UIElement element in contentItems)
            {
                content.Children.Add(element);
            }

            // Set the container content
            panel.Content = content;

            return panel;

            #endregion
        }
コード例 #60
0
 private void CalendarView_SelectedDatesChanged(CalendarView sender, CalendarViewSelectedDatesChangedEventArgs args)
 {
     IList<DateTimeOffset> selectedDates = (sender as CalendarView).SelectedDates;
     if (selectedDates != null && selectedDates.Count > 0)
     {
         appointmentsList.ItemsSource = (DataContext as CortanaCalendarViewModel).CortanaAppointments.Where(app => app.StartDate.Date == selectedDates[0].Date);
     }
 }