예제 #1
0
            /// <summary>
            /// 构造函数
            /// </summary>
            /// <param name="DataSheet">图表对应的数据工作表</param>
            /// <param name="DrawingChart">Excel图形所在的Chart对象</param>
            /// <param name="ParentApp">此图表所在的Excel类的实例对象</param>
            /// <param name="type">此图表所属的类型,由枚举drawingtype提供</param>
            /// <param name="CanRoll">是图表是否可以滚动,即是动态图还是静态图</param>
            /// <param name="Info">图表中用来显示相关信息的那个文本框对象</param>
            /// <param name="DrawingTag">每一个监测曲线图的相关信息</param>
            /// <param name="MonitorType">监测数据的类型,比如测斜数据、立柱垂直位移数据、支撑轴力数据等</param>
            /// <remarks></remarks>
            public ClsDrawing_Mnt_Base(Excel.Worksheet DataSheet,
                                       Microsoft.Office.Interop.Excel.Chart DrawingChart, Cls_ExcelForMonitorDrawing ParentApp,
                                       DrawingType type, bool CanRoll, Excel.TextFrame2 Info,
                                       MonitorInfo DrawingTag, MntType MonitorType)
            {
                try
                {
                    //设置Excel窗口与Chart的尺寸

                    this.F_Application = ParentApp.Application;
                    ExcelFunction.SetLocation_Size(this.ChartSize_sugested, DrawingChart, this.Application, true);
                    //
                    this.Sheet_Data     = DataSheet;
                    this.F_myChart      = DrawingChart;
                    this.F_textbox_Info = Info;
                    this.Sheet_Drawing  = DrawingChart.Parent.Parent;
                    this.F_blnCanRoll   = CanRoll;
                    this.F_DrawingType  = type;
                    this.P_MntType      = MonitorType;
                    //将此对象添加进其所属的集合中
                    F_Class_ParentApp = ParentApp;
                    //
                    this.P_Key      = System.Convert.ToInt32(F_Class_ParentApp.Mnt_Drawings.Add(this));
                    this.F_UniqueID = GeneralMethods.GetUniqueID();
                    //
                    this.Tags = DrawingTag;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("创建基本监测曲线图出错。" + "\r\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
예제 #2
0
        /// <summary>
        /// 开始绘制开挖剖面图的Chart对象
        /// </summary>
        /// <returns>进行绘图的Chart对象的高度值,以磅为单位,可以用来确定Excel Application的高度值</returns>
        /// <remarks>绘图时,标高值与Excel中的Y坐标值的对应关系:
        /// 在程序中,定义了eleTop变量(以米为单位)与F_sngTopRef变量(以磅为单位),
        /// 它们指示的是此基坑区域中,地下室顶板的标高值与其在Excel绘图中对应的Y坐标值</remarks>
        private Microsoft.Office.Interop.Excel.Chart DrawChart(Microsoft.Office.Interop.Excel.Worksheet DrawingSheet,
                                                               List <clsData_ProcessRegionData> SelectedRegion)
        {
            Microsoft.Office.Interop.Excel.Application DrawingApp = DrawingSheet.Application;
            DrawingApp.ScreenUpdating = false;
            DrawingApp.Caption        = "开挖标高图";

            //---------------- 创建一个新的,进行绘图的Chart对象 -------------------------------
            Excel.Chart DrawingChart = default(Excel.Chart);
            DrawingChart = DrawingSheet.Shapes.AddChart(Top: 0, Left: 0).Chart;
            string TemplatePath = System.IO.Path.Combine(System.Convert.ToString(My.Settings.Default.Path_Template),
                                                         Constants.FolderOrFileName.File_Template.Chart_Elevation);

            DrawingChart.Parent.Activate();
            DrawingChart.ApplyChartTemplate(TemplatePath);
            this.F_Textbox_Info          = DrawingChart.Shapes.Item(1).TextFrame2;
            DrawingChart.ChartTitle.Text = "开挖标高图";
            //
            Microsoft.Office.Interop.Excel.SeriesCollection src = DrawingChart.SeriesCollection();
            for (short i = 0; i <= 1 - src.Count; i++)             //确保Chart中至少有两个数据系列
            {
                src.NewSeries();
            }
            // ----------------------- 设置绘图及Excel窗口的尺寸 ----------------------------
            double ChartHeight       = 400;
            double InsideLeft        = 60;
            double InsideRight       = 20;
            double LeastWidth_Chart  = 500;
            double LeastWidth_Column = 100;
            //
            double ChartWidth  = LeastWidth_Chart;
            double insideWidth = LeastWidth_Chart - InsideLeft - InsideRight;

            //
            ChartWidth = GetChartWidth(DrawingChart, SelectedRegion.Count,
                                       LeastWidth_Chart, LeastWidth_Column,
                                       InsideLeft + InsideRight, ref insideWidth);
            ChartSize Size_Chart_App = new ChartSize(ChartHeight,
                                                     ChartWidth,
                                                     26,
                                                     9);

            ExcelFunction.SetLocation_Size(Size_Chart_App, DrawingChart, DrawingChart.Application, true);
            //With DrawingChart.PlotArea
            //    .InsideLeft = InsideLeft
            //    .InsideWidth = insideWidth
            //End With
            // --------------------------------------------------
            return(DrawingChart);
        }