示例#1
0
        private void ApplySelectedItem()
        {
            if (listBox == null)
            {
                return;
            }
            var listSelectedItem = listBox.SelectedItem;

            for (int i = 0; i < Items.Count; i++)
            {
                if (Items[i] == listSelectedItem)
                {
                    filter = listSelectedItem != null?listSelectedItem.ToString() : "";

                    SelectedItem = listSelectedItem;
                    break;
                }
            }
            listBox.Dispose();
            listBox = null;
        }
示例#2
0
        private void ListBoxOnDisposed(object sender, EventArgs eventArgs)
        {
            var clientRect = new System.Drawing.Rectangle(0, 0, Width, Height);
            var contains   = clientRect.Contains(PointToClient(MousePosition));

            if (!contains)
            {
                listBoxOpened = false;
            }
            else
            {
                listBoxOpened = !listBoxOpened;
            }

            listBox.MouseUp  -= ListBoxOnMouseUp;
            listBox.KeyDown  -= ListBoxOnKeyDown;
            listBox.Disposed -= ListBoxOnDisposed;

            listBox = null;

            OnDropDownClosed(EventArgs.Empty);
        }
示例#3
0
            public void InitializeComponent()
            {
                listBox                = new ComboListBox();
                listBox.BackColor      = owner.BackColor;
                listBox.BorderColor    = owner.uwfBorderColorHovered;
                listBox.Font           = owner.Font;
                listBox.ForeColor      = owner.ForeColor;
                listBox.Width          = owner.Width;
                listBox.IntegralHeight = false;
                listBox.ItemHeight     = owner.ItemHeight;
                listBox.Size           = new Size(Width, Height);
                listBox.Location       = new Point(0, -listBox.Height);

                currentY = listBox.Location.Y;

                listBox.uwfWrapText           = false;
                listBox.uwfShadowBox          = true;
                listBox.uwfItemHoverColor     = owner.uwfListItemHoverColor;
                listBox.uwfSelectionBackColor = owner.uwfListItemSelectedBackgroundColor;
                listBox.uwfSelectionForeColor = owner.uwfListItemSelectedForeColor;

                Controls.Add(listBox);
            }
        /// <summary>
        /// Display the combo box at the specified location, or the list box pulled down from the specified location.
        /// </summary>
        /// <param name="loc"></param>
        public void Activate(SIL.Utils.Rect loc)
        {
            CheckDisposed();

            FwComboBox combo = m_combo as FwComboBox;

            if (combo != null)
            {
                combo.Location = new System.Drawing.Point(loc.left, loc.top);
                // 21 is the default height of a combo, the smallest reasonable size.
                combo.Size = new System.Drawing.Size(Math.Max(loc.right - loc.left + 30, 200), Math.Max(loc.bottom - loc.top, 50));
                if (!m_owner.Controls.Contains(combo))
                {
                    m_owner.Controls.Add(combo);
                }
            }
            else
            {
                ComboListBox c = (m_combo as ComboListBox);
                c.AdjustSize(500, 400);                 // these are maximums!
                c.Launch(m_owner.RectangleToScreen(loc), Screen.GetWorkingArea(m_owner));
            }
        }
示例#5
0
        /// <summary>
        /// Executes in two distinct scenarios.
        ///
        /// 1. If disposing is true, the method has been called directly
        /// or indirectly by a user's code via the Dispose method.
        /// Both managed and unmanaged resources can be disposed.
        ///
        /// 2. If disposing is false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference (access)
        /// other managed objects, as they already have been garbage collected.
        /// Only unmanaged resources can be disposed.
        /// </summary>
        /// <param name="disposing"></param>
        /// <remarks>
        /// If any exceptions are thrown, that is fine.
        /// If the method is being done in a finalizer, it will be ignored.
        /// If it is thrown by client code calling Dispose,
        /// it needs to be handled by fixing the bug.
        ///
        /// If subclasses override this method, they should call the base implementation.
        /// </remarks>
        protected virtual void Dispose(bool disposing)
        {
            System.Diagnostics.Debug.WriteLineIf(!disposing, "****************** Missing Dispose() call for " + GetType().Name + " ******************");
            // Must not be run more than once.
            if (m_isDisposed)
            {
                return;
            }

            if (disposing)
            {
                // Dispose managed resources here.
                if (m_combo != null)
                {
                    m_combo.SelectedIndexChanged -= new EventHandler(m_combo_SelectedIndexChanged);
                    FwComboBox combo = m_combo as FwComboBox;
                    if (combo != null && combo.Parent == null)
                    {
                        combo.Dispose();
                    }
                    else
                    {
                        ComboListBox clb = (m_combo as ComboListBox);
                        if (clb != null)
                        {
                            clb.Dispose();
                        }
                    }
                }
            }

            // Dispose unmanaged resources here, whether disposing is true or false.
            m_cache = null;
            m_owner = null;

            m_isDisposed = true;
        }
