Exemple #1
0
        private void panel2_MouseUp(object sender, MouseEventArgs e)
        {
            int     H          = 0;
            int     W          = 0;
            GObject GContainer = new GObject();
            GObject GToDrag    = new GObject();

            GToDrag = GNetwork.GObjects[CurrObjDragIndx];
            double   d1     = 0;
            double   d2     = 0;
            TimeSpan DTDrag = new TimeSpan();

            DTDrag = DateTime.Now.Subtract(Tdown);
            if ((Dragging == true) && (DTDrag.Milliseconds > DragTimeMin))
            {
                //如果拖动的是线,并且有容器
                if ((GNetwork.GObjects[CurrObjDragIndx].Type == "Line") &&
                    (GNetwork.FindContainerObject(e.X, e.Y, ref GContainer, true) > -1))
                {
                    //
                    //    What is the point of the line to link ?
                    //    The nearest to (Xdown,Ydown)
                    //
                    d1 = CommFnc.distance(Xdown, Ydown, GToDrag.x1, GToDrag.y1);
                    d2 = CommFnc.distance(Xdown, Ydown, GToDrag.x2, GToDrag.y2);
                    if (d1 <= d2)
                    {
                        GToDrag.x1   = (GContainer.x1 + GContainer.x2) / 2;
                        GToDrag.y1   = (GContainer.y1 + GContainer.y2) / 2;
                        GToDrag.Lnk1 = GContainer.Name;
                    }
                    else
                    {
                        GToDrag.x2   = (GContainer.x1 + GContainer.x2) / 2;
                        GToDrag.y2   = (GContainer.y1 + GContainer.y2) / 2;
                        GToDrag.Lnk2 = GContainer.Name;
                    }
                }
                else
                {
                    W          = GToDrag.x2 - GToDrag.x1;
                    H          = GToDrag.y2 - GToDrag.y1;
                    GToDrag.x1 = e.X;
                    GToDrag.y1 = e.Y;
                    GToDrag.x2 = e.X + W;
                    GToDrag.y2 = e.Y + H;
                    GNetwork.AdjustLinkedTo(GToDrag.Name);
                }
                Cursor.Current = Cursors.Default;
                Dragging       = false;



                //this.panel2.Refresh();

                ReDrawAll();

                //this.Refresh();
            }
        }
Exemple #2
0
    //프로그램 시작 시
    void Awake()
    {
        //Cursor.lockState = CursorLockMode.Locked;
        //Cursor.visible = false;
        //참조하는 게임오브젝트 및 컴포넌트 찾아서 가져오기
        user             = GameObject.Find("User").GetComponent <GUser>();
        net              = GetComponent <GNetwork>();
        screenViewCanvas = GameObject.Find("ScreenViewCanvas").gameObject;
        blackScreen      = GameObject.Find("ScreenViewCanvas").transform.Find("BlackScreen").GetComponent <Image>();
        //변수 초기화
        sinValue   = 0.0f;
        switchFlag = false;
        //======================================
        //switchAlpha = 0.0f;
        //======================================
        switchAlpha  = 1.0f;
        switchTarget = GameMode.Park;
        gameMode     = GameMode.Switching;
        //======================================


        //게임 전체 꺼놓기, Park 만 켜놓기
        for (int i = 0; i < gameList.Count; i++)
        {
            gameList[i].AwakeInitialize();
            gameList[i].enabled = false;
        }
    }
Exemple #3
0
        private void panel2_MouseDown(object sender, MouseEventArgs e)
        {
            Xdown = e.X;
            Ydown = e.Y;
            Tdown = DateTime.Now;
            GObject GContainer = new GObject();
            int     Container  = GNetwork.FindContainerObject(Xdown, Ydown, ref GContainer, false);

            //如果有容器,就允许拖动!!
            if (Container > -1)
            {
                Dragging        = true;
                Cursor.Current  = Cursors.Hand;
                CurrObjDragIndx = Container;
            }
            else
            {
                // Click out of all objects
            }
        }
Exemple #4
0
        private void panel2_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Xdown = e.X;
            Ydown = e.Y;
            //Tdown = DateTime.Now;
            GObject GContainer = new GObject();
            int     Container  = GNetwork.FindContainerObject(Xdown, Ydown, ref GContainer, false);

            //如果有容器,就允许拖动!!
            if (Container > -1)
            {
                //Dragging = true;
                //Cursor.Current = Cursors.Hand;
                //CurrObjDragIndx = Container;

                this.toolTip1.SetToolTip(this.panel2, GContainer.AddInfo);
                //this.toolTip1.ShowAlways = true;
                //this.toolTip1.Show(this);
            }
            else
            {
                // Click out of all objects
            }
        }
Exemple #5
0
        /// <summary>
        /// 首先判断ShowBlockNodes和StoreBlockNodes的比对关系
        /// </summary>
        private void RefreshPanelInfo()
        {
            while (true)
            {
                //争取在左上角加一个时间显示!!!

                ///争取画面不闪烁的关键是一次性画出所有控件!!!

                //每一次都从GNetwork读取信息,不再删除该数组
                //GNetwork.Clear();
                //GNetwork = new GScenario(Nmax);
                //GNetwork.CurrObjIndx = 0;

                //this.panel2.Refresh();



                //urinatedong
                //RepeatTime 代表最多有几层
                //FindNodeNumber 代表每层最多有几个,这两个数据需要在显示之前传进来


                //int RepeatTime = 6;

                //int[] FindNodeNumber = new int[5] { 1, 2, 3, 4, 6 };

                ///在读端使用

                //int RepeatTimeForRead = 0;

                //List<int> EveryColumnNodeCountForRead = new List<int>();



                if (this.ShowBlockNodes.Nodelist.Count > 0)
                {
                    _rwlock.AcquireReaderLock(100);



                    ///首先删除那些已经不存在的关系和节点!!!
                    ///urinatedong 20170325
                    ///删除上一轮中消失的节点
                    ///问题是按照要求需要显示出来,显示在哪里???
                    var NoneNodes = from p in this.StoreBlockNodes.Nodelist where !(from q in this.ShowBlockNodes.Nodelist select q.MacAddress).Contains(p.MacAddress) select p;

                    if (NoneNodes.Count() > 0)
                    {
                        foreach (MeshNode n in NoneNodes)
                        {
                            GObject obj = new GObject();
                            GNetwork.FindGObjectByName(n.MacAddress, ref obj);

                            if (obj.Type != "")
                            {
                                GNetwork.DeleteGObject(obj);
                                //在TreeView中删除该MAC对应的父节点!!!
                                //this.treeView1.Nodes.Find(n.MacAddress, true);
                                DeleteNodeMethod(n.MacAddress);
                            }
                        }
                    }

                    var NoneRelations = from p in this.ShowBlockNodes.Relationlist where !this.StoreBlockNodes.Relationlist.Any(x => x.Localnode.IpAddress == p.Localnode.IpAddress & x.Remotenode.IpAddress == p.Remotenode.IpAddress) select p;

                    if (NoneRelations.Count() > 0)
                    {
                        foreach (MeshRelation r in NoneRelations)
                        {
                            GObject obj = new GObject();
                            GNetwork.FindGObjectByName(r.Localnode.MacAddress + r.Remotenode.MacAddress, ref obj);

                            if (obj.Type != "")
                            {
                                GNetwork.DeleteGObject(obj);
                            }
                        }
                    }

                    //var NoneNodes = this.ShowBlockNodes.Nodelist.Where(x=>x.IpAddress)


                    ///需要在这里判断出来哪些是在这个循环中没有出现的节点???



                    ///首先分割界面!!!
                    ///获取区间宽度
                    int ColumnWidth = this.panel2.Width / RepeatTimeForRead;

                    int nodecount = 0;



                    for (int i = 0; i < RepeatTimeForRead; i++)
                    {
                        //x坐标为 ColumnWidth/2 + i*ColumnWidth - 30(图片宽度的一半)

                        int j = EveryColumnNodeCountForRead[i];

                        if (j > 0)
                        {
                            //每行占据的高度
                            int CellHeight = this.panel2.Height / j;

                            for (int k = 0; k < j; k++)
                            {
                                //y坐标为 CellHeight/2 + k*CellHeight - 30(图片高度的一半)

                                //AddGObject(x, y, node);



                                MeshNode TempNode = ShowBlockNodes.Nodelist[nodecount];


                                //urinatedog 向TREEVIEW中加入节点
                                //TreeNode NewNode = this.treeView1.Nodes.Add(TempNode.IpAddress);
                                //TreeNode SubNode = new TreeNode(TempNode.MacAddress);

                                //NewNode.Nodes.Add(SubNode);

                                AddNodeMethod(TempNode);


                                int x = ColumnWidth / 2 + i * ColumnWidth - this.imageList1.ImageSize.Width / 2;
                                int y = CellHeight / 2 + k * CellHeight - this.imageList1.ImageSize.Height / 2;

                                nodecount++;

                                //AddGobject(ColumnWidth / 2 + i * ColumnWidth - 30, CellHeight / 2 + k * CellHeight - 30, TempNode);


                                ///使用双缓存后,这里就很重要,必须每个循环后判断哪些变化了,哪些没有变化!!!

                                AddGObject(ColumnWidth / 2 + i * ColumnWidth - this.imageList1.ImageSize.Width / 2, CellHeight / 2 + k * CellHeight - this.imageList1.ImageSize.Height / 2, TempNode);
                            }
                        }
                    }


                    ///开始画线
                    ///public void FindGObjectByName(string ObjLnkName, ref GObject GObj)
                    ///urinatedong 20170311
                    ///关系不对暂时取消!

                    GObject TempGObject = new GObject();

                    if (ShowBlockNodes.Relationlist.Count > 0)
                    {
                        foreach (MeshRelation r in ShowBlockNodes.Relationlist)
                        {
                            GNetwork.FindGObjectByName(r.Localnode.MacAddress, ref TempGObject);
                            int x1 = TempGObject.x1;
                            int y1 = TempGObject.y1;
                            GNetwork.FindGObjectByName(r.Remotenode.MacAddress, ref TempGObject);
                            int x2 = TempGObject.x1;
                            int y2 = TempGObject.y1;

                            int ImageHeight = imageList1.Images[0].Height;
                            int ImageWidth  = imageList1.Images[0].Width;

                            AddGobject(x1 + ImageWidth / 2, y1 + ImageHeight / 2, x2 + ImageWidth / 2, y2 + ImageHeight / 2, r);
                        }
                    }

                    #region urinatedong 20170322 取消对于连线位置的判断
                    //if (ShowBlockNodes.Relationlist.Count > 0)
                    //{
                    //    foreach (relation r in ShowBlockNodes.Relationlist)
                    //    {
                    //      GNetwork.FindGObjectByName(r.Localnode.MacAddress, ref TempGObject);
                    //      int x1 = TempGObject.x1;
                    //      int y1 = TempGObject.y1;
                    //      GNetwork.FindGObjectByName(r.Remotenode.MacAddress, ref TempGObject);
                    //      int x2 = TempGObject.x1;
                    //      int y2 = TempGObject.y1;

                    //      ///重新定义画线的方式(如果新节点在上,采用老节点右上,新节点坐下的方式画)
                    //      if (y1 > y2)
                    //      {
                    //          if (x1.Equals(x2)) //画竖线
                    //          {
                    //              x1 = x1 + 30;
                    //              y2 = y2 + 60;

                    //              x2 = x2 + 30;


                    //          }
                    //          else
                    //          {
                    //              x1 = x1 + 60;
                    //              //x2 = x2 - 60;
                    //              y1 = y1 + 30;
                    //              y2 = y2 + 30;

                    //          }
                    //      }
                    //      else if (y1 < y2)
                    //      {

                    //          if (x1.Equals(x2)) //画竖线
                    //          {
                    //              x1 = x1 + 30;
                    //              y1 = y1 + 60;

                    //              x2 = x2 + 30;

                    //          }
                    //          else
                    //          {
                    //              x1 = x1 + 60;
                    //              y1 = y1 + 30;
                    //              y2 = y2 + 30;
                    //          }
                    //      }
                    //      else  //画横线
                    //      {

                    //          x1 = x1 + 60;
                    //          y1 = y1 + 30;
                    //          y2 = y2 + 30;

                    //      }

                    //      AddGobject(x1, y1, x2, y2, r);

                    //    }
                    //}
                    #endregion

                    _rwlock.ReleaseReaderLock();

                    this.StoreBlockNodes.Nodelist     = this.ShowBlockNodes.Nodelist.ToArray().ToList();
                    this.StoreBlockNodes.Relationlist = this.ShowBlockNodes.Relationlist.ToArray().ToList();
                }


                this.Invoke(new DPanel2Refresh(Panel2Refresh));


                Thread.Sleep(this.ShowRate * 1000);
            }
        }
Exemple #6
0
        /// <summary>
        /// urinatedong 20170312
        /// 新增一键改频后台代码
        /// </summary>
        /// <param name="frequency">新频率</param>
        private void updatefrequency(object frequency)
        {
            GNetwork.Clear();
            GNetwork             = new GScenario(Nmax);
            GNetwork.CurrObjIndx = 0;

            //this.panel2.Refresh();
            this.Invoke(new DPanel2Refresh(Panel2Refresh));



            List <MeshNode> updatefrequencynodelist = new List <MeshNode>();



            _rwlock.AcquireWriterLock(100);

            updatefrequencynodelist = this.ShowBlockNodes.Nodelist.ToArray().ToList();

            _rwlock.ReleaseWriterLock();



            if (updatefrequencynodelist.Count > 0)
            {
                ///尝试关闭进程
                try
                {
                    if (GetRealInfoThread != null)
                    {
                        GetRealInfoThread.Abort();
                        GetRealInfoThread = null;
                    }

                    if (RefreshPanelContext != null)
                    {
                        RefreshPanelContext.Abort();
                        RefreshPanelContext = null;
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.WriteLog("关闭前后台现成时异常:" + ex.Message.ToString());
                    MessageBox.Show("无法关闭前后台现成,不能进行一键改频操作");
                    return;
                }

                double param = (double)frequency;

                int nodecount = updatefrequencynodelist.Count;


                for (int i = nodecount - 1; i >= 0; i--)
                {
                    LogHelper.WriteLog("开始修改IP为" + updatefrequencynodelist[i].IpAddress + " 节点的frequency 信息!");
                    LogHelper.WriteLog("当前频率: " + updatefrequencynodelist[i].Frequency.ToString() + " 计划修改频率: " + param.ToString());
                    try
                    {
                        if (updatefrequencynodelist[i].Frequency.Equals(param))
                        {
                            LogHelper.WriteLog("频率与原来频率相同无需修改!!!");
                        }
                        else
                        {
                            UpdateFrequencyTelnetTelegram(updatefrequencynodelist[i].IpAddress, param);
                        }
                    }
                    catch (Exception ex)
                    {
                        LogHelper.WriteLog("该IP修改频率未成功,不再修改其他节点频率!!!");
                        MessageBox.Show("IP为" + updatefrequencynodelist[i].IpAddress + " 节点的频率信息未修改成功!");
                        break;
                    }
                }
                this.MYBlockNodes.Nodelist.Clear();
                this.MYBlockNodes.Relationlist.Clear();
                this.ShowBlockNodes.Nodelist.Clear();
                this.ShowBlockNodes.Relationlist.Clear();
                this.StoreBlockNodes.Nodelist.Clear();
                this.StoreBlockNodes.Relationlist.Clear();
                MessageBox.Show("更改频率完成,请重新扫描拓扑检查信息!!!");
            }
            else
            {
                MessageBox.Show("没有发现节点,请检查拓扑结构!");
            }
        }