Exemplo n.º 1
0
    def __init__(self):
        self.Text = "Hello World"
        self.FormBorderStyle = FormBorderStyle.Fixed3D
        self.Height = 150
        
        newFont = Font("Verdana", 16, FontStyle.Bold | FontStyle.Italic)

        label = Label()
        label.AutoSize = True
        label.Text = "My Hello World Label"
        label.Location = Point(10, 50)
        label.BackColor = Color.Aquamarine
        label.ForeColor = Color.DarkMagenta
        label.Font = newFont

        self.Controls.Add(label)
Exemplo n.º 2
0
import clr
clr.AddReference('System.Windows.Forms') 
clr.AddReference('System.Drawing')
from System.Windows.Forms import (
    Application, Form,
    FormBorderStyle, Label
)
from System.Drawing import (
    Color, Font, FontStyle, Point
)

form = Form()
form.Text = "Hello World"
form.FormBorderStyle = FormBorderStyle.Fixed3D
form.Height = 150

newFont = Font("Verdana", 16, 
    FontStyle.Bold | FontStyle.Italic)

label = Label()
label.AutoSize = True
label.Text = "My Hello World Label"
label.Font = newFont
label.BackColor = Color.Aquamarine
label.ForeColor = Color.DarkMagenta
label.Location = Point(10, 50)

form.Controls.Add(label)

Application.Run(form)
Exemplo n.º 3
0
import clr
clr.AddReference('System.Windows.Forms')
clr.AddReference('System.Drawing')
from System.Windows.Forms import (Application, Form, FormBorderStyle, Label)
from System.Drawing import (Color, Font, FontStyle, Point)

form = Form()
form.Text = "Hello World"
form.FormBorderStyle = FormBorderStyle.Fixed3D
form.Height = 150

newFont = Font("Verdana", 16, FontStyle.Bold | FontStyle.Italic)

label = Label()
label.AutoSize = True
label.Text = "My Hello World Label"
label.Location = Point(10, 50)
label.BackColor = Color.Aquamarine
label.ForeColor = Color.DarkMagenta
label.Font = newFont

form.Controls.Add(label)

Application.Run(form)
Exemplo n.º 4
0
    def __init__(self):
        self.received_messages = {}
        self.msg_ids = {}

        self.config = None
        self.num_messages = DEFAULT_NUM_MESSAGES
        if path.exists(CONFIG_FILENAME):
            print('Reading config...')
            self.config = open(CONFIG_FILENAME, 'r').readlines()
            for x in range(len(self.config)):
                self.config[x] = self.config[x].strip('\n')
            self.num_messages = int(self.config[0].split(',')[0])

        # we subscribe to every possible MAVLink message here
        # super inefficient, but much easier to just collect 'em all!
        for attr_name in dir(MAVLink.MAVLINK_MSG_ID):
            if attr_name.upper() == attr_name:
                attr = getattr(MAVLink.MAVLINK_MSG_ID, attr_name)
                self.msg_ids[attr.value__] = attr
                MAV.SubscribeToPacketType(
                    attr, Func[MAVLink.MAVLinkMessage,
                               bool](self.get_message_data))
        MAV.OnPacketReceived += self.packet_handler

        self.Text = 'MAVLink MinMonitor'
        self.Location = Point(0, 0)
        self.TopMost = True
        self.BackColor = CustomColor.MPDarkGray
        self.ForeColor = CustomColor.White
        self.Shown += self.on_load
        self.FormClosing += self.on_exit

        self.margin = 5
        start_x, start_y = 12, 10

        self.msg_widgets = []
        for x in range(self.num_messages):
            cbo_msg_id = ComboBox()
            cbo_msg_id.Width = 175
            cbo_msg_id.DropDownStyle = ComboBoxStyle.DropDown
            cbo_msg_id.FlatStyle = FlatStyle.Flat
            cbo_msg_id.BackColor = CustomColor.MPLightGray
            cbo_msg_id.ForeColor = CustomColor.White
            cbo_msg_id.DataSource = self.received_messages.keys()
            cbo_msg_id.MouseDown += self.update_message_ids
            cbo_msg_id.SelectionChangeCommitted += self.update_datasource
            cbo_msg_id.Text = ''

            cbo_msg_dataframes = ComboBox()
            cbo_msg_dataframes.Width = 120
            cbo_msg_dataframes.DropDownStyle = ComboBoxStyle.DropDown
            cbo_msg_dataframes.FlatStyle = FlatStyle.Flat
            cbo_msg_dataframes.BackColor = CustomColor.MPLightGray
            cbo_msg_dataframes.ForeColor = CustomColor.White
            cbo_msg_dataframes.Text = ''

            lbl_data = Label()
            lbl_data.Text = 'NO DATA'
            lbl_data.BackColor = CustomColor.MPMediumGray
            lbl_data.Width = 120
            lbl_data.Height = cbo_msg_id.Height - 5

            txt_min = TextBox()
            txt_min.Width = 75
            txt_min.BorderStyle = BorderStyle.FixedSingle
            txt_min.BackColor = CustomColor.MPLightGray
            txt_min.ForeColor = CustomColor.White
            txt_min.MaxLength = 10
            txt_min.TextAlign = HorizontalAlignment.Center
            txt_min.KeyPress += self.limit_to_decimal_digits

            txt_max = TextBox()
            txt_max.Width = 75
            txt_max.BorderStyle = BorderStyle.FixedSingle
            txt_max.BackColor = CustomColor.MPLightGray
            txt_max.ForeColor = CustomColor.White
            txt_max.MaxLength = 10
            txt_max.TextAlign = HorizontalAlignment.Center
            txt_max.KeyPress += self.limit_to_decimal_digits

            txt_factor = TextBox()
            txt_factor.Width = 75
            txt_factor.BorderStyle = BorderStyle.FixedSingle
            txt_factor.BackColor = CustomColor.MPLightGray
            txt_factor.ForeColor = CustomColor.White
            txt_factor.MaxLength = 10
            txt_factor.TextAlign = HorizontalAlignment.Center
            txt_factor.KeyPress += self.limit_to_decimal_digits

            self.msg_widgets.append(
                OrderedDict([('cbo_msg_id', cbo_msg_id),
                             ('cbo_msg_dataframes', cbo_msg_dataframes),
                             ('lbl_data', lbl_data), ('txt_min', txt_min),
                             ('txt_max', txt_max),
                             ('txt_factor', txt_factor)]))

        self.lbl_min = Label()
        self.lbl_min.Text = 'Min'
        self.lbl_min.BackColor = CustomColor.MPDarkGray
        self.lbl_min.Width = self.msg_widgets[0]['txt_min'].Width
        self.lbl_min.Height = self.msg_widgets[0]['txt_min'].Height - 5

        self.lbl_max = Label()
        self.lbl_max.Text = 'Max'
        self.lbl_max.BackColor = CustomColor.MPDarkGray
        self.lbl_max.Width = self.msg_widgets[0]['txt_max'].Width
        self.lbl_max.Height = self.msg_widgets[0]['txt_max'].Height - 5

        self.lbl_factor = Label()
        self.lbl_factor.Text = 'Factor'
        self.lbl_factor.BackColor = CustomColor.MPDarkGray
        self.lbl_factor.Width = self.msg_widgets[0]['txt_factor'].Width
        self.lbl_factor.Height = self.msg_widgets[0]['txt_factor'].Height - 5

        self.lbl_num_messages = Label()
        self.lbl_num_messages.Text = 'Number of messages to monitor (restart to take effect)'
        self.lbl_num_messages.BackColor = CustomColor.MPDarkGray
        self.lbl_num_messages.AutoSize = True

        self.spn_num_messages = NumericUpDown()
        self.spn_num_messages.Width = 40
        self.spn_num_messages.BorderStyle = BorderStyle.FixedSingle
        self.spn_num_messages.BackColor = CustomColor.MPLightGray
        self.spn_num_messages.ForeColor = CustomColor.White
        self.spn_num_messages.Value = self.num_messages

        self.chk_hide_factors = CheckBox()
        self.chk_hide_factors.FlatAppearance.BorderSize = 1
        self.chk_hide_factors.FlatAppearance.BorderColor = CustomColor.MPLightGray
        self.chk_hide_factors.Text = 'Hide threshold/scaling preferences'
        self.chk_hide_factors.AutoSize = True

        self.chk_sticky = CheckBox()
        self.chk_sticky.FlatAppearance.BorderSize = 1
        self.chk_sticky.FlatAppearance.BorderColor = CustomColor.MPLightGray
        self.chk_sticky.Text = 'Always on top'
        self.chk_sticky.AutoSize = True

        self.lbl_status = Label()
        self.lbl_status.Text = 'No messages received'
        self.lbl_status.BackColor = CustomColor.MPMediumGray
        self.lbl_status.Height = self.msg_widgets[0]['txt_min'].Height - 5

        # pseudo-responsive form layout
        x, y = start_x, start_y
        max_x = 0
        x = start_x + (self.msg_widgets[0]['cbo_msg_id'].Width +
                       self.msg_widgets[0]['cbo_msg_dataframes'].Width +
                       self.msg_widgets[0]['lbl_data'].Width) + self.margin * 4
        x, y, x_extent = \
            self.add_control_horizontal(self.lbl_min, x, y, self.margin)
        x, y, x_extent = \
            self.add_control_horizontal(self.lbl_max, x, y, self.margin)
        x, y, x_extent = \
            self.add_control_vertical(self.lbl_factor, x, y, self.margin)
        for widget in self.msg_widgets:
            x = start_x
            for control in widget.items():
                x, y, x_extent = self.add_control_horizontal(
                    control[1], x, y, self.margin)
            max_x = max([x_extent, max_x])
            y += widget.items()[0][1].Height + self.margin
        self.Width = max_x + self.margin * 4
        self.WideWidth = self.Width
        self.NarrowWidth = self.msg_widgets[0]['lbl_data'].Location.X + \
                           self.msg_widgets[0]['lbl_data'].Width + self.margin * 5
        y += 20
        x, y, x_extent = self.add_control_horizontal(self.spn_num_messages,
                                                     start_x, y, self.margin)
        x, y, x_extent = self.add_control_vertical(self.lbl_num_messages, x,
                                                   y + 3, self.margin)
        x, y, x_extent = self.add_control_vertical(self.chk_hide_factors,
                                                   start_x + 3, y + 5,
                                                   self.margin)
        x, y, x_extent = self.add_control_vertical(self.chk_sticky, x, y,
                                                   self.margin)
        self.lbl_status.Width = self.Width - self.margin * 7
        x, y, x_extent = self.add_control_vertical(self.lbl_status, start_x,
                                                   y + 3, self.margin)
        self.Height = y + self.lbl_status.Height + self.margin * 5