Esempio n. 1
0
 // -------------------------------------------------        OnLoad
 private void OnLoad (object sender, EventArgs e)
 {
     nTypes = Enum .GetNames (typeof (DemoFuncType)) .Length - 1;
     int nPerRow = 4;
     int nRowStandard = (nTypes - 1) / nPerRow;
     if ((nTypes - 1) % nPerRow != 0) nRowStandard++;
     int nRectSize = RectArea .MinSize;
     int nSpace = nRectSize / 3;
     ClientSize = new Size (nRectSize * nPerRow + nSpace * (nPerRow + 1),
                            nRectSize * nRowStandard + nSpace * (nRowStandard + 1));
     rc = new Rectangle [nTypes];
     for (int i = 0; i < nTypes; i++)
     {
         rc [i] = new Rectangle (nSpace + (i % nPerRow) * (nRectSize + nSpace),
                                 nSpace + (i / nPerRow) * (nRectSize + nSpace), nRectSize, nRectSize);
     }
     plot = new MSPlot [nTypes];
     for (int i = 0; i < nTypes; i++)
     {
         double [] fParam = PlotOnScreen .PredefinedFunctonParams ((DemoFuncType) i);
         plot [i] = new MSPlot (this, rc [i], Side .S, fParam [0], fParam [1], GridOrigin .ByStep, fParam [2],
                                              Side .W, fParam [3], fParam [4], GridOrigin .ByStep, fParam [5]);
         plot [i] .HorScales [0] .Visible = false;
         plot [i] .VerScales [0] .Visible = false;
     }
     Point ptLT = Auxi_Common .FormPosition (this, ptMouseInit, 700, 600, 4);
     this .Location = ptLT;  
 }
Esempio n. 2
0
 // -------------------------------------------------
 public AreaOnScreen (MSPlot plot, int [] iFunc, MSPlotAuxi [] auxi, FunctionAccess [] acs)  
 {
     area = plot;
     ifunc = iFunc;
     auxidraw = auxi;
     acsfuncs = acs;
     Rectangle rc = area .MainArea .Area;
 }
Esempio n. 3
0
        // -------------------------------------------------        OnLoad
        private void OnLoad (object sender, EventArgs e)
        {
            RestoreFromRegistry ();

            if (plot == null)
            {
                Rectangle rc = new Rectangle (50, 50, 560, 400);
                plot = new MSPlot (this, rc, Side .S, 0.0, 4 * Math .PI, GridOrigin .ByStep, Math .PI,
                                             Side .E, 1.0, -1.0, GridOrigin .ByStep, 0.5);
                plot .AddComment (0.5, -14, "Sin (x) * Cos (20x)", Font, 0, Color .Red);
            }
            RenewMover ();
        }
Esempio n. 4
0
        // -------------------------------------------------        OnLoad
        private void OnLoad (object sender, EventArgs e)
        {
            text = new TextMR (this, new Point (670, 120), info, new Font ("Times New Toman", 9, FontStyle .Bold), 0, Color .DarkGreen);
            mover .Add (text);

            area_0 = new MSPlot (this, new Rectangle (110, 30, 350, 180), Side .S, -4, 25, GridOrigin .ByMinLines, 4,
                                                                          Side .W, 1.2, -1.0, GridOrigin .ByStep, 0.5);
            area_0 .AddComment (0.8, 0.05, "Standard sin(x)", new Font ("Times New Toman", 9, FontStyle .Bold | FontStyle .Italic), 0, Color .Blue);
            area_0 .HorScales [0] .ValuesFormat = "F0";

            area_1 = new MSPlot (this, new Rectangle (80, 250, 700, 340), Side .S, 0.0, 18, GridOrigin .ByStep, Math .PI,
                                                                          Side .E, 1.1, -1.1, GridOrigin .ByStep, 0.5);
            area_1 .AddComment (0.8, -18, "Three functions", new Font ("Times New Toman", 15, FontStyle .Italic), 0, Color .Red);
        }
