private void DataGridCollectionViewSource_EditBegun(object sender, DataGridItemEventArgs e)
        {
            if (XceedGrid.CurrentColumn == XceedGrid.Columns[IS_CURRENT_COLUMN_CAPTION]) // if user clicks to "IsCurrent" cell - don't show editing status.
            {
                return;
            }

            string selectedProjectName = SelectedProjectName;

            Row parentRow = (Row)XceedGrid.GetContainerFromItem(e.Item);

            if (null == parentRow)
            {
                return;
            }

            bool stopEdit = false;

            if (XceedGrid.CurrentColumn == XceedGrid.Columns[NAME_COLUMN_CAPTION])
            {
                _projectNameBeforeEditing = ((ProjectDataWrapper)e.Item).Name;

                if (null != CurrentProjectName)
                {
                    if ((null != selectedProjectName) && selectedProjectName.Equals(CurrentProjectName, StringComparison.OrdinalIgnoreCase))
                    {
                        stopEdit = true;
                    }
                }
            }
            parentRow.Cells[IS_CURRENT_COLUMN_CAPTION].IsEnabled = stopEdit;

            Cell cell = parentRow.Cells[NAME_COLUMN_CAPTION];

            cell.ReadOnly = stopEdit;
            if (stopEdit)
            {
                string status = (string)App.Current.FindResource("UnaEditCurrentProjectNameTooltip");
                cell.ToolTip = status;
                cell.EndEdit();
                parentRow.CancelEdit();
                _isForcingEndEdit = true;

                App.Current.MainWindow.StatusBar.SetStatus(this, status);
                _needToUpdateStatus = false;
            }
            else
            {
                if (null != selectedProjectName)
                {
                    _statusBuilder.FillEditingStatus(selectedProjectName, PROJECT_TYPE_NAME, this);
                    _needToUpdateStatus = false;
                }
            }
        }
        /// <summary>
        /// Occurs when user press "enter" on edited grid row.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DataGridCollectionViewSource_CommittingEdit(object sender, DataGridItemCancelEventArgs e)
        {
            App.Current.MainWindow.StatusBar.SetStatus(this, null);

            Row parentRow = (Row)XceedGrid.GetContainerFromItem(e.Item);

            parentRow.Cells[IS_CURRENT_COLUMN_CAPTION].IsEnabled = true;

            ProjectDataWrapper editedItem = e.Item as ProjectDataWrapper;

            _EditProject(editedItem);

            e.Handled = true;
        }
Beispiel #3
0
        /// <summary>
        /// Occurs when user changes any property in mobile device
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void device_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            // if any property except "SyncType" was changed - return
            if (e.PropertyName != MobileDevice.PropertyNameSyncType)
            {
                return;
            }

            DataRow row = null; // edited row

            if (_InsertionRow.IsBeingEdited)
            {
                row = _InsertionRow; // if insertion row is in editing - use insertion row as current row
            }
            else
            {
                row = XceedGrid.GetContainerFromItem(XceedGrid.CurrentItem) as DataRow; // otherwise - get current row by current item
            }
            Debug.Assert(row != null);

            MobileDevice device = (MobileDevice)sender; // edited mobile device

            Debug.Assert(device != null);

            // update value in field corresponding to sync type for show validation
            switch (device.SyncType)
            {
            case SyncType.None:
                break;

            case SyncType.EMail:
                device.EmailAddress = (string)row.Cells[MobileDevice.PropertyNameEmailAddress].Content;
                break;

            case SyncType.ActiveSync:
                device.ActiveSyncProfileName = (string)row.Cells[MobileDevice.PropertyNameActiveSyncProfileName].Content;
                break;

            case SyncType.Folder:
                device.SyncFolder = (string)row.Cells[MobileDevice.PropertyNameSyncFolder].Content;
                break;

            case SyncType.WMServer:
                device.TrackingId = (string)row.Cells[MobileDevice.PropertyNameName].Content;
                break;

            default:
                break;
            }
        }
        private void DataGridCollectionViewSource_CancelingEdit(object sender, DataGridItemHandledEventArgs e)
        {
            if (!_isForcingEndEdit)
            {
                App.Current.MainWindow.StatusBar.SetStatus(this, null);
            }
            _isForcingEndEdit = false;

            Row parentRow = (Row)XceedGrid.GetContainerFromItem(e.Item);

            parentRow.Cells[IS_CURRENT_COLUMN_CAPTION].IsEnabled = true;

            _projectNameBeforeEditing = string.Empty;

            e.Handled = true;
        }