예제 #1
0
        /**
         * Creates a new ModalList state.
         *
         * @param title Title to display at top of list
         * @param objects A list of objects that will be selected from
         * @param canCancel If true a cancel button is included which will close the window and return a null result
         */
        public ModalOptionListState(string title, List <T> objects, bool canCancel = true)
            : base(title)
        {
            GuiListBox <T> ListBox = new GuiListBox <T>(10, 10, Window.Width - 20, Window.Height - 80);

            foreach (T item in objects)
            {
                ListBox.Add(item);
            }

            GuiButton ConfirmationButton = new GuiButton("OK", 120, 30);

            ConfirmationButton.OnMouseClicked += delegate {
                Result = ListBox.Selected;
                Close();
            };

            GuiButton CancelButton = new GuiButton("Cancel", 120, 30);

            CancelButton.OnMouseClicked += delegate {
                Result = default(T);
                Close();
            };

            Window.Add(ListBox);
            Window.Add(ConfirmationButton, -20, -20);
            if (canCancel)
            {
                Window.Add(CancelButton, 20, -20);
            }
        }
예제 #2
0
        public LibraryItemsView()
            : base(500 - 16, 350 - 18)
        {
            Align = GuiAlignment.Full;

            var scrollableItemList = new ScrollableListBox <MDRItemInstance>(200 - 4, 450 - 37)
            {
                X = 4
            };

            ItemList = scrollableItemList.ListBox;
            ItemList.EnableBackground = true;

            ItemInfo        = new GuiItemToolTip();
            ItemInfo.X      = 200;
            ItemInfo.Y      = 0;
            ItemInfo.Width  = 200;
            ItemInfo.Height = Height;

            ItemInfo.AutoFit     = false;
            ItemInfo.WindowStyle = GuiWindowStyle.ThinTransparent;
            ItemInfo.Color       = Color.black;

            ItemList.OnSelectedChanged += SyncItemInfo;

            Add(scrollableItemList);
            Add(ItemInfo);
            CreateListings();
        }
예제 #3
0
        public LibraryMonstersView()
            : base(500 - 16, 350 - 18)
        {
            Align = GuiAlignment.Full;

            var scrollableMonsterList = new ScrollableListBox <MDRMonster>(200 - 4, 450 - 37)
            {
                X = 4
            };

            MonsterList = scrollableMonsterList.ListBox;
            MonsterList.EnableBackground = true;

            MonsterInfo                    = new GuiMonsterToolTip();
            MonsterInfo.X                  = 200;
            MonsterInfo.Y                  = 0;
            MonsterInfo.Width              = Width - 200;
            MonsterInfo.Height             = Height;
            MonsterInfo.ShowEncounterStats = true;
            MonsterInfo.WindowStyle        = GuiWindowStyle.ThinTransparent;
            MonsterInfo.Color              = Color.black;

            MonsterList.OnSelectedChanged += SyncMonsterInfo;

            Add(scrollableMonsterList);
            Add(MonsterInfo);
            CreateListings();
        }
예제 #4
0
파일: DynamicForm.cs 프로젝트: zhh007/MyGen
        private void listBoxChanged(object sender, System.EventArgs e)
        {
            try
            {
                if (sender is ListBox)
                {
                    ListBox    lb  = sender as ListBox;
                    GuiListBox glb = guiController[lb.Name] as GuiListBox;

                    UpdateAutoBinding(glb);

                    foreach (string functionName in glb.GetEventHandlers("onchange"))
                    {
                        this.executioner.ExecuteFunction(functionName, glb);
                    }
                }
            }
            catch (Exception x)
            {
                //ZeusDisplayError formError = new ZeusDisplayError(x);
                //formError.ShowDialog(this);
                if (logger != null)
                {
                    logger.LogException(x);
                }
            }
        }
예제 #5
0
        public void cmbDatabases_onchange(GuiComboBox control)
        {
            GuiComboBox cmbDatabases = ui["databaseName"] as GuiComboBox;
            GuiComboBox cmbTables    = ui["tableName"] as GuiComboBox;

            cmbTables.BindData(MyMeta.Databases[cmbDatabases.SelectedValue].Tables);

            // clear columns list
            GuiListBox lstColumns = ui["lstColumns"] as GuiListBox;

            lstColumns.Clear();
        }
예제 #6
0
 public void cmbTables_onchange(GuiComboBox control)
 {
     try
     {
         GuiComboBox cmbDatabases = ui["databaseName"] as GuiComboBox;
         GuiComboBox cmbTables    = ui["tableName"] as GuiComboBox;
         GuiListBox  lstColumns   = ui["lstColumns"] as GuiListBox;
         lstColumns.BindData(MyMeta.Databases[cmbDatabases.SelectedValue].Tables[cmbTables.SelectedValue].Columns);
     }
     catch (Exception ex)
     {
     }
 }
