public abstract void AnnotationShare(Guid shareTaskId, string provider, Obany.Render.Objects.Canvas canvas, string title, bool isPublic, string keywords, AnnotationShareComplete annotationShareComplete);
 public abstract void AnnotationSave(Guid saveTaskId, System.IO.Stream saveStream, Obany.Render.Objects.Canvas canvas, string mimeType, AnnotationSaveComplete annotationSaveComplete);
Example #3
0
        public override void AnnotationShare(Guid shareTaskId, string provider, Obany.Render.Objects.Canvas canvas, string title, bool isPublic, string keywords, AnnotationShareComplete annotationShareComplete)
        {
            ThreadPool.QueueUserWorkItem(delegate(object s)
            {
                bool success    = false;
                Uri providerUri = null;

                Obany.DocumentStorage.Model.IDocumentStorageProvider documentStorageProvider = Core.CoreConfiguration.DocumentStorageProviderFactory.CreateInstance(provider);

                if (documentStorageProvider != null)
                {
                    ApiCredential apic = ApiCredentialsGet(provider);

                    if (apic != null)
                    {
                        bool sessionOk = true;

                        ISessionProvider sessionProvider = documentStorageProvider as ISessionProvider;
                        string sessionId = null;

                        if (sessionProvider != null)
                        {
                            Obany.Provider.Model.Results.SessionStartResult sessionStartResult = sessionProvider.SessionStart(
                                Obany.Cryptography.SecureEncryption.DecryptData(apic.ApiCredentials1),
                                Obany.Cryptography.SecureEncryption.DecryptData(apic.ApiCredentials2),
                                Obany.Cryptography.SecureEncryption.DecryptData(apic.ApiCredentials3),
                                Obany.Cryptography.SecureEncryption.DecryptData(apic.ApiCredentials4));

                            if (sessionStartResult.Status != OperationStatus.Success)
                            {
                                sessionOk = false;
                            }
                            else
                            {
                                sessionId = sessionStartResult.SessionId;
                            }
                        }

                        if (sessionOk)
                        {
                            Obany.Render.Canvas.CanvasRenderer canvasRenderer = new Obany.Render.Canvas.CanvasRenderer();

                            string errorMessage;
                            Obany.Render.Objects.RenderCanvas renderCanvas = canvasRenderer.Render(canvas, "application/pdf", GetFontFolderPath(), out errorMessage);

                            if (renderCanvas != null)
                            {
                                List <Obany.DocumentStorage.Model.DocumentMetadata> documentMetaData = new List <Obany.DocumentStorage.Model.DocumentMetadata>();
                                if (!string.IsNullOrEmpty(keywords))
                                {
                                    documentMetaData.Add(new Obany.DocumentStorage.Model.DocumentMetadata("Keywords", keywords));
                                }

                                Obany.DocumentStorage.Model.Results.DocumentUploadResult documentUploadResult = documentStorageProvider.DocumentUpload(title, "pdf", renderCanvas.Data, "application/pdf", isPublic, documentMetaData);

                                if (documentUploadResult.Status == OperationStatus.Success)
                                {
                                    providerUri = documentStorageProvider.GetDocumentUrl(documentUploadResult.DocumentId);
                                    success     = true;
                                }
                            }

                            if (sessionProvider != null)
                            {
                                sessionProvider.SessionEnd(sessionId);
                            }
                        }
                    }
                }

                if (annotationShareComplete != null)
                {
                    annotationShareComplete(success, shareTaskId, providerUri);
                }
            });
        }