Esempio n. 5
0
        // -------------------------------------------------
        public Form_Profiles ()
        {
            InitializeComponent ();
            mover = new Mover (this);

            CreateInfo (12, 430);

            Rectangle rc = new Rectangle (40, 60, 180, 140); ;
            Point [] pts = new Point [3] { new Point (rc .Left, rc .Bottom), Auxi_Geometry .Middle (rc), new Point (rc .Right, rc .Bottom) };
            profile [0] = new Profile (rc, new ValuesOnBorders (0, 1, 1, 0), pts, NodeShape .Circle, 3);
            profile [0] .Selected = 0;
            profile [0] .LinesPen = Pens .DarkGreen;

            area = new MSPlot (this, new Rectangle (240, 30, 500, 430), Side .S, 0.0, 100.0, GridOrigin .ByStep, 20.0,
                                                                        Side .E, 1.0, 0.0, GridOrigin .ByStep, 0.25);
            area .AddComment (0.25, 0.06, "Two profiles in one area", Font, 0, Color .Red);
            area .VerScales [0] .ImmutableParams = Immutable .ValueLT | Immutable .ValueRB | Immutable .ValuesSwap;
            area .HorScales [0] .ImmutableParams = Immutable .ValueLT | Immutable .ValueRB | Immutable .ValuesSwap;
            area .VerScales [0] .ValuesFormat = "F2";   // .DecPlaces = 2;

            ValuesOnBorders bordvals = area .ControllersValuesOnBorders;
            double [] xs = new double [9] { 0.0, 0.4, 0.5, 0.58, 0.7, 0.75, 0.79, 0.9, 1.0 };
            double [] ys = new double [9] { 0.0, 0.2, 0.5, 0.31, 0.4, 0.46, 0.31, 0.8, 0.74 };
            int nDots = Math .Min (xs .Length, ys .Length);
            for (int i = 0; i < nDots; i++)
            {
                xs [i] = bordvals .Left + xs [i] * (bordvals .Right - bordvals .Left);
                ys [i] = bordvals .Bottom + ys [i] * (bordvals .Top - bordvals .Bottom);
            }
            profile [1] = new Profile (rc, bordvals, xs, ys, NodeShape .Circle, 3);

            pts = new Point [] {new Point (rc .Left, (rc.Top + rc .Bottom) / 2), 
                                new Point (rc.Left, rc .Top + rc .Height * 5 / 8), 
                                new Point (rc.Left + rc .Width / 4, rc .Top + rc .Height * 5 / 8), 
                                new Point (rc.Left + rc .Width / 4, rc .Top + rc .Height * 3 / 8), 
                                new Point (rc.Left + rc .Width * 3/ 5, rc .Top + rc .Height * 3 / 8), 
                                new Point (rc.Left + rc .Width * 3/ 5, rc .Top + rc .Height * 6 / 8), 
                                new Point (rc.Left + rc .Width * 3/ 4, rc .Top + rc .Height * 6 / 8), 
                                new Point (rc.Left + rc .Width * 3/ 4, rc .Top + rc .Height * 1 / 8), 
                                new Point (rc.Left + rc .Width * 8/ 9, rc .Top + rc .Height * 2 / 3), 
                                new Point (rc .Right, rc .Bottom - 24)
                            };
            profile [2] = new Profile (rc, bordvals, pts, NodeShape .Polygon, 3);
            profile [2] .LinesPen = Pens .DarkGreen;
            profile [2] .DotsColor = Color .DarkGreen;

            RenewMover ();
        }
Esempio n. 6
0
        // -------------------------------------------------        OnLoad
        private void OnLoad (object sender, EventArgs e)
        {
            RestoreFromRegistry ();

            if (plot == null)
            {
                plot = new MSPlot (this, new Rectangle (100, 100, 500, 400),
                                         Side .S, (-4.0) * Math .PI, 4.0 * Math .PI, GridOrigin .ByStep, 3.0,
                                         Side .E, 1.0, -1.0, GridOrigin .ByStep, 0.5);
                plot .VerScales [0] .ValuesFormat = "F2";
                plot .HorScales [0] .ShowNumLT = false;
                plot .HorScales [0] .ShowNumRB = false;

                plot .AddScale (this, Side .E, 40, 4.0, -4.5, GridOrigin .ByStep, 1.0);
                plot .AddScale (this, Side .S, 40, 0.0, 6.0, GridOrigin .ByStep, 2.0); 
                plot .HorScales [1] .AdjustEnds (false, false);
            }
            RenewMover ();
        }
