Пример #1
0
        public static void Fill(Grid a, string[] data, int index)
        {
            object[] temp = new object[data.Length];
            data.CopyTo(temp, 0);

            MakeGrid.Fill(a, temp, Color.Snow, index);
        }
Пример #2
0
        public static void Fill(Grid a, string[] data)
        {
            object[] temp = new object[data.Length];
            data.CopyTo(temp, 0);

            MakeGrid.Fill(a, temp, Color.Snow, a.FixedRows);
        }
Пример #3
0
        public static void Fill(Grid a, int[,] data)
        {
            object[,] temp = new object[data.GetLongLength(0), data.GetLongLength(1)];

            for (int i = 0; i < data.GetLongLength(0); i++)
            {
                for (int j = 0; j < data.GetLongLength(1); j++)
                {
                    temp[i, j] = data[i, j];
                }
            }

            MakeGrid.Fill(a, temp, Color.Snow);
        }
Пример #4
0
        public static void Fill(Grid a, double[] data, HeaderColumnsHeader header = HeaderColumnsHeader.both)
        {
            object[] temp = new object[data.Length];
            data.CopyTo(temp, 0);

            switch (header)
            {
            case HeaderColumnsHeader.both:
            case HeaderColumnsHeader.rows:
                MakeGrid.Fill2(a, temp, Color.Snow, 1);
                break;

            case HeaderColumnsHeader.none:
            case HeaderColumnsHeader.columns:
                MakeGrid.Fill2(a, temp, Color.Snow, 0);
                break;
            }
        }
        public static double[,] getOpen(Grid a)
        {
            string         TampunganData        = null;
            OpenFileDialog bukaFileInputAnggota = new OpenFileDialog();

            bukaFileInputAnggota.Title       = "Buka File";
            bukaFileInputAnggota.Filter      = "CSV Text File|*.csv|All Files (*.*)|*.*";
            bukaFileInputAnggota.FilterIndex = 1;
            bukaFileInputAnggota.Multiselect = false;
            DialogResult result = bukaFileInputAnggota.ShowDialog();

            if (result == DialogResult.OK)
            {
                //string file = Path.GetFileName(bukaFileInputAnggota.FileName);
                //string path = Path.GetDirectoryName(file);

                System.IO.StreamReader sr = new System.IO.StreamReader(bukaFileInputAnggota.FileName);
                TampunganData = sr.ReadToEnd();

                string[] u = TampunganData.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

                int hitcount = (u[0].Split(',')).Count();
                double[,] temp = new double[u.Length, hitcount];

                for (int i = 0; i < u.Length; i++)
                {
                    string[] Temp1 = (u[i].Split(','));

                    for (int j = 0; j < hitcount; j++)
                    {
                        temp[i, j] = double.Parse(Temp1[j]);
                    }
                }
                MakeGrid.Build(a, temp.GetLength(0), 2, new[] { "X", "Y" });
                MakeGrid.Fill(a, temp);

                return(MakeGrid.Return(a));
            }

            return(null);
        }
Пример #6
0
        private static void Build(Grid a, int m, int n, Color warna, HeaderColumnsHeader headerstate = HeaderColumnsHeader.both, ResizeColumns autoresize = ResizeColumns.autocell, string pointzero = "#", string[] headername = null, int positionx = 0, int positiony = 0, SorterColumns sortable = SorterColumns.sort)
        {
            try
            {
                MakeGrid.Reset(a, m, n, headerstate);

                SourceGrid.Cells.Views.Cell      view   = new SourceGrid.Cells.Views.Cell();
                SourceGrid.Cells.Editors.TextBox editor = new SourceGrid.Cells.Editors.TextBox(typeof(string));
                view.BackColor = warna;

                if (headerstate == HeaderColumnsHeader.both || headerstate == HeaderColumnsHeader.rows)
                {
                    for (int r = a.FixedRows; r < a.RowsCount; r++)
                    {
                        a[r, 0] = new SourceGrid.Cells.RowHeader(r);
                    }
                }

                if (headerstate == HeaderColumnsHeader.both || headerstate == HeaderColumnsHeader.columns)
                {
                    try
                    {
                        for (int c = a.FixedColumns; c < a.ColumnsCount; c++)
                        {
                            SourceGrid.Cells.ColumnHeader header = new
                                                                   SourceGrid.Cells.ColumnHeader(headername[c - 1]);
                            header.AutomaticSortEnabled = true;
                            header.View.TextAlignment   = ContentAlignment.MiddleCenter;
                            a[0, c] = header;
                        }
                    }
                    catch
                    {
                    }
                }

                SourceGrid.Cells.ColumnHeader header1 = new SourceGrid.Cells.ColumnHeader(pointzero);

                if (sortable == SorterColumns.sort)
                {
                    header1.SortComparer = new SourceGrid.MultiColumnsComparer(1, 2, 3, 4);
                }

                a[0, 0] = header1;

                for (int r = a.FixedRows; r < a.RowsCount; r++)
                {
                    for (int c = a.FixedColumns; c < a.ColumnsCount; c++)
                    {
                        a[r, c]        = new SourceGrid.Cells.Cell("");
                        a[r, c].Editor = editor;
                        a[r, c].View   = view;
                    }
                }

                a.Update();
                a.Selection.Focus(new SourceGrid.Position(positionx, positiony), true);

                if (autoresize == ResizeColumns.autocell)
                {
                    a.AutoSizeCells();
                }
            }
            catch
            {
            }
        }