Exemplo n.º 1
0
        private void gridAttributeTypes_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
        {
            //if (e.Column == checkedColumn)
            //    return;

            if (e.Row != null && e.Row.Item is FakeAttributeType)
            {
                FakeAttributeType editedAttributeType = ((FakeAttributeType)e.Row.Item);
                if (!editedAttributeType.Checked)
                {
                }

                if (editedAttributeType.IsSealed)
                {
                    ExolutioErrorMsgBox.Show("This is a built-in type and it can not be changed.", "Built-in types can not be created, deleted or modified by the user. ");
                    e.Cancel = true;
                }

                if (e.Column == isSealedPIM || e.Column == isSealedPSM)
                {
                    ExolutioErrorMsgBox.Show("This property can not be modified.", "It is not possible to add more built-in types into the system. ");
                    return;
                }

                //if (e.Column == baseTypeColumn && editedAttribute.RepresentedAttribute != null)
                //{
                //    ErrorMsgBox.Show("Type can be changed only for PIM-less attributes. ", "You can change the represented attribute's type instead. ");
                //}
            }
        }
Exemplo n.º 2
0
        private void bValidateNew_Click(object sender, RoutedEventArgs e)
        {
            XsdValidator validator = new XsdValidator();
            bool         valid     = validator.ValidateDocument(schemaVersion2, tbNewDoc.Text);

            if (valid)
            {
                ExolutioMessageBox.Show("Validation", "Valid", "The new version is valid.");
            }
            else
            {
                ExolutioErrorMsgBox.Show("ERROR - The new version is not valid!", validator.ErrorMessage);
            }
        }
Exemplo n.º 3
0
        private void DoExecute()
        {
            CommandDescriptor commandDescriptor =
                PublicCommandsHelper.GetCommandDescriptor(ControllerCommandType);

            commandDescriptor.ClearParameterValues();
            OperationParametersControlCreator.ReadParameterValues(commandDescriptor, controls);
            foreach (ParameterDescriptor parameterDescriptor in commandDescriptor.Parameters)
            {
                if (parameterDescriptor.ParameterPropertyInfo == commandDescriptor.ScopeProperty)
                {
                    parameterDescriptor.ParameterValue = ((ExolutioObject)this.ScopeObject).ID;
                }
            }
            CreateControllerCommand();
            CommandSerializer.FillParameters(ControllerCommand, commandDescriptor);
            ControllerCommand.CanExecuteChanged -= OnControllerCommandCanExecuteChanged;
            if (!ControllerCommand.CanExecute())
            {
#if SILVERLIGHT
                ExolutioErrorMsgBox.Show("Command can not be executed", ControllerCommand.ErrorDescription);
#else
                ExolutioErrorMsgBox.Show("Command can not be executed", ControllerCommand.ErrorDescription);
#endif
            }
            else
            {
                if (ControllerCommand is StackedCommand)
                {
                    if (((StackedCommand)ControllerCommand).Controller == null)
                    {
                        ((StackedCommand)ControllerCommand).Controller = Current.Controller;
                    }
                }
                try
                {
                    ControllerCommand.Execute();
                }
                catch (ExolutioCommandException e)
                {
                    ExolutioErrorMsgBox.Show("Command " + e.Command.GetType().ToString() + " can not be executed", e.Command.ErrorDescription);
                }
            }
            ControllerCommand = null;
        }
