예제 #1
0
 protected virtual void Delete()
 {
     if (SelectionMode == DataGridSelectionMode.Single || SelectionMode == DataGridSelectionMode.Extended && SelectedItems?.Count == 1)
     {
         if (MessageConfirmBox.Show(Settings.Same().AppImageUrl,
                                    $"{CurrentItem.Name}",
                                    Settings.Same().LocalisationHelper["DMLRes.ConfirmDeleteCaption"],
                                    ConfirmBoxButtons.OKCancel,
                                    ConfirmBoxImage.Question) == MessageBoxResult.OK)
         {
             try {
                 //RefNode node = _db.RefNodes.Find(Directories[SelectedIndex].Id);
                 //if (node != null) {
                 //  _db.RefNodes.Remove(node);
                 //  _db.SaveChanges();
                 //} else {
                 //  MessageConfirmBox.Show(Settings.Same().AppImageUrl, $"ID={Directories[SelectedIndex].Id}", "Данные не найдены.", ConfirmBoxButtons.Cancel, ConfirmBoxImage.Warning);
                 //}
                 int deleted = _db.Database.ExecuteSqlCommand("DELETE FROM " + TableName + " WHERE Id = " + CurrentItem.Id);
             } catch (Exception e) {
                 ErrorProcessing.Show(e);
             }
             Load();
         }
     }
     else
     {
         ExecuteDeleteDialog();
     }
 }
예제 #2
0
 public void SetImageRotate(ListContent item)
 {
     try {
         if (item.NProperty != null)
         {
             // Update
             ContentProperty rotateProperty = Settings.Instance.ContentDB.ContentProperties.Find(item.NProperty);
             if (rotateProperty != null)
             {
                 rotateProperty.Rotate = (int)item.NRotate;
                 Settings.Instance.ContentDB.Entry(rotateProperty).State = EntityState.Modified;
                 Settings.Instance.ContentDB.SaveChanges();
             }
         }
         else
         {
             // Insert
             ContentProperty rotateProperty = new ContentProperty {
                 Content = item.Id,
                 Rotate  = (int)item.NRotate
             };
             Settings.Instance.ContentDB.ContentProperties.Add(rotateProperty);
             Settings.Instance.ContentDB.SaveChanges();
             item.NProperty = GetIdContentProperties(item.Id);
         }
     } catch (Exception e) {
         ErrorProcessing.Show(e);
     }
 }
예제 #3
0
 void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
 {
     try {
         //Debug.WriteLine("------> DispatcherUnhandledException");
         ErrorProcessing.Show(e.Exception, _localisationHelper["MainWindowRes.AppDispatcherUnhandledExceptionTitleError"]);
         e.Handled = true; // помечаем необработанное исключение, как обработанное.
         Settings.Same().AppStatus = TaskStatus.Faulted;
         Shutdown();
     } catch (Exception eLocal) {
         ErrorProcessing.Show(eLocal);
     }
 }
예제 #4
0
 public KaleidoscopeImagesViewModel()
 {
     try {
         MainWindowViewModel.LocalizationChangedEvent += () => ContentMenuItemsLocalization();
         ContentMenuItemsInit();
         SelectedIndexContentMenu = 0;
         _db = Settings.Same().ContentDB;
     } catch (Exception e) {
         Settings.Same().AppStatus = TaskStatus.Faulted;
         ErrorProcessing.Show(e);
         (Application.Current as App).Shutdown();
     }
 }
예제 #5
0
 protected virtual void Insert(string name)
 {
     if (!string.IsNullOrWhiteSpace(name))
     {
         try {
             //T entity = new T() { Name = name };
             //_db.RefNodes.Add(node);
             //_db.SaveChanges();
             int inserted = _db.Database.ExecuteSqlCommand("INSERT INTO " + TableName + " (Name) VALUES ('" + name + "')");
         } catch (Exception e) {
             ErrorProcessing.Show(e, name);
         }
         Load();
     }
 }
예제 #6
0
 protected virtual void Update(string name)
 {
     if (!string.IsNullOrWhiteSpace(name))
     {
         try {
             //RefNode node = _db.RefNodes.Find(Directories[SelectedIndex].Id);
             //if (node != null) {
             //  node.Name = name;
             //  _db.Entry(node).State = EntityState.Modified;
             //  _db.SaveChanges();
             //} else {
             //  MessageConfirmBox.Show(Settings.Same().AppImageUrl, $"ID={Directories[SelectedIndex].Id}", "Данные не найдены.", ConfirmBoxButtons.Cancel, ConfirmBoxImage.Warning);
             //}
             int updated = _db.Database.ExecuteSqlCommand("UPDATE " + TableName + " SET Name = '" + name + "' WHERE Id = " + CurrentItem.Id);
         } catch (Exception e) {
             ErrorProcessing.Show(e, name);
         }
         Load();
     }
 }
