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
    )
  • 相关阅读:
    SSL延迟有多大?(转)
    Nginx/LVS/HAProxy负载均衡软件的优缺点详解(转)
    lvs、haproxy、nginx 负载均衡的比较分析(转)
    入木三分学网络第一篇--VRRP协议详解第一篇(转)
    从一个开发的角度看负载均衡和LVS(转)
    四层和七层负载均衡的区别(转)
    geo实现方案
    HTTP API 设计指南(转)
    app后端设计(0)--总目录(转)
    Django接收自定义http header(转)
  • 原文地址:https://www.cnblogs.com/softimagewht/p/1784122.html
Copyright © 2011-2022 走看看