Ejemplo n.º 1
0
        private void DrawLinePoint(ushort data)
        {
            Point DrawPoint = ExtentionMethodss.FromUInt(data);

            DrawPoint.X = DrawPoint.X + 4;
            DrawPoint.Y = GraphPictureBox1.Height - DrawPoint.Y;

            //DrawPoint.X = (int)((float)DrawPoint.X).Map(DrawInput, DrawX);
            //DrawPoint.Y = (int)((float)DrawPoint.Y).Map(DrawInput, DrawY);

            if (LinePointValid)
            {
                if (DrawColor == Color.Black)
                {
                    PersistentDrawing.Delete(new Line(LinePoint, DrawPoint, DrawColor, DrawPenSize));
                }
                else
                {
                    PersistentDrawing.Add(new Line(LinePoint, DrawPoint, DrawColor, DrawPenSize));
                }

                GraphPictureBox1.Invalidate();
                LinePoint = DrawPoint;
            }
            else
            {
                LinePoint      = DrawPoint;
                LinePointValid = true;
            }
        }
Ejemplo n.º 2
0
        private void DrawPersitentLine(Int64 MyLine)
        {
            String hexdata = "";
            int    xs      = 0;
            int    ys      = 0;
            int    xe      = 0;
            int    ye      = 0;

            hexdata = Convert.ToUInt32(MyLine).ToString("X8");
            xs      = Convert.ToInt32(Convert.ToByte(Convert.ToInt16(hexdata.Substring(0, 2), 16))) + 4;
            ys      = Convert.ToInt32(Convert.ToByte(Convert.ToInt16(hexdata.Substring(2, 2), 16)));
            xe      = Convert.ToInt32(Convert.ToByte(Convert.ToInt16(hexdata.Substring(4, 2), 16))) + 4;
            ye      = Convert.ToInt32(Convert.ToByte(Convert.ToInt16(hexdata.Substring(6, 2), 16)));
            ys      = GraphPictureBox1.Height - ys;
            ye      = GraphPictureBox1.Height - ye;

            if (DrawColor == Color.Black)
            {
                PersistentDrawing.Delete(new Line(xs, ys, xe, ye, DrawColor, DrawPenSize));
            }
            else
            {
                PersistentDrawing.Add(new Line(xs, ys, xe, ye, DrawColor, DrawPenSize));
            }
            GraphPictureBox1.Invalidate();
        }
Ejemplo n.º 3
0
 private void DrawCaption(string data, int CaptionId)
 {
     if (DrawTextColor == Color.Black)
     {
         if (CaptionId == 1)
         {
             PersistentDrawing.Delete(new Text(new Point(10, 5), data, DrawTextColor, 8));
         }
         if (CaptionId == 2)
         {
             PersistentDrawing.Delete(new Text(new Point(10, 202), data, DrawTextColor, 8));
         }
     }
     else
     {
         if (CaptionId == 1)
         {
             PersistentDrawing.Add(new Text(new Point(10, 5), data, DrawTextColor, 8));
         }
         if (CaptionId == 2)
         {
             PersistentDrawing.Add(new Text(new Point(10, 202), data, DrawTextColor, 8));
         }
     }
     GraphPictureBox1.Invalidate();
 }
Ejemplo n.º 4
0
        private void DrawPixel(ushort data)
        {
            Point DrawPoint = ExtentionMethodss.FromUInt(data);

            DrawPoint.X = DrawPoint.X + 4;
            DrawPoint.Y = GraphPictureBox1.Height - DrawPoint.Y;

            if (DrawColor == Color.Black)
            {
                PersistentDrawing.Delete(new Pixel(DrawPoint.X, DrawPoint.Y, DrawPointColor));
            }
            else
            {
                PersistentDrawing.Add(new Pixel(DrawPoint.X, DrawPoint.Y, DrawPointColor));
            }

            GraphPictureBox1.Invalidate();
        }
Ejemplo n.º 5
0
        private void Drawtext(string data)
        {
            Color col = VirtualPanelForm.String2Color(data);

            if (!col.IsEmpty)
            {
                DrawTextColor = col; //
            }
            else
            {
                if (DrawTextColor == Color.Black)
                {
                    PersistentDrawing.Delete(new Text(DrawtextPoint, data, DrawTextColor, 8));
                }
                else
                {
                    PersistentDrawing.Add(new Text(DrawtextPoint, data, DrawTextColor, 8));
                }
                GraphPictureBox1.Invalidate();
            }
        }