예제 #7
0
 public MainWindowViewModel()
 {
     try {
         // Позиционирование
         InitLocation();
         // Настройка событий
         _window.Activated       += (o, e) => PositionSave(o, e);
         _window.Closing         += (o, e) => Closing(_window, e);
         _window.ContentRendered += (o, e) => SetUpAppSettings(_window, e);
         // Apply localization
         ResourceManagerService.ChangeLocale(Settings.Same().Localization);
         // Инициализация списков культур
         _namesOfCultures          = InitNamesOfCultures();
         ListOfLocalization        = GetListOfLocalization();
         SelectedIndexLocalization = _namesOfCultures.IndexOf(Settings.Same().Localization);
         // Временно скрываем верхнюю линейку управления, что бы не мигало при инициализации цветово палитры
         ColorZoneVisibility = Visibility.Hidden;
         // Инициализация главного меню
         MainMenuItemsInit();
         // Random ColorSet
         PaletteThemeViewModel.ThemeChanged           += () => ColorSet.Create().RedefineColors();
         MainWindowViewModel.LocalizationChangedEvent += () => ColorSet.Create().RedefineColors();
         SettingOptionsViewModel.ApplyPrimaryChanged  += () => ColorSet.Create().RedefineColors();
         SettingOptionsViewModel.ApplyAccentChanged   += () => ColorSet.Create().RedefineColors();
         _dispatcherTimerShowBusyMemory = new DispatcherTimer(TimeSpan.FromMilliseconds(1000),
                                                              DispatcherPriority.Normal,
                                                              new EventHandler(SetBusyMemoryCaption),
                                                              Dispatcher.CurrentDispatcher);
         _dispatcherTimerShowBusyMemory.Stop();
         _dispatcherTimerShowBusyMemory.Start();
     } catch (Exception e) {
         Settings.Same().AppStatus = TaskStatus.Faulted;
         ErrorProcessing.Show(e);
         (Application.Current as App).Shutdown();
     }
 }
예제 #8
0
        private void ClosingDeleteEventHandler(object sender, DialogClosingEventArgs eventArgs)
        {
            SampleProgressDialogViewModel dialog = ((eventArgs.Session.Content as SampleProgressDialog).DataContext as SampleProgressDialogViewModel);

            if ((bool)eventArgs.Parameter == false && !dialog.IsProgress)
            {
                return;
            }
            else if ((bool)eventArgs.Parameter && !dialog.IsProgress)
            {
                if (MessageConfirmBox.Show(Settings.Same().AppImageUrl,
                                           $"{SelectedItems?.Count} {GetCaptionRecords(SelectedItems.Count)}",
                                           Settings.Instance.LocalisationHelper["DMLRes.ConfirmDeleteCaption"],
                                           ConfirmBoxButtons.YesNo,
                                           ConfirmBoxImage.Question) == MessageBoxResult.No)
                {
                    return;
                }
            }
            else if ((bool)eventArgs.Parameter == false && dialog.IsProgress)
            {
                if (!dialog.IsCompletedProgress)
                {
                    if (MessageConfirmBox.Show(Settings.Instance.AppImageUrl,
                                               Settings.Instance.LocalisationHelper["DMLRes.InterruptDeleteRecordsConfirm"],
                                               "",
                                               ConfirmBoxButtons.YesNo,
                                               ConfirmBoxImage.Question
                                               ) == MessageBoxResult.No)
                    {
                        eventArgs.Cancel();
                        return;
                    }
                    else
                    {
                        _workerDeleteRecords.CancelAsync();
                        eventArgs.Cancel();
                        return;
                    }
                }
                else
                {
                    DeleteProgressEvent  -= new Action <string>(dialog.ProgressTextBlock);
                    DeleteCompletedEvent -= new Action(dialog.TrackCompletedProgress);
                    Load();
                    return;
                }
            }
            eventArgs.Cancel();
            dialog.IsProgress              = true;
            DeleteProgressEvent           += new Action <string>(dialog.ProgressTextBlock);
            DeleteCompletedEvent          += new Action(dialog.TrackCompletedProgress);
            dialog.ProgressPanelVisibility = Visibility.Visible;
            try {
                _workerDeleteRecords                            = new BackgroundWorker();
                _workerDeleteRecords.DoWork                    += new DoWorkEventHandler(Worker_DoWorkDelete);
                _workerDeleteRecords.RunWorkerCompleted        += new RunWorkerCompletedEventHandler(Worker_RunDeleteCompleted);
                _workerDeleteRecords.ProgressChanged           += new ProgressChangedEventHandler(Worker_ProgressDeleteChanged);
                _workerDeleteRecords.WorkerReportsProgress      = true;
                _workerDeleteRecords.WorkerSupportsCancellation = true;
                _workerDeleteRecords.RunWorkerAsync();
            } catch (Exception e) {
                DeleteProgressEvent  -= new Action <string>(dialog.ProgressTextBlock);
                DeleteCompletedEvent -= new Action(dialog.TrackCompletedProgress);
                ErrorProcessing.Show(e);
            }
        }