Skip to content

WPF-865519 Sample is added for How to enable or disable the stencil symbol KB #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# How to adjust node position placed on page breaks sample

This sample demonstrates How to adjust node position placed on page breaks.

__*Documentation*__: https://help.syncfusion.com/wpf/diagram/page-settings

## Project pre-requisites

To run this application, you need to have the below two in your system

* [Visual Studio 2019](https://www.visualstudio.com/wpf-vs)
* [Syncfusion.SfDiagram.WPF](https://www.nuget.org/packages/Syncfusion.SfDiagram.WPF/) nuget package. To install the package using NuGet Package Manager, refer this [link](https://docs.microsoft.com/en-us/nuget/quickstart/install-and-use-a-package-in-visual-studio#nuget-package-manager).

## Deploying and running the sample

* To debug the sample and then run it, press F5 or select Debug > Start Debugging. To run the sample without debugging, press Ctrl+F5 or selectDebug > Start Without Debugging.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>

</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Application x:Class="PageBreaksSample.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:PageBreaksSample"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!--Initialize Shapes-->
<ResourceDictionary Source="/Syncfusion.SfDiagram.Wpf;component/Resources/BasicShapes.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace PageBreaksSample
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<Window x:Class="PageBreaksSample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:PageBreaksSample"
xmlns:sync="http://schemas.syncfusion.com/wpf"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Window.Resources>

<Style TargetType="Path" x:Key="connectorstyle">
<Setter Property="Stroke" Value="Blue"/>
<Setter Property="StrokeThickness" Value="2"></Setter>
</Style>
<Style TargetType="Path" x:Key="targetdecorator">
<Setter Property="Width" Value="10"/>
<Setter Property="Height" Value="10"/>
<Setter Property="Stroke" Value="Blue"/>
<Setter Property="Fill" Value="Blue"></Setter>
<Setter Property="Stretch" Value="Fill"></Setter>
</Style>
<Style TargetType="Path" x:Key="nodestyle">
<Setter Property="Fill" Value="Gray"></Setter>
<Setter Property="Stretch" Value="Fill"></Setter>
</Style>
<Style TargetType="sync:Node">
<Setter Property="ShapeStyle">
<Setter.Value>
<Style TargetType="Path">
<Setter Property="Fill" Value="#FF5B9BD5"></Setter>
<Setter Property="Stretch" Value="Fill"></Setter>
</Style>
</Setter.Value>
</Setter>
</Style>

<DataTemplate x:Key="TitleTemplate">
<TextBlock x:Name="HeaderText" Text="{Binding}" FontSize="15" FontWeight="SemiBold" Foreground="#2b579a" >
</TextBlock>
</DataTemplate>
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"></ColumnDefinition>

</Grid.ColumnDefinitions>

<Grid Grid.Column="0">

<sync:Stencil BorderBrush="#dfdfdf" Title="Shapes" BorderThickness="1" Width="250" x:Name="stencil" Grid.Row="1" ShowDisplayModeToggleButton="True" TitleTemplate="{StaticResource TitleTemplate}"
ExpandMode="ZeroOrMore" ShowSearchTextBox="True" >
<!--Initialize the stencil categories-->
<sync:Stencil.Categories>
<sync:StencilCategoryCollection>
<!--Specify the basic shapes category with title and resource key-->
<sync:StencilCategory Title="Basic Shapes" Keys="{StaticResource BasicShapes}"/>
</sync:StencilCategoryCollection>
</sync:Stencil.Categories>

<sync:Stencil.SymbolGroups>
<sync:SymbolGroups>
<!--Separate groups based on the key-->
<sync:SymbolGroupProvider MappingName="Key"/>
</sync:SymbolGroups>
</sync:Stencil.SymbolGroups>
</sync:Stencil>
</Grid>
<Grid Grid.Column="1">
<sync:SfDiagram x:Name="diagram">
<sync:SfDiagram.Nodes>
<sync:NodeCollection></sync:NodeCollection>
</sync:SfDiagram.Nodes>
<sync:SfDiagram.Connectors>
<sync:ConnectorCollection/>
</sync:SfDiagram.Connectors>
<sync:SfDiagram.Groups>
<sync:GroupCollection></sync:GroupCollection>
</sync:SfDiagram.Groups>
</sync:SfDiagram>
</Grid>

</Grid>

</Window>
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
using Syncfusion.UI.Xaml.Diagram;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace PageBreaksSample
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
diagram.PageSettings.PageWidth = 1000;
diagram.PageSettings.PageHeight = 1000;
diagram.PageSettings.PrintMargin = new Thickness(0);

diagram.HorizontalRuler = new Syncfusion.UI.Xaml.Diagram.Controls.Ruler() { };
diagram.VerticalRuler = new Syncfusion.UI.Xaml.Diagram.Controls.Ruler() { Orientation = Orientation.Vertical };
diagram.PageSettings.ShowPageBreaks = true;
(diagram.Info as IGraphInfo).ItemDropEvent += MainWindow_ItemDropEvent;

}

private void MainWindow_ItemDropEvent(object sender, ItemDropEventArgs args)
{
//For Offset X

//Store the Offset value for move the Node Offset
var OldOffsetX = (args.Source as NodeViewModel).OffsetX;

//Rounded off the Offset value
var RoundedNumberX = Math.Round((args.Source as NodeViewModel).OffsetX);

var numberX = RoundedNumberX / diagram.PageSettings.PageWidth;

//Convert to string
var numberStringX = numberX.ToString();

//Find the index value of the decimal point
var decimalIndexForX = numberStringX.IndexOf('.');

//Get the values after the decimal index if the index is -1 i have change this to 1
var stringAfterDecimalForX = decimalIndexForX != -1 ? numberStringX.Substring(decimalIndexForX + 1) : "1";

//Covert the string to int
int finalNumberX = int.Parse(stringAfterDecimalForX);

if (args.Source is INode)
{
if ((args.Source as NodeViewModel).OffsetX > (diagram.PageSettings.PageWidth/2))
{
//Move the dropped node if the off set value is less than 1000
if (finalNumberX >= (diagram.PageSettings.PageWidth - (args.Source as NodeViewModel).UnitWidth)) //&& num1 < diagram.PageSettings.PageWidth)
{
(args.Source as NodeViewModel).OffsetX = OldOffsetX - (args.Source as NodeViewModel).UnitWidth;

}
//Move the dropped node if the off set value is greater than or equal 1000
if (finalNumberX >= 1 && finalNumberX < (args.Source as NodeViewModel).UnitWidth)
{
(args.Source as NodeViewModel).OffsetX = OldOffsetX + (args.Source as NodeViewModel).UnitWidth;
}
}
}


//For Offset Y

//Store the Offset value for move the Node Offset
var OldOffsetY = (args.Source as NodeViewModel).OffsetY;

//Rounded off the Offset value
var RoundedNumberY = Math.Round((args.Source as NodeViewModel).OffsetY);

var numberY = RoundedNumberY / diagram.PageSettings.PageWidth;

//Convert to string
var numberStringY = numberY.ToString();

//Find the index value of the decimal point
var decimalIndexForY = numberStringY.IndexOf('.');

//Get the values after the decimal index if the index is -1 i have change this to 1
var stringAfterDecimalForY = decimalIndexForY != -1 ? numberStringY.Substring(decimalIndexForY + 1) : "1";

//Covert the string to int
int finalNumberY = int.Parse(stringAfterDecimalForY);

if (args.Source is INode)
{
//Move the dropped node if the off set value is less than 1000
if (finalNumberY >= (diagram.PageSettings.PageWidth - (args.Source as NodeViewModel).UnitWidth))
{
(args.Source as NodeViewModel).OffsetY = OldOffsetY - (args.Source as NodeViewModel).UnitWidth;
}
//Move the dropped node if the off set value is greater than or equal 1000
if (finalNumberY >= 1 && finalNumberY < (args.Source as NodeViewModel).UnitWidth)
{
(args.Source as NodeViewModel).OffsetY = OldOffsetY + (args.Source as NodeViewModel).UnitWidth;
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{399C2FDD-ECB2-4587-8F75-99B27D9D6085}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>PageBreaksSample</RootNamespace>
<AssemblyName>PageBreaksSample</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Syncfusion.Licensing, Version=24.2460.3.0, Culture=neutral, PublicKeyToken=632609b4d040f6b4, processorArchitecture=MSIL">
<HintPath>packages\Syncfusion.Licensing.24.2.3\lib\net46\Syncfusion.Licensing.dll</HintPath>
</Reference>
<Reference Include="Syncfusion.SfDiagram.WPF, Version=24.2460.3.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
<HintPath>packages\Syncfusion.SfDiagram.WPF.24.2.3\lib\net46\Syncfusion.SfDiagram.WPF.dll</HintPath>
</Reference>
<Reference Include="Syncfusion.Shared.WPF, Version=24.2460.3.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
<HintPath>packages\Syncfusion.Shared.WPF.24.2.3\lib\net46\Syncfusion.Shared.WPF.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Loading