Ejemplo n.º 1
0
 public ViewModel(RadScheduleView sv)
 {
     dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
     dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
     dispatcherTimer.Interval = new TimeSpan(0, 0, 30);
     dispatcherTimer.Start();
     reminderViewModel = new ReminderWindowViewModel(this, sv);
     reminderWindow = new ReminderWindow() { DataContext = reminderViewModel };
 }
Ejemplo n.º 2
0
 public ReminderWindowViewModel(ViewModel viewModel, RadScheduleView scheduleView)
 {
     this.MainViewModel = viewModel;
     this.MainViewModel.PropertyChanged += MainViewModel_PropertyChanged;
     this.DismissCommand         = new DelegateCommand(this.DismissCommandExecuted, this.DismissCommandCanExecute);
     this.SnoozeCommand          = new DelegateCommand(this.SnoozeCommandExecuted, this.SnoozeCommandCanExecute);
     this.ScheduleView           = scheduleView;
     this.EditAppointmentCommand = new DelegateCommand(this.EditAppointmentCommandExecuted, this.EditAppointmentCommandCanExecute);
 }
 public ReminderWindowViewModel(ViewModel viewModel, RadScheduleView scheduleView)
 {
     this.MainViewModel = viewModel;
     this.MainViewModel.PropertyChanged += MainViewModel_PropertyChanged;
     this.DismissCommand = new DelegateCommand(this.DismissCommandExecuted, this.DismissCommandCanExecute);
     this.SnoozeCommand = new DelegateCommand(this.SnoozeCommandExecuted, this.SnoozeCommandCanExecute);
     this.ScheduleView = scheduleView;
     this.EditAppointmentCommand = new DelegateCommand(this.EditAppointmentCommandExecuted, this.EditAppointmentCommandCanExecute);
 }
Ejemplo n.º 4
0
 public ViewModel(RadScheduleView sv)
 {
     dispatcherTimer          = new System.Windows.Threading.DispatcherTimer();
     dispatcherTimer.Tick    += new EventHandler(dispatcherTimer_Tick);
     dispatcherTimer.Interval = new TimeSpan(0, 0, 10);
     dispatcherTimer.Start();
     reminderViewModel = new ReminderWindowViewModel(this, sv);
     reminderWindow    = new ReminderWindow()
     {
         DataContext = reminderViewModel
     };
 }
Ejemplo n.º 5
0
        private static void OnAppointmentCreated(object sender, AppointmentCreatedEventArgs e)
        {
            scheduleView = sender as RadScheduleView;
            var createdApp = e.CreatedAppointment as Appointment;

            var timeMarker = createdApp.TimeMarker as TimeMarker;
            var resourcers = createdApp.Resources;

            var currentMarkerResource = scheduleView.ResourceTypesSource.Cast <ResourceType>()
                                        .Select(a => a.Resources).Where(a => a.ResourceType == "TimeMarkers").FirstOrDefault();

            if (timeMarker != null)
            {
                var markers = new ObservableCollection <TimeMarker>(scheduleView.TimeMarkersSource.Cast <TimeMarker>().ToList());

                if (!createdApp.Resources.Any(a => a.ResourceType == currentMarkerResource.ResourceType))
                {
                    var newResource = currentMarkerResource.Where(a => a.DisplayName == timeMarker.TimeMarkerName).FirstOrDefault();

                    EditAppointment(createdApp, null, newResource);
                }
                else
                {
                    var oldMarker         = markers.Where(a => a.TimeMarkerName.Equals(createdApp.Resources.Select(b => b.ResourceName).FirstOrDefault())).First();
                    var currTimeMarkerRes = createdApp.Resources.Where(a => a.ResourceName.Equals(oldMarker.TimeMarkerName)).First();
                    var newResource       = currentMarkerResource.Where(a => a.DisplayName == timeMarker.TimeMarkerName).FirstOrDefault();

                    EditAppointment(createdApp, currTimeMarkerRes, newResource);
                }
            }
            else
            {
                var markers = new ObservableCollection <TimeMarker>(scheduleView.TimeMarkersSource.Cast <TimeMarker>().ToList());

                if (createdApp.Resources.Any(a => a.ResourceType == currentMarkerResource.ResourceType))
                {
                    var currentMarker = markers.Where(a => a.TimeMarkerName.Equals(createdApp.Resources.Select(b => b.ResourceName).FirstOrDefault())).First();
                    createdApp.TimeMarker = currentMarker;
                }
            }

            if (IsAppointmentChangedThroughDialog)
            {
                IsAppointmentChangedThroughDialog = false;
            }
        }
Ejemplo n.º 6
0
        private static void OnIsTimeMarkerGroupingEnabledChagned(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            d.Dispatcher.BeginInvoke(new Action(() =>
            {
                scheduleView = d as RadScheduleView;

                if (scheduleView != null && e.NewValue != e.OldValue)
                {
                    if ((bool)e.NewValue)
                    {
                        var viewModel = scheduleView.DataContext as MyViewModel;
                        var timeMarkers = scheduleView.TimeMarkersSource;

                        var timeMarkerResources = new ResourceType("TimeMarkers");

                        foreach (TimeMarker marker in timeMarkers)
                        {
                            Resource res = new Resource(marker.TimeMarkerName);
                            timeMarkerResources.Resources.Add(res);
                        }

                        viewModel.ResourcesTypes.Add(timeMarkerResources);

                        ResourceGroupDescription groupDescription = new ResourceGroupDescription();
                        groupDescription.ResourceType = timeMarkerResources.Name;
                        groupDescription.ShowNullGroup = true;
                        viewModel.GroupDescriptions.Add(groupDescription);

                        scheduleView.AppointmentCreated += OnAppointmentCreated;
                        scheduleView.AppointmentEdited += OnAppointmentEdited;
                        scheduleView.DialogClosing += OnDialogClosing;
                        scheduleView.Loaded += OnLoaded;
                    }
                    else
                    {
                        scheduleView.AppointmentCreated -= OnAppointmentCreated;
                        scheduleView.AppointmentEdited -= OnAppointmentEdited;
                        scheduleView.DialogClosing -= OnDialogClosing;
                        scheduleView.Loaded -= OnLoaded;
                    }
                }
            }));
        }
Ejemplo n.º 7
0
        private static void OnIsTimeMarkerGroupingEnabledChagned(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            d.Dispatcher.BeginInvoke(new Action(() =>
            {
                scheduleView = d as RadScheduleView;

                if (scheduleView != null && e.NewValue != e.OldValue)
                {
                    if ((bool)e.NewValue)
                    {
                        var viewModel   = scheduleView.DataContext as MyViewModel;
                        var timeMarkers = scheduleView.TimeMarkersSource;

                        var timeMarkerResources = new ResourceType("TimeMarkers");

                        foreach (TimeMarker marker in timeMarkers)
                        {
                            Resource res = new Resource(marker.TimeMarkerName);
                            timeMarkerResources.Resources.Add(res);
                        }

                        viewModel.ResourcesTypes.Add(timeMarkerResources);

                        ResourceGroupDescription groupDescription = new ResourceGroupDescription();
                        groupDescription.ResourceType             = timeMarkerResources.Name;
                        groupDescription.ShowNullGroup            = true;
                        viewModel.GroupDescriptions.Add(groupDescription);

                        scheduleView.AppointmentCreated += OnAppointmentCreated;
                        scheduleView.AppointmentEdited  += OnAppointmentEdited;
                        scheduleView.DialogClosing      += OnDialogClosing;
                        scheduleView.Loaded             += OnLoaded;
                    }
                    else
                    {
                        scheduleView.AppointmentCreated -= OnAppointmentCreated;
                        scheduleView.AppointmentEdited  -= OnAppointmentEdited;
                        scheduleView.DialogClosing      -= OnDialogClosing;
                        scheduleView.Loaded             -= OnLoaded;
                    }
                }
            }));
        }
 public void InitializeComponent() {
     if (_contentLoaded) {
         return;
     }
     _contentLoaded = true;
     System.Windows.Application.LoadComponent(this, new System.Uri("/Procbel.Apps.Silverlight.Modules.Companies;component/Views/CompanyActivitiesUser" +
                 "Control.xaml", System.UriKind.Relative));
     this.uc = ((System.Windows.Controls.UserControl)(this.FindName("uc")));
     this.LayoutRoot = ((System.Windows.Controls.Grid)(this.FindName("LayoutRoot")));
     this.VisualStateGroup = ((System.Windows.VisualStateGroup)(this.FindName("VisualStateGroup")));
     this.Normal = ((System.Windows.VisualState)(this.FindName("Normal")));
     this.Add = ((System.Windows.VisualState)(this.FindName("Add")));
     this.Edit = ((System.Windows.VisualState)(this.FindName("Edit")));
     this.scheduleView = ((RadScheduleView)(this.FindName("scheduleView")));
     this.activitiesGrid = ((RadGridView)(this.FindName("activitiesGrid")));
     this.Status = ((GridViewDataColumn)(this.FindName("Status")));
     this.overlayRectangle = ((System.Windows.Shapes.Rectangle)(this.FindName("overlayRectangle")));
     this.border = ((System.Windows.Controls.Border)(this.FindName("border")));
     this.dialog = ((Procbel.Apps.Silverlight.Helpers.ScheduleViewCustomDialogHost)(this.FindName("dialog")));
 }
