Ejemplo n.º 1
0
        private void RequestCloseTabs(IEnumerable <TabPage> pages, PluginCloseInfo info)
        {
            var pagesList = pages.ToList();

            if ((info.FormReason != CloseReason.None ||
                 info.ToolBoxReason == ToolBoxCloseReason.CloseAll ||
                 info.ToolBoxReason == ToolBoxCloseReason.CloseAllExceptActive) &&
                pagesList.Count > 0)
            {
                info.Cancel = MessageBox.Show(@"Are you sure you want to close " + pagesList.Count + @" tab(s)?", @"Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes;
                if (info.Cancel)
                {
                    return;
                }
            }

            foreach (var page in pagesList)
            {
                RequestCloseTab(page, info);
                if (info.Cancel)
                {
                    return;
                }
            }
        }
Ejemplo n.º 2
0
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            var info = new PluginCloseInfo(e.CloseReason);

            RequestCloseTabs(GetPluginPages(), info);
            e.Cancel = info.Cancel;
        }
Ejemplo n.º 3
0
        private void RequestCloseTab(TabPage page, PluginCloseInfo info)
        {
            var plugin = page.GetPlugin();

            plugin.ClosingPlugin(info);
            if (info.Cancel)
            {
                return;
            }
            CloseTab(page);
        }
Ejemplo n.º 4
0
        public void ClosingPlugin(PluginCloseInfo info)
        {
            if (info.FormReason != CloseReason.None ||
                info.ToolBoxReason == ToolBoxCloseReason.CloseAll ||
                info.ToolBoxReason == ToolBoxCloseReason.CloseAllExceptActive)
            {
                return;
            }

            info.Cancel = MessageBox.Show(@"Are you sure you want to close this tab?", @"Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Allows for the plugin to prevent the form from closing, or preform some action before closing
        /// By default, if the Form is being closed, or a close all or all except active is being called, it won't prompt the user to ensure they wanted to close
        /// </summary>
        /// <param name="info"></param>
        public virtual void ClosingPlugin(PluginCloseInfo info)
        {
            if (info.FormReason != CloseReason.None ||
                info.ToolBoxReason == ToolBoxCloseReason.CloseAll ||
                info.ToolBoxReason == ToolBoxCloseReason.CloseAllExceptActive)
            {
                return;
            }

            info.Cancel = MessageBox.Show(@"Are you sure you want to close this tab?", @"Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes;
        }
Ejemplo n.º 6
0
        private void RequestCloseTab(TabPage page, PluginCloseInfo info)
        {
            info.Silent = currentOptions.CloseEachPluginSilently;
            var plugin = page.GetPlugin();

            plugin.ClosingPlugin(info);
            if (info.Cancel)
            {
                return;
            }
            CloseTab(page);
        }
Ejemplo n.º 7
0
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            // Save current form size for future usage
            currentOptions.Size.CurrentSize = Size;
            currentOptions.Size.IsMaximized = (WindowState == FormWindowState.Maximized);
            currentOptions.Save();

            // Warn to close opened plugins
            var info = new PluginCloseInfo(e.CloseReason);

            RequestCloseTabs(GetPluginPages(), info);
            e.Cancel = info.Cancel;
        }
Ejemplo n.º 8
0
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            PluginCloseInfo info;

            // Save current form size for future usage
            currentOptions.Size.CurrentSize = Size;
            currentOptions.Size.IsMaximized = (WindowState == FormWindowState.Maximized);
            currentOptions.LastConnection   = this.currentConnectionDetail?.ConnectionName;
            var currentTab = tabControl1.SelectedTab;

            if (currentTab != null && currentTab.Name != "HomePageTab")
            {
                var currentPlugin = currentTab.GetPluginName();
                currentOptions.LastPlugin = currentPlugin;
            }
            else
            {
                currentOptions.LastPlugin = "";
            }
            currentOptions.Save();

            // Warn to close opened plugins
            if (currentOptions.CloseOpenedPluginsSilently)
            {
                foreach (var page in GetPluginPages())
                {
                    info = new PluginCloseInfo(ToolBoxCloseReason.CloseAll);
                    RequestCloseTab(page, info);
                    if (info.Cancel)
                    {
                        return;
                    }
                }
                return;
            }

            info = new PluginCloseInfo(e.CloseReason);
            RequestCloseTabs(GetPluginPages(), info);
            e.Cancel = info.Cancel;
        }
Ejemplo n.º 9
0
        private void RequestCloseTab(TabPage page, PluginCloseInfo info)
        {
            info.Silent = currentOptions.CloseEachPluginSilently;
            var plugin = page.GetPlugin();

            plugin?.ClosingPlugin(info);
            if (info.Cancel)
            {
                return;
            }

            int index = tabControl1.TabPages.IndexOf(page);

            CloseTab(page);

            pluginConnections.Remove(index);
            for (var i = index; i <= pluginConnections.Count; i++)
            {
                pluginConnections.Add(i, pluginConnections[i + 1]);
                pluginConnections.Remove(i + 1);
            }
        }
Ejemplo n.º 10
0
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            PluginCloseInfo info;

            // Save current form size for future usage
            currentOptions.Size.CurrentSize = Size;
            currentOptions.Size.IsMaximized = (WindowState == FormWindowState.Maximized);
            currentOptions.LastConnection   = this.currentConnectionDetail?.ConnectionName;
            var currentPluginASMName = (this.ActiveControl as IXrmToolBoxPluginControl)?.GetType().FullName;
            var currentPlugin        =
                pManager.Plugins.SingleOrDefault(
                    x => x.Metadata.Name != "A Sample Tool" &&
                    x.Value.GetControl().GetType().FullName == currentPluginASMName
                    );

            currentOptions.LastPlugin = currentPlugin?.Metadata.Name;
            currentOptions.Save();

            // Warn to close opened plugins
            if (currentOptions.CloseOpenedPluginsSilently)
            {
                foreach (var page in GetPluginPages())
                {
                    info = new PluginCloseInfo(ToolBoxCloseReason.CloseAll);
                    RequestCloseTab(page, info);
                    if (info.Cancel)
                    {
                        return;
                    }
                }
                return;
            }

            info = new PluginCloseInfo(e.CloseReason);
            RequestCloseTabs(GetPluginPages(), info);
            e.Cancel = info.Cancel;
        }
