zoukankan      html  css  js  c++  java
  • Using System.Windows.Forms.Label and System.Windows.Forms.FontDialog

    The following example demonstrates

    • The use of the System.Windows.Forms.Label DotNetControl to output formatted text to a rollout.
    • Setting the Font of the Label using a System.Windows.Forms.FontDialog DotNetObject
    • Getting and Setting the Alignment of the Label
    • Getting and Setting the Foreground and Background Colors of the Label
    (
    global label_test  --declare a global variable to hold the test rollout
    try(destroyDialog label_test)catch() --try to destroy it if it already exists as a dialog
    local theDialog = dotNetObject "System.Windows.Forms.FontDialog" --create a FontDialog DotNetObject
    rollout label_test "Label Demo" --define the rollout
    (
    dotNetControl dn_control "System.Windows.Forms.Label" 200 height:100 --create a LABEL DotNetControl
    dropdownlist ddl_Align items:#() --create a MAXScript dropdown list control
    button btn_changeFont "Change Font" across:3 --create a MAXScript button
    colorpicker clr_forecolor align:#right  --create a color picker for the text color
    colorpicker clr_backcolor align:#right --create a color picker for the background color

    on btn_changeFont pressed do  --when the button is pressed
    (
      theResult = theDialog.ShowDialog() --open the Font dialog
      if theResult.Equals theResult.OK do --if the OK button was pressed
        dn_control.font = theDialog.font  --set the font of the Label to the Font selected in the Font Dialog
    )

    on ddl_Align selected itm do --if an item was selected from the dropdown list
      try(dn_control.TextAlign = (getProperty dn_control.TextAlign ddl_Align.selected))catch() --try to set the TextAlign property to that value

    on label_test open do  --if the rollout was just opened
    (
    ddl_Align.items = for i in (getPropNames dn_control.TextAlign) collect i as string --collect the TextAlign enums into the dropdown list items array
    dn_control.text = "This is a label.\nIt can contain multiple lines." --set the text of the label
    dn_control.TextAlign = (getProperty dn_control.TextAlign ddl_Align.selected) --set the alignment to the current list selection
    theFC = dn_control.forecolor  --get the default foreground color of the control
    clr_forecolor.color = color theFC.r theFC.g theFC.b --and assign to the color picker
    theBC = dn_control.backcolor --get the default foreground color of the control
    clr_backcolor.color = color theBC.r theBC.g theBC.b --and assign to the color picker
    )

    on clr_forecolor changed clr do --if the user picked a new color, set the text color to it
      dn_control.forecolor = dn_control.forecolor.fromARGB clr.r clr.g clr.b
    on clr_backcolor changed clr do --if the user picked a new color, set the background color to it
      dn_control.backcolor = dn_control.backcolor.fromARGB clr.r clr.g clr.b

    )
    createDialog label_test 220 160
    )
  • 相关阅读:
    [Android] Android 手机下 仿 今日头条 新闻客户端
    [Android] Android Error: Suspicious namespace and prefix combination [NamespaceTypo] when I try create Signed APK
    [Android] Android Build 时报错: java.io.IOException: Could not parse XML from android/accounts/annotations.xml
    Uva 10557 XYZZY
    Uva 705
    Uva532(三维搜索)
    Uva657
    B. Bear and Three Musketeers
    1092 回文字符串(51nod)
    1050 循环数组最大子段和
  • 原文地址:https://www.cnblogs.com/softimagewht/p/1784122.html
Copyright © 2011-2022 走看看