//A ADAPTER AVEC UN INT PLUTOT (PR AVOIR LES NUMEROS DIRECT DES POSITION

    int[] giveMeARowPosition()
    {
        myPoint[] rowPositions = new myPoint[columns];
        int[]     indexObjects = new int[columns];

        int randomRow = Random.Range(0, rows);



        for (var i = 0; i < columns; i++)
        {
            // Debug.Log(i);
            rowPositions[i].y = randomRow;
            rowPositions[i].x = i;


            int index = getNumOfTile(rowPositions[i].x, rowPositions[i].y);



            indexObjects[i] = index;
        }


        //  for (var i = 0; i < indexObjects.Length;i++) {


        //}

        return(indexObjects);
    }
示例#2
0
        private void save(string fileName)
        {
            FileStream    fs   = new FileStream(fileName, FileMode.Create);
            StreamWriter  sw   = new StreamWriter(fs);
            StringBuilder data = new StringBuilder("");

            foreach (var item in Node.dirData)
            {
                myPoint p      = item.Key;
                Node    n      = item.Value;
                string  helper = n.function + "|" + "R" + p.X.ToString() + "C" + p.Y.ToString() + ";|";
                foreach (var con in n.connetNode)
                {
                    helper += "R" + con.X.ToString() + "C" + con.Y.ToString() + ";";
                }
                helper += "|";

                foreach (var con in n.wasConnetNode)
                {
                    helper += "R" + con.X.ToString() + "C" + con.Y.ToString() + ";";
                }
                helper += "|" + n.data;
                data.Append(helper + "\r\n");
            }
            string result = GZipCompressString(data.ToString());

            sw.Write(result);
            sw.Close();
            fs.Close();

            MessageBox.Show("保存成功");
        }
示例#3
0
        private void textBox1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (isExpModing)
                {
                    isExpModing = false;
                    if (!Node.dirData.ContainsKey(expModPoint))
                    {
                        Node.dirData[expModPoint] = new Node(expModPoint);
                    }
                    Node.dirData[expModPoint].write(textBox1.Text, textBox1);

                    drawPic();
                    expSelectPoint = null;
                    expSelectPoint = null;
                }
                else
                {
                    if (selectPoint != null)
                    {
                        if (!Node.dirData.ContainsKey(selectPoint))
                        {
                            Node.dirData[selectPoint] = new Node(selectPoint);
                        }
                        Node.dirData[selectPoint].write(textBox1.Text, textBox1);
                        drawPic();
                    }
                    else
                    {
                        MessageBox.Show("未选中单元格");
                    }
                }
            }
        }
