コード例 #1
0
        private void OnExecuteLoadJournal()
        {
            _applicationGlobalCommands.SelectFileToOpen(_localizerService.GetLocalizedString("OpenJournal"),
                                                        " UJR файл (*.ujr)|*.ujr" + "|Все файлы (*.*)|*.* ").OnSuccess(info =>
            {
                var loadedJournal = _typesContainer.Resolve <ISerializerService>()
                                    .DeserializeFromFile <IUniconJournal>(info.FullName);
                if (!JournalStructureHelper.IsJournalStructureSimilar(_uniconJournal, loadedJournal))
                {
                    if (!_applicationGlobalCommands.AskUserGlobal(
                            _localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages
                                                                 .JOURNAL_STRUCTURE_WARNING_MESSAGE),
                            _localizerService.GetLocalizedString("Warning")))
                    {
                        return;
                    }
                }

                Table = new DynamicDataTable(JournalParametersNameList, null, true);
                RaisePropertyChanged(nameof(Table));
                RaisePropertyChanged(nameof(JournalParametersNameList));
                _journalLoaderProvider
                .GetJournalLoader(DeviceContext, _uniconJournal, _loaderHooks)
                .LoadFromReadyModelList(loadedJournal.JournalRecords);
                _wasLoadedOnce = true;
                _logService.LogMessage(_localizerService
                                       .GetLocalizedString("JournalOpened") + " " + info.FullName);
            });
        }
コード例 #2
0
        private void OnCheckCommandExecute()
        {
            FireErrorsChanged(nameof(TestValueOfX));
            FireErrorsChanged(nameof(FormulaString));
            if (HasErrors)
            {
                return;
            }
            _formulaFormatter.FormulaString             = FormulaString;
            _formulaFormatter.NumberOfSimbolsAfterComma = NumberOfSimbolsAfterComma;
            if (ArgumentViewModels.Count > 0)
            {
                TestResult =
                    _localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages
                                                         .DYNAMIC_VALUES_CHECKING_IMPOSSIBLE);
                return;
            }

            try
            {
                TestResult = _formattingService.FormatValueAsync(_formulaFormatter, new[] { (ushort)TestValueOfX }, new FormattingContext(null, null, true))
                             .ToString();
            }
            catch
            {
                TestResult =
                    _localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages.ERROR);
            }
        }
コード例 #3
0
        private TagBuilder CreateHeaderRows(bool isDeviceDataPrinting, bool isLocalDataPrinting)
        {
            TagBuilder tableRowForHeaders = new TagBuilder("tr");

            TagBuilder nameTableHeader = new TagBuilder("th");

            nameTableHeader.AddToInnerHtml(_localizerService.GetLocalizedString("Name"));
            tableRowForHeaders.AddTagToInnerHtml(nameTableHeader);

            if (isDeviceDataPrinting)
            {
                TagBuilder deviceDataTableHeader = new TagBuilder("th");
                deviceDataTableHeader.AddToInnerHtml(_localizerService.GetLocalizedString("DeviceData"));
                tableRowForHeaders.AddTagToInnerHtml(deviceDataTableHeader);
            }

            if (isLocalDataPrinting)
            {
                TagBuilder localDataTableHeader = new TagBuilder("th");
                localDataTableHeader.AddToInnerHtml(_localizerService.GetLocalizedString("LocalData"));
                tableRowForHeaders.AddTagToInnerHtml(localDataTableHeader);
            }

            TagBuilder measureUnitTableHeader = new TagBuilder("th");

            measureUnitTableHeader.AddToInnerHtml(_localizerService.GetLocalizedString("MeasureUnit"));

            TagBuilder rangeTableHeader = new TagBuilder("th");

            rangeTableHeader.AddToInnerHtml(_localizerService.GetLocalizedString("Range"));

            tableRowForHeaders.AddTagToInnerHtml(measureUnitTableHeader);
            tableRowForHeaders.AddTagToInnerHtml(rangeTableHeader);
            return(tableRowForHeaders);
        }
コード例 #4
0
 public FormulaFormatterViewModelValidator(ILocalizerService localizerService)
 {
     RuleFor(model => model.FormulaString).NotEmpty()
     .WithMessage(localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages
                                                      .NULL_OR_EMPTY_MESSAGE));
     RuleFor(model => model.FormulaString).Must(((args, s) => IsFormulaStringValid(s, args)))
     .WithMessage(localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages.FORMAT_ERROR));
 }
