Exemple #1
0
        private void Initialise()
        {
            string fontFamily = ReadProperty <string>("FontsAndColors", "TextEditor", "FontFamily", "Courier New");
            short  fontSize   = ReadProperty <short>("FontsAndColors", "TextEditor", "FontSize", 10);

            _font = new Font(fontFamily, ( float )fontSize);

            _listBox              = new Form.ListBox();
            _listBox.DrawMode     = Form.DrawMode.OwnerDrawVariable;
            _listBox.Width        = 340;
            _listBox.Height       = 200;
            _listBox.DrawItem    += ListBoxDrawItem;
            _listBox.MeasureItem += ListBoxMeasureItem;
            _listBox.KeyDown     += ListBoxKeyDown;
            _listBox.DoubleClick += ListBoxDoubleClick;
            _listBox.LostFocus   += ListBoxLostFocus;
            _listBox.Hide();

            _window = new Window((IntPtr)AddIn.TextDocument.DTE.MainWindow.HWnd);

            _fontSize         = TextRenderer.MeasureText("W", _font);
            _fontSize.Width   = TextRenderer.MeasureText("WW", _font).Width - _fontSize.Width;
            _fontSize.Height -= 1;

            //WriteProperty<bool>( "TextEditor", "SQL", "AutoListMembers", false );
            //WriteProperty<bool>( "TextEditor", "SQL", "AutoListParams", true );
            _window.SetParent(_listBox.Handle);
        }
        public AutoCompleteTagger()
        {
            asKeyWords = new string[0];

              sbHorz = new HScrollBar();
              sbHorz.Scroll += sbHorz_Scroll;
              sbHorz.Height = 14;
              sbHorz.Hide();

              lbSuggest = new ListBox();
              lbSuggest.MouseUp += lbSuggest_MouseUp;
              lbSuggest.MouseMove += lbSuggest_MouseMove;
              lbSuggest.VisibleChanged += lbSuggest_VisibleChanged;
              lbSuggest.Hide();
        }
Exemple #3
0
        private void Initialise()
        {
            string fontFamily = ReadProperty<string>( "FontsAndColors", "TextEditor", "FontFamily", "Courier New" );
            short fontSize = ReadProperty<short>( "FontsAndColors", "TextEditor", "FontSize", 10 );

            _font = new Font( fontFamily, ( float )fontSize );

            _listBox = new Form.ListBox();
            _listBox.DrawMode = Form.DrawMode.OwnerDrawVariable;
            _listBox.Width = 340;
            _listBox.Height = 200;
            _listBox.DrawItem += ListBoxDrawItem;
            _listBox.MeasureItem += ListBoxMeasureItem;
            _listBox.KeyDown += ListBoxKeyDown;
            _listBox.DoubleClick += ListBoxDoubleClick;
            _listBox.LostFocus += ListBoxLostFocus;
            _listBox.Hide();

            _window = new Window( (IntPtr) AddIn.TextDocument.DTE.MainWindow.HWnd );

            _fontSize = TextRenderer.MeasureText( "W", _font );
            _fontSize.Width = TextRenderer.MeasureText( "WW", _font ).Width - _fontSize.Width;
            _fontSize.Height -= 1;

            //WriteProperty<bool>( "TextEditor", "SQL", "AutoListMembers", false );
            //WriteProperty<bool>( "TextEditor", "SQL", "AutoListParams", true );
            _window.SetParent( _listBox.Handle );
        }
Exemple #4
0
 private void Done()
 {
     _listBox.Hide();
     _window.SetFocus();
 }
Exemple #5
0
 private void Done()
 {
     _listBox.Hide();
     _editor.SetFocus();
 }
