Dot net buttons

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 04 April 2013   #1
Dot net buttons

I'm trying to build a user interface but I realized quickly that the default maxscript button didn't have enough visual options for what I wanted to do.
SO I looked into dot net but I still can't find what i'm looking for.

What i'd like is to have a circular button. Is there a way to do it in dot net? Should I use a picture and map onto my button instead?

on the other side i'd be happy with another type of solution: is there a way to give a 45 degree rotation to a button in either mxscript or dontnet
 
Old 04 April 2013   #2
Originally Posted by mrfred: I'm trying to build a user interface but I realized quickly that the default maxscript button didn't have enough visual options for what I wanted to do.
SO I looked into dot net but I still can't find what i'm looking for.

What i'd like is to have a circular button. Is there a way to do it in dot net? Should I use a picture and map onto my button instead?

on the other side i'd be happy with another type of solution: is there a way to give a 45 degree rotation to a button in either mxscript or dontnet

.NET + WPF = any shape, any transform, any color and opacity
 
Old 04 April 2013   #3
hmm so i assume there's not right of the bat function for what I wanted to do.
oh well... time to learn wpf
 
Old 04 April 2013   #4
so far i've been unable to do anything good witg wpf yet anyother leads?
 
Old 04 April 2013   #5
Originally Posted by mrfred: so far i've been unable to do anything good witg wpf yet anyother leads?

what's the problem with wpf?
also you can do custom draw on paint event. there are some samples on this forum. i remember at least one by LO for sure...

as i have a time i will post a wpf sample code.
 
Old 04 April 2013   #6
Originally Posted by denisT: as i have a time i will post a wpf sample code.

here is a sample how to make round button using .NET and WPF classes

try(wp.close()) catch()
fn makeToolBall size:[50,50] =
(
	global _b = ball = dotnetobject "System.Windows.Shapes.Ellipse"
	
	local mcolor = dotnetclass "System.Windows.Media.Color"
	
	ball.Width = size.x
	ball.Height = size.y
	ball.Stroke = dotnetobject "System.Windows.Media.SolidColorBrush" (mcolor.FromArgb 150 20 20 20) --Black --MidnightBlue
	ball.StrokeThickness = 1.5

	local radBrush = dotnetobject "System.Windows.Media.RadialGradientBrush"
	local gpClass = dotnetclass "System.Windows.Media.GradientStop"
	local mcolors = dotnetclass "System.Windows.Media.Colors"
	
	radBrush.GradientOrigin = dotnetobject "System.Windows.Point" 0.25 0.25
	radBrush.GradientStops.Add (dotnetobject gpClass mcolors.White 0.0) 
	radBrush.GradientStops.Add (dotnetobject gpClass mcolors.LightSteelBlue 0.95) 
	radBrush.GradientStops.Add (dotnetobject gpClass mcolors.SlateGray 0.99) 

	ball.Fill = radBrush
	
	local cv = dotnetobject "System.Windows.Controls.Canvas"
	cv.Width = ball.Width
	cv.Height = ball.Height
	cv.Children.Add ball
	
	local wp = dotnetobject "System.Windows.Window"
	wp.WindowStartupLocation = wp.WindowStartupLocation.Manual
	wp.Left = 800
	wp.Top = 200
	wp.Width = ball.Width + 40
	wp.Height = ball.Height + 50
	wp.WindowStyle = wp.WindowStyle.ToolWindow

	wp.Title = "ExtraToolball"
	wp.ShowInTaskbar = off

	fn onMouseDown s e = 
	(
		format "mouse down...\n"
	)
	dotnet.addeventhandler ball "MouseDown" onMouseDown
	fn onMouseUp s e = 
	(
		format "mouse up...\n"
	)
	dotnet.addeventhandler ball "MouseUp" onMouseUp
	wp.content = cv
	
	wih = dotnetobject "System.Windows.Interop.WindowInteropHelper" wp
	wih.owner = dotnetobject "IntPtr" (windows.getmaxhwnd())

	wp
)	
wp = makeToolBall()
wp.Show()
 
