Click here to Skip to main content
15,881,173 members
Articles / Programming Languages / C#

modds Drag and Drop Programming for C# Creating Class Library (DLL) - Part 5

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
20 Sep 2016CPOL3 min read 14.9K   284   6   6
Visual Programming Language

Introduction

Continue of modds Drag and Drop Programming for C# Debugging (Part 4) if you want some functions of modds visual program to be used in your big existing project, the modds Class Library Template can help to create .NET DLL which can be used in exiting Visual Studio Projects. In this article, we will create two independent DLLs and combine them in a Visual Studio Project to develop a Stock Chart Program.

Project Requirements

  • Modds C# Designer(from www.modds.org)
  • Microsoft Visual Studio
  • Windows 7 or above
  • .NET Framework 4.5.2 OR above

DLL Function Control

The DLL Function Control is the control that creates function interface for a Class Library Template DLL. The control can be found at modds IDE Control Toolbox->modds Common Controls->Module->DLL Function. This control can only work for Class Library Template. It can create an interface function with any number of parameters and with or without a return value.

Image 1

Stock Chart Program Example

In this example, we will create two independent DLLs (MarketDataYahoo.dll and MarketDataView.dll). The MarketDataYahoo.dll will have an interface function called “GetStockMarketData”. This function will take three parameters (Stock Symbol, Start Data, and End Date) and it does not return any values, instead, it will broadcast the market data values to “StockMarketData” message channel. Any other objects listening to the message channel can process it. The MarketDataView.dll will have an interface function called “CreateStockChartView”. This function will not take any parameters and it will return a stock chart view object. This object will listen to “StockMarketData” message channel. When there is a data updated, this object will display on its view. The object view can be data binded with a WPF ContentControl for UI display.

Image 2

MarketDataYahoo.dll

  1. Create a Class Library Project and name it “MarketDataYahoo
  2. Add “MarketData.dll” from download source (LIB) to References/ProgramDLL. The MarketData.dll is code from the previous example that gets the market data from yahoo.
  3. Crate a message channel and name it “StockMarketData
    • Right click on->Solution->MarketDataYahoo->Channels select Add namespace and name it “StockMarketData
    • Right click on “StockMarketData” and select Add Broadcast
  4. Delete “DLLClass.xsml” and create new Schema and name it “DataServer.xsml”. Double click to open.
  5. Double click Solution->MarketDataYahoo->References->ProgramDLL->MarketData.dll to open it on .NET DLL toolbox.
  6. Drag the following controls to design board and connect them as following image:
    • Control Toolbox->modds Common Controls->Module->DLL Function
    • .NET DLL Toolbox->MarketData.dll->Class->YahooMarketData->YahooDailyMarketData
    • Control Toolbox->modds Common Controls->Toolbox->Group Data
    • Solution->MarketDataYahoo->Channels->StockMarketData->Broadcast

Image 3

StockChartView.dll

  1. Create a Class Library Project and name it “StockChartView
  2. Add “ChartConrol.dll” from download source (LIB) to References/ProgramDLL. The ChartControl.dll is WFP stock chart control from the previous example.
  3. Add “MarketDataView.xaml” from download source (LIB) to SchemaView. The MarketDataView.xaml is the stock chart view design.
  4. Crate a message channel “StockMarketData”.
    • Right click on->Solution-> StockChartView ->Channels select Add namespace and name it “StockMarketData
    • Right click on “StockMarketData” and select Add Listener
  5. Delete “DLLClass.xsml” and create new Schema and name it “StockChartView.xsml”. Double click to open it.
  6. Drag the following controls to design board and connect them as following image:
    • Solution->StockChartView->SchemaView->MarketDataView.xaml
    • Solution->Channels->StockMarketData->Listener
    • Control Toolbox->modds Common Controls->Toolbox->Group Data
    • Control Toolbox->modds Common Controls->Toolbox->Ungroup Data
    • .NET DLL Toolbox->CSharpCommonLibrary->Primitive Type->Double
    • .NET DLL Toolbox->CSharpCommonLibrary->Class->DateTime
    • .NET DLL Toolbox->CSharpCommonLibrary->Class->Object
    • Properties->DataObjects(Data, Open, High, Low, and Last)

Image 4

Image 5

  1. Double click Solution-> StockChartView ->References->ProgramDLL->modds.LIB.dll to open it on .NET DLL toolbox.
  2. Create a new schema and name it “ObjectBuilder.xsml”. Double click to open it.
  3. Drag the following controls to design board and connect them as following image.
    • Control Toolbox->modds Common Controls->Module->DLL Function
    • Solution->StockChartView->Schema->StockChartView.xsml and select Module Id
    • .NET DLL Toolbox->modds.LIB.dll->Class->GeneralObject->CreateGeneralObject(Guid)
    • Return from DLL Function control

Image 6

Visual Studio Project

Create new WPF Application Project and add (MarketDataYahoo.dll and StockChartView) to References. Add the following code to complete the program.

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        chartContent.DataContext = StockChartView.ObjectBuilder.CreateStockChartView(); 
    }

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        string symbol = symbolBox.Text;
        DateTime startDate = (DateTime)startDatePicker.SelectedDate;
        DateTime endDate = (DateTime) endDatePicker.SelectedDate;
        MarketDataYahoo.DataServer.GetMarketData(symbol, startDate, endDate);
    }
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionI can not open the www.modds.org Pin
Member 102498248-Dec-17 20:58
Member 102498248-Dec-17 20:58 
QuestionWhat the status of the project? Pin
Member 278874428-Sep-16 11:37
Member 278874428-Sep-16 11:37 
AnswerRe: What the status of the project? Pin
douglas young28-Sep-16 14:28
douglas young28-Sep-16 14:28 
QuestionWhere is the other 4 parts? Pin
Member 278874427-Sep-16 0:12
Member 278874427-Sep-16 0:12 
AnswerRe: Where is the other 4 parts? Pin
douglas young28-Sep-16 3:15
douglas young28-Sep-16 3:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.