示例#4
0
        private void Picbox_MouseClick(object sender, MouseEventArgs e)
        {
            picbox.Focus();
            int x = e.X / 75;
            int y = e.Y / 20;

            if (!isExpModing)
            {
                selectPoint = new myPoint(p.X + y, p.Y + x);
                drawPic();
                g.DrawRectangle(new Pen(Color.Black, 2), (selectPoint.Y - p.Y) * 75, (selectPoint.X - p.X) * 20, 75, 20);
                picbox.Image = img;
                if (Node.dirData.ContainsKey(selectPoint))
                {
                    if (Node.dirData[selectPoint].function != "")
                    {
                        textBox1.Text = "=" + Node.dirData[selectPoint].function;
                        drawSelectRect(textBox1.Text);
                    }
                    else
                    {
                        textBox1.Text = Node.dirData[selectPoint].data;
                    }
                    textBox1.Tag = selectPoint;
                }
                else
                {
                    textBox1.Text = "";
                }
            }
            else
            {
                if (isExpModing)
                {
                    expSelectPoint = new myPoint(p.X + y, p.Y + x);
                    string preString = textBox1.Text;
                    string symbols   = "-+*/%(";
                    if (symbols.Contains(preString[preString.Length - 1]))
                    {
                        textBox1.Text += "R" + expSelectPoint.X + "C" + expSelectPoint.Y + ";";
                    }
                    else
                    {
                        int index = preString.LastIndexOf('R');
                        if (index != -1)
                        {
                            preString    = preString.Substring(0, index);
                            index        = selectPoints.LastIndexOf('R');
                            selectPoints = selectPoints.Substring(0, index);
                        }
                        textBox1.Text = preString + "R" + expSelectPoint.X + "C" + expSelectPoint.Y + ";";
                    }
                    selectPoints += "R" + expSelectPoint.X + "C" + expSelectPoint.Y + ";,";
                    drawPic();
                    g.DrawRectangle(new Pen(Color.Black, 2), (selectPoint.Y - p.Y) * 75, (selectPoint.X - p.X) * 20, 75, 20);
                    drawSelectRect(selectPoints);
                }
            }
        }
        void paint_Board()
        {
            myPoint MyPoint = new myPoint();

            int    row_index    = 0;
            int    column_index = 0;
            string Image_Name   = string.Empty;

            string tmp_color = string.Empty;

            for (int index = 0; index < ChessEngine1.Board_Array.Length; index++)
            {
                if (index > 7)
                {
                    column_index = (index) % 8;
                    row_index    = (index - column_index) / 8;
                }
                else
                {
                    column_index = index;
                    row_index    = 0;
                }

                MyPoint.X = ChessEngine1.MyCell.width * column_index;
                MyPoint.Y = ChessEngine1.MyCell.height * row_index;


                string element = ChessEngine1.Board_Array[index];



                if (element != "e")
                {
                    if (MyFunctions.is_lower_case(element))
                    {
                        Image_Name = "2" + element.ToUpper();
                    }
                    else
                    {
                        Image_Name = "1" + element.ToUpper();
                    }


                    images_list.Add(new image
                    {
                        x       = MyPoint.X + ChessEngine1.MyCell.width / 2 + ChessEngine1.MyCell.width * 0.1, //(1-0.8 qvemot rac iqneba /2 radgan unda gasashualovdes)
                        y       = MyPoint.Y + ChessEngine1.MyCell.height / 2 + ChessEngine1.MyCell.height * 0.1,
                        width   = ChessEngine1.MyCell.width * 0.8,
                        height  = ChessEngine1.MyCell.height * 0.8,
                        href    = "content/images/style3/" + Image_Name + ".png",
                        onclick = BoolOptionsEnum.Yes,
                    });
                }
            }


            ChessEngine1.acxadebs_shaxs_an_gardes(ChessEngine1.PlayerColor);
            ChessEngine1.acxadebs_shaxs_an_gardes(ChessEngine1.OppositeColor);
        }
示例#6
0
 public Node(myPoint point)
 {
     location      = point;
     data          = "";
     function      = "";
     connetNode    = new List <myPoint>();
     wasConnetNode = new List <myPoint>();
 }
    unsafe Program()
    {
        double d1 = 1.0;
        var    T  = new myPoint();

        T.Initialize(10, d1);
        Program.CalcPoint(ref T);
        // T.z = {2,4,6,...}
    }
示例#8
0
 private void drawRectangle(myPoint point, Color col)
 {
     if (point != null)
     {
         if (point.X >= p.X && point.Y >= p.Y)
         {
             g.DrawRectangle(new Pen(col, 2), (point.Y - p.Y) * 75, (point.X - p.X) * 20, 75, 20);
             picbox.Image = img;
         }
     }
 }
示例#9
0
 private void textBox1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Shift & e.KeyCode == Keys.Oemplus)
     {
     }
     else if (e.KeyCode == Keys.Oemplus && selectPoint != null)
     {
         selectPoints = "";
         isExpModing  = true;
         expModPoint  = selectPoint;
     }
 }