コード例 #5
0
 public DeviceEditingViewModelValidator(ILocalizerService localizerService)
 {
     RuleFor(model => model.SelectedDevice).NotNull()
     .WithMessage(localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages.SELECTED_DEVICE_NULL_MESSAGE));
     RuleFor(model => model.SelectedDeviceConnection).NotNull()
     .WithMessage(localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages.SELECTED_CONNECTION_NULL_MESSAGE));
     RuleFor(model => model.DeviceSignature).Must(s => !string.IsNullOrWhiteSpace(s))
     .WithMessage(localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages.NULL_OR_EMPTY_MESSAGE));
 }
コード例 #6
0
 public bool AskUserToDeleteSelectedGlobal(object context)
 {
     if (_dialogCoordinator.ShowModalMessageExternal(context, _localizerService.GetLocalizedString(ApplicationGlobalNames.DialogStrings.DELETE),
                                                     _localizerService.GetLocalizedString(ApplicationGlobalNames.DialogStrings.DELETE_SELECTED_ITEM_QUESTION),
                                                     MessageDialogStyle.AffirmativeAndNegative) == MessageDialogResult.Affirmative)
     {
         return(true);
     }
     return(false);
 }
コード例 #7
0
 public ComPortConfigurationViewModelValidator(ILocalizerService localizerService)
 {
     //    RuleFor(model => model.SelectedParity).Must(parity => parity != Parity.None).WithMessage(
     //        localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages.NULL_OR_EMPTY_MESSAGE));
     RuleFor(model => model.SelectedStopBits).Must(sb => sb != StopBits.None).WithMessage(
         localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages.NULL_OR_EMPTY_MESSAGE));
     RuleFor(model => model.WaitAnswer).Must(sb => sb > 0).WithMessage(
         localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages.MUST_BE_POSITIVE));
     RuleFor(model => model.WaitByte).Must(sb => sb > 0).WithMessage(
         localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages.MUST_BE_POSITIVE));
 }
コード例 #8
0
        public List <EditorValidationErrorViewModel> CheckItem(List <EditorValidationErrorViewModel> initialErrors,
                                                               IConfigurationItemViewModel configurationEditorItemViewModel,
                                                               IConfigurationEditorViewModel configurationEditorViewModel)
        {
            if (configurationEditorItemViewModel is IPropertyEditorViewModel propertyEditorViewModel &&
                !(configurationEditorItemViewModel is IComplexPropertyEditorViewModel))
            {
                if (propertyEditorViewModel.FormatterParametersViewModel == null ||
                    (propertyEditorViewModel.FormatterParametersViewModel.RelatedUshortsFormatterViewModel == null &&
                     !propertyEditorViewModel.FormatterParametersViewModel.IsFromSharedResources))
                {
                    initialErrors.Add(new EditorValidationErrorViewModel(
                                          $"{propertyEditorViewModel.Name} ({_localizerService.GetLocalizedString("Address")}:{propertyEditorViewModel.Address}): {_localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages.EMPTY_FORMATTING_MESSAGE)}",
                                          Result <Action> .Create(
                                              () =>
                    {
                        _formatterEditorFactory.EditFormatterByUser(propertyEditorViewModel,
                                                                    configurationEditorViewModel.RootConfigurationItemViewModels.ToList());
                    }, true)));
                }

                if (propertyEditorViewModel.FormatterParametersViewModel != null &&

                    propertyEditorViewModel.FormatterParametersViewModel.IsFromSharedResources &&
                    _sharedResourcesGlobalViewModel.GetResourceByName(propertyEditorViewModel
                                                                      .FormatterParametersViewModel.Name) == null)
                {
                    initialErrors.Add(new EditorValidationErrorViewModel(
                                          $"{propertyEditorViewModel.Name} ({_localizerService.GetLocalizedString("Address")}:{propertyEditorViewModel.Address}): {_localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages.FORMATTING_RESOURCE_NOT_FOUND_MESSAGE)}",
                                          Result <Action> .Create(
                                              () =>
                    {
                        _formatterEditorFactory.EditFormatterByUser(propertyEditorViewModel,
                                                                    configurationEditorViewModel.RootConfigurationItemViewModels.ToList());
                    }, true)));
                }
            }

            if (configurationEditorItemViewModel is IConfigurationGroupEditorViewModel configurationGroupEditorViewModel
                )
            {
                configurationGroupEditorViewModel.ChildStructItemViewModels.ForEach(model =>
                                                                                    CheckItem(initialErrors, model, configurationEditorViewModel));
            }

            if (configurationEditorItemViewModel is IComplexPropertyEditorViewModel complexPropertyEditorViewModel)
            {
                complexPropertyEditorViewModel.SubPropertyEditorViewModels.ForEach(model =>
                                                                                   CheckItem(initialErrors, model, configurationEditorViewModel));
            }

            return(initialErrors);
        }
