Пример #1
0
        private void LoadProjectInfo()
        {
            try
            {
                hshProjects = syncMgr.GetProjects(false);

                gridProjects.FixedRows = 1;
                gridProjects.AutoStretchColumnsToFitWidth = true;

                // create a visual model for right-aligned text with trimming
                SourceGrid2.VisualModels.Common vmEllipsePath = new SourceGrid2.VisualModels.Common();
                vmEllipsePath.StringFormat.Trimming = StringTrimming.EllipsisPath;
                // create a visual model for flat headers
                SourceGrid2.VisualModels.Common vmHeader = new SourceGrid2.VisualModels.FlatHeader();
                vmHeader.BackColor = Color.FromArgb(228, 229, 237);
                SourceGrid2.BehaviorModels.Header bmHeader = new SourceGrid2.BehaviorModels.Header();

                // set up the header row
                gridProjects.Rows.Insert(0);

                // set up the columns
                gridProjects.Columns.Insert(0);                 // hidden sync project full path
                gridProjects[0, 0] = new SourceGrid2.Cells.Real.ColumnHeader("", vmHeader, bmHeader);

                gridProjects.Columns.Insert(1);                 // check box column
                gridProjects[0, 1] = new SourceGrid2.Cells.Real.ColumnHeader("Sync?", vmHeader, bmHeader);

                gridProjects.Columns.Insert(2);                 // project name
                gridProjects[0, 2] = new SourceGrid2.Cells.Real.ColumnHeader("Project Name", vmHeader, bmHeader);

                gridProjects.Columns.Insert(3);                 // sync folder short for display
                gridProjects[0, 3] = new SourceGrid2.Cells.Real.ColumnHeader("Outlook Sync Folder", vmHeader, bmHeader);

                gridProjects.Columns.Insert(4);                 // browse button
                gridProjects[0, 4] = new SourceGrid2.Cells.Real.ColumnHeader("", vmHeader, bmHeader);

                SizeColumns();

                if (hshProjects == null)
                {
                    return;
                }

                // add rows for projects
                int iRow = 0;
                foreach (ProjectInfo projInfo in hshProjects.Values)
                {
                    iRow++;
                    gridProjects.Rows.Insert(iRow);

                    // add row
                    if (!hshProjRows.Contains(projInfo.ProjID))
                    {
                        hshProjRows.Add(projInfo.ProjID, iRow);
                    }

                    // add each cell individually
                    // sync folder path
                    gridProjects[iRow, col_SyncFolderFull] = new SourceGrid2.Cells.Real.Cell(projInfo.SyncFolder);
                    // checkbox for sync enabled
                    gridProjects[iRow, col_SyncEnabled] = new SourceGrid2.Cells.Real.CheckBox(projInfo.SyncEnabled);
                    // project name
                    gridProjects[iRow, col_ProjName] = new SourceGrid2.Cells.Real.Cell(projInfo.ProjectName);
                    // sync folder short
                    gridProjects[iRow, col_SyncFolder]             = new SourceGrid2.Cells.Real.Cell(projInfo.SyncFolderShort);
                    gridProjects[iRow, col_SyncFolder].VisualModel = vmEllipsePath;
                    // browse button
                    gridProjects[iRow, col_BrowseButton] = new SourceGrid2.Cells.Real.Button("...", new SourceGrid2.PositionEventHandler(BrowseOutlookFolders_Click));
                    FlatHeader vm = new FlatHeader();
                    vm.BackColor = Color.FromArgb(228, 229, 237);
                    gridProjects[iRow, col_BrowseButton].VisualModel = vm;

                    // TODO: NEXT VERSION ... add a hidden row for additional project settings that displays when
                    //       the main project row is selected
                }
            }
            catch (System.Exception ex)
            {
                ErrorHandler.PublishError(ex, syncMgr.Logger);
            }
        }
        public void Init格式()
        {
            toolStripCboElement.Items.Clear();
            if (GlobeVal.mysys.language == 0)
            {
                toolStripCboElement.Items.Add("标题栏");
                toolStripCboElement.Items.Add("固定列");
                toolStripCboElement.Items.Add("内容");
            }
            else
            {
                toolStripCboElement.Items.Add("Title bar");
                toolStripCboElement.Items.Add("Fixed column");
                toolStripCboElement.Items.Add("Content");
            }
            toolStripCboElement.SelectedIndex = 0;

            if (resulttab == 0)
            {
                grid1.RowsCount = 0;


                grid1.BorderStyle = BorderStyle.Fixed3D;
                grid1.AutoStretchRowsToFitHeight = true;
                grid1.ColumnsCount = CComLibrary.GlobeVal.filesave.mtablecol1.Count + 2;

                grid1.FixedRows    = 1;
                grid1.FixedColumns = 1;
                grid1.Rows.Insert(0);
                grid1.Rows[0].Height = 30;


                SourceGrid2.Cells.Real.ColumnHeader boldHeader = new SourceGrid2.Cells.Real.ColumnHeader();
                boldHeader.Font = new Font(CComLibrary.GlobeVal.filesave.mtable1para.mTableHeaderPara.HeaderFont.FontFamily,
                                           CComLibrary.GlobeVal.filesave.mtable1para.mTableHeaderPara.HeaderFont.Size);
                boldHeader.EnableSort    = false;
                boldHeader.WordWrap      = true;
                boldHeader.Value         = "";
                boldHeader.TextAlignment = CComLibrary.GlobeVal.filesave.mtable1para.mTableHeaderPara.HeaderAlignment;
                boldHeader.BackColor     = CComLibrary.GlobeVal.filesave.mtable1para.mTableHeaderPara.HeaderBackColor;
                boldHeader.ForeColor     = CComLibrary.GlobeVal.filesave.mtable1para.mTableHeaderPara.HeaderForeColor;

                grid1[0, 0] = boldHeader;



                for (int i = 0; i < CComLibrary.GlobeVal.filesave.mtablecol1.Count; i++)
                {
                    boldHeader      = new SourceGrid2.Cells.Real.ColumnHeader();
                    boldHeader.Font = new Font(CComLibrary.GlobeVal.filesave.mtable1para.mTableHeaderPara.HeaderFont.FontFamily,
                                               CComLibrary.GlobeVal.filesave.mtable1para.mTableHeaderPara.HeaderFont.Size);
                    boldHeader.EnableSort = false;
                    boldHeader.WordWrap   = true;
                    if (CComLibrary.GlobeVal.filesave.mtablecol1[i].apply == false)
                    {
                        boldHeader.Value = CComLibrary.GlobeVal.filesave.mtablecol1[i].formulaname + "(" +
                                           CComLibrary.GlobeVal.filesave.mtablecol1[i].myitemsignal.cUnits[
                            CComLibrary.GlobeVal.filesave.mtablecol1[i].myitemsignal.cUnitsel] + ")";
                    }
                    else
                    {
                        boldHeader.Value = CComLibrary.GlobeVal.filesave.mtablecol1[i].formulaexplain + "(" +
                                           CComLibrary.GlobeVal.filesave.mtablecol1[i].myitemsignal.cUnits[
                            CComLibrary.GlobeVal.filesave.mtablecol1[i].myitemsignal.cUnitsel] + ")";
                    }
                    boldHeader.TextAlignment = CComLibrary.GlobeVal.filesave.mtable1para.mTableHeaderPara.HeaderAlignment;
                    boldHeader.BackColor     = CComLibrary.GlobeVal.filesave.mtable1para.mTableHeaderPara.HeaderBackColor;
                    boldHeader.ForeColor     = CComLibrary.GlobeVal.filesave.mtable1para.mTableHeaderPara.HeaderForeColor;

                    grid1[0, 1 + i] = boldHeader;
                }

                boldHeader      = new SourceGrid2.Cells.Real.ColumnHeader();
                boldHeader.Font = new Font(CComLibrary.GlobeVal.filesave.mtable1para.mTableHeaderPara.HeaderFont.FontFamily,
                                           CComLibrary.GlobeVal.filesave.mtable1para.mTableHeaderPara.HeaderFont.Size);
                boldHeader.EnableSort = false;
                boldHeader.WordWrap   = true;
                boldHeader.Value      = "";
                boldHeader.BackColor  = CComLibrary.GlobeVal.filesave.mtable1para.mTableHeaderPara.HeaderBackColor;
                boldHeader.ForeColor  = CComLibrary.GlobeVal.filesave.mtable1para.mTableHeaderPara.HeaderForeColor;


                grid1[0, CComLibrary.GlobeVal.filesave.mtablecol1.Count + 1] = boldHeader;


                int mw = grid1.Width / grid1.ColumnsCount;

                for (int i = 0; i < grid1.ColumnsCount; i++)
                {
                    grid1.Columns[i].Width = mw - 1;
                }


                grid1.Columns[grid1.ColumnsCount - 1].AutoSizeMode = SourceGrid2.AutoSizeMode.EnableStretch;

                grid1.AutoStretchColumnsToFitWidth = true;

                for (int i = 1; i <= 4; i++)
                {
                    grid1.Rows.Insert(i);


                    grid1[i, 0] = new SourceGrid2.Cells.Real.Button(
                        typeof(string));
                    (grid1[i, 0] as SourceGrid2.Cells.Real.Button).Value = i.ToString();

                    SourceGrid2.VisualModels.MultiImages view = new SourceGrid2.VisualModels.MultiImages();
                    view.BackColor = CComLibrary.GlobeVal.filesave.mtable1para.mTableColPara.ColBackColor;
                    view.ForeColor = CComLibrary.GlobeVal.filesave.mtable1para.mTableColPara.ColForeColor;

                    view.Font = new Font(CComLibrary.GlobeVal.filesave.mtable1para.mTableColPara.ColFont.FontFamily,
                                         CComLibrary.GlobeVal.filesave.mtable1para.mTableColPara.ColFont.Size);

                    if ((i == 2) || (i == 3))
                    {
                        if (CComLibrary.GlobeVal.filesave.mtable1para.showvalidspe == true)
                        {
                            view.Image = imageList1.Images[1];
                        }
                        else
                        {
                            view.Image = imageList1.Images[0];
                        }
                    }
                    else
                    {
                        view.Image = imageList1.Images[0];
                    }
                    view.TextAlignment = CComLibrary.GlobeVal.filesave.mtable1para.mTableColPara.ColAlignment;


                    grid1[i, 0].VisualModel = view;


                    for (int j = 0; j < CComLibrary.GlobeVal.filesave.mtablecol1.Count; j++)
                    {
                        float  t = 0;
                        string s = t.ToString("F" + CComLibrary.GlobeVal.filesave.mtablecol1[j].myitemsignal.precise.ToString().Trim());

                        if (CComLibrary.GlobeVal.filesave.mtablecol1[j].myitemsignal.cUnitKind == 19)
                        {
                            s = "";
                        }

                        grid1[i, 1 + j] = new SourceGrid2.Cells.Real.Cell(
                            s, typeof(string));
                        (grid1[i, 1 + j] as SourceGrid2.Cells.Real.Cell).TextAlignment = CComLibrary.GlobeVal.filesave.mtable1para.mTableGridPara.GridAlignment;
                        (grid1[i, 1 + j] as SourceGrid2.Cells.Real.Cell).BackColor     = CComLibrary.GlobeVal.filesave.mtable1para.mTableGridPara.GridBackColor;
                        (grid1[i, 1 + j] as SourceGrid2.Cells.Real.Cell).ForeColor     = CComLibrary.GlobeVal.filesave.mtable1para.mTableGridPara.GridForeColor;

                        (grid1[i, 1 + j] as SourceGrid2.Cells.Real.Cell).Font = new Font(CComLibrary.GlobeVal.filesave.mtable1para.mTableGridPara.GridFont.FontFamily,
                                                                                         CComLibrary.GlobeVal.filesave.mtable1para.mTableGridPara.GridFont.Size);
                    }

                    grid1[i, grid1.ColumnsCount - 1] = new SourceGrid2.Cells.Real.Cell(
                        "", typeof(string));
                }

                chkspe.Checked = CComLibrary.GlobeVal.filesave.mtable1para.showvalidspe;
                if (CComLibrary.GlobeVal.filesave.mtable1para.statisticssel == 0)
                {
                    this.radioButton1.Checked = true;
                    this.radioButton2.Checked = false;
                    this.radioButton3.Checked = false;
                }
                if (CComLibrary.GlobeVal.filesave.mtable1para.statisticssel == 1)
                {
                    this.radioButton1.Checked = false;
                    this.radioButton2.Checked = true;
                    this.radioButton3.Checked = false;
                }

                if (CComLibrary.GlobeVal.filesave.mtable1para.statisticssel == 2)
                {
                    this.radioButton1.Checked = false;
                    this.radioButton2.Checked = false;
                    this.radioButton3.Checked = true;
                }
            }

            if (resulttab == 1)
            {
                grid1.RowsCount = 0;


                grid1.BorderStyle = BorderStyle.Fixed3D;
                grid1.AutoStretchRowsToFitHeight = true;
                grid1.ColumnsCount = CComLibrary.GlobeVal.filesave.mtablecol2.Count + 2;

                grid1.FixedRows    = 1;
                grid1.FixedColumns = 1;

                grid1.Rows.Insert(0);
                grid1.Rows[0].Height = 30;


                SourceGrid2.Cells.Real.ColumnHeader boldHeader = new SourceGrid2.Cells.Real.ColumnHeader();
                boldHeader.Font = new Font(CComLibrary.GlobeVal.filesave.mtable2para.mTableHeaderPara.HeaderFont.FontFamily,
                                           CComLibrary.GlobeVal.filesave.mtable2para.mTableHeaderPara.HeaderFont.Size);
                boldHeader.EnableSort    = false;
                boldHeader.WordWrap      = true;
                boldHeader.Value         = "";
                boldHeader.TextAlignment = CComLibrary.GlobeVal.filesave.mtable2para.mTableHeaderPara.HeaderAlignment;
                boldHeader.BackColor     = CComLibrary.GlobeVal.filesave.mtable2para.mTableHeaderPara.HeaderBackColor;
                boldHeader.ForeColor     = CComLibrary.GlobeVal.filesave.mtable2para.mTableHeaderPara.HeaderForeColor;

                grid1[0, 0] = boldHeader;



                for (int i = 0; i < CComLibrary.GlobeVal.filesave.mtablecol2.Count; i++)
                {
                    boldHeader      = new SourceGrid2.Cells.Real.ColumnHeader();
                    boldHeader.Font = new Font(CComLibrary.GlobeVal.filesave.mtable2para.mTableHeaderPara.HeaderFont.FontFamily,
                                               CComLibrary.GlobeVal.filesave.mtable2para.mTableHeaderPara.HeaderFont.Size);
                    boldHeader.EnableSort = false;
                    boldHeader.WordWrap   = true;

                    if (CComLibrary.GlobeVal.filesave.mtablecol2[i].apply == false)
                    {
                        boldHeader.Value = CComLibrary.GlobeVal.filesave.mtablecol2[i].formulaname + "(" +
                                           CComLibrary.GlobeVal.filesave.mtablecol2[i].myitemsignal.cUnits[
                            CComLibrary.GlobeVal.filesave.mtablecol2[i].myitemsignal.cUnitsel] + ")";
                    }
                    else
                    {
                        boldHeader.Value = CComLibrary.GlobeVal.filesave.mtablecol2[i].formulaexplain + "(" +
                                           CComLibrary.GlobeVal.filesave.mtablecol2[i].myitemsignal.cUnits[
                            CComLibrary.GlobeVal.filesave.mtablecol2[i].myitemsignal.cUnitsel] + ")";
                    }
                    boldHeader.TextAlignment = CComLibrary.GlobeVal.filesave.mtable2para.mTableHeaderPara.HeaderAlignment;
                    boldHeader.BackColor     = CComLibrary.GlobeVal.filesave.mtable2para.mTableHeaderPara.HeaderBackColor;
                    boldHeader.ForeColor     = CComLibrary.GlobeVal.filesave.mtable2para.mTableHeaderPara.HeaderForeColor;

                    grid1[0, 1 + i] = boldHeader;
                }

                boldHeader      = new SourceGrid2.Cells.Real.ColumnHeader();
                boldHeader.Font = new Font(CComLibrary.GlobeVal.filesave.mtable2para.mTableHeaderPara.HeaderFont.FontFamily,
                                           CComLibrary.GlobeVal.filesave.mtable2para.mTableHeaderPara.HeaderFont.Size);
                boldHeader.EnableSort = false;
                boldHeader.WordWrap   = true;
                boldHeader.Value      = "";
                boldHeader.BackColor  = CComLibrary.GlobeVal.filesave.mtable2para.mTableHeaderPara.HeaderBackColor;
                boldHeader.ForeColor  = CComLibrary.GlobeVal.filesave.mtable2para.mTableHeaderPara.HeaderForeColor;


                grid1[0, CComLibrary.GlobeVal.filesave.mtablecol2.Count + 1] = boldHeader;


                int mw = grid1.Width / grid1.ColumnsCount;

                for (int i = 0; i < grid1.ColumnsCount; i++)
                {
                    grid1.Columns[i].Width = mw - 1;
                }


                grid1.Columns[grid1.ColumnsCount - 1].AutoSizeMode = SourceGrid2.AutoSizeMode.EnableStretch;

                grid1.AutoStretchColumnsToFitWidth = true;

                for (int i = 1; i <= 4; i++)
                {
                    grid1.Rows.Insert(i);


                    grid1[i, 0] = new SourceGrid2.Cells.Real.Button(
                        typeof(string));
                    (grid1[i, 0] as SourceGrid2.Cells.Real.Button).Value = i.ToString();

                    SourceGrid2.VisualModels.MultiImages view = new SourceGrid2.VisualModels.MultiImages();
                    view.BackColor = CComLibrary.GlobeVal.filesave.mtable2para.mTableColPara.ColBackColor;
                    view.ForeColor = CComLibrary.GlobeVal.filesave.mtable2para.mTableColPara.ColForeColor;

                    view.Font = new Font(CComLibrary.GlobeVal.filesave.mtable2para.mTableColPara.ColFont.FontFamily,
                                         CComLibrary.GlobeVal.filesave.mtable2para.mTableColPara.ColFont.Size);

                    if ((i == 2) || (i == 3))
                    {
                        if (CComLibrary.GlobeVal.filesave.mtable1para.showvalidspe == true)
                        {
                            view.Image = imageList1.Images[1];
                        }
                        else
                        {
                            view.Image = imageList1.Images[0];
                        }
                    }
                    else
                    {
                        view.Image = imageList1.Images[0];
                    }
                    view.TextAlignment = CComLibrary.GlobeVal.filesave.mtable2para.mTableColPara.ColAlignment;


                    grid1[i, 0].VisualModel = view;


                    for (int j = 0; j < CComLibrary.GlobeVal.filesave.mtablecol2.Count; j++)
                    {
                        grid1[i, 1 + j] = new SourceGrid2.Cells.Real.Cell(
                            "0.000", typeof(string));
                        (grid1[i, 1 + j] as SourceGrid2.Cells.Real.Cell).TextAlignment = CComLibrary.GlobeVal.filesave.mtable2para.mTableGridPara.GridAlignment;
                        (grid1[i, 1 + j] as SourceGrid2.Cells.Real.Cell).BackColor     = CComLibrary.GlobeVal.filesave.mtable2para.mTableGridPara.GridBackColor;
                        (grid1[i, 1 + j] as SourceGrid2.Cells.Real.Cell).ForeColor     = CComLibrary.GlobeVal.filesave.mtable2para.mTableGridPara.GridForeColor;

                        (grid1[i, 1 + j] as SourceGrid2.Cells.Real.Cell).Font = new Font(CComLibrary.GlobeVal.filesave.mtable2para.mTableGridPara.GridFont.FontFamily,
                                                                                         CComLibrary.GlobeVal.filesave.mtable2para.mTableGridPara.GridFont.Size);
                    }

                    grid1[i, grid1.ColumnsCount - 1] = new SourceGrid2.Cells.Real.Cell(
                        "", typeof(string));
                }

                chkspe.Checked = CComLibrary.GlobeVal.filesave.mtable2para.showvalidspe;
                if (CComLibrary.GlobeVal.filesave.mtable2para.statisticssel == 0)
                {
                    this.radioButton1.Checked = true;
                    this.radioButton2.Checked = false;
                    this.radioButton3.Checked = false;
                }
                if (CComLibrary.GlobeVal.filesave.mtable2para.statisticssel == 1)
                {
                    this.radioButton1.Checked = false;
                    this.radioButton2.Checked = true;
                    this.radioButton3.Checked = false;
                }

                if (CComLibrary.GlobeVal.filesave.mtable2para.statisticssel == 2)
                {
                    this.radioButton1.Checked = false;
                    this.radioButton2.Checked = false;
                    this.radioButton3.Checked = true;
                }
            }
        }