473,394 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to pass more than 2 parameters in C#

Sorry about the code being hard to read, but I can assure you that it
did not look like that when I copied and pasted the message. I'm a
hardware engineer
who has only been using c# for a couple weeks now and must admit that
its been a long time since I've done any OO programming. But, all I want
to do is when the "Get Curves" button is clicked, for the event handler
to call the initializeIgnComm grabbing int[,] curveArray from my
CurveData class, and then use that data to plot. Thats all I want this
event handler to do. Get data, then plot it. Before messing with
delegates and event handlers and all
that this how I had my code. Of course I got the overloading error.
Ultimately the issue I am having is getting/passing the curveArray data
to the event handler.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.IO.Ports;
using System.Windows.Forms;
using System.Threading;
using PCComm;
using PortSet;
using ZedGraph;

namespace PCComm
{
public partial class frmMain : Form
{
CurveData comm = new CurveData();
string transType = string.Empty;

public frmMain()
{
InitializeComponent();
}

private void frmMain_Load(object sender, EventArgs e)
{
//SetDefaults();
}

# region MENU STRIP CONTROL

//<<<<<<<<< SERIAL PORT SETTINGS MENU >>>>>>>>>>//
private void settingsToolStripMenuItem_Click1(object sender,
EventArgs e)
{
// Make sure the port isn't already open
if (serialPort1.IsOpen)
{
MessageBox.Show("The port must be closed before changing
the settings.");
return;
}
else
{
// Create an instance of the settings form
PortSettings settings = new PortSettings();
if (settings.ShowDialog() == DialogResult.OK)
{
if (settings.selectedPort != "")
{
// Set the serial port to the new settings
serialPort1.PortName = settings.selectedPort;
serialPort1.BaudRate =
settings.selectedBaudrate;
showSettings();
}
else
{
MessageBox.Show("Error: Settings form returned
with no COM port selected.");
return; // bail out
}
}
else
{
MessageBox.Show("Error: buttonSetup_Click - Settings
dialog box did not return Okay.");
return; // bail out
}
// Open the port
try
{
serialPort1.Close();
serialPort1.Open();
menuStrip1.Items[1].Text = "Close Port";
showSettings();
}
catch (System.Exception ex)
{
MessageBox.Show("Error -
setupToolStripMenuItem_Click Exception: " + ex);
}
}
}

//<<<<<<<<< OPEN/CLOSE PORT BUTTON >>>>>>>>>>//
private void openPortToolStripMenuItem_Click(object sender,
EventArgs e)
{
try
{
if (serialPort1.IsOpen)
{
serialPort1.Close();
menuStrip1.Items[1].Text = "Open Port";
}
else
{
serialPort1.Open();
menuStrip1.Items[1].Text = "Close Port";
}

showSettings();
}
catch (System.Exception ex)
{
MessageBox.Show("Error - openPortToolStripMenuItem_Click
Exception: " + ex);
}
}

private void GroupBox1_Enter(object sender, EventArgs e)
{

}

//<<<<<<<<< GET CURVES BUTTON >>>>>>>>>>//
private void getCurvesToolStripMenuItem_Click(object sender,
EventArgs e, int[,] curveArray)
{
comm.DisplayWindow = rtbDisplay;
try
{
if (serialPort1.IsOpen)
{
comm.initializeIgnComm(serialPort1);
plotCurves(zedGraphControl1, curveArray);
}
else
{
MessageBox.Show("Error: COM port closed.");
return; // bail out
}
}
catch (System.Exception ex)
{
MessageBox.Show("Error - findIgnButton_Click Exception:
" + ex);
}

}
#endregion

# region CURVE ID HEADER
private void showSettings()
{
this.Text = "DYNATEK IGNITIONS - " +
serialPort1.PortName + " " +
serialPort1.BaudRate.ToString();
if (serialPort1.IsOpen)
{
this.Text += " - Port is open";
}
else
{
this.Text += " - Port is closed";
}
}
#endregion

# region GRAPH CURVES
private void zedGraphControl1_Load(object sender, EventArgs e)
{
}

private void plotCurves(ZedGraphControl zgc, int[,] curveArray)
{
GraphPane plotCurve = zgc.GraphPane; //Get a
reference to the GraphPane

// Set the Titles
plotCurve.Title.Text = "DFS726 IGNITION TIMING\n";
plotCurve.XAxis.Title.Text = "RPM(x100)";
plotCurve.YAxis.Title.Text = "Advance Angle(Degrees BTDC)";

PointPairList curve1 = new PointPairList(); //Create
curve1 list
sortData(curveArray); //Sort data into
list for plotting

LineItem ignCurve = plotCurve.AddCurve("WOT Curve 4",
curve1, Color.Red, SymbolType.Diamond);
zgc.AxisChange();

}
#endregion

//-------------------------------------------------
// SORT ARRAY DATA TO POINTS FUNCTION
//-------------------------------------------------
private PointPairList sortData(int[,] curveArray)
{
int numberOfCurves = 8;
int[,] advDegBTDC = new int[numberOfCurves,8];
int[,] rpmValues = new int[numberOfCurves,8];
int curveNumber = 0;
int arrayIndex = 0;
int genArrayIndex = 0;

// Copy data from rpmArray and advArray into rpmValues and
advDegBTDC arrays used for plots
for (curveNumber = 0; curveNumber < numberOfCurves;
curveNumber++)
{
for (arrayIndex = 0; arrayIndex < 8; arrayIndex++)
{
advDegBTDC[curveNumber,arrayIndex] =
curveArray[0,genArrayIndex];
rpmValues[curveNumber,arrayIndex] =
curveArray[1,genArrayIndex];
genArrayIndex++;
}
}
PointPairList list1 = new PointPairList();

// TEST: Just sending the first curve (8 data points) to
list1 to graph
for (int i = 0; i < 8; i++)
{
list1.Add(rpmValues[0,i], advDegBTDC[0,i]);
}
return list1;

}
}
}

*** Sent via Developersdex http://www.developersdex.com ***
Oct 31 '08 #1
2 2696
On Fri, 31 Oct 2008 09:47:28 -0700, dondigitech LaPel
<dl****@dynaonline.comwrote:
Sorry about the code being hard to read, but I can assure you that it
did not look like that when I copied and pasted the message. [...]
Is this related to the previous thread you started? Is this code in any
way different from the previous code you posted? Is there some particular
reason you are starting a new thread rather than following up in the
previous thread, where I already replied to a post that looks remarkably
similar to the one you just made?
Oct 31 '08 #2
"dondigitech LaPel" <dl****@dynaonline.comwrote in message
news:e8**************@TK2MSFTNGP04.phx.gbl...
Ultimately the issue I am having is getting/passing the curveArray data
to the event handler.
I'm going to reply in the original thread. Do NOT start multiple threads for
the same question. The regulars that are most likely to help you are also
very likely to be put off by this bad Netiquette.
Oct 31 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

110
by: Mr A | last post by:
Hi! I've been thinking about passing parameteras using references instead of pointers in order to emphasize that the parameter must be an object. Exemple: void func(Objec& object); //object...
7
by: Zlatko Matić | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the...
0
by: Zlatko Matić | last post by:
Hi everybody! Recently I was struggling with client/server issues in MS Access/PostgreSQL combination. Although Access is intuitive and easy to use desktop database solution, many problems...
3
by: JezB | last post by:
I know I can use the querystring mechanism to pass simple parameters to a Page using Response.Redirect, but Im having problems getting this to work using Server.Transfer or Server.Execute - is this...
14
by: Derek Basch | last post by:
This one has always bugged me. Is it better to just slap a "self" in front of any variable that will be used by more than one class method or should I pass around variable between the methods? ...
28
by: Bill | last post by:
Hello All, I am trying to pass a struct to a function. How would that best be accomplished? Thanks, Bill
12
by: ArunDhaJ | last post by:
Hi Friends, Is it possible to pass a table as a parameter to a funtion. whos function declaration would look some thing like this.... ALTER FUNCTION TempFunction (@TempTable TABLE, @nPId INT) ...
2
by: Tim Arnold | last post by:
Hi, I'm writing a command-line interface using optparse. The cli takes several options with a single action and several parameters to be used in the resulting worker classes. I've been passing...
24
by: =?Utf-8?B?U3dhcHB5?= | last post by:
Can anyone suggest me to pass more parameters other than two parameter for events like the following? Event: Onbutton_click(object sender, EventArgs e)" Event handler: button.Click += new...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.