コード例 #1
0
 // ------- Service methods for subclasses
 
 /// <summary>
 /// Copies the following characteristics from one grapher to another:
 ///     1. Axis names.
 ///     2. Axis "X" and "Y" coordinate steps.
 ///     3. Axis numbers formatters.
 ///     
 ///     It DOES NOT copy the grapher name, points array etc. 
 ///     Just the signature of the grapher.
 ///     
 ///     It is used in cases when you subclass the AbstractGrapher
 ///     and want to delegate the grapher functionality to the
 ///     inner object using composition.
 ///     (<see>FunctionGrapher</see>)
 /// </summary>
 /// <param name="from">Grapher from which the copying is produced.</param>
 /// <param name="to">Grapher which is to receive the signature.</param>
 protected static void copyGrapherSignature(AbstractGrapher from, AbstractGrapher to)
 {
     to.formatter1 = from.formatter1;
     to.formatter2 = from.formatter2;
     to.GrapherName = from.GrapherName;
     to.Step1 = from.Step1;
     to.Step2 = from.Step2;
     to.xName = from.xName;
     to.yName = from.yName;
 }
コード例 #2
0
        // ------- Service methods for subclasses

        /// <summary>
        /// Copies the following characteristics from one grapher to another:
        ///     1. Axis names.
        ///     2. Axis "X" and "Y" coordinate steps.
        ///     3. Axis numbers formatters.
        ///
        ///     It DOES NOT copy the grapher name, points array etc.
        ///     Just the signature of the grapher.
        ///
        ///     It is used in cases when you subclass the AbstractGrapher
        ///     and want to delegate the grapher functionality to the
        ///     inner object using composition.
        ///     (<see>FunctionGrapher</see>)
        /// </summary>
        /// <param name="from">Grapher from which the copying is produced.</param>
        /// <param name="to">Grapher which is to receive the signature.</param>
        protected static void copyGrapherSignature(AbstractGrapher from, AbstractGrapher to)
        {
            to.formatter1  = from.formatter1;
            to.formatter2  = from.formatter2;
            to.GrapherName = from.GrapherName;
            to.Step1       = from.Step1;
            to.Step2       = from.Step2;
            to.xName       = from.xName;
            to.yName       = from.yName;
        }
コード例 #3
0
        public GraphicDrawer(AbstractGrapher grapher, double xMin, double xMax, double yMin, double yMax)
        {
            InitializeComponent();

            G = grapher;

            this.xMinInitial = xMin;
            this.xMaxInitial = xMax;
            this.yMinInitial = yMin;
            this.yMaxInitial = yMax;
            
            restoreTextBoxesInitial();                      // set textboxes

            this.decals = new List<IDecal>();               // set decals empty
            this.multiGrapherPens1.setGrapher(grapher);     // set the component
            this.Text = "GraphicDrawer - " + grapher.Name;  // set the form header

            // ---------- if user chooses another color

            this.multiGrapherPens1.ColorValueChanged += new EventHandler(
                delegate
                {
                    buttonGraph_Click(this, EventArgs.Empty);
                }
                );

            // ----------------------

            pictureBoxWindow.SizeMode = PictureBoxSizeMode.Normal;
            pictureBoxWindow.Image = new Bitmap(pictureBoxWindow.Width, pictureBoxWindow.Height);

            // ---------- максимальный отступ осей и заданный уже отступ

            Graphics tmp = Graphics.FromImage(pictureBoxWindow.Image);
            
            numericUpDownShift.Value = G.getRecommendedIndentFromBorder(tmp, CoordFont, string.Format("{{0:G{0}}}", numericUpDownEX.Value), string.Format("{{0:G{0}}}", numericUpDownEX2.Value));
            numericUpDownShift.Maximum = this.pictureBoxWindow.Height / 2 - (this.pictureBoxWindow.Height/2) % 100;
            
            pictureBoxWindow.MinimumSize = new Size((int)numericUpDownShift.Maximum, (int)numericUpDownShift.Maximum);

            // ---------- обработчики событий

            // показ текущих координат
            pictureBoxWindow.MouseMove += new MouseEventHandler(
                delegate(object source, MouseEventArgs e)
                {
                    if(somethingIsDrawn)
                        toolStripStatusLabelCoord.Text = String.Format("X={0}, Y={1}", ctf.transformImageXtoFunctionX(this.xImageCoordinate + e.X), ctf.transformImageYToFunctionY(this.yImageCoordinate + e.Y));
                });

            // набоссить иксов
            pictureBoxWindow.MouseClick += new MouseEventHandler(
                delegate(object source, MouseEventArgs e)
                {
                    if (e.Button == MouseButtons.Left) return;

                    if (somethingIsDrawn && GraphicDrawerGraphClick != null)
                    {
                        double x = ctf.transformImageXtoFunctionX(this.xImageCoordinate + e.X);
                        double y = ctf.transformImageYToFunctionY(this.yImageCoordinate + e.Y);
                        GraphicDrawerGraphClick.Invoke(this, new GraphicDrawerGraphClickEventArgs(e.X, e.Y, x, y));
                    }
                });

            richTextBoxFontTest.Font = CoordFont;
            
            // надо вызвать, чтобы установить границы и сделать первоначальное рисование
            buttonRestore_Click(this, EventArgs.Empty);

            tmp.Dispose();
        }