示例#10
0
文件: Draw.cs 项目: Sledneva/Segment
 public void PrintAll(float x, myPoint A, myPoint B, myPoint O, Graphics g)
 {
     Point[] points =
     {
         new Point(A.x, A.y),
         new Point(B.x, B.y),
         new Point(O.x, O.y),
     };
     Clear(g);
     g.FillPie(Brushes.Red, rect, 0.0F, x);
     g.FillPolygon(Brushes.White, points);
 }
示例#11
0
 private void Txb_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
 {
     if (e.KeyCode == Keys.Oemplus && selectPoint != null)
     {
         selectPoints = "";
         isExpModing  = true;
         expModPoint  = selectPoint;
     }
     if (e.KeyCode == Keys.Enter)
     {
         picbox.Focus();
     }
     drawRectangle(selectPoint, Color.Black);
 }
示例#12
0
        private void drawPic()
        {
            img = new Bitmap(picbox.Width, picbox.Height);
            g   = Graphics.FromImage(img);
            g.Clear(Color.White);

            Pen   pen = new Pen(System.Drawing.ColorTranslator.FromHtml("#D4D4D4"), 1);
            Point p1  = new Point(75, 0);
            Point p2  = new Point(75, picbox.Height);

            for (int i = 0; i < colButton.Count; ++i)
            {
                g.DrawLine(pen, p1, p2);
                p1.X += 75;
                p2.X  = p1.X;
            }
            p1.X = 0; p1.Y = 20;
            p2.X = picbox.Width; p2.Y = 20;
            for (int i = 0; i < rowButton.Count; ++i)
            {
                g.DrawLine(pen, p1, p2);
                p1.Y += 20;
                p2.Y  = p1.Y;
            }
            for (int i = 0; i < rowButton.Count; ++i)
            {
                for (int j = 0; j < colButton.Count; ++j)
                {
                    myPoint tempPoint = new myPoint(p.X + i, p.Y + j);
                    if (Node.dirData.ContainsKey(tempPoint))
                    {
                        Font  font  = new Font("Consolas", 10);
                        Brush brush = Brushes.Black;
                        {
                            if (Node.dirData[tempPoint].data.Length > 5)
                            {
                                g.DrawString(Node.dirData[tempPoint].data.Substring(0, 5) + "...", font, brush, j * 75, i * 20);
                            }
                            else
                            {
                                g.DrawString(Node.dirData[tempPoint].data, font, brush, j * 75, i * 20);
                            }
                        }
                    }
                }
            }
            picbox.Image = img;
        }
示例#13
0
        private void Txb_Leave(object sender, EventArgs e)
        {
            var txb = sender as TextBox;

            if (!isExpModing)
            {
                myPoint point = new myPoint(p.X + ((Point)txb.Tag).X, p.Y + ((Point)txb.Tag).Y);
                if (!Node.dirData.ContainsKey(point))
                {
                    Node.dirData[point] = new Node(point);
                }
                Node.dirData[point].write(txb.Text.Trim());
                drawPic();
            }
            txb.Dispose();
        }
示例#14
0
        private void button3_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "csv文件(*.csv) | *.csv";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                FileStream   fs = new FileStream(ofd.FileName, FileMode.OpenOrCreate);
                StreamReader sr = new StreamReader(fs);

                Node.dirData.Clear();
                string helper = sr.ReadLine();

                int r = 0, c = 0;
                while (helper != null)
                {
                    var nums = helper.Split(',');
                    c = 0;
                    while (c < nums.Count())
                    {
                        if (nums[c] != "")
                        {
                            myPoint mp = new myPoint(r, c);
                            Node.dirData[mp] = new Node(mp);
                            Node.dirData[mp].write(nums[c]);
                        }
                        c++;
                    }
                    helper = sr.ReadLine();
                    r++;
                }
                drawPic();
                sr.Close();
                fs.Close();
            }

            isExpModing   = false;
            expModPoint   = null;
            selectPoint   = null;
            selectPoints  = "";
            textBox1.Text = "";
        }