示例#6
0
		protected override void Dispose (bool disposing)
		{
			if (disposing) {
				if (listbox_ctrl != null) {
					listbox_ctrl.Dispose ();
					Controls.RemoveImplicit (listbox_ctrl);
					listbox_ctrl = null;
				}
			
				if (textbox_ctrl != null) {
					Controls.RemoveImplicit (textbox_ctrl);
					textbox_ctrl.Dispose ();
					textbox_ctrl = null;
				}
			}
			
			base.Dispose (disposing);
		}
示例#7
0
		internal void DropDownListBoxFinished ()
		{
			if (DropDownStyle == ComboBoxStyle.Simple)
				return;
				
			FindMatchOrSetIndex (SelectedIndex);
			button_state = ButtonState.Normal;
			Invalidate (button_area);
			dropped_down = false;
			OnDropDownClosed (EventArgs.Empty);
			/*
			 * Apples X11 looses override-redirect when doing a Unmap/Map on a previously mapped window
			 * this causes the popup to appear under the main form.  This is horrible but necessary
			 */
			 
			 // If the user opens a new form in an event, it will close our dropdown,
			 // so we need a null check here
			 if (listbox_ctrl != null) {
				listbox_ctrl.Dispose ();
				listbox_ctrl = null;
			}
			 // The auto complete list could have been shown after the listbox,
			 // so make sure it's hidden.
			 if (textbox_ctrl != null)
				 textbox_ctrl.HideAutoCompleteList ();
		}
