Skip to content

Commit

Permalink
WPF-888586 Changes are added
Browse files Browse the repository at this point in the history
WPF-888586 Changes are added
  • Loading branch information
KarkuvelRajan committed Jun 11, 2024
1 parent 3301087 commit bd53484
Show file tree
Hide file tree
Showing 15 changed files with 721 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Samples/Stencil/StencilCustomCommands/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Stencil with Custom Commands
This repository contains sample which shows how can we Add or Remove commands from the Stencil's Command Manager.

__*Documentation*__: https://help.syncfusion.com/wpf/diagram/stencil

## 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,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StencilCustomCommand", "StencilCustomCommand\StencilCustomCommand.csproj", "{7E911D50-4FC4-4000-864F-B6746AD59C03}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Release-Xml|Any CPU = Release-Xml|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7E911D50-4FC4-4000-864F-B6746AD59C03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7E911D50-4FC4-4000-864F-B6746AD59C03}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7E911D50-4FC4-4000-864F-B6746AD59C03}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7E911D50-4FC4-4000-864F-B6746AD59C03}.Release|Any CPU.Build.0 = Release|Any CPU
{7E911D50-4FC4-4000-864F-B6746AD59C03}.Release-Xml|Any CPU.ActiveCfg = Release|Any CPU
{7E911D50-4FC4-4000-864F-B6746AD59C03}.Release-Xml|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5D803A3C-1FBA-4643-AB77-C8F08484C4DC}
EndGlobalSection
EndGlobal
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,9 @@
<Application x:Class="StencilCustomCommand.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:StencilCustomCommand"
StartupUri="MainWindow.xaml">
<Application.Resources>

</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 StencilCustomCommand
{
/// <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,103 @@
<Window xmlns:sf="http://schemas.syncfusion.com/wpf" x:Class="StencilCustomCommand.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:StencilCustomCommand"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800" WindowState="Maximized">

<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Syncfusion.SfDiagram.Wpf;component/Resources/BasicShapes.xaml"/>
</ResourceDictionary.MergedDictionaries>
<!--Style for node-->
<Style TargetType="sf:Node">
<Setter Property="ShapeStyle">
<Setter.Value>
<Style TargetType="Path">
<Setter Property="Fill" Value="CornflowerBlue"/>
<Setter Property="Stretch" Value="Fill"/>
<Setter Property="Stroke" Value="CornflowerBlue"/>
</Style>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</Window.Resources>

<Grid>

<Grid.ColumnDefinitions>
<ColumnDefinition Width="500"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>

<!--Stencil-->
<sf:Stencil x:Name="Stencil"
DisplayMode="Expanded"
ShowDisplayModeToggleButton="False"
ShowSearchTextBox="False"
SymbolsDisplayMode="IconsOnly"
ExpandMode="ZeroOrOne"
Grid.Column="0" Constraints="Default">
<sf:Stencil.Categories>
<sf:StencilCategoryCollection>
<sf:StencilCategory Title="Basic Shapes" Keys="{StaticResource BasicShapes}"/>
<sf:StencilCategory Title="Flow Shapes" Keys="{StaticResource FlowShapes}"/>
<sf:StencilCategory Title="Arrow Shapes" Keys="{StaticResource ArrowShapes}"/>
<sf:StencilCategory Title="DataFlow Shapes" Keys="{StaticResource DataFlowShapes}"/>
<sf:StencilCategory Title="UMLActivity Shapes" Keys="{StaticResource UMLActivity}"/>
<sf:StencilCategory Title="UMLUseCase Shapes" Keys="{StaticResource UMLUseCase}"/>
<sf:StencilCategory Title="UMLRelationship Shapes" Keys="{StaticResource UMLRelationship}"/>
<sf:StencilCategory Title="Swimlane Shapes" Keys="{StaticResource SwimlaneShapes}"/>
<sf:StencilCategory Title="BPMNEditor Shapes" Keys="{StaticResource BPMNEditorShapes}"/>
</sf:StencilCategoryCollection>
</sf:Stencil.Categories>
<sf:Stencil.SymbolGroups>
<sf:SymbolGroups>
<!--Separate groups based on the key-->
<sf:SymbolGroupProvider MappingName = "Key" />
</sf:SymbolGroups>
</sf:Stencil.SymbolGroups>
</sf:Stencil>

<sf:SfDiagram x:Name="Diagram" Grid.Column="1">

<sf:SfDiagram.Nodes>
<sf:NodeCollection/>
</sf:SfDiagram.Nodes>

<sf:SfDiagram.Connectors>
<sf:ConnectorCollection/>
</sf:SfDiagram.Connectors>

<sf:SfDiagram.Groups>
<sf:GroupCollection/>
</sf:SfDiagram.Groups>

<sf:SfDiagram.Swimlanes>
<sf:SwimlaneCollection/>
</sf:SfDiagram.Swimlanes>

<sf:SfDiagram.SnapSettings>
<sf:SnapSettings SnapConstraints="ShowLines"/>
</sf:SfDiagram.SnapSettings>

<sf:SfDiagram.HorizontalRuler>
<sf:Ruler />
</sf:SfDiagram.HorizontalRuler>

<sf:SfDiagram.VerticalRuler>
<sf:Ruler Orientation="Vertical"/>
</sf:SfDiagram.VerticalRuler>

<sf:SfDiagram.PageSettings>
<sf:PageSettings />
</sf:SfDiagram.PageSettings>

</sf:SfDiagram>

</Grid>
</Window>
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using StencilCustomCommand.Utility;
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 StencilCustomCommand
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();

AddCommand();
RemoveCommand();

}

ICommand CustomCommand;

private void AddCommand()
{
// Adding a custom command to the stencil CommandManager
CustomCommand = new Command(OnCustomCommand);
GestureCommand customCommmandGesture = new GestureCommand()
{
Command = CustomCommand,
Gesture = new Gesture
{
Key = Key.K,
KeyModifiers = ModifierKeys.Control,
KeyState = KeyStates.Down
},
Name = "Custom",
};
Stencil.CommandManager.Commands.Add(customCommmandGesture);
}
private void OnCustomCommand(object obj)
{
// Perform Operations
MessageBox.Show("Custom Command Executed Successfully!");
}

private void RemoveCommand()
{
// Removing a particular stencil command from the CommandManager
string commandName = "SelectAll";
IGestureCommand commandToBeRemoved = Stencil.CommandManager.Commands.FirstOrDefault(command => command.Name.Equals(commandName));
Stencil.CommandManager.Commands.Remove(commandToBeRemoved);
}

}
}
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("StencilCustomCommand")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StencilCustomCommand")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[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

0 comments on commit bd53484

Please sign in to comment.