Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (145).NET Core  (23)Angular  (40)ASP.NET  (47)ASP.NET Core  (54)ASP.NET MVC  (84)Azure  (28)Blazor  (57)DocIO  (18)Essential JS 2  (65)Essential Studio  (160)Flutter  (61)JavaScript  (135)Microsoft  (97)PDF  (50)React  (30)Succinctly series  (119)Syncfusion  (428)TypeScript  (30)Uno Platform  (2)UWP  (4)Vue  (26)Webinar  (14)Windows Forms  (52)WPF  (98)Xamarin  (107)XlsIO  (20)Other CategoriesBarcode  (4)BI  (29)Bold BI  (3)Build conference  (6)Business intelligence  (53)Button  (4)C#  (100)Chart  (40)Cloud  (9)Company  (445)Dashboard  (5)Data Science  (3)Data Validation  (3)DataGrid  (31)Development  (238)Doc  (7)eBook  (90)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (14)Extensions  (8)File Manager  (3)Gantt  (7)Gauge  (4)Git  (3)Grid  (25)HTML  (8)Installer  (1)Knockout  (2)LINQPad  (1)Linux  (1)M-Commerce  (1)Metro Studio  (11)Mobile  (151)Mobile MVC  (9)OLAP server  (1)Orubase  (12)Partners  (20)PDF viewer  (18)Performance  (2)PHP  (1)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (5)Road Map  (9)Scheduler  (15)SfDataGrid  (7)Silverlight  (21)Sneak Peek  (12)Solution Services  (2)Spreadsheet  (2)SQL  (4)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (9)Tips and Tricks  (27)UI  (79)Uncategorized  (68)Unix  (2)User interface  (57)Visual State Manager  (1)Visual Studio  (14)Visual Studio Code  (8)Web  (120)What's new  (78)Windows 8  (19)Windows App  (1)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Share on twitter
Share on facebook
Share on linkedin
Easily Prepare Network Diagrams with Our WPF Diagram Control

Easily Prepare Network Diagrams with Our WPF Diagram Control

Do you have an application requirement to draw network diagrams? Are you looking for a network diagram designer? Designing your own network architecture diagram is faster and easier with a network diagram creator application built using our WPF Diagram control.

In this blog post, you will learn how to create your own network architecture diagram quickly and easily using an interactive user interface that supports drag-and-drop operations, copy, paste, import, export, pan, zoom, and more. We will see much of the rich feature set available in our WPF Diagram control that provides an excellent, intuitive user experience.

Preparing Network Diagrams with Our WPF Diagram Control
Preparing Network Diagrams with Our WPF Diagram Control

What is a network diagram?

A network diagram is a graphical representation of network architecture. It shows how computers and network devices (e.g., routers, hubs, switches, firewalls, etc.) are connected within a network and displays how information flows through it. This visual representation helps to track down network issues by studying how the devices are connected and interrelated.

Network diagram symbols

Since a network diagram is a graphical representation of an actual system, it relies on symbols to convey the meaning. The network diagram may include hundreds of different symbols. The standard network diagram symbols include firewall, server, mainframe, PC, laptop, switch, hub, router, cell phone, and more.

Common Network Diagram Symbols
Common Network Diagram Symbols

Creating reusable network diagram symbols

The WPF Diagram control provides a gallery of reusable symbols and diagram elements, called a stencil. The symbols can be dragged onto the diagramming page any number of times and in any place.

Let’s see how to create a stencil with our network diagram symbols. The stencil’s SymbolSource property is used to define the data source as a collection of objects (symbol, node, connector, etc.) that needs to be populated as symbols. The following code creates a stencil with network diagram symbols.

XAML:

