private void OnScheduleConvertToOptionsSetClick(object sender, EventArgs e)
 {
     using (var form = new FormOptionSetName())
     {
         form.OptionSetName = SectionData.Name;
         if (form.ShowDialog(Controller.Instance.FormMain) == DialogResult.OK)
         {
             var newOptionSet = SectionData.CopyScheduleToOptionsSet(form.OptionSetName);
             RaiseDataChanged(new SectionDataChangedEventArgs {
                 OptionsSetsChanged = true
             });
             using (var confirmation = new FormCopyContentConfirmation())
             {
                 confirmation.Text = "Create Flex-Grid";
                 confirmation.simpleLabelItemTitle.Text = String.Format(confirmation.simpleLabelItemTitle.Text, "Flex-Grid successfully added");
                 confirmation.buttonXOK.Text            = String.Format("Go to {0}", Controller.Instance.TabOptions.Text);
                 if (confirmation.ShowDialog(Controller.Instance.FormMain) == DialogResult.OK)
                 {
                     ContentRibbonManager <MediaScheduleChangeInfo> .ShowRibbonTab(
                         ContentIdentifiers.Options,
                         new OptionsSetOpenEventArgs
                     {
                         OptionsSetId = newOptionSet.UniqueID,
                         EditorType   = OptionEditorType.Schedule
                     });
                 }
             }
         }
     }
 }
        private void OnTabControlMouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Right)
            {
                return;
            }
            var menuHitInfo = xtraTabControl.CalcHitInfo(new Point(e.X, e.Y));

            if (menuHitInfo.HitTest != XtraTabHitTest.PageHeader)
            {
                return;
            }
            if (menuHitInfo.Page == _sectionControl && SectionData.Programs.Any())
            {
                contextMenuStripSchedule.Show((Control)sender, e.Location);
            }
            else if (menuHitInfo.Page == _digitalInfoControl && SectionData.DigitalInfo.Records.Any())
            {
                toolStripMenuItemDigitalToSnapshot.DropDownItems.Clear();
                toolStripMenuItemDigitalToSnapshot.DropDownItems.Add(new ToolStripMenuItem(
                                                                         "Create New...",
                                                                         null,
                                                                         (s, args) =>
                {
                    _digitalInfoControl.SaveData();
                    using (var form = new FormSnapshotName())
                    {
                        form.SnapshotName = SectionData.Name;
                        if (form.ShowDialog(Controller.Instance.FormMain) == DialogResult.OK)
                        {
                            var newSnapshot = SectionData.CopyDigitalToSnapshot(form.SnapshotName);
                            RaiseDataChanged(new SectionDataChangedEventArgs {
                                SnapshotsChanged = true
                            });
                            using (var confirmation = new FormCopyContentConfirmation())
                            {
                                confirmation.Text = "Send to Snapshot";
                                confirmation.simpleLabelItemTitle.Text = String.Format(confirmation.simpleLabelItemTitle.Text, "Digital successfully copied");
                                confirmation.buttonXOK.Text            = String.Format("Go to {0}", Controller.Instance.TabSnapshot.Text);
                                if (confirmation.ShowDialog(Controller.Instance.FormMain) == DialogResult.OK)
                                {
                                    ContentRibbonManager <MediaScheduleChangeInfo> .ShowRibbonTab(
                                        ContentIdentifiers.Snapshots,
                                        new SnapshotOpenEventArgs
                                    {
                                        SnapshotId = newSnapshot.UniqueID,
                                        EditorType = SnapshotEditorType.DigitalInfo
                                    });
                                }
                            }
                        }
                    }
                }));
                foreach (var snapshot in SectionData.ParentSchedule.SnapshotContent.Snapshots)
                {
                    toolStripMenuItemDigitalToSnapshot.DropDownItems.Add(new ToolStripMenuItem(
                                                                             snapshot.Name.Replace("&", "&&"),
                                                                             null,
                                                                             (s, args) =>
                    {
                        _digitalInfoControl.SaveData();
                        SectionData.CopyDigitalToSnapshot(snapshot);
                        RaiseDataChanged(new SectionDataChangedEventArgs {
                            SnapshotsChanged = true
                        });
                        using (var confirmation = new FormCopyContentConfirmation())
                        {
                            confirmation.Text = "Send to Snapshot";
                            confirmation.simpleLabelItemTitle.Text = String.Format(confirmation.simpleLabelItemTitle.Text, "Digital successfully copied");
                            confirmation.buttonXOK.Text            = String.Format("Go to {0}", Controller.Instance.TabSnapshot.Text);
                            if (confirmation.ShowDialog(Controller.Instance.FormMain) == DialogResult.OK)
                            {
                                ContentRibbonManager <MediaScheduleChangeInfo> .ShowRibbonTab(
                                    ContentIdentifiers.Snapshots,
                                    new SnapshotOpenEventArgs
                                {
                                    SnapshotId = snapshot.UniqueID,
                                    EditorType = SnapshotEditorType.DigitalInfo
                                });
                            }
                        }
                    }));
                }

                toolStripMenuItemDigitalToOptions.DropDownItems.Clear();
                toolStripMenuItemDigitalToOptions.DropDownItems.Add(new ToolStripMenuItem(
                                                                        "Create New...",
                                                                        null,
                                                                        (s, args) =>
                {
                    _digitalInfoControl.SaveData();
                    using (var form = new FormOptionSetName())
                    {
                        form.OptionSetName = SectionData.Name;
                        if (form.ShowDialog(Controller.Instance.FormMain) == DialogResult.OK)
                        {
                            var newOptionsSet = SectionData.CopyDigitalToOptionsSet(form.OptionSetName);
                            RaiseDataChanged(new SectionDataChangedEventArgs {
                                OptionsSetsChanged = true
                            });
                            using (var confirmation = new FormCopyContentConfirmation())
                            {
                                confirmation.Text = "Send to Flex-Grid";
                                confirmation.simpleLabelItemTitle.Text = String.Format(confirmation.simpleLabelItemTitle.Text, "Digital successfully copied");
                                confirmation.buttonXOK.Text            = String.Format("Go to {0}", Controller.Instance.TabOptions.Text);
                                if (confirmation.ShowDialog(Controller.Instance.FormMain) == DialogResult.OK)
                                {
                                    ContentRibbonManager <MediaScheduleChangeInfo> .ShowRibbonTab(
                                        ContentIdentifiers.Options,
                                        new OptionsSetOpenEventArgs
                                    {
                                        OptionsSetId = newOptionsSet.UniqueID,
                                        EditorType   = OptionEditorType.DigitalInfo
                                    });
                                }
                            }
                        }
                    }
                }));
                foreach (var optionSet in SectionData.ParentSchedule.OptionsContent.Options)
                {
                    toolStripMenuItemDigitalToOptions.DropDownItems.Add(new ToolStripMenuItem(
                                                                            optionSet.Name.Replace("&", "&&"),
                                                                            null,
                                                                            (s, args) =>
                    {
                        _digitalInfoControl.SaveData();
                        SectionData.CopyDigitalToOptionsSet(optionSet);
                        RaiseDataChanged(new SectionDataChangedEventArgs {
                            OptionsSetsChanged = true
                        });
                        using (var confirmation = new FormCopyContentConfirmation())
                        {
                            confirmation.Text = "Send to Flex-Grid";
                            confirmation.simpleLabelItemTitle.Text = String.Format(confirmation.simpleLabelItemTitle.Text, "Digital successfully copied");
                            confirmation.buttonXOK.Text            = String.Format("Go to {0}", Controller.Instance.TabOptions.Text);
                            if (confirmation.ShowDialog(Controller.Instance.FormMain) == DialogResult.OK)
                            {
                                ContentRibbonManager <MediaScheduleChangeInfo> .ShowRibbonTab(
                                    ContentIdentifiers.Options,
                                    new OptionsSetOpenEventArgs
                                {
                                    OptionsSetId = optionSet.UniqueID,
                                    EditorType   = OptionEditorType.DigitalInfo
                                });
                            }
                        }
                    }));
                }

                contextMenuStripDigital.Show((Control)sender, e.Location);
            }
        }