Beispiel #1
0
 protected void OnTaskInfoSelected(QuickTaskInfo taskInfo)
 {
     if (TaskInfoSelected != null)
     {
         TaskInfoSelected(taskInfo);
     }
 }
Beispiel #2
0
        public void ShowMenu()
        {
            ContextMenuStrip cms = new ContextMenuStrip
            {
                Font            = new Font("Arial", 10f),
                AutoClose       = false,
                ShowImageMargin = false
            };

            if (Program.Settings != null && Program.Settings.QuickTaskPresets != null && Program.Settings.QuickTaskPresets.Count > 0)
            {
                foreach (QuickTaskInfo taskInfo in Program.Settings.QuickTaskPresets)
                {
                    if (taskInfo.IsValid)
                    {
                        ToolStripMenuItem tsmi = new ToolStripMenuItem {
                            Text = taskInfo.ToString().Replace("&", "&&"), Tag = taskInfo
                        };
                        tsmi.Click += (sender, e) =>
                        {
                            QuickTaskInfo selectedTaskInfo = ((ToolStripMenuItem)sender).Tag as QuickTaskInfo;
                            cms.Close();
                            OnTaskInfoSelected(selectedTaskInfo);
                        };
                        cms.Items.Add(tsmi);
                    }
                    else
                    {
                        cms.Items.Add(new ToolStripSeparator());
                    }
                }

                cms.Items[0].Select();

                cms.Items.Add(new ToolStripSeparator());
            }

            // Translate
            ToolStripMenuItem tsmiEdit = new ToolStripMenuItem("Edit this menu...");

            tsmiEdit.Click += (sender, e) =>
            {
                cms.Close();
                new QuickTaskMenuEditorForm().ShowDialog();
            };
            cms.Items.Add(tsmiEdit);

            cms.Items.Add(new ToolStripSeparator());

            ToolStripMenuItem tsmiCancel = new ToolStripMenuItem("Cancel");

            tsmiCancel.Click += (sender, e) => cms.Close();
            cms.Items.Add(tsmiCancel);

            Point cursorPosition = CaptureHelpers.GetCursorPosition();

            cursorPosition.Offset(-10, -10);
            cms.Show(cursorPosition);
        }
Beispiel #3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            QuickTaskInfo taskInfo = new QuickTaskInfo();
            ListViewItem  lvi      = new ListViewItem();

            Program.Settings.QuickTaskPresets.Add(taskInfo);
            lvPresets.Items.Add(lvi);
            Edit(lvi, taskInfo);
        }
Beispiel #4
0
 private void EditSelectedItem()
 {
     if (lvPresets.SelectedItems.Count > 0)
     {
         ListViewItem  lvi      = lvPresets.SelectedItems[0];
         QuickTaskInfo taskInfo = lvi.Tag as QuickTaskInfo;
         Edit(lvi, taskInfo);
     }
 }
Beispiel #5
0
 private void btnRemove_Click(object sender, EventArgs e)
 {
     if (lvPresets.SelectedItems.Count > 0)
     {
         ListViewItem  lvi      = lvPresets.SelectedItems[0];
         QuickTaskInfo taskInfo = lvi.Tag as QuickTaskInfo;
         Program.Settings.QuickTaskPresets.Remove(taskInfo);
         lvPresets.Items.Remove(lvi);
     }
 }
Beispiel #6
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     if (lvPresets.SelectedItems.Count > 0)
     {
         ListViewItem  lvi      = lvPresets.SelectedItems[0];
         QuickTaskInfo taskInfo = lvi.Tag as QuickTaskInfo;
         Edit(taskInfo);
         lvi.Text = taskInfo.ToString();
     }
 }
 private void btnAdd_Click(object sender, EventArgs e)
 {
     QuickTaskInfo taskInfo = new QuickTaskInfo();
     ListViewItem lvi = new ListViewItem();
     lvi.Tag = taskInfo;
     Program.Settings.QuickTaskPresets.Add(taskInfo);
     lvPresets.Items.Add(lvi);
     Edit(taskInfo);
     lvi.Text = taskInfo.ToString();
 }
