رفتن به مطلب
  • 0

تنظیم تصویر ساعت


alimaha

سوال

سلام

یک سورس برای ساعت آنالوگ دانلود کردم اما ساعتی که در سورس هست شماره ندارند یعنی اعداد 1 تا 12 را ننوشته است .

خواستم تصویر یک ساعت عقربه دار رو زیرش اضاف کنم اما نشد .یعنی تصویر تنظیم بر عقربه ها نبود 

این سورس کامل ساعت

#Region  Project Attributes 
	#ApplicationLabel: تیک تاک
	#VersionCode: 1
	#VersionName: 1
	'SupportedOrientations possible values: unspecified, landscape or portrait.
	#SupportedOrientations: unspecified
	#CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes 
	#FullScreen: True
	#IncludeTitle: False
#End Region

Sub Process_Globals
	Dim TicTac As Timer	
	
	
End Sub

Sub Globals
Dim p As PinchZoomAndMove
Dim b As BitmapDrawable
Dim out1 As OutputStream
Dim  bitmap1 As Bitmap
	Dim Wall As Canvas
	
	Dim maxresX = GetDeviceLayoutValues.Width  As Float
	Dim maxresY = GetDeviceLayoutValues.Height As Float
	
	Dim Clock_Radius As Float
	Dim Clock_X, Clock_Y As Float
	
	Dim Hour_Handle_Size, Mins_Handle_Size, Secs_Handle_Size As Float

	Dim Sound   As SoundPool
	Dim ticksnd As Int
	
	Private EditText1 As EditText
	Private EditText2 As EditText
	Private Button2 As Button
	Private EditText3 As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
	
	Activity.LoadLayout("Layout1")

'p.Initialize(LoadBitmap,"img1","",1,3,3,False,Me)
  ' p.CanZoom=True
   'p.CanMove=True
   'p.LimitArea=True

	'Clock Position on the wall
		Clock_X = maxresX / 2
		Clock_Y = maxresY / 2

	'Resize the clock accordingly to the screen orientation
		If maxresX > maxresY Then 
			Clock_Radius = 30%y
		Else
			Clock_Radius = 30%x
		End If
	
	'Set the handle size accordingly to the clock size
		Hour_Handle_Size = Clock_Radius * 0.65 '70% of the clock radius
		Mins_Handle_Size = Clock_Radius * 0.80 '80% of the clock radius
		Secs_Handle_Size = Clock_Radius * 0.80 '80% of the clock radius
	
	'Initialize the Sound
		Sound.Initialize(2)
		ticksnd = Sound.Load(File.DirAssets,"tick.mp3")
	
	'Initialize the Wall	
		Wall.Initialize(Activity)		

	'Initialize the Clock
		TicTac.Initialize("TicTac", 1000)	
		TicTac.Enabled = True
	
End Sub