Esempio n. 7
0
        // -------------------------------------------------        OnLoad
        private void OnLoad (object sender, EventArgs e)
        {
            Auxi_Colours .VisibleFrame (this);

            plot = new MSPlot (this, new Rectangle (50, 60, 350, 290), Side .S, 0.0, 4 * Math .PI, GridOrigin .ByStep, Math .PI,
                                                                       Side .E, 1.0, -1.0, GridOrigin .ByStep, 0.5);
            plot .AddComment (0.5, -14, "Sin (x) * Cos (12x)", 
                              new Font ("Times New Roman", 11, FontStyle .Bold | FontStyle .Italic), 0, Color .Blue);

            piechart = new PieChart (this, new Point (500, 330), 140, Auxi_Common .RandomArray (1000, Auxi_Common .strDays .Length));
            piechart .SectorTexts = Auxi_Common .strDays;

            Font fnt = new Font ("Times New Roman", 14, FontStyle.Bold | FontStyle.Italic);
            house9 = new ApartmentHouse (new Rectangle (690, 110, 120, 210));
            house9 .HouseColor = Color .White;
            house9 .RoofColor = Color .Red;
            house9 .DoorColor = Color .Brown;
            house9 .WindowColor = Color .Cyan;

            house23 = new ApartmentHouse (new Rectangle (580, 90, 130, 110));
            house23 .HouseColor = Color .Yellow;
            house23 .RoofColor = Color .Green;

            Point ptC = new Point (100, 440);
            int radius = 50;
            Color [] clrs = Auxi_Colours .SmoothChangedColors (4, Auxi_Colours .ColorPredefined (4), Auxi_Colours .ColorPredefined (5));
            poly4 = new ChatoyantPolygon (Auxi_Geometry .RegularPolygon (4, ptC, radius, 0), ptC, clrs, Auxi_Colours .ColorPredefined (6));
            ptC = new Point (260, 460);
            radius = 75;
            clrs = Auxi_Colours .SmoothChangedColors (7, Auxi_Colours .ColorPredefined (7), Auxi_Colours .ColorPredefined (8));
            poly7 = new ChatoyantPolygon (Auxi_Geometry .RegularPolygon (7, ptC, radius, 0), ptC, clrs, Auxi_Colours .ColorPredefined (9));

            info = new TextM (this, new Point (plot .MainArea .Area .Right + 30, Convert .ToInt32 (poly4 .Center .Y) + 20), strInfo);
            info .BackColor = Color .FromArgb (255, 255, 128);

            ClientSize = new Size (Math .Max (info .Area .Right, house9 .Area .Right) + 20, info .Area .Bottom + 12);

            timerStart .Enabled = true;
            timerStart .Start ();

            RenewMover ();
        }
Esempio n. 8
0
 // -------------------------------------------------        AreaTitle
 private string AreaTitle (MSPlot plot)
 {
     string str = "";
     if (plot .Comments .Count > 0)
     {
         str = plot .Comments [0] .Text + " - ";
     }
     return (str);
 }
Esempio n. 9
0
  // -------------------------------------------------        PlotOnScreen
 public PlotOnScreen (DemoFuncType type, MSPlot area)
 {
     funcType = type;
     plot = area;
 }
Esempio n. 10
0
 // -------------------------------------------------        CreateAreaOnScreen
 private AreaOnScreen CreateAreaOnScreen (MSPlot plot, int [] nFuncs)
 {
     MSPlotAuxi [] auxi = new MSPlotAuxi [nFuncs .Length];
     FunctionAccess [] acs = new FunctionAccess [nFuncs .Length];
     for (int i = 0; i < nFuncs .Length; i++)
     {
         acs [i] = funcInputInfo [nFuncs [i]] .FunctionAccess;
         auxi [i] = new MSPlotAuxi (i, SegmentLocation .Partly_Inside);
         if (acs [i] .Source == DataSource .ParametricFunction ||
             acs [i] .Source == DataSource .InterpreterParametric)
         {
             auxi [i] .ParamTrio (acs [i] .ParamFrom, acs [i] .ParamTo, acs [i] .ParamStep);
         }
     }
     return (new AreaOnScreen (plot, nFuncs, auxi, acs));   
 }