Ejemplo n.º 11
0
 private void RequestCloseTab(TabPage page, PluginCloseInfo info)
 {
     var plugin = page.GetPlugin();
     plugin.ClosingPlugin(info);
     if (info.Cancel)
     {
         return;
     }
     CloseTab(page);
 }
Ejemplo n.º 12
0
        private void RequestCloseTabs(IEnumerable<TabPage> pages, PluginCloseInfo info)
        {
            var pagesList = pages.ToList();
            if ((info.FormReason != CloseReason.None ||
                info.ToolBoxReason == ToolBoxCloseReason.CloseAll ||
                info.ToolBoxReason == ToolBoxCloseReason.CloseAllExceptActive)
                && pagesList.Count > 0)
            {
                info.Cancel = MessageBox.Show(@"Are you sure you want to close " + pagesList.Count + @" tab(s)?", @"Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes;
                if (info.Cancel)
                {
                    return;
                }
            }

            foreach (var page in pagesList)
            {
                RequestCloseTab(page, info);
                if (info.Cancel) return;
            }
        }
Ejemplo n.º 13
0
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            // Save current form size for future usage
            currentOptions.Size.CurrentSize = Size;
            currentOptions.Size.IsMaximized = (WindowState == FormWindowState.Maximized);
            currentOptions.Save();

            // Warn to close opened plugins
            var info = new PluginCloseInfo(e.CloseReason);
            RequestCloseTabs(GetPluginPages(), info);
            e.Cancel = info.Cancel;
        }