Old 04 April 2013   #7
wow thanks for that snippet, I was trying to use xaml code format :/ feel kinda ashamed now.
 
Old 04 April 2013   #8
ok so I'm trying to integrate the ball fn into a standard rollout ( got rid of the window creation stuff) So i can be able to call it and create circular button at ease
but when I do so I get

-- Runtime error: dotNet runtime exception: The calling thread must be STA, because many UI components require this.
google tell me something a Dispatcher.CurrentDispatcher but how can I plug this?
 
Old 04 April 2013   #9
Originally Posted by mrfred: ok so I'm trying to integrate the ball fn into a standard rollout ( got rid of the window creation stuff) So i can be able to call it and create circular button at ease

here is how to add the button for a rollout:

try(destroydialog wpfRollout) catch()

rollout wpfRollout "" width:70 height:80
(
	dotNetControl eh "Integration.ElementHost" width:50 height:50 align:#left offset:[0,0]
	
	fn makeToolBall size:[50,50] =
	(
		local ball = dotnetobject "System.Windows.Shapes.Ellipse"
		
		local mcolor = dotnetclass "System.Windows.Media.Color"
		
		ball.Width = size.x
		ball.Height = size.y
		ball.Stroke = dotnetobject "System.Windows.Media.SolidColorBrush" (mcolor.FromArgb 150 20 20 20) --Black --MidnightBlue
		ball.StrokeThickness = 1.5

		local radBrush = dotnetobject "System.Windows.Media.RadialGradientBrush"
		local gpClass = dotnetclass "System.Windows.Media.GradientStop"
		local mcolors = dotnetclass "System.Windows.Media.Colors"
		
		radBrush.GradientOrigin = dotnetobject "System.Windows.Point" 0.25 0.25
		radBrush.GradientStops.Add (dotnetobject gpClass mcolors.White 0.0) 
		radBrush.GradientStops.Add (dotnetobject gpClass mcolors.LightSteelBlue 0.95) 
		radBrush.GradientStops.Add (dotnetobject gpClass mcolors.SlateGray 0.99) 

		ball.Fill = radBrush
				
		fn onMouseDown s e = (format "mouse down...\n")
		dotnet.addeventhandler ball "MouseDown" onMouseDown
		fn onMouseUp s e = (format "mouse up...\n")
		dotnet.addeventhandler ball "MouseUp" onMouseUp
		
		ball
	)	

	on wpfRollout open do
	(
		eh.child = makeToolBall()
	)
)

createDialog wpfRollout style:#(#style_toolwindow,#style_sysmenu,#style_re  sizing)


if WindowsFormsIntegration assembly is not loading automatically you have to manually load it:

dotNet.loadAssembly @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\WindowsFormsIn  tegration.dll"

using right for your system path
 
Old 04 April 2013   #10
Works like a charm I think I was missing the integration.elementhost thing
Thanks you.

One little thing though is there a way to have the white part around the circle to be transparent?
 
Old 04 April 2013   #11
Originally Posted by mrfred: One little thing though is there a way to have the white part around the circle to be transparent?

there is no easy way to make its background transparent but you can do the same color as rollout background:

	on wpfRollout open do
	(
		eh.Backcolor = ((dotnetClass "ManagedServices.CuiUpdater").GetInstance()).getMaxColor 0
		eh.child = makeToolBall()
	)
 
Old 04 April 2013   #12
sadly thats not gonna work as the button needs to be over a picture, i'll do some research later today
 
Old 04 April 2013   #13
Originally Posted by mrfred: sadly thats not gonna work as the button needs to be over a picture, i'll do some research later today

there is my sample on this forum about how to make semitransparent window forms control. it's only way that i know.
 
Old 04 April 2013   #14
ok thank you, i'll look for it asap
 
Old 04 April 2013   #15
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 03:19 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.