Esempio n. 11
0
 // -------------------------------------------------        Click_btnShowSelected
 private void Click_btnShowSelected (object sender, EventArgs e)
 {
     int nSelected = listFunctions .SelectedIndices .Count;
     if (nSelected < 1)
     {
         MessageBox .Show ("No functions are selected", "Show functions", MessageBoxButtons .OK, MessageBoxIcon .Exclamation);
     }
     else
     {
         string areaTag = FuncsCombinedTag;
         int iOnScreen = FindAreaInList (areasOnScreen, areaTag);
         if (iOnScreen >= 0)
         {
             MoveScreenAreaOnTop (iOnScreen);        // move this area, which is on screen, to position 0
         }
         else
         {
             int iInStore = FindAreaInList (areasInStore, areaTag);
             if (iInStore >= 0)
             {
                 MoveStoreAreaOnTopOfScreen (iInStore);  // move this area from store to position 0 on screen
             }
             else
             {
                 // new combination of functions
                 Rectangle rc = NewFuncRect;
                 FuncInputInfo fii = funcInputInfo [listFunctions .SelectedIndices [0]];
                 double argL = fii .X_Left;
                 double argR = fii .X_Right;
                 double valT = fii .Y_Top;
                 double valB = fii .Y_Bottom;
                 for (int i = 1; i < nSelected; i++)
                 {
                     fii = funcInputInfo [listFunctions .SelectedIndices [i]];
                     argL = Math .Min (argL, fii .X_Left);
                     argR = Math .Max (argR, fii .X_Right);
                     valT = Math .Max (valT, fii .Y_Top);
                     valB = Math .Min (valB, fii .Y_Bottom);
                 }
                 MSPlot area = new MSPlot (this, rc, Side .S, argL, argR, GridOrigin .ByMinLines, 4,
                                                     Side .W, valT, valB, GridOrigin .ByMinLines, 3);
                 for (int j = 0; j < nSelected; j++)
                 {
                     CommentToRect comment = new CommentToRect (this, rc, new Point (rc .Left + 40, rc .Top + (j + 1) * 20),
                                                                funcInputInfo [listFunctions .SelectedIndices [j]] .NameOnScreen,
                                                                Font, 0, area .LineCopy (j) .Color);
                     area .AddComment (comment);
                 }
                 int [] nSelectedFuncNums = new int [nSelected];
                 for (int i = 0; i < nSelected; i++)
                 {
                     nSelectedFuncNums [i] = listFunctions .SelectedIndices [i];
                 }
                 areasOnScreen .Insert (0, CreateAreaOnScreen (area, nSelectedFuncNums));
                 RenewMover ();
             }
             Invalidate ();
         }
     }
 }
Esempio n. 12
0
        // =================================================        RestoreFromRegistry
        private void RestoreFromRegistry ()
        {
            string strkey = Form_Main .strRegKey + strAddRegKey;

            RegistryKey regkey = null;
            try
            {
                regkey = Registry .CurrentUser .OpenSubKey (strkey, true);
                if (regkey != null)
                {
                    string [] strSizes = (string []) regkey .GetValue (nameSizes);
                    if (strSizes != null && strSizes .Length == 7)
                    {
                        if (Convert .ToInt32 (strSizes [0]) == 507 &&
                            Font .Name == strSizes [1] &&
                            Font .SizeInPoints == Convert .ToSingle (strSizes [2]))
                        {
                            ClientSize = Auxi_Convert .IntoSize (strSizes, 3);
                            CreateInfo (Convert .ToInt32 (strSizes [5]), Convert .ToInt32 (strSizes [6]));

                            plot = MSPlot .FromRegistry (this, regkey, "MSP");
                        }
                    }
                }
            }
            catch
            {
            }
            finally
            {
                if (regkey != null) regkey .Close ();
            }
        }