コード例 #9
0
 public PropertyEditorEditorViewModelValidator(ILocalizerService localizerService)
 {
     RuleFor(model => model.Address).Must(s =>
     {
         ushort u;
         return(ushort.TryParse(s, out u));
     }).WithMessage(localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages.FORMAT_ERROR));
     RuleFor(model => model.NumberOfPoints).Must(s =>
     {
         ushort u;
         return(ushort.TryParse(s, out u));
     }).WithMessage(localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages.FORMAT_ERROR));
 }
コード例 #10
0
 public DictionaryMatchingFormatterValidator(ILocalizerService localizerService)
 {
     RuleFor(model => model.KeyValuesDictionary)
     .Must(pairs => !pairs.GroupBy(pair => pair.Key).Any(grouping => grouping.Count() > 1))
     .WithMessage(
         localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages
                                             .DUBLICATE_VALUES_MESSAGE));
 }
コード例 #11
0
        public IRuntimeBaseValuesViewModel CreateRuntimeBaseValuesViewModel(
            IConfigurationBaseValues configurationBaseValues, DeviceContext deviceContext)
        {
            if (configurationBaseValues == null)
            {
                return(new RuntimeBaseValuesViewModel(new List <IRuntimeBaseValueViewModel>()));
            }

            return(new RuntimeBaseValuesViewModel(configurationBaseValues.BaseValues.Select(value =>
                                                                                            new RuntimeBaseValueViewModel(value.Name, new RelayCommand(
                                                                                                                              () =>
            {
                if (_applicationGlobalCommands.AskUserGlobal(
                        _localizerService.GetLocalizedString(ApplicationGlobalNames.DialogStrings
                                                             .ARE_YOU_SURE_TO_APPLY_VALUES) + ": " + value.Name,
                        _localizerService.GetLocalizedString("BasicValues")))
                {
                    var addresses = value.LocalMemoryValues.Keys.ToArray();
                    foreach (var address in addresses)
                    {
                        if (deviceContext.DeviceMemory.LocalMemoryValues.ContainsKey(address))
                        {
                            deviceContext.DeviceMemory.LocalMemoryValues[address] =
                                value.LocalMemoryValues[address];
                        }
                        else
                        {
                            deviceContext.DeviceMemory.LocalMemoryValues.Add(address,
                                                                             value.LocalMemoryValues[address]);
                        }
                    }

                    foreach (var address in addresses)
                    {
                        deviceContext.DeviceEventsDispatcher.TriggerLocalAddressSubscription(
                            address, 1, MemoryKind.UshortMemory);
                    }
                }
            }
                                                                                                                              ))).Cast <IRuntimeBaseValueViewModel>().ToList()));
        }
コード例 #12
0
 private void OnDeleteFragmentExecute(object obj)
 {
     if (!(obj is IFragmentEditorViewModel))
     {
         return;
     }
     if (_dialogCoordinator.ShowModalMessageExternal(this,
                                                     _localizerService.GetLocalizedString(ApplicationGlobalNames.DialogStrings.DELETE),
                                                     _localizerService.GetLocalizedString(ApplicationGlobalNames.DialogStrings
                                                                                          .DELETE_SELECTED_ITEM_QUESTION) + " (" +
                                                     _localizerService.GetLocalizedString((obj as IFragmentEditorViewModel).NameForUiKey) + ") ",
                                                     MessageDialogStyle.AffirmativeAndNegative) ==
         MessageDialogResult.Affirmative)
     {
         ResultingDeviceViewModel.FragmentEditorViewModels.Remove(obj as IFragmentEditorViewModel);
     }
 }
コード例 #13
0
 public ModbusEntityEditingViewModelValidator(ILocalizerService localizerService)
 {
     RuleFor(model => model.ValueDec).Must(s =>
     {
         ushort u;
         return(ushort.TryParse(s, out u));
     }).WithMessage(localizerService.GetLocalizedString(
                        ApplicationGlobalNames.StatusMessages.VALUE_OUT_OF_RANGE_MESSAGE_KEY) + " (0-65535)");
     RuleFor(model => model.ValueHex).Must(s =>
     {
         try
         {
             Convert.ToInt16(s, 16);
         }
         catch
         {
             return(false);
         }
         return(true);
     }).WithMessage(localizerService.GetLocalizedString(
                        ApplicationGlobalNames.StatusMessages.VALUE_OUT_OF_RANGE_MESSAGE_KEY) + " (0-65535)");
 }