Exemplo n.º 4
0
        private void DataGridCell_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            DataGridCell cell = sender as DataGridCell;

            System.Windows.Controls.CheckBox cb = cell.Content as System.Windows.Controls.CheckBox;
            if (cb != null)
            {
                if (cell != null &&
                    !cell.IsEditing)
                {
                    try
                    {
                        if (!cell.IsFocused)
                        {
                            cell.Focus();
                        }
                    }
                    catch (Exception)
                    {
                    }

                    DataGrid dataGrid = FindVisualParent <DataGrid>(cell);
                    if (dataGrid != null)
                    {
                        if (dataGrid.SelectionUnit != DataGridSelectionUnit.FullRow)
                        {
                            if (!cell.IsSelected)
                            {
                                cell.IsSelected = true;
                            }
                        }
                        else
                        {
                            DataGridRow row = FindVisualParent <DataGridRow>(cell);

                            if (row != null && !row.IsSelected)
                            {
                                row.IsSelected = true;
                            }

                            if (row.Item is FakeAttributeType)
                            {
                                if (cell.Column == isSealedPIM || cell.Column == isSealedPSM)
                                {
                                    if (cb.IsChecked == true)
                                    {
                                        ExolutioErrorMsgBox.Show("This is a built-in type and it can not be changed.", "Built-in types can not be created, deleted or modified by the user. ");
                                        return;
                                    }
                                    else
                                    {
                                        ExolutioErrorMsgBox.Show("This property can not be modified.", "It is not possible to add more built-in types into the system. ");
                                        return;
                                    }
                                }
                                if (cell.Column == checkedColumnPIM || cell.Column == checkedColumnPSM)
                                {
                                    if (((FakeAttributeType)row.Item).IsSealed)
                                    {
                                        ExolutioErrorMsgBox.Show("This is a built-in type and it can not be changed.", "Built-in types can not be created, deleted or modified by the user. ");
                                        return;
                                    }
                                }
                                cb.IsChecked = !cb.IsChecked.Value;
                                ((FakeAttributeType)row.Item).Checked = cb.IsChecked.Value;
                                UpdateApplyEnabled();
                            }
                        }
                        dataGrid.SelectedItem = null;
                    }
                }
            }
        }
Exemplo n.º 5
0
        private void ValidateDocumentAgainstSchema(XDocument schemaXSD)
        {
            XmlReader    xmlfile       = null;
            XmlReader    schemaReader  = null;
            MemoryStream _msSchemaText = null;

            isValidAgainstSchema         = true;
            abortValidationAgainstSchema = false;
            try
            {
                _msSchemaText = new MemoryStream();
                string tmp = System.IO.Path.GetTempFileName();
                schemaXSD.Save(tmp);
                schemaReader = new XmlTextReader(File.OpenRead(tmp));
                XmlSchema         schema         = XmlSchema.Read(schemaReader, schemaSettings_ValidationEventHandler);
                XmlReaderSettings schemaSettings = new XmlReaderSettings();
                schemaSettings.Schemas.Add(schema);
                foreach (XmlSchema s in schemaSettings.Schemas.Schemas())
                {
                    StringBuilder sb = new StringBuilder();
                    StringWriter  sw = new StringWriter(sb);
                    s.Write(sw);
                    sw.Flush();
                }

                schemaSettings.ValidationType          = ValidationType.Schema;
                schemaSettings.ValidationEventHandler += schemaSettings_ValidationEventHandler;

                try
                {
                    xmlfile = XmlReader.Create(new StringReader(fileView.FileContents), schemaSettings);
                }
                catch (XmlSchemaValidationException ex)
                {
                    isValidAgainstSchema = false;
                    ExolutioErrorMsgBox.Show("Invalid schema",
                                             string.Format("Validation can not continue - schema is invalid. \r\n\r\n{0}",
                                                           ex.Message));
                    return;
                }

                if (isValidAgainstSchema)
                {
                    while (xmlfile.Read() && !abortValidationAgainstSchema)
                    {
                    }
                }
            }
            catch (XmlSchemaValidationException ex)
            {
                isValidAgainstSchema = false;
                ExolutioErrorMsgBox.Show("Invalid document",
                                         string.Format("{0} \r\n\r\nValidation can not continue.", ex.Message));
            }
            catch (Exception ex)
            {
                isValidAgainstSchema = false;
                ExolutioErrorMsgBox.Show("Invalid document",
                                         string.Format("{0} \r\n\r\nValidation can not continue.", ex.Message));
            }
            finally
            {
                if (xmlfile != null)
                {
                    xmlfile.Close();
                }
                if (schemaReader != null)
                {
                    schemaReader.Close();
                }
                if (_msSchemaText != null)
                {
                    _msSchemaText.Dispose();
                }
            }

            if (isValidAgainstSchema)
            {
                ExolutioMessageBox.Show("Validation successful", "Document is valid",
                                        "Validation against the XML schema passed successfuly. ");
            }
        }