Sub TicTac_Tick	
	'Redraw everything
		Activity.Invalidate
	
	'Get the current time
		'''Dim Hour = DateTime.GetHour(DateTime.Now)   As Int
	'''	Dim Mins = DateTime.GetMinute(DateTime.Now) As Int
	'''	Dim Secs = DateTime.GetSecond(DateTime.Now) As Int
	
	    
End Sub


Sub Draw_Clock	
	'.Initialize(File.DirAssets,"ic2.png")
	'Draw the clock itself	
'Wall.DrawBitmap(b)
'out1=File.OpenOutput(File.DirInternal,"ic2.png",False)
'Wall.Bitmap.WriteToStream(out1,100,"png")
bitmap1.Initialize(File.DirAssets,"ic2.png")
'Dim dr As Rect
'dr.Initialize(55dip,135dip,200dip+70dip,90dip+250dip)

'Wall.DrawBitmap(bitmap1,Null,dr)

		Wall.DrawCircle(Clock_X + 1%x, Clock_Y + 1%y, Clock_Radius, Colors.Gray, True, 0)		
		Wall.DrawCircle(Clock_X, Clock_Y, Clock_Radius, Colors.White, True, 0)		
	Wall.DrawCircle(Clock_X, Clock_Y, Clock_Radius * 0.05, Colors.Black, True, 0)

	'Draw the 12 dots representing the hours
		Dim midnight = 270 As Int
		For angle = midnight To (midnight + 360) Step (360 / 12)
		    Dim x = (CosD(angle) * Clock_Radius * 0.80) + Clock_X As Float
		    Dim y = (SinD(angle) * Clock_Radius * 0.80) + Clock_Y As Float
		    Wall.DrawCircle(x, y, Clock_Radius * 0.05, Colors.Black, True, 0)
		Next	
End Sub


Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub





Sub Button2_Click
	'f EditText1.Text=False And EditText2.Text=False	And	EditText3.Text=False Then
		
	'EditText1.Text="0" And EditText2.Text="0"  And EditText3.Text="0"
		
		 	
			
'End If
	
	
	 Dim Hour = EditText1.Text
	Dim Mins = EditText2.Text
	Dim Secs = EditText3.Text
		
			
		
	
	'Brace yourselves. Math is coming!
		Dim Hour_X, Hour_Y, Mins_X, Mins_Y, Secs_X, Secs_Y As Float	
		Dim Hour_Angle, Mins_Angle, Secs_Angle             As Float
		
	'270 degrees is the position for midnight
		Hour_Angle = 270 + (Hour * 360 / 12)
		Mins_Angle = 270 + (Mins * 360 / 60)
		Secs_Angle = 270 + (Secs * 360 / 60)
	
	'Keep in mind that we're using degrees instead of radians
		Hour_X = (CosD(Hour_Angle) * Hour_Handle_Size) + Clock_X
		Hour_Y = (SinD(Hour_Angle) * Hour_Handle_Size) + Clock_Y
		
		Mins_X = (CosD(Mins_Angle) * Mins_Handle_Size) + Clock_X
		Mins_Y = (SinD(Mins_Angle) * Mins_Handle_Size) + Clock_Y

		Secs_X = (CosD(Secs_Angle) * Secs_Handle_Size) + Clock_X
		Secs_Y = (SinD(Secs_Angle) * Secs_Handle_Size) + Clock_Y
		
	'Draw the clock
		Draw_Clock
	
	'Draw the handles on the clock
		Wall.DrawLine(Clock_X, Clock_Y, Hour_X, Hour_Y, Colors.Blue,  Clock_Radius * 0.03)
		Wall.DrawLine(Clock_X, Clock_Y, Mins_X, Mins_Y, Colors.Green, Clock_Radius * 0.03)
		Wall.DrawLine(Clock_X, Clock_Y, Secs_X, Secs_Y, Colors.Red,   Clock_Radius * 0.01)
		Sound.Play(ticksnd, 1, 1, 1 , 0, 0)
	    
End Sub

 سورس مربوط به طراحی ساعت


Sub Draw_Clock	
	'.Initialize(File.DirAssets,"ic2.png")
	'Draw the clock itself	
'Wall.DrawBitmap(b)
'out1=File.OpenOutput(File.DirInternal,"ic2.png",False)
'Wall.Bitmap.WriteToStream(out1,100,"png")
bitmap1.Initialize(File.DirAssets,"ic2.png")
'Dim dr As Rect
'dr.Initialize(55dip,135dip,200dip+70dip,90dip+250dip)

'Wall.DrawBitmap(bitmap1,Null,dr)

		Wall.DrawCircle(Clock_X + 1%x, Clock_Y + 1%y, Clock_Radius, Colors.Gray, True, 0)		
		Wall.DrawCircle(Clock_X, Clock_Y, Clock_Radius, Colors.White, True, 0)		
	Wall.DrawCircle(Clock_X, Clock_Y, Clock_Radius * 0.05, Colors.Black, True, 0)

	'Draw the 12 dots representing the hours
		Dim midnight = 270 As Int
		For angle = midnight To (midnight + 360) Step (360 / 12)
		    Dim x = (CosD(angle) * Clock_Radius * 0.80) + Clock_X As Float
		    Dim y = (SinD(angle) * Clock_Radius * 0.80) + Clock_Y As Float
		    Wall.DrawCircle(x, y, Clock_Radius * 0.05, Colors.Black, True, 0)
		Next	
End Sub

کد هایی که خودم نوشتم هم هست اما غیر فعال هستند .روی شبیه ساز تصویر تنظیم می شه اما روی هر گوشی دیگه به هم می ریزه 

ممنون می شم اگر راهنمایی بفرمایید باید چی کار کنم که به ساعت شماره 1- 12 بدهم یا تصویر اضافه کنم.

لینک ارسال
به اشتراک گذاری در سایت های دیگر

1 پاسخ به این سوال تاکنون داده شده است

ارسال‌های توصیه شده

لینک ارسال
به اشتراک گذاری در سایت های دیگر

بایگانی شده

این موضوع بایگانی و قفل شده و دیگر امکان ارسال پاسخ نیست.

  • کاربران آنلاین در این صفحه   0 کاربر

    • هیچ کاربر عضوی،در حال مشاهده این صفحه نیست.
×
×
  • اضافه کردن...