예제 #1
0
        private void miEditEvent_Click(object sender, RoutedEventArgs e)
        {
            ContextMenu cm  = ((MenuItem)sender).Parent as ContextMenu;
            ListBoxItem lbi = cm.PlacementTarget as ListBoxItem;

            if (lbi == null)
            {
                return;
            }
            Guid targetGuid = (lbi.DataContext as IEvent).GUID;

            EventCollection ec = EventCollection.GetDataBase();

            if (ec == null)
            {
                throw new Exception("Event database is not avalible.");
            }
            IEvent evnt = ec.GetEvent(targetGuid);

            WindowEventSetting winEventSetting = new WindowEventSetting();

            winEventSetting.Owner                 = Calendar.Owner;
            winEventSetting.UpdateEvent          += OnRecievingUpdatedEvent;
            winEventSetting.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            winEventSetting.ShowEventSetting(evnt, DisplayMode.Edit);
            winEventSetting.Show();
        }
예제 #2
0
        private void miAddEvent_Click(object sender, RoutedEventArgs e)
        {
            ContextMenu cm = ((MenuItem)sender).Parent as ContextMenu;
            DockPanel   dp = cm.PlacementTarget as DockPanel;

            if (dp == null)
            {
                return;
            }

            // Set initial DateTime for dateTimePicker in WindowEventSetting
            Day      obj             = dp.DataContext as Day;
            DateTime initialDateTime = (obj.Date == DateTime.Today) ? DateTime.Now.Ceiling(TimeSpan.FromMinutes(30)) : obj.Date.AddHours(7);

            WindowEventSetting winEventSetting = new WindowEventSetting(initialDateTime);

            winEventSetting.Owner = Calendar.Owner;                                       // workaround: store owner info by static property
            winEventSetting.NewEventIsCreatedEvent += OnRecievingNewEvent;
            winEventSetting.WindowStartupLocation   = WindowStartupLocation.CenterScreen; // TODO: try to set startupLocation to center of MPLite
            winEventSetting.Show();
        }