Exemplo n.º 1
0
 private void AddSingleStrokeBasedNote(IdeationUnit strokeBasedIdea)
 {
     try
     {
         StrokeData ideaData = (StrokeData)(strokeBasedIdea.Content);
         List <System.Windows.Point> strokePoints = ideaData.StrokePoints;
         StylusPointCollection       stylusPoints = new StylusPointCollection();
         foreach (System.Windows.Point p in strokePoints)
         {
             StylusPoint stylusP = new StylusPoint(p.X, p.Y);
             stylusPoints.Add(stylusP);
         }
         Stroke newStroke = new Stroke(stylusPoints);
         if (!ideaData.IsErasingStroke)
         {
             newStroke.DrawingAttributes       = DrawingCanvasModeSwitcher.normalDrawingAttribute.Clone();
             newStroke.DrawingAttributes.Color = (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString(ideaData.StrokeColorCode);
         }
         else
         {
             newStroke.DrawingAttributes       = new DrawingAttributes();
             newStroke.DrawingAttributes.Color = System.Windows.Media.Color.FromRgb(0, 0, 0);
             newStroke.DrawingAttributes.Width = newStroke.DrawingAttributes.Height = 30;
         }
         drawingCanvas.Strokes.Add(newStroke);
     }
     catch (Exception ex)
     {
         Utilities.UtilitiesLib.LogError(ex);
     }
 }
Exemplo n.º 2
0
 public StrokeDto(StrokeData strokeData)
 {
     Id    = strokeData.Id;
     Path  = strokeData.Path;
     Brush = strokeData.Color;
     Size  = strokeData.Size;
 }
Exemplo n.º 3
0
        private static StrokeData StrokeToData(Stroke stroke, System.Windows.Size size)
        {
            StrokeData data = new StrokeData();
            string     type = "";

            if (stroke is ArrowStroke)
            {
                type = StrokeTypes.Arrow;
            }
            if (stroke is CircleStroke)
            {
                type = StrokeTypes.Circle;
            }
            if (stroke is StraightStroke)
            {
                type = StrokeTypes.Line;
            }
            if (stroke is RectangleStroke)
            {
                type = StrokeTypes.Rectangle;
            }
            if (stroke is TriangleStroke)
            {
                type = StrokeTypes.Triangle;
            }
            data.Type = type;

            data.Points = StrokeDataEx.ToPoints(stroke.StylusPoints, size);
            data.Atts   = DrawingAttributesDataEx.ToData(stroke.DrawingAttributes);
            data.ID     = StrokeEx.GetID(stroke);

            return(data);
        }
Exemplo n.º 4
0
    void IListenerErg.OnStrokeDataEvent(StrokeDataEvent strokeDataEvent)
    {
        StrokeData stroke = strokeDataEvent.strokeData;

        textWatts.text       = stroke.strokePower + "";
        textStrokeCount.text = stroke.strokeCount + "";
    }
Exemplo n.º 5
0
 public void SetStrokeData(List <StrokeData> strokeDataList)
 {
     fromDisk               = true;
     currentStrokeData      = strokeDataList[0];
     this.strokeDataList    = strokeDataList;
     currentStrokeDataIndex = 0;
     nextPointIndex         = 0;
     pointCount             = ((strokeDataList.Count - 1) * maxPoints) + strokeDataList[strokeDataList.Count - 1].pointCount;
 }
Exemplo n.º 6
0
 public Vector3 NextPoint()
 {
     if (nextPointIndex > maxPoints - 1)
     {
         nextPointIndex = 0;
         currentStrokeDataIndex++;
         currentStrokeData = strokeDataList[currentStrokeDataIndex];
     }
     return(currentStrokeData.points[nextPointIndex++]);
 }
Exemplo n.º 7
0
 public static void AddStroke(List <string> userIds, StrokeData strokeData)
 {
     foreach (string id in userIds)
     {
         if (userConnectionDictionary.ContainsKey(id))
         {
             hubContext.Clients.Client(userConnectionDictionary[id]).AddStroke(strokeData);
         }
     }
 }
Exemplo n.º 8
0
 public static Stroke FromData(StrokeData data, Note note)
 {
     return(new Stroke()
     {
         Color = data.Color,
         Id = data.Id,
         Owner = note,
         Path = data.Path,
         Size = data.Size,
     });
 }
        public override async Task <string> PostMessage(int id, int segmentIndex, StrokeData e)
        {
            PostMessageTS       postM    = new PostMessageTS(id, segmentIndex, e);
            string              payload  = UnityEngine.JsonUtility.ToJson(postM);
            var                 content  = new StringContent(payload, System.Text.Encoding.UTF8, "application/json");
            HttpResponseMessage response = await client.PostAsync(backendAPIAddress + "/user/", content);

            var responseString = await response.Content.ReadAsStringAsync();

            return(responseString);
        }
Exemplo n.º 10
0
        private void drawingCanvas_StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
        {
            try
            {
                sv_MainCanvas.IsHitTestVisible = true;
                Stroke latestStroke = e.Stroke;
                StylusPointCollection strokePoints = latestStroke.StylusPoints;
                if (!DrawingCanvasModeSwitcher.IsInErasingMode() && strokePoints.Count < 10)
                {
                    return;
                }
                List <System.Windows.Point> pathPoints = new List <System.Windows.Point>();
                foreach (StylusPoint stylusP in strokePoints)
                {
                    System.Windows.Point p = new System.Windows.Point();
                    p.X = stylusP.X;
                    p.Y = stylusP.Y;
                    pathPoints.Add(p);
                }

                /*if (Utilities.UtilitiesLib.CheckClosedPath(pathPoints))
                 * {
                 *  System.Windows.Point orginTopleft, orginBottomRight, orginCenter;
                 *  Utilities.UtilitiesLib.extractAnchorPointsOfPath(pathPoints,out orginTopleft,out orginBottomRight,out orginCenter);
                 *
                 *  IdeationUnitGroup idea = new IdeationUnitGroup();
                 *  IdeaGroupContentType ideaGroupContent = new IdeaGroupContentType();
                 *  ideaGroupContent.DisplayBoundaries = pathPoints;
                 *  idea.Content = ideaGroupContent;
                 *  idea.Id = IdeaIDGenerator.generateID();
                 *  idea.CenterX = (float)orginCenter.X;
                 *  idea.CenterY = (float)orginCenter.Y;
                 *
                 *  AddSingleIdeaGroup(idea);
                 * }*/
                //add corresponding idea object for this stroke
                IdeationUnit strokeIdea = new StrokeBasedIdea();
                strokeIdea.Id = IdeaIDGenerator.generateID();
                StrokeData strokeData = new StrokeData();
                strokeData.IsErasingStroke = DrawingCanvasModeSwitcher.IsInErasingMode();
                strokeData.StrokeColorCode = new System.Windows.Media.ColorConverter().ConvertToString(latestStroke.DrawingAttributes.Color);
                strokeData.StrokePoints    = pathPoints;
                strokeIdea.Content         = strokeData;
                brainstormManager.AddIdeaInBackground(strokeIdea);
                //get the current screenshot
                TakeASnapshot();
                timelineManager.AddADDChange(strokeIdea);
            }
            catch (Exception ex)
            {
                Utilities.UtilitiesLib.LogError(ex);
            }
        }
Exemplo n.º 11
0
    public Stroke(StrokeData data)
    {
        Width         = data.width;
        StrokeColor   = new Color(data.color[0], data.color[1], data.color[2], data.color[3]);
        BrushInfoName = data.brushInfoName;
        List <Vector3> pointsList = new List <Vector3>();

        for (int i = 0; i < data.points.Length; i += 3)
        {
            pointsList.Add(new Vector3(data.points[i], data.points[i + 1], data.points[i + 2]));
        }
        Points = pointsList.ToArray();
    }
Exemplo n.º 12
0
        private void OnStrokeAdded(StrokeData strokeData)
        {
            if (strokeData.BoardId != Scrim.Id)
            {
                return;
            }
            StrokeId strokeId = ConvertStrokeDataToStrokeId(strokeData);

            Scrim.StrokeIds.Add(strokeId);
            Application.Current.Dispatcher.Invoke(() =>
            {
                Strokes.Add(strokeId.Stroke);
            });
        }
Exemplo n.º 13
0
        private StrokeId ConvertStrokeDataToStrokeId(StrokeData strokeData)
        {
            StrokeCollection strokes;

            using (MemoryStream ms = new MemoryStream(strokeData.Data))
            {
                strokes = new StrokeCollection(ms);
            }
            return(new StrokeId()
            {
                Id = strokeData.Id,
                Stroke = strokes[0]
            });
        }
Exemplo n.º 14
0
    public Stroke(Transform canvas, Transform pencil, GameObject paint)
    {
        this.canvas = canvas;
        this.pencil = pencil;

        this.paint = GameObject.Instantiate <GameObject>(paint);

        Color color = paint.gameObject.GetComponent <TrailRenderer>().material.GetColor("_EmissionColor");

        strokeDataList    = new List <StrokeData>();
        currentStrokeData = new StrokeData(color, maxPoints);
        strokeDataList.Add(currentStrokeData);

        currentStrokeDataIndex = 0;
        nextPointIndex         = 0;
        pointCount             = 0;
    }
Exemplo n.º 15
0
    public void StartLoading(GameObject loadingPencil)
    {
        currentStrokeDataIndex = 0;
        nextPointIndex         = 0;
        currentStrokeData      = strokeDataList[0];

        loadingPaint       = GameObject.Instantiate <GameObject>(paint);
        this.loadingPencil = loadingPencil;
        Vector3 startingPoint = NextPoint();

        loadingPencil.gameObject.GetComponent <MeshRenderer>().enabled = false;
        loadingPencil.transform.position = startingPoint;
        loadingPaint.transform.position  = startingPoint;
        loadingPaint.transform.SetParent(loadingPencil.transform);
        loadingPaint.gameObject.GetComponent <TrailRenderer>().enabled = true;
        loadingPaint.SetActive(true);
    }
Exemplo n.º 16
0
    public void RecordPoint()
    {
        if (nextPointIndex > maxPoints - 1)
        {
            nextPointIndex = 0;
            currentStrokeDataIndex++;
            currentStrokeData = new StrokeData(currentStrokeData.color, maxPoints);
            strokeDataList.Add(currentStrokeData);
        }

        Vector3 currentPoint = paint.transform.position;

        if (nextPointIndex == 0 || AreDistinctEnough(currentPoint, currentStrokeData.points[nextPointIndex - 1]))
        {
            currentStrokeData.pointCount             = nextPointIndex;
            currentStrokeData.points[nextPointIndex] = currentPoint;
            nextPointIndex++;
            pointCount++;
        }
    }
Exemplo n.º 17
0
        private static Stroke DataToStroke(StrokeData data, System.Windows.Size size)
        {
            Stroke stroke = null;

            switch (data.Type)
            {
            case StrokeTypes.Arrow:
                stroke = new ArrowStroke(StrokeDataEx.ToStylusPoints(data.Points, size));
                break;

            case StrokeTypes.Circle:
                CircleStroke cs = new CircleStroke(StrokeDataEx.ToStylusPoints(data.Points, size));
                stroke = cs;
                break;

            case StrokeTypes.Line:
                stroke = new StraightStroke(StrokeDataEx.ToStylusPoints(data.Points, size));
                break;

            case StrokeTypes.Rectangle:
                stroke = new RectangleStroke(StrokeDataEx.ToStylusPoints(data.Points, size));
                break;

            case StrokeTypes.Triangle:
                stroke = new TriangleStroke(StrokeDataEx.ToStylusPoints(data.Points, size));
                break;

            default:
                stroke = new Stroke(StrokeDataEx.ToStylusPoints(data.Points, size));
                break;
            }


            StrokeEx.SetID(stroke, data.ID);
            stroke.DrawingAttributes = DrawingAttributesDataEx.ToDrawingAttributes(data.Atts);
            if (stroke is ShapeStroke)
            {
                stroke.DrawingAttributes.FitToCurve = false;
            }
            return(stroke);
        }
Exemplo n.º 18
0
 static TimelineChange extractADDCommandFromXmlNode(XmlElement node)
 {
     try
     {
         TimelineChange ADDchange = new TimelineChange();
         ADDchange.ChangeType    = TypeOfChange.ADD;
         ADDchange.ChangedIdeaID = Int32.Parse(node.Attributes["NoteID"].Value, CultureInfo.InvariantCulture);
         string contentType = node.Attributes["ContentType"].Value;
         string contentStr  = node.Attributes["Content"].Value;
         if (contentStr.CompareTo("BITMAP") == 0)
         {
             byte[] contentBytes = Convert.FromBase64String(contentStr);
             ADDchange.MetaData = Utilities.UtilitiesLib.BytesToBitmap(contentBytes);
         }
         else if (contentStr.CompareTo("STROKE") == 0)
         {
             //ADDchange.MetaData = PostItObjects.StrokeBasedIdea.ParseContentFromString(contentStr);
             StrokeData strokeData = new StrokeData();
             strokeData.ParseStrokePointsFromString(contentStr);
             if (node.HasAttribute("IsErasing"))
             {
                 strokeData.ParseIsErasingFromString(node.Attributes["IsErasing"].Value);
             }
             if (node.HasAttribute("Color"))
             {
                 strokeData.StrokeColorCode = node.Attributes["Color"].Value;
             }
             ADDchange.MetaData = strokeData;
         }
         else if (contentStr.CompareTo("GROUP") == 0)
         {
         }
         return(ADDchange);
     }
     catch (Exception ex)
     {
         Utilities.UtilitiesLib.LogError(ex);
     }
     return(null);
 }
Exemplo n.º 19
0
    void OnMessage(int from, JToken message)
    {
        string action = message["action"].ToString();

        if (action == "send-stroke-data")
        {
            point = JsonConvert.DeserializeObject <StrokeData>(message["stroke-data"].ToString());

            if (newStroke)
            {
                ColorUtility.TryParseHtmlString(point.color, out Color color);
                CurrentLine.material.color = color;
                newStroke = false;
            }

            if (CurrentLine != null)
            {
                int n = CurrentLine.positionCount + 1;
                CurrentLine.positionCount = n;
                CurrentLine.SetPosition(n - 1, new Vector3(point.x / 100f, -point.y / 100f, 10f));
                //LineVertexCount++;
            }
            brush.transform.position = new Vector3((point.x / 100f) + CurrentLine.transform.position.x, (-point.y / 100f) + CurrentLine.transform.position.y, brush.transform.position.z);
        }

        if (action == "new-stroke")
        {
            if (CurrentLine == null)
            {
                CurrentLine = SpawnNewLine();
            }

            CurrentLine.positionCount = 0;
            newStroke = true;
        }
    }
Exemplo n.º 20
0
    public IEnumerator readBrushStrokes()
    {
        string url;

                #if UNITY_ANDROID
        url = Path.Combine("jar:file://" + Application.dataPath + "!/assets/", readFileName);
                #endif

                #if UNITY_IOS
        url = Path.Combine("file://" + Application.dataPath + "/Raw", readFileName);
                #endif

                #if UNITY_EDITOR
        url = Path.Combine("file://" + Application.dataPath, readFileName);
#endif

#if UNITY_STANDALONE_WIN
        url = Path.Combine("file://" + Application.dataPath, readFileName);
#endif

#if UNITY_STANDALONE_OSX
        url = Path.Combine("file://" + Application.dataPath, readFileName);
#endif

#if UNITY_WSA
        url = Path.Combine("file://" + Application.dataPath, readFileName);
#endif

        WWW www = new WWW(url);
        yield return(www);

        Debug.Log("+++ File reading finished. Begin parsing...");
        yield return(new WaitForSeconds(consoleUpdateInterval));

        jsonNode = JSON.Parse(www.text);

        for (int f = 0; f < jsonNode["grease_pencil"][0]["layers"].Count; f++)
        {
            for (int h = 0; h < jsonNode["grease_pencil"][0]["layers"][f]["frames"].Count; h++)
            {
                for (int i = 0; i < jsonNode["grease_pencil"][0]["layers"][f]["frames"][h]["strokes"].Count; i++)
                {
                    StrokeData s = new StrokeData();

                    float r = jsonNode["grease_pencil"][0]["layers"][f]["frames"][h]["strokes"][i]["color"][0].AsFloat;
                    float g = jsonNode["grease_pencil"][0]["layers"][f]["frames"][h]["strokes"][i]["color"][1].AsFloat;
                    float b = jsonNode["grease_pencil"][0]["layers"][f]["frames"][h]["strokes"][i]["color"][2].AsFloat;
                    Color c = new Color(r, g, b);
                    s.color = c;

                    for (int j = 0; j < jsonNode["grease_pencil"][0]["layers"][f]["frames"][h]["strokes"][i]["points"].Count; j++)
                    {
                        float x = 0f;
                        float y = 0f;
                        float z = 0f;

                        x = jsonNode["grease_pencil"][0]["layers"][f]["frames"][h]["strokes"][i]["points"][j]["co"][0].AsFloat;
                        y = jsonNode["grease_pencil"][0]["layers"][f]["frames"][h]["strokes"][i]["points"][j]["co"][1].AsFloat;
                        z = jsonNode["grease_pencil"][0]["layers"][f]["frames"][h]["strokes"][i]["points"][j]["co"][2].AsFloat;

                        //Vector3 p = new Vector3(x, y, z) * globalScale;
                        Vector3 p = applyTransformMatrix(new Vector3(x, y, z));

                        s.points.Add(p);
                    }

                    strokesRaw.Add(s);
                }
                yield return(new WaitForSeconds(consoleUpdateInterval));
            }
        }
        ready = true;
    }
Exemplo n.º 21
0
        public override void Apply(ComputedStyle style, Value value)
        {
            // Got any text at all?:
            if (GetText(style) == null)
            {
                return;
            }

            // Apply the property:
            if (value == null || value.Text == "none")
            {
                // Clear the stroke:
                style.TextStroke = null;
            }
            else
            {
                // The stroke properties:
                int   blur   = 0;
                Color colour = Color.black;

                int thickness = value[0].PX;

                if (thickness == 0)
                {
                    style.TextStroke = null;
                }
                else
                {
                    StrokeData data = style.TextStroke;

                    if (data == null)
                    {
                        data             = new StrokeData();
                        style.TextStroke = data;
                    }

                    data.Thickness = thickness;

                    // Grab the blur:
                    Value innerValue = value[1];

                    if (innerValue.Type == ValueType.Color)
                    {
                        colour = innerValue.ToColor();
                    }
                    else
                    {
                        blur = innerValue.PX;

                        // Grab the colour:
                        innerValue = value[2];

                        if (innerValue.Type == ValueType.Color)
                        {
                            colour = innerValue.ToColor();
                        }
                    }

                    data.Colour = colour;
                    data.Blur   = blur;
                }
            }

            // Apply the changes - doesn't change anything about the actual text, so we just want a layout:
            style.RequestLayout();
        }