示例#1
0
 private void OnEdit()
 {
     EditMode       = true;
     CanEditFields  = true;
     CanUseDatagrid = false;
     SelectedEvent.BeginEdit();
 }
        public AddEventReminderViewModel(IEnumerable <EventModel> events, EventReminderModel eventReminderModel)
        {
            var Today = DateTime.Now;

            Events = events.Where(x => x.Date.Date > Today.Date).OrderBy(x => x.Date).ThenBy(x => x.Name).ToList();

            var dataUnitLocator = ContainerAccessor.Instance.GetContainer().Resolve <IDataUnitLocator>();

            _eventDataUnit = dataUnitLocator.ResolveDataUnit <IEventDataUnit>();

            CanEditEveryoneEventReminders = AccessService.Current.UserHasPermissions(Resources.PERMISSION_EDIT_EVERYONE_FOLLOWUP_ALLOWED);
            CanEditOwnEventReminders      = AccessService.Current.UserHasPermissions(Resources.PERMISSION_EDIT_OWN_FOLLOWUP_ALLOWED);

            SubmitCommand = new RelayCommand(SubmitCommandExecuted, SubmitCommandCanExecute);
            CancelCommand = new RelayCommand(CancelCommandExecuted);

            OpenEventCommand = new RelayCommand(OpenEventCommandExecute, OpenEventCommandCanExecute);
            if (eventReminderModel != null)
            {
                ProcessEventReminder(eventReminderModel);
                SelectedEvent  = Events.FirstOrDefault(x => x.Event == eventReminderModel.EventReminder.Event);
                _originalEvent = SelectedEvent.Clone();
            }
            else
            {
                EventReminder = GetEventReminderWithoutEvent();
                EventReminder.PropertyChanged += EventReminderOnPropertyChanged;
            }
        }
示例#3
0
        private void Gridview1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            var id       = (int)gridview1.Rows[e.RowIndex].Cells[nameof(IMultiple.Id)].Value;
            var info     = list.Find(c => c.Id == id);
            var selected = !info.Selected;

            if (info.Name == TConfig.All)
            {
                foreach (var item in list)
                {
                    item.Selected = selected;
                    item.Image    = item.Selected ? Resources.Controls_accept_16 : Resources.Controls_blank;
                }
                foreach (DataGridViewRow item in gridview1.Rows)
                {
                    item.Cells[nameof(IMultiple.Image)].Value = info.Image;
                }
            }
            else
            {
                info.Selected = selected;
                info.Image    = info.Selected ? Resources.Controls_accept_16 : Resources.Controls_blank;
                gridview1.Rows[e.RowIndex].Cells[nameof(IMultiple.Image)].Value = info.Image;
            }
            var enumValue = UpdateSelected();

            SelectedEvent?.Invoke(enumValue);
        }
示例#4
0
 private void OnCancel()
 {
     if (AddMode)
     {
         EventCollection.Remove(SelectedEvent);
         SelectedEvent = null;
         AddMode       = false;
     }
     else if (EditMode)
     {
         SelectedEvent.CancelEdit();
         EditMode = false;
     }
     else if (RemoveMode)
     {
         foreach (var item in EventCollection)
         {
             if (item.IsChecked)
             {
                 item.IsChecked = false;
             }
         }
         RemoveMode = false;
     }
     CanUseDatagrid = true;
     CanEditFields  = false;
 }
 private void LandBorder_MouseDown(object obj)
 {
     //最开始用点击UserControl,再VisualTreeHelper.HitTest命中测试的方法,border不能命中,可能是layout变换了的缘故
     //最后将上层的Image的IsHitTestVisible设为false,border即可被点中。
     IsSelected = true;
     SelectedEvent?.Invoke();
     Console.WriteLine("AAAAAAAAAAA");
     //e.Handled = true;
 }
示例#6
0
 private void DeleteEventCommandExecute(Object param)
 {
     using (var context = new DataContext())
     {
         context.DeleteEvent(SelectedEvent.ConvertBackToDalModel());
     }
     SelectedEvent = null;
     RefreshEvents();
 }
