Пример #1
0
        public void DealEventProperty(bool bClick, object sender, EventArgs e)
        {
            VisualGraph.VisualGraph drawArea = (VisualGraph.VisualGraph)sender;

            //取得鼠标位置
            Point      point = new Point(MousePosition.X, MousePosition.Y);
            DrawObject gp    = drawArea.ObjList.GetSelectedObject(point);

            if (gp != null)//选中了
            {
                if (bClick)
                {
                    if (gp.Click != "")//deal the click event
                    {
                        string[] strContent = gp.Click.Split('+');
                        if (strContent[0].Equals("打开画面"))
                        {
                            try
                            {
                                int n = editFormList.Count;
                                for (int i = 0; i < n; i++)
                                {
                                    if (((FormEdit)editFormList[i]).Text.Equals(strContent[1]))
                                    {
                                        SelectedPage.SendToBack();
                                        ((FormEdit)editFormList[i]).Show();
                                        ((FormEdit)editFormList[i]).BringToFront();
                                        SelectedPage = editFormList[i];
                                        nCurrentForm = i;
                                        break;
                                    }
                                }
                            }
                            catch (System.Exception ex)
                            {
                                MessageBox.Show(ex.Message, "Error");
                            }
                        }
                        else if (strContent[0].Equals("写变量值"))
                        {
                            WritetoDevice(strContent[1], strContent[2]);
                        }
                    }
                }
                else
                {
                    if (gp.DoubleClick != "")//deal the dclick event
                    {
                        string[] strContent = gp.Click.Split('+');
                        if (strContent[0].Equals("打开画面"))
                        {
                            try
                            {
                                int n = editFormList.Count;
                                for (int i = 0; i < n; i++)
                                {
                                    if (((FormEdit)editFormList[i]).Text.Equals(strContent[1]))
                                    {
                                        ((FormEdit)editFormList[i]).Show();
                                        ((FormEdit)editFormList[i]).BringToFront();
                                        SelectedPage = editFormList[i];
                                        break;
                                    }
                                }
                            }
                            catch (System.Exception ex)
                            {
                                MessageBox.Show(ex.Message, "Error");
                            }
                        }
                        else if (strContent[0].Equals("写变量值"))
                        {
                            WritetoDevice(strContent[1], strContent[2]);
                        }
                    }
                }
            }
        }