Пример #1
0
 //比较两个国家土地
 public static int CompareNationsByDistrict(NationNode x, NationNode y)
 {
     if (x == null)
     {
         if (y == null)
         {
             // If x is null and y is null, they're
             // equal.
             return(0);
         }
         else
         {
             // If x is null and y is not null, y
             // is greater.
             return(1);
         }
     }
     else
     {
         // If x is not null...
         //
         if (y == null)
         // ...and y is null, x is greater.
         {
             return(-1);
         }
         else
         {
             // ...and y is not null, compare the
             // lengths of the two strings.
             //
             int retval = x.Districts.Count.CompareTo(y.Districts.Count);
             return(-retval);
         }
     }
 }
Пример #2
0
        //绘制节点
        Image DrawNode(DistrictNode dNode, NationNode nNode)
        {
            Pen        frame;       //显示变量 边框画笔
            Image      img;         //返回Image
            Graphics   gGraphic;    //绘制目标图元
            SolidBrush fore, back;  //显示变量 背景色刷
            int        intRand;     //半径

            intRand = 12;
            //新建位图,存放节点图像
            img      = new Bitmap(intRand * 2 + 1, intRand * 2 + 1);
            gGraphic = Graphics.FromImage(img);
            gGraphic.SmoothingMode = SmoothingMode.HighQuality;//平滑处理
            //填充圆形
            back = new SolidBrush(nNode.BackColor);
            gGraphic.FillEllipse(back, 0, 0, intRand * 2, intRand * 2);
            //外围边框绘制
            frame = new Pen(nNode.FrameColor);
            gGraphic.DrawEllipse(frame, 0, 0, 2 * intRand, 2 * intRand);
            //绘制前景字符串
            fore = new SolidBrush(nNode.ForeColor);
            gGraphic.DrawString(dNode.Name, new Font("Times New Roman", 7), fore, 1, 7);
            return(img);
        }