コード例 #14
0
 public RangeViewModelValidator(ILocalizerService localizerService)
 {
     RuleFor(model => model.RangeTo).Must((s =>
     {
         double x;
         return(double.TryParse(s, out x));
     })).WithMessage(localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages.FORMAT_ERROR));
     RuleFor(model => model.RangeFrom).Must((s =>
     {
         double x;
         return(double.TryParse(s, out x));
     })).WithMessage(localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages.FORMAT_ERROR));
     RuleFor(model => model.RangeTo).Must((fooArgs, rangeTo) =>
     {
         double rFrom;
         double rTo;
         if ((!double.TryParse(rangeTo, out rTo)) ||
             (!double.TryParse(fooArgs.RangeFrom, out rFrom)))
         {
             return(false);
         }
         return(rTo >= rFrom);
     }).WithMessage(
         localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages.INVALID_RANGE_ERROR));
     RuleFor(model => model.RangeFrom).Must((fooArgs, rangeFrom) =>
     {
         double rFrom;
         double rTo;
         if ((!double.TryParse(fooArgs.RangeTo, out rTo)) ||
             (!double.TryParse(rangeFrom, out rFrom)))
         {
             return(false);
         }
         return(rTo >= rFrom);
     }).WithMessage(
         localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages.INVALID_RANGE_ERROR));
 }
コード例 #15
0
ファイル: LogService.cs プロジェクト: Pepega-corp/Un2
        public void LogMessage(string messageKey, LogMessageTypeEnum messageType = LogMessageTypeEnum.Info)
        {
            ILogMessage logMessage = _logMessageGettingFunc();

            logMessage.LogMessageType = messageType;
            logMessage.MessageSubject = _localizerService.GetLocalizedString(ApplicationGlobalNames.GENERAL);
            string localizedString = String.Empty;

            if (!_localizerService.TryGetLocalizedString(messageKey, out localizedString))
            {
                localizedString = messageKey;
            }
            logMessage.Description     = localizedString;
            logMessage.MessageDateTime = DateTime.Now;
            NewMessageAction?.Invoke(logMessage);
        }
コード例 #16
0
        public List <EditorValidationErrorViewModel> CheckItem(List <EditorValidationErrorViewModel> initialErrors,
                                                               IConfigurationItemViewModel configurationEditorViewModel)
        {
            if (configurationEditorViewModel is IPropertyEditorViewModel propertyEditorViewModel &&
                !(configurationEditorViewModel is IComplexPropertyEditorViewModel))
            {
                var resources = propertyEditorViewModel.DependencyViewModels
                                .Where(model => model is ConditionResultDependencyViewModel)
                                .Select(model => (model as ConditionResultDependencyViewModel).SelectedConditionViewModel)
                                .Where(model => model is RegexMatchConditionViewModel)
                                .Cast <RegexMatchConditionViewModel>()
                                .Select(model => _sharedResourcesGlobalViewModel.GetResourceViewModelByName(model.ReferencedResourcePropertyName))
                                .Choose()
                                .Where(nameable => nameable is IPropertyEditorViewModel)
                                .Select(nameable => (nameable as IPropertyEditorViewModel).FormatterParametersViewModel)
                                .ToList();



                if (resources.Any(model => !_formatterInfoService.ReturnsString(model.RelatedUshortsFormatterViewModel)))
                {
                    initialErrors.Add(new EditorValidationErrorViewModel(
                                          $"{propertyEditorViewModel.Name} ({_localizerService.GetLocalizedString("Address")}:{propertyEditorViewModel.Address}): {_localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages.REGEX_RESOURCE_FORMATTER_IS_NOT_STRING_MESSAGE)}",
                                          Result <Action> .Create(
                                              () =>
                    {
                        _dependenciesService.EditDependencies(propertyEditorViewModel,
                                                              new DependenciesConfiguration(("ConditionResultDependency",
                                                                                             () => _dependencyFillHelper.CreateEmptyConditionResultDependencyViewModel())));
                    }, true)));
                }
            }

            if (configurationEditorViewModel is IConfigurationGroupEditorViewModel configurationGroupEditorViewModel)
            {
                configurationGroupEditorViewModel.ChildStructItemViewModels.ForEach(model =>
                                                                                    CheckItem(initialErrors, model));
            }

            if (configurationEditorViewModel is IComplexPropertyEditorViewModel complexPropertyEditorViewModel)
            {
                complexPropertyEditorViewModel.SubPropertyEditorViewModels.ForEach(model =>
                                                                                   CheckItem(initialErrors, model));
            }

            return(initialErrors);
        }