예제 #7
0
        public void InitializeControlData(Hashtable input)
        {
            Control w32ctrl;
            object  objData;

            foreach (GuiControl control in this.orderedGuiControls)
            {
                try
                {
                    w32ctrl = win32Controls[control.ID] as Control;

                    if (input.Contains(control.ID))
                    {
                        objData = input[control.ID];

                        if (control is GuiCheckBox)
                        {
                            GuiCheckBox guiCheckBox = control as GuiCheckBox;

                            CheckBox b = w32ctrl as CheckBox;
                            b.Checked = Convert.ToBoolean(objData);
                        }
                        else if (control is GuiLabel)
                        {
                            GuiLabel guiLabel = control as GuiLabel;

                            Label l = w32ctrl as Label;
                            l.Text = Convert.ToString(objData);
                        }
                        else if (control is GuiTextBox)
                        {
                            GuiTextBox guiTextBox = control as GuiTextBox;

                            TextBox tb = w32ctrl as TextBox;
                            tb.Text = Convert.ToString(objData);
                        }
                        else if (control is GuiComboBox)
                        {
                            GuiComboBox guiComboBox = control as GuiComboBox;

                            ComboBox cb = w32ctrl as ComboBox;
                            foreach (ListControlItem item in cb.Items)
                            {
                                if (item.Value == Convert.ToString(objData))
                                {
                                    cb.SelectedItem = item;
                                    break;
                                }
                            }
                        }
                        else if (control is GuiListBox)
                        {
                            GuiListBox guiListBox = control as GuiListBox;

                            ListBox lb = w32ctrl as ListBox;

                            ArrayList list = objData as ArrayList;
                            if (list != null)
                            {
                                for (int i = 0; i < lb.Items.Count; i++)
                                {
                                    ListControlItem item = lb.Items[i] as ListControlItem;
                                    lb.SetSelected(i, list.Contains(item.Value));
                                }
                            }
                        }
                        else if (control is GuiGrid)
                        {
                            GuiGrid guiGrid = control as GuiGrid;

                            DataGrid dg = w32ctrl as DataGrid;

                            SimpleTable table = objData as SimpleTable;
                            if (table != null)
                            {
                                guiGrid.DataSource = table;
                                dg.DataSource      = SimpleTableTools.ConvertToDataTable(table);
                            }
                        }
                        else if (control is GuiCheckBoxList)
                        {
                            GuiCheckBoxList guiListBox = control as GuiCheckBoxList;

                            CheckedListBox lb = w32ctrl as CheckedListBox;

                            ArrayList list = objData as ArrayList;
                            if (list != null)
                            {
                                for (int i = 0; i < lb.Items.Count; i++)
                                {
                                    ListControlItem item = lb.Items[i] as ListControlItem;
                                    lb.SetItemChecked(i, list.Contains(item.Value));
                                }
                            }
                        }
                    }
                }
                catch
                {
                    // Do nothing in the catch for now. We want it to fill in as many items as possible.
                }
            }
        }
예제 #8
0
        protected void UpdateForm(Control eventSource)
        {
            Control w32ctrl;

            foreach (GuiControl control in guiControls.Values)
            {
                w32ctrl = win32Controls[control.ID] as Control;
                if (eventSource != w32ctrl)
                {
                    if (control is GuiLabel)
                    {
                        GuiLabel guiLabel = control as GuiLabel;

                        Label l = w32ctrl as Label;
                        l.Text = guiLabel.Text;

                        Font      font  = l.Font;
                        FontStyle style = FontStyle.Regular;
                        if (guiLabel.Bold)
                        {
                            style = style | FontStyle.Bold;
                        }
                        if (guiLabel.Underline)
                        {
                            style = style | FontStyle.Underline;
                        }
                        if (guiLabel.Strikeout)
                        {
                            style = style | FontStyle.Strikeout;
                        }
                        if (guiLabel.Italic)
                        {
                            style = style | FontStyle.Italic;
                        }
                        l.Font = new Font(font, style);
                    }
                    else if (control is GuiButton)
                    {
                        GuiButton guiButton = control as GuiButton;

                        Button b = w32ctrl as Button;
                        b.Text = guiButton.Text;
                    }
                    else if (control is GuiCheckBox)
                    {
                        GuiCheckBox guiCheckBox = control as GuiCheckBox;

                        CheckBox b = w32ctrl as CheckBox;

                        b.CheckedChanged -= new EventHandler(OnCheckBoxClick);
                        b.Checked         = guiCheckBox.Checked;
                        b.CheckedChanged += new EventHandler(OnCheckBoxClick);

                        b.Text = guiCheckBox.Text;
                    }
                    else if (control is GuiFilePicker)
                    {
                        GuiFilePicker guiPicker = control as GuiFilePicker;

                        Button b = w32ctrl as Button;
                        b.Text = guiPicker.Text;
                    }
                    else if (control is GuiTextBox)
                    {
                        GuiTextBox guiTextBox = control as GuiTextBox;

                        TextBox tb = w32ctrl as TextBox;
                        tb.Text      = guiTextBox.Text;
                        tb.Multiline = guiTextBox.Multiline;
                        tb.WordWrap  = guiTextBox.WordWrap;

                        if (guiTextBox.VerticalScroll && guiTextBox.HorizontalScroll)
                        {
                            tb.ScrollBars = ScrollBars.Both;
                        }
                        else if (guiTextBox.VerticalScroll)
                        {
                            tb.ScrollBars = ScrollBars.Vertical;
                        }
                        else if (guiTextBox.HorizontalScroll)
                        {
                            tb.ScrollBars = ScrollBars.Horizontal;
                        }
                        else
                        {
                            tb.ScrollBars = ScrollBars.None;
                        }
                    }
                    else if (control is GuiComboBox)
                    {
                        GuiComboBox guiComboBox = control as GuiComboBox;

                        ComboBox cb = w32ctrl as ComboBox;
                        cb.SelectedValueChanged -= new EventHandler(OnComboBoxChange);

                        cb.Items.Clear();
                        foreach (string val in guiComboBox.Items)
                        {
                            ListControlItem item = new ListControlItem(val, guiComboBox[val]);
                            cb.Items.Add(item);

                            if (item.Value == guiComboBox.SelectedValue)
                            {
                                cb.SelectedItem = item;
                            }
                        }
                        cb.SelectedValueChanged += new EventHandler(OnComboBoxChange);
                    }
                    else if (control is GuiListBox)
                    {
                        GuiListBox guiListBox = control as GuiListBox;

                        ListBox lb = w32ctrl as ListBox;

                        lb.SelectedValueChanged -= new EventHandler(OnListBoxChange);

                        lb.Items.Clear();
                        foreach (string val in guiListBox.Items)
                        {
                            ListControlItem item = new ListControlItem(val, guiListBox[val]);
                            lb.Items.Add(item);

                            if (guiListBox.SelectedItems.Contains(val))
                            {
                                lb.SetSelected(lb.Items.IndexOf(item), true);
                            }
                        }

                        lb.SelectedValueChanged += new EventHandler(OnListBoxChange);

                        lb.SelectionMode = guiListBox.IsMultiSelect ? SelectionMode.MultiExtended : SelectionMode.One;
                        lb.Sorted        = guiListBox.Sorted;
                    }
                    else if (control is GuiGrid)
                    {
                        GuiGrid guiGrid = control as GuiGrid;

                        DataGrid dg = w32ctrl as DataGrid;
                        dg.DataSource = SimpleTableTools.ConvertToDataTable(guiGrid.DataSource);
                    }
                    else if (control is GuiCheckBoxList)
                    {
                        GuiCheckBoxList guiCheckBoxList = control as GuiCheckBoxList;

                        CheckedListBox lb = w32ctrl as CheckedListBox;

                        lb.SelectedValueChanged -= new EventHandler(OnCheckedListBoxChange);

                        lb.Items.Clear();
                        foreach (string val in guiCheckBoxList.Items)
                        {
                            ListControlItem item = new ListControlItem(val, guiCheckBoxList[val]);
                            lb.Items.Add(item);

                            if (guiCheckBoxList.SelectedItems.Contains(val))
                            {
                                lb.SetItemChecked(lb.Items.IndexOf(item), true);
                            }
                        }

                        lb.SelectedValueChanged += new EventHandler(OnCheckedListBoxChange);

                        lb.Sorted = guiCheckBoxList.Sorted;
                    }
                }

                w32ctrl.Left    = control.Left;
                w32ctrl.Top     = control.Top;
                w32ctrl.Width   = control.Width;
                w32ctrl.Height  = control.Height;
                w32ctrl.Visible = control.Visible;
                w32ctrl.Enabled = control.Enabled;
                if (control.ForeColor != string.Empty)
                {
                    w32ctrl.ForeColor = Color.FromName(control.ForeColor);
                }
                if (control.BackColor != string.Empty)
                {
                    w32ctrl.BackColor = Color.FromName(control.BackColor);
                }

                tooltip.SetToolTip(w32ctrl, control.ToolTip);
            }
        }