示例#8
0
		private void CreateComboListBox ()
		{
			listbox_ctrl = new ComboListBox (this);
			listbox_ctrl.HighlightedIndex = SelectedIndex;
		}
        private void InitControls()
        {
            int tableRow    = 0;
            int tableColumn = 0;

            /***
             * FontAlignmentTestWidget test = new FontAlignmentTestWidget ();
             * this.AddChild (test, tableRow++, tableColumn);
             ***/

            m_Label1 = new CaptionLabel("label1");
            //m_Label1.Styles.GetStyle (WidgetStates.Default).BackColorBrush.Color = SolarizedColors.Base2;
            m_Label1.Style.BackColorBrush.Color = Theme.Colors.Base2;
            m_Label1.Dock = Docking.Fill;
            m_Label1.Text = "Check Boxes".ToUpper();
            this.AddChild(m_Label1, tableRow++, tableColumn);

            m_CheckBox1 = new CheckBox("checkbox1", "CheckBox 1");
            this.AddChild(m_CheckBox1, tableRow++, tableColumn);

            m_CheckBox3         = new CheckBox("checkbox3", "CheckBox 3 (disabled)");
            m_CheckBox3.Enabled = false;
            this.AddChild(m_CheckBox3, tableRow++, tableColumn);

            m_ToggleCheckBox         = new ToggleCheckBox("togglecheckbox", "Option 1");
            m_ToggleCheckBox.Checked = true;
            this.AddChild(m_ToggleCheckBox, tableRow++, tableColumn);

            m_Label2 = new CaptionLabel("label2");
            m_Label2.Style.BackColorBrush.Color = Theme.Colors.Base2;
            m_Label2.Dock = Docking.Fill;
            m_Label2.Text = "Radio Buttons".ToUpper();
            this.AddChild(m_Label2, tableRow++, tableColumn);

            m_RadioButton1         = new RadioButton("radiobutton1", "RadioButton 1");
            m_RadioButton1.Checked = true;
            this.AddChild(m_RadioButton1, tableRow++, tableColumn);

            m_RadioButton2 = new RadioButton("radiobutton2", "RadioButton 2");
            this.AddChild(m_RadioButton2, tableRow++, tableColumn);

            m_RadioButton3 = new RadioButton("radiobutton3", "RadioButton 3");
            this.AddChild(m_RadioButton3, tableRow++, tableColumn);

            m_Label3 = new CaptionLabel("label3");
            m_Label3.Style.BackColorBrush.Color = Theme.Colors.Base2;
            m_Label3.Dock = Docking.Fill;
            m_Label3.Text = "Progress Bars".ToUpper();
            this.AddChild(m_Label3, tableRow++, tableColumn);

            m_ProgressBar         = new ProgressBar("ProgressBar1");
            m_ProgressBar.Value   = 0.625f;
            m_ProgressBar.Tooltip = "Click to animate..";
            m_ProgressBar.Click  += delegate {
                ParentWindow.Animator.AddAnimation(m_ProgressBar, "Value", 0, 1, 5);
            };
            m_ProgressBar.AnimationCompleted += delegate {
                m_ProgressBar.Value = 0.625f;
                (ParentWindow as ApplicationWindow).ShowNotification("Progressbar animation completed, state was reset to it's former value.", ColorContexts.Information);
            };
            this.AddChild(m_ProgressBar, tableRow++, tableColumn);


            /*** ***/
            // Circle Sliders in a Sub-Container
            m_CircleSliderSubContainer        = new TableLayoutContainer("m_CircleSliderSubContainer");
            m_CircleSliderSubContainer.Margin = new Padding(0, 0, 0, 16);

            m_CircleSlider1         = new CircleSlider("CircleSlider1", ColorContexts.Information);
            m_CircleSlider1.Value   = 0.75f;
            m_CircleSlider1.Tooltip = "Click to animate..";
            m_CircleSliderSubContainer.AddChild(m_CircleSlider1, 0, 0);
            m_CircleSlider1.Click += delegate {
                ParentWindow.Animator.AddAnimation(m_CircleSlider1, "Value", 0, 1, 5);
            };
            m_CircleSlider1.AnimationCompleted += delegate {
                m_CircleSlider1.Value = 0.75f;
                (ParentWindow as ApplicationWindow).ShowNotification("The animation was successfully completed.", ColorContexts.Success);
            };

            m_CircleSlider2             = new CircleSlider("CircleSlider1", ColorContexts.Information);
            m_CircleSlider2.Value       = 0.333f;
            m_CircleSlider2.CustomColor = Theme.Colors.Magenta;
            m_CircleSlider2.Tooltip     = "Drag up and down\nto change the value.";
            m_CircleSliderSubContainer.AddChild(m_CircleSlider2, 0, 1);

            this.AddChild(m_CircleSliderSubContainer, tableRow++, tableColumn);


            // >>> New Column >>>

            tableRow    = 0;
            tableColumn = 1;

            cmdDefaultButton        = new Button("cmdDefaultButton", "Default Button", ColorContexts.Default);
            cmdDefaultButton.Click += delegate {
                ParentWindow.ShowInfo("You pressed the default button. Great.");
            };
            this.AddChild(cmdDefaultButton, tableRow++, tableColumn);

            cmdShowInfo        = new Button("cmdShowInfo", "Info MessageBox", (char)FontAwesomeIcons.fa_info_circle, ColorContexts.Information);
            cmdShowInfo.Click += delegate {
                ParentWindow.ShowInfo("This is an info.");
            };
            this.AddChild(cmdShowInfo, tableRow++, tableColumn);

            cmdShowWarning        = new Button("cmdShowWarning", "Warning MessageBox", ColorContexts.Warning);
            cmdShowWarning.Click += delegate {
                ParentWindow.ShowWarning("This is a warning.");
            };
            this.AddChild(cmdShowWarning, tableRow++, tableColumn);

            cmdShowError        = new Button("cmdShowError", "Error MessageBox", ColorContexts.Danger);
            cmdShowError.Click += delegate {
                try {
                    throw new Exception("This is a sample error.");
                } catch (Exception ex) {
                    string errMsg = ex.Message + "\n" + Concurrency.GetStackTrace();
                    ParentWindow.ShowError(errMsg);
                }
            };
            this.AddChild(cmdShowError, tableRow++, tableColumn);

            cmdShowQuestion        = new Button("cmdShowQuestion", "Question MessageBox", ColorContexts.Question);
            cmdShowQuestion.Click += delegate {
                ParentWindow.ShowQuestion("This is a question. Are you sure ?");
            };
            this.AddChild(cmdShowQuestion, tableRow++, tableColumn);

            m_TextBox1      = new TextBox("TextBox1");
            m_TextBox1.Text = "Abcd Efg Hijk";
            this.AddChild(m_TextBox1, tableRow++, tableColumn);

            m_ShowPasswordChar                 = new CheckBox("ShowPasswordChar", "Password visible");
            m_ShowPasswordChar.Checked         = true;
            m_ShowPasswordChar.CheckedChanged += (object sender, EventArgs eCheckedChanged) =>
                                                 m_TextBox1.PasswordChar = m_ShowPasswordChar.Checked ? (char)0 : TextBox.DefaultPasswortChar;
            this.AddChild(m_ShowPasswordChar, tableRow++, tableColumn);

            m_NumberTextBox1       = new NumberTextBox("NumberTextBox1");
            m_NumberTextBox1.Value = 123.45m;
            this.AddChild(m_NumberTextBox1, tableRow++, tableColumn);

            m_ButtonTextBox1 = new ButtonTextBox("ButtonTextBox1", (char)FontAwesomeIcons.fa_send);
            m_ButtonTextBox1.Button.Click += delegate {
                (ParentWindow as ApplicationWindow).ShowNotification("Your email has been sent.", ColorContexts.Success);
            };
            this.AddChild(m_ButtonTextBox1, tableRow++, tableColumn);

            m_ComboListBox1 = new ComboListBox("ComboListBox1");
            m_ComboListBox1.Items.Add("Apple", 1);
            m_ComboListBox1.Items.Add("Orange", 2);
            m_ComboListBox1.Items.Add("Banana", 3);
            m_ComboListBox1.Items.Add("Cherry", 4);
            m_ComboListBox1.Items.Add("Pineapple", 5);
            m_ComboListBox1.SelectedIndex = 0;
            this.AddChild(m_ComboListBox1, tableRow++, tableColumn);

            m_ComboBox1 = new ComboBox("ComboBox1");
            m_ComboBox1.Items.Add("Apple", 1);
            m_ComboBox1.Items.Add("Orange", 2);
            m_ComboBox1.Items.Add("Banana", 3);
            m_ComboBox1.Items.Add("Cherry", 4);
            m_ComboBox1.Items.Add("Pineapple", 5);
            m_ComboBox1.SelectedIndex = 0;
            this.AddChild(m_ComboBox1, tableRow++, tableColumn);
        }