Ejemplo n.º 9
0
        private static void OnAppointmentCreated(object sender, AppointmentCreatedEventArgs e)
        {
            scheduleView = sender as RadScheduleView;
            var createdApp = e.CreatedAppointment as Appointment;

            var timeMarker = createdApp.TimeMarker as TimeMarker;
            var resourcers = createdApp.Resources;

            var currentMarkerResource = scheduleView.ResourceTypesSource.Cast<ResourceType>()
                .Select(a => a.Resources).Where(a => a.ResourceType == "TimeMarkers").FirstOrDefault();

            if (timeMarker != null)
            {
                var markers = new ObservableCollection<TimeMarker>(scheduleView.TimeMarkersSource.Cast<TimeMarker>().ToList());

                if (!createdApp.Resources.Any(a => a.ResourceType == currentMarkerResource.ResourceType))
                {
                    var newResource = currentMarkerResource.Where(a => a.DisplayName == timeMarker.TimeMarkerName).FirstOrDefault();
                    createdApp.Resources.Add(newResource);
                }
                else
                {
                    var oldMarker = markers.Where(a => a.TimeMarkerName.Equals(createdApp.Resources.Select(b => b.ResourceName).FirstOrDefault())).First();
                    var currTimeMarkerRes = createdApp.Resources.Where(a => a.ResourceName.Equals(oldMarker.TimeMarkerName)).First();
                    var newResource = currentMarkerResource.Where(a => a.DisplayName == timeMarker.TimeMarkerName).FirstOrDefault();

                    EditAppointment(createdApp, currTimeMarkerRes, newResource);
                }
            }
            else
            {
                var markers = new ObservableCollection<TimeMarker>(scheduleView.TimeMarkersSource.Cast<TimeMarker>().ToList());

                if (createdApp.Resources.Any(a => a.ResourceType == currentMarkerResource.ResourceType))
                {
                    var currentMarker = markers.Where(a => a.TimeMarkerName.Equals(createdApp.Resources.Select(b => b.ResourceName).FirstOrDefault())).First();
                    createdApp.TimeMarker = currentMarker;
                }
            }

            if (IsAppointmentChangedThroughDialog)
            {
                IsAppointmentChangedThroughDialog = false;
            }
        }
