/// <summary>
        /// React on new version button click.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Ignored.</param>
        private void _NewVersionButtonClick(object sender, RoutedEventArgs e)
        {
            try
            {
                XceedGrid.EndEdit();
                WorkingStatusHelper.SetBusy((string)App.Current.FindResource("CreatingScheduleVersionStatus"));

                _UnsubscribeFromGridSelection();

                // Make version, add to project and save.
                Debug.Assert(_SelectedSchedule != null);
                Schedule newSchedule = _MakeScheduleVersion(_SelectedSchedule, _ScheduleVersions);
                App.Current.Project.Schedules.Add(newSchedule);
                App.Current.Project.Save();

                _SubscribeToGridSelection();

                // Select new schedule.
                XceedGrid.SelectedItem = newSchedule;
            }
            finally
            {
                WorkingStatusHelper.SetReleased();
            }
        }
        /// <summary>
        /// Changed selection in RadioButtons and reloads project
        /// </summary>
        /// <param name="e"></param>
        private void _ChangeSelectedProject(RoutedEventArgs e)
        {
            if (XceedGrid.SelectedIndex != -1)
            {
                Row row = XceedVisualTreeHelper.GetRowByEventArgs(e);

                Debug.Assert(row != null);

                // NOTE : when user clicks so fast on radio buttons sometimes row's content can't be updated in time.
                // In that case we should do nothing
                if (row.Cells[NAME_COLUMN_CAPTION].Content == null)
                {
                    return;
                }

                string checkedProjectName = row.Cells[NAME_COLUMN_CAPTION].Content.ToString();

                _LoadProject(checkedProjectName);
                try
                {
                    XceedGrid.EndEdit();
                }
                catch
                {
                    XceedGrid.CancelEdit();
                }
            }
        }
        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>
        /// Delete current project.
        /// </summary>
        private void _DeleteProject()
        {
            // deletes item in insertion row
            if (_InsertionRow.IsBeingEdited)
            {
                XceedGrid.CancelEdit();
                return;
            }

            if (XceedGrid.IsBeingEdited)
            {
                XceedGrid.CancelEdit();
            }

            string selectedProjectName = SelectedProjectName;

            if (selectedProjectName == null)
            {
                return;
            }

            bool doProcess = true;

            if (Settings.Default.IsAllwaysAskBeforeDeletingEnabled)
            {
                // show warning dialog
                doProcess = DeletingWarningHelper.Execute(selectedProjectName, "Project", "Project");
            }

            // do process
            if (doProcess)
            {
                _itemIndexToSelection = XceedGrid.SelectedIndex;

                string path = string.Empty;
                foreach (ProjectConfiguration project in App.Current.ProjectCatalog.Projects)
                {
                    if (project.Name.Equals(selectedProjectName, StringComparison.OrdinalIgnoreCase))
                    {
                        path = project.FilePath;
                        break; // NOTE: founded
                    }
                }

                try
                {
                    ProjectFactory.DeleteProject(path);
                    UpdateView();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(App.Current.MainWindow, ex.Message, (string)App.Current.FindResource("WarningMessageBoxTitle"), MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
 private void ProjectsPage_NavigationCalled(object sender, EventArgs e)
 {
     try
     {
         XceedGrid.CancelEdit();
         CanBeLeft = true;
     }
     catch
     {
         CanBeLeft = 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;
        }
예제 #7
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 DriversPage_NavigationCalled(object sender, EventArgs e)
        {
            try
            {
                XceedGrid.EndEdit();
                CanBeLeft = true;
            }
            catch
            {
                CanBeLeft = false;
            }

            // If there are validation errors - show them.
            CanBeLeftValidator <Driver> .ShowErrorMessagesInMessageWindow(App.Current.Project.Drivers);
        }
        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;
        }
예제 #10
0
        /// <summary>
        /// Occurs when navigation called - stops editing in datagrid control.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Ignored.</param>
        private void _BarriersPageNavigationCalled(object sender, EventArgs e)
        {
            try
            {
                XceedGrid.EndEdit();
                CanBeLeft = true;
            }
            catch
            {
                CanBeLeft = false;
            }

            // If there are validation errors - show them.
            var barriers = (IDataObjectCollection <Barrier>)_collectionSource.Source;

            CanBeLeftValidator <Barrier> .ShowErrorMessagesInMessageWindow(barriers);
        }
예제 #11
0
        private void XceedGrid_SelectionChanged(object sender, DataGridSelectionChangedEventArgs e)
        {
            if (e.SelectionInfos[0] != null && e.SelectionInfos[0].AddedItems.Count > 0)
            {
                XceedGrid.BringItemIntoView(e.SelectionInfos[0].AddedItems[0]);
            }

            _regionsPage.OnSelectionChanged(e);

            _SetSelectionStatus();

            // NOTE : event raises to notify all necessary object about selection was changed. Added because XceedGrid.SelectedItems doesn't implement INotifyCollectionChanged
            if (SelectionChanged != null)
            {
                SelectionChanged(null, EventArgs.Empty);
            }
        }
        /// <summary>
        /// Loads grid layout if it wasn't loaded before.
        /// </summary>
        private void _LoadLayout()
        {
            if (Properties.Settings.Default.ProjectGridSettings == null)
            {
                return;
            }
            if (!_isLayoutLoaded)
            {
                try
                {
                    this.XceedGrid.LoadUserSettings(Properties.Settings.Default.ProjectGridSettings, UserSettings.All);
                    _isLayoutLoaded = true;
                }
                catch
                {
                    _isLayoutLoaded = true;
                }
            }

            XceedGrid.UpdateLayout();
        }
예제 #13
0
        /// <summary>
        /// Occurs when user try navigate to other page.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LocationsPage_NavigationCalled(object sender, EventArgs e)
        {
            if (_geocodablePage.IsGeocodingInProcess)
            {
                CanBeLeft = false;
            }
            else
            {
                CanBeLeft = true;
                try
                {
                    XceedGrid.EndEdit();
                    CanBeLeft = true;
                }
                catch
                {
                    CanBeLeft = false;
                }
            }

            // If there are validation errors - show them.
            CanBeLeftValidator <Location> .ShowErrorMessagesInMessageWindow(App.Current.Project.Locations);
        }
예제 #14
0
        private void XceedGrid_SelectionChanged(object sender, DataGridSelectionChangedEventArgs e)
        {
            // NOTE : commented in xceed v 3.6  - events order changed in this version of data grid
            //if (XceedGrid.IsBeingEdited)
            //    XceedGrid.CancelEdit();
            if (e.SelectionInfos[0] != null && e.SelectionInfos[0].AddedItems.Count > 0)
            {
                XceedGrid.BringItemIntoView(e.SelectionInfos[0].AddedItems[0]);
            }

            if (_geocodablePage != null)
            {
                _geocodablePage.OnSelectionChanged(XceedGrid.SelectedItems);
            }

            // NOTE : event raises to notify all necessary object about selection was changed. Added because XceedGrid.SelectedItems doesn't implement INotifyCollectionChanged
            if (SelectionChanged != null)
            {
                SelectionChanged(null, EventArgs.Empty);
            }

            _SetSelectionStatus();
        }
예제 #15
0
        /// <summary>
        /// Occurs when navigation called - stops xceed edit.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Ignored.</param>
        private void DefaultRoutesPage_NavigationCalled(object sender, EventArgs e)
        {
            try
            {
                XceedGrid.EndEdit();
                CanBeLeft = true;
            }
            catch
            {
                CanBeLeft = false;
            }

            // If we will navigate to other page - check routes for updates.
            if (CanBeLeft)
            {
                _defaultRoutesController.CheckDefaultRoutesForUpdates();
            }
            // Else - show validation errors.
            else
            {
                CanBeLeftValidator <Route> .ShowErrorMessagesInMessageWindow
                    (App.Current.Project.DefaultRoutes);
            }
        }
예제 #16
0
 public void CancelObjectEditing()
 {
     XceedGrid.CancelEdit();
 }