Example #1
0
 public static List<int> RangesToRows(SelectedRange[] ranges)
 {
     List<int> rows = new List<int>();
     for (int i = 0; i < ranges.Length; i++) {
         for (int j = ranges[i].FromRow.Value; j <= ranges[i].ToRow; j++) {
             rows.Add(j);
         }
     }
     return rows;
 }
Example #2
0
 public void RaiseOnSelectedRowsChanged(SelectedRange[] rows)
 {
     this._selectedRows = rows;
     if (this.OnSelectedRowsChanged != null)
         this.OnSelectedRowsChanged();
 }
        public Action SaveSelectedContact()
        {
            if (_saveSelectedContact == null)
            {
                _saveSelectedContact = delegate()
                {
                    if (((IValidatedObservable)SelectedContact).IsValid())
                    {
                        Contact contact = SelectedContact.GetValue().Commit();
                        ObservableContact selectedContact = SelectedContact.GetValue();

                        if (selectedContact.EntityState.GetValue() == EntityStates.Created)
                        {
                            this.Contacts.AddItem(contact);

                            // Move to the last page
                            PagingInfo paging = this.Contacts.GetPagingInfo();

                            SelectedRange[] newRow = new SelectedRange[1];
                            newRow[0] = new SelectedRange();
                            newRow[0].FromRow = paging.TotalRows - ((paging.TotalPages - 1) * paging.PageSize)-1;
                            this.Contacts.RaiseOnSelectedRowsChanged(newRow);
                            selectedContact.EntityState.SetValue(EntityStates.Changed);
                        }
                        else
                        {
                            Contacts.Refresh();
                        }
                    }
                    else
                    {
                        Script.Literal("{0}.errors.showAllMessages()", SelectedContact);
                    }
                };
            }
            return _saveSelectedContact;
        }
Example #4
0
        private void AddDefaultSession(DayEntry activity)
        {
            // Clear the sessions from the previously selected row, and show a blank row
            Sessions.SetCurrentActivity(activity.Activity, 0);

            dev1_session session = new dev1_session();
            session.Account = activity.Account;
            session.dev1_ActivityId = activity.Activity.Id.ToString();
            session.dev1_ActivityTypeName = activity.Activity.LogicalName;
            session.dev1_ActivityId = activity.Activity.Id.ToString();
            session.dev1_StartTime = Sessions.WeekStart;
            session.activitypointer_subject = activity.Activity.Name;
            session.activitypointer_regardingobjectid = activity.RegardingObjectId;
            Sessions.SelectedActivity = activity.Activity;
            session.dev1_Row = this.Sessions.GetCurrentWeek().Count;
            // Has the account been set - if not we need to look it up from the selected activity
            if (session.Account == null || session.activitypointer_regardingobjectid == null)
                SetAccountAndRegardingFromActivity(session);


            Sessions.AddItem(session);
            _selectedRows = new SelectedRange[1] { new SelectedRange() };
            _selectedRows[0].FromRow = rows.Count + 1;
            _selectedRows[0].ToRow = rows.Count + 1;
            
        }
 public override void AddItem(object item)
 {
     dev1_session session = new dev1_session();
     DayEntry activity = (DayEntry)item;
     if ((activity.Activity != null) && (activity.Activity.Id!=null))
     {
         session.dev1_ActivityId = activity.Activity.Id.ToString();
         session.dev1_ActivityTypeName = activity.Activity.LogicalName;
         //session.activityName = activity.Activity.Name;
         session.dev1_ActivityId = activity.Activity.Id.ToString();
         session.dev1_StartTime = sessions.WeekStart;
         sessions.SelectedActivity = activity.Activity;
         sessions.AddItem(session);
         _selectedRows = new SelectedRange[1] { new SelectedRange() };
         _selectedRows[0].FromRow = rows.Count + 1;
         _selectedRows[0].ToRow = rows.Count + 1;
         Refresh();
     }
 }
        public Action NewCommand()
        {
            if (_newCommand == null)
            {
                _newCommand = delegate()
                {
                    // Remove selected rows
                   SelectedRange[] rows = new SelectedRange[0];
                   this.JobsViewModel.RaiseOnSelectedRowsChanged(rows);

                   // Create new schedule
                   ScheduledJob job = SelectedJob.GetValue();
                   job.Reset();
                };
            }
            return _newCommand;
        }