示例#1
0
        private void Drawpic(DingFan DF_flag, DingFan DF_flag2, DingFan DF_flagc, DingFan DF_flagd, STATE state, STATE state2, STATE state_1, STATE state_2)
        {
            initial();
            if (bmp != null)
            {
                bmp.Dispose();
            }
            bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);
            Graphics g = Graphics.FromImage(bmp);

            g.Clear(Color.Black);
            Drawpic_sub(g, DF_flag, state, linea);
            Drawpic_sub(g, DF_flag2, state2, lineb);
            Drawpic_sub(g, DF_flagc, state_1, linec);
            Drawpic_sub(g, DF_flagd, state_2, lined);
            g.DrawLine(p_blue, new Point(a[6].X - 4, a[6].Y - 4), new Point(a[6].X + 4, a[6].Y + 2));
            switch (fangwei)
            {
            case Fangwei.左:
                //g.DrawString(ID_down, new Font("宋体", 8, FontStyle.Bold), new SolidBrush(Color.White), new Point(a[2].X -6, a[2].Y));
                //g.DrawString(ID_up, new Font("宋体", 8, FontStyle.Bold), new SolidBrush(Color.White), new Point(b[2].X-6 , b[2].Y-10));
                break;

            case Fangwei.右:
                bmp.RotateFlip(RotateFlipType.Rotate180FlipY);
                //g.DrawString(ID_down, new Font("宋体", 8, FontStyle.Bold), new SolidBrush(Color.White), new Point(this.Width - a[2].X , a[2].Y));
                //g.DrawString(ID_up, new Font("宋体", 8, FontStyle.Bold), new SolidBrush(Color.White), new Point(this.Width - b[2].X , b[2].Y-10));
                break;
            }
            g.Save();
            pictureBox1.Image = bmp;
        }
示例#2
0
        private void 道岔反位ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DF_flag = DingFan.反位;
            wparam  = new IntPtr(Convert.ToInt32(ID));
            pwaram  = new IntPtr(2);
            //Send_Message.sendmessage(handle, Send_Message.Message_DC1, wparam, pwaram);
            Drawpic(DF_flag, state);

            //事件部分
            testFlag1 = false;
            CustomEventArgs eArgs = new CustomEventArgs(testFlag1);

            OnCustom(eArgs);
        }
        private void 道岔反位ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DF_flag_up   = DingFan.反位;
            DF_flag_down = DingFan.反位;
            wparam       = new IntPtr(Convert.ToInt32(ID_up + "0" + ID_down));
            pwaram       = new IntPtr(2);
            //Send_Message.sendmessage(handle, Send_Message.Message_DC2, wparam, pwaram);
            Drawpic(DF_flag_up, DF_flag_down, state_up, state_down);

            //与button关联函数 事件部分
            testFlag1 = false;
            CustomEventArgs eArgs = new CustomEventArgs(testFlag1);

            OnCustom(eArgs);
        }
