/// <summary>
        /// Method edits project.
        /// </summary>
        /// <param name="selectedItem"></param>
        private void _EditProject(ProjectDataWrapper selectedItem)
        {
            try
            {
                string nameOfEditedProject = selectedItem.Name;

                if (!string.IsNullOrEmpty(_projectNameBeforeEditing))
                {
                    nameOfEditedProject       = _projectNameBeforeEditing;
                    _projectNameBeforeEditing = string.Empty;
                }

                // Search project with necessary name in ProjectCatalog.
                var configs = from cfg in App.Current.ProjectCatalog.Projects
                              where cfg.Name.Equals(nameOfEditedProject)
                              select cfg;

                Debug.Assert(configs.ToList <ProjectConfiguration>().Count > 0);

                ProjectConfiguration editedProjectCfg = configs.First();


                // ProjectConfiguration editedProjectCfg = App.Current.ProjectCatalog.Projects.ElementAt(XceedGrid.SelectedIndex);

                Logger.Info("////////// Edited project " + editedProjectCfg.Name);

                Logger.Info("////////// Selected project " + selectedItem.Name);

                if (selectedItem.Description != editedProjectCfg.Description)
                {
                    editedProjectCfg.Description = selectedItem.Description;

                    // in case of editing current project need to rename at project
                    if (editedProjectCfg.Name.Equals(App.Current.Project.Name, StringComparison.OrdinalIgnoreCase))
                    {
                        App.Current.Project.Description = selectedItem.Description;
                    }
                }

                if (!selectedItem.Name.Equals(editedProjectCfg.Name, StringComparison.OrdinalIgnoreCase))
                {
                    string oldProjectName = editedProjectCfg.Name;
                    ProjectFactory.RenameProject(editedProjectCfg, selectedItem.Name, App.Current.ProjectCatalog);
                    if (oldProjectName.Equals(App.Current.Project.Name, StringComparison.OrdinalIgnoreCase))
                    {
                        Settings settings = Settings.Default;
                        settings.LastProjectName = System.IO.Path.GetFileName(editedProjectCfg.FilePath);
                        settings.Save();
                    }
                }

                editedProjectCfg.Save();
                App.Current.ProjectCatalog.Refresh();
            }
            catch (Exception ex)
            {
                Logger.Info(ex);
            }
        }
Exemplo n.º 2
0
        void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if (!Check())
            {
                return;
            }

            int value = 0;

            // сколько дней перечитывать
            if (int.TryParse(txtReadDays.Text, out value))
            {
                ProjectConfiguration.LoadDays = value;
            }
            // как часто перечитывать
            if (int.TryParse(txtUpdateTimeSec.Text, out value))
            {
                ProjectConfiguration.UpdateTimeSec = value;
            }
            //через сколько мин закрывать окно оповещения
            if (int.TryParse(txtAlertShowTimeMin.Text, out value))
            {
                ProjectConfiguration.AlertShowTimeMin = value;
            }

            // адпрес сервера
            if (ProjectConfiguration.Address != txtAddress.Text)
            {
                ProjectConfiguration.Address = txtAddress.Text;

                ServiceManager.CloseClient();
                ProjectManager.ReloadProjectsAsync();
            }

            // панель оповещений
            ProjectConfiguration.IsShowMessageMenu = cmbIsShowMessageMenu.IsChecked == true;
            ProjectConfiguration.IsHideAlertWin    = chkIsHideAlertWin.IsChecked == true;
            ProjectConfiguration.IsEnableColorsOnMainImportToExcel = cmbIsEnableColorsOnMainImportToExcel.IsChecked == true;

            ProjectConfiguration.Save();
            Close();
        }