473,394 Members | 1,722 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.

Anyone know vb.net and c#/ Conversion help please

Hi all Im converting code from vb.net to c# an im stuck again! :O)
anyway ive included both vb and c# versions and if anyone could see
where im going wrong it would much appreaciated.
i've tried to simplify the code as much as i can.

here is the vb first.

this displayHomePage() is first called from the new sub in frmShell.vb
class

Private Sub displayHomePage()
Try
Dim pg As Page
While history.Count > 0
pg = CType(history.Pop, Page)
pg.Dispose()
End While
If Not currentPage Is Nothing Then
currentPage.Dispose()
currentPage = Nothing
End If
Dim newPage As New HomePage()
currentPage = newPage
newPage.DisplayPage(Me)
Catch ex As System.Exception
ErrorHandler.GenericHandler(ex)
End Try

End Sub

//This is in a new class called page and overridden from two inherited
pages navigationpage and homepage.

Public Overridable Sub DisplayPage(ByRef myForm As frmMain)
myForm.currentPage = Me
Me.albumList = myForm.albumList
Me.detailList = myForm.detailList
Me.mainList = myForm.listNavigation
Me.sideList = myForm.sideNavigation
Me.softKeyboard = myForm.softKeyboard
Me.theForm = myForm

If Me.softKeyboard.Visible Then
Me.softKeyboard.Text = softKeyboardText
End If

If Me.albumList.Visible Then
Me.albumList.SelectedIndex = albumListSelectedIndex
End If

If Me.detailList.Visible Then
Me.detailList.SelectedIndex = detailListSelectedIndex
End If

If Me.mainList.Visible Then
Me.mainList.SelectedIndex = mainListSelectedIndex
End If

If Me.sideList.Visible Then
Me.sideList.SelectedIndex = sideListSelectedIndex
End If

Select Case hasFocus
Case "softKeyboard"
Me.softKeyboard.Focus()
Case "albumList"
Me.albumList.Focus()
Case "detailList"
Me.detailList.Focus()
Case "mainList"
Me.mainList.Focus()
Case "sideList"
Me.sideList.Focus()
End Select
End Sub
//The override in Navigation page

Public Overrides Sub DisplayPage(ByRef myForm As frmMain)
'handle events
With myForm
.HideControls()
.SetUpFullListView()
.listNavigation.DataSource = navArray
.listNavigation.Visible = True
.listNavigation.RightSelect = True
.listNavigation.Focus()
End With
MyBase.DisplayPage(myForm)
End Sub
//The override in Homepage

Public Overrides Sub DisplayPage(ByRef myForm As frmMain)
MyBase.DisplayPage(myForm)
myForm.wmp.Visible = True
myForm.SetUpHomeView()
End Sub
End Class

//this method in the page class handles an event on the homepage and
calls another method in the HomePage class. this is where i think
things go wrong in the c# version

Private Sub mainList_Selected(ByVal sSelected As String, ByVal Data
As Object) Handles mainList.Selected
Sounds.PlaySelectSound()
RaiseEvent MainListSelected(sSelected, Data)
End Sub

//this is the method it calls in the Homepage class

Private Sub HomePage_MainListSelected(ByVal sSelected As String, ByVal
Data As Object) Handles MyBase.MainListSelected
Debug.WriteLine("HomePage_MainListSelected")
Select Case sSelected
Case "Browse Artists"
Dim page2 As New ArtistListing()
Dim myForm As frmMain = Me.theForm
Me.SavePageState(Me.theForm)
Me.theForm.history.Push(Me)
Debug.WriteLine("HomePage Push")
page2.DisplayPage(myForm)
Case "Browse All Albums"
Dim page2 As New AlbumListPage()
Dim myForm As frmMain = Me.theForm
Me.SavePageState(Me.theForm)
Me.theForm.history.Push(Me)
Debug.WriteLine("HomePage Push")
page2.DisplayPage(myForm)

...........................
.......................
End Select
End Sub

when Me.SavePageState(Me.theForm) is called in the vb version its fine
and passes it but in the c# conversion it is null for some reason
Me.SavePageState(Me.theForm)

Anyway if anybody is still reading :O) here is the c# code in the same
order.

