Exemple #1
0
        private void Recreate()
        {
            sfp = new SnowflakeParameters(
                (float)nudArmAngle.Value,
                (int)nudNumberOfArms.Value,
                ((float)nudShrinkFactor.Value) / 100.0f,
                (float)nudLength.Value,
                (float)nudThickness.Value,
                (float)nudThicknessShrink.Value / 100.0f,
                (int)nudMaxDepth.Value,
                pbxBackgroundColour.BackColor,
                pbxForegroundColour.BackColor,
                (int)nudSymmetryOrder.Value);

            pbxDisplay2.BackColor = sfp.backgroundColor;
            pbxDisplay2.ForeColor = sfp.foregroundColour;

            snowflake.Clear();

            float x = pbxDisplay2.Width / 2;
            float y = pbxDisplay2.Height / 2;

            int numberOfFlakes = (int)nudSymmetryOrder.Value;

            for (int i = 0; i < numberOfFlakes; i++)
            {
                float theta = (float)Math.PI * 2 * (float)i / numberOfFlakes;


                snowflake.Add(new FlakeArm(0, x, y, sfp.length, theta, sfp.numberOfArms, sfp.armAngleDegree * Math.PI / 180.0f, sfp.shrinkFactor, sfp.thickness, sfp.thicknessShrinkFactor, sfp.maxDepth, sfp.foregroundColour));
            }
            pbxDisplay2.Invalidate();
        }
Exemple #2
0
        private void Recreate()
        {

            sfp = new SnowflakeParameters(
                (float)nudArmAngle.Value,
                (int)nudNumberOfArms.Value,
                ((float)nudShrinkFactor.Value) / 100.0f,
                (float)nudLength.Value,
                (float)nudThickness.Value,
                (float)nudThicknessShrink.Value / 100.0f,
                (int)nudMaxDepth.Value,
                pbxBackgroundColour.BackColor,
                pbxForegroundColour.BackColor,
                (int)nudSymmetryOrder.Value);

            pbxDisplay2.BackColor = sfp.backgroundColor;
            pbxDisplay2.ForeColor = sfp.foregroundColour;

            snowflake.Clear();

            float x = pbxDisplay2.Width / 2;
            float y = pbxDisplay2.Height / 2;

            int numberOfFlakes = (int)nudSymmetryOrder.Value;

            for (int i = 0; i < numberOfFlakes; i++)
            {
                float theta = (float)Math.PI * 2 * (float)i / numberOfFlakes;


                snowflake.Add(new FlakeArm(0, x, y, sfp.length, theta, sfp.numberOfArms, sfp.armAngleDegree * Math.PI / 180.0f, sfp.shrinkFactor, sfp.thickness, sfp.thicknessShrinkFactor, sfp.maxDepth, sfp.foregroundColour));
            }
            pbxDisplay2.Invalidate();

        }
Exemple #3
0
        private void LoadSnowflakeData()
        {
            string         fileName   = null;
            OpenFileDialog openDialog = openFileDialog1;

            openDialog.DefaultExt = "*.txt";
            openDialog.Filter     = "Snowflake data files(snowflake)|*.snowflake";

            DialogResult dr = openFileDialog1.ShowDialog();

            if (dr == System.Windows.Forms.DialogResult.OK)
            {
                //could fail - so we have a try catch block
                //also we load to a second copy of the animal list
                //then if the load is ok we copy the data to the original list
                //
                //this means that if the load fails we won't lose any original list

                try
                {
                    fileName = openFileDialog1.FileName;

                    System.IO.FileStream filestream = new System.IO.FileStream(fileName, System.IO.FileMode.Open);
                    System.Runtime.Serialization.Formatters.Binary.BinaryFormatter f = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                    SnowflakeParameters restoredSfp = null;
                    restoredSfp = (SnowflakeParameters)f.Deserialize(filestream);
                    filestream.Close();

                    // copy this across to the real one

                    sfp = restoredSfp;

                    // copy to the controls

                    //sfp = new SnowflakeParameters(
                    nudArmAngle.Value        = (decimal)restoredSfp.armAngleDegree;
                    nudNumberOfArms.Value    = restoredSfp.numberOfArms;
                    nudShrinkFactor.Value    = (decimal)(restoredSfp.shrinkFactor * 100.0f);
                    nudLength.Value          = (decimal)restoredSfp.length;
                    nudThickness.Value       = (decimal)restoredSfp.thickness;
                    nudThicknessShrink.Value = (decimal)(restoredSfp.thicknessShrinkFactor * 100.0f);
                    nudMaxDepth.Value        = restoredSfp.maxDepth;

                    // colour to do later...

                    pbxForegroundColour.BackColor = restoredSfp.foregroundColour;
                    pbxBackgroundColour.BackColor = restoredSfp.backgroundColor;

                    nudSymmetryOrder.Value = restoredSfp.symmetryOrder;

                    Recreate();
                }
                catch (System.IO.IOException ex)
                {
                    MessageBox.Show(ex.Message, "File Load Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemple #4
0
        private void LoadSnowflakeData()
        {
            string fileName = null;
            OpenFileDialog openDialog = openFileDialog1;

            openDialog.DefaultExt = "*.txt";
            openDialog.Filter = "Snowflake data files(snowflake)|*.snowflake";

            DialogResult dr = openFileDialog1.ShowDialog();

            if (dr == System.Windows.Forms.DialogResult.OK)
            {
                //could fail - so we have a try catch block
                //also we load to a second copy of the animal list
                //then if the load is ok we copy the data to the original list
                //
                //this means that if the load fails we won't lose any original list

                try
                {
                    fileName = openFileDialog1.FileName;

                    System.IO.FileStream filestream = new System.IO.FileStream(fileName, System.IO.FileMode.Open);
                    System.Runtime.Serialization.Formatters.Binary.BinaryFormatter f = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                    SnowflakeParameters restoredSfp = null;
                    restoredSfp = (SnowflakeParameters)f.Deserialize(filestream);
                    filestream.Close();

                    // copy this across to the real one

                    sfp = restoredSfp;

                    // copy to the controls

                    //sfp = new SnowflakeParameters(
                    nudArmAngle.Value = (decimal)restoredSfp.armAngleDegree;
                    nudNumberOfArms.Value = restoredSfp.numberOfArms;
                    nudShrinkFactor.Value = (decimal)(restoredSfp.shrinkFactor * 100.0f);
                    nudLength.Value = (decimal)restoredSfp.length;                                         
                    nudThickness.Value = (decimal)restoredSfp.thickness;
                    nudThicknessShrink.Value = (decimal)(restoredSfp.thicknessShrinkFactor * 100.0f);
                    nudMaxDepth.Value = restoredSfp.maxDepth;
                    
                    // colour to do later...

                    pbxForegroundColour.BackColor = restoredSfp.foregroundColour;
                    pbxBackgroundColour.BackColor = restoredSfp.backgroundColor;

                    nudSymmetryOrder.Value = restoredSfp.symmetryOrder;

                    Recreate();



                }
                catch (System.IO.IOException ex)
                {
                    MessageBox.Show(ex.Message, "File Load Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                }

            }
        }