예제 #9
0
        public void AddToForm(GuiControl control)
        {
            guiControls.Add(control.ID, control);
            orderedGuiControls.Add(control);

            if (control is GuiLabel)
            {
                GuiLabel guiLabel = control as GuiLabel;

                Label l = new Label();

                l.Left    = guiLabel.Left;
                l.Top     = guiLabel.Top;
                l.Width   = guiLabel.Width;
                l.Height  = guiLabel.Height;
                l.Visible = guiLabel.Visible;
                l.Enabled = guiLabel.Enabled;
                l.Enabled = guiLabel.Enabled;

                l.ForeColor = Color.FromName(guiLabel.ForeColor);
                if (guiLabel.BackColor != string.Empty)
                {
                    l.BackColor = Color.FromName(guiLabel.BackColor);
                }

                l.TextAlign = ContentAlignment.BottomLeft;

                l.Name = guiLabel.ID;
                l.Text = guiLabel.Text;
                tooltip.SetToolTip(l, guiLabel.ToolTip);

                Font      font  = l.Font;
                FontStyle style = FontStyle.Regular;
                if (guiLabel.Bold)
                {
                    style = style | FontStyle.Bold;
                }
                if (guiLabel.Underline)
                {
                    style = style | FontStyle.Underline;
                }
                if (guiLabel.Strikeout)
                {
                    style = style | FontStyle.Strikeout;
                }
                if (guiLabel.Italic)
                {
                    style = style | FontStyle.Italic;
                }
                l.Font = new Font(font, style);

                l.LostFocus += new EventHandler(ControlLostFocus);
                l.Enter     += new EventHandler(ControlEnter);

                addControl(control, l);
            }
            else if (control is GuiButton)
            {
                GuiButton guiButton = control as GuiButton;

                Button b = new Button();

                b.Click     += new EventHandler(OnButtonClick);
                b.LostFocus += new EventHandler(ControlLostFocus);
                b.Enter     += new EventHandler(ControlEnter);

                if (guiButton.ClosesForm)
                {
                    b.Click += new EventHandler(OnButtonOkClick);
                }
                else if (guiButton.CancelGeneration)
                {
                    b.Click += new EventHandler(OnButtonCancelClick);
                }

                b.Text    = guiButton.Text;
                b.Left    = guiButton.Left;
                b.Top     = guiButton.Top;
                b.Width   = guiButton.Width;
                b.Height  = guiButton.Height;
                b.Name    = guiButton.ID;
                b.Visible = guiButton.Visible;
                b.Enabled = guiButton.Enabled;

                b.ForeColor = Color.FromName(guiButton.ForeColor);
                if (guiButton.BackColor != string.Empty)
                {
                    b.BackColor = Color.FromName(guiButton.BackColor);
                }

                tooltip.SetToolTip(b, guiButton.ToolTip);

                addControl(control, b);
            }
            else if (control is GuiCheckBox)
            {
                GuiCheckBox guiCheckBox = control as GuiCheckBox;

                CheckBox cb = new CheckBox();

                cb.Checked = guiCheckBox.Checked;

                cb.CheckedChanged += new EventHandler(OnCheckBoxClick);
                cb.LostFocus      += new EventHandler(ControlLostFocus);
                cb.Enter          += new EventHandler(ControlEnter);

                cb.Text    = guiCheckBox.Text;
                cb.Left    = guiCheckBox.Left;
                cb.Top     = guiCheckBox.Top;
                cb.Width   = guiCheckBox.Width;
                cb.Height  = guiCheckBox.Height;
                cb.Name    = guiCheckBox.ID;
                cb.Visible = guiCheckBox.Visible;
                cb.Enabled = guiCheckBox.Enabled;

                cb.ForeColor = Color.FromName(guiCheckBox.ForeColor);
                if (guiCheckBox.BackColor != string.Empty)
                {
                    cb.BackColor = Color.FromName(guiCheckBox.BackColor);
                }

                tooltip.SetToolTip(cb, guiCheckBox.ToolTip);

                addControl(control, cb);
            }
            else if (control is GuiFilePicker)
            {
                GuiFilePicker guiPicker = control as GuiFilePicker;

                Button b = new Button();

                if (guiPicker.PicksFolder)
                {
                    b.Click += new EventHandler(OnFolderSelectorClick);
                }
                else
                {
                    b.Click += new EventHandler(OnFileSelectorClick);
                }

                b.Text    = guiPicker.Text;
                b.Left    = guiPicker.Left;
                b.Top     = guiPicker.Top;
                b.Width   = guiPicker.Width;
                b.Height  = guiPicker.Height;
                b.Name    = guiPicker.ID;
                b.Visible = guiPicker.Visible;
                b.Enabled = guiPicker.Enabled;

                b.ForeColor = Color.FromName(guiPicker.ForeColor);
                if (guiPicker.BackColor != string.Empty)
                {
                    b.BackColor = Color.FromName(guiPicker.BackColor);
                }

                tooltip.SetToolTip(b, guiPicker.ToolTip);

                b.LostFocus += new EventHandler(ControlLostFocus);
                b.Enter     += new EventHandler(ControlEnter);

                addControl(control, b);
            }
            else if (control is GuiTextBox)
            {
                GuiTextBox guiTextBox = control as GuiTextBox;

                TextBox tb = new TextBox();

                tb.Left      = guiTextBox.Left;
                tb.Top       = guiTextBox.Top;
                tb.Width     = guiTextBox.Width;
                tb.Height    = guiTextBox.Height;
                tb.Visible   = guiTextBox.Visible;
                tb.Enabled   = guiTextBox.Enabled;
                tb.Multiline = guiTextBox.Multiline;
                tb.WordWrap  = guiTextBox.WordWrap;

                if (guiTextBox.VerticalScroll && guiTextBox.HorizontalScroll)
                {
                    tb.ScrollBars = ScrollBars.Both;
                }
                else if (guiTextBox.VerticalScroll)
                {
                    tb.ScrollBars = ScrollBars.Vertical;
                }
                else if (guiTextBox.HorizontalScroll)
                {
                    tb.ScrollBars = ScrollBars.Horizontal;
                }
                else
                {
                    tb.ScrollBars = ScrollBars.None;
                }

                tb.ForeColor = Color.FromName(guiTextBox.ForeColor);
                if (guiTextBox.BackColor != string.Empty)
                {
                    tb.BackColor = Color.FromName(guiTextBox.BackColor);
                }

                tb.Name = guiTextBox.ID;
                tb.Text = guiTextBox.Text;
                tooltip.SetToolTip(tb, guiTextBox.ToolTip);

                tb.KeyPress  += new KeyPressEventHandler(OnTextBoxKeyPress);
                tb.LostFocus += new EventHandler(ControlLostFocus);
                tb.Enter     += new EventHandler(ControlEnter);

                addControl(control, tb);
            }
            else if (control is GuiComboBox)
            {
                GuiComboBox guiComboBox = control as GuiComboBox;

                ComboBox cb = new ComboBox();
                cb.DropDownStyle = ComboBoxStyle.DropDownList;
                cb.Sorted        = guiComboBox.Sorted;

                foreach (string val in guiComboBox.Items)
                {
                    ListControlItem item = new ListControlItem(val, guiComboBox[val]);
                    cb.Items.Add(item);

                    if (val == guiComboBox.SelectedValue)
                    {
                        cb.SelectedItem = item;
                    }
                }

                cb.SelectedValueChanged += new EventHandler(OnComboBoxChange);
                cb.LostFocus            += new EventHandler(ControlLostFocus);
                cb.Enter += new EventHandler(ControlEnter);

                cb.Left    = guiComboBox.Left;
                cb.Top     = guiComboBox.Top;
                cb.Width   = guiComboBox.Width;
                cb.Height  = guiComboBox.Height;
                cb.Visible = guiComboBox.Visible;
                cb.Enabled = guiComboBox.Enabled;

                cb.ForeColor = Color.FromName(guiComboBox.ForeColor);
                if (guiComboBox.BackColor != string.Empty)
                {
                    cb.BackColor = Color.FromName(guiComboBox.BackColor);
                }

                cb.Name = guiComboBox.ID;

                tooltip.SetToolTip(cb, guiComboBox.ToolTip);

                addControl(control, cb);
            }
            else if (control is GuiListBox)
            {
                GuiListBox guiListBox = control as GuiListBox;

                ListBox lb = new ListBox();
                if (guiListBox.IsMultiSelect)
                {
                    lb.SelectionMode = SelectionMode.MultiExtended;
                }
                else
                {
                    lb.SelectionMode = SelectionMode.One;
                }
                lb.Sorted = guiListBox.Sorted;

                lb.Left    = guiListBox.Left;
                lb.Top     = guiListBox.Top;
                lb.Width   = guiListBox.Width;
                lb.Height  = guiListBox.Height;
                lb.Visible = guiListBox.Visible;
                lb.Enabled = guiListBox.Enabled;

                lb.ForeColor = Color.FromName(guiListBox.ForeColor);
                if (guiListBox.BackColor != string.Empty)
                {
                    lb.BackColor = Color.FromName(guiListBox.BackColor);
                }

                lb.Name = guiListBox.ID;

                tooltip.SetToolTip(lb, guiListBox.ToolTip);

                foreach (string val in guiListBox.Items)
                {
                    ListControlItem item  = new ListControlItem(val, guiListBox[val]);
                    int             index = lb.Items.Add(item);

                    if (guiListBox.SelectedItems.Contains(val))
                    {
                        lb.SetSelected(index, true);
                    }
                }

                // For some reason this fixes all of my timing issues!
                object s;
                foreach (object o in lb.SelectedIndices)
                {
                    s = o;
                }

                lb.KeyUp += new KeyEventHandler(OnListBoxKeyUp);
                lb.SelectedValueChanged += new EventHandler(OnListBoxChange);
                lb.LostFocus            += new EventHandler(ControlLostFocus);
                lb.Enter += new EventHandler(ControlEnter);

                addControl(control, lb);
            }
            else if (control is GuiGrid)
            {
                GuiGrid guiGrid = control as GuiGrid;

                DataGrid dg = new DataGrid();

                dg.Left    = guiGrid.Left;
                dg.Top     = guiGrid.Top;
                dg.Width   = guiGrid.Width;
                dg.Height  = guiGrid.Height;
                dg.Visible = guiGrid.Visible;
                dg.Enabled = guiGrid.Enabled;

                if (guiGrid.ForeColor != string.Empty)
                {
                    dg.ForeColor = Color.FromName(guiGrid.ForeColor);
                }
                else if (guiGrid.BackColor != string.Empty)
                {
                    dg.BackColor = Color.FromName(guiGrid.BackColor);
                }

                dg.Name       = guiGrid.ID;
                dg.DataSource = SimpleTableTools.ConvertToDataTable(guiGrid.DataSource);

                tooltip.SetToolTip(dg, guiGrid.ToolTip);

                dg.LostFocus += new EventHandler(ControlLostFocus);
                dg.Enter     += new EventHandler(ControlEnter);

                addControl(control, dg);
            }
            else if (control is GuiCheckBoxList)
            {
                GuiCheckBoxList guiCheckBoxList = control as GuiCheckBoxList;

                CheckedListBox lb = new CheckedListBox();
                lb.Sorted       = guiCheckBoxList.Sorted;
                lb.CheckOnClick = true;
                lb.Left         = guiCheckBoxList.Left;
                lb.Top          = guiCheckBoxList.Top;
                lb.Width        = guiCheckBoxList.Width;
                lb.Height       = guiCheckBoxList.Height;
                lb.Visible      = guiCheckBoxList.Visible;
                lb.Enabled      = guiCheckBoxList.Enabled;

                lb.ForeColor = Color.FromName(guiCheckBoxList.ForeColor);
                if (guiCheckBoxList.BackColor != string.Empty)
                {
                    lb.BackColor = Color.FromName(guiCheckBoxList.BackColor);
                }

                lb.Name = guiCheckBoxList.ID;
                tooltip.SetToolTip(lb, guiCheckBoxList.ToolTip);

                foreach (string val in guiCheckBoxList.Items)
                {
                    ListControlItem item  = new ListControlItem(val, guiCheckBoxList[val]);
                    int             index = lb.Items.Add(item);

                    if (guiCheckBoxList.SelectedItems.Contains(val))
                    {
                        lb.SetItemChecked(index, true);
                    }
                }

                // For some reason this fixes all of my timing issues!
                object s;
                foreach (object o in lb.CheckedItems)
                {
                    s = o;
                }

                lb.KeyUp += new KeyEventHandler(OnCheckedListBoxKeyUp);
                lb.SelectedValueChanged += new EventHandler(OnCheckedListBoxChange);
                lb.LostFocus            += new EventHandler(ControlLostFocus);
                lb.Enter += new EventHandler(ControlEnter);

                addControl(control, lb);
            }
        }
