Exemple #1
0
        void Interpolate(GridSelection Sel)
        {
            Cell A = Sel.A, B = Sel.B, C = Sel.C, D = Sel.D;

            for (int Y = Sel.Y1; Y <= Sel.Y2; Y++)
            {
                for (int X = Sel.X1; X <= Sel.X2; X++)
                {
                    double Data;

                    if (Sel.Width == 1)
                    {
                        Data = Utils.Lerp((double)A.Data, (double)D.Data, Sel.Y1, Sel.Y2, Y);
                    }
                    else if (Sel.Height == 1)
                    {
                        Data = Utils.Lerp((double)A.Data, (double)B.Data, Sel.X1, Sel.X2, X);
                    }
                    else
                    {
                        Data = Utils.Bilinear((double)A.Data, (double)B.Data, (double)C.Data, (double)D.Data, Sel.X1, Sel.X2, Sel.Y1, Sel.Y2, X, Y);
                    }

                    Sel.Sheet.Cells[Y, X].Data = Math.Round(Data, 2);
                }
            }

            ColorSheet(Sel.Sheet);
        }
Exemple #2
0
        private void OnMouseClick(object S, MouseEventArgs E)
        {
            if (E.Button == MouseButtons.Right)
            {
                Worksheet     Sheet    = Grid.CurrentWorksheet;
                RangePosition CurRange = Sheet.SelectionRange;

                if (CtxMenu == null)
                {
                    CtxMenu = new ContextMenu();
                    CtxMenu.MenuItems.Add(new MenuItem("Interpolate", (SS, EE) => Interpolate(Selection)));
                }

                if (Selection == null)
                {
                    Selection = new GridSelection();
                }

                Selection.Sheet = Sheet;
                Selection.A     = Sheet.Cells[CurRange.StartPos];
                Selection.D     = Sheet.Cells[CurRange.EndPos];
                Selection.B     = Sheet.Cells[Selection.A.Row, Selection.D.Column];
                Selection.C     = Sheet.Cells[Selection.D.Row, Selection.A.Column];

                CtxMenu.Show(Grid, Grid.PointToClient(MousePosition));
            }
        }