Esempio n. 13
0
        // -------------------------------------------------        DefaultFunctions
        void DefaultFunctions ()
        {
            double [] fParam;
            DemoFuncType functype = DemoFuncType .Parametric_0;
            fParam = PlotOnScreen .PredefinedFunctonParams (functype);
            Rectangle rc = new Rectangle (50, 60, ClientSize .Width / 2, ClientSize .Height / 2);
            MSPlot plot = new MSPlot (this, rc, Side .S, fParam [0], fParam [1], GridOrigin .ByStep, fParam [2],
                                                Side .W, fParam [3], fParam [4], GridOrigin .ByStep, fParam [5]);
            plot .MainArea .BackColor = Color .LightCyan;
            plot .VerScales [0] .ValuesFormat = "F1";
            plot .HorScales [0] .ValuesFormat = "F1";
            plot .AddComment (0.2, 0.1, Enum .GetName (typeof (DemoFuncType), functype),
                              new Font ("Times New Roman", 12, FontStyle .Bold | FontStyle .Italic), 0, Color .Blue);
            AddDemoFunction (functype, plot);

            functype = DemoFuncType .DampedVibrations;
            fParam = PlotOnScreen .PredefinedFunctonParams (functype);
            rc = new Rectangle (ClientSize .Width / 3, ClientSize .Height / 3, 
                                ClientSize .Width / 2 + 70, ClientSize .Height / 2 + 30);
            plot = new MSPlot (this, rc, Side .S, 14.5, 18.5, GridOrigin .ByStep, 1.0,
                                         Side .E, 3.0, 1.3, GridOrigin .ByStep, 1.0);
            plot .VerScales [0] .ValuesFormat = "F1";
            plot .HorScales [0] .ValuesFormat = "F0";
            plot .HorScales [0] .AdjustEnds (false, false);
            plot .HorScales [0] .ShowNumLT = false;
            plot .HorScales [0] .ShowNumRB = false;
            plot .HorScales [0] .Values = new double [] { 14.7, 18.2 };
            plot .AddComment (0.6, 0.2, Enum .GetName (typeof (DemoFuncType), functype),
                              new Font ("Times New Roman", 11, FontStyle .Italic), 0, Color .Blue);
            AddDemoFunction (functype, plot);
        }
Esempio n. 14
0
 // =================================================        AddDemoFunction
 // new function is added on top of the list
 private void AddDemoFunction (DemoFuncType type, MSPlot plot)
 {
     PlotOnScreen demoFunc = new PlotOnScreen (type, plot);
     plotInView .Insert (0, demoFunc);
     RefreshList ();
 }
Esempio n. 15
0
        // -------------------------------------------------        NewPlot
        private void NewPlot (Point pt)
        {
            Form_SelectNewFunction form = new Form_SelectNewFunction (this, this .PointToScreen (pt));
            form .ShowDialog ();
            int iNew = form .SelectedFunction;
            if (iNew >= 0)
            {
                int nSelectFunc = Enum .GetNames (typeof (DemoFuncType)) .Length - 1;
                Rectangle rc = new Rectangle (pt .X, pt .Y, ClientSize .Width / 2, ClientSize .Height / 2);
                if (iNew < nSelectFunc)
                {
                    // one of standard functions
                    double [] fParam;
                    DemoFuncType functype = (DemoFuncType) iNew;
                    fParam = PlotOnScreen .PredefinedFunctonParams (functype);
                    MSPlot plot = new MSPlot (this, rc, Side .S, fParam [0], fParam [1], GridOrigin .ByStep, fParam [2],
                                                        Side .E, fParam [3], fParam [4], GridOrigin .ByStep, fParam [5]);
                    plot .AddComment (0.2, 0.07, Enum .GetName (typeof (DemoFuncType), iNew), Font, 0, plot .LineCopy (0) .Color);

                    AddDemoFunction ((DemoFuncType) iNew, plot);
                    RenewMover ();
                    RefreshList ();
                    listFunctions .Items [0] .Selected = true;
                    listFunctions .Items [0] .EnsureVisible ();
                    Invalidate ();
                }
            }
        }