<stencil:Stencil x:Name="stencil" 
      Grid.Row="1"   
   ExpandMode="ZeroOrMore"
      SymbolFilters="{Binding Symbolfilters}" SelectedFilter="{Binding Selectedfilter}">
  <stencil:Stencil.SymbolSource>
    <local:SymbolCollection>
       <!--Computers and Monitors-->
        <viewmodel:CustomNode Name="PC" UnitHeight="140" UnitWidth="100" ContentTemplate="{StaticResource PCStencil}" Key="Computers and Monitors">
          <!--Initialize the annotations-->
          <Syncfusion:NodeViewModel.Annotations>
             <!--Initialize the AnnotationCollection-->
             <Syncfusion:AnnotationCollection>
                 <!--Initialize the Annotation editor view model-->
                 <Syncfusion:AnnotationEditorViewModel Constraints="Editable,Selectable,Resizable,Draggable" Margin="0,60,0,0"/>
              </Syncfusion:AnnotationCollection>
          </Syncfusion:NodeViewModel.Annotations>
        </viewmodel:CustomNode>
      <viewmodel:CustomNode Name="VirtualPC" UnitHeight="140" UnitWidth="100" ContentTemplate="{StaticResource VirtualPCStencil}" Key="Computers and Monitors">
        <Syncfusion:NodeViewModel.Annotations>
           <!--Initialize the AnnotationCollection-->
           <Syncfusion:AnnotationCollection>
             <!--Initialize the Annotation editor view model-->
             <Syncfusion:AnnotationEditorViewModel Constraints="Editable,Selectable,Resizable,Draggable" Margin="0,60,0,0"/>
           </Syncfusion:AnnotationCollection>
        </Syncfusion:NodeViewModel.Annotations>
      </viewmodel:CustomNode>
     <viewmodel:CustomNode Name="Terminal" UnitHeight="150" UnitWidth="130" ContentTemplate="{StaticResource TerminalStencil}" Key="Computers and Monitors">
      <Syncfusion:NodeViewModel.Annotations>
       <!--Initialize the AnnotationCollection-->
       <Syncfusion:AnnotationCollection>
         <!--Initialize the Annotation editor view model-->
         <Syncfusion:AnnotationEditorViewModel Constraints="Editable,Selectable,Resizable,Draggable" Margin="0,60,0,0"/>
        </Syncfusion:AnnotationCollection>
       </Syncfusion:NodeViewModel.Annotations>
      </viewmodel:CustomNode>
    <viewmodel:CustomNode Name="Wavelength" UnitHeight="140" UnitWidth="150" ContentTemplate="{StaticResource WavelengthStencil}" Key="Computers and Monitors">
     <Syncfusion:NodeViewModel.Annotations>
      <!--Initialize the AnnotationCollection-->
      <Syncfusion:AnnotationCollection>
        <!--Initialize the Annotation editor view model-->
        <Syncfusion:AnnotationEditorViewModel Constraints="Editable,Selectable,Resizable,Draggable" Margin="0,35,0,0"/>
       </Syncfusion:AnnotationCollection>
      </Syncfusion:NodeViewModel.Annotations>
     </viewmodel:CustomNode>
   <viewmodel:CustomNode Name="DataPipe" UnitHeight="80" UnitWidth="120" ContentTemplate="{StaticResource DataPipeStencil}" Key="Computers and Monitors">
    <Syncfusion:NodeViewModel.Annotations>
     <!--Initialize the AnnotationCollection-->
     <Syncfusion:AnnotationCollection>
       <!--Initialize the Annotation editor view model-->
       <Syncfusion:AnnotationEditorViewModel Constraints="Editable,Selectable,Resizable,Draggable" Margin="0,30,0,0"/>
      </Syncfusion:AnnotationCollection>
     </Syncfusion:NodeViewModel.Annotations>
    </viewmodel:CustomNode>
   <viewmodel:CustomNode Name="SlateDevice" UnitHeight="100" UnitWidth="130" ContentTemplate="{StaticResource SlateDivceStencil}" Key="Computers and Monitors">
    <Syncfusion:NodeViewModel.Annotations>
      <!--Initialize the AnnotationCollection-->
      <Syncfusion:AnnotationCollection>
        <!--Initialize the Annotation editor view model-->
        <Syncfusion:AnnotationEditorViewModel Constraints="Editable,Selectable,Resizable,Draggable" Margin="0,60,0,0"/>
       </Syncfusion:AnnotationCollection>
      </Syncfusion:NodeViewModel.Annotations>
     </viewmodel:CustomNode>
    <viewmodel:CustomNode Name="TabletDevice" UnitHeight="130" UnitWidth="130" ContentTemplate="{StaticResource TabletDeviceStencil}" Key="Computers and Monitors">
     <Syncfusion:NodeViewModel.Annotations>
       <!--Initialize the AnnotationCollection-->
       <Syncfusion:AnnotationCollection>
          <!--Initialize the Annotation editor view model-->
          <Syncfusion:AnnotationEditorViewModel Constraints="Editable,Selectable,Resizable,Draggable" Margin="0,60,0,0"/>
         </Syncfusion:AnnotationCollection>
       </Syncfusion:NodeViewModel.Annotations>
      </viewmodel:CustomNode>
     <viewmodel:CustomNode Name="Laptop" UnitHeight="140" UnitWidth="100" ContentTemplate="{StaticResource LaptopStencil}" Key="Computers and Monitors">
      <Syncfusion:NodeViewModel.Annotations>
        <!--Initialize the AnnotationCollection-->
        <Syncfusion:AnnotationCollection>
           <!--Initialize the Annotation editor view model-->
           <Syncfusion:AnnotationEditorViewModel Constraints="Editable,Selectable,Resizable,Draggable" Margin="0,60,0,0"/>
          </Syncfusion:AnnotationCollection>
         </Syncfusion:NodeViewModel.Annotations>
        </viewmodel:CustomNode>
      <viewmodel:CustomNode Name="PDA" UnitHeight="150" UnitWidth="70" ContentTemplate="{StaticResource PDAStencil}" Key="Computers and Monitors">
        <Syncfusion:NodeViewModel.Annotations>
          <!--Initialize the AnnotationCollection-->
          <Syncfusion:AnnotationCollection>
            <!--Initialize the Annotation editor view model-->
            <Syncfusion:AnnotationEditorViewModel Constraints="Editable,Selectable,Resizable,Draggable" Margin="0,60,0,0"/>
           </Syncfusion:AnnotationCollection>
          </Syncfusion:NodeViewModel.Annotations>
         </viewmodel:CustomNode>
        <viewmodel:CustomNode Name="CRTMonitor" UnitHeight="140" UnitWidth="120" ContentTemplate="{StaticResource CRTMonitorStencil}" Key="Computers and Monitors">
         <Syncfusion:NodeViewModel.Annotations>
          <!--Initialize the AnnotationCollection-->
          <Syncfusion:AnnotationCollection>
             <!--Initialize the Annotation editor view model-->
             <Syncfusion:AnnotationEditorViewModel Constraints="Editable,Selectable,Resizable,Draggable" Margin="0,60,0,0"/>
            </Syncfusion:AnnotationCollection>
           </Syncfusion:NodeViewModel.Annotations>
          </viewmodel:CustomNode>
        <viewmodel:CustomNode Name="LCDMonitor" UnitHeight="140" UnitWidth="130" ContentTemplate="{StaticResource LCDMonitorStencil}" Key="Computers and Monitors">
         <Syncfusion:NodeViewModel.Annotations>
           <!--Initialize the AnnotationCollection-->
           <Syncfusion:AnnotationCollection>
              <!--Initialize the Annotation editor view model-->
              <Syncfusion:AnnotationEditorViewModel Constraints="Editable,Selectable,Resizable,Draggable" Margin="0,60,0,0"/>
             </Syncfusion:AnnotationCollection>
            </Syncfusion:NodeViewModel.Annotations>
           </viewmodel:CustomNode>
          <viewmodel:CustomNode Name="Connector" UnitHeight="170" UnitWidth="130" ContentTemplate="{StaticResource DynamicConnectorStencil}" Key="Computers and Monitors">
          </viewmodel:CustomNode>
         </local:SymbolCollection>
        </stencil:Stencil.SymbolSource>
         <stencil:Stencil.SymbolGroups>
           <stencil:SymbolGroups>
              <!--Separate groups based on the key-->
              <stencil:SymbolGroupProvider MappingName="Key"/>
           </stencil:SymbolGroups>
      </stencil:Stencil.SymbolGroups>
    </stencil:Stencil>