Ejemplo n.º 10
0
        private static void OnAppointmentEdited(object sender, AppointmentEditedEventArgs e)
        {
            scheduleView = sender as RadScheduleView;
            var editedApp = e.Appointment as Appointment;

            var resourcers = editedApp.Resources;
            var timeMarker = editedApp.TimeMarker;

            var currnetTimeMarkerResouce = scheduleView.ResourceTypesSource.Cast<ResourceType>()
                .Select(a => a.Resources).Where(a => a.ResourceType == "TimeMarkers").FirstOrDefault();

            if (!editedApp.Resources.Any(a => a.ResourceType == currnetTimeMarkerResouce.ResourceType) && IsAppointmentChangedThroughDialog)
            {
                if (timeMarker != null)
                {
                    var newResource = currnetTimeMarkerResouce.Where(a => a.DisplayName == timeMarker.TimeMarkerName).FirstOrDefault();

                    EditAppointment(editedApp, null, newResource);
                }
            }
            else
            {
                if (IsAppointmentChangedThroughDialog)
                {
                    var currentResource = editedApp.Resources.Select(a => a).Where(a => a.ResourceType == "TimeMarkers").FirstOrDefault();

                    if (timeMarker != null)
                    {
                        var newResource = currnetTimeMarkerResouce.Where(a => a.DisplayName == timeMarker.TimeMarkerName).FirstOrDefault();

                        if (currentResource != newResource)
                        {
                            EditAppointment(editedApp, currentResource, newResource);
                        }
                    }
                    else
                    {
                        EditAppointment(editedApp, currentResource, null);
                    }

                    if (editedApp.RecurrenceRule != null)
                    {
                        if (editedApp.RecurrenceRule.Exceptions.Count > 0)
                        {
                            foreach (var excApp in editedApp.RecurrenceRule.Exceptions)
                            {
                                var app = excApp.Appointment as Appointment;
                                var currentExcResource = app.Resources.Select(a => a).Where(a => a.ResourceType == "TimeMarkers").FirstOrDefault();

                                if (app.TimeMarker != null)
                                {
                                    var newExcResource = currnetTimeMarkerResouce.Where(a => a.DisplayName == app.TimeMarker.TimeMarkerName).FirstOrDefault();

                                    if(currentExcResource != null)
                                    {
                                        if (app.TimeMarker.TimeMarkerName != currentExcResource.DisplayName)
                                        {
                                            EditAppointment(app, currentExcResource, newExcResource);
                                            UpdateMasterAppointment(editedApp);
                                        }
                                    }
                                    else
                                    {
                                        EditAppointment(app, null, newExcResource);
                                        UpdateMasterAppointment(editedApp);
                                    }
                                }
                                else
                                {
                                    EditAppointment(app, currentExcResource, null);
                                    UpdateMasterAppointment(editedApp);
                                }
                            }
                        }
                    }
                }
                else
                {
                    var markers = new ObservableCollection<TimeMarker>(scheduleView.TimeMarkersSource.Cast<TimeMarker>().ToList());
                    var currResourcesNames = editedApp.Resources.Select(b => b.ResourceName);
                    var newMarker = markers.Where(a => currResourcesNames.Contains(a.TimeMarkerName)).FirstOrDefault();

                    if (editedApp.TimeMarker != newMarker)
                    {
                        editedApp.TimeMarker = newMarker;
                    }

                    if (editedApp.RecurrenceRule != null)
                    {
                        if (editedApp.RecurrenceRule.Exceptions.Count > 0)
                        {
                            foreach (var excApp in editedApp.RecurrenceRule.Exceptions)
                            {
                                var exception = excApp.Appointment as Appointment;
                                var currExcResourcesNames = exception.Resources.Select(b => b.ResourceName);
                                var newExcMarker = markers.Where(a => currExcResourcesNames.Contains(a.TimeMarkerName)).FirstOrDefault();

                                if (exception.TimeMarker != newExcMarker)
                                {
                                    exception.TimeMarker = newExcMarker;
                                }
                            }
                        }
                    }
                }

            }

            if (IsAppointmentChangedThroughDialog)
            {
                IsAppointmentChangedThroughDialog = false;
            }
        }
Ejemplo n.º 11
0
 public void PaymentScheduleView_OnLoaded(object sender, RoutedEventArgs e)
 {
     if (_scheduleView == null)
     {
         _scheduleView = sender as RadScheduleView;
     }
 }
