C# Calendar Conversion [FIXED]

Converting a project I found to VB.NET

Page 1 of 1

3 Replies - 1855 Views - Last Post: 03 September 2009 - 10:20 PM Rate Topic: -----

#1 CakeMaker  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 69
  • Joined: 20-August 09

C# Calendar Conversion [FIXED]

Posted 03 September 2009 - 07:45 PM

After running into much difficulty getting started on my little planner attachment, I found this C# program (calendar_src) floating around on the net...somewhere. So I have been working on trying to convert this from C# to VB, which I have been using an online converter (http://www.developerfusion.com/tools/convert/csharp-to-vb/). From what I know I have been going through and trying to edit the code after it has been converted to VB code as best as I can. But now I have limited the errors from over 50 to these:

Error	1	Overload resolution failed because no accessible 'DrawLine' can be called without a narrowing conversion:
	'Public Sub DrawLine(pen As System.Drawing.Pen, x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer)': Argument matching parameter 'y1' narrows from 'Double' to 'Integer'.
	'Public Sub DrawLine(pen As System.Drawing.Pen, x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer)': Argument matching parameter 'y2' narrows from 'Double' to 'Integer'.
	'Public Sub DrawLine(pen As System.Drawing.Pen, x1 As Single, y1 As Single, x2 As Single, y2 As Single)': Argument matching parameter 'y1' narrows from 'Double' to 'Single'.
	'Public Sub DrawLine(pen As System.Drawing.Pen, x1 As Single, y1 As Single, x2 As Single, y2 As Single)': Argument matching parameter 'y2' narrows from 'Double' to 'Single'.	C:\Documents and Settings\UDM\My Documents\Visual Studio 2008\Projects\DayView\DayView\Office12Renderer.vb	92	17	DayView

Error	2	Class 'SelectionTool' must implement 'Property DayView() As DayView' for interface 'ITool'. Implementing property must have matching 'ReadOnly' or 'WriteOnly' specifiers.	C:\Documents and Settings\UDM\My Documents\Visual Studio 2008\Projects\DayView\DayView\SelectionTool.vb	9	20	DayView

Error	3	Class 'SelectionTool' must implement 'Sub MouseDown(e As System.Windows.Forms.MouseEventArgs)' for interface 'ITool'.	C:\Documents and Settings\UDM\My Documents\Visual Studio 2008\Projects\DayView\DayView\SelectionTool.vb	9	20	DayView

Error	4	Class 'SelectionTool' must implement 'Sub MouseMove(e As System.Windows.Forms.MouseEventArgs)' for interface 'ITool'.	C:\Documents and Settings\UDM\My Documents\Visual Studio 2008\Projects\DayView\DayView\SelectionTool.vb	9	20	DayView

Error	5	Class 'SelectionTool' must implement 'Sub MouseUp(e As System.Windows.Forms.MouseEventArgs)' for interface 'ITool'.	C:\Documents and Settings\UDM\My Documents\Visual Studio 2008\Projects\DayView\DayView\SelectionTool.vb	9	20	DayView

Error	6	Class 'SelectionTool' must implement 'Sub Reset()' for interface 'ITool'.	C:\Documents and Settings\UDM\My Documents\Visual Studio 2008\Projects\DayView\DayView\SelectionTool.vb	9	20	DayView

Error	7	'Mode' is already declared as 'Private mode As Mode' in this class.	C:\Documents and Settings\UDM\My Documents\Visual Studio 2008\Projects\DayView\DayView\SelectionTool.vb	171	22	DayView



Not only this, the VB main Form1 isn't showing the "DayView1" control that the C# one is. When I first created the VB app, I didn't know how to make 2 projects in 1, so it's probably wrong altogether...but I tried. The only reasons I am wanting to go off of someone else's control is because it only lacks 1 feature that I want, and that's having a full month view, not just limited to 1-3-5-7 day views.

Please help with this because I am really stuck. Even if you don't want to help with the code, just let me know what I need to look for. I am attaching the original C# file that I found, and a zipped file with the 2 projects from my Projects folder. I don't know if it works that way for passing around what I have so far, but I have never posted a project like this.

Thanks everyone!

This post has been edited by CakeMaker: 03 September 2009 - 10:19 PM


Is This A Good Question/Topic? 0
  • +

Replies To: C# Calendar Conversion [FIXED]

#2 CakeMaker  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 69
  • Joined: 20-August 09

Re: C# Calendar Conversion [FIXED]

Posted 03 September 2009 - 08:52 PM

Error 7 is all I have left. I have worked and gotten the rest.
Was This Post Helpful? 0
  • +
  • -

#3 CakeMaker  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 69
  • Joined: 20-August 09

Re: C# Calendar Conversion [FIXED]

Posted 03 September 2009 - 09:13 PM

This is the part I am having trouble with now:

Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Drawing

