Exemple #1
0
 public MainWindow()
 {
     InitializeComponent();
     customeEditor      = new CustomEditor(this.Schedule.Appointments);
     SourceInitialized += (s, a) =>
     {
         customeEditor.Owner = this;
     };
 }
 void pasteButton_Click(object sender, RoutedEventArgs e)
 {
     RadialPopup.IsOpen = false;
     if (this.copiedAppointment != null)
     {
         Appointment app         = this.copiedAppointment;
         TimeSpan    appTimeDiff = app.EndTime - app.StartTime;
         Appointment appointment = new Appointment();
         appointment.Subject  = app.Subject;
         appointment.Notes    = app.Notes;
         appointment.Location = app.Location;
         appointment.ReadOnly = app.ReadOnly;
         appointment.AppointmentBackground = app.AppointmentBackground;
         appointment.AppointmentTime       = this.CurrentSelectedDate.ToString("hh:mm tt");
         appointment.AppointmentType       = app.AppointmentType;
         CustomEditor.SetImageForAppointment(appointment);
         appointment.StartTime = (DateTime)this.CurrentSelectedDate;
         appointment.EndTime   = ((DateTime)this.CurrentSelectedDate).Add(appTimeDiff);
         Schedule.Appointments.Add(appointment);
     }
 }
        public MainWindow()
        {
            InitializeComponent();
            customeEditor       = new CustomEditor(this);
            customeEditor.Style = FindResource("Editor") as Style;
            SkinStorage.SetVisualStyle(customeEditor, "Metro");
            customeEditor.DataContext = AddDataContext;
            Grid.SetRow(customeEditor, 1);
            grid1.Children.Add(customeEditor);
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
            CultureInfo culture;

            culture = CultureInfo.CreateSpecificCulture("en-US");
            Thread.CurrentThread.CurrentCulture = culture;
            AppCollection = new ScheduleAppointmentCollection();
            DateTime currentdate = DateTime.Now.Date;

            if (currentdate.DayOfWeek == System.DayOfWeek.Friday || currentdate.DayOfWeek == System.DayOfWeek.Saturday)
            {
                currentdate = currentdate.SubtractDays(3);
            }
            else if (currentdate.DayOfWeek == System.DayOfWeek.Sunday || currentdate.DayOfWeek == System.DayOfWeek.Monday)
            {
                currentdate = currentdate.AddDays(3);
            }
            AppCollection.Add(new Appointment()
            {
                AppointmentImageURI = new BitmapImage(new Uri("pack://application:,,,/CustomizationDemo;Component/Assets/Hospital.png")),
                AppointmentType     = Appointment.AppointmentTypes.Health,
                Status                = Schedule.AppointmentStatusCollection[0],
                StartTime             = currentdate.AddHours(12),
                AppointmentTime       = currentdate.AddHours(12).ToString("hh:mm tt"),
                EndTime               = currentdate.AddHours(15),
                Subject               = "Checkup",
                Location              = "Chennai",
                AppointmentBackground = new SolidColorBrush(Color.FromArgb(255, 236, 12, 12))
            }
                              );
            currentdate = currentdate.AddHours(4);
            AppCollection.Add(new Appointment()
            {
                AppointmentImageURI = new BitmapImage(new Uri("pack://application:,,,/CustomizationDemo;Component/Assets/Cake.png")),
                AppointmentType     = Appointment.AppointmentTypes.Family,
                Status                = Schedule.AppointmentStatusCollection[0],
                StartTime             = currentdate.Date.SubtractDays(2).AddHours(1),
                AppointmentTime       = currentdate.Date.SubtractDays(2).AddHours(1).ToString("hh:mm tt"),
                EndTime               = currentdate.Date.SubtractDays(2).AddHours(4),
                Subject               = "My B'day",
                AppointmentBackground = new SolidColorBrush(Color.FromArgb(255, 180, 31, 125))
            }
                              );
            AppCollection.Add(new Appointment()
            {
                AppointmentImageURI = new BitmapImage(new Uri("pack://application:,,,/CustomizationDemo;Component/Assets/Team.png")),
                AppointmentType     = Appointment.AppointmentTypes.Office,
                Status                = Schedule.AppointmentStatusCollection[0],
                StartTime             = currentdate.Date.AddDays(2).AddHours(9),
                AppointmentTime       = currentdate.Date.AddDays(2).AddHours(9).ToString("hh:mm tt"),
                EndTime               = currentdate.Date.AddDays(2).AddHours(12),
                Subject               = "Meeting",
                AppointmentBackground = new SolidColorBrush(Color.FromArgb(255, 60, 181, 75))
            }
                              );


            Schedule.Appointments = AppCollection;
            DataContext           = this;

            PreviewMouseLeftButtonUp          += MainWindow_PreviewMouseLeftButtonDown;
            Schedule.ContextMenuOpening       += Schedule_PopupMenuOpening;
            Schedule.MouseLeave               += new MouseEventHandler(Schedule_MouseLeave);
            Schedule.AppointmentEditorOpening += Schedule_AppointmentEditorOpening;
            Schedule.Loaded                      += Schedule_Loaded;
            Schedule.ReminderOpening             += Schedule_ReminderOpening;
            Schedule.PreviewMouseRightButtonDown += Schedule_PreviewMouseRightButtonDown;
        }