Ejemplo n.º 1
0
        /// <summary>
        /// 图形控件命令响应方法
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mx_OnViewCallOutCommand(object sender, Axmetamap2dLib.IMetaMapX2DEvents_OnViewCallOutCommandEvent e)
        {
            string Param = "";

            switch (e.p_sCmd)
            {
            case "MessagePub":    //测试交互代码
                DevExpress.XtraEditors.XtraMessageBox.Show(e.p_sParam);
                break;

            case "PointEdit":    //图形测点编辑
                //barStaticItem1.Caption = "测点编辑";
                //try
                //{
                //    Param = e.p_sParam;
                //    string Point = e.p_sParam.ToString().Split('|')[0];
                //    string UnitName = e.p_sParam.ToString().Split('|')[1];
                //    string BindType = e.p_sParam.ToString().Split('|')[2];
                //    string ZoomLevel = e.p_sParam.ToString().Split('|')[3];
                //    string animationState = e.p_sParam.ToString().Split('|')[4];
                //    string TurnToPage = "";
                //    //判断当前图元类型
                //    if (UnitName.Contains("&"))//静态图元
                //    {
                //        if (BindType == "1" || BindType == "2")
                //        {
                //            string Width = e.p_sParam.ToString().Split('|')[5];
                //            string Height = e.p_sParam.ToString().Split('|')[6];
                //            TurnToPage = e.p_sParam.ToString().Split('|')[7];

                //            PointEdit pointedit = new PointEdit(Point, Width, Height, TurnToPage);
                //            pointedit.Show();
                //        }
                //        else
                //        {
                //            TurnToPage = e.p_sParam.ToString().Split('|')[5];
                //            PointEdit pointedit = new PointEdit(Point, TurnToPage);
                //            pointedit.Show();
                //        }
                //    }
                //    else//动态图元
                //    {
                //        if (BindType == "1" || BindType == "2")
                //        {
                //            string Width = e.p_sParam.ToString().Split('|')[5];
                //            string Height = e.p_sParam.ToString().Split('|')[6];
                //            TurnToPage = e.p_sParam.ToString().Split('|')[7];
                //            //PointDefEdit pointedit = new PointDefEdit(Point, UnitName, BindType, ZoomLevel, animationState, Width, Height, TurnToPage);
                //            //pointedit.Show();
                //        }
                //        else
                //        {
                //            TurnToPage = e.p_sParam.ToString().Split('|')[5];
                //            //PointDefEdit pointedit = new PointDefEdit(Point, UnitName, BindType, ZoomLevel, animationState, TurnToPage);
                //            //pointedit.Show();
                //        }
                //    }
                //}
                //catch (Exception ex)
                //{
                //    //DevExpress.XtraEditors.XtraMessageBox.Show("测点编辑失败,详细请查看错误日志!");
                //    //barStaticItem1.Caption = "编辑失败,详细请查看错误日志!";
                //    LogHelper.Error("mx_OnViewCallOutCommand_PointEdit" + ex.Message + ex.StackTrace);
                //}
                break;

            case "PointDel":    //图形测点删除
            // barStaticItem1.Caption = "测点删除";
            //try
            //{
            //    Param = e.p_sParam;
            //    GraphOpt.DelPoint(mx, Param);
            //}
            //catch (Exception ex)
            //{
            //    //DevExpress.XtraEditors.XtraMessageBox.Show("删除失败,详细请查看错误日志!");
            //    // barStaticItem1.Caption = "删除失败,详细请查看错误日志!";
            //    LogHelper.Error("mx_OnViewCallOutCommand_PointDel" + ex.Message + ex.StackTrace);
            //}
            //break;
            case "PointsSave":    //图形测点保存
                //barStaticItem1.Caption = "图形保存";
                try
                {
                    Param = e.p_sParam;
                    GraphOpt.PointsSave(Param);
                    // barStaticItem1.Caption = "保存成功!";
                    //DevExpress.XtraEditors.XtraMessageBox.Show("保存成功!");
                }
                catch (Exception ex)
                {
                    //DevExpress.XtraEditors.XtraMessageBox.Show("保存失败,详细请查看错误日志!");
                    //barStaticItem1.Caption = "保存失败,详细请查看错误日志!";
                    LogHelper.Error("mx_OnViewCallOutCommand_PointsSave" + ex.Message + ex.StackTrace);
                }
                break;

            case "RoutesSave":    //保存测点连线
                try
                {
                    Param = e.p_sParam;
                    if (string.IsNullOrEmpty(Param))
                    {
                        return;
                    }
                    GraphOpt.RoutesSave(Param);
                }
                catch (Exception ex)
                {
                    //DevExpress.XtraEditors.XtraMessageBox.Show("保存测点连线失败,详细请查看错误日志!");
                    //barStaticItem1.Caption = "保存失败,详细请查看错误日志!";
                    LogHelper.Error("mx_OnViewCallOutCommand_RoutesSave" + ex.Message + ex.StackTrace);
                }
                break;

            case "LoadPoint":    //加载图形绑定的测点信息
                try
                {
                    //GraphOpt.LoadMapPointsInfo(mx, GraphOpt.GraphNameNow);
                    if (!string.IsNullOrWhiteSpace(this.Jsonstr))
                    {
                        string[] json = this.Jsonstr.Split('|');
                        GraphOpt.DoDrawingGraphicsInEdit(mx, json[0], json[1]);
                    }

                    //移除右键菜单
                    GraphOpt.DoRemoveMapContextMenu(mx);
                }
                catch (Exception ex)
                {
                    //DevExpress.XtraEditors.XtraMessageBox.Show("加载图形绑定的测点信息失败,详细请查看错误日志!");
                    // barStaticItem1.Caption = "加载图形的测点信息失败,详细请查看错误日志!";
                    LogHelper.Error("mx_OnViewCallOutCommand_LoadPoint" + ex.Message + ex.StackTrace);
                }
                break;

            case "SetMapEditState":    //设置图形的可编辑状态
                try
                {
                    GraphOpt.setGraphEditState(mx, GraphOpt.IsGraphicEdit);
                }
                catch (Exception ex)
                {
                    //DevExpress.XtraEditors.XtraMessageBox.Show("设置图形的可编辑状态失败,详细请查看错误日志!");
                    //barStaticItem1.Caption = "设置图形的编辑状态失败,详细请查看错误日志!";
                    LogHelper.Error("mx_OnViewCallOutCommand_SetMapEditState" + ex.Message + ex.StackTrace);
                }
                break;

            case "setMapEditSave":    //设置图形是否保存
                try
                {
                    Param = e.p_sParam;
                    GraphOpt.setGraphEditSave(bool.Parse(Param));
                }
                catch (Exception ex)
                {
                    //DevExpress.XtraEditors.XtraMessageBox.Show("设置图形是否保存失败,详细请查看错误日志!");
                    //  barStaticItem1.Caption = "设置图形是否保存失败,详细请查看错误日志!";
                    LogHelper.Error("mx_OnViewCallOutCommand_setMapEditSave" + ex.Message + ex.StackTrace);
                }
                break;

            case "SetMapTopologyInit":    //拓扑图初始化所有井上设备
                try
                {
                    if (GraphOpt.IsTopologyInit)
                    {
                        GraphOpt.SetMapTopologyInit(mx);
                    }
                }
                catch (Exception ex)
                {
                    //DevExpress.XtraEditors.XtraMessageBox.Show("拓扑图加载井上设备失败,详细请查看错误日志!");
                    // barStaticItem1.Caption = "拓扑图加载井上设备失败,详细请查看错误日志!";
                    LogHelper.Error("mx_OnViewCallOutCommand_SetMapTopologyInit" + ex.Message + ex.StackTrace);
                }
                break;

            case "pageToImg":
                // barStaticItem1.Caption = "导出图片";
                saveFileDialog1.FileName = GraphOpt.GraphNameNow;
                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    GraphOpt.mapToImage(mx, saveFileDialog1.FileName);
                }
                break;

            case "layerDis":
                // barStaticItem1.Caption = "图层显示/隐藏";

                break;

            case "pointDis":
                //barStaticItem1.Caption = "设备显示/隐藏";

                break;

            case "pointSercah":
                //barStaticItem1.Caption = "设备查找";

                break;

            case "PageChange":
                Param = e.p_sParam;
                LoadMap(Param);
                GraphOpt.IsTopologyInit = false;
                break;

            case "AddMapRightMenu":
                //添加右键菜单
                //string pageListstr = "";
                //IList<GraphicsbaseinfInfo> AllGraphicDto = GraphOpt.getAllGraphicDto();
                //if (AllGraphicDto.Count > 0)
                //{
                //    for (int i = 0; i < AllGraphicDto.Count; i++)
                //    {
                //        pageListstr += AllGraphicDto[i].GraphName + "|";
                //    }
                //    if (pageListstr.Contains("|"))
                //    {
                //        pageListstr = pageListstr.Substring(0, pageListstr.Length - 1);
                //    }
                //    GraphOpt.AddMapRightMenu(mx, pageListstr);
                //}
                break;

            case "DoRefPointSsz":
                try
                {
                    GraphOpt.DoRefPointSsz(mx);
                }
                catch (Exception ex)
                {
                    //DevExpress.XtraEditors.XtraMessageBox.Show("实时刷新数据失败,详细请查看错误日志!");
                    //barStaticItem1.Caption = "实时刷新数据失败,详细请查看错误日志!";
                    LogHelper.Error("mx_OnViewCallOutCommand_DoRefPointSsz" + ex.Message + ex.StackTrace);
                }
                break;

            case "PointDblClick":
                string Point_Now    = e.p_sParam.ToString().Split('|')[0];
                string UnitName_Now = e.p_sParam.ToString().Split('|')[1];

                GraphicspointsinfInfo PointDto = GraphOpt.getPointDto(Point_Now);
                if (!string.IsNullOrEmpty(PointDto.Bz4))
                {
                    GraphOpt.LoadMap(mx, PointDto.Bz4);
                }

                if (UnitName_Now.Contains("摄像头"))
                {
                    //CFVideoInf videoForm = new CFVideoInf(Point_Now);
                    //videoForm.Show();
                }
                break;
            }
        }