Exemple #1
0
        private void add_firework_menu_Click(object sender, EventArgs e)
        {
            firework_page page = new firework_page(click_sound);

            firework_tab.TabPages.Add(page.firework_tab.SelectedTab);
            firework_tab.SelectedIndex    = firework_tab.TabPages.Count - 1;
            firework_tab.SelectedTab.Text = "第" + firework_tab.TabPages.Count + "个";
            CheckedListBox color_box = firework_tab.SelectedTab.Controls.Find("color_box", true)[0] as CheckedListBox;

            color_box.MouseDown += (a, b) => {
                CheckedListBox this_obj = a as CheckedListBox;
                CurrentPos     = this_obj.PointToClient(this_obj.PointToScreen(b.Location));
                panel.Location = new Point(CurrentPos.X + this_obj.Location.X + 30, CurrentPos.Y);
                panel.Visible  = true;
            };
            color_box.MouseMove += (a, b) =>
            {
                CheckedListBox this_obj = a as CheckedListBox;
                if (color_box.SelectedIndex >= 0 && color_box.SelectedIndex <= (color_box.Items.Count - 1))
                {
                    CurrentPos      = this_obj.PointToClient(this_obj.PointToScreen(b.Location));
                    panel.BackColor = ColorList[color_box.SelectedIndex];
                    panel.Location  = new Point(CurrentPos.X + this_obj.Location.X + 30, CurrentPos.Y);
                    panel.BringToFront();
                }
            };
            color_box.MouseUp += (a, b) =>
            {
                panel.Visible = false;
            };
        }
Exemple #2
0
 /// <summary>
 /// When got the focus, handle the lost focus event.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnMouseDown(object sender, MouseEventArgs e)
 {
     if (!handleLostfocus && clb.ClientRectangle.Contains(clb.PointToClient(new Point(e.X, e.Y))))
     {
         clb.LostFocus  += new EventHandler(this.ValueChanged);
         handleLostfocus = true;
     }
 }
Exemple #3
0
        private void characterSelector_DragDrop(object sender, DragEventArgs e)
        {
            CheckedListBox listBox = sender as CheckedListBox;

            if (e.Data.GetDataPresent(typeof(Character)))
            {
                if (e.Effect == DragDropEffects.Move)
                {
                    Character c     = e.Data.GetData(typeof(Character)) as Character;
                    int       index = listBox.IndexFromPoint(listBox.PointToClient(new Point(e.X, e.Y)));
                    if (index > -1)
                    {
                        listBox.Items.Insert(index, c);
                        characterCollection.Insert(index, c);

                        int oldSelectedIndex = listBox.SelectedIndex;
                        listBox.Items.RemoveAt(oldSelectedIndex);
                        characterCollection.RemoveAt(oldSelectedIndex);

                        listBox.SelectedItem      = c;
                        characterEditor.Character = c;
                        FireDataChangedEvent();
                    }
                }
                else if (e.Effect == DragDropEffects.Copy)
                {
                    Character c     = e.Data.GetData(typeof(Character)) as Character;
                    int       index = listBox.IndexFromPoint(listBox.PointToClient(new Point(e.X, e.Y)));
                    Character d     = new Character(c.ToByteArray(), index);
                    if (index > -1)
                    {
                        d.Index = (byte)index;
                        listBox.Items.Insert(index, d);
                        listBox.SetItemChecked(index, d.IsPresent);
                        characterCollection.Insert(index, d);

                        listBox.Items.RemoveAt(index + 1);
                        characterCollection.RemoveAt(index + 1);

                        listBox.SelectedItem      = d;
                        characterEditor.Character = d;
                        FireDataChangedEvent();
                    }
                }
            }
        }
Exemple #4
0
 /// <summary>
 /// Функция показывающая информацию о выбранном TestCase
 /// </summary>
 private void ShowToolTip(CheckedListBox checkedListBox, List <ITestCase> testCaseList)
 {
     nToolTipIndex = checkedListBox.IndexFromPoint(checkedListBox.PointToClient(MousePosition));
     if (nToolTipIndex > -1)
     {
         TestCaseInfoForm testCaseInfoForm = new TestCaseInfoForm(testCaseList, nToolTipIndex);
         testCaseInfoForm.ShowDialog();
     }
 }
Exemple #5
0
        private void CheckedListBox_MouseMove(object sender, MouseEventArgs e)
        {
            CheckedListBox chk = (CheckedListBox)sender;

            Point point = chk.PointToClient(Cursor.Position);
            int   index = chk.IndexFromPoint(point);

            if (index < 0)
            {
                return;
            }

            chk.SelectedItem = chk.Items[index];
        }
        private void SetCheckBoxItem(CheckedListBox checkbox)
        {
            for (int i = 0; i < checkbox.Items.Count; i++)
            {
                if (checkbox.GetItemRectangle(i).Contains(checkbox.PointToClient(MousePosition)))
                {
                    switch (checkbox.GetItemCheckState(i))
                    {
                    case CheckState.Checked:
                        checkbox.SetItemCheckState(i, CheckState.Unchecked);
                        break;

                    case CheckState.Indeterminate:
                    case CheckState.Unchecked:
                        checkbox.SetItemCheckState(i, CheckState.Checked);
                        break;
                    }
                }
            }
        }
        private void DoProfileCheckDown(object sender, MouseEventArgs e)
        {
            CheckedListBox targetBox = sender as CheckedListBox;
            Point          loc       = targetBox.PointToClient(Cursor.Position);

            for (int i = 0; i < targetBox.Items.Count; i++)
            {
                Rectangle rec = targetBox.GetItemRectangle(i);
                rec.Width = 16;

                if (rec.Contains(loc))
                {
                    _authorizeCheckBehavior = true;
                    bool newValue = !targetBox.GetItemChecked(i);
                    targetBox.SetItemChecked(i, newValue);
                    _authorizeCheckBehavior = false;

                    return;
                }
            }
        }
Exemple #8
0
        private void Add_sentence_title_menu_Click(object sender, EventArgs e)
        {
            sentence   sen         = new sentence();
            TabControl sentence_tc = page_tab.SelectedTab.Controls.Find("sentence_page", true)[0] as TabControl;

            #region 动态显示文本效果
            sen.font_property_box.MouseDown += (a, b) => {
                //更新预览文本
                TextBox current_text_box = page_tab.SelectedTab.Controls.Find("sentence_content", true)[0] as TextBox;
                display_txt.Text = current_text_box.Text.Trim() == "" ? "Minecraft" : Regex.Match(current_text_box.Text, @"(.*)").ToString();

                CheckedListBox this_obj = a as CheckedListBox;
                MousePos             = this_obj.PointToClient(this_obj.PointToScreen(b.Location));
                color_panel.Location = new Point(MousePos.X + this_obj.Location.X + 30, MousePos.Y + 30);
                color_panel.AutoSize = true;
                color_panel.Height   = 30;
                if (display_txt.Parent != color_panel)
                {
                    color_panel.Controls.Add(display_txt);
                }
                display_txt.Font = new Font(Font, FontStyle.Bold | FontStyle.Italic);
                color_panel.BringToFront();
                color_panel.Visible = true;
            };

            sen.font_property_box.MouseUp += (a, b) => {
                color_panel.Visible = false;
            };

            sen.font_property_box.MouseMove += (a, b) => {
                CheckedListBox this_obj  = a as CheckedListBox;
                CheckedListBox color_box = this_obj.Parent.Controls.Find("font_color_box", true)[0] as CheckedListBox;
                MousePos             = this_obj.PointToClient(this_obj.PointToScreen(b.Location));
                color_panel.Location = new Point(MousePos.X + this_obj.Location.X + 30, MousePos.Y + 30);
                FontStyle display_style = FontStyle.Regular;
                foreach (string item in this_obj.CheckedItems)
                {
                    if (item == "bold")
                    {
                        display_style |= FontStyle.Bold;
                    }
                    if (item == "italic")
                    {
                        display_style |= FontStyle.Italic;
                    }
                    if (item == "underlined")
                    {
                        display_style |= FontStyle.Underline;
                    }
                    if (item == "strikethrough")
                    {
                        display_style |= FontStyle.Strikeout;
                    }
                }

                if (color_box.SelectedIndex >= 0 && color_box.SelectedIndex < (color_box.Items.Count - 1))
                {
                    display_txt.ForeColor = Colors[color_box.SelectedIndex];
                }
                display_txt.Font      = new Font(Font, display_style);
                color_panel.BackColor = Color.Empty;
                color_panel.BringToFront();
            };
            #endregion

            #region 动态显示颜色
            sen.font_color_box.MouseMove += (a, b) =>
            {
                CheckedListBox this_obj = a as CheckedListBox;
                MousePos             = this_obj.PointToClient(this_obj.PointToScreen(b.Location));
                color_panel.Location = new Point(MousePos.X + this_obj.Location.X + 30, MousePos.Y);
                if (this_obj.SelectedIndex >= 0 && this_obj.SelectedIndex < this_obj.Items.Count)
                {
                    color_panel.BackColor = Colors[this_obj.SelectedIndex];
                }
            };

            sen.font_color_box.MouseUp += (a, b) => {
                color_panel.Visible = false;
            };

            sen.font_color_box.MouseDown += (a, b) =>
            {
                CheckedListBox this_obj = a as CheckedListBox;
                MousePos             = this_obj.PointToClient(this_obj.PointToScreen(b.Location));
                color_panel.Location = new Point(MousePos.X + this_obj.Location.X + 30, MousePos.Y);
                if (this_obj.SelectedIndex >= 0 && this_obj.SelectedIndex < this_obj.Items.Count)
                {
                    color_panel.BackColor = Colors[this_obj.SelectedIndex];
                }
                color_panel.Size    = new Size(50, 50);
                color_panel.Visible = true;
                color_panel.BringToFront();
            };

            sen.font_color_box.SelectedIndexChanged += (a, b) => {
                CheckedListBox this_obj = a as CheckedListBox;
                color_panel.Controls.Clear();
                this_obj.Parent.Parent.Controls.Add(color_panel);
                if (this_obj.SelectedIndex >= 0 && this_obj.SelectedIndex < this_obj.Items.Count)
                {
                    color_panel.BackColor = Colors[this_obj.SelectedIndex];
                }
            };
            #endregion

            sentence_tc.TabPages.Add(sen.sentence_page.SelectedTab);
            sentence_tc.SelectedIndex++;
            sentence_tc.SelectedTab.Text = "第" + sentence_tc.TabPages.Count + "句";
        }