示例#7
0
 /// <summary>
 /// 双击选择并关闭
 /// </summary>
 internal override void Gridview1_DoubleClick(object sender, EventArgs e)
 {
     if (gridview1.CurrentCell != null)
     {
         int index = gridview1.CurrentCell.RowIndex;
         var id    = this.gridview1.Rows[index].Cells[gridview1.IdColumn()].Value.ToInt();
         SelectedEvent?.Invoke(list.Find(c => c.Id == id));
         base.Gridview1_DoubleClick(sender, e);
     }
 }
        public MatchInfoViewModel()
        {
            NavigateHomeCommand = new RelayCommand(NavigateHome, () => {
                return(!_Navigating);
            });
            SubmitCommand = new RelayCommand(Submit, () => {
                if (_Navigating)
                {
                    return(false);
                }
                if (!SelectedRecorderID.Any())
                {
                    return(false);
                }
                if (!SelectedAlliance.Any())
                {
                    return(false);
                }
                if (!SelectedEvent.Any())
                {
                    return(false);
                }
                if (!MatchNumber.Any())
                {
                    return(false);
                }
                if (!TeamNumber.Any())
                {
                    return(false);
                }
                return(true);
            });
            NavigateHomeCommand.RaiseCanExecuteChanged();
            SubmitCommand.RaiseCanExecuteChanged();

            Messenger.Default.Send(new Message.RetrieveDataMessage <Model.MatchInfoSource>()
            {
                SetData = (MatchInfoSource matchInfoSource) => {
                    RecorderIDSource = matchInfoSource.RecorderIDSource;
                    AllianceSource   = matchInfoSource.AllianceSource;
                    EventSource      = matchInfoSource.EventSource;
                }
            });
            Messenger.Default.Send(new Message.RetrieveDataMessage <Model.MatchInfo>()
            {
                SetData = (MatchInfo matchInfo) => {
                    SelectedRecorderID = matchInfo.RecorderID;
                    SelectedAlliance   = matchInfo.Alliance;
                    SelectedEvent      = matchInfo.Event;
                    MatchNumber        = Convert.ToString(matchInfo.MatchNumber);
                    TeamNumber         = Convert.ToString(matchInfo.TeamNumber);
                }
            });
        }
 public void AttendedAlumn()
 {
     if (SelectedEvent != null)
     {
         AttendedAlumns = SelectedEvent.GetAttendedAlumns(Services);
     }
     else
     {
         MessageBox.Show("Du måste välja ett event");
     }
 }
 public void DeleteEvent()
 {
     if (SelectedEvent != null)
     {
         SelectedEvent.Delete(Services);
     }
     else
     {
         MessageBox.Show("Du måste välja ett event");
     }
     Update();
 }
 public void EditEvent()
 {
     if (SelectedEvent != null)
     {
         SelectedEvent.UpdateEvent(Services);
         MessageBox.Show("Eventet: " + SelectedEvent.Title + " har uppdaterats");
         Update();
     }
     else
     {
         MessageBox.Show("Du måste välja ett event");
     }
 }
示例#12
0
 /// <summary>
 /// 选中此图形
 /// </summary>
 public virtual void Select()
 {
     if (CanSelect)
     {
         Selected = true;
         ResizeHandles.ForEach(h => h.Visible = true);
         if (__bound != null)
         {
             __bound.Visible = true;
         }
         SelectedEvent?.Invoke(this, null);
     }
 }
示例#13
0
        //Edit event btn
        private void Edit_Click_1(object sender, RoutedEventArgs e)
        {
            UserEvent newUser = SelectedEvent.Clone();
            DateTime  dt      = new DateTime(EditEventDate.Year, EditEventDate.Month, EditEventDate.Day);
            TimeSpan  ts      = new TimeSpan(EditEventHour, EditEventMinute, 0);

            dt += ts;
            newUser.EventDate  = dt;
            newUser.EventTitle = EditEventTitle;
            newUser.EventDesc  = EditEventDesc;
            Events.Remove(SelectedEvent);
            Events.Add(newUser);
            ReloadList();
        }
        private void biEditEvent_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (Ticker == null)
            {
                return;
            }
            TickerEvent   ev   = SelectedEvent.Clone();
            EventEditForm form = new EventEditForm();

            form.Event = ev;
            if (form.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            SelectedEvent.Assign(ev);
            Ticker.OnEventsChanged();
        }
示例#15
0
        private void ModifyCommandExecute(Object param)
        {
            SelectedEvent.BeginEdit();
            if (AddNewEventFunc != null && AddNewEventFunc(SelectedEvent))
            {
                using (var context = new DataContext())
                {
                    context.UpdateEventParticipators(SelectedEvent.Id, SelectedEvent.Participators);
                    context.UpdateEvent(SelectedEvent.ConvertBackToDalModel());
                    context.UpdateEventDocuments(SelectedEvent.Documents.Select(d => d.ConvertBackToDalModel()), SelectedEvent.Id);

                    SelectedEvent.EndEdit();
                    RefreshEvents();
                    return;
                }
            }
            SelectedEvent.CancelEdit();
        }