コード例 #17
0
        public List <EditorValidationErrorViewModel> CheckItem(List <EditorValidationErrorViewModel> initialErrors,
                                                               IConfigurationItemViewModel configurationEditorViewModel)
        {
            if (configurationEditorViewModel is IPropertyEditorViewModel propertyEditorViewModel &&
                !(configurationEditorViewModel is IComplexPropertyEditorViewModel))
            {
                var dependenciesWithResources = propertyEditorViewModel.DependencyViewModels
                                                .Where(model => model is ConditionResultDependencyViewModel)
                                                .Select(model => (model as ConditionResultDependencyViewModel).SelectedConditionViewModel)
                                                .Where(model => model is IConditionWithResourceViewModel)
                                                .Cast <IConditionWithResourceViewModel>()
                                                .ToList();

                if (dependenciesWithResources.Any(model =>
                                                  string.IsNullOrEmpty(model.ReferencedResourcePropertyName)) ||
                    dependenciesWithResources.Any(model =>
                                                  !_sharedResourcesGlobalViewModel.GetResourceViewModelByName(
                                                      model.ReferencedResourcePropertyName).IsSuccess))
                {
                    initialErrors.Add(new EditorValidationErrorViewModel(
                                          $"{propertyEditorViewModel.Name} ({_localizerService.GetLocalizedString("Address")}:{propertyEditorViewModel.Address}): {_localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages.RESOURCE_FOR_DEPENDENCY_NOT_FOUND_MESSAGE)}",
                                          Result <Action> .Create(
                                              () =>
                    {
                        _dependenciesService.EditDependencies(propertyEditorViewModel,
                                                              new DependenciesConfiguration(("ConditionResultDependency",
                                                                                             () => _dependencyFillHelper.CreateEmptyConditionResultDependencyViewModel())));
                    }, true)));
                }
            }

            if (configurationEditorViewModel is IConfigurationGroupEditorViewModel configurationGroupEditorViewModel)
            {
                configurationGroupEditorViewModel.ChildStructItemViewModels.ForEach(model =>
                                                                                    CheckItem(initialErrors, model));
            }

            if (configurationEditorViewModel is IComplexPropertyEditorViewModel complexPropertyEditorViewModel)
            {
                complexPropertyEditorViewModel.SubPropertyEditorViewModels.ForEach(model =>
                                                                                   CheckItem(initialErrors, model));
            }

            return(initialErrors);
        }
コード例 #18
0
        public ResultingDeviceViewModel(IDevice device, ITypesContainer container, ILocalizerService localizerService,
                                        IDeviceSharedResources deviceSharedResources, IApplicationGlobalCommands applicationGlobalCommands,
                                        ISharedResourcesGlobalViewModel sharedResourcesGlobalViewModel,
                                        IFragmentEditorViewModelFactory fragmentEditorViewModelFactory,
                                        IConnectionStateViewModelFactory connectionStateViewModelFactory, ISerializerService serializerService)
        {
            _device                          = device;
            _container                       = container;
            _deviceSharedResources           = deviceSharedResources;
            _applicationGlobalCommands       = applicationGlobalCommands;
            _sharedResourcesGlobalViewModel  = sharedResourcesGlobalViewModel;
            _fragmentEditorViewModelFactory  = fragmentEditorViewModelFactory;
            _connectionStateViewModelFactory = connectionStateViewModelFactory;
            _serializerService               = serializerService;

            DeviceName =
                localizerService.GetLocalizedString(ApplicationGlobalNames.DefaultStringsForUi.NEW_DEVICE_STRING);
            FragmentEditorViewModels = new ObservableCollection <IFragmentEditorViewModel>();
            sharedResourcesGlobalViewModel.InitializeFromResources(deviceSharedResources);
            NavigateToConnectionTestingCommand = new RelayCommand(OnNavigateToConnectionTestingExecute);
        }