예제 #10
0
        public void UpdateData()
        {
            Control w32ctrl;

            foreach (GuiControl control in guiControls.Values)
            {
                w32ctrl = win32Controls[control.ID] as Control;

                if (control is GuiLabel)
                {
                    GuiLabel guiLabel = control as GuiLabel;
                    Label    l        = w32ctrl as Label;

                    guiLabel.Text = l.Text;
                }
                else if (control is GuiButton)
                {
                    GuiButton guiButton = control as GuiButton;
                    Button    b         = w32ctrl as Button;

                    guiButton.Text = b.Text;
                }
                else if (control is GuiCheckBox)
                {
                    GuiCheckBox guiCheckBox = control as GuiCheckBox;
                    CheckBox    cb          = w32ctrl as CheckBox;

                    guiCheckBox.Text    = cb.Text;
                    guiCheckBox.Checked = cb.Checked;
                }
                else if (control is GuiFilePicker)
                {
                    GuiFilePicker guiPicker = control as GuiFilePicker;
                    Button        b         = w32ctrl as Button;

                    guiPicker.Text = b.Text;
                    b.Tag          = win32Controls[guiPicker.TargetControl];
                }
                else if (control is GuiTextBox)
                {
                    GuiTextBox guiTextBox = control as GuiTextBox;
                    TextBox    tb         = w32ctrl as TextBox;

                    guiTextBox.Text = tb.Text;
                }
                else if (control is GuiComboBox)
                {
                    GuiComboBox guiComboBox = control as GuiComboBox;
                    ComboBox    cb          = w32ctrl as ComboBox;

                    if (cb.SelectedItem is ListControlItem)
                    {
                        guiComboBox.SelectedValue = ((ListControlItem)cb.SelectedItem).Value;
                    }
                }
                else if (control is GuiListBox)
                {
                    GuiListBox guiListBox = control as GuiListBox;
                    ListBox    lb         = w32ctrl as ListBox;

                    guiListBox.Clear();
                    foreach (ListControlItem item in lb.Items)
                    {
                        guiListBox[item.Value] = item.Text;
                    }
                    foreach (ListControlItem item in lb.SelectedItems)
                    {
                        guiListBox.SelectedItems.Add(item.Value);
                    }
                }
                else if (control is GuiGrid)
                {
                    GuiGrid  guiGrid = control as GuiGrid;
                    DataGrid dg      = w32ctrl as DataGrid;

                    guiGrid.DataSource = SimpleTableTools.ConvertToSimpleTable(dg.DataSource as DataTable);
                }
                else if (control is GuiCheckBoxList)
                {
                    GuiCheckBoxList guiCheckBoxList = control as GuiCheckBoxList;
                    CheckedListBox  lb = w32ctrl as CheckedListBox;

                    guiCheckBoxList.Clear();
                    foreach (ListControlItem item in lb.Items)
                    {
                        guiCheckBoxList[item.Value] = item.Text;
                    }
                    foreach (ListControlItem item in lb.CheckedItems)
                    {
                        guiCheckBoxList.SelectedItems.Add(item.Value);
                    }
                }
            }
        }
예제 #11
0
        /** Creates the UI componenets required to display the gui */
        private void CreateUIComponents()
        {
            var window = new GuiWindow(800, 560);

            window.Background.Sprite = ResourceManager.GetSprite("Gui/InnerWindow");
            window.Background.Color  = new Color(0.5f, 0.5f, 0.5f);
            PositionComponent(window, 0, 0);
            Add(window);

            // ------------------

            nameInput               = new GuiTextField(0, 0, 200);
            nameInput.Value         = CharacterNameGenerator.GenerateName();
            nameInput.LabelText     = "Name";
            nameInput.LabelPosition = LabelPosition.Left;
            window.Add(nameInput, 0, 20);

            var randomButton = new GuiButton("random", -1, 20);

            window.Add(randomButton, (int)nameInput.Bounds.xMax + 10, 25);

            // ------------------

            var genderListFrame = new FramedListBox <MDRGender>(200, 100, "Gender");

            window.Add(genderListFrame, 260, 100);

            portraitSelector          = new GuiPictureSeletor();
            portraitSelector.Pictures = CoM.Instance.Portraits.GetEntries().ToArray();
            window.Add(portraitSelector, 460, 70 + 18 + 20);

            allRacesToggle                 = new GuiToggleButton();
            allRacesToggle.LabelText       = "Show All";
            allRacesToggle.LabelPosition   = LabelPosition.Right;
            allRacesToggle.X               = (int)portraitSelector.Bounds.xMax + 10;
            allRacesToggle.Y               = (int)portraitSelector.Bounds.y + 30;
            allRacesToggle.Value           = false;
            allRacesToggle.OnValueChanged += delegate {
                updatePortraits();
            };
            window.Add(allRacesToggle);

            // ------------------

            var raceListFrame = new FramedListBox <MDRRace>(200, 240, "Race");

            window.Add(raceListFrame, 20, 240);

            statList = new GuiStatList(new MDRStats());
            window.Add(statList, 220 + 20, 240);

            var characterInfo = new GuiWindow(250, 240, "Info");

            window.Add(characterInfo, 470 + 40, 240);

            characterInfoText          = new GuiLabel(0, 0, "");
            characterInfoText.Align    = GuiAlignment.Full;
            characterInfoText.WordWrap = true;
            characterInfo.Add(characterInfoText);

            // ------------------

            // ------------------

            GuiButton cancelButton = new GuiButton("Cancel", 100);

            window.Add(cancelButton, 20, -20);

            GuiButton doneButton = new GuiButton("Save", 100);

            window.Add(doneButton, -20, -20);


            raceList = raceListFrame.ListBox;
            foreach (MDRRace race in CoM.Races)
            {
                raceList.Add(race);
            }

            genderList = genderListFrame.ListBox;
            genderList.Add(MDRGender.Male);
            genderList.Add(MDRGender.Female);

            genderList.OnSelectedChanged += delegate {
                updateGender();
            };
            raceList.OnSelectedChanged += delegate {
                updateRace();
            };

            doneButton.OnMouseClicked += delegate {
                if (statList.FreePoints != 0)
                {
                    Engine.ConfirmAction(saveAndClose, "This character still has " + Util.Colorise(statList.FreePoints, Color.green) + " stat points left to spend.\nAre you sure you want to save the character without spending them?");
                }
                else
                {
                    saveAndClose();
                }
            };

            cancelButton.OnMouseClicked += delegate {
                Engine.PopState();
            };
            randomButton.OnMouseClicked += delegate {
                nameInput.Value = CharacterNameGenerator.GenerateName();
            };

            updateRace();
            updateGender();
        }