Beispiel #8
0
 public QuickTaskInfoEditForm(QuickTaskInfo taskInfo)
 {
     InitializeComponent();
     TaskInfo     = taskInfo;
     txtName.Text = TaskInfo.Name;
     AddMultiEnumItemsContextMenu <AfterCaptureTasks>(x => TaskInfo.AfterCaptureTasks = TaskInfo.AfterCaptureTasks.Swap(x), cmsAfterCapture);
     AddMultiEnumItemsContextMenu <AfterUploadTasks>(x => TaskInfo.AfterUploadTasks   = TaskInfo.AfterUploadTasks.Swap(x), cmsAfterUpload);
     SetMultiEnumCheckedContextMenu(TaskInfo.AfterCaptureTasks, cmsAfterCapture);
     SetMultiEnumCheckedContextMenu(TaskInfo.AfterUploadTasks, cmsAfterUpload);
     UpdateUploaderMenuNames();
 }
Beispiel #9
0
        public Image FindSuitableIcon(QuickTaskInfo taskInfo)
        {
            if (taskInfo.AfterCaptureTasks.HasFlag(AfterCaptureTasks.UploadImageToHost))
            {
                return(Resources.upload_cloud);
            }
            else if (taskInfo.AfterCaptureTasks.HasFlag(AfterCaptureTasks.CopyImageToClipboard) || taskInfo.AfterCaptureTasks.HasFlag(AfterCaptureTasks.CopyFileToClipboard))
            {
                return(Resources.clipboard);
            }
            else if (taskInfo.AfterCaptureTasks.HasFlag(AfterCaptureTasks.SaveImageToFile) || taskInfo.AfterCaptureTasks.HasFlag(AfterCaptureTasks.SaveImageToFileWithDialog))
            {
                return(Resources.disk_black);
            }

            return(Resources.image);
        }
Beispiel #10
0
        private void Edit(ListViewItem lvi, QuickTaskInfo taskInfo)
        {
            new QuickTaskInfoEditForm(taskInfo).ShowDialog();

            UpdateItem(lvi, taskInfo);
        }
Beispiel #11
0
 private void UpdateItem(ListViewItem lvi, QuickTaskInfo taskInfo)
 {
     lvi.Tag  = taskInfo;
     lvi.Text = taskInfo.ToString();
 }
Beispiel #12
0
 protected void OnTaskInfoSelected(QuickTaskInfo taskInfo)
 {
     if (TaskInfoSelected != null)
     {
         TaskInfoSelected(taskInfo);
     }
 }
        private void Edit(ListViewItem lvi, QuickTaskInfo taskInfo)
        {
            new QuickTaskInfoEditForm(taskInfo).ShowDialog();

            UpdateItem(lvi, taskInfo);
        }
 private void UpdateItem(ListViewItem lvi, QuickTaskInfo taskInfo)
 {
     lvi.BackColor = taskInfo.IsValid ? Color.White : Color.WhiteSmoke;
     lvi.Tag = taskInfo;
     lvi.Text = taskInfo.ToString();
 }
 private void Edit(QuickTaskInfo taskInfo)
 {
     new QuickTaskInfoEditForm(taskInfo).ShowDialog();
 }
Beispiel #16
0
 private void UpdateItem(ListViewItem lvi, QuickTaskInfo taskInfo)
 {
     lvi.BackColor = taskInfo.IsValid ? Color.White : Color.WhiteSmoke;
     lvi.Tag       = taskInfo;
     lvi.Text      = taskInfo.ToString();
 }
Beispiel #17
0
 protected void OnTaskInfoSelected(QuickTaskInfo taskInfo)
 {
     TaskInfoSelected?.Invoke(taskInfo);
 }