コード例 #19
0
        public void LoadDevicesDefinitions(string folderPath = ApplicationGlobalNames.DEFAULT_DEVICES_FOLDER_PATH)
        {
            if (!(Directory.Exists(folderPath)))
            {
                return;
            }
            string[] names = Directory.GetFiles(folderPath).Select((s => Path.GetFileName(s))).ToArray();
            Creators = new List <IDeviceCreator>();

            foreach (string name in names.Where(name => name.Contains("json")))
            {
                IDeviceCreator deviceCreator = _deviceCreatorGettingFunc();

                deviceCreator.DeviceDescriptionFilePath = Path.Combine(folderPath, name);

                IDevice device = _deviceGettingFunc();
                try
                {
                    device = _serializerService.DeserializeFromFile <IDevice>(deviceCreator.DeviceDescriptionFilePath);
                    deviceCreator.ConnectionState = device.ConnectionState.Clone() as IConnectionState;

                    deviceCreator.DeviceName = Path.GetFileNameWithoutExtension(name);

                    deviceCreator.DeviceMetaInfo = device.DeviceMetaInfo;

                    Creators.Add(deviceCreator);
                }
                catch
                {
                    var message =
                        _localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages
                                                             .DEVICE_READING_ERROR);
                    _logService.LogMessage(message + " " + name);
                }
            }
        }
コード例 #20
0
        /// <summary>
        /// Проверить сохранен ли проект
        /// </summary>
        /// <returns>Было ли взаимодействие с пользователем по сохранению проекта</returns>
        public ProjectSaveCheckingResultEnum CheckIfProjectSaved()
        {
            if (GetIsProjectChanged(_uniconProject))
            {
                MessageDialogResult result = _dialogCoordinator().ShowModalMessageExternal(_dialogContext,
                                                                                           "Сохранение",
                                                                                           "Проект не был сохранен. Сохранить проект?",
                                                                                           MessageDialogStyle.AffirmativeAndNegativeAndSingleAuxiliary,
                                                                                           new MetroDialogSettings
                {
                    FirstAuxiliaryButtonText =
                        _localizerService.GetLocalizedString(ApplicationGlobalNames.DialogStrings.CANCEL),
                    AffirmativeButtonText =
                        _localizerService.GetLocalizedString(ApplicationGlobalNames.DialogStrings.YES),
                    NegativeButtonText =
                        _localizerService.GetLocalizedString(ApplicationGlobalNames.DialogStrings.NO)
                });
                if (result == MessageDialogResult.FirstAuxiliary)
                {
                    return(ProjectSaveCheckingResultEnum.CancelledByUser);
                }

                if (result == MessageDialogResult.Affirmative)
                {
                    SaveProjectInFile(false);
                    return(ProjectSaveCheckingResultEnum.ProjectSavedByUserInDialog);
                }

                if (result == MessageDialogResult.Negative)
                {
                    return(ProjectSaveCheckingResultEnum.UserRejectedSaving);
                }
            }

            return(ProjectSaveCheckingResultEnum.ProjectAlreadySaved);
        }
コード例 #21
0
 private void LoggersCollectionChanged()
 {
     FilteringMessageSourceCollection = new ObservableCollection <string>(_logService.GetLoggersEnumerable().Select((logger => logger.SourceName)));
     FilteringMessageSourceCollection.Insert(0, _localizerService.GetLocalizedString(ApplicationGlobalNames.DefaultStringsForUi.ALL_STRING_KEY));
     RaisePropertyChanged(nameof(FilteringMessageSourceCollection));
 }
コード例 #22
0
 public ModBusConnectionViewModelValidator(ILocalizerService localizerService)
 {
     RuleFor(model => model.SelectedPort).Must(s => !string.IsNullOrWhiteSpace(s)).WithMessage(
         localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages
                                             .PORT_NOT_SELECTED));
 }
コード例 #23
0
 public DateTimeViewModelValidator(ILocalizerService localizerService)
 {
     RuleFor(model => model.Date).Matches(@"\b(0[1-9]|[12][0-9]|3[01])\b[,]\b(0[1-9]|1[0-2])\b[,]\b(0[0-9]|[1-9][0-9])\b$$").WithMessage(localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages.FORMAT_ERROR) + " (" + localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages.DATE_FORMAT) + ")");
     RuleFor(model => model.Time).Matches(@"^(?:(?:([01]?\d|2[0-3]):)?([0-5]?\d):)?([0-5]?\d),(\d{1}|\d{3}|\d{2})$").WithMessage(localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages.FORMAT_ERROR));;
 }