示例#15
0
    int[] giveMeAColumnPosition()
    {
        myPoint[] columnPositions = new myPoint[rows];
        int[]     indexObjects    = new int[rows];

        int randomColumn = Random.Range(0, rows);

        for (var i = 0; i < rows; i++)
        {
            // Debug.Log(i);
            columnPositions[i].y = i;
            columnPositions[i].x = randomColumn;


            int index = getNumOfTile(columnPositions[i].x, columnPositions[i].y);
            indexObjects[i] = index;
        }

        return(indexObjects);
    }
示例#16
0
            /// <summary>
            /// 解析表达式,构建关系表
            /// </summary>
            /// <param name="sourceString">带待解析的字符串</param>
            /// <returns>读取数字后的表达式</returns>
            private string analysisText(string sourceString)
            {
                Regex reg = new Regex(@"R(\d+)C(\d+);");
                var   mat = reg.Matches(function);

                List <myPoint> checkLoop = new List <myPoint>();

                foreach (Match item in mat)
                {
                    string t = item.Groups[0].Value;
                    int    x = int.Parse(item.Groups[1].Value);
                    int    y = int.Parse(item.Groups[2].Value);
                    //与数据点建立连接
                    myPoint p = new myPoint(x, y);
                    if (!dirData.ContainsKey(p))
                    {
                        dirData[p]      = new Node(p);
                        dirData[p].data = "0";
                    }
                    if (!dirData[p].wasConnetNode.Contains(location))
                    {
                        dirData[p].wasConnetNode.Add(location);
                    }
                    checkLoop.Add(p);
                    sourceString = Regex.Replace(sourceString, t, dirData[p].data);
                }

                var repeatList = checkLoop.Intersect(wasConnetNode).ToList();

                connetNode = checkLoop;

                if (!checkCircleHelper(ref wasConnetNode, ref checkLoop))
                {
                    throw new Exception("存在循环引用");
                }

                return(sourceString);
            }
示例#17
0
        private void generateTextBox(myPoint loc)
        {
            if (loc.X >= p.X && loc.Y >= p.Y && p.X + rowButton.Count - 1 > selectPoint.X + 1)
            {
                #region 生成文本框
                TextBox txb = new TextBox();
                //使其坐标变为整数(取左上角)
                int x = (loc.X - p.X) * 20;
                int y = (loc.Y - p.Y) * 75;
                txb.Location = new Point(picbox.Location.X + y, picbox.Location.Y + x);
                txb.Size     = new Size(75, 20);
                pan.Controls.Add(txb);
                txb.BringToFront();
                txb.Focus();
                #endregion

                //记录此时文本框的信息
                int m  = x / 20;
                int n  = y / 75;
                var tp = new myPoint(p.X + m, p.Y + n);
                if (Node.dirData.ContainsKey(tp))
                {
                    if (Node.dirData[tp].function != "")
                    {
                        txb.Text = "=" + Node.dirData[tp].function;
                    }
                    else
                    {
                        txb.Text = Node.dirData[tp].data;
                    }
                }
                txb.Tag             = new Point((int)rowButton[m].Tag, (int)colButton[n].Tag);
                txb.Leave          += Txb_Leave;
                txb.PreviewKeyDown += Txb_PreviewKeyDown;
                txb.TextChanged    += Txb_TextChanged;
            }
        }