Example #4
0
        public override void AnnotationSave(Guid saveTaskId, System.IO.Stream saveStream, Obany.Render.Objects.Canvas canvas, string mimeType, AnnotationSaveComplete annotationSaveComplete)
        {
            ThreadPool.QueueUserWorkItem(delegate(object s)
            {
                Obany.Render.Canvas.CanvasRenderer canvasRenderer = new Obany.Render.Canvas.CanvasRenderer();

                string errorMessage;
                Obany.Render.Objects.RenderCanvas renderCanvas = canvasRenderer.Render(canvas, mimeType, GetFontFolderPath(), out errorMessage);

                if (renderCanvas != null)
                {
                    saveStream.Write(renderCanvas.Data, 0, renderCanvas.Data.Length);
                    saveStream.Close();
                }

                if (annotationSaveComplete != null)
                {
                    annotationSaveComplete(renderCanvas != null, saveTaskId);
                }
            });
        }
        private Obany.Render.Objects.Canvas CreateCanvas()
        {
            Obany.Render.Objects.Canvas canvas = new Obany.Render.Objects.Canvas();

            canvas.Width    = _inkPresenter.Width;
            canvas.Height   = _inkPresenter.Height;
            canvas.Colour   = "#FFFFFFFF";
            canvas.Children = new List <Obany.Render.Objects.BaseObject>();
            canvas.Strokes  = new List <Obany.Render.Objects.Stroke>();

            foreach (UIElement uiElement in _uiElements)
            {
                TextBlock textBlock = uiElement as TextBlock;

                if (textBlock != null)
                {
                    canvas.Children.Add(new Obany.Render.Objects.TextBlock(Canvas.GetLeft(uiElement), Canvas.GetTop(uiElement), double.NaN, double.NaN, Canvas.GetZIndex(uiElement), textBlock.Text, textBlock.FontFamily.Source, textBlock.FontSize, (textBlock.Foreground as SolidColorBrush).Color.ToString()));
                }
                else
                {
                    Rectangle rectangle = uiElement as Rectangle;

                    if (rectangle != null)
                    {
                        canvas.Children.Add(new Obany.Render.Objects.Rectangle(Canvas.GetLeft(uiElement), Canvas.GetTop(uiElement), rectangle.Width, rectangle.Height, Canvas.GetZIndex(uiElement), (rectangle.Fill as SolidColorBrush).Color.ToString()));
                    }
                    else
                    {
                        Image image = uiElement as Image;

                        if (image != null)
                        {
                            string resourceId = null;
                            byte[] imageData  = null;
                            string mimeType   = "";

                            object[] data = (object[])image.Tag;

                            if (data != null)
                            {
                                if (data.Length == 3)
                                {
                                    resourceId = (string)data[1];
                                    mimeType   = (string)data[2];
                                    if (string.IsNullOrEmpty(resourceId))
                                    {
                                        System.IO.MemoryStream ms = (System.IO.MemoryStream)data[0];
                                        if (ms != null)
                                        {
                                            imageData = ms.ToArray();
                                        }
                                    }
                                }
                            }

                            canvas.Children.Add(new Obany.Render.Objects.Image(Canvas.GetLeft(uiElement), Canvas.GetTop(uiElement), image.Width, image.Height, Canvas.GetZIndex(uiElement), imageData, mimeType, "", resourceId));
                        }
                    }
                }
            }

            foreach (Stroke stroke in _inkPresenter.Strokes)
            {
                Obany.Render.Objects.Stroke canvasStroke = new Obany.Render.Objects.Stroke();
                canvasStroke.Width  = stroke.DrawingAttributes.Width;
                canvasStroke.Height = stroke.DrawingAttributes.Height;
                canvasStroke.Colour = stroke.DrawingAttributes.Color.ToString();
                canvasStroke.Points = new List <Obany.Render.Objects.StrokePoint>();

                foreach (StylusPoint stylusPoint in stroke.StylusPoints)
                {
                    canvasStroke.Points.Add(new Obany.Render.Objects.StrokePoint(stylusPoint.X, stylusPoint.Y));
                }

                canvas.Strokes.Add(canvasStroke);
            }

            return(canvas);
        }
        private Obany.Render.Objects.Canvas CreateCanvas()
        {
            Obany.Render.Objects.Canvas canvas = new Obany.Render.Objects.Canvas();

            canvas.Width = _inkPresenter.Width;
            canvas.Height = _inkPresenter.Height;
            canvas.Colour = "#FFFFFFFF";
            canvas.Children = new List<Obany.Render.Objects.BaseObject>();
            canvas.Strokes = new List<Obany.Render.Objects.Stroke>();

            foreach (UIElement uiElement in _uiElements)
            {
                TextBlock textBlock = uiElement as TextBlock;

                if (textBlock != null)
                {
                    canvas.Children.Add(new Obany.Render.Objects.TextBlock(Canvas.GetLeft(uiElement), Canvas.GetTop(uiElement), double.NaN, double.NaN, Canvas.GetZIndex(uiElement), textBlock.Text, textBlock.FontFamily.Source, textBlock.FontSize, (textBlock.Foreground as SolidColorBrush).Color.ToString()));
                }
                else
                {
                    Rectangle rectangle = uiElement as Rectangle;

                    if (rectangle != null)
                    {
                        canvas.Children.Add(new Obany.Render.Objects.Rectangle(Canvas.GetLeft(uiElement), Canvas.GetTop(uiElement), rectangle.Width, rectangle.Height, Canvas.GetZIndex(uiElement), (rectangle.Fill as SolidColorBrush).Color.ToString()));
                    }
                    else
                    {
                        Image image = uiElement as Image;

                        if (image != null)
                        {
                            string resourceId = null;
                            byte[] imageData = null;
                            string mimeType = "";

                            object[] data = (object[])image.Tag;

                            if (data != null)
                            {
                                if (data.Length == 3)
                                {
                                    resourceId = (string)data[1];
                                    mimeType = (string)data[2];
                                    if (string.IsNullOrEmpty(resourceId))
                                    {
                                        System.IO.MemoryStream ms = (System.IO.MemoryStream)data[0];
                                        if (ms != null)
                                        {
                                            imageData = ms.ToArray();
                                        }
                                    }
                                }
                            }

                            canvas.Children.Add(new Obany.Render.Objects.Image(Canvas.GetLeft(uiElement), Canvas.GetTop(uiElement), image.Width, image.Height, Canvas.GetZIndex(uiElement), imageData, mimeType, "", resourceId));
                        }
                    }
                }
            }

            foreach (Stroke stroke in _inkPresenter.Strokes)
            {
                Obany.Render.Objects.Stroke canvasStroke = new Obany.Render.Objects.Stroke();
                canvasStroke.Width = stroke.DrawingAttributes.Width;
                canvasStroke.Height = stroke.DrawingAttributes.Height;
                canvasStroke.Colour = stroke.DrawingAttributes.Color.ToString();
                canvasStroke.Points = new List<Obany.Render.Objects.StrokePoint>();

                foreach (StylusPoint stylusPoint in stroke.StylusPoints)
                {
                    canvasStroke.Points.Add(new Obany.Render.Objects.StrokePoint(stylusPoint.X, stylusPoint.Y));
                }

                canvas.Strokes.Add(canvasStroke);
            }

            return (canvas);
        }