public void AddLine(T newObject)
        {
            var newPlayerLine = Instantiate(listLinePrefab, Vector3.zero, Quaternion.identity, contentTransform);

            newPlayerLine.GetComponentInChildren <TextMeshProUGUI>()?.SetText(GetLineText(newObject));

            Objects.Add(newPlayerLine, newObject);

            LineAdded?.Invoke(newPlayerLine);
        }
Esempio n. 2
0
        private void OnLineAdded(TerminalLine terminalLine)
        {
            PrinterLines.Add(terminalLine);

            LineAdded?.Invoke(this, terminalLine);

            if (PrinterLines.Count > maxLinesToBuffer)
            {
                this.Clear();
            }
        }
Esempio n. 3
0
 public override void Write(char value)
 {
     if (value == '\n')
     {
         LineAdded?.Invoke(this, new StringEventArgs(_buffer.ToString()));
         _buffer.Clear();
     }
     if (value > 31)
     {
         _buffer.Append(value);
     }
 }
Esempio n. 4
0
        protected override void OnItemAdded(TGridLine gridLine)
        {
            base.OnItemAdded(gridLine);

            _sortedLines.Add(gridLine);

            SortGridLines();

            LineAdded?.Invoke(this, new EventArgs <TGridLine>(gridLine));

            _model.OnModelChangedInternal();
        }
Esempio n. 5
0
        private void AddLine(TerminalLine terminalLine)
        {
            lock (printerLines)
            {
                printerLines.Add(terminalLine);

                LineAdded?.Invoke(this, terminalLine);

                if (printerLines.Count > maxLinesToBuffer)
                {
                    this.Clear();
                }
            }
        }
Esempio n. 6
0
        private void ReadLog(LogLineType type)
        {
            DateTime time = DateTime.MinValue;

            switch (type)
            {
            case LogLineType.Debug: time = lastDebugTimestamp; break;

            case LogLineType.Error: time = lastErrorTimestamp; break;

            case LogLineType.Notification: time = lastNotificationTimestamp; break;

            case LogLineType.Warning: time = lastWarningTimestamp; break;
            }

            var nodes = Logger.ReadOutputLogXml(type, AppicationName, time);

            if (nodes != null)
            {
                foreach (var node in nodes)
                {
                    var line = Line.FromXmlNode(node);

                    switch (type)
                    {
                    case LogLineType.Debug: lastDebugTimestamp = line.Timestamp; break;

                    case LogLineType.Error: time = lastErrorTimestamp = line.Timestamp; break;

                    case LogLineType.Notification: time = lastNotificationTimestamp = line.Timestamp; break;

                    case LogLineType.Warning: time = lastWarningTimestamp = line.Timestamp; break;
                    }

                    line.Type = type;
                    LineAdded?.Invoke(line);
                }
            }
        }
Esempio n. 7
0
        private void timer_tick(object sender, EventArgs e)
        {
            // Search for Pen / Finger
            Touch        pen     = null;
            Touch        mouse   = null;
            List <Touch> fingers = new List <Touch>();

            foreach (Touch t in pm.Touches.Values)
            {
                if (t.TouchDevice == TouchDevice.Pen && t.Down)
                {
                    pen = t;
                    break;
                }
                if (t.TouchDevice == TouchDevice.Finger)
                {
                    fingers.Add(t);
                }
                if (t.TouchDevice == TouchDevice.Mouse && t.Down)
                {
                    mouse = t;
                }
            }
            if (mouseDown)
            {
                mouse = new Touch((int)mousePos.X, (int)mousePos.Y, Touch.MOUSE_ID, TouchDevice.Mouse, Touch.MAX_PREASSURE, PenFlags.NONE, true);
            }

            // Show / Hide Cursor
            if (pen != null && pen.Down && !cursorHidden)
            {
                this.Cursor  = blankCursor;
                cursorHidden = true;
            }
            else if ((pen == null || !pen.Down) && cursorHidden)
            {
                this.Cursor  = Cursors.Default;
                cursorHidden = false;
            }

            // Screen Objects
            for (int i = 0; i < ScreenObjects.Count; i++)
            {
                if (ScreenObjects[i].Think(fingers, ref pen, ref mouse, this.Width, this.Height))
                {
                    recreateBuffer();
                }
                if (ScreenObjects[i].Close)
                {
                    ScreenObjects[i].Dispose();
                    ScreenObjects.RemoveAt(i--);
                }
            }

            // Eraser
            if (pen != null && (pen.PenFlags & PenFlags.INVERTED) == PenFlags.INVERTED)
            {
                for (int i = 0; i < page.LineCount; i++)
                {
                    if (EraserColor != Color.Transparent && EraserColor != page.GetLine(i).Brush.GetColor())
                    {
                        continue;
                    }
                    PointF[] pts = new PointF[1];
                    pts[0] = new PointF(pen.X, pen.Y);
                    transform.GetInverse().Transform(pts);
                    if (page.GetLine(i).Collision(new LPoint(pts[0].X, pts[0].Y, pen.Pressure / 100)))
                    {
                        gpuRenderer.EditPage();
                        page.RemoveLine(i--);
                        gpuRenderer.EndEditPage();
                        recreateBufferFull();
                        break;
                    }
                }

                pen = null;
            }

            // Select
            if (pen != null && (pen.PenFlags & PenFlags.BARREL) == PenFlags.BARREL)
            {
                if (selections == null)
                {
                    selections = new List <PointF>();
                    lock (selections)
                        selections.Add(new PointF(pen.X, pen.Y));
                }
                else
                {
                    lock (selections)
                        selections.Add(new PointF(pen.X, pen.Y));
                    recreateBuffer();
                }
                pen = null;
            }
            else if (selections != null)
            {
                PointF[] pts = selections.ToArray();
                selections = null;
                transform.GetInverse().Transform(pts);
                Page.SelectArea(pts);
                recreateBufferFull();
                ShowSelectionMenu();
            }

            // Move
            if (fingers.Count == 1 && !LockMove)
            {
                Point fp = new Point(fingers[0].X, fingers[0].Y);
                if (lastMove)
                {
                    int deltaX = fp.X - lastMovePoint.X;
                    int deltaY = fp.Y - lastMovePoint.Y;
                    transTranslateValue.X += deltaX;
                    transTranslateValue.Y += deltaY;
                    if (Math.Abs(transTranslateValue.X) > Configuration.TransformTranslateThreshold ||
                        Math.Abs(transTranslateValue.Y) > Configuration.TransformTranslateThreshold)
                    {
                        transTranslateLocked = false;
                    }

                    if (!transTranslateLocked)
                    {
                        Matrix3x3 mat = Matrix3x3.Translation(deltaX, deltaY);
                        transform *= mat;
                    }
                }
                lastMove      = true;
                lastMovePoint = fp;
                pen           = null;
                if (Configuration.RefreshOnTransform)
                {
                    recreateBufferFull();
                }
                else
                {
                    recreateBuffer();
                }
            }
            else if (lastMove)
            {
                lastMove = false;
                recreateBufferFull();
                transTranslateLocked = true;
                transTranslateValue  = new PointF(0, 0);
            }

            // Transform
            if (fingers.Count == 2 &&
                !(LockMove && LockScale && LockRotate))
            {
                FingerTransform t = new FingerTransform(fingers[0].X, fingers[0].Y, fingers[1].X, fingers[1].Y);
                if (lastTrans)
                {
                    float dd = 1 + (t.Distance - lastTransInfo.Distance) / lastTransInfo.Distance;
                    float dr = t.Rotation - lastTransInfo.Rotation;
                    Point dp = new Point(t.Position.X - lastTransInfo.Position.X,
                                         t.Position.Y - lastTransInfo.Position.Y);

                    transRotationValue += dr;
                    if (Math.Abs(transRotationValue) > Configuration.TransformRotationThreshold)
                    {
                        transRotationLocked = false;
                    }
                    transScaleValue *= dd;
                    float sLim1 = 1 - Configuration.TransformScaleThreshold;
                    float sLim2 = 1 + Configuration.TransformScaleThreshold;
                    if (transScaleValue < sLim1 || transScaleValue > sLim2)
                    {
                        transScaleLocked = false;
                    }
                    transTranslateValue.X += dp.X;
                    transTranslateValue.Y += dp.Y;
                    if (Math.Abs(transTranslateValue.X) > Configuration.TransformTranslateThreshold ||
                        Math.Abs(transTranslateValue.Y) > Configuration.TransformTranslateThreshold)
                    {
                        transTranslateLocked = false;
                    }

                    if (LockMove || transTranslateLocked)
                    {
                        dp = new Point(0, 0);
                    }
                    if (LockScale || transScaleLocked)
                    {
                        dd = 1;
                    }
                    if (LockRotate || transRotationLocked)
                    {
                        dr = 0;
                    }

                    Matrix3x3 mat = new Matrix3x3();
                    mat.TransformTranslate(dp.X, dp.Y);
                    mat.TransformTranslate(-t.Position.X, -t.Position.Y);
                    mat.TransformScale(dd);
                    mat.TransformTranslate(t.Position.X, t.Position.Y);
                    mat.TransformRotateAt(-dr, t.Position.X, t.Position.Y);
                    transform *= mat;
                    if (Configuration.RefreshOnTransform)
                    {
                        recreateBufferFull();
                    }
                    else
                    {
                        recreateBuffer();
                    }
                }
                lastTrans     = true;
                lastTransInfo = t;
            }
            else if (lastTrans)
            {
                lastTrans = false;
                recreateBufferFull();
                transRotationValue   = 0;
                transScaleValue      = 1;
                transRotationLocked  = true;
                transScaleLocked     = true;
                transTranslateLocked = true;
            }

            // Draw
            Touch drawDev = pen | mouse;

            if (line != null)
            {
                if (drawDev != null)
                {
                    float rad;
                    rad = line.CalcRad(drawDev.Pressure, Thicknes);
                    PointF[] p = new PointF[1];
                    p[0] = new PointF(drawDev.X, drawDev.Y);
                    linePoints.Add(p[0]);
                    transform.GetInverse().Transform(p);
                    line.AddPoint(p[0].X, p[0].Y, rad);
                    RecreateBuffer(Util.GetBounds(linePoints.ToArray()).Expand(8));
                }
                else
                {
                    line.CalcSpline();
                    gpuRenderer.EditPage();
                    page.AddLine(line);
                    page.Deselect();
                    gpuRenderer.EndEditPage();
                    //while (gpuRenderer.Drawing) ;
                    //Util.WaitTimeout(gpuRenderer, gpuRenderer.GetType().GetProperty("Drawing"), 500);
                    tmpLine = line;
                    if (line is Forms.TextBox)
                    {
                        var input = new Dialogues.TextBoxInput((Forms.TextBox)line, this);
                        input.Show();
                    }
                    LineAdded?.Invoke(this, line);
                    line       = null;
                    linePoints = null;
                    recreateBufferFull();
                }
            }
            else if (drawDev != null)
            {
                pen?.Trail.Clear();
                PointF[] p = new PointF[1];
                long     pressure;
                p[0]     = new PointF(drawDev.X, drawDev.Y);
                pressure = drawDev.Pressure;
                transform.GetInverse().Transform(p);
                linePoints = new List <PointF>();
                if (InkMode == InkMode.Pen)
                {
                    line       = new Line();
                    line.Brush = Brush;
                    line.AddPoint(p[0].X, p[0].Y, line.CalcRad(pressure, Thicknes));
                }
                else if (InkMode == InkMode.Line)
                {
                    line       = new Forms.LinearLine();
                    line.Brush = Brush;
                    line.AddPoint(p[0].X, p[0].Y, line.CalcRad(pressure, Thicknes));
                }
                else if (InkMode == InkMode.Rect)
                {
                    line       = new Forms.Rect();
                    line.Brush = Brush;
                    line.AddPoint(p[0].X, p[0].Y, line.CalcRad(pressure, Thicknes));
                }
                else if (InkMode == InkMode.Arc)
                {
                    line       = new Forms.Arc();
                    line.Brush = Brush;
                    line.AddPoint(p[0].X, p[0].Y, line.CalcRad(pressure, Thicknes));
                }
                else if (InkMode == InkMode.Arc2)
                {
                    line       = new Forms.Arc2();
                    line.Brush = Brush;
                    line.AddPoint(p[0].X, p[0].Y, line.CalcRad(pressure, Thicknes));
                }
                else if (InkMode == InkMode.Marker)
                {
                    line       = new Forms.Marker();
                    line.Brush = Brush;
                    line.AddPoint(p[0].X, p[0].Y, line.CalcRad(pressure, Thicknes));
                }
                else if (InkMode == InkMode.Text)
                {
                    line       = new Forms.TextBox();
                    line.Brush = Brush;
                    line.AddPoint(p[0].X, p[0].Y, 1);
                }
            }

            // Evaluate Transformation
            if (page != null)
            {
                RectangleF rect       = page.GetTransformedBoundaryBox(transform);
                float      border     = Util.GetGUISize() * 2;
                float      force      = .2f;
                float      constForce = .3f;
                float      minSize    = .3f;
                if (rect.Right < border)
                {
                    transform.TransformTranslate((border - rect.Right) * force + constForce, 0);
                    if (Configuration.RefreshOnTransform)
                    {
                        recreateBufferFull();
                    }
                    else
                    {
                        recreateBuffer();
                    }
                    evaluateTmp = true;
                    fullredraw  = false;
                }
                else if (rect.Bottom < border)
                {
                    transform.TransformTranslate(0, (border - rect.Bottom) * force + constForce);
                    if (Configuration.RefreshOnTransform)
                    {
                        recreateBufferFull();
                    }
                    else
                    {
                        recreateBuffer();
                    }
                    evaluateTmp = true;
                    fullredraw  = false;
                }
                else if (rect.Left > this.Width - border)
                {
                    transform.TransformTranslate((this.Width - border - rect.Left) * force - constForce, 0);
                    if (Configuration.RefreshOnTransform)
                    {
                        recreateBufferFull();
                    }
                    else
                    {
                        recreateBuffer();
                    }
                    evaluateTmp = true;
                    fullredraw  = false;
                }
                else if (rect.Top > this.Height - border)
                {
                    transform.TransformTranslate(0, (this.Height - border - rect.Top) * force - constForce);
                    if (Configuration.RefreshOnTransform)
                    {
                        recreateBufferFull();
                    }
                    else
                    {
                        recreateBuffer();
                    }
                    evaluateTmp = true;
                    fullredraw  = false;
                }
                else if (rect.Width < this.Width * minSize &&
                         rect.Height < this.Height * minSize)
                {
                    float scale1 = rect.Width / (this.Width * minSize);
                    float scale2 = rect.Height / (this.Height * minSize);
                    float scale  = 1 + Math.Max(scale1, scale2) * force / 7;
                    var   center = page.GetTransformedCenter(transform);
                    transform.TransformScaleAt(scale, scale, center.X, center.Y);

                    if (Configuration.RefreshOnTransform)
                    {
                        recreateBufferFull();
                    }
                    else
                    {
                        recreateBuffer();
                    }
                    evaluateTmp = true;
                    fullredraw  = false;
                }
                else if (evaluateTmp)
                {
                    evaluateTmp = false;
                    recreateBufferFull();
                }
            }
        }
Esempio n. 8
0
 /// <summary>
 /// Trace a line, add Name of FrameworkElement
 /// </summary>
 static public void Line(FrameworkElement?frameworkElement, string traceLine)
 {
     LineAdded?.Invoke(frameworkElement, traceLine);
 }