The following screenshot shows the collection of network diagram symbols in the created stencil.

Network Diagram Symbol Stencil
Network Diagram Symbol Stencil

You can refer to this stencil documentation page for details about adding and grouping symbols, plus customizing the stencil appearance.

Creating a diagramming page

Now, we have set up reusable network diagram shapes in our Stencil. Using the following code example, let’s add the diagramming page we’ll create our network diagram on.

XAML:

<Syncfusion:SfDiagram x:Name="Diagram" Grid.Column="1"
        DefaultConnectorType="{Binding DefaultConnectorType,Mode=TwoWay}"
        PortVisibility="{Binding PortVisibility}"
        Nodes="{Binding Nodes}"
        Connectors="{Binding Connectors}"
        ScrollSettings="{Binding ScrollSettings}"
        PageSettings="{Binding PageSettings}"
        VerticalRuler="{Binding VerticalRuler}"
        HorizontalRuler="{Binding HorizontalRuler}"
        PrintingService="{Binding PrintingService}"
        Constraints="{Binding Constraints}"
        Tool="{Binding Tool,Mode=TwoWay}"
        DrawingTool="{Binding DrawingTool,Mode=TwoWay}"
        SelectedItems="{Binding SelectedItems}"
        ExportSettings="{Binding ExportSettings}"
        SnapSettings="{Binding SnapSettings}"
        DragEnterCommand="{Binding DragEnterCommand}"
        DragOverCommand="{Binding DragOverCommand}"
        ItemAddedCommand="{Binding ItemAddedCommand}"
        DropCommand="{Binding DropCommand}"
        ItemSelectedCommand="{Binding ItemSelectedCommand}"
        ItemUnSelectedCommand="{Binding ItemUnSelectedCommand}"
        ViewPortChangedCommand="{Binding ViewPortChangedCommand}"
        AnnotationConstraints="{Binding AnnotationConstraints}"
        Loaded="Diagram_Loaded">