private void displayHomePage()
{
try
{
Page pg;
while (history.Count > 0)
{
pg = (Page) history.Pop();
pg.Dispose();
}
if (currentPage != null)
{
currentPage.Dispose();
currentPage = null;
}
HomePage newPage = new HomePage();
currentPage = newPage;
MusicXP.frmMain X = this;
newPage.DisplayPage(ref X);
}
catch (System.Exception ex)
{
ErrorHandler.GenericHandler(ex);
}

}
This is in the page class
public virtual void DisplayPage(ref frmMain myForm)
{
myForm.currentPage = this;
this.albumList = myForm.albumList;
this.detailList = myForm.detailList;
this.mainList = myForm.listNavigation;
this.sideList = myForm.sideNavigation;
this.softKeyboard = myForm.softKeyboard;
this.theForm = myForm;
this.mainList.Selected += new
dmControls.ListControl.SelectedEventHandler(mainLi st_Selected);
MainListSelectedEvent += new
MainListSelectedEventHandler(mainList_Selected);

//......................more event stuff here but i just
left one on show

if (this.softKeyboard.Visible)
{
this.softKeyboard.Text = softKeyboardText;
}if (this.albumList.Visible)
{
this.albumList.SelectedIndex = albumListSelectedIndex;
}if (this.detailList.Visible)
{
this.detailList.SelectedIndex = detailListSelectedIndex;
}if (this.mainList.Visible)
{
this.mainList.SelectedIndex = mainListSelectedIndex;
}if (this.sideList.Visible)
{
this.sideList.SelectedIndex = sideListSelectedIndex;
}
switch (hasFocus)
{
case "softKeyboard":
this.softKeyboard.Focus();
break;
case "albumList":
this.albumList.Focus();
break;
case "detailList":
this.detailList.Focus();
break;
case
"mainList":
this.mainList.Focus();
break;
case "sideList":
this.sideList.Focus();
break;
}
}
//the one in navigation page
public override void DisplayPage(ref frmMain myForm)
{
//handle events
frmMain with_1 = myForm;
with_1.HideControls();
with_1.SetUpFullListView();
with_1.listNavigation.DataSource = navArray;
with_1.listNavigation.Visible = true;
with_1.listNavigation.RightSelect = true;
with_1.listNavigation.Focus();
base.DisplayPage(ref
myForm);
}

//the one in Home page

public override void DisplayPage(ref frmMain myForm)
{
base.DisplayPage(ref myForm);
myForm.wmp.Visible = true;
myForm.SetUpHomeView();
}

//This is where i think it goes wrong because i have to create a new
homepage to call HomePage_MainListSelected

private void mainList_Selected(string sSelected, object Data)
{

Sounds.PlaySelectSound();
if (MainListSelectedEvent != null)
{
// frmMain tmp = this.theForm;
HomePage hp = new HomePage();
hp.HomePage_MainListSelected(sSelected, Data);
}
}
public void HomePage_MainListSelected(string sSelected, object Data)
{

MusicXP.Page page2;
Debug.WriteLine("HomePage_MainListSelected");
System.Diagnostics.Process proc;
frmMain myForm;
switch (sSelected)
{
case "Browse Artists":

page2 = new ArtistListing();
myForm = this.theForm;
this.SavePageState(ref this.theForm); //
<-----------this is where this.theForm is null and im not sure why?
this.theForm.history.Push(this);
Debug.WriteLine("HomePage Push");
page2.DisplayPage(ref myForm);
break;
case "Browse All Albums":

page2 = new AlbumListPage();
myForm = this.theForm;
this.SavePageState(ref myForm);
this.theForm.history.Push(this);
Debug.WriteLine("HomePage Push");
page2.DisplayPage(ref myForm);
break;

//..........................more here but you get the
idea
}
}
Ok i know thats really long but if anyone could help i would really
appreaciate it.
thank you very much
Bryan.

Mar 21 '06 #1
0 1082

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

Similar topics

30
by: Tim Johansson | last post by:
I'm new to C++, and tried to start making a script that will shuffle an array. Can someone please tell me what's wrong? #include <iostream.h> #include <string.h> int main () {...
6
by: Danny Lesandrini | last post by:
I'm using an Access database to drive a web site and the colors of various table backgrounds are stored in Access. I want users of the Access database to be able to select colors for the site, but...
0
by: Duane Phillips | last post by:
Evolution Access Converter Found at: http://www.evolutionsoft.co.uk Has anyone played with this? Is it any good? Scale on 1 to 100? I have a fairly complex MSAXP/2003 multi-app (multiple...
15
by: Anonymousgoogledeja | last post by:
Hi all, since the function atof, atoi, _atoi64, atol returned value are Return Values Each function returns the double, int, __int64 or long value produced by interpreting the input...
11
by: Steve Gough | last post by:
Could anyone please help me to understand what is happening here? The commented line produces an error, which is what I expected given that there is no conversion defined from type double to type...
8
by: Dgates | last post by:
Has anyone typed up an index for the O'Reilly book "C# and VB.NET Conversion?" I'm just learning C#, and often using this little book to see which VB.NET terms translate directly to some term in...
15
by: Pucca | last post by:
I'm getting an error when I tried to use this BerConverter class in my C# code. Even though the Interent doc says that it runs on Win2000 sp4, I just thgouth I'll double check. Does anyone know...
5
by: karmalax | last post by:
public static string Somme(string T) { string text1 = ""; double num5 = Strings.Len(T) + 1; int num3 = 7;
169
by: JohnQ | last post by:
(The "C++ Grammer" thread in comp.lang.c++.moderated prompted this post). It would be more than a little bit nice if C++ was much "cleaner" (less complex) so that it wasn't a major world wide...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.