Exemple #6
0
        /// <summary>
        /// Shows the player's score, whether they win/lose, and the top 10 on the leaderboard for the current level.
        /// </summary>
        /// <param name="sender">Reference to method that calls this event</param>
        /// <param name="e"></param>
        public void results(object sender, EventArgs e)
        {
            game.hideGameControls();

            int x         = gameMain.ActiveForm.Width;
            int x_textbox = 0;
            int x_button  = 0;
            int x_win     = 0;


            //Creates a panel for results of the game to show
            panel_results           = new Panel();
            panel_results.Dock      = System.Windows.Forms.DockStyle.Fill;
            panel_results.Location  = new System.Drawing.Point(0, 0);
            panel_results.Size      = new System.Drawing.Size(gameMain.ActiveForm.Width, gameMain.ActiveForm.Height);//THROWS ERROR EXCEPTION
            panel_results.Visible   = true;
            panel_results.BackColor = Color.AntiqueWhite;

            //Creates a label for player's final score
            label_score           = new Label();
            label_score.AutoSize  = true;
            label_score.BackColor = System.Drawing.Color.Transparent;
            label_score.Text      = "Score: " + gamePlay.score.ToString();
            label_score.Font      = new System.Drawing.Font("Comic Sans MS", 36F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            label_score.Location  = new System.Drawing.Point(0, 0);//66, 114
            label_score.Name      = "label_score";
            label_score.Visible   = true;


            //Indicates whether the player reached the needed score to move on
            label_win_lose           = new Label();
            label_win_lose.AutoSize  = true;
            label_win_lose.BackColor = System.Drawing.Color.Transparent;
            label_win_lose.Font      = new System.Drawing.Font("Comic Sans MS", 36F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            label_win_lose.ForeColor = System.Drawing.Color.Red;
            //x_win = ((x/2) - (label_win_lose.Width/2));
            label_win_lose.Location  = new System.Drawing.Point(212, 100);
            label_win_lose.Name      = "label_win_lose";
            this.label_win_lose.Size = new System.Drawing.Size(286, 86);


            //Creates a button for the player to return the game modes page
            button_return          = new Button();
            button_return.AutoSize = true;
            button_return.Size     = new System.Drawing.Size(100, 50); //200, 100
            button_return.Location = new Point(100, 650);              //100, 400
            button_return.Text     = "Return";
            button_return.Font     = new System.Drawing.Font("Comic Sans MS", 26F, FontStyle.Bold);
            button_return.Click   += new EventHandler(button_start_Click);

            //Creates a button for the player to move onto the next levels
            button_continue          = new Button();
            button_continue.AutoSize = true;
            button_continue.Size     = new System.Drawing.Size(100, 50); //200, 100
            button_continue.Location = new Point(400, 650);              //400, 400
            button_continue.Text     = "Continue";
            button_continue.Font     = new System.Drawing.Font("Comic Sans MS", 26F, FontStyle.Bold);

            //Creates TextBox for leadboard name entry
            textbox_leaderboard = new TextBox();
            //x_textbox = (x - textbox_leaderboard.Width) / 2;
            textbox_leaderboard.Name     = "textbox_leaderboard";
            textbox_leaderboard.Size     = new System.Drawing.Size(350, 150);
            textbox_leaderboard.TabIndex = 0;
            textbox_leaderboard.Font     = new System.Drawing.Font("Microsoft Sans Serif", 20F);
            textbox_leaderboard.Location = new System.Drawing.Point(180, 400);

            // this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);

            //Creates a button to save name for leaderboard
            button_leaderboard_name_save          = new Button();
            button_leaderboard_name_save.AutoSize = true;
            //x_button = (x - button_leaderboard_name_save.Width) / 2;
            button_leaderboard_name_save.Size     = new System.Drawing.Size(100, 50);
            button_leaderboard_name_save.Text     = "Submit";
            button_leaderboard_name_save.Font     = new System.Drawing.Font("Comic Sans MS", 26F, FontStyle.Bold);
            button_leaderboard_name_save.Location = new Point(305, 450);
            button_leaderboard_name_save.Click   += new EventHandler(save_name);


            //Creates a listBox for the top 5 leaderboard
            listBox_leaderboard = new ListBox();
            listBox_leaderboard.FormattingEnabled = true;
            listBox_leaderboard.Location          = new System.Drawing.Point(251, 200);
            listBox_leaderboard.Name     = "listBox_leaderboard";
            listBox_leaderboard.Size     = new System.Drawing.Size(200, 200);
            listBox_leaderboard.TabIndex = 0;
            listBox_leaderboard.Font     = new System.Drawing.Font("Comic Sans MS", 16F, FontStyle.Bold);


            //Add all created controls to panel
            panel_results.Controls.Add(button_return);
            panel_results.Controls.Add(button_continue);
            panel_results.Controls.Add(label_score);
            panel_results.Controls.Add(label_win_lose);
            panel_results.Controls.Add(button_leaderboard_name_save);
            panel_results.Controls.Add(textbox_leaderboard);
            panel_results.Controls.Add(listBox_leaderboard);

            //Add Panel to form
            this.Controls.Add(panel_results);
            label_win_lose.Show();
            label_score.Show();
            this.panel_results.BringToFront();

            //Depending on the player's score, it will say either they won or lost
            int passingScore = 1000;

            if (gamePlay.score >= passingScore)
            {
                label_win_lose.Text = "You Win!";

                //System.Media.SoundPlayer player = new System.Media.SoundPlayer(global::Mustache_ic___V2.Properties.Resources.WINNER);
                //player.Play();
                listBox_leaderboard.Hide();
                button_leaderboard_name_save.Show();
                textbox_leaderboard.Show();
            }
            else
            {
                label_win_lose.Text = "You Lose!";
                button_leaderboard_name_save.Hide();
                textbox_leaderboard.Hide();
                //listBox_leaderboard.Hide();
                //System.Media.SoundPlayer player = new System.Media.SoundPlayer(global::Mustache_ic___V2.Properties.Resources.Price_Is_Right_loser_clip);
                //player.Play();
                get_leaderboard();
            }
        }
Exemple #7
0
        public static void AutoCompleteTextBox(TextBox txtControl, ListBox lstControl, 
            List<string> lstAutoCompleteList, KeyEventArgs txtControlKEA)
        {
            Point cp;
            GetCaretPos(out cp);
            List<string> lstTemp = new List<string>();
            //Positioning the Listbox on TextBox by Type Insertion Cursor position
            lstControl.SetBounds(cp.X + txtControl.Location.X, cp.Y + txtControl.Location.Y + 20, 150, 50);

            var TempFilteredList = lstAutoCompleteList.Where
                (n => n.StartsWith(GetLastString(txtControl.Text))).Select(r => r);

            lstTemp = TempFilteredList.ToList<string>();
            if (lstTemp.Count != 0 && GetLastString(txtControl.Text) != "")
            {
                lstControl.DataSource = lstTemp;
                lstControl.Show();
                lstControl.BringToFront();
            }
            else
            {
                lstControl.Hide();
            }

            //Code for focusing ListBox Items While Pressing Down and UP Key.
            if (txtControlKEA.KeyCode == Keys.Down)
            {
                lstControl.SelectedIndex = 0;
                lstControl.Focus();
                txtControlKEA.Handled = true;
            }
            else if (txtControlKEA.KeyCode == Keys.Up)
            {
                lstControl.SelectedIndex = lstControl.Items.Count - 1;
                lstControl.Focus();
                txtControlKEA.Handled = true;
            }

            //text box key press event
            txtControl.KeyPress += (s, kpeArgs) =>
            {

                if (kpeArgs.KeyChar == (char)Keys.Enter)
                {
                    if (lstControl.Visible)
                    {
                        lstControl.Focus();
                    }
                    kpeArgs.Handled = true;
                }
                else if (kpeArgs.KeyChar == (char)Keys.Escape)
                {
                    lstControl.Visible = false;
                    kpeArgs.Handled = true;
                }
                else if (kpeArgs.KeyChar == (char)Keys.Tab)
                {
                    txtControl.Text = ((ListBox)s).SelectedItem.ToString();
                    txtControl.Select(txtControl.Text.Length, 0);
                    txtControl.Focus();
                    lstControl.Hide();
                }
            };

            txtControl.LostFocus += (s, eventArgs) =>
                {
                    if (!lstControl.Focused)
                        lstControl.Hide();
                };

            //listbox keyup event
            lstControl.KeyUp += (s, kueArgs) =>
            {
                if (kueArgs.KeyCode == Keys.Tab)
                {
                    //string StrLS = GetLastString(txtControl.Text);
                    //int LIOLS = txtControl.Text.LastIndexOf(StrLS);
                    //string TempStr = txtControl.Text.Remove(LIOLS);
                    //txtControl.Text = TempStr + ((ListBox)s).SelectedItem.ToString();
                    txtControl.Text = ((ListBox)s).SelectedItem.ToString();
                    txtControl.Select(txtControl.Text.Length, 0);
                    txtControl.Focus();
                    lstControl.Hide();
                }
                else if (kueArgs.KeyCode == Keys.Escape)
                {
                    lstControl.Hide();
                    txtControl.Focus();
                }
            };
        }
		public AutoCompleteTagger()
		{
			asKeyWords = new string[0];
			AutoWordSelection = AutoWordSelectionOverride;
			ScrollBars = RichTextBoxScrollBars.None;
			WordWrap = false;
			grBase = CreateGraphics();

			lbSuggest = new ListBox();
			lbSuggest.MouseUp += lbSuggest_MouseUp;
			lbSuggest.MouseMove += lbSuggest_MouseMove;
			lbSuggest.VisibleChanged += lbSuggest_VisibleChanged;
			lbSuggest.Hide();
		}