Пример #1
0
        private bool IsInView(ILineText curLine, ILineText preLine, Vector2 actualSize)
        {
            bool changedPosition = false;

            if (Overlap(curLine, preLine))
            {
                curLine.ChangePosition();
                changedPosition = true;
            }

            for (int i = 0; i < 2; i++)
            {
                Vector2 topLeft = curLine.TopLeftPoint, bottomRight = curLine.BottomRightPoint;

                if (topLeft.X > 0 && topLeft.Y > 0 && bottomRight.X < actualSize.X &&
                    bottomRight.Y < actualSize.Y)
                {
                    return(true);
                }

                if (!changedPosition)
                {
                    curLine.ChangePosition();
                }
                else
                {
                    break;
                }
            }

            for (int i = 0; i < 2; i++)
            {
                Vector2 topLeft = curLine.TopLeftPoint, bottomRight = curLine.BottomRightPoint;

                if ((topLeft.X > 0 && topLeft.Y > 0 && topLeft.X < actualSize.X && topLeft.Y < actualSize.Y) ||
                    (bottomRight.X > 0 && bottomRight.Y > 0 &&
                     bottomRight.X < actualSize.X && bottomRight.Y < actualSize.Y))
                {
                    return(true);
                }

                if (!changedPosition)
                {
                    curLine.ChangePosition();
                }
                else
                {
                    break;
                }
            }

            return(false);
        }
Пример #2
0
        public void Draw(CanvasDrawingSession drawingSession, Vector2 actualSize)
        {
            ILineText preLineText = null;

            if (IsInView(xAxisLine, actualSize))
            {
                drawingSession.DrawLine(xAxisLine.Point1, xAxisLine.Point2, color, thickness);
            }

            if (IsInView(yAxisLine, actualSize))
            {
                drawingSession.DrawLine(yAxisLine.Point1, yAxisLine.Point2, color, thickness);
            }

            foreach (HorizontalLineText hlt in yAxisStrokes)
            {
                if (IsInView(hlt, preLineText, actualSize))
                {
                    drawingSession.DrawLine(hlt.Point1, hlt.Point2, color, thickness);
                    drawingSession.DrawText(hlt.ValueText, hlt.ValuePoint, color, hlt.Format);

                    preLineText = hlt;
                }
                else
                {
                    preLineText = null;
                }
            }

            preLineText = null;

            foreach (VerticalLineText vlt in xAxisStrokes)
            {
                if (IsInView(vlt, preLineText, actualSize))
                {
                    drawingSession.DrawLine(vlt.Point1, vlt.Point2, color, thickness);
                    drawingSession.DrawText(vlt.ValueText, vlt.ValuePoint, color, vlt.Format);

                    preLineText = vlt;
                }
                else
                {
                    preLineText = null;
                }
            }
        }
Пример #3
0
        private bool Overlap(ILineText line1, ILineText line2)
        {
            if (line1 == null || line2 == null)
            {
                return(false);
            }

            if (!(IsBetween(line1.TopLeftPoint.X, line1.BottomRightPoint.X, line2.TopLeftPoint.X,
                            line2.BottomRightPoint.X) || Enclose(line1.TopLeftPoint.X, line1.BottomRightPoint.X,
                                                                 line2.TopLeftPoint.X, line2.BottomRightPoint.X)))
            {
                return(false);
            }

            return(IsBetween(line1.TopLeftPoint.Y, line1.BottomRightPoint.Y, line2.TopLeftPoint.Y,
                             line2.BottomRightPoint.Y) || Enclose(line1.TopLeftPoint.Y, line1.BottomRightPoint.Y,
                                                                  line2.TopLeftPoint.Y, line2.BottomRightPoint.Y));
        }
Пример #4
0
 private void RunUser()
 {
     channel = new SocketLineText(socket);
     while (true)
     {
         string data = channel.NextLine();
         if (data == "bye\r\n")
         {
             break;
         }
         data = data.Insert(0, $"{Id}> ");
         Console.Write($"MSG: {data}");
         EchoServer.NET.Program.Broadcast(data);
     }
     active = false;
     // remove ourselves from the ConcurrentBag
     socket.Shutdown(SocketShutdown.Both);
     socket.Close();
 }