Beispiel #1
0
        private void saveButton_click(object sender, RoutedEventArgs e)
        {
            //we update the module definition
            _currentModule = _currentModule ?? new moduleDefinition()
            {
                id = Guid.NewGuid().ToString("N"), subModules = new List <subModuleDefinition>()
            };
            var validates = updateModuleDefinition(_currentModule);

            if (!validates)
            {
                return;
            }

            //and save
            var name   = _currentModule.name.Replace(' ', '-').ToLowerInvariant() + ".json";
            var dialog = new SaveFileDialog()
            {
                FileName = name, OverwritePrompt = true, Filter = "*.json|json", InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
            };
            var dialogResult = dialog.ShowDialog();

            if (dialogResult != null && dialogResult == true)
            {
                File.WriteAllText(dialog.FileName,
                                  Newtonsoft.Json.JsonConvert.SerializeObject(_currentModule));
            }
        }
Beispiel #2
0
        private void cancelButton_click(object sender, RoutedEventArgs e)
        {
            //warn that they wil lose data before attempting to close
            var msg = MessageBox.Show("Do you want to close? Unsaved changes will be lost", "Confirm action", MessageBoxButton.OKCancel);

            if (msg == MessageBoxResult.OK)
            {
                var module = new moduleDefinition()
                {
                    id = Guid.NewGuid().ToString("N")
                };
                updateView(module);
            }
        }
Beispiel #3
0
        void updateView(moduleDefinition module)
        {
            _currentModule = module;
            setValue(textModulePrefix, module.prefix);
            setValue(textModuleName, module.name);
            setValue(textModuleDescription, module.description);
            setValue(textModuleVersion, module.version);
            setValue(module.moduleType, rdbModTypePerson, rdbModTypeNonPerson, rdbModTypeGroup);
            setValue(textEmailAddress, module.userId);
            //setValue(textModuleName, module.name);

            //bind activities list
            updateActivitiesList(_currentModule.subModules);
        }
Beispiel #4
0
        bool updateModuleDefinition(moduleDefinition module)
        {
            var toReturn      = false;
            var validationRes = textRequiredValidationRules.ValidateControl(textModuleName);

            if (!validationRes.IsValid)
            {
                return(toReturn);
            }

            module.prefix = textRequiredValidationRules.getValue(textModulePrefix);

            module.name = textRequiredValidationRules.getValue(textModuleName);

            module.description = getValue(textModuleDescription);

            validationRes = textRequiredValidationRules.ValidateControl(textModuleVersion);
            if (!validationRes.IsValid)
            {
                return(toReturn);
            }
            module.version = textRequiredValidationRules.getValue(textModuleVersion);


            var moduleTypeOption = getCheckedItem(
                rdbModTypePerson, rdbModTypeNonPerson, rdbModTypeGroup);

            module.moduleType = moduleTypeOption;

            validationRes = textRequiredValidationRules.ValidateControl(textEmailAddress);
            if (!validationRes.IsValid)
            {
                return(toReturn);
            }
            module.userId = textRequiredValidationRules.getValue(textEmailAddress);
            return(true);
        }