Example #1
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;
        }
Example #2
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);
            }
        }