示例#16
0
    void Awake()
    {
        if (selectedEvent == null)
        {
            selectedEvent = new SelectedEvent();
        }
        if (deselectedEvent == null)
        {
            deselectedEvent = new DeselectedEvent();
        }
        if (clickedEvent == null)
        {
            clickedEvent = new ClickedEvent();
        }

        isVisible = false;

        canvas = GetComponent <Canvas>();
    }
示例#17
0
        private async void SubmitCommandExecuted()
        {
            if (!IsEditMode)
            {
                if (AreEventsVisible)
                {
                    EventReminder.EventReminder.EventID = SelectedEvent.Event.ID;
                    EventReminder.EventReminder.Event   = SelectedEvent.Event;
                }
                else
                {
                    _event.EventReminders.Add(EventReminder);
                }
                _eventDataUnit.EventRemindersRepository.Add(EventReminder.EventReminder);

                var primaryContact = EventReminder.EventReminder.Event != null ? EventReminder.EventReminder.Event.Contact == null ? String.Empty : "Primary Contact: " + EventReminder.EventReminder.Event.Contact.FirstName + " "
                                     + EventReminder.EventReminder.Event.Contact.LastName : String.Empty;

                var msg = "Event-Reminder" + "\n" + "Created by " + EventReminder.CreatedByUser.FirstName + " " +
                          EventReminder.CreatedByUser.LastName + " at " + DateTime.Now + "\n" +
                          "Event Name: " + EventReminder.EventName + "\n" + primaryContact + "\n" + EventReminder.WhatToDo;
                var email = new CorrespondenceModel(new Corresponcence()
                {
                    ID          = Guid.NewGuid(),
                    Date        = DateTime.Now,
                    FromAddress = EventReminder.CreatedByUser.EmailAddress,
                    ToAddress   = EventReminder.AssignedToUser.EmailAddress,
                    Subject     = "Event-Reminder",
                    Message     = msg,
                });

                await EmailService.SendEmail(email, null, null);

                if (AreEventsVisible)
                {
                    _originalEvent = SelectedEvent.Clone();
                    SelectedEvent.EventReminders.Add(EventReminder);
                    var eventUpdates = LoggingService.FindDifference(_originalEvent, SelectedEvent);
                    if (!SelectedEvent.EventUpdates.Any())
                    {
                        var updates = await _eventDataUnit.EventUpdatesRepository.GetAllAsync(x => x.EventID == SelectedEvent.Event.ID);

                        SelectedEvent.EventUpdates = new ObservableCollection <EventUpdate>(updates.OrderByDescending(x => x.Date));
                    }
                    ProcessUpdates(SelectedEvent, eventUpdates);

                    await _eventDataUnit.SaveChanges();
                }
            }
            else
            {
                _eventReminder.AssignedToUser = AssignedToUser;
                _eventReminder.EventReminder.AssignedToUserID = AssignedToUser.ID;
                EventReminder.EventReminder.LastEditDate      = DateTime.Now;
                if (AreEventsVisible)
                {
                    if (_originalEvent.Event.ID != _selectedEvent.Event.ID)
                    {
                        _originalEvent = _selectedEvent.Clone();
                    }

                    EventReminder.EventReminder.Event = SelectedEvent.Event;
                    SelectedEvent.EventReminders.Where(x => x.EventReminder == _eventReminder.EventReminder).FirstOrDefault().AssignedToUser = AssignedToUser;
                    var eventUpdates = LoggingService.FindDifference(_originalEvent, SelectedEvent);
                    if (!SelectedEvent.EventUpdates.Any())
                    {
                        var updates = await _eventDataUnit.EventUpdatesRepository.GetAllAsync(x => x.EventID == SelectedEvent.Event.ID);

                        SelectedEvent.EventUpdates = new ObservableCollection <EventUpdate>(updates.OrderByDescending(x => x.Date));
                    }
                    ProcessUpdates(_selectedEvent, eventUpdates);

                    await _eventDataUnit.SaveChanges();
                }
                else
                {
                    _eventDataUnit.EventRemindersRepository.SetEntityModified(_eventReminder.EventReminder);
                }
                EventReminder.Refresh();
            }
        }
示例#18
0
 add => this.AddRoutedHandler(SelectedEvent, value);
示例#19
0
 remove => this.RemoveRoutedHandler(SelectedEvent, value);
示例#20
0
 private bool CanUpdate()
 {
     return(SelectedEvent != null && SelectedEvent.IsValid());
 }
