Changeset 1145


Ignore:
Timestamp:
Feb 16, 2010, 5:14:49 PM (12 years ago)
Author:
Patrick Vacek
Message:

PluginHowTo: further comprehensive revisions, i.e. grammar, formatting, labeling, clarity, etc.

Location:
trunk/Documentation/Developer/PluginHowTo
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Documentation/Developer/PluginHowTo/HowToDeveloper.tex

    r1141 r1145  
    1010\usepackage{url}
    1111\usepackage{wrapfig}
    12 \usepackage{color}
     12\usepackage[usenames,dvipsnames]{color}
    1313\usepackage{colortbl}
    1414\usepackage{eso-pic}
     
    1818%\usepackage[absolute]{textpos}
    1919
    20 \lstset{language=[Sharp]C, % Grundsprache ist C und Dialekt ist Sharp (C#)
    21 captionpos=b, % Beschriftung ist unterhalb
    22 frame=lines, % Oberhalb und unterhalb des Listings ist eine Linie
    23 basicstyle=\ttfamily, % Schriftart
    24 keywordstyle=\color{blue}, % Farbe für die Keywords wie public, void, object u.s.w.
    25 commentstyle=\color{green}, % Farbe der Kommentare
    26 stringstyle=\color{red}, % Farbe der Zeichenketten
    27 numbers=left, % Zeilennummern links vom Code
    28 numberstyle=\tiny, % kleine Zeilennummern
     20\lstset{language=[Sharp]C, % base language is C and dialect is Sharp (C#)
     21captionpos=b, % descriptions are underneath
     22frame=lines, % above und underneath the code listing are horizontal lines
     23basicstyle=\ttfamily, % font
     24keywordstyle=\color{blue}, % Color for keywords like public, void, object, etc.
     25commentstyle=\color{ForestGreen}, % Color for comments
     26stringstyle=\color{BrickRed}, % Color for strings
     27numbers=left, % line numbers to the left of the code
     28numberstyle=\tiny, % small line numbers
    2929numbersep=5pt,
    3030tabsize=2,
    31 breaklines=true, % Wordwrap a.k.a. Zeilenumbruch aktiviert
     31breaklines=true, % Wordwrap activated
    3232showstringspaces=false,
    33 % emph legt Farben für bestimmte Wörter manuell fest
     33% emph defines certain colors for specific words
    3434emph={double,bool,int,unsigned,char,true,false,void},
    3535emphstyle=\color{blue},
    3636emph={Assert,Test},
    37 emphstyle=\color{red},
     37emphstyle=\color{BrickRed},
    3838emph={[2]\using,\#define,\#ifdef,\#endif}, emphstyle={[2]\color{blue}}
    3939}
     
    4343%\pagestyle{headings}
    4444%\pagestyle{scrheadings}
    45 \pagestyle{fancy} %eigener Seitenstil
    46 \fancyhf{} %alle Kopf- und Fußzeilenfelder bereinigen
    47 \fancyhead[L]{\leftmark} %Kopfzeile links
    48 \fancyhead[C]{\AddToShipoutPicture*{\BackgroundHeaderPic}} %zentrierte Kopfzeile
    49 %\fancyhead[R]{\rightmark} %Kopfzeile rechts --> Removed because it's overflowing on the leftmark if the text is too long
     45\pagestyle{fancy} % self-made page style
     46\fancyhf{} % clear all header and footer fields
     47\fancyhead[L]{\leftmark} % left header
     48\fancyhead[C]{\AddToShipoutPicture*{\BackgroundHeaderPic}} % center header
     49%\fancyhead[R]{\rightmark} % right header --> Removed because it overflows on the leftmark if the text is too long
    5050
    51 \fancyfoot[C]{\thepage\AddToShipoutPicture*{\BackgroundFooterPic}} %zentrierte Fußzeile
    52 %\fancyfoot[EL,OR]{\thepage} %Seitennummer
     51\fancyfoot[C]{\thepage\AddToShipoutPicture*{\BackgroundFooterPic}} % center footer
     52%\fancyfoot[EL,OR]{\thepage} % page number
    5353%\fancyfoot[ER,OL]{\includegraphics[height=0.3cm]{figures/ct_logo}}
    5454
    55 \renewcommand{\headrulewidth}{2pt} %obere Trennlinie
    56 \renewcommand{\footrulewidth}{2pt} %untere Trennlinie
     55\renewcommand{\headrulewidth}{2pt} % upper separator
     56\renewcommand{\footrulewidth}{2pt} % lower separator
    5757
    5858\newlength{\headbgwidth}
     
    177177This document is intended for plugin developers who want to contribute new visual or mathematical functionality to CT2. As of January 2010, the code consists of about 7000 lines of C\# code in the core system and about 240,641 lines of C\# code in 115 plugins.
    178178
    179 
    180179For further news and more screenshots please see the developer page \htmladdnormallink{http://www.cryptool2.vs.uni-due.de}{http://www.cryptool2.vs.uni-due.de}.
    181180    \end{abstract}
    182181
    183182        \tableofcontents
    184 
    185183
    186184    \AddToShipoutPicture{\WaterMarkPic}
  • trunk/Documentation/Developer/PluginHowTo/part1.tex

    r1141 r1145  
    11\chapter{Developer Guidelines}
     2\label{DeveloperGuidelines}
    23
    34CrypTool 2.0 uses state-of-the-art technologies like .NET 3.5 and WPF. In order to make your first steps towards developing something in the context of this project, a few things need to be considered. First of all, please follow the instructions in this document so that you do not get stuck. If you encouter a problem or error that is not described here, please let us know so we can add the appropriate information to this guide.
     
    1112
    1213\section{Prerequisites}
     14\label{Prerequisites}
    1315
    1416Since CrypTool 2.0 is based on Microsoft .NET 3.5, you will need a Microsoft Windows environment. (Currently no plans exist for porting this project to mono or to other platforms.) We have successfully tested with \textbf{Windows XP} and \textbf{Windows Vista}.
     
    2123
    2224\section{Accessing Subversion (SVN)}
     25\label{AccessingSubversion}
    2326
    2427This section describes how to access our SVN repository and how to configure the basic settings.
    2528
    2629\subsection*{The CrypTool2 SVN URL}
     30\label{TheCrypTool2SVNURL}
    2731
    2832Our code repository is accessable at the following URL:
     
    3034\url{https://www.cryptool.org/svn/CrypTool2/}
    3135
    32 To access the repository, you must provide a username and password. If you are a guest and just want to download our source code you can use "anonymous" as the username and an empty password. If you are a registered developer, just use your provided username and password (which is the same as for this wiki).
     36To access the repository, you must provide a username and password. If you are a guest and just want to download our source code, you can use ``anonymous" as the username and an empty password. If you are a registered developer, just use your provided username and password (which is the same as for the wiki).
    3337
    34 \subsection*{Accessing the SVN repository with TortoiseSVN}
     38\subsection*{Accessing the repository with TortoiseSVN}
     39\label{AccessingTheRepositoryWithTortoiseSVN}
    3540
    36 As already mentioned, in order to use the SVN repository one of the best options is \href{http://www.tortoisesvn.net/}{TortoiseSVN}. Please install TortoiseSVN (unfortunately it will ask you to reboot, which you need to do) and then create somewhere on your computer a directory (for instance "Cryptool2") for storing the local working files. Right click on this directory and select "SVN Checkout" from the context menu. In the new appearing window you must enter the URL of the repository as given above. The "Checkout directory" should be filled in correctly. After that, just hit ok, accept the certificate (if necessary) and enter your user credentials or "anonymous" for guests. Also mark the checkbox for saving your crendentials otherwise you will be asked about them for every single file. Then hit ok, and now the whole CrypTool2 repository should be checked out into the given directory.
     41As mentioned above, in order to access the SVN repository one of the best options is \href{http://www.tortoisesvn.net/}{TortoiseSVN}. We will describe here how to use the basics of the program, although you should be able to use any SVN client in a similar fashion.
    3742
    38 Later on, if you just want to update (if there where changes in the repository) you can do this with right click on any directory within the working files and choose "SVN Update" from the context menu. If you changed a file you should choose "SVN Commit" from the context menu in order to upload your changes. Please always provide \textit{meaningfull descriptions} of your updates. You should commit your sources to our SVN repository as often as you can. This will ensure your interoperability with the rest of the project for further development.
     43First install TortoiseSVN (which unfortunately requires you to reboot your computer) and then create a directory (for instance ``CrypTool2") for storing the local working files somewhere on your computer. Right-click on this directory and select ``SVN Checkout" from the context menu. A window will appear in which you will be asked for the URL of the repository as given above. The ``Checkout directory" should already be filled in correctly with your new folder. Then just hit ok, accept the certificate (if necessary), and enter your login information as described above. Mark the checkbox for saving your credentials, or else you will be asked for them for every single file. Then hit ok, and now the whole CrypTool2 repository should be checked out into your chosen directory.
    3944
    40 A TortoiseSVN Tutorial can be found \href{http://www.mind.ilstu.edu/research/robots/iris4/developers/svntutorial}{here}.
     45Later on, if changes have been made in the repository and you want to update your working copy, you can do this by right-clicking on any directory within the working files and choosing ``SVN Update" from the context menu. If you are a registered developer, have changed a file, and want your changes to be reflected in the repository, you should choose ``SVN Commit" from the context menu to upload your changes. Please always provide \textit{meaningful descriptions} of your updates. You should commit your sources to our SVN repository as often as you can. This will ensure your interoperability with the rest of the project for further development.
     46
     47A TortoiseSVN tutorial can be found \href{http://www.mind.ilstu.edu/research/robots/iris4/developers/svntutorial}{here}.
    4148
    4249\subsection*{Ignore patterns}
     50\label{IgnorePatterns}
    4351
    44 In order to checkin only clean code, please use the following \textbf{ignore patterns}: \textit{"obj bin debug release *.pdb *.suo *.exe *.dll"}
     52Please only check in clean code by using the following \textbf{ignore patterns}:
    4553
    46 This basically means that you should never check-in compiled and user-generated files. As an example please do not check-in the entire bin/ and obj/ directories which Visual Studio generates. If you want to submit a component (binary file) despite the ignore patterns you can still add *.dll files by using the context menu and add that file explicitely -- but please be absolutely sure, that you know what you are doing.
     54\begin{center}
     55\textit{obj bin debug release *.pdb *.suo *.exe *.dll}
     56\end{center}
     57
     58This basically means that you should never check in compiled and user-generated files. For example, please do not check in the entire \textit{bin/} and \textit{obj/} directories that Visual Studio generates. If you want to submit a component (binary file) despite the ignore patterns you can still add \textit{*.dll} files by using the context menu and adding that file explicitly --- but please be absolutely sure that you know what you are doing.
    4759
    4860\section{Compiling the sources}
     61\label{CompilingTheSources}
    4962
    50 At this point you should have checked out the entire CrypTool repository. Then compiling is pretty easy, you just go to the directory \textit{trunk/} and open the \textbf{CrypTool 2.0.sln} Visual Studio solution. Now Visual Studio should open with all working plugins and all components nicely arranged. In case you started Visual Studio now for the very first time, you must choose a certain settings -- just select either "most common" or "C\#" -- you can change this at any time later. In the right hand you get the project explorer, where you see all the subprojects included in the solution. You have to look for the project \textbf{CrypWin.exe} there. When you found it, you need to right-click it and select \textbf{"Set as startup-project"} from the context menu. After you have done this, just go to the menu \textit{Build} and select \textit{Build solution} (clearly you can also use the hotkeys if you memorized them). Then go to \textit{Debug} and click \textit{Start debugging} -- now CrypTool 2.0 should start for the first time with your own compiled code -- clearly you did not change yet anything, however, you have now an own build of all components (with the exception of CrypWin and AnotherEditor, since they are available only as binary). In case it does not compile or start, please consult our \href{https://www.cryptool.org/trac/CrypTool2/wiki/FAQ}{F.A.Q.} and let us know if you found a bug.
     63By this point you should have checked out a copy of the entire CrypTool repository. Compiling is pretty easy; just go to the \textit{trunk/} directory and open the \textbf{\textit{CrypTool 2.0.sln}} Visual Studio solution. The Visual Studio IDE should open with all the working plugins components nicely arranged. In case you are now starting Visual Studio for the first time, you will have to choose your settings. Just select either ``most common" or ``C\#" --- you can change this at any time later. On the right side is the project explorer, where you can see all the subprojects included in the solution. Look for the project \textbf{\textit{CrypWin.exe}} there. Once you have found it, right-click on it and select ``Set as StartUp-Project" from the context menu. Next, go to the menu bar and select ``Build" $\rightarrow$ ``Build Solution". Then go to ``Debug" and select ``Start Debugging" --- now CrypTool 2.0 should start for the first time with your own compiled code. Presumably you have not changed anything yet, but you now have your own build of all the components (with the exception of CrypWin and AnotherEditor, since they are available only as binaries). If the program does not compile or start correctly, please consult our \href{https://www.cryptool.org/trac/CrypTool2/wiki/FAQ}{FAQ} and let us know if you found a bug.
    5164
    52 As a core-developer, hence somebody who can also compile CryWin and AnotherEditor, you should use the \textbf{CrypTool 2.0.sln} solution from the trunk/CoreDeveloper/ directory (this directory is \textbf{not} visible to you if you are not a core developer). As a core developer you should know, that when compiling you \textbf{change} the CryWin.exe which is visible to everybody else. Hence, when doing a checkin, please make sure you \textit{really} want to checkin a new binary.
     65If you are a core developer, hence somebody who can also compile CryWin and AnotherEditor, you should use the \textbf{\textit{CrypTool 2.0.sln}} solution from the \textit{trunk/CoreDeveloper/} directory (which will \textit{not} be visible to you if you are not a core developer). As a core developer, be aware that when you compile, you \textbf{change the \textit{CryWin.exe}} which is visible to everybody else. Thus, when doing a check-in, please make sure you \textit{really} want to check in a new binary.
  • trunk/Documentation/Developer/PluginHowTo/part2.tex

    r1141 r1145  
    11\chapter{Plugin Implementation}
    2 In this chapter we provide step-by-step instructions for implementing your own CrypTool 2.0 plugin. The given instructions refer mostly to the usage of MS Visual C\# 2008 Express Edition, hence before starting you should have installed your copy of Microsoft Visual Studio 2008 or Microsoft Visual C\# 2008 Express Edition.
    3 \section{New project}
    4 \label{sec:CreateANewProjectInVS2008ForYourPlugin}
    5 Open Visual Studio 2008 or C\# 2008 Express Edition and create a new project:\\
     2\label{sec:PluginImplementation}
     3In this chapter we provide step-by-step instructions for implementing your own CrypTool 2.0 plugin. The given instructions refer mostly to the usage of MS Visual C\# 2008 Express Edition, hence before starting you should have a copy of \textbf{Microsoft Visual Studio 2008} or \textbf{Microsoft Visual C\# 2008 Express Edition} installed on your computer. We will use the \textbf{Caesar cipher} (also known as the \textbf{shift cipher}) for our example implemenation.
     4
     5\section{Creating a new project}
     6\label{sec:CreatingANewProject}
     7
     8To begin, open Visual Studio 2008 or C\# 2008 Express Edition, go to the menu bar and select ``File"~$\rightarrow$ ``New" $\rightarrow$ ``Project\ldots ". The following window will appear:
     9
    610\begin{figure}[h!]
    711        \centering
    812                \includegraphics[width=1.00\textwidth]{figures/vs_create_new_project.jpg}
    9         \caption{Create New Visual Studio/C\# Express Project}
     13        \caption{Creating a new Visual Studio/C\# Express project.}
    1014        \label{fig:vs_create_new_project}
    11 \end{figure}\\
    12 Select ''.NET-Framework 3.5'' as the target framework (the Visual Studio Express edition don't provide this selection because it automatically chooses the actual target framework), and ''Class Library'' as default template to create a DLL file. Give the project a unique and significant name (here: ''Caesar''), and choose a location where to save (the Express edition will ask later for a save location when you close your project or your environment). Select the subdirectory ''CrypPlugins'' from your SVN trunk as location. Finally confirm by pressing the ''OK'' button.
     15\end{figure}
     16
     17If you are using Visual Studio 2008, select \textbf{``.NET-Framework 3.5"} as the target framework; the Express Edition will automatically choose the target framework. Then choose \textbf{``Class Library"} as the default template, as this will build the project as a DLL file. Give the project a unique and meaningful name (such as ``Caesar" in our case), and choose a location to save it to. (The Express Edition will ask for a save location later when you close your project or environment). Select the subdirectory ``CrypPlugins" from your SVN trunk as the location. Finally, confirm by pressing the ``OK" button. Note that creating a new project in this manner also creates a new solution into which the project is placed.
     18
    1319\begin{figure}[h!]
    1420        \centering
    1521                \includegraphics[width=0.80\textwidth]{figures/save_solution_csharp_express.JPG}
    16         \caption{Microsoft C\# Express Edition save solution dialog}
     22        \caption{The Microsoft C\# Express Edition Save Project dialog window.}
    1723        \label{fig:save_solution_csharp_express}
    18 \end{figure}\\
    19 Now your Visual Studio/C\# Express solution should look like this:\\
     24\end{figure}
     25
     26At this point, your Visual Studio\slash C\# Express solution should look like this:
     27
    2028\begin{figure}[h!]
    2129        \centering
    2230                \includegraphics[width=1.00\textwidth]{figures/solution_start_up.jpg}
    23         \caption{Start-Up solution}
     31        \caption{A newly created solution and project.}
    2432        \label{fig:solution_start_up}
    2533\end{figure}
     34\clearpage
     35
    2636\section{Interface selection}
    27 \label{sec:SelectTheInterfaceYourPluginWantsToServe}
    28 First we have to add a reference to the CrypTool library called ''CrypPluginBase.dll'' where all necessary CrypTool plugin interfaces are declared.
     37\label{sec:InterfaceSelection}
     38
     39First we must add a reference to the CrypTool library, \textbf{\textit{CrypPluginBase.dll}}, where all the necessary CrypTool plugin interfaces are declared.
    2940
    3041\begin{figure}[h!]
    3142        \includegraphics{figures/add_reference.jpg}
    32         \caption{Add new reference}
     43        \caption{Adding a new reference.}
    3344        \label{fig:add_reference}
    3445\end{figure}
    3546
    36 Make a right click in the Solution Explorer on the ''Reference'' item and choose ''Add Reference''.\\
     47Right-click in the Solution Explorer on the ``Reference" item and choose ``Add Reference". A window like the following should appear:
    3748
    3849\begin{figure}[h!]
    3950        \centering
    4051                \includegraphics{figures/add_pluginbase_source.jpg}
    41         \caption{Add reference PluginBase source code}
     52        \caption{Adding a reference to the PluginBase source code.}
    4253        \label{fig:add_pluginbase_source}
    4354\end{figure}
    44 
    45 Select the project ''CrypPluginBase''. If you don't have the CrypPluginBase source code, it's also possible to add a reference the the binary DLL. In this case browse to the path where the library file ''CrypPluginBase.dll'' is located e.g. ''C:\textbackslash Documents and Settings \textbackslash $<$Username$>$ \textbackslash My Documents\textbackslash Visual Studio  2008\textbackslash Projects\textbackslash CrypPluginBase\textbackslash bin\textbackslash Debug'') and select the library by double clicking the file or pressing the "OK" button.\\
    46 
    47 \textit{\small Note: You can also take the binary DLL which is located in the folder where the ''CrypWin.exe'' is placed when you download CrypTool2.}
    48 
    4955\clearpage
     56
     57Select the project ``CrypPluginBase". If you do not have the ``CrypPluginBase" source code, it is also possible to add a reference the the binary DLL. In this case browse to the path where the library file \textit{CrypPluginBase.dll} is located, e.g.\ \textit{C:\textbackslash Documents and Settings\textbackslash $<$Username$>$\textbackslash My Documents\textbackslash Visual Studio 2008\textbackslash Projects\textbackslash CrypPluginBase\textbackslash bin\textbackslash Debug} and select the library by double clicking the file or pressing the ``OK" button. (You can also select the binary DLL located in the folder where \textit{CrypWin.exe} was placed when you downloaded CrypTool2.)
     58
    5059\begin{figure}[h!]
    5160        \centering
    5261                \includegraphics{figures/browse_reference.jpg}
    53         \caption{Browse reference}
     62        \caption{Browsing for a reference.}
    5463        \label{fig:browse_reference}
    5564\end{figure}
    5665
    57 Besides the CrypPluginBase you need to add three assembly references (same way like the ''CrypPluginBase'' before by selecting the ''.NET'' tab) to provide the necessary ''Windows'' namespace for your \textbf{user control} functions called ''Presentation'' and "QuickWatchPresentation". Select the following .NET components:
     66Besides CrypPluginBase you will need to add three assembly references to provide the necessary ``Windows" namespaces for the \textbf{user control} functions ``Presentation" and ``QuickWatchPresentation". This can be done in the same manner as before with the ``CrypPluginBase" but by selecting the ``.NET" tab. Select the following .NET components:
    5867
    5968\begin{itemize}
     
    6877\begin{figure}[h!]
    6978                \includegraphics{figures/reference_tree.jpg}
    70         \caption{Reference tree}
     79        \caption{A reference tree with the essential components.}
    7180        \label{fig:reference_tree}
    7281\end{figure}
    7382
    74 If your plugin will be based on further libraries, you have to add them in the same way.
    75 \section{Modify project properties}\label{sec:ModifyProjectProperties}
    76 It is important to make two little changes in your plugin assembly to ensure a right import of your plugin in CrypTool 2.\\
    77 You will find your assembly file called ''AssemblyInfo.cs'' in in your solution tree view at the item ''Properties''. Make these two changes:
     83If your plugin will be based on other additional libraries, you can add them in the same way.
     84
     85\section{Modifing the project properties}
     86\label{sec:ModifyTheProjectProperties}
     87
     88It is important to make two small changes to your plugin's assembly data to make sure that it will be imported correctly into CrypTool 2. Go to the Solution Explorer and open ``AssemblyInfo.cs", which can be found in the ``Properties" folder. Make the following two changes:
     89
    7890\begin{itemize}
    79         \item Fit the attribute ''AssemblyVersion''
    80         \item Comment out the attribute ''AssemblyFileVersion''
     91        \item Change the attribute ``AssemblyVersion" to have the value ``2.0.*", and
     92        \item Comment out the attribute ``AssemblyFileVersion".
    8193\end{itemize}
    82 Usually your assembly code part could now look like this:
    83 \begin{lstlisting}
    84 [assembly: AssemblyVersion(''2.0.*'')]
    85 //[assembly: AssemblyFileVersion(''1.0.0.0'')]
    86 \end{lstlisting}
    87 \section{Create the classes for the algorithm and for its settings}\label{sec:CreateTheClassesForTheAlgorithmAndForItsSettings}
    88 In the next step we have to create two classes. The first class named ''Caesar'' has to inherit from IEncryption to provide an ecryption plugin. If you want to develop a Hash plugin your class has to inherit from IHash.
    89 The second class named ''CaesarSettings'' has to inherit from ISettings.
    90 \subsection{Create the class for the algorithm (Caesar)}\label{sec:CreateTheClassForTheAlgorithmCaesar}
    91 Visual Studio automatically creates a class which has the name ''Class1.cs''.  There are two ways to change the name to ''Caesar.cs'':
    92 \renewcommand{\labelitemi}{-}
     94
     95This section of your assembly file should now look something like this:
     96
     97\begin{lstlisting}
     98[assembly: AssemblyVersion("2.0.*")]
     99//[assembly: AssemblyFileVersion("1.0.0.0")]
     100\end{lstlisting}
     101
     102\section{Creating classes for the algorithm and its settings}
     103\label{sec:CreatingClassesForTheAlgorithmAndItsSettings}
     104
     105In the next step we will create two classes. The first class will be the main driver; we will call ours ``Caesar" since that is the name of the cipher that it will implement. In our case, this class has to inherit from IEncryption because it will be an ecryption plugin. If it was instead a hash plugin, this class should inherit from IHash. The second class will be used to store setting information for the plugin, and thus we will name ours ``CaesarSettings". It has to inherit from ISettings.
     106\clearpage
     107
     108\subsection{Creating a class for the algorithm}
     109\label{sec:CreatingAClassForTheAlgorithm}
     110
     111When starting a new project, Visual Studio automatically creates a class which has the name ``Class1.cs".  Since this is a rather non-descriptive name, we will change it. In our example, it should be ``Caesar.cs". There are two ways to change the name:
     112
    93113\begin{itemize}
    94         \item Rename the existent class
    95         \item Delete the existent class and create a new one.
    96 \end{itemize}\clearpage
    97 Which one you choose is up to you. We choose the second way as you can see in the next screenshot:
     114        \item Rename the existing class, or
     115        \item Delete the existing class and create a new one.
     116\end{itemize}
     117%\clearpage
     118
     119Both options will achieve the same results. We will guide you through the second method. First, delete ``Class1.cs".
     120
    98121\begin{figure}[h!]
    99122        \centering
    100123                \includegraphics{figures/new_class.jpg}
    101         \caption{Create new class}
     124        \caption{Deleting a class.}
    102125        \label{fig:new_class}
    103 \end{figure}\clearpage
    104 Now make a right click on the project item "Caesar" and select "Add-$>$Class...":
     126\end{figure}
     127\clearpage
     128
     129Then right-click on the project item (in our case, ``Caesar") and select ``Add $\rightarrow$ Class\ldots ":
     130
    105131\begin{figure}[h]
    106132        \centering
    107133                \includegraphics{figures/add_new_class.jpg}
    108         \caption{Add a new class}
     134        \caption{Adding a new class.}
    109135        \label{fig:add_new_class}
    110 \end{figure}\clearpage
    111 Now give your class a unique name. We call the class as mentioned above "Caesar.cs" and make it public to be available to other classes.
     136\end{figure}
     137\clearpage
     138
     139Finally, give your class a unique name. We will call our class ``Caesar.cs" and define it as public so that it will be available to other classes.
     140
    112141\begin{figure}[h!]
    113142        \centering
    114143                \includegraphics[width=1.00\textwidth]{figures/name_new_class.jpg}
    115         \caption{Name the new class}
     144        \caption{Naming the new class.}
    116145        \label{fig:name_new_class}
    117146\end{figure}
    118 \subsection{Create the class for the settings (CaesarSettings)}\label{sec:CreateTheClassForTheSettingsCaesarSettings}
    119 Add a second public class for ISettings in the same way. We call the class "CaesarSettings". The settings class provides the necessary information about controls, captions and descriptions and default parameters for e.g. key settings, alphabets, key length and action to build the \textbf{TaskPane} in CrypTool.\clearpage
    120 How a \textbf{TaskPane} could look like you can see below for the example of a Caesar encryption.\\
     147
     148\subsection{Creating a settings class}
     149\label{sec:CreatingASettingsClass}
     150
     151Add a second public class in the same way. We will call the class ``CaesarSettings". The settings class stores the necessary information about controls, captions, descriptions and default parameters (e.g.\ for key settings, alphabets, key length and type of action) to build the \textbf{TaskPane} in the CrypTool application.
     152\clearpage
     153
     154Below is an example of what a completed TaskPane for the existing Caesar plugin in CrypTool 2 looks like:
     155
    121156\begin{figure}[h!]
    122157        \centering
    123158                \includegraphics{figures/task_pane.jpg}
    124         \caption{TaskPane}
     159        \caption{The completed TaskPane for the existing Caesar plugin.}
    125160        \label{fig:task_pane}
    126 \end{figure}\\
    127 \subsection{Add namespace for the class Caesar and the place from where to inherit}
    128 \label{sec:AddNamespaceForTheClassCaesarAndThePlaceFromWhereToInherit}
    129 Now open the ''Caesar.cs'' file by double clicking on it at the Solution Explorer and include the necessary namespaces to the class header by typing in the according ''using'' statement. The CrypTool 2.0 API provides the following namespaces:
     161\end{figure}
     162\clearpage
     163
     164\subsection{Adding the namespaces and inheritance sources for the Caesar class}
     165\label{sec:AddingTheNamespacesAndInheritanceSourcesForTheCaesarClass}
     166
     167Open the ``Caesar.cs" file by double clicking on it in the Solution Explorer. To include the necessary namespaces in the class header, use the ``using" statement followed by the name of the desired namespace. The CrypTool 2.0 API provides the following namespaces:
     168
    130169\begin{itemize}
    131         \item Cryptool.PluginBase = interfaces like IPlugin, IHash, ISettings, attributes, enumerations, delegates and extensions.
    132         \item Cryptool.PluginBase.Analysis = interface for the crypto analysis plugins like ''Stream Comparator''
    133         \item Cryptool.PluginBase.Control = contains global interfaces for the IControl feature to define own controls
    134         \item Cryptool.PluginBase.Cryptography = interface for all encryption and hash algorithms like AES, DES or MD5 hash
    135         \item Cryptool.PluginBase.Editor = interface for editors you want to implement for CrypTool 2.0 like the default editor
    136         \item Cryptool.PluginBase.Generator = interface for generators like the random input generator
    137         \item Cryptool.PluginBase.IO = interface for CryptoolStream, input and output plugins like text input, file input, text output and file output
    138         \item Cryptool.PluginBase.Miscellaneous = provides all event helper like GuiLogMessage or PropertyChanged
    139         \item Cryptool.PluginBase.Resources = used by CrypWin and the editor. Not required for plugin developers
    140         \item Cryptool.PluginBase.Tool = interface for all foreign tools which CrypTool 2.0 has to provide and which does not exactly support the CrypTool 2.0 API
    141         \item Cryptool.PluginBase.Validation = interface which provides method for validation like regular expression
     170        \item Cryptool.PluginBase --- contains interfaces such as IPlugin, IHash, and ISettings, as well as attributes, enumerations, delegates and extensions.
     171        \item Cryptool.PluginBase.Analysis --- contains interfaces for cryptanalysis plugins (such as ``Stream Comparator").
     172        \item Cryptool.PluginBase.Control --- contains global interfaces for the IControl feature for defining custom controls.
     173        \item Cryptool.PluginBase.Cryptography --- contains interfaces for encryption and hash algorithms such as AES, DES and MD5.
     174        \item Cryptool.PluginBase.Editor --- contains interfaces for editors that can be implemented in CrypTool 2.0, such as the default editor.
     175        \item Cryptool.PluginBase.Generator --- contains interfaces for generators, including the random input generator.
     176        \item Cryptool.PluginBase.IO --- contains interfaces for input, output and the CryptoolStream.
     177        \item Cryptool.PluginBase.Miscellaneous --- contains assorted helper classes, including \textit{GuiLogMessage} and \textit{PropertyChanged}.
     178        \item Cryptool.PluginBase.Resources --- used only by CrypWin and the editor; not necessary for plugin development.
     179        \item Cryptool.PluginBase.Tool --- contains an interface for all external tools implemented by CrypTool 2.0 that do not entirely support the CrypTool 2.0 API .
     180        \item Cryptool.PluginBase.Validation --- contains interfaces for validation methods, including regular expressions.
    142181\end{itemize}
    143 In this case we want to implement a Caesar algorithm which means we need to include the following namespaces:
     182
     183In our example, the Caesar algorithm necessitates the inclusion of the following namespaces:
     184
    144185\begin{itemize}
    145         \item ''Cryptool.PluginBase'' to provide ''ISettings'' for the CaesarSettings class
    146         \item ''Cryptool.PluginBase.Cryptography'' to provide ''IEncryption'' for the Caesar class
    147         \item ''Cryptool.PluginBase.IO'' to provide CryptoolStream for the input and output Data
    148         \item ''Cryptool.PluginBase.Miscellaneous'' to use the entire CrypTool event handler
     186        \item ''Cryptool.PluginBase'' --- to provide ''ISettings'' for the CaesarSettings class
     187        \item ''Cryptool.PluginBase.Cryptography'' --- to provide ''IEncryption'' for the Caesar class
     188        \item ''Cryptool.PluginBase.IO'' --- to provide CryptoolStream for the input and output Data
     189        \item ''Cryptool.PluginBase.Miscellaneous'' --- to use the entire CrypTool event handler
    149190\end{itemize}
     191
    150192It is important to define a new default namespace of our public class (''Caesar''). In CrypTool the default namespace is presented by ''Cryptool.[name of class]''. Therefore our namespace has to be defined as follows: ''Cryptool.Caesar''.\clearpage
     193
    151194Up to now the source code should look as you can see below:
     195
    152196\begin{lstlisting}
    153197using System.Collections.Generic;
     
    176220}
    177221\end{lstlisting}
    178 \subsection{Add the interface functions for the class Caesar}\label{sec:AddTheInterfaceFunctionsForTheClassCaesar}
     222\subsection{Add the interface functions for the class Caesar}
     223\label{sec:AddTheInterfaceFunctionsForTheClassCaesar}
    179224There is an underscore at the ''I'' in IEncryption statement. Move your mouse over it or place the cursor at it and press ''Shift+Alt+F10'' and you will see the following submenu:
    180225\begin{figure}[h!]
     
    839884        #endregion
    840885\end{lstlisting}
    841 Please notice if there is a sinuous line at the code you type for example at the ''CryptoolStream'' type of the variable listCryptoolStreamsOut. ''CryptoolStream'' is a data type for input and output between plugins and is able to handle large data amounts. To use the CrypTool own stream type, include the namespace ''Cryptool.PluginBase.IO'' with a ''using'' statement as explained in chapter \ref{sec:AddNamespaceForTheClassCaesarAndThePlaceFromWhereToInherit}. Check the other code entries while typing and update the missing namespaces.\\
     886Please notice if there is a sinuous line at the code you type for example at the ''CryptoolStream'' type of the variable listCryptoolStreamsOut. ''CryptoolStream'' is a data type for input and output between plugins and is able to handle large data amounts. To use the CrypTool own stream type, include the namespace ''Cryptool.PluginBase.IO'' with a ''using'' statement as explained in chapter \ref{sec:CaesarNamespacesAndInheritance}. Check the other code entries while typing and update the missing namespaces.\\
    842887The following private variables are being used in this example:
    843888\begin{itemize}
     
    13081353        \caption{Plugin sample}
    13091354        \label{fig:sample}
    1310 \end{figure} 
     1355\end{figure}
Note: See TracChangeset for help on using the changeset viewer.