• 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
    )
  • 相关阅读:
    洛谷 P1593 因子和
    洛谷 P1167 刷题
    洛谷 P1613 跑路
    洛谷 P1629 邮递员送信
    洛谷 P1654 OSU!
    洛谷 P1967 货车运输
    FPGA开平方的实现
    FPGA设计思想之串并转换
    verilog乘法器的设计
    FPGA浮点数定点数的处理
  • 原文地址:https://www.cnblogs.com/softimagewht/p/1784122.html
Copyright © 2020-2023  润新知