Ejemplo n.º 6
0
        private void Arduinoport_MessageReceived(object sender, MessageEventArgs <object> mse)
        {
            ChannelId id = (ChannelId)mse.ChannelID;

            Tuple <ChannelId, Control> control = pannelControlList.Find(t => t.Item1 == id);

            if (!Hold)
            {
                if (control != null)
                {
                    if (control.Item2 is Button)
                    {
                        VirtualPanelForm.SetButtonAppearance((Button)control.Item2, mse);
                    }
                    if (control.Item2 is Label)
                    {
                        SetLabelAppearance((Label)control.Item2, mse);
                    }
                }

                if ((ChannelId)mse.ChannelID == ChannelId.Graph && mse.Type == vp_type.vp_string)
                {
                    if ((string)mse.Data == "$CLEAR")
                    {
                        PersistentDrawing.Clear(); LinePointValid = false;
                    }
                }
                //               if ((ChannelId)mse.ChannelID == ChannelId.GraphPen && mse.Type == vp_type.vp_string) SetDrawPointPen((string)mse.Data);
                if ((ChannelId)mse.ChannelID == ChannelId.GraphDrawLine && mse.Type == vp_type.vp_ulong)
                {
                    DrawPersitentLine((Int64)mse.Data);
                }
                if ((ChannelId)mse.ChannelID == ChannelId.GraphDrawLine && mse.Type == vp_type.vp_string)
                {
                    SetDrawPen((string)mse.Data);
                }
                if ((ChannelId)mse.ChannelID == ChannelId.GraphDrawLine && mse.Type == vp_type.vp_uint)
                {
                    DrawLinePoint((ushort)(int)mse.Data);
                }
                if ((ChannelId)mse.ChannelID == ChannelId.GraphDrawLine && mse.Type == vp_type.vp_void)
                {
                    LinePointValid = false;
                }
                if ((ChannelId)mse.ChannelID == ChannelId.GraphDrawPixel && mse.Type == vp_type.vp_uint)
                {
                    DrawPixel((ushort)(int)mse.Data);
                }
                if ((ChannelId)mse.ChannelID == ChannelId.GraphDrawPixel && mse.Type == vp_type.vp_string)
                {
                    SetDrawPointPen((string)mse.Data);
                }
                ;
                if ((ChannelId)mse.ChannelID == ChannelId.GraphText && mse.Type == vp_type.vp_uint)
                {
                    DrawTextPos((Int32)mse.Data);
                }
                if ((ChannelId)mse.ChannelID == ChannelId.GraphText && mse.Type == vp_type.vp_string)
                {
                    Drawtext((string)mse.Data);
                }

                if ((ChannelId)mse.ChannelID == ChannelId.GraphGrid && mse.Type == vp_type.vp_boolean)
                {
                    Grid = (bool)mse.Data;
                }
                if ((ChannelId)mse.ChannelID == ChannelId.GraphGrid && mse.Type == vp_type.vp_int)
                {
                    Grid = true; GridCount = (int)mse.Data;
                }

                if ((ChannelId)mse.ChannelID == ChannelId.GraphValue_1 && mse.Type == vp_type.vp_string)
                {
                    SetGraphAttr((string)mse.Data, GraphPlot_1);
                }
                if ((ChannelId)mse.ChannelID == ChannelId.GraphValue_2 && mse.Type == vp_type.vp_string)
                {
                    SetGraphAttr((string)mse.Data, GraphPlot_2);
                }
                if ((ChannelId)mse.ChannelID == ChannelId.GraphValue_3 && mse.Type == vp_type.vp_string)
                {
                    SetGraphAttr((string)mse.Data, GraphPlot_3);
                }
                if ((ChannelId)mse.ChannelID == ChannelId.GraphValue_4 && mse.Type == vp_type.vp_string)
                {
                    SetGraphAttr((string)mse.Data, GraphPlot_4);
                }
                if ((ChannelId)mse.ChannelID == ChannelId.GraphValue_5 && mse.Type == vp_type.vp_string)
                {
                    SetGraphAttr((string)mse.Data, GraphPlot_5);
                }

                if ((ChannelId)mse.ChannelID == ChannelId.GraphValueCount_1 && mse.Type == vp_type.vp_int)
                {
                    GraphPlot_1.SampleCount = (int)mse.Data;
                }
                if ((ChannelId)mse.ChannelID == ChannelId.GraphValueCount_2 && mse.Type == vp_type.vp_int)
                {
                    GraphPlot_2.SampleCount = (int)mse.Data;
                }
                if ((ChannelId)mse.ChannelID == ChannelId.GraphValueCount_3 && mse.Type == vp_type.vp_int)
                {
                    GraphPlot_3.SampleCount = (int)mse.Data;
                }
                if ((ChannelId)mse.ChannelID == ChannelId.GraphValueCount_4 && mse.Type == vp_type.vp_int)
                {
                    GraphPlot_4.SampleCount = (int)mse.Data;
                }
                if ((ChannelId)mse.ChannelID == ChannelId.GraphValueCount_5 && mse.Type == vp_type.vp_int)
                {
                    GraphPlot_5.SampleCount = (int)mse.Data;
                }

                if ((ChannelId)mse.ChannelID == ChannelId.GraphValue_1 && mse.Type == vp_type.vp_byte)
                {
                    GraphValueAdd((int)mse.Data, GraphPlot_1);
                }                                                                                                                                     //Grid = true; removed
                if ((ChannelId)mse.ChannelID == ChannelId.GraphValue_2 && mse.Type == vp_type.vp_byte)
                {
                    GraphValueAdd((int)mse.Data, GraphPlot_2);
                }
                if ((ChannelId)mse.ChannelID == ChannelId.GraphValue_3 && mse.Type == vp_type.vp_byte)
                {
                    GraphValueAdd((int)mse.Data, GraphPlot_3);
                }
                if ((ChannelId)mse.ChannelID == ChannelId.GraphValue_4 && mse.Type == vp_type.vp_byte)
                {
                    GraphValueAdd((int)mse.Data, GraphPlot_4);
                }
                if ((ChannelId)mse.ChannelID == ChannelId.GraphValue_5 && mse.Type == vp_type.vp_byte)
                {
                    GraphValueAdd((int)mse.Data, GraphPlot_5);
                }

                if ((ChannelId)mse.ChannelID == ChannelId.GraphCaption_1 && mse.Type == vp_type.vp_string)
                {
                    DrawCaption((string)mse.Data, 1);
                }
                if ((ChannelId)mse.ChannelID == ChannelId.GraphCaption_2 && mse.Type == vp_type.vp_string)
                {
                    DrawCaption((string)mse.Data, 2);
                }

                GraphPictureBox1.Invalidate();
            }
        }