示例#21
0
        private async void OnSave()
        {
            if (AddMode)
            {
                var    _event  = Converter.ConvertFromEventModel(SelectedEvent);
                int    id      = 0;
                bool   success = true;
                string error   = "";
                OnInformationRequested("Loading...");
                await Task.Run(() =>
                {
                    try
                    {
                        using (Repository <Event> repo = new Repository <Event>())
                        {
                            var result = repo.InsertWithResult(_event);
                            if (result.Status.Success)
                            {
                                id = result.Data.ID;
                            }
                            else
                            {
                                success = false;
                                error   = result.Status.ErrorMessage;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        success = false;
                        error   = $"An error occured. Message: {ex.Message}";
                    }
                });

                if (success)
                {
                    SelectedEvent.Id = id;
                    OnInformationRequested("Data added successfully, refreshing service in the background...");
                    await Task.Run(() =>
                    {
                        var result = Controller.RefreshService();
                        if (!result.Success)
                        {
                            success = false;
                            error   = result.ErrorMessage;
                        }
                    });

                    if (success)
                    {
                        OnInformationRequested("Service refreshed successfully");
                    }
                    else
                    {
                        OnErrorOccured(error);
                    }
                }
                else
                {
                    EventCollection.Remove(SelectedEvent);
                    SelectedEvent = null;
                    OnErrorOccured(error);
                }
                AddMode = false;
            }
            else if (EditMode)
            {
                var    _event  = Converter.ConvertFromEventModel(SelectedEvent);
                bool   success = true;
                string error   = "";
                OnInformationRequested("Loading...");
                await Task.Run(() =>
                {
                    try
                    {
                        using (Repository <Event> repo = new Repository <Event>())
                        {
                            var result = repo.Update(_event);
                            if (!result.Success)
                            {
                                success = false;
                                error   = result.ErrorMessage;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        success = false;
                        error   = $"An error occured. Message: {ex.Message}";
                    }
                });

                if (success)
                {
                    SelectedEvent.EndEdit();
                    OnInformationRequested("Data updated successfully, refreshing service in the background...");
                    await Task.Run(() =>
                    {
                        var result = Controller.RefreshService();
                        if (!result.Success)
                        {
                            success = false;
                            error   = result.ErrorMessage;
                        }
                    });

                    if (success)
                    {
                        OnInformationRequested("Service refreshed successfully");
                    }
                    else
                    {
                        OnErrorOccured(error);
                    }
                }
                else
                {
                    SelectedEvent.CancelEdit();
                    OnErrorOccured(error);
                }
                EditMode = false;
            }
            else if (RemoveMode)
            {
                var temp = from item in EventCollection
                           where item.IsChecked
                           select item;
                var    eventsToRemove = temp.Select(x => Converter.ConvertFromEventModel(x));
                bool   success        = true;
                string error          = "";
                OnInformationRequested("Loading...");
                await Task.Run(() =>
                {
                    try
                    {
                        using (Repository <Event> repo = new Repository <Event>())
                        {
                            var result = repo.Delete(eventsToRemove);
                            if (!result.Success)
                            {
                                success = false;
                                error   = result.ErrorMessage;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        success = false;
                        error   = $"An error occured. Message: {ex.Message}";
                    }
                });

                if (success)
                {
                    //to avoid Invalid Operation Exception
                    for (int i = 0; i < EventCollection.Count; i++)
                    {
                        if (EventCollection[i].IsChecked)
                        {
                            EventCollection.RemoveAt(i);
                            i--;
                        }
                    }
                    OnInformationRequested("Data removed successfully, refreshing service in the background...");
                    await Task.Run(() =>
                    {
                        var result = Controller.RefreshService();
                        if (!result.Success)
                        {
                            success = false;
                            error   = result.ErrorMessage;
                        }
                    });

                    if (success)
                    {
                        OnInformationRequested("Service refreshed successfully");
                    }
                    else
                    {
                        OnErrorOccured(error);
                    }
                }
                else
                {
                    OnErrorOccured(error);
                }
                RemoveMode = false;
            }
            CanUseDatagrid = true;
            CanEditFields  = false;
        }
示例#22
0
 public void Select(Vector2 pointerPosition)
 {
     SelectedEvent?.Invoke(pointerPosition, this);
 }
示例#23
0
 public void Selected(object sender, RoutedEventArgs args)
 {
     SelectedEvent?.Invoke(sender, args);
 }
 public void OnSelected(MonitorView monitorView)
 {
     SelectedEvent?.Invoke(monitorView);
 }