Ejemplo n.º 12
0
        private static void OnAppointmentEdited(object sender, AppointmentEditedEventArgs e)
        {
            scheduleView = sender as RadScheduleView;
            var editedApp = e.Appointment as Appointment;

            var resourcers = editedApp.Resources;
            var timeMarker = editedApp.TimeMarker;

            var currnetTimeMarkerResouce = scheduleView.ResourceTypesSource.Cast <ResourceType>()
                                           .Select(a => a.Resources).Where(a => a.ResourceType == "TimeMarkers").FirstOrDefault();

            if (!editedApp.Resources.Any(a => a.ResourceType == currnetTimeMarkerResouce.ResourceType) && IsAppointmentChangedThroughDialog)
            {
                if (timeMarker != null)
                {
                    var newResource = currnetTimeMarkerResouce.Where(a => a.DisplayName == timeMarker.TimeMarkerName).FirstOrDefault();

                    EditAppointment(editedApp, null, newResource);
                }
            }
            else
            {
                if (IsAppointmentChangedThroughDialog)
                {
                    var currentResource = editedApp.Resources.Select(a => a).Where(a => a.ResourceType == "TimeMarkers").FirstOrDefault();

                    if (timeMarker != null)
                    {
                        var newResource = currnetTimeMarkerResouce.Where(a => a.DisplayName == timeMarker.TimeMarkerName).FirstOrDefault();

                        if (currentResource != newResource)
                        {
                            EditAppointment(editedApp, currentResource, newResource);
                        }
                    }
                    else
                    {
                        EditAppointment(editedApp, currentResource, null);
                    }

                    if (editedApp.RecurrenceRule != null)
                    {
                        if (editedApp.RecurrenceRule.Exceptions.Count > 0)
                        {
                            foreach (var excApp in editedApp.RecurrenceRule.Exceptions)
                            {
                                var app = excApp.Appointment as Appointment;
                                var currentExcResource = app.Resources.Select(a => a).Where(a => a.ResourceType == "TimeMarkers").FirstOrDefault();

                                if (app.TimeMarker != null)
                                {
                                    var newExcResource = currnetTimeMarkerResouce.Where(a => a.DisplayName == app.TimeMarker.TimeMarkerName).FirstOrDefault();

                                    if (currentExcResource != null)
                                    {
                                        if (app.TimeMarker.TimeMarkerName != currentExcResource.DisplayName)
                                        {
                                            EditAppointment(app, currentExcResource, newExcResource);
                                            UpdateMasterAppointment(editedApp);
                                        }
                                    }
                                    else
                                    {
                                        EditAppointment(app, null, newExcResource);
                                        UpdateMasterAppointment(editedApp);
                                    }
                                }
                                else
                                {
                                    EditAppointment(app, currentExcResource, null);
                                    UpdateMasterAppointment(editedApp);
                                }
                            }
                        }
                    }
                }
                else
                {
                    var markers            = new ObservableCollection <TimeMarker>(scheduleView.TimeMarkersSource.Cast <TimeMarker>().ToList());
                    var currResourcesNames = editedApp.Resources.Select(b => b.ResourceName);
                    var newMarker          = markers.Where(a => currResourcesNames.Contains(a.TimeMarkerName)).FirstOrDefault();

                    if (editedApp.TimeMarker != newMarker)
                    {
                        editedApp.TimeMarker = newMarker;
                    }

                    if (editedApp.RecurrenceRule != null)
                    {
                        if (editedApp.RecurrenceRule.Exceptions.Count > 0)
                        {
                            foreach (var excApp in editedApp.RecurrenceRule.Exceptions)
                            {
                                var exception             = excApp.Appointment as Appointment;
                                var currExcResourcesNames = exception.Resources.Select(b => b.ResourceName);
                                var newExcMarker          = markers.Where(a => currExcResourcesNames.Contains(a.TimeMarkerName)).FirstOrDefault();

                                if (exception.TimeMarker != newExcMarker)
                                {
                                    exception.TimeMarker = newExcMarker;
                                }
                            }
                        }
                    }
                }
            }

            if (IsAppointmentChangedThroughDialog)
            {
                IsAppointmentChangedThroughDialog = false;
            }
        }