Ejemplo n.º 1
0
        private void ReadXml()
        {
            data = new XMLDataHandler();
            string filename = GetFileName("xml");

            if (filename == null)
            {
                return;
            }
            try
            {
                _baseDocument       = data.LoadXML(filename);
                _generatedXDocument = new XDocument(_baseDocument);
            }
            catch (Exception ex)
            {
                SweetAlert.Show("Error while reading file:", ex.Message, msgImage: SweetAlertImage.ERROR);
            }

            _schemaPath = GetFileName("xsd");
            try
            {
                XMLValidator.ValidateSchema("http://www.gamelib.org/types", _schemaPath, _baseDocument);
            }
            catch (Exception ex)
            {
                SweetAlert.Show("XSD Schema validation error:", ex.Message, msgImage: SweetAlertImage.ERROR);
            }

            GameLibrary     = data.GameLibrary;
            BaseGameLibrary = new GameLibrary(GameLibrary);
            UpdateIds();
            RaisePropertyChanged("GamesIds");
        }
Ejemplo n.º 2
0
 private void Transform()
 {
     try
     {
         TransformedDocument = XMLTransformator.Transform(XmlPath, TransformationPath);
     }
     catch (Exception ex)
     {
         SweetAlert.Show("Error while transforming document:", ex.Message, msgImage: SweetAlertImage.ERROR);
     }
 }
Ejemplo n.º 3
0
 private void SaveXml()
 {
     try
     {
         _generatedXDocument = data.CreateXDocument();
         data.SaveXML(_generatedXDocument, "BibliotekaGierAfter.xml");
     }
     catch (Exception ex)
     {
         SweetAlert.Show("Error while saving file:", ex.Message, msgImage: SweetAlertImage.ERROR);
     }
 }
Ejemplo n.º 4
0
        private void RestoreDocument()
        {
            if (_baseDocument == null)
            {
                SweetAlert.Show("Restoring error", "Read xml document first.", msgImage: SweetAlertImage.ERROR);
                return;
            }

            GameLibrary         = new GameLibrary(BaseGameLibrary);
            data.GameLibrary    = GameLibrary;
            _generatedXDocument = new XDocument(_baseDocument);
            ;
            RaisePropertyChanged("GameLibrary");
        }
Ejemplo n.º 5
0
        public static void Main()
        {
            var confirmButton = new HTMLButtonElement
            {
                InnerHTML = "Delete file conformation",
                OnClick   = (ev) =>
                {
                    SweetAlert.Show(new SweetAlertOptions
                    {
                        Title              = "Are you sure?",
                        Text               = "You will not be able to recover this imaginary file!",
                        Type               = SweetAlertType.Warning,
                        ShowCancelButton   = true,
                        ConfirmButtonColor = "#DD6B55",
                        ConfirmButtonText  = "Yes, delete it!",
                        CancelButtonText   = "No, cancel please",
                        CloseOnConfirm     = false,
                        CloseOnCancel      = false
                    }, OnConfirmed);
                }
            };

            var promptButton = new HTMLButtonElement
            {
                InnerHTML = "Prompt example",
                OnClick   = (ev) =>
                {
                    SweetAlert.Show(new SweetAlertOptions
                    {
                        Title            = "An input!",
                        Text             = "Write something interesting:",
                        Type             = SweetAlertType.Input,
                        ShowCancelButton = true,
                        CloseOnConfirm   = false,
                        Animation        = "slide-from-top",
                        InputPlaceholder = "Write something"
                    }, OnInputConfirmed);
                }
            };

            // Add the Button to the page
            Document.Body.AppendChild(confirmButton);
            Document.Body.AppendChild(promptButton);
        }
Ejemplo n.º 6
0
 private void ReadTransformation()
 {
     TransformationPath = GetFileName("xsl");
     if (TransformationPath == null)
     {
         return;
     }
     try
     {
         var fileStream = new FileStream(TransformationPath, FileMode.Open, FileAccess.Read);
         using (var streamReader = new StreamReader(fileStream, Encoding.UTF8))
         {
             XSLDocument = streamReader.ReadToEnd();
         }
     }
     catch (IOException ex)
     {
         SweetAlert.Show("Error while reading transformation:", ex.Message, msgImage: SweetAlertImage.ERROR);
     }
 }
Ejemplo n.º 7
0
        private void SaveTransformation()
        {
            string savePath = GetFileName("");

            if (TransformationPath == null)
            {
                return;
            }
            try
            {
                if (!File.Exists(savePath))
                {
                    File.WriteAllText(savePath, TransformedDocument);
                }
            }
            catch (IOException ex)
            {
                SweetAlert.Show("Error while saving transformation:", ex.Message, msgImage: SweetAlertImage.ERROR);
            }
        }
Ejemplo n.º 8
0
        private void ValidateXml()
        {
            if (null == data.GameLibrary)
            {
                return;
            }

            try
            {
                _generatedXDocument = data.CreateXDocument();
                _schemaPath         = GetFileName("xsd");
                XMLValidator.ValidateSchema("http://www.gamelib.org/types", _schemaPath, _generatedXDocument);
            }
            catch (XmlSchemaValidationException ex)
            {
                SweetAlert.Show("XSD Schema validation error:", ex.Message, msgImage: SweetAlertImage.ERROR);
            }
            catch (Exception ex)
            {
                SweetAlert.Show("Model error:", ex.Message, msgImage: SweetAlertImage.ERROR);
            }
        }
Ejemplo n.º 9
0
 private void Event_YesNo(object sender, RoutedEventArgs e)
 {
     SweetAlert.Show("Caption", "Content", SweetAlertButton.YesNo, SweetAlertImage.INFORMATION);
 }
Ejemplo n.º 10
0
 private void Event_Information(object sender, RoutedEventArgs e)
 {
     SweetAlert.Show("Caption", "Content", msgImage: SweetAlertImage.INFORMATION);
 }
Ejemplo n.º 11
0
 private void Event_Click(object sender, RoutedEventArgs e)
 {
     SweetAlert.Show("Caption", "Content");
 }