示例#4
0
        private void Drawpic(DingFan flag, STATE st)
        {
            Point p1, p2;

            initial();
            if (bmp != null)
            {
                bmp.Dispose();
            }
            bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);
            Graphics g = Graphics.FromImage(bmp);

            g.Clear(Color.Black);
            foreach (myLine m in line)
            {
                if (m.key == 2)
                {
                    if (DF_flag == DingFan.定位)
                    {
                        m.enable = true;
                    }
                    else if (DF_flag == DingFan.反位)
                    {
                        m.enable = false;
                    }
                }
                else if (m.key == 4)
                {
                    if (DF_flag == DingFan.定位)
                    {
                        m.enable = false;
                    }
                    else if (DF_flag == DingFan.反位)
                    {
                        m.enable = true;
                    }
                }
                m.draw(g, p_blue);
            }
            if (DF_flag == DingFan.定位)
            {
                foreach (myLine m in line)
                {
                    if (m.key == 1 || m.key == 2 || m.key == 3)
                    {
                        switch (state)
                        {
                        case STATE.锁闭:
                            m.draw(g, p_white);
                            break;

                        case STATE.占用:
                            m.draw(g, p_red);
                            break;
                        }
                    }
                }
            }
            else
            {
                foreach (myLine m in line)
                {
                    if (m.key == 1 || m.key == 4 || m.key == 5 || m.key == 6)
                    {
                        switch (state)
                        {
                        case STATE.锁闭:
                            m.draw(g, p_white);
                            break;

                        case STATE.占用:
                            m.draw(g, p_red);
                            break;
                        }
                    }
                }
            }
            switch (fangwei)
            {
            case Fangwei.左上:
                //g.DrawString(ID, new Font("宋体", 8, FontStyle.Bold), new SolidBrush(Color.White), new Point(a[2].X-5, a[2].Y - 12));
                p1 = new Point(0, pictureBox1.Height - 9);
                p2 = new Point(0, pictureBox1.Height);
                //   g.DrawLine(p_jyj_white, p1, p2);
                break;

            case Fangwei.左下:
                bmp.RotateFlip(RotateFlipType.Rotate180FlipX);
                //g.DrawString(ID, new Font("宋体", 8, FontStyle.Bold), new SolidBrush(Color.White), new Point(a[2].X-5, this.Height-a[2].Y+6));
                p1 = new Point(0, 0);
                p2 = new Point(0, 9);
                //  g.DrawLine(p_jyj_white, p1, p2);
                break;

            case Fangwei.右上:
                bmp.RotateFlip(RotateFlipType.Rotate180FlipY);
                //g.DrawString(ID, new Font("宋体", 8, FontStyle.Bold), new SolidBrush(Color.White), new Point(this.Width-a[2].X-4, a[2].Y - 12));
                p1 = new Point(pictureBox1.Width - 1, pictureBox1.Height - 9);
                p2 = new Point(pictureBox1.Width - 1, pictureBox1.Height);
                //    g.DrawLine(p_jyj_white, p1, p2);
                break;

            case Fangwei.右下:
                bmp.RotateFlip(RotateFlipType.Rotate180FlipY);
                bmp.RotateFlip(RotateFlipType.Rotate180FlipX);
                //g.DrawString(ID, new Font("宋体", 8, FontStyle.Bold), new SolidBrush(Color.White), new Point(this.Width - a[2].X-4, this.Height - a[2].Y + 6));
                p1 = new Point(pictureBox1.Width - 1, 0);
                p2 = new Point(pictureBox1.Width - 1, 9);
                //  g.DrawLine(p_jyj_white, p1, p2);
                break;
            }
            g.Save();
            pictureBox1.Image = bmp;
        }
示例#5
0
        private void Drawpic_sub(Graphics g, DingFan DF_flag, STATE state, List <myLine> line)
        {
            foreach (myLine m in line)
            {
                if (m.key == 2)
                {
                    if (DF_flag == DingFan.定位)
                    {
                        m.enable = true;
                    }
                    else if (DF_flag == DingFan.反位)
                    {
                        m.enable = false;
                    }
                }
                else if (m.key == 4)
                {
                    if (DF_flag == DingFan.定位)
                    {
                        m.enable = false;
                    }
                    else if (DF_flag == DingFan.反位)
                    {
                        m.enable = true;
                    }
                }
                m.draw(g, p_blue);
            }
            if (DF_flag == DingFan.定位)
            {
                foreach (myLine m in line)
                {
                    if (m.key == 1 || m.key == 2 || m.key == 3)
                    {
                        switch (state)
                        {
                        case STATE.锁闭:
                            m.draw(g, p_white);
                            break;

                        case STATE.占用:
                            m.draw(g, p_red);
                            break;
                        }
                    }
                }
            }
            else
            {
                foreach (myLine m in line)
                {
                    if (m.key == 1 || m.key == 4 || m.key == 5)
                    {
                        switch (state)
                        {
                        case STATE.锁闭:
                            m.draw(g, p_white);
                            break;

                        case STATE.占用:
                            m.draw(g, p_red);
                            break;
                        }
                    }
                }
            }
        }