Nevron Open Vision Documentation
Diagram / Diagram DOM / Drawings / Saving and Loading Drawings
In This Topic
    Saving and Loading Drawings
    In This Topic

    Saving and loading drawings in NOV Diagram is done by calling one of the Save... or Load... method overloads of the NDrawingView class.

     Save to File or Stream Directly

    To save synchronously to a Nevron Binary Drawing local file call the SaveToLocalFile method of the drawing view. This method doesn't work on sandboxed platforms like Blazor WebAssembly.

    Save to a Nevron Binary Drawing file synchronously
    Copy Code
    drawingView.SaveToLocalFile(@"D:\Documents\MyDrawing.ndb");
    

    To save a drawing to a file asynchronously call the SaveToFileAsync method of the drawing view. Calling this method shows a loader over the drawing view until the saving completes. The method returns a promise, which you can use to get notified when the saving completes.

    Save to a Nevron Binary Drawing file asynchronously
    Copy Code
    drawingView.SaveToFileAsync(@"D:\Documents\MyDrawing.ndb").Then(
        delegate (bool success)
        {
        },
        delegate (Exception ex)
        {
        }
    );
    

    To save a drawing to a stream call the SaveToStream method of the drawing view and pass the drawing format to save to:

    Save to Nevron Binary Drawing stream
    Copy Code
    drawingView.SaveToStream(stream, NDrawingFormat.NevronBinary);
    
     Show a Save File Dialog

    To show the standard Save File dialog, use the SaveAsAsync method:

    Save File dialog
    Copy Code
    drawingView.SaveAsAsync();
    

    If you want a specific format to be selected by default, pass it as an argument:

    Save File dialog with a specific file format selected
    Copy Code
    drawingView.SaveAsAsync(NDrawingFormat.NevronBinary);
    
     Load from File or Stream Directly

    To load a Nevron Drawing synchronously from a local file call the LoadFromLocalFile method of the drawing view. This method doesn't work on sandboxed platforms like Blazor WebAssembly.

    Load a Nevron Binary Drawing file synchronously
    Copy Code
    drawingView.LoadFromLocalFile(@"D:\Documents\MyDrawing.ndb");
    

    To load a Nevron Drawing asynchronously call the LoadFromFileAsync method of the drawing view. Calling this method shows a loader over the drawing view until the loading completes. The method returns a promise, which can be used to get notified when the loading completes.

    Load a Nevron Binary Drawing file asynchronously
    Copy Code
    drawingView.LoadFromFileAsync(@"D:\Documents\MyDrawing.ndb").Then(
        delegate (bool success)
        {
        },
        delegate (Exception ex)
        {
        }
    );
    

    To load a drawing from a stream call the LoadFromStream method of the drawing view and pass the drawing format to load:

    Load from Nevron Binary Drawing stream
    Copy Code
    drawingView.LoadFromStream(stream, NDrawingFormat.NevronBinary);
    
     Show an Open File Dialog

    The OpenFileAsync method shows an Open File dialog with all supported drawing formats:

    Open File dialog
    Copy Code
    drawingView.OpenFileAsync();
    

    If you want a specific format to be selected by default, pass it as an argument:

    Open File dialog with a specific file format selected
    Copy Code
    drawingView.OpenFileAsync(NDrawingFormat.NevronBinary);
    
    See Also