</Syncfusion:SfDiagram>

The following screenshot shows the created diagramming page along with the network diagram symbols stencil.

Diagramming Page with Stencil
Diagramming Page with Stencil

You can refer to this Diagram documentation page for more details on how to add a diagramming page in your application and how to customize its appearance.

How to create a network diagram

Now you can easily draw a network diagram by dragging and dropping the network diagram symbols from the stencil, arranging them on the page, and connecting them.

Add network diagram symbols

Start by dragging the symbols you need for each device onto the diagramming page from the Computers and Monitors and Network and Peripherals stencils. Arrange them in an order that makes it clear where the network origin and end points are, and how the various nodes are linked. People who read the diagram should be able to see where to start, and how to follow the connections.
Add network diagram symbols

Add connections between devices

Each diagram symbol has Draw quick command which is visible when the symbol is selected. This quick command creates a connection from the symbol by clicking and dragging the connector and dropping it on another symbol.
Add connections between devices

You can refer to this quick command documentation page for more details on how to add or remove default and custom quick commands in your application and how to customize their appearance.

You can also create connectors by selecting the connector tool  connector tool   from the toolbar or from the Tools > Connector tool menu option. Now, click a symbol and drag a connector to another shape. When you are done, click the pointer tool  pointer tool  on the toolbar to select the symbols.
Add connections between devices

Refer to the tools documentation page for more details about supported diagram tools.

Change connection line style

