// Use this for initialization void Start() { _rightObj = _rightHand.GetComponent <SteamVR_TrackedObject>(); _leftObj = _leftHand.GetComponent <SteamVR_TrackedObject>(); setupRightPointer(); setupLeftPointer(); _annotationManager = null; DisableRightPointer(); DisableLeftPointer(); _menu = MenuOpened.None; _video = null; _playSpeed = 1; _slider = GameObject.Find("Timeline"); _representation = "Full"; annotationManagerByVideo = new Dictionary <CloudVideoPlayer, AnnotationManager>(); _annotationManager = new AnnotationManager(); _annotationManager.init(); itemSelected = false; spriteButtonSelected = (Sprite)Resources.Load("Textures/white", typeof(Sprite)); spriteButton = (Sprite)Resources.Load("Textures/border2", typeof(Sprite)); }
/// <summary> /// Returns a RubberStamp with all properties set and passed Text. /// </summary> /// <param name="annotationMngr"></param> /// <param name="stampText"></param> /// <returns></returns> private static AnnotationRubberStamp getRubberStamp(AnnotationManager annotationMngr, string stampText) { AnnotationRubberStamp stamp = annotationMngr.AddRubberStampAnnot(Color.Red, 0.2f, 0.2f, 3.0f, 1.2f, stampText); stamp.BorderWidth = 0.2f; stamp.DashCap = System.Drawing.Drawing2D.DashCap.Flat; stamp.Fill = true; if (stampText.Trim() == "Approved") { stamp.FillColor = Color.White; } else { stamp.FillColor = Color.Black; } stamp.FontName = "Arial"; stamp.FontStyle = System.Drawing.FontStyle.Bold; stamp.ForeColor = Color.Red; stamp.Opacity = 100f; stamp.Printable = true; stamp.RadiusFactor = 0.25f; stamp.Stroke = true; stamp.StrokeColor = Color.Red; return(stamp); }
void Start() { _rightObj = _rightHand.GetComponent <SteamVR_TrackedObject>(); _leftObj = _leftHand.GetComponent <SteamVR_TrackedObject>(); setupRightPointer(); setupLeftPointer(); _annotationManager = null; //GameObject annotationManagerGO = GameObject.Find("AnnotationManager"); //_annotationManager = annotationManagerGO.GetComponent<AnnotationManager>(); //_annotationManager.SetRightHand(_rightHand); DisableRightPointer(); DisableLeftPointer(); _menu = MenuOpened.None; _video = null; _playSpeed = 1; _slider = GameObject.Find("Timeline"); _controlDataset = Instantiate(Resources.Load("Prefabs/ControlDataset")) as GameObject; _controlDataset.SetActive(false); _representation = "Full"; annotationManagerByVideo = new Dictionary <CloudVideoPlayer, AnnotationManager>(); itemSelected = false; }
/// <summary> /// general method for changing the manager instance /// replaces the old instace with the new one /// </summary> /// <param name="isQuiz">if true a QuizManager is created instead of a AnnotationManager</param> /// <param name="quizName">if isQuiz this is used to tell the QuizManager which quiz to load</param> /// <returns></returns> private AnnotationManager SetManager(bool isQuiz, string quizName) { if (manager != null) { UnRegisterOnNotifiers(); try { manager.HideAllAnnotations(); } catch (Exception e) { Debug.Log("Could not hide all Annotations: " + e.Message); } Destroy(manager); } if (isQuiz) { QuizManager quizManager = gameObject.AddComponent <QuizManager>(); quizManager.QuizName = quizName; manager = quizManager; IsQuiz = true; Debug.Log("Create new QuizManager"); } else { manager = gameObject.AddComponent <AnnotationManager>(); IsQuiz = false; Debug.Log("Create new AnnotationManager"); } RegisterOnNotifiers(); return(manager); }
private static void CustomActionDispatcher(object sender, CustomActionEventArgs e) { GdPicturePDF oPDF = new GdPicturePDF(); AnnotationManager oAnnotationsManager = new AnnotationManager(); Annotation oAnnotation; switch (e.actionName) { case "tooltip": e.docuVieware.GetNativePDF(out oPDF); oAnnotationsManager.InitFromGdPicturePDF(oPDF); for (int y = 1; y <= oPDF.GetPageCount(); y++) { oAnnotationsManager.SelectPage(y); oPDF.SetOrigin(PdfOrigin.PdfOriginTopLeft); oPDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitInch); int AnnotationCount = oAnnotationsManager.GetAnnotationCount(); if (AnnotationCount > 0) { for (int c = 0; c < AnnotationCount; c++) { oAnnotation = oAnnotationsManager.GetAnnotationFromIdx(c); if (oAnnotation.Guid == e.args.ToString()) { e.result = oAnnotation; } } } } break; } }
/// <summary> /// Add text annotation to pdf /// </summary> /// <param name="pdf">Pdf to add annotation to</param> /// <param name="textAnnotation">Annotation object</param> /// <returns>Pdf containing the annotation</returns> public byte[] AddAnnotation(byte[] pdf, TextAnnotation textAnnotation) { using (var pdfInstance = GdPictureHelper.GetPDFInstance()) { pdfInstance.LoadFromStream(new MemoryStream(pdf)); if (textAnnotation.Page == 0) { textAnnotation.Page++; } pdfInstance.SelectPage(textAnnotation.Page); using (var annotationManager = new AnnotationManager()) { annotationManager.InitFromGdPicturePDF(pdfInstance); var annotation = annotationManager.AddTextAnnot(textAnnotation.Left, textAnnotation.Top, textAnnotation.Width, textAnnotation.Height, textAnnotation.Text); annotation.FontSize = textAnnotation.FontSize; annotation.FontName = textAnnotation.FontName; annotation.ForeColor = textAnnotation.ForeColor; annotationManager.BurnAnnotationsToPage(false); using (var memoryStream = new MemoryStream()) { annotationManager.SaveDocumentToPDF(memoryStream); memoryStream.Position = 0; return(memoryStream.ToArray()); } } } }
private void AddManagers() { var annotationManager = new AnnotationManager(_iosMapView, _customMap); _mapManager = new MapManager(_customMap, annotationManager); _iosMapView.GetViewForAnnotation = annotationManager.GetViewForAnnotation; }
public override void play() { if (!audioSource.isPlaying && AnnotationManager.RoughlyEqual(_start, _video.getVideoTime())) { audioVisualCueGO.SetActive(true); audioSource.Play(); } }
public AnnotationsController() { //TODO Remove - this was just to test output when hitting API Annotation a = new Annotation(); annotationManager = new AnnotationManager(); annotationManager.AddAnnotation(a); }
private void ucDokuViewerGdPicture_Load(object sender, EventArgs e) { if (DesignMode == false) { annotManager = gdViewer1.GetAnnotationManager(); //gdPdf.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitInch); DisableColumnButtons(); } }
/// <summary> /// The constructor initializes members with the provided parameters. /// </summary> /// <param name="widthPixels">The width of the image (pixels).</param> /// <param name="heightPixels">The height of the image (pixels).</param> /// <param name="widthInches">The width of the image (inches).</param> /// <param name="heightInches">The height of the image (inches).</param> /// <param name="annotationManager">The annotation manager to udpdate.</param> /// <param name="textWriter">The stream to output the annotations as text (optional).</param> public WangTiffToGdPictureTiffWangAnnotationHandler(int widthPixels, int heightPixels, double widthInches, double heightInches, AnnotationManager annotationManager, StreamWriter textWriter) { _widthPixels = (double)widthPixels; _heightPixels = (double)heightPixels; _widthInches = widthInches; _heightInches = heightInches; _annotationManager = annotationManager; _textWriter = textWriter; LastError = GdPictureStatus.OK; }
public string Serialize(object enast, bool serializeAnnotations, out AnnotationManager annotMan, bool templateMode) { annotMan = new AnnotationManager(); string ret = null; if (enast is IEnumerable <object> ) { StringBuilder retTT = new StringBuilder(); foreach (var e in enast as IEnumerable <object> ) { var localManager = new AnnotationManager(); retTT.Append(Serialize(e, serializeAnnotations, out localManager, templateMode) + " "); annotMan.appendAnnotations(localManager); } return(retTT.ToString().Trim()); } else { var ser = new CogniPy.CNL.EN.Serializer2(); ser.SerializeAnnotations = serializeAnnotations; ser.TemplateMode = templateMode; if (enast is CogniPy.CNL.EN.paragraph) { ret = ser.Serialize(enast as CogniPy.CNL.EN.paragraph); } else if (enast is CogniPy.CNL.EN.sentence) { ret = ser.Serialize(enast as CogniPy.CNL.EN.sentence); } else if (enast is CogniPy.CNL.EN.orloop) { ret = ser.Serialize(enast as CogniPy.CNL.EN.orloop); } else if (enast is CogniPy.CNL.EN.boundFacets) { ret = ser.Serialize(enast as CogniPy.CNL.EN.boundFacets); } else if (enast is CogniPy.CNL.EN.boundTop) { ret = ser.Serialize(enast as CogniPy.CNL.EN.boundTop); } else if (enast is CogniPy.CNL.EN.boundTotal) { ret = ser.Serialize(enast as CogniPy.CNL.EN.boundTotal); } else { throw new NotImplementedException("Could not serialize. Not implemented."); } annotMan = ser.annotMan; return(ret); } }
/// <summary> /// Makes sure annotations are not added twice on the same page /// </summary> /// <param name="annotationMngr">AnnotationManager object</param> /// <param name="tag">Annotation tag to clean</param> private static void ClearAnnotation(AnnotationManager annotationMngr, string tag) { for (int i = 0; i < annotationMngr.GetAnnotationCount(); i++) { Annotation annot = annotationMngr.GetAnnotationFromIdx(i); if (annot.Tag == tag) { annotationMngr.DeleteAnnotation(i); } } }
private void AddManagers() { var annotationManager = new AnnotationManager(_iosMapView, _customMap); var routeManager = new RouteManager(_iosMapView, _customMap, annotationManager); _mapManager = new MapManager(_customMap, annotationManager, routeManager); _iosMapView.GetViewForAnnotation = annotationManager.GetViewForAnnotation; _drawingManager = new MapDrawingManager(_customMap, Color.Black); _iosMapView.OverlayRenderer = _drawingManager.GetOverlayRenderer; }
public override void ViewDidLoad() { base.ViewDidLoad(); this.bindableProgress = new BindableProgress(View); this.CustomizeNavigationBar(); this.annotationManager = new AnnotationManager(this.Map); this.Map.Delegate = new MapDelegate(); this.SetUpBindings(); }
public PictureView() { InitializeComponent(); this.zoomFactor = 1; this.mainForm = mainForm as MainForm; this.currentFrame = 0; this.annotationManager = new AnnotationManager(); this.BorderStyle = BorderStyle.Fixed3D; this.imageSettings = new ImageSettings(); this.columnHeader1.Width = -2; this.annotationManager.AnnotationAdded += new AnnotationManager.CollectionChanged(annotationManager_AnnotationAdded); this.annotationManager.AnnotationDeleted += new AnnotationManager.CollectionChanged(annotationManager_AnnotationDeleted); this.annotationManager.AnnotationCleared += new AnnotationManager.CollectionCleared(annotationManager_AnnotationCleared); }
void SelectDataset() { Ray raycast = new Ray(_leftHand.transform.position, _leftHand.transform.forward); RaycastHit hit; bool bHit = Physics.Raycast(raycast, out hit); if (hit.transform != null) { Button b = hit.transform.gameObject.GetComponent <Button>(); if (b != null) { b.Select(); if (_leftController.GetPress(SteamVR_Controller.ButtonMask.Trigger)) { if (b.name == "PlaySpeed") { SetPlaybackSpeed(float.Parse(b.GetComponent <VRUIItem>().value)); return; } if (b.name == "Representation") { SetRepresentation(b.GetComponent <VRUIItem>().value); return; } if (_video != null && _video.configFile == b.name) { return; } else if (_video != null && _video.configFile != b.name) { _video.Close(); } _video = new CloudVideoPlayer(b.name, this); if (!annotationManagerByVideo.ContainsKey(_video)) { _annotationManager = new AnnotationManager(); _annotationManager.init(); _annotationManager.SetCloudVideo(_video); annotationManagerByVideo.Add(_video, _annotationManager); } CloseAllMenus(); DisableLeftPointer(); _menu = MenuOpened.None; } } } }
public ActivityDesigner() { this.Loaded += (sender, args) => { this.SetupDefaultIcon(); this.annotationManager.Initialize(); }; this.Unloaded += (sender, args) => { this.annotationManager.Uninitialize(); }; this.annotationManager = new AnnotationManager(this); }
public override void ViewDidLoad() { base.ViewDidLoad(); this.annotationManager = new AnnotationManager(this.Map); this.Map.Delegate = new MapDelegate(/* customize layout */ true); this.Map.AddGestureRecognizer(new UITapGestureRecognizer(_ => { this.VehiclesInMapViewModel.SelectedVehicle = null; })); this.tableViewSource = new SearchTableViewSource(this.SelectedVehicleTable); this.SelectedVehicleTable.Source = this.tableViewSource; this.SelectedVehicleTable.ReloadData(); this.SetUpBindings(); }
/// <summary> /// Dedicated to process image documents /// It retrieves the currently loaded native image handle and initializes an annotation manager object from it. /// </summary> /// <param name="customActionEventArgs">The arguments received from the custom action handler</param> private static void AnnotatePdfDocument(CustomActionEventArgs customActionEventArgs) { GdPicturePDF gdPicturePdf; GdPictureStatus status = customActionEventArgs.docuVieware.GetNativePDF(out gdPicturePdf); if (status == GdPictureStatus.OK) { using (AnnotationManager annotateMngr = new AnnotationManager()) { status = annotateMngr.InitFromGdPicturePDF(gdPicturePdf); if (status == GdPictureStatus.OK) { if (customActionEventArgs.actionName == "addTimestamp") { AddTimestampAnnotation(customActionEventArgs, annotateMngr); } else if (customActionEventArgs.actionName == "addSignature") { AddSignatureAnnotation(customActionEventArgs, annotateMngr); } else if (customActionEventArgs.actionName == "addApprovedStamp") { AddApprovedStampAnnotation(customActionEventArgs, annotateMngr); } else if (customActionEventArgs.actionName == "addRejectedStamp") { AddRejecteStampAnnotation(customActionEventArgs, annotateMngr); } } else { customActionEventArgs.message = new DocuViewareMessage("Failed to initialize Annotation Manager. Status is : " + status + ".", icon: DocuViewareMessageIcon.Error); } } } else { customActionEventArgs.message = new DocuViewareMessage("Failed to retrieve native document. Status is : " + status + ".", icon: DocuViewareMessageIcon.Error); } return; }
/// <summary> /// general method for changing the manager instance /// replaces the old instace with the new one /// </summary> /// <param name="isQuiz">if true a QuizManager is created instead of a AnnotationManager</param> /// <param name="quizName">if isQuiz this is used to tell the QuizManager which quiz to load</param> /// <returns></returns> private AnnotationManager SetManager(bool isQuiz, string quizName) { if (manager != null) { UnRegisterOnNotifiers(); manager.HideAllAnnotations(); Destroy(manager); } if (isQuiz) { QuizManager quizManager = gameObject.AddComponent <QuizManager>(); quizManager.QuizName = quizName; manager = quizManager; IsQuiz = true; } else { manager = gameObject.AddComponent <AnnotationManager>(); IsQuiz = false; } RegisterOnNotifiers(); return(manager); }
void SetUpManager() { manager = new AnnotationManager(loader, mapWrapper); }
public void Finished(AnnotationManager am) { }
public void Undo(AnnotationManager am) { UnityEngine.Object.Destroy(indicator); UnityEngine.Object.Destroy(item); }
public void Perform(AnnotationManager am, Vector4 annopos) { indicator = am.CreateDotIndicator(am.iw.AnnotationPosToCanvasLocalpos(annopos), am.GetCurrentColor()); item = am.im.CreateListItem(annopos); }
private void InitializeAnnotation() { this.annotationManager = new AnnotationManager(this); this.annotationManager.AnnotationVisualProvider = new FlowSwitchDesignerAnnotationVisualProvider(this); }
/// <summary> /// WriteAnnotations writes the tiff to a file including its annotations. /// </summary> /// <param name="strOutputFilePath">The path to the output file.</param> /// <param name="errorMessage">Used to retrieve an error message.</param> /// <param name="pageCount">The number of pages.</param> /// <param name="pageInfo">The page information.</param> /// <param name="textExtension">The extension for the text file.</param> /// <returns>true if the conversion succeded otherwise returns false.</returns> private static bool WriteAnnotations(string strOutputFilePath, ref string errorMessage, PageInfo[] pageInfo, int pageCount, string textExtension) { // Load the tiff from the stream using (MemoryStream stream = new MemoryStream()) { using (FileStream fileStream = File.OpenRead(strOutputFilePath)) { stream.SetLength(fileStream.Length); fileStream.Read(stream.GetBuffer(), 0, (int)fileStream.Length); } using (AnnotationManager annotationManager = new AnnotationManager()) { GdPictureStatus status = annotationManager.InitFromStream(stream); if (status != GdPictureStatus.OK) { errorMessage = annotationManager.GetStat().ToString(); return(false); } // Write the annotation from the pages for (int pageIndex = 0; pageIndex < pageCount; pageIndex++) { if (pageInfo[pageIndex].WangTagData != null) { annotationManager.SelectPage(pageIndex + 1); bool wangAnnotationsReadingSuccess; if (textExtension == "") { WangTiffToGdPictureTiffWangAnnotationHandler handler = new WangTiffToGdPictureTiffWangAnnotationHandler(pageInfo[pageIndex].WidthPixels, pageInfo[pageIndex].HeightPixels, pageInfo[pageIndex].WidthInches, pageInfo[pageIndex].HeightInches, annotationManager, null); wangAnnotationsReadingSuccess = WangTagReadingLibrary.WangAnnotationsReader.Read( handler, pageInfo[pageIndex].WangTagData); } else { using ( StreamWriter textWriter = new StreamWriter(strOutputFilePath + "." + pageIndex + textExtension)) { WangTiffToGdPictureTiffWangAnnotationHandler handler = new WangTiffToGdPictureTiffWangAnnotationHandler( pageInfo[pageIndex].WidthPixels, pageInfo[pageIndex].HeightPixels, pageInfo[pageIndex].WidthInches, pageInfo[pageIndex].HeightInches, annotationManager, textWriter); wangAnnotationsReadingSuccess = WangTagReadingLibrary.WangAnnotationsReader.Read( handler, pageInfo[pageIndex].WangTagData); } } if (!wangAnnotationsReadingSuccess) { annotationManager.Close(); errorMessage = "An error occurred while reading Wang annotations."; return(false); } } } // Writes the tiff as a file status = annotationManager.SaveDocumentToTIFF(strOutputFilePath, TiffCompression.TiffCompressionAUTO); if (status != GdPictureStatus.OK) { errorMessage = annotationManager.GetStat().ToString(); return(false); } annotationManager.Close(); } } return(true); }
public static string GetOWLXML(CNL.DL.Paragraph para, bool owlXml, string externext, Dictionary <string, string> invUriMappings, AnnotationManager annotMan, string ontologyBase = null, Dictionary <string, Tuple <string, string> > prefixes = null, string defaultGuid = null, Dictionary <string, List <string> > owlOntologyAnnotation = null, string generatedBy = "CogniPy") { prefixes = prefixes ?? new Dictionary <string, Tuple <string, string> >(); if (ontologyBase == null) { ontologyBase = "http://www.ontorion.com/ontologies/Ontology" + Guid.NewGuid().ToString("N"); } //var ontologyBase = (ontologyNs ?? "http://www.ontorion.com/ontologies/Ontology" + Guid.NewGuid().ToString("N")); //if(!String.IsNullOrEmpty(defaultGuid)) // ontologyBase = (ontologyNs ?? "http://www.ontorion.com/ontologies/Ontology" + defaultGuid); if (!ontologyBase.EndsWith("/") && !ontologyBase.EndsWith("#") && !ontologyBase.Contains("#")) { ontologyBase += "#"; } OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); CogniPy.ARS.Transform transform = new CogniPy.ARS.Transform(); transform.InvUriMappings = invUriMappings; var df = manager.getOWLDataFactory(); ontology = manager.createOntology(IRI.create(ontologyBase)); org.semanticweb.owlapi.vocab.PrefixOWLOntologyFormat owlxmlFormat = null; if (owlXml) { owlxmlFormat = new org.semanticweb.owlapi.io.OWLXMLOntologyFormat(); } else { owlxmlFormat = new org.semanticweb.owlapi.io.RDFXMLOntologyFormat(); } owlxmlFormat.setDefaultPrefix(ontologyBase); foreach (var kv in prefixes) { owlxmlFormat.setPrefix(kv.Key.Replace("$", "."), kv.Value.Item1); // should we put here the Item2 (the location) and not the inner namespace??? if (!String.IsNullOrEmpty(kv.Value.Item2) && !(kv.Value.Item2.EndsWith(".encnl") || kv.Value.Item2.EndsWith(".encnl#"))) // do not export cnl imports (not in OWL!) { // here we need to use Item1 because we cannot export into OWL the specific location of the ontology ---> this is bad practice as in this way we loose the generality of the owl file // imagine that the location is C://mydirectory/... and I add into an owl file: owl:import "C:/mydirectory/". This mean that only on my computer I will be able to import this file. // On the other hand if we write owl:import "namespace of the file" there is a good chance that when someone else will open the file, the file will be imported from internet. var decl = manager.getOWLDataFactory().getOWLImportsDeclaration(OWLPathUriTools.Path2IRI(kv.Value.Item1.TrimEnd('#'))); manager.applyChange(new AddImport(ontology, decl)); } } manager.setOntologyFormat(ontology, owlxmlFormat); if (owlOntologyAnnotation != null) { foreach (var keyVal in owlOntologyAnnotation) { foreach (string val in keyVal.Value) { manager.applyChange(new AddOntologyAnnotation( ontology, manager.getOWLDataFactory().getOWLAnnotation( manager.getOWLDataFactory().getOWLAnnotationProperty(IRI.create(keyVal.Key)), manager.getOWLDataFactory().getOWLLiteral(val)))); } } } transform.setOWLDataFactory(false, ontologyBase, df, owlxmlFormat, CNL.EN.CNLFactory.lex); var paraFromAnnotStatements = annotMan.getDLAnnotationAxioms(); var stmts = para.Statements; foreach (var p in paraFromAnnotStatements) { stmts.AddRange(p.Value); } var conv = transform.Convert(new CogniPy.CNL.DL.Paragraph(null) { Statements = stmts }); var om = new org.coode.xml.OWLOntologyXMLNamespaceManager(manager, ontology); foreach (var axiom in conv.axioms) { if (axiom.comment != null) { var dp = axiom.comment.IndexOf(':'); var x = axiom.comment.Substring(0, dp); if (x.Trim() == "Namespace") { var ontologyIri = axiom.comment.Substring(dp + 1).Trim(); if (ontologyIri.EndsWith(".")) { ontologyIri = ontologyIri.Substring(0, ontologyIri.Length - 1); } if (ontologyIri.StartsWith("\'") && ontologyIri.Length > 2) { ontologyIri = ontologyIri.Substring(1, ontologyIri.Length - 2).Replace("\'\'", "\'"); } manager.removeOntology(ontology); ontology = manager.createOntology(IRI.create(ontologyIri)); om.setDefaultNamespace(ontologyIri + "#"); transform.setOWLDataFactory(true, ontologyBase, df, owlxmlFormat, CNL.EN.CNLFactory.lex); } else if (x.Trim() == "References") { var refs = CNLTools.ParseReferences(axiom.comment.Substring(dp)); foreach (Match match in refs) { var onto = match.Groups["ont"].Value; if (onto.StartsWith("\'") && onto.Length > 2) { onto = onto.Substring(1, onto.Length - 2).Replace("\'\'", "\'").Trim(); } if (!string.IsNullOrEmpty(onto)) { if (onto.ToLower().EndsWith(".encnl")) { onto = OWLConverter.PathToIRIString(onto.Substring(0, onto.Length - ".encnl".Length) + externext); } var ns = match.Groups["ns"].Value; if (ns.StartsWith("\'") && ns.Length > 2) { ns = ns.Substring(1, ns.Length - 2).Replace("\'\'", "\'").Trim(); } else if (string.IsNullOrEmpty(ns)) { ns = onto; } om.setPrefix(match.Groups["pfx"].Value, ns); owlxmlFormat.setPrefix(match.Groups["pfx"].Value, ns); var decl = manager.getOWLDataFactory().getOWLImportsDeclaration(OWLPathUriTools.Path2IRI(onto)); manager.applyChange(new AddImport(ontology, decl)); } } } else { //manager.applyChange(new AddOntologyAnnotation( // ontology, // manager.getOWLDataFactory().getOWLAnnotation( // manager.getOWLDataFactory().getOWLAnnotationProperty(IRI.create(ontologyBase + x)), // manager.getOWLDataFactory().getOWLLiteral(axiom.comment.Substring(dp))))); } } else if (axiom.axiom != null) { manager.addAxiom(ontology, axiom.axiom); } } foreach (var axiom in conv.additions) { manager.addAxiom(ontology, axiom); } var ontout = new org.semanticweb.owlapi.io.StringDocumentTarget(); manager.saveOntology(ontology, owlxmlFormat, ontout); manager.removeOntology(ontology); var retdoc = new XmlDocument(); retdoc.LoadXml(ontout.toString()); foreach (var elem in retdoc.ChildNodes) { if (elem is XmlComment) { retdoc.RemoveChild(elem as XmlComment); } } retdoc.AppendChild(retdoc.CreateComment("Generated by " + generatedBy + ", (with support from OwlApi)")); return(SerializeDoc(retdoc)); }
/// <summary> /// WriteAnnotations writes the pdf to a file including its annotations. /// </summary> /// <param name="strOutputFilePath">The path to the output file.</param> /// <param name="errorMessage">Used to retrieve an error message.</param> /// <param name="stream">The stream containing the PDF.</param> /// <param name="pageCount">The number of pages.</param> /// <param name="pageInfo">The page information.</param> /// <param name="textExtension">The extension for the text file.</param> /// <returns>true if the conversion succeded otherwise returns false.</returns> private static bool WriteAnnotations(string strOutputFilePath, ref string errorMessage, MemoryStream stream, int pageCount, PageInfo[] pageInfo, string textExtension) { using (AnnotationManager annotationManager = new AnnotationManager()) { // Load the pdf from the stream GdPictureStatus status = annotationManager.InitFromStream(stream); if (status != GdPictureStatus.OK) { errorMessage = annotationManager.GetStat().ToString(); return(false); } // Write the annotation from the pages for (int pageIndex = 0; pageIndex < pageCount; pageIndex++) { if (pageInfo[pageIndex].WangTagData != null) { annotationManager.SelectPage(pageIndex + 1); bool wangAnnotationsReadingSuccess; if (textExtension == "") { WangTiffToPdfWangAnnotationHandler handler = new WangTiffToPdfWangAnnotationHandler(pageInfo[pageIndex].WidthPixels, pageInfo[pageIndex].HeightPixels, pageInfo[pageIndex].WidthInches, pageInfo[pageIndex].HeightInches, annotationManager, null); wangAnnotationsReadingSuccess = WangTagReadingLibrary.WangAnnotationsReader.Read(handler, pageInfo[pageIndex].WangTagData); } else { using ( StreamWriter textWriter = new StreamWriter(strOutputFilePath + "." + pageIndex + textExtension)) { WangTiffToPdfWangAnnotationHandler handler = new WangTiffToPdfWangAnnotationHandler(pageInfo[pageIndex].WidthPixels, pageInfo[pageIndex].HeightPixels, pageInfo[pageIndex].WidthInches, pageInfo[pageIndex].HeightInches, annotationManager, textWriter); wangAnnotationsReadingSuccess = WangTagReadingLibrary.WangAnnotationsReader.Read( handler, pageInfo[pageIndex].WangTagData); } } status = wangAnnotationsReadingSuccess ? annotationManager.BurnAnnotationsToPage(true) : GdPictureStatus.GenericError; if (status != GdPictureStatus.OK) { annotationManager.Close(); errorMessage = wangAnnotationsReadingSuccess ? annotationManager.GetStat().ToString() : "An error occurred while reading Wang annotations."; return(false); } } } // Writes the pdf as a file status = annotationManager.SaveDocumentToPDF(strOutputFilePath); if (status != GdPictureStatus.OK) { errorMessage = annotationManager.GetStat().ToString(); return(false); } annotationManager.Close(); } return(true); }
private static void Dispatcher(object sender, CustomActionEventArgs e) { GdPicturePDF oPdf = new GdPicturePDF(); switch (e.actionName) { //loading document and setting annotations access control //the workflow is designed for PDF files, you can apply similar workflow on the other formats using GdPictureImaging class case "load": load oLoad = JsonConvert.DeserializeObject <load>(e.args.ToString()); GdPictureStatus status = oPdf.LoadFromFile(HttpRuntime.AppDomainAppPath + "\\Files\\" + oLoad.Path, true); AnnotationManager oAnnotationmanager = new AnnotationManager(); oAnnotationmanager.InitFromGdPicturePDF(oPdf); for (int i = 1; i < oAnnotationmanager.PageCount; i++) { oAnnotationmanager.SelectPage(i); for (int y = 0; y < oAnnotationmanager.GetAnnotationCount(); y++) { Annotation annot = oAnnotationmanager.GetAnnotationFromIdx(y); if (oLoad.UserType == "user") //case for external user member { if (annot.Tag != oLoad.UserType) //annotation is not vissible if not added by external group memebr { annot.Visible = false; } } else if (oLoad.UserType == "staff") //case for staff member { annot.Visible = true; //all annot are visible } } oAnnotationmanager.SaveAnnotationsToPage(); } e.docuVieware.LoadFromGdPicturePdf(oPdf); e.docuVieware.DisplayPage(1); break; //setting annotation tag that represents access group and saving annotation to PDF //the workflow is designed for PDF files, you can apply similar workflow on the other formats using GdPictureImaging class case "setAnnotationTag": e.docuVieware.GetNativePDF(out oPdf); AnnotationManager manager = new AnnotationManager(); manager.InitFromGdPicturePDF(oPdf); details oDetails = JsonConvert.DeserializeObject <details>(e.args.ToString()); manager.SelectPage(oDetails.annot.pageNo); int pages = manager.GetAnnotationCount(); for (int i = 0; i < pages; i++) { Annotation oAnnotation = manager.GetAnnotationFromIdx(i); if (oAnnotation.Guid == oDetails.annot.id) { oAnnotation.Tag = oDetails.type; } } manager.SaveAnnotationsToPage(); status = oPdf.SaveToFile(HttpRuntime.AppDomainAppPath + "\\Files\\DocuViewareFlyer.pdf", true); break; } }