예제 #12
0
        public override void Setup()
        {
            ui.Title  = "ASP.NET InlineGrid (CSharp dOOdads)";
            ui.Width  = 350;
            ui.Height = 450;

            // width of labels
            int lableWidth = 120;

            // Grab default output path
            string sOutputPath = "";

            if (input.Contains("defaultOutputPath"))
            {
                sOutputPath = input["defaultOutputPath"].ToString();
            }

            // Setup Folder selection input control.
            GuiLabel      lblPath = ui.AddLabel("lblPath", "Select the output path:", "Select the output path in the field below.");
            GuiTextBox    txtPath = ui.AddTextBox("txtPath", sOutputPath, "Select the Output Path.");
            GuiFilePicker btnPath = ui.AddFilePicker("btnPath", "Select Path", "Select the Output Path.", "txtPath", true);

            // size text box and button
            txtPath.Width = 250;
            btnPath.Width = ui.Width - txtPath.Left - txtPath.Width - 20;

            // position button
            btnPath.Top  = txtPath.Top;
            btnPath.Left = txtPath.Left + txtPath.Width;

            GuiLabel   lblNamespace = ui.AddLabel("lblNamespace", "Namespace: ", "Provide namespace.");
            GuiTextBox txtNamespace = ui.AddTextBox("txtNamespace", "FineSchool.MvcApp.Areas.Admin.Controllers", "Provide your namespace.");

            // size label and text box
            lblNamespace.Width = lableWidth;
            txtNamespace.Width = ui.Width - lblNamespace.Left - lblNamespace.Width - 20;

            // position text box
            txtNamespace.Top  = lblNamespace.Top;
            txtNamespace.Left = lblNamespace.Left + lblNamespace.Width;

            // Setup Database selection combobox.
            GuiLabel    lblDatabases = ui.AddLabel("lblDatabases", "Select a database:", "Select a database in the dropdown below.");
            GuiComboBox cmbDatabases = ui.AddComboBox("databaseName", "Select a database.");

            // size label and combo box
            lblDatabases.Width = lableWidth;
            cmbDatabases.Width = ui.Width - lblDatabases.Left - lblDatabases.Width - 20;

            // position combo box
            cmbDatabases.Top  = lblDatabases.Top;
            cmbDatabases.Left = lblDatabases.Left + lblDatabases.Width;

            // Setup Tables selection multi-select listbox.
            GuiLabel    lblTables = ui.AddLabel("lblTables", "Select table:", "Select table from the combobox below.");
            GuiComboBox cmbTables = ui.AddComboBox("tableName", "Select a table.");

            // size label and combo box
            lblTables.Width = lableWidth;
            cmbTables.Width = ui.Width - lblTables.Left - lblTables.Width - 20;

            // position combo box
            cmbTables.Top  = lblTables.Top;
            cmbTables.Left = lblTables.Left + lblTables.Width;

            // setup columns list box
            GuiLabel   lblColumns = ui.AddLabel("lblColumns", "Select columns:", "Select columns from the listbox below.");
            GuiListBox lstColumns = ui.AddListBox("lstColumns", "Select columns.");

            // size label and combo box
            lstColumns.Height = 150;
            lblColumns.Width  = lableWidth;
            lstColumns.Width  = ui.Width - lblColumns.Left - lblColumns.Width - 20;

            // position combo box
            lstColumns.Top  = lblColumns.Top;
            lstColumns.Left = lblColumns.Left + lblColumns.Width;

            // bind data to the controls
            cmbDatabases.BindData(MyMeta.Databases);
            cmbDatabases.SelectedValue = MyMeta.DefaultDatabase.Name;
            cmbTables.BindData(MyMeta.Databases[cmbDatabases.SelectedValue].Tables);


            // Attach the onchange event to the cmbDatabases control.
            cmbDatabases.AttachEvent("onchange", "cmbDatabases_onchange");
            cmbTables.AttachEvent("onchange", "cmbTables_onchange");
            cmbTables.SelectedValue = "Suzhi";
            lstColumns.BindData(MyMeta.Databases[cmbDatabases.SelectedValue].Tables[cmbTables.SelectedValue].Columns);

            ui.ShowGui = true;
        }