Namespace Calendar
	Public Class SelectionTool
		Implements ITool

		Private m_dayView As DayView

		Public Property DayView() As DayView
			Get
				Return m_dayView
			End Get
			Set(ByVal value As DayView)
				m_dayView = value
			End Set
		End Property

		Private startDate As DateTime
		Private length As TimeSpan
		Private mode As Mode
		Private delta As TimeSpan

		Public Sub Reset() Implements ITool.Reset
			length = TimeSpan.Zero
			delta = TimeSpan.Zero
		End Sub

		Public Sub MouseMove(ByVal e As System.Windows.Forms.MouseEventArgs) Implements ITool.MouseMove
			Dim selection As Appointment = m_dayView.SelectedAppointment

			If (selection IsNot Nothing) AndAlso (Not selection.Locked) Then
				Select Case e.Button
					Case System.Windows.Forms.MouseButtons.Left

						' Get time at mouse position
						Dim m_Date As DateTime = m_dayView.GetTimeAt(e.X, e.Y)

						Select Case mode
							Case mode.Move

								' add delta value
								m_Date = m_Date.Add(delta)

								If length = TimeSpan.Zero Then
									startDate = selection.StartDate
									length = selection.EndDate - startDate
								Else
									Dim m_EndDate As DateTime = m_Date.Add(length)

									If m_EndDate.Day = m_Date.Day Then
										selection.StartDate = m_Date
										selection.EndDate = m_EndDate
										m_dayView.Invalidate()
										m_dayView.RaiseAppointmentMove(New AppointmentEventArgs(selection))
									End If
								End If

								Exit Select

							Case mode.ResizeBottom

								If m_Date > selection.StartDate Then
									If selection.EndDate.Day = m_Date.Day Then
										selection.EndDate = m_Date
										m_dayView.Invalidate()
										m_dayView.RaiseAppointmentMove(New AppointmentEventArgs(selection))
									End If
								End If

								Exit Select

							Case mode.ResizeTop

								If m_Date < selection.EndDate Then
									If selection.StartDate.Day = m_Date.Day Then
										selection.StartDate = m_Date
										m_dayView.Invalidate()
										m_dayView.RaiseAppointmentMove(New AppointmentEventArgs(selection))
									End If
								End If

								Exit Select
						End Select

						Exit Select
					Case Else

						'**************Mode**********************************************
						Dim tmpNode As XNode = GetMode(e)

						Select Case tmpNode
							Case mode.Move
								m_dayView.Cursor = System.Windows.Forms.Cursors.[Default]
								Exit Select
							Case mode.ResizeBottom, mode.ResizeTop
								m_dayView.Cursor = System.Windows.Forms.Cursors.SizeNS
								Exit Select
						End Select

						Exit Select
				End Select
			End If
		End Sub

		Private Function GetMode(ByVal e As System.Windows.Forms.MouseEventArgs) As Mode
			If m_dayView.SelectedAppointment Is Nothing Then
				Return mode.None
			End If

			If m_dayView.appointmentViews.ContainsKey(m_dayView.SelectedAppointment) Then
				Dim view As DayView.AppointmentView = m_dayView.appointmentViews(m_dayView.SelectedAppointment)

				Dim topRect As Rectangle = view.Rectangle
				Dim bottomRect As Rectangle = view.Rectangle

				bottomRect.Y = bottomRect.Bottom - 5
				bottomRect.Height = 5
				topRect.Height = 5

				If topRect.Contains(e.Location) Then
					Return mode.ResizeTop
				ElseIf bottomRect.Contains(e.Location) Then
					Return mode.ResizeBottom
				Else
					Return mode.Move
				End If
			End If

			Return mode.None
		End Function

		Public Sub MouseUp(ByVal e As System.Windows.Forms.MouseEventArgs) Implements ITool.MouseUp
			If e.Button = System.Windows.Forms.MouseButtons.Left Then
				RaiseEvent Complete(Me, EventArgs.Empty)
			End If

			m_dayView.RaiseSelectionchanged(EventArgs.Empty)

			mode = mode.Move

			delta = TimeSpan.Zero
		End Sub

		Public Sub MouseDown(ByVal e As System.Windows.Forms.MouseEventArgs) Implements ITool.MouseDown
			If m_dayView.SelectedAppointmentIsNew Then
				m_dayView.RaiseNewAppointment()
			End If

			If m_dayView.CurrentlyEditing Then
				m_dayView.FinishEditing(False)
			End If

			mode = GetMode(e)

			If m_dayView.SelectedAppointment IsNot Nothing Then
				Dim downPos As DateTime = m_dayView.GetTimeAt(e.X, e.Y)
				' Calculate delta time between selection and clicked point
				delta = m_dayView.SelectedAppointment.StartDate - downPos
			Else
				delta = TimeSpan.Zero
			End If

			length = TimeSpan.Zero
		End Sub

		Public Event Complete As EventHandler

		Private Enum Mode
			ResizeTop
			ResizeBottom
			Move
			None
		End Enum

		Public Property DayView1() As DayView Implements ITool.DayView
			Get
				Return DayView
			End Get
			Set(ByVal value As DayView)
				DayView = value
			End Set
		End Property
	End Class
End Namespace
 


'Mode' is already declared as 'Private mode As Mode' in this class

That's all I have left, which is one part I have been working on most of the day. When it converted this to VB code it must be trying to declare this twice.
Was This Post Helpful? 0
  • +
  • -

#4 CakeMaker  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 69
  • Joined: 20-August 09

Re: C# Calendar Conversion [FIXED]

Posted 03 September 2009 - 10:20 PM

Solved...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1