private void ChartAppearanceChange()
        {
            // Enable/disable appearance controls
            ForeColorCom.Enabled  = (HatchStyle.SelectedIndex != 0 || Gradient.SelectedIndex != 0);
            BorderColor.Enabled   = (BorderDashStyle.SelectedIndex != 0);
            BorderSizeCom.Enabled = (BorderDashStyle.SelectedIndex != 0);

            // Set Back Color
            Chart1.BackColor = Color.FromName(BackColorCom.GetItemText(BackColorCom.SelectedItem));

            // Set Back Gradient End Color
            Chart1.BackSecondaryColor = Color.FromName(ForeColorCom.GetItemText(ForeColorCom.SelectedItem));

            // Set Gradient Type
            if (Gradient.SelectedItem != null)
            {
                Chart1.BackGradientStyle = (GradientStyle)GradientStyle.Parse(typeof(GradientStyle), Gradient.GetItemText(Gradient.SelectedItem));
            }

            // Set Gradient Type
            if (HatchStyle.SelectedItem != null)
            {
                Chart1.BackHatchStyle = (ChartHatchStyle)ChartHatchStyle.Parse(typeof(ChartHatchStyle), HatchStyle.GetItemText(HatchStyle.SelectedItem));
            }

            // Set background image
            if (!ShowImageCheck.Checked)
            {
                Chart1.BackImage   = "";
                ImageAlign.Enabled = false;
                ImageMode.Enabled  = false;
            }
            else
            {
                ImageMode.Enabled  = true;
                ImageAlign.Enabled = (ImageMode.SelectedIndex == 5);

                // Set chart image
                MainForm mainForm      = (MainForm)this.ParentForm;
                string   imageFileName = mainForm.CurrentSamplePath;
                imageFileName   += "\\Flag.gif";
                Chart1.BackImage = imageFileName;
                Chart1.BackImageTransparentColor = Color.Red;

                // Set Image Mode
                if (ImageMode.SelectedItem != null)
                {
                    Chart1.BackImageWrapMode = (ChartImageWrapMode)ChartImageWrapMode.Parse(typeof(ChartImageWrapMode), ImageMode.SelectedItem.ToString());
                }

                // Set Image Alignment
                if (ImageAlign.SelectedItem != null)
                {
                    Chart1.BackImageAlignment = (ChartImageAlignmentStyle)ChartImageAlignmentStyle.Parse(typeof(ChartImageAlignmentStyle), ImageAlign.SelectedItem.ToString());
                }
            }

            // Set Border Width
            if (BorderSizeCom.SelectedItem != null)
            {
                Chart1.BorderWidth = int.Parse(BorderSizeCom.GetItemText(BorderSizeCom.SelectedItem));
            }

            // Set Border Style
            if (BorderDashStyle.SelectedItem != null)
            {
                Chart1.BorderDashStyle = (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), BorderDashStyle.GetItemText(BorderDashStyle.SelectedItem));
            }

            // Set Border Color
            Chart1.BorderColor = Color.FromName(BorderColor.GetItemText(BorderColor.SelectedItem));
        }
Exemple #2
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!this.IsPostBack)
            {
                // Add Hatch styles to control.
                foreach (string colorName in Enum.GetNames(typeof(ChartHatchStyle)))
                {
                    HatchStyle.Items.Add(colorName);
                }
                HatchStyle.Items[0].Selected = true;

                // Add Chart Gradient types to control.
                foreach (string colorName in Enum.GetNames(typeof(GradientStyle)))
                {
                    Gradient.Items.Add(colorName);
                }

                // Add Chart Line styles to control.
                foreach (string colorName in Enum.GetNames(typeof(ChartDashStyle)))
                {
                    BorderDashStyle.Items.Add(colorName);
                }

                BorderDashStyle.Items.FindByValue("Solid").Selected = true;

                // Add Image Mode
                foreach (string item in Enum.GetNames(typeof(ChartImageWrapMode)))
                {
                    ImageMode.Items.Add(item);
                }
                ImageMode.SelectedIndex = 5;

                // Add Image Aligne
                foreach (string item in Enum.GetNames(typeof(ChartImageAlignmentStyle)))
                {
                    ImageAlign1.Items.Add(item);
                }
                ImageAlign1.SelectedIndex = 2;
            }

            // Set Back Color
            Chart1.BackColor = Color.FromName(BackColor.SelectedItem.Value);

            // Set Back Gradient End Color
            Chart1.BackSecondaryColor = Color.FromName(ForeColor.SelectedItem.Value);

            // Set Hatch Style
            Chart1.BackHatchStyle = (ChartHatchStyle)ChartHatchStyle.Parse(typeof(ChartHatchStyle), HatchStyle.SelectedItem.Text);

            // Set Gradient Type
            Chart1.BackGradientStyle = (GradientStyle)GradientStyle.Parse(typeof(GradientStyle), Gradient.SelectedItem.Text);

            // Set Border Color
            Chart1.BorderColor = Color.FromName(BorderColor.SelectedItem.Value);

            // Set Border Style
            Chart1.BorderlineDashStyle = (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), BorderDashStyle.SelectedItem.Text);

            // Set Border Width
            Chart1.BorderWidth = int.Parse(BorderSize.SelectedItem.Value);

            // Chart Image Mode
            Chart1.BackImageWrapMode = (ChartImageWrapMode)ChartImageWrapMode.Parse(typeof(ChartImageWrapMode), ImageMode.SelectedItem.Text);

            // Chart Image Align
            Chart1.BackImageAlignment = (ChartImageAlignmentStyle)ChartImageAlignmentStyle.Parse(typeof(ChartImageAlignmentStyle), ImageAlign1.SelectedItem.Text);

            // Disable secondary back color if gradient and hatching are not used
            ForeColor.Enabled = (HatchStyle.SelectedIndex != 0 || Gradient.SelectedIndex != 0);

            // Set Image
            ImageAlign1.Enabled = false;
            ImageMode.Enabled   = Image1.Checked;
            if (Image1.Checked)
            {
                Chart1.BackImage = "Flag.gif";
                Chart1.BackImageTransparentColor = Color.White;
                if (ImageMode.SelectedItem.Value == "Unscaled")
                {
                    ImageAlign1.Enabled = true;
                }
            }
            else
            {
                Chart1.BackImage = "";
            }

            // Enable/disable border attributes
            BorderColor.Enabled = (BorderDashStyle.SelectedIndex != 0);
            BorderSize.Enabled  = (BorderDashStyle.SelectedIndex != 0);
        }