Beispiel #18
0
        public void ShowMenu()
        {
            ContextMenuStrip cms = new ContextMenuStrip()
            {
                Font      = new Font("Arial", 10f),
                AutoClose = false
            };

            cms.KeyUp += (sender, e) =>
            {
                if (e.KeyCode == Keys.Escape)
                {
                    cms.Close();
                }
            };

            ToolStripMenuItem tsmiContinue = new ToolStripMenuItem(Resources.QuickTaskMenu_ShowMenu_Continue);

            tsmiContinue.Image  = Resources.control;
            tsmiContinue.Click += (sender, e) =>
            {
                cms.Close();
                OnTaskInfoSelected(null);
            };
            cms.Items.Add(tsmiContinue);

            cms.Items.Add(new ToolStripSeparator());

            if (Program.Settings != null && Program.Settings.QuickTaskPresets != null && Program.Settings.QuickTaskPresets.Count > 0)
            {
                foreach (QuickTaskInfo taskInfo in Program.Settings.QuickTaskPresets)
                {
                    if (taskInfo.IsValid)
                    {
                        ToolStripMenuItem tsmi = new ToolStripMenuItem {
                            Text = taskInfo.ToString().Replace("&", "&&"), Tag = taskInfo
                        };
                        tsmi.Image  = FindSuitableIcon(taskInfo);
                        tsmi.Click += (sender, e) =>
                        {
                            QuickTaskInfo selectedTaskInfo = ((ToolStripMenuItem)sender).Tag as QuickTaskInfo;
                            cms.Close();
                            OnTaskInfoSelected(selectedTaskInfo);
                        };
                        cms.Items.Add(tsmi);
                    }
                    else
                    {
                        cms.Items.Add(new ToolStripSeparator());
                    }
                }

                cms.Items[0].Select();

                cms.Items.Add(new ToolStripSeparator());
            }

            ToolStripMenuItem tsmiEdit = new ToolStripMenuItem(Resources.QuickTaskMenu_ShowMenu_Edit_this_menu___);

            tsmiEdit.Image  = Resources.pencil;
            tsmiEdit.Click += (sender, e) =>
            {
                cms.Close();
                new QuickTaskMenuEditorForm().ShowDialog();
            };
            cms.Items.Add(tsmiEdit);

            cms.Items.Add(new ToolStripSeparator());

            ToolStripMenuItem tsmiCancel = new ToolStripMenuItem(Resources.QuickTaskMenu_ShowMenu_Cancel);

            tsmiCancel.Image  = Resources.cross;
            tsmiCancel.Click += (sender, e) => cms.Close();
            cms.Items.Add(tsmiCancel);

            if (ShareXResources.UseCustomTheme)
            {
                ShareXResources.ApplyCustomThemeToContextMenuStrip(cms);
            }

            Point cursorPosition = CaptureHelpers.GetCursorPosition();

            cursorPosition.Offset(-10, -10);
            cms.Show(cursorPosition);
            cms.Focus();
        }
Beispiel #19
0
        public Image FindSuitableIcon(QuickTaskInfo taskInfo)
        {
            if (taskInfo.AfterCaptureTasks.HasFlag(AfterCaptureTasks.UploadImageToHost))
            {
                return Resources.upload_cloud;
            }
            else if (taskInfo.AfterCaptureTasks.HasFlag(AfterCaptureTasks.CopyImageToClipboard) || taskInfo.AfterCaptureTasks.HasFlag(AfterCaptureTasks.CopyFileToClipboard))
            {
                return Resources.clipboard;
            }
            else if (taskInfo.AfterCaptureTasks.HasFlag(AfterCaptureTasks.SaveImageToFile) || taskInfo.AfterCaptureTasks.HasFlag(AfterCaptureTasks.SaveImageToFileWithDialog))
            {
                return Resources.disk_black;
            }

            return Resources.image;
        }
Beispiel #20
0
 private void Edit(QuickTaskInfo taskInfo)
 {
     new QuickTaskInfoEditForm(taskInfo).ShowDialog();
 }