public PreviewWindow(ImpObservableCollection<object> nodes)
        {
            InitializeComponent();

            // clone the module by generating a new module via serialization
            // this is not the nicest way of doing this, so we'll improve it later with a proper clone mechanism
            // for now though, it works quite well
            XmlDocument doc = LibnoiseFileUtils.DiagramToXML(nodes);
            ModuleBase module = LibnoiseFileUtils.LoadLibnoiseXml(doc);
            SetSeeds(module, 0);

            this.nodes = nodes;
            this.module = module;

            imageWidth = 512;
            imageHeight = 512;

            selectedNoiseStyle = NoiseStyles.Planar;
            selectedColorStyle = ColourStyles.Greyscale;

            GeneratePreview();
        }
Beispiel #2
0
        public PreviewWindow(ImpObservableCollection <object> nodes)
        {
            InitializeComponent();

            // clone the module by generating a new module via serialization
            // this is not the nicest way of doing this, so we'll improve it later with a proper clone mechanism
            // for now though, it works quite well
            XmlDocument doc    = LibnoiseFileUtils.DiagramToXML(nodes);
            ModuleBase  module = LibnoiseFileUtils.LoadLibnoiseXml(doc);

            SetSeeds(module, 0);

            this.nodes  = nodes;
            this.module = module;

            imageWidth  = 512;
            imageHeight = 512;

            selectedNoiseStyle = NoiseStyles.Planar;
            selectedColorStyle = ColourStyles.Greyscale;

            GeneratePreview();
        }
        private void PreviewButton_Click(object sender, RoutedEventArgs e)
        {
            // validate the height/width first
            bool widthValid = Int32.TryParse(WidthBox.Text, out imageWidth);
            bool heightValid = Int32.TryParse(HeightBox.Text, out imageHeight);
            bool seedValid = Int32.TryParse(SeedBox.Text, out seed);

            if (!widthValid) WidthBox.BorderBrush = System.Windows.Media.Brushes.Red;
            else WidthBox.BorderBrush = System.Windows.Media.Brushes.CornflowerBlue;

            if (!heightValid) HeightBox.BorderBrush = System.Windows.Media.Brushes.Red;
            else HeightBox.BorderBrush = System.Windows.Media.Brushes.CornflowerBlue;

            if (!seedValid) SeedBox.BorderBrush = System.Windows.Media.Brushes.Red;
            else SeedBox.BorderBrush = System.Windows.Media.Brushes.CornflowerBlue;

            string noiseStyle = ((ComboBoxItem)NoiseStyle.SelectedItem).Content.ToString();
            string colorStyle = ((ComboBoxItem)ColourStyle.SelectedItem).Content.ToString();

            if (noiseStyle.Equals("Planar")) selectedNoiseStyle = NoiseStyles.Planar;
            else if (noiseStyle.Equals("Cylindrical")) selectedNoiseStyle = NoiseStyles.Cylindrical;
            else selectedNoiseStyle = NoiseStyles.Spherical;

            if (colorStyle.Equals("Grayscale")) selectedColorStyle = ColourStyles.Greyscale;
            else if (colorStyle.Equals("Blue/Red")) selectedColorStyle = ColourStyles.RedBlue;
            else selectedColorStyle = ColourStyles.World;

            if (seedValid)
            {
                // clone the module by generating a new module via serialization
                // this is not the nicest way of doing this, so we'll improve it later with a proper clone mechanism
                // for now though, it works quite well
                XmlDocument doc = LibnoiseFileUtils.DiagramToXML(nodes);
                ModuleBase module = LibnoiseFileUtils.LoadLibnoiseXml(doc);
                SetSeeds(module, seed);
                this.module = module;
            }

            if (widthValid && heightValid && seedValid) GeneratePreview();
        }
Beispiel #4
0
        private void PreviewButton_Click(object sender, RoutedEventArgs e)
        {
            // validate the height/width first
            bool widthValid  = Int32.TryParse(WidthBox.Text, out imageWidth);
            bool heightValid = Int32.TryParse(HeightBox.Text, out imageHeight);
            bool seedValid   = Int32.TryParse(SeedBox.Text, out seed);

            if (!widthValid)
            {
                WidthBox.BorderBrush = System.Windows.Media.Brushes.Red;
            }
            else
            {
                WidthBox.BorderBrush = System.Windows.Media.Brushes.CornflowerBlue;
            }

            if (!heightValid)
            {
                HeightBox.BorderBrush = System.Windows.Media.Brushes.Red;
            }
            else
            {
                HeightBox.BorderBrush = System.Windows.Media.Brushes.CornflowerBlue;
            }

            if (!seedValid)
            {
                SeedBox.BorderBrush = System.Windows.Media.Brushes.Red;
            }
            else
            {
                SeedBox.BorderBrush = System.Windows.Media.Brushes.CornflowerBlue;
            }

            string noiseStyle = ((ComboBoxItem)NoiseStyle.SelectedItem).Content.ToString();
            string colorStyle = ((ComboBoxItem)ColourStyle.SelectedItem).Content.ToString();

            if (noiseStyle.Equals("Planar"))
            {
                selectedNoiseStyle = NoiseStyles.Planar;
            }
            else if (noiseStyle.Equals("Cylindrical"))
            {
                selectedNoiseStyle = NoiseStyles.Cylindrical;
            }
            else
            {
                selectedNoiseStyle = NoiseStyles.Spherical;
            }

            if (colorStyle.Equals("Grayscale"))
            {
                selectedColorStyle = ColourStyles.Greyscale;
            }
            else if (colorStyle.Equals("Blue/Red"))
            {
                selectedColorStyle = ColourStyles.RedBlue;
            }
            else
            {
                selectedColorStyle = ColourStyles.World;
            }

            if (seedValid)
            {
                // clone the module by generating a new module via serialization
                // this is not the nicest way of doing this, so we'll improve it later with a proper clone mechanism
                // for now though, it works quite well
                XmlDocument doc    = LibnoiseFileUtils.DiagramToXML(nodes);
                ModuleBase  module = LibnoiseFileUtils.LoadLibnoiseXml(doc);
                SetSeeds(module, seed);
                this.module = module;
            }

            if (widthValid && heightValid && seedValid)
            {
                GeneratePreview();
            }
        }