Пример #1
0
        //高亮节点绘制函数
        public void DrawHighLightNode(int iNum, ref Graphics GraCam)
        {
            Image          img;
            PaintParameter curNodePara;
            Point          potStart;
            dNode          curNode = curNetwork.Network[iNum];

            //计算网络绘制参数
            curNodePara = new PaintParameter(iNum, curNode.Degree, curNetwork.MaxDeg, curNetwork.MinDeg);
            //获取绘制完成的图片
            img = this.DrawNode(curNodePara, true);
            //在图元对应位置绘制图片
            GraCam.DrawImage(img, new Point(curNode.Location.X - img.Width / 2, curNode.Location.Y - img.Height / 2));
            //计算编号绘制起点
            potStart = new Point(curNode.Location.X - curNode.Offset.X, curNode.Location.Y - curNode.Offset.Y);
            //绘制节点编号
            this.DrawString(iNum.ToString(), potStart, ref GraCam, true);
        }
Пример #2
0
        //刷新网络图片列表
        void IfPaintStrategy.UpdateImage()
        {
            PaintParameter curNodePara;
            Image IRet;
            int index;

            //计算每个节点的绘制参数
            foreach (dNode curNode in curNetwork.Network)
            {
                curNodePara = new PaintParameter(curNode.Number, curNode.ComCount, curNetwork.MaxDeg, curNetwork.MinDeg);
                curNode.Offset = new Point(curNodePara.x, curNodePara.y);
            }
            //绘制每个通信度所属的图片
            foreach (KeyValuePair<int, int> img in curNetwork.DegreeList)
            {
                curNodePara = new PaintParameter(img.Key, img.Key, curNetwork.MaxDeg, curNetwork.MinDeg);
                IRet = this.DrawNode(curNodePara, false);
                index = img.Key;
                curNetwork.SharedImages.Remove(index);
                curNetwork.SharedImages.Add(index, IRet);
            }
        }
Пример #3
0
        //刷新网络图片列表
        void IfPaintStrategy.UpdateImage()
        {
            PaintParameter curNodePara;
            Image          IRet;
            int            index;

            //计算每个节点的绘制参数
            foreach (dNode curNode in curNetwork.Network)
            {
                curNodePara    = new PaintParameter(curNode.Number, curNode.Degree, curNetwork.MaxDeg, curNetwork.MinDeg);
                curNode.Offset = new Point(curNodePara.x, curNodePara.y);
            }
            //绘制每个度所属的图片
            foreach (KeyValuePair <int, int> img in curNetwork.DegreeList)
            {
                curNodePara = new PaintParameter(img.Key, img.Key, curNetwork.MaxDeg, curNetwork.MinDeg);
                IRet        = this.DrawNode(curNodePara, false);
                index       = img.Key;
                curNetwork.SharedImages.Remove(index);
                curNetwork.SharedImages.Add(index, IRet);
            }
        }
Пример #4
0
        //绘制网络节点,输入绘制参数和是否高亮
        Image DrawNode(PaintParameter curNodePara, Boolean isHL)
        {
            Pen frame;					//显示变量 边框画笔
            Image img;                  //返回Image
            Graphics gGraphic;      //绘制目标图元
            GraphicsPath path;  //路径图形
            PathGradientBrush pthGrBrush;   //路径画笔
            int intRand;                    //半径

            intRand = curNodePara.intRand;
            //新建位图,存放节点图像
            img = new Bitmap(intRand * 2 + 1, intRand * 2 + 1);
            gGraphic = Graphics.FromImage(img);
            gGraphic.SmoothingMode = NetStyle.SmoothMode;//平滑处理
            //立体效果绘制
            path = new GraphicsPath();
            path.AddEllipse(0, 0, intRand * 2, intRand * 2);
            pthGrBrush = new PathGradientBrush(path);
            pthGrBrush.CenterColor = Color.FromArgb(255, 255, 255, 255);
            pthGrBrush.CenterPoint = new Point(Convert.ToInt32(2 * intRand * 0.618), Convert.ToInt32(intRand * 0.618));
            if (isHL == true)
            {//高亮节点使用高亮背景色和边框
                frame = new Pen(NetStyle.HLFrameColor);
                pthGrBrush.SurroundColors = new Color[] { NetStyle.HLBackColor };
            }
            else
            {//普通节点使用普通背景色和边框
                frame = new Pen(NetStyle.FrameColor);
                pthGrBrush.SurroundColors = new Color[] { NetStyle.BackColor };
            }
            //填充圆形
            gGraphic.FillEllipse(pthGrBrush, 0, 0, intRand * 2, intRand * 2);
            //外围边框绘制
            gGraphic.DrawEllipse(frame, 0, 0, 2 * intRand, 2 * intRand);
            return img;
        }
Пример #5
0
        //绘制网络节点,输入绘制参数和是否高亮
        Image DrawNode(PaintParameter curNodePara, Boolean isHL)
        {
            Pen               frame;      //显示变量 边框画笔
            Image             img;        //返回Image
            Graphics          gGraphic;   //绘制目标图元
            GraphicsPath      path;       //路径图形
            PathGradientBrush pthGrBrush; //路径画笔
            int               intRand;    //半径

            intRand = curNodePara.intRand;
            //新建位图,存放节点图像
            img      = new Bitmap(intRand * 2 + 1, intRand * 2 + 1);
            gGraphic = Graphics.FromImage(img);
            gGraphic.SmoothingMode = NetStyle.SmoothMode;//平滑处理
            //立体效果绘制
            path = new GraphicsPath();
            path.AddEllipse(0, 0, intRand * 2, intRand * 2);
            pthGrBrush             = new PathGradientBrush(path);
            pthGrBrush.CenterColor = Color.FromArgb(255, 255, 255, 255);
            pthGrBrush.CenterPoint = new Point(Convert.ToInt32(2 * intRand * 0.618), Convert.ToInt32(intRand * 0.618));
            if (isHL == true)
            {//高亮节点使用高亮背景色和边框
                frame = new Pen(NetStyle.HLFrameColor);
                pthGrBrush.SurroundColors = new Color[] { NetStyle.HLBackColor };
            }
            else
            {//普通节点使用普通背景色和边框
                frame = new Pen(NetStyle.FrameColor);
                pthGrBrush.SurroundColors = new Color[] { NetStyle.BackColor };
            }
            //填充圆形
            gGraphic.FillEllipse(pthGrBrush, 0, 0, intRand * 2, intRand * 2);
            //外围边框绘制
            gGraphic.DrawEllipse(frame, 0, 0, 2 * intRand, 2 * intRand);
            return(img);
        }
Пример #6
0
        //高亮节点绘制函数
        public void DrawHighLightNode(int iNum, ref Graphics GraCam)
        {
            Image img;
            PaintParameter curNodePara;
            Point potStart;
            dNode curNode = curNetwork.Network[iNum];

            //计算网络绘制参数
            curNodePara = new PaintParameter(iNum, curNode.ComCount, curNetwork.MaxDeg, curNetwork.MinDeg);
            //获取绘制完成的图片
            img = this.DrawNode(curNodePara, true);
            //在图元对应位置绘制图片
            GraCam.DrawImage(img, new Point(curNode.Location.X - img.Width / 2, curNode.Location.Y - img.Height / 2));
            //计算编号绘制起点
            potStart = new Point(curNode.Location.X - curNode.Offset.X, curNode.Location.Y - curNode.Offset.Y);
            //绘制节点编号
            this.DrawString(iNum.ToString(), potStart, ref GraCam, true);
        }