コード例 #4
0
        public GraphicDrawer(AbstractGrapher grapher, double xMin, double xMax, double yMin, double yMax)
        {
            InitializeComponent();

            G = grapher;

            this.xMinInitial = xMin;
            this.xMaxInitial = xMax;
            this.yMinInitial = yMin;
            this.yMaxInitial = yMax;

            restoreTextBoxesInitial();                      // set textboxes

            this.decals = new List <IDecal>();              // set decals empty
            this.multiGrapherPens1.setGrapher(grapher);     // set the component
            this.Text = "GraphicDrawer - " + grapher.Name;  // set the form header

            // ---------- if user chooses another color

            this.multiGrapherPens1.ColorValueChanged += new EventHandler(
                delegate
            {
                buttonGraph_Click(this, EventArgs.Empty);
            }
                );

            // ----------------------

            pictureBoxWindow.SizeMode = PictureBoxSizeMode.Normal;
            pictureBoxWindow.Image    = new Bitmap(pictureBoxWindow.Width, pictureBoxWindow.Height);

            // ---------- максимальный отступ осей и заданный уже отступ

            Graphics tmp = Graphics.FromImage(pictureBoxWindow.Image);

            numericUpDownShift.Value   = G.getRecommendedIndentFromBorder(tmp, CoordFont, string.Format("{{0:G{0}}}", numericUpDownEX.Value), string.Format("{{0:G{0}}}", numericUpDownEX2.Value));
            numericUpDownShift.Maximum = this.pictureBoxWindow.Height / 2 - (this.pictureBoxWindow.Height / 2) % 100;

            pictureBoxWindow.MinimumSize = new Size((int)numericUpDownShift.Maximum, (int)numericUpDownShift.Maximum);

            // ---------- обработчики событий

            // показ текущих координат
            pictureBoxWindow.MouseMove += new MouseEventHandler(
                delegate(object source, MouseEventArgs e)
            {
                if (somethingIsDrawn)
                {
                    toolStripStatusLabelCoord.Text = String.Format("X={0}, Y={1}", ctf.transformImageXtoFunctionX(this.xImageCoordinate + e.X), ctf.transformImageYToFunctionY(this.yImageCoordinate + e.Y));
                }
            });

            // набоссить иксов
            pictureBoxWindow.MouseClick += new MouseEventHandler(
                delegate(object source, MouseEventArgs e)
            {
                if (e.Button == MouseButtons.Left)
                {
                    return;
                }

                if (somethingIsDrawn && GraphicDrawerGraphClick != null)
                {
                    double x = ctf.transformImageXtoFunctionX(this.xImageCoordinate + e.X);
                    double y = ctf.transformImageYToFunctionY(this.yImageCoordinate + e.Y);
                    GraphicDrawerGraphClick.Invoke(this, new GraphicDrawerGraphClickEventArgs(e.X, e.Y, x, y));
                }
            });

            richTextBoxFontTest.Font = CoordFont;

            // надо вызвать, чтобы установить границы и сделать первоначальное рисование
            buttonRestore_Click(this, EventArgs.Empty);

            tmp.Dispose();
        }