コード例 #1
0
        private void ConfigureFractalObserverDialog_Shown(object sender, EventArgs e)
        {
            tbZoomXStart.Text = Convert.ToString(myFractalObserverConfiguration.ZoomRectangle.StartX, CultureInfo.CurrentCulture);
            tbZoomXEnd.Text   = Convert.ToString(myFractalObserverConfiguration.ZoomRectangle.EndX, CultureInfo.CurrentCulture);
            tbZoomYStart.Text = Convert.ToString(myFractalObserverConfiguration.ZoomRectangle.StartY, CultureInfo.CurrentCulture);
            tbZoomYEnd.Text   = Convert.ToString(myFractalObserverConfiguration.ZoomRectangle.EndY, CultureInfo.CurrentCulture);

            tbCurrentXStart.Text = Convert.ToString(myFractalObserverConfiguration.CurrentRectangle.StartX, CultureInfo.CurrentCulture);
            tbCurrentXEnd.Text   = Convert.ToString(myFractalObserverConfiguration.CurrentRectangle.EndX, CultureInfo.CurrentCulture);
            tbCurrentYStart.Text = Convert.ToString(myFractalObserverConfiguration.CurrentRectangle.StartY, CultureInfo.CurrentCulture);
            tbCurrentYEnd.Text   = Convert.ToString(myFractalObserverConfiguration.CurrentRectangle.EndY, CultureInfo.CurrentCulture);

            cbFractalEquation.Items.Clear();

            foreach (KeyValuePair <string, FractalTypes> fractalType in FractalFactory.AvailableFractalTypes)
            {
                cbFractalType.Items.Add(fractalType.Key);

                if (myFractalObserverConfiguration.FractalType == fractalType.Value)
                {
                    cbFractalType.SelectedItem = fractalType.Key;

                    bool aEquationSelected = false;
                    foreach (KeyValuePair <string, EquationTypes> equationType in EquationFactory.AvailableEquationTypes)
                    {
                        if (FractalFactory.GetAvailableEquationTypesForFractalType(fractalType.Value).Contains(equationType.Value))
                        {
                            cbFractalEquation.Items.Add(equationType.Key);

                            if (myFractalObserverConfiguration.EquationType == equationType.Value)
                            {
                                cbFractalEquation.SelectedItem = equationType.Key;
                                aEquationSelected = true;
                            }
                        }
                    }
                    if (!aEquationSelected && cbFractalEquation.Items.Count > 0)
                    {
                        cbFractalEquation.SelectedIndex = 0;
                    }
                }
            }

            if (cbFractalEquation.Items.Count == 0)
            {
                cbFractalEquation.Enabled = false;
            }
        }
コード例 #2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            //loading fractal configuration during start of application
            myFractalObserverConfiguration = new FractalObserverConfiguration();

            try
            {
                myConfigurationXmlIsOk = true;
                myFractalObserverConfiguration.ReadFromFractalObserverConfigurationXml();
            }
            catch (Exception ex)
            {
                if (ex is FileNotFoundException || ex is XmlException)
                {
                    DialogResult aDialogResult = MessageBox.Show("Error ocurred during reading of configuration xml!\n" +
                                                                 "Do you want to read the default configuration!? (if no the application will be closed!'\n" +
                                                                 "Exception message: " + ex.Message, "FractalObserver", MessageBoxButtons.YesNo, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0);
                    if (aDialogResult == DialogResult.Yes)
                    {
                        myFractalObserverConfiguration.SetDefaultValues();
                    }
                    else
                    {
                        myConfigurationXmlIsOk = false;
                        this.Close();
                        return;
                    }
                }
                else
                {
                    throw;
                }
            }

            tsStatusLabelFractalType.Text = "FractalType = " + myFractalObserverConfiguration.FractalType;

            tsStatusLabelGridSpacing.Text = "GridSpacing : Horizontal = " + Convert.ToString(myFractalObserverConfiguration.HorizontalSpacing, CultureInfo.CurrentCulture)
                                            + ", Vertical = " + Convert.ToString(myFractalObserverConfiguration.VerticalSpacing, CultureInfo.CurrentCulture);

            CheckZoomRectangleBoundary();

            myFractalFactory = new FractalFactory();
        }
コード例 #3
0
        private void cbFractalType_SelectionChangeCommitted(object sender, EventArgs e)
        {
            cbFractalEquation.Items.Clear();

            foreach (KeyValuePair <string, FractalTypes> fractalType in FractalFactory.AvailableFractalTypes)
            {
                if ((string)cbFractalType.SelectedItem == fractalType.Key)
                {
                    bool aEquationSelected = false;
                    foreach (KeyValuePair <string, EquationTypes> equationType in EquationFactory.AvailableEquationTypes)
                    {
                        if (FractalFactory.GetAvailableEquationTypesForFractalType(fractalType.Value).Contains(equationType.Value))
                        {
                            cbFractalEquation.Items.Add(equationType.Key);

                            if (myFractalObserverConfiguration.EquationType == equationType.Value)
                            {
                                cbFractalEquation.SelectedItem = equationType.Key;
                                aEquationSelected = true;
                            }
                        }
                    }

                    if (!aEquationSelected && cbFractalEquation.Items.Count > 0)
                    {
                        cbFractalEquation.SelectedIndex = 0;
                    }

                    if (cbFractalEquation.Items.Count == 0)
                    {
                        cbFractalEquation.Enabled = false;
                    }
                    else
                    {
                        cbFractalEquation.Enabled = true;
                    }
                }
            }
        }