// ------------------------------------------------- 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 (); } } }
// ------------------------------------------------- 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 (); } } }