Skip to content
Merged
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
12 changes: 12 additions & 0 deletions Samples/Commands/RemoveDefaultCommands/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# RemoveDefaultCommands sample
This sample demonstrate how to remove the default commands from the diagram commands.

__*Documentation*__: https://help.syncfusion.com/wpf/diagram/commands#custom-command
## 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,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
</startup>
</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Application x:Class="CustomCommand.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:CustomCommand"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Syncfusion.SfDiagram.Wpf;component/Resources/BindingStyle.xaml" />
<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 CustomCommand
{
/// <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,76 @@
<Window x:Class="CustomCommand.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:CustomCommand"
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"

mc:Ignorable="d"
WindowState="Maximized"
Title="MainWindow" Height="350" Width="525">

<Window.Resources>
<!--Style for Node-->
<Style TargetType="syncfusion:Node">
<Setter Property="Shape" Value="{StaticResource Rectangle}"/>
<Setter Property="ShapeStyle">
<Setter.Value>
<Style TargetType="Path">
<Setter Property="Fill" Value="#6BA5D7"/>
<Setter Property="Stretch" Value="Fill"/>
<Setter Property="Stroke" Value="White"/>
<Setter Property="StrokeThickness" Value="1"/>
</Style>
</Setter.Value>
</Setter>
</Style>

<!--Style for Connector-->
<Style TargetType="syncfusion:Connector">
<Setter Property="ConnectorGeometryStyle">
<Setter.Value>
<Style TargetType="Path">
<Setter Property="Stroke" Value="#FF5B9BD5" />
<Setter Property="StrokeThickness" Value="1" />
</Style>
</Setter.Value>
</Setter>
<Setter Property="TargetDecoratorStyle" >
<Setter.Value>
<Style TargetType="Path">
<Setter Property="Fill" Value="#6BA5D7" />
<Setter Property="Stroke" Value="#6BA5D7" />
<Setter Property="StrokeThickness" Value="1" />
<Setter Property="Width" Value="10" />
<Setter Property="Height" Value="10" />
<Setter Property="Stretch" Value="Fill" />
</Style>
</Setter.Value>
</Setter>
</Style>

</Window.Resources>

<Grid>
<!--Initialize the Diagram-->
<syncfusion:SfDiagram x:Name="diagram" PortVisibility="Visible" >
<!--Initialize the Node collection-->
<syncfusion:SfDiagram.Nodes>
<syncfusion:NodeCollection>
<!--Initialize the Node-->
<syncfusion:NodeViewModel ID="node1" UnitHeight="50" UnitWidth="100" OffsetX="200" OffsetY="200"/>
<!--Initialize the Node-->
<syncfusion:NodeViewModel ID="node2" UnitHeight="50" UnitWidth="100" OffsetX="400" OffsetY="200"/>
</syncfusion:NodeCollection>
</syncfusion:SfDiagram.Nodes>
<!--Initialize the Connector collection-->
<syncfusion:SfDiagram.Connectors>
<syncfusion:ConnectorCollection>
<!--Initialize the Connector-->
<syncfusion:ConnectorViewModel SourceNodeID="node1" TargetNodeID="node2"/>
</syncfusion:ConnectorCollection>
</syncfusion:SfDiagram.Connectors>
</syncfusion:SfDiagram>
</Grid>
</Window>
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using Microsoft.Win32;
using Syncfusion.UI.Xaml.Diagram;
using Syncfusion.UI.Xaml.Diagram.Controls;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
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 CustomCommand
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
diagram.Loaded += Diagram_Loaded;

}

private void Diagram_Loaded(object sender, RoutedEventArgs e)
{
if (diagram != null)
{

string MoveRightCommand = "MoveRight";
var RightcommandToBeRemoved = diagram.CommandManager.Commands.FirstOrDefault(command => command.Name != null && command.Name.Equals(MoveRightCommand));
if (RightcommandToBeRemoved != null)
{
diagram.CommandManager.Commands.Remove(RightcommandToBeRemoved);
}


string MoveLeftCommand = "MoveLeft";
var LeftcommandToBeRemoved = diagram.CommandManager.Commands.FirstOrDefault(command => command.Name != null && command.Name.Equals(MoveLeftCommand));
if (LeftcommandToBeRemoved != null)
{
diagram.CommandManager.Commands.Remove(LeftcommandToBeRemoved);
}

string MoveUpCommand = "MoveUp";
var UpcommandToBeRemoved = diagram.CommandManager.Commands.FirstOrDefault(command => command.Name != null && command.Name.Equals(MoveUpCommand));
if (UpcommandToBeRemoved != null)
{
diagram.CommandManager.Commands.Remove(UpcommandToBeRemoved);
}


string MoveDownCommand = "MoveDown";
var DowncommandToBeRemoved = diagram.CommandManager.Commands.FirstOrDefault(command => command.Name != null && command.Name.Equals(MoveDownCommand));
if (DowncommandToBeRemoved != null)
{
diagram.CommandManager.Commands.Remove(DowncommandToBeRemoved);
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("CustomCommand")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CustomCommand")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.

//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]


[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]


// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading