Esempio n. 1
0
        private void ExportClassItem_Click(object sender, RoutedEventArgs e)
        {
            bool validNoise = ValidateDiagram.ValidateNoiseGeneration(DesignerViewer.networkControl.Nodes.Cast <NodeViewModel>().ToList());
            bool validNames = ValidateDiagram.ValidateUniqueNames(DesignerViewer.networkControl.Nodes.Cast <NodeViewModel>().ToList());

            if (!validNoise && validNames)
            {
                MessageBox.Show("The diagram is invalid and cannot be saved at this time. Please verify links to the final module are valid and not circular.", "Invalid", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else if (validNoise && !validNames)
            {
                MessageBox.Show("The diagram is invalid and cannot be saved at this time. Please verify all modules have unique names.", "Invalid", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else if (!validNoise && !validNames)
            {
                MessageBox.Show("The diagram is invalid and cannot be saved at this time. Please verify links to the final module are valid and not circular. Please verify all modules have unique names.", "Invalid", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                try
                {
                    SaveFileDialog saveFileDialog = new SaveFileDialog();
                    saveFileDialog.Filter = "c# class Document|*.cs";
                    saveFileDialog.Title  = "Save libnoise c# class File";
                    saveFileDialog.ShowDialog();

                    if (!string.IsNullOrEmpty(saveFileDialog.FileName))
                    {
                        StringBuilder sb = LibnoiseFileUtils.ExportToClass(DesignerViewer.networkControl.Nodes);

                        using (StreamWriter outfile = new StreamWriter(saveFileDialog.FileName))
                        {
                            outfile.Write(sb.ToString());
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("An error occured attempting to save the Libnoise Document. " + ex.Message);
                }
            }
        }
Esempio n. 2
0
        private void SaveLibnoise_Click(object sender, RoutedEventArgs e)
        {
            // validate the diagram first

            bool validNoise = ValidateDiagram.ValidateNoiseGeneration(DesignerViewer.networkControl.Nodes.Cast <NodeViewModel>().ToList());
            bool validNames = ValidateDiagram.ValidateUniqueNames(DesignerViewer.networkControl.Nodes.Cast <NodeViewModel>().ToList());

            if (!validNoise && validNames)
            {
                MessageBox.Show("The diagram is invalid and cannot be saved at this time. Please verify links to the final module are valid and not circular.", "Invalid", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else if (validNoise && !validNames)
            {
                MessageBox.Show("The diagram is invalid and cannot be saved at this time. Please verify all modules have unique names.", "Invalid", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else if (!validNoise && !validNames)
            {
                MessageBox.Show("The diagram is invalid and cannot be saved at this time. Please verify links to the final module are valid and not circular. Please verify all modules have unique names.", "Invalid", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                try
                {
                    XmlDocument doc = LibnoiseFileUtils.DiagramToXML(DesignerViewer.networkControl.Nodes);

                    SaveFileDialog saveFileDialog = new SaveFileDialog();
                    saveFileDialog.Filter = "XML Document|*.xml";
                    saveFileDialog.Title  = "Save libnoise XML File";
                    saveFileDialog.ShowDialog();

                    if (!string.IsNullOrEmpty(saveFileDialog.FileName))
                    {
                        doc.Save(saveFileDialog.FileName);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("An error occured attempting to save the Libnoise Document. " + ex.Message);
                }
            }
        }
Esempio n. 3
0
        public void Validate()
        {
            bool validNoise = ValidateDiagram.ValidateNoiseGeneration(Network.Nodes.Cast <NodeViewModel>().ToList());
            bool validNames = ValidateDiagram.ValidateUniqueNames(Network.Nodes.Cast <NodeViewModel>().ToList());

            if (!validNoise && validNames)
            {
                MessageBox.Show("The diagram is invalid. Please verify links to the final module are valid and not circular.", "Invalid", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else if (validNoise && !validNames)
            {
                MessageBox.Show("The diagram is invalid. Please verify all modules have unique names.", "Invalid", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else if (!validNoise && !validNames)
            {
                MessageBox.Show("The diagram is invalid. Please verify links to the final module are valid and not circular. Please verify all modules have unique names.", "Invalid", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                MessageBox.Show("The diagram is valid.", "Valid", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }