Example #1
0
 private void createOneZoneToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (var frm = new frmOneZone(currentProfile.Displays, currentProfile, this))
     {
         frm.ShowDialog();
     }
     UpdateForm();
 }
Example #2
0
        private void zoneListBox_DoubleClick(object sender, EventArgs e)
        {
            if (zoneListBox.SelectedIndex != -1)
            {
                using (var frm = new frmOneZone(currentProfile.Displays, currentProfile, currentProfile.Zones.Count - 1, this))
                {
                    frm.ShowDialog();
                }
            }

            UpdateForm();
        }
Example #3
0
        private void PictureBox_MouseClick(object sender, MouseEventArgs e)
        {
            var locationClicked = new Point(
                (int)((e.X / profilePictureBox.Zoom * 100) + currentProfile.TotalArea.X),
                (int)((e.Y / profilePictureBox.Zoom * 100) + currentProfile.TotalArea.Y));
            bool containsZone = false;

            // Check if there is a zone at that location, and if so: LEFT -> edit, RIGHT -> remove
            // Reversed because last item in list lies on top
            for (int i = currentProfile.Zones.Count - 1; i >= 0; i--)
            {
                if (currentProfile.Zones[i].Area.Contains(locationClicked))
                {
                    currentProfile.SetLast(i);
                    UpdateForm(true);
                    if (e.Button == MouseButtons.Left)
                    {
                        using (var frm = new frmOneZone(currentProfile.Displays, currentProfile, currentProfile.Zones.Count - 1, this))
                        {
                            frm.ShowDialog();
                        }
                    }
                    else if (e.Button == MouseButtons.Right)
                    {
                        if (MessageBox.Show("Are you sure you want to remove this zone?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                        {
                            currentProfile.Zones[currentProfile.Zones.Count - 1].Unregister();
                            currentProfile.Zones.RemoveAt(currentProfile.Zones.Count - 1);
                        }
                    }
                    UpdateForm();
                    containsZone = true;
                    break;
                }
            }

            // If there is no zone, but there is a display, then give the option to add zones: LEFT -> one, RIGHT -> multiple
            if (!containsZone)
            {
                for (int i = 0; i < currentProfile.Displays.Count; i++)
                {
                    if (currentProfile.Displays[i].WorkingArea.Contains(locationClicked))
                    {
                        if (e.Button == MouseButtons.Left)
                        {
                            using (var frm = new frmOneZone(currentProfile.Displays, currentProfile, this))
                            {
                                frm.ShowDialog();
                            }
                        }
                        else if (e.Button == MouseButtons.Right)
                        {
                            using (var frm = new frmMultipleZones(currentProfile.Displays, currentProfile, zoneTemplateList, i))
                            {
                                frm.ShowDialog();
                            }
                        }
                        UpdateForm();
                        break;
                    }
                }
            }
        }