示例#18
0
        // Check for a Derp's Circle-Cast across the field
        // This will work like a BFS, starting from the initial position
        // then check all 4 corners around the position to build on the bfs
        public bool CheckFieldCollision(Derp d, myVector v, out double t, out myLineSegment col)
        {
            // initial optimistic setup that there will not be a collision
            bool ret = false;
            t = 1.0;
            col = null;

            // calculate starting point
            int startX = (int)(d.x / BLOCK_WIDTH);
            int startY = (int)(d.y / BLOCK_HEIGHT);

            // Unit Vector in desired direction
            myVector vUnit = new myVector(v.x, v.y);
            vUnit.toUnit();

            // set up the bfs
            Queue<SimpleNode> q = new Queue<SimpleNode>();
            bool[,] vis = new bool[height+1, width+1];

            q.Enqueue(new SimpleNode(startX, startY, 0));
            vis[startY, startX] = true;

            // Create the 4 line segments so we don't have to do quiiite as much object creation in this loop
            myLineSegment[] segs = new myLineSegment[4];
            for (int i = 0; i < 4; ++i)
                segs[i] = new myLineSegment(null, null);

            // BFS
            int[] dx = { 0, 1, 0, -1 };
            int[] dy = { -1, 0, 1, 0 };
            int cur_step = 0;
            while (q.Count > 0)
            {
                SimpleNode cur = q.Dequeue();

                // end early if we had a hit already in a previous step
                if (ret && cur_step != cur.step)
                    break;

                // checking 4 nodes around us
                myPoint p1 = new myPoint(cur.x * BLOCK_WIDTH, cur.y * BLOCK_HEIGHT);
                myPoint p2 = new myPoint((cur.x + 1) * BLOCK_WIDTH, cur.y * BLOCK_HEIGHT);
                myPoint p3 = new myPoint((cur.x + 1) * BLOCK_WIDTH, (cur.y + 1) * BLOCK_HEIGHT);
                myPoint p4 = new myPoint(cur.x * BLOCK_WIDTH, (cur.y + 1) * BLOCK_HEIGHT);
                segs[0].Update(p1, p2);
                segs[1].Update(p2, p3);
                segs[2].Update(p4, p3);
                segs[3].Update(p1, p4);

                for (int i = 0; i < 4; ++i)
                {
                    int nx = cur.x + dx[i];
                    int ny = cur.y + dy[i];

                    if (nx < 0 || nx > width || ny < 0 || ny >= height || vis[ny, nx])
                        continue;

                    double possible_t;
                    if (Geometry.DerpLineSegmentCast(d, v, segs[i], out possible_t))
                    {
                        // We have a hit! If the next zone is safe to move in, then continue the bfs
                        if (gameGrid[ny, nx] != '0')
                        {
                            q.Enqueue(new SimpleNode(nx, ny, cur.step + 1));
                            vis[ny, nx] = true;
                        }
                        // We hit an unnavigable space. Stop the BFS, this is as far as we go
                        else
                        {
                            ret = true;

                            if (Math.Abs(possible_t - t) < 1e-5 && col != null)
                            {
                                // break ties by taking the furthest behind the direction we wish to go
                                // Calculate the center point on the wall, and get the dot product of the vector to that point.
                                // The most negative value is the furthest behind
                                myPoint segMidPoint1 = new myPoint((segs[i].p1.x + segs[i].p2.x) / 2.0, (segs[i].p1.y + segs[i].p2.y) / 2.0);
                                myVector toMidPoint1 = new myVector(segMidPoint1.x - d.x, segMidPoint1.y - d.y);

                                myPoint segMidPoint2 = new myPoint((col.p1.x + col.p2.x) / 2.0, (col.p1.y + col.p2.y) / 2.0);
                                myVector toMidPoint2 = new myVector(segMidPoint2.x - d.x, segMidPoint2.y - d.y);

                                if (vUnit.dot(toMidPoint1) < vUnit.dot(toMidPoint2))
                                {
                                    t = possible_t;
                                    col = new myLineSegment(segs[i].p1.x, segs[i].p1.y, segs[i].p2.x, segs[i].p2.y); // careful... memory bugs
                                }
                            }
                            else if (possible_t < t)
                            {
                                t = possible_t;
                                col = new myLineSegment(segs[i].p1.x, segs[i].p1.y, segs[i].p2.x, segs[i].p2.y); // careful... memory bugs
                            }
                        }
                    }
                }

                // if we are a special diagonal case, then check the cross hit as well
                myLineSegment diag = null;

                char c = gameGrid[cur.y, cur.x];
                if (c == '1' || c == '3')
                    diag = new myLineSegment(p2, p4);

                if (c == '2' || c == '4')
                    diag = new myLineSegment(p1, p3);

                if (diag != null)
                {
                    double possible_t;
                    if (Geometry.DerpLineSegmentCast(d, v, diag, out possible_t))
                    {
                        ret = true;

                        if (Math.Abs(possible_t - t) < 1e-5 && col != null)
                        {
                            // break ties by taking the furthest behind the direction we wish to go
                            // Calculate the center point on the wall, and get the dot product of the vector to that point.
                            // The most negative value is the furthest behind
                            myPoint segMidPoint1 = new myPoint((diag.p1.x + diag.p2.x) / 2.0, (diag.p1.y + diag.p2.y) / 2.0);
                            myVector toMidPoint1 = new myVector(segMidPoint1.x - d.x, segMidPoint1.y - d.y);

                            myPoint segMidPoint2 = new myPoint((col.p1.x + col.p2.x) / 2.0, (col.p1.y + col.p2.y) / 2.0);
                            myVector toMidPoint2 = new myVector(segMidPoint2.x - d.x, segMidPoint2.y - d.y);

                            if (vUnit.dot(toMidPoint1) < vUnit.dot(toMidPoint2))
                            {
                                t = possible_t;
                                col = new myLineSegment(diag.p1.x, diag.p1.y, diag.p2.x, diag.p2.y); // careful... memory bugs
                            }
                        }
                        else if (possible_t < t)
                        {
                            t = possible_t;
                            col = new myLineSegment(diag.p1.x,diag.p1.y, diag.p2.x, diag.p2.y); // careful... memory bugs
                        }
                    }
                }

                cur_step = cur.step;
            }

            return ret;
        }