The WPF Diagram control provides three different types of connection lines: straight, orthogonal, and Bezier. You can change the connector type of a connector by selecting it and using the change connector type   change connector type  drop-down in the toolbar, or by using the Tools > Connectors menu option.
Change connection line style

Refer to the connector types documentation page for more details on different types of connectors and how to change them in your application.

Add labels and data

To add text to a network symbol, double-click the symbol and start typing. To move the text, click and drag the text to the desired position.
Add labels and data

Refer to annotation documentation page for more details on how to add labels in your application and customize their appearance.

Loading and saving a diagram

The Diagram control provides the flexibility to save your current work and resume it later by loading the saved diagram back to the diagram canvas. You can use Save button  Savebutton to save your current diagram to the local drive and use the Open button Open button to load an existing diagram file from your local drive.
Loading and saving a diagram

Refer to the load and save documentation pages for more details on how to integrate the WPF Diagram control’s load and save functionality in your application.

Print and export diagram

Once you have finished editing the network diagram, you can export it as an image or PDF document, or you can print it using a printer.

Print a diagram

You can print a diagram directly by clicking the Print button  Print button in the toolbar or by selecting the File > Print menu option.

The following screenshot shows the Print Diagram dialog box along with the custom print options.

Diagram Print Options
Diagram Print Options

Refer to the printing documentation page for more details on how to configure diagram printing functionality in your application.

Export a diagram

You can save a diagram in PDF format, or you can save it as an image file (JPEG, PNG, BMP, TIF, GIF, and more). You can do this by clicking the Export button  export button  or selecting the File > Export menu option.
Export a diagram

Refer to the exporting documentation page for more details on how to configure diagram exporting functionality in your application.

Pan and zoom

The WPF Diagram control provides support to pan and zoom the diagram in different ways.

Pan and zoom using the keyboard

  1. Hold down the Ctrl and Shift keys. The pointer will turn into a magnifying glass.
  2. Try the following techniques:
  • Click the left mouse button to enlarge the view.
  • Click the right mouse button to reduce the view.
  • Click the left mouse button and drag a rectangle that contains a region you want to zoom into.
  • Right-click and drag to pan the diagram.

Pan and zoom using the keyboard

Pan and zoom using the scroll wheel

Do any of the following:

  • To scroll up or down, rotate the scroll wheel forward or backward.
  • To scroll left or right, hold down Shift as you rotate the scroll wheel forward or backward.
  • To zoom in or out, hold down Ctrl as you rotate the scroll wheel forward or backward.

Pan and zoom using the scroll wheelZoom using the zoom controls

The zoom controls are in the status bar, below the diagramming page.

Clicking the zoom out and zoom in buttons change the zoom level of the diagram. The controls include a slider that sets the zoom level and a button to fit the page to the size of the current window.
Zoom by using the Zoom controls

Pan using the pan tool

You can pan the diagram by selecting the Pan tool  Pan tool  from the toolbar or the Tools > Pan menu option and then clicking and dragging the mouse to pan the diagram.
Pan using the pan tool

Resources

You can download the source project for this network diagram designer from this GitHub location.

Conclusion

In this blog post, you have seen how to create a network diagram easily using a network diagram designer application that was created using the Syncfusion WPF Diagram library. Also, you have learned about connectors and labels, and about performing operations such as load, save, export, print, pan, and zoom with the created network diagram.

Similarly, you can create your own diagram creation application like an organization chart creator, a flow chart creator, or a logic circuit diagram using the Syncfusion WPF Diagram library. The library supports even more rich interactive features than just those demonstrated here, automatic layouts, and data binding from different data sources. To explore features in more depth, refer to our documentation.

If you’re already a Syncfusion user, you can download the product setup from our website. Otherwise, you can download a free, 30-day trial here.

If you have any questions, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Tags:

Share this post:

Share on twitter
Share on facebook
Share on linkedin

Leave a comment

Popular Now

Be the first to get updates

Subscribe RSS feed
Scroll To Top