예제 #13
0
        public TempleState()
            : base("Temple")
        {
            MainWindow.Width  = 650;
            MainWindow.Height = 400;

            // Background:
            MainWindow.InnerShadow       = true;
            MainWindow.Background.Align  = GuiAlignment.None;
            MainWindow.Background.Sprite = ResourceManager.GetSprite("Backgrounds/TownTemple");
            MainWindow.Background.Color  = Color.white;
            MainWindow.Background.BestFit(MainWindow.ContentsFrame, true);
            MainWindow.PositionComponent(MainWindow.Background, 0, 0);

            // Bodies list:
            deadCharactersList = new GuiListBox <MDRCharacter>(0, 0, 250, 200);
            var deadCharactersListFrame = GuiWindow.CreateFrame(deadCharactersList, "Characters");

            deadCharactersListFrame.Style            = Engine.GetStyleCopy("Box50");
            deadCharactersListFrame.Background.Color = Colors.BackgroundYellow.Faded(0.75f);
            MainWindow.Add(deadCharactersListFrame, 10, 0);

            noDeadCharacters            = new GuiLabel("There are no dead\ncharacters here.", 250);
            noDeadCharacters.TextAlign  = TextAnchor.MiddleCenter;
            noDeadCharacters.DropShadow = true;
            MainWindow.Add(noDeadCharacters, 10, 150);

            // Info:
            raiseInfo               = new GuiLabel(0, 0, "", 300, 200);
            raiseInfo.WordWrap      = true;
            raiseInfo.Color         = new Color(0.9f, 0.9f, 0.9f, 0.9f);
            raiseInfo.Style.padding = new RectOffset(10, 10, 10, 4);
            var raiseInfoFrame = GuiWindow.CreateFrame(raiseInfo, "Details");

            raiseInfoFrame.Style            = Engine.GetStyleCopy("Box50");
            raiseInfoFrame.Background.Color = Color.white.Faded(0.75f);
            MainWindow.Add(raiseInfoFrame, (int)deadCharactersList.Bounds.xMax + 40, (int)deadCharactersList.Bounds.yMin);

            // Buttons:
            raiseCharacterButton = new GuiButton("Raise", 120);
            MainWindow.Add(raiseCharacterButton, raiseInfoFrame.X + 70, (int)raiseInfoFrame.Bounds.yMax + 5);

            costLabel = new GuiCoinAmount();

            MainWindow.Add(costLabel, (int)raiseCharacterButton.Bounds.xMax + 20, raiseCharacterButton.Y + 3);

            // Triggers
            deadCharactersList.OnSelectedChanged += delegate {
                doUpdateRaiseInfo();
            };
            PopulateDeadCharacterList();

            raiseCharacterButton.OnMouseClicked += delegate {
                if (deadCharactersList.Selected != null)
                {
                    doRaiseCharacter(deadCharactersList.Selected);
                }
            };

            RepositionControls();
        }
예제 #14
0
파일: GuildState.cs 프로젝트: bsimser/CoM
        public GuildState()
            : base("Guild")
        {
            Util.Assert(CoM.AllDataLoaded, "Data must be loaded before GuildState can be created.");

            MainWindow.Width  = 600;
            MainWindow.Height = 450;

            // --------------------------------------

            MainWindow.InnerShadow       = true;
            MainWindow.Background.Align  = GuiAlignment.None;
            MainWindow.Background.Sprite = ResourceManager.GetSprite("Backgrounds/TownGuild");
            MainWindow.Background.Color  = Color.white;
            MainWindow.Background.BestFit(MainWindow.ContentsFrame, true);
            MainWindow.PositionComponent(MainWindow.Background, 0, 0);

            GuildInfoSection = new GuiContainer((int)MainWindow.ContentsBounds.width - 200, (int)MainWindow.ContentsBounds.height);
            MainWindow.Add(GuildInfoSection, -1, 0);

            GuildListSection                  = new GuiContainer(205, (int)MainWindow.ContentsBounds.height + 10);
            GuildListSection.X                = -5;
            GuildListSection.Y                = -5;
            GuildListSection.Style            = Engine.GetStyleCopy("Frame");
            GuildListSection.EnableBackground = true;
            GuildListSection.Color            = new Color(1f, 1f, 1f, 0.75f);
            MainWindow.Add(GuildListSection);

            GuildList = new GuiListBox <MDRGuild>(0, 0, 180, 300);
            GuildListSection.Add(GuildList, 15, 15);

            GuildTitle           = new GuiLabel(-5, -5, "", GuildInfoSection.Width, 50);
            GuildTitle.Align     = GuiAlignment.Top;
            GuildTitle.TextAlign = TextAnchor.MiddleCenter;
            GuildTitle.FontSize  = 22;
            GuildInfoSection.Add(GuildTitle);

            GuildInfo          = new GuiLabel(10, 50, "", (int)GuildInfoSection.ContentsFrame.width - 10);
            GuildInfo.WordWrap = true;
            GuildInfoSection.Add(GuildInfo);

            // --------------------------------------

            JoinButton = new GuiButton("Join", 120);
            GuildInfoSection.Add(JoinButton, 0, -20);

            LevelButton = new GuiButton("Level", 120);
            GuildInfoSection.Add(LevelButton, 0, -20);

            GuildList.OnSelectedChanged += delegate {
                updateGuildInfo();
            };
            JoinButton.OnMouseClicked += delegate {
                JoinGuild();
            };
            LevelButton.OnMouseClicked += delegate {
                LevelUp();
            };

            GuildList.DoConvertItemToString = delegate(MDRGuild guild) {
                bool hasPrereq     = (guild.RequiredGuild != null);
                bool couldJoin     = guild.CanAccept(Character);
                bool isMemeber     = Character.Membership[guild].IsMember;
                bool currentMember = (guild == Character.CurrentGuild);

                string levelInfo = isMemeber ? "(" + Character.Membership[guild].CurrentLevel + ")" : "";

                string guildDescription = guild.Name + levelInfo;

                if (hasPrereq)
                {
                    guildDescription = "  " + guildDescription;
                }

                if (currentMember)
                {
                    guildDescription = Util.Colorise(guildDescription, Color.yellow, true);
                }
                else if (isMemeber)
                {
                    guildDescription = Util.Colorise(guildDescription, new Color(0.9f, 0.9f, 0.9f));
                }
                else if (couldJoin)
                {
                    guildDescription = Util.Colorise(guildDescription, new Color(0.9f, 0.9f, 0.9f));
                }
                else
                {
                    guildDescription = Util.Colorise(guildDescription, new Color(0.7f, 0.7f, 0.7f));
                }

                return(guildDescription);
            };

            CoM.Party.OnSelectedChanged += delegate {
                RefreshUI();
            };

            RepositionControls();
            RefreshUI();
        }