示例#19
0
        public void paint_shape()
        {
            myPoint MyPoint = new myPoint();

            int i = 0;

            foreach (string item in ChessEngine1.Board_Array_Letters)
            {
                texts_list.Add(new text()
                {
                    x                 = i * ChessEngine1.MyCell.width + ChessEngine1.MyCell.width * 0.9,
                    y                 = ChessEngine1.MyCell.height * 0.3,
                    content           = item,
                    dominant_baseline = "middle",
                });

                texts_list.Add(new text()
                {
                    x                 = i * ChessEngine1.MyCell.width + ChessEngine1.MyCell.width * 0.9,
                    y                 = ChessEngine1.compSettings.CompHeight - ChessEngine1.MyCell.height * 0.25,
                    content           = item,
                    dominant_baseline = "middle",
                });



                int k = 8 - i;

                texts_list.Add(new text()
                {
                    x           = ChessEngine1.MyCell.width * 0.25,
                    y           = i * ChessEngine1.MyCell.height + ChessEngine1.MyCell.height * 1.1,
                    content     = k.ToString(),
                    text_anchor = "middle",
                });


                texts_list.Add(new text()
                {
                    x           = ChessEngine1.compSettings.CompWidth - ChessEngine1.MyCell.width * 0.25,
                    y           = i * ChessEngine1.MyCell.height + ChessEngine1.MyCell.height * 1.1,
                    content     = k.ToString(),
                    text_anchor = "middle",
                });

                i++;
            }

            int row_index    = 0;
            int column_index = 0;

            string tmp_color = string.Empty;



            rects_list.Add(new rect
            {
                x            = ChessEngine1.MyCell.width / 2,
                y            = ChessEngine1.MyCell.height / 2,
                width        = ChessEngine1.compSettings.CompWidth - ChessEngine1.MyCell.width,
                height       = ChessEngine1.compSettings.CompHeight - ChessEngine1.MyCell.height,
                stroke       = ChessEngine1.MyCell.black_color,
                stroke_width = ChessEngine1.MylineWidths.dafis_charcho,
            });

            for (int index = 0; index < ChessEngine1.Board_Array.Length; index++)
            {
                if (index > 7)
                {
                    column_index = (index) % 8;
                    row_index    = (index - column_index) / 8;
                }
                else
                {
                    column_index = index;
                    row_index    = 0;
                }

                MyPoint.X = ChessEngine1.MyCell.width * column_index;
                MyPoint.Y = ChessEngine1.MyCell.height * row_index;


                if (MyFunctions.Get_Cell_Color_By_Index(index))
                {
                    tmp_color = ChessEngine1.MyCell.black_color;
                }
                else
                {
                    tmp_color = ChessEngine1.MyCell.white_color;
                }

                rects_list.Add(new rect
                {
                    x      = MyPoint.X + ChessEngine1.MyCell.width / 2,
                    y      = MyPoint.Y + ChessEngine1.MyCell.height / 2,
                    width  = ChessEngine1.MyCell.width,
                    height = ChessEngine1.MyCell.height,
                    fill   = tmp_color,
                });
            }
        }
示例#20
0
        private void Picbox_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.Oemplus:
            {
                if (!isExpModing)
                {
                    if (selectPoint != null)
                    {
                        selectPoints  = "";
                        isExpModing   = true;
                        expModPoint   = selectPoint;
                        textBox1.Text = "=";
                    }
                }
                break;
            }

            case Keys.Enter:
            {
                if (selectPoint != null)
                {
                    generateTextBox(selectPoint);
                }
                if (isExpModing)
                {
                    isExpModing = false;
                }
                break;
            }

            case Keys.Up:
            {
                if (p.X < selectPoint.X)
                {
                    selectPoint.X--;
                }
                else
                {
                    if (vsb.Value > 0)
                    {
                        vsb.Value--;
                        selectPoint.X--;
                        picbox.Focus();
                        p.X = vsb.Value;
                        drawPic();
                        for (int i = 0; i < rowButton.Count; ++i)
                        {
                            rowButton[i].Text = "R" + (i + vsb.Value + 1);
                        }
                    }
                }
                if (Node.dirData.ContainsKey(selectPoint))
                {
                    if (Node.dirData[selectPoint].function != "")
                    {
                        textBox1.Text = "=" + Node.dirData[selectPoint].function;
                    }
                    else
                    {
                        textBox1.Text = Node.dirData[selectPoint].data;
                    }
                }
                else
                {
                    textBox1.Text = "";
                }
                drawPic();
                drawRectangle(selectPoint, Color.Black);
                drawSelectRect(textBox1.Text);
                picbox.Focus();
                break;
            }

            case Keys.Down:
            {
                if (p.X + rowButton.Count - 2 > selectPoint.X + 1)
                {
                    selectPoint.X++;
                }
                else
                {
                    if (vsb.Value < 65535)
                    {
                        vsb.Value++;
                        selectPoint.X++;
                        picbox.Focus();
                        p.X = vsb.Value;
                        for (int i = 0; i < rowButton.Count; ++i)
                        {
                            rowButton[i].Text = "R" + (i + vsb.Value + 1);
                        }
                    }
                }
                if (Node.dirData.ContainsKey(selectPoint))
                {
                    if (Node.dirData[selectPoint].function != "")
                    {
                        textBox1.Text = "=" + Node.dirData[selectPoint].function;
                    }
                    else
                    {
                        textBox1.Text = Node.dirData[selectPoint].data;
                    }
                }
                else
                {
                    textBox1.Text = "";
                }
                drawPic();
                drawRectangle(selectPoint, Color.Black);
                drawSelectRect(textBox1.Text);
                picbox.Focus();
                break;
            }

            case Keys.Left:
            {
                if (p.Y < selectPoint.Y)
                {
                    selectPoint.Y--;
                    picbox.Focus();
                }
                else
                {
                    if (hsb.Value > 0)
                    {
                        hsb.Value--;
                        selectPoint.Y--;
                        picbox.Focus();
                        p.Y = hsb.Value;
                        for (int i = 0; i < colButton.Count; ++i)
                        {
                            colButton[i].Text = "R" + (i + hsb.Value + 1);
                        }
                    }
                }
                if (Node.dirData.ContainsKey(selectPoint))
                {
                    if (Node.dirData[selectPoint].function != "")
                    {
                        textBox1.Text = "=" + Node.dirData[selectPoint].function;
                    }
                    else
                    {
                        textBox1.Text = Node.dirData[selectPoint].data;
                    }
                }
                else
                {
                    textBox1.Text = "";
                }
                drawPic();
                drawRectangle(selectPoint, Color.Black);
                drawSelectRect(textBox1.Text);
                picbox.Focus();
                break;
            }

            case Keys.Right:
            {
                if (p.Y + colButton.Count > selectPoint.Y + 2)
                {
                    selectPoint.Y++;
                }
                else
                {
                    if (hsb.Value < 256)
                    {
                        hsb.Value++;
                        selectPoint.Y++;
                        picbox.Focus();
                        p.Y = hsb.Value;
                        for (int i = 0; i < colButton.Count; ++i)
                        {
                            colButton[i].Text = "R" + (i + hsb.Value + 1);
                        }
                    }
                }
                if (Node.dirData.ContainsKey(selectPoint))
                {
                    if (Node.dirData[selectPoint].function != "")
                    {
                        textBox1.Text = "=" + Node.dirData[selectPoint].function;
                    }
                    else
                    {
                        textBox1.Text = Node.dirData[selectPoint].data;
                    }
                }
                else
                {
                    textBox1.Text = "";
                }
                drawPic();
                drawRectangle(selectPoint, Color.Black);
                drawSelectRect(textBox1.Text);
                picbox.Focus();
                break;
            }
            }
        }
示例#21
0
        private void read()
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "txt文件(*.txt) | *.txt";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                FileStream   fs   = new FileStream(ofd.FileName, FileMode.OpenOrCreate);
                StreamReader sr   = new StreamReader(fs);
                string       data = sr.ReadToEnd();

                string result = GZipDecompressString(data);

                MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(result));
                stream.Position = 0;
                sr = new StreamReader(stream);
                Node.dirData.Clear();
                string helper = sr.ReadLine();
                Regex  reg    = new Regex(@"R(\d+)C(\d+);");

                while (helper != null)
                {
                    var     info  = split(helper);
                    var     match = reg.Match(info[1]);
                    int     x     = int.Parse(match.Groups[1].Value);
                    int     y     = int.Parse(match.Groups[2].Value);
                    myPoint p     = new myPoint(x, y);
                    Node    n     = new Node(p);
                    n.data     = info[4];
                    n.function = info[0];
                    n.location = p;
                    var mat = reg.Matches(info[2]);
                    foreach (Match item in mat)
                    {
                        x = int.Parse(item.Groups[1].Value);
                        y = int.Parse(item.Groups[2].Value);
                        n.connetNode.Add(new myPoint(x, y));
                    }
                    mat = reg.Matches(info[3]);
                    foreach (Match item in mat)
                    {
                        x = int.Parse(item.Groups[1].Value);
                        y = int.Parse(item.Groups[2].Value);
                        n.wasConnetNode.Add(new myPoint(x, y));
                    }
                    Node.dirData[p] = n;
                    helper          = sr.ReadLine();
                }
                drawPic();

                sr.Close();
                fs.Close();

                stream.Close();
                isExpModing   = false;
                expModPoint   = null;
                selectPoint   = null;
                selectPoints  = "";
                textBox1.Text = "";

                MessageBox.Show("读取成功");
            }
        }
 public unsafe static extern void CalcPoint(ref myPoint t);