Beispiel #1
0
        internal static void OnlyOneDropDownItemCheckedOnce(Form1 form, ToolStripDropDownItem toolStripDropDownItem, ToolStripMenuItem toolStripMenuItem)
        {
            ToolStripMenuItem closeButtonToolStripMenuItem    = form.closeButtonToolStripMenuItem;
            ToolStripMenuItem tabPositionToolStripMenuItem    = form.tabPositionToolStripMenuItem;
            ToolStripMenuItem tabOrientationToolStripMenuItem = form.tabOrientationToolStripMenuItem;

            for (int i = 0; i < toolStripDropDownItem.DropDownItems.Count; i++)
            {
                ToolStripMenuItem child = (ToolStripMenuItem)toolStripDropDownItem.DropDownItems[i];
                if (child != toolStripMenuItem)
                {
                    child.Checked = false;
                    continue;
                }

                child.Checked = true;

                if (toolStripDropDownItem == closeButtonToolStripMenuItem)
                {
                    OptionManager.CheckTabCloseButton(form, i);
                }
                else if (toolStripDropDownItem == tabPositionToolStripMenuItem)
                {
                    OptionManager.CheckTabPosition(form, i);
                }
                else if (toolStripDropDownItem == tabOrientationToolStripMenuItem)
                {
                    OptionManager.CheckTabOrientation(form, i);
                }
            }
        }
Beispiel #2
0
        internal static void UseDefaultAspectChanged(Form1 form)
        {
            ToolStripMenuItem useDefaultToolStripMenuItem     = form.useDefaultToolStripMenuItem;
            ToolStripMenuItem closeButtonToolStripMenuItem    = form.closeButtonToolStripMenuItem;
            ToolStripMenuItem tabPositionToolStripMenuItem    = form.tabPositionToolStripMenuItem;
            ToolStripMenuItem tabOrientationToolStripMenuItem = form.tabOrientationToolStripMenuItem;

            if (useDefaultToolStripMenuItem.Checked)
            {
                closeButtonToolStripMenuItem.Enabled    = false;
                tabPositionToolStripMenuItem.Enabled    = false;
                tabOrientationToolStripMenuItem.Enabled = false;

                OptionManager.CheckTabCloseButton(form, ConfigUtil.GetIntParameter("TabCloseButtonMode"));
                OptionManager.CheckTabPosition(form, ConfigUtil.GetIntParameter("TabPosition"));
                OptionManager.CheckTabOrientation(form, ConfigUtil.GetIntParameter("TabOrientation"));
            }
            else
            {
                closeButtonToolStripMenuItem.Enabled    = true;
                tabPositionToolStripMenuItem.Enabled    = true;
                tabOrientationToolStripMenuItem.Enabled = true;

                OptionManager.CheckTabCloseButton(form, GetDropDownIndexChecked(closeButtonToolStripMenuItem));
                OptionManager.CheckTabPosition(form, GetDropDownIndexChecked(tabPositionToolStripMenuItem));
                OptionManager.CheckTabOrientation(form, GetDropDownIndexChecked(tabOrientationToolStripMenuItem));
            }
        }
Beispiel #3
0
        internal static void OpenSession(Form1 form, String fileName = null)
        {
            CustomXtraTabControl pagesTabControl              = form.pagesTabControl;
            ToolStrip            sessionToolStrip             = form.sessionToolStrip;
            ToolStripButton      sessionToolStripButton       = form.sessionToolStripButton;
            ToolStripMenuItem    closeToolStripMenuItem3      = form.closeToolStripMenuItem3;
            ToolStripMenuItem    saveToolStripMenuItem2       = form.saveToolStripMenuItem2;
            ToolStripMenuItem    exportAsZipToolStripMenuItem = form.exportAsZipToolStripMenuItem;
            ToolStripStatusLabel toolStripStatusLabel         = form.toolStripStatusLabel;
            OpenFileDialog       openFileDialog       = form.openFileDialog;
            ToolStripProgressBar toolStripProgressBar = form.toolStripProgressBar;
            //SplitContainer verticalSplitContainer = form.verticalSplitContainer;
            ToolStripMenuItem renameSessionToolStripMenuItem     = form.renameSessionToolStripMenuItem;
            ToolStripMenuItem favouriteSessionToolStripMenuItem  = form.favouriteSessionToolStripMenuItem;
            ToolStripMenuItem listFilesToolStripMenuItem         = form.listFilesToolStripMenuItem;
            ToolStripMenuItem aspectToolStripMenuItem            = form.aspectToolStripMenuItem;
            ToolStripMenuItem useDefaultToolStripMenuItem        = form.useDefaultToolStripMenuItem;
            ToolStripMenuItem closeButtonToolStripMenuItem       = form.closeButtonToolStripMenuItem;
            ToolStripMenuItem tabPositionToolStripMenuItem       = form.tabPositionToolStripMenuItem;
            ToolStripMenuItem tabOrientationToolStripMenuItem    = form.tabOrientationToolStripMenuItem;
            ToolStripMenuItem sessionPropertiesToolStripMenuItem = form.sessionPropertiesToolStripMenuItem;

            try
            {
                bool isASessionOpened = IsASessionOpened(form);
                if (isASessionOpened && WindowManager.ShowQuestionBox(form, LanguageUtil.GetCurrentLanguageString("AlreadyOpen", className)) != DialogResult.Yes)
                {
                    return;
                }
                if (isASessionOpened)
                {
                    CloseSession(form);
                }

                if (String.IsNullOrEmpty(fileName))
                {
                    openFileDialog.InitialDirectory = FileUtil.GetInitialFolder(form);
                    openFileDialog.Multiselect      = false;
                    openFileDialog.Filter           = LanguageUtil.GetCurrentLanguageString("FileDialog", className);
                    openFileDialog.FilterIndex      = 0;
                    openFileDialog.FileName         = "*.dps";

                    if (openFileDialog.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    fileName = openFileDialog.FileName;
                }

                if (!File.Exists(fileName))
                {
                    WindowManager.ShowAlertBox(form, String.Format(LanguageUtil.GetCurrentLanguageString("FileNotExisting", className), fileName));
                    return;
                }
                if (FileUtil.IsFileInUse(fileName))
                {
                    WindowManager.ShowAlertBox(form, String.Format(LanguageUtil.GetCurrentLanguageString("FileInUse", className), fileName));
                    return;
                }
                if (pagesTabControl.TabPages.Count > 1 && TabManager.AreAllTabsEmpty(form))
                {
                    if (!TabManager.CloseAllPages(form))
                    {
                        return;
                    }
                }

                bool   loadTotallyFailed;
                String sessionName = ReadSessionXML(form, fileName, out loadTotallyFailed);
                toolStripProgressBar.Visible = false;

                if (loadTotallyFailed)
                {
                    return;
                }

                sessionToolStrip.Visible                   = true;
                sessionToolStripButton.Text                = sessionName;
                closeToolStripMenuItem3.Enabled            = true;
                saveToolStripMenuItem2.Enabled             = true;
                exportAsZipToolStripMenuItem.Enabled       = true;
                renameSessionToolStripMenuItem.Enabled     = true;
                favouriteSessionToolStripMenuItem.Enabled  = true;
                listFilesToolStripMenuItem.Enabled         = true;
                aspectToolStripMenuItem.Enabled            = true;
                useDefaultToolStripMenuItem.Enabled        = true;
                sessionPropertiesToolStripMenuItem.Enabled = true;

                if (!useDefaultToolStripMenuItem.Checked)
                {
                    closeButtonToolStripMenuItem.Enabled    = true;
                    tabPositionToolStripMenuItem.Enabled    = true;
                    tabOrientationToolStripMenuItem.Enabled = true;

                    OptionManager.CheckTabCloseButton(form, GetDropDownIndexChecked(closeButtonToolStripMenuItem));
                    OptionManager.CheckTabPosition(form, GetDropDownIndexChecked(tabPositionToolStripMenuItem));
                    OptionManager.CheckTabOrientation(form, GetDropDownIndexChecked(tabOrientationToolStripMenuItem));
                }
                else
                {
                    closeButtonToolStripMenuItem.Enabled    = false;
                    tabPositionToolStripMenuItem.Enabled    = false;
                    tabOrientationToolStripMenuItem.Enabled = false;
                }

                ConfigUtil.UpdateParameter("LastUserFolder", Path.GetDirectoryName(fileName));
                FileListManager.SetNewRecentSession(form, fileName);

                //verticalSplitContainer.Panel1.Padding = new Padding(0);
                toolStripStatusLabel.Text = String.Format(LanguageUtil.GetCurrentLanguageString("Opened", className), sessionToolStripButton.Text);
            }
            catch (Exception exception)
            {
                OptionManager.CheckTabCloseButton(form, ConfigUtil.GetIntParameter("TabCloseButtonMode"));
                OptionManager.CheckTabPosition(form, ConfigUtil.GetIntParameter("TabPosition"));
                OptionManager.CheckTabOrientation(form, ConfigUtil.GetIntParameter("TabOrientation"));

                WindowManager.ShowErrorBox(form, exception.Message, exception);
            }
        }
Beispiel #4
0
        internal static void CloseSession(Form1 form)
        {
            ToolStrip sessionToolStrip = form.sessionToolStrip;
            ToolStripDropDownButton sessionImageToolStripButton  = form.sessionImageToolStripButton;
            ToolStripButton         sessionToolStripButton       = form.sessionToolStripButton;
            ToolStripMenuItem       closeToolStripMenuItem3      = form.closeToolStripMenuItem3;
            ToolStripMenuItem       saveToolStripMenuItem2       = form.saveToolStripMenuItem2;
            ToolStripMenuItem       exportAsZipToolStripMenuItem = form.exportAsZipToolStripMenuItem;
            ToolStripStatusLabel    toolStripStatusLabel         = form.toolStripStatusLabel;
            //SplitContainer verticalSplitContainer = form.verticalSplitContainer;
            XtraTabControl    pagesTabControl = form.pagesTabControl;
            ToolStripMenuItem renameSessionToolStripMenuItem     = form.renameSessionToolStripMenuItem;
            ToolStripMenuItem favouriteSessionToolStripMenuItem  = form.favouriteSessionToolStripMenuItem;
            ToolStripMenuItem listFilesToolStripMenuItem         = form.listFilesToolStripMenuItem;
            ToolStripMenuItem aspectToolStripMenuItem            = form.aspectToolStripMenuItem;
            ToolStripMenuItem useDefaultToolStripMenuItem        = form.useDefaultToolStripMenuItem;
            ToolStripMenuItem closeButtonToolStripMenuItem       = form.closeButtonToolStripMenuItem;
            ToolStripMenuItem tabPositionToolStripMenuItem       = form.tabPositionToolStripMenuItem;
            ToolStripMenuItem tabOrientationToolStripMenuItem    = form.tabOrientationToolStripMenuItem;
            ToolStripMenuItem sessionPropertiesToolStripMenuItem = form.sessionPropertiesToolStripMenuItem;

            if (CheckSessionOnClosing(form, true) == DialogResult.Cancel)
            {
                return;
            }

            for (int i = startPositionToReadSessionFiles; i < sessionImageToolStripButton.DropDownItems.Count; i++)
            {
                foreach (XtraTabPage tabPage in pagesTabControl.TabPages)
                {
                    if (ProgramUtil.GetFilenameTabPage(tabPage) != sessionImageToolStripButton.DropDownItems[i].Text)
                    {
                        continue;
                    }

                    pagesTabControl.SelectedTabPage = tabPage;
                    TabManager.ClosePage(form);
                    break;
                }
            }

            sessionImageToolStripButton.DropDownItems.Clear();
            sessionToolStrip.Visible                   = false;
            closeToolStripMenuItem3.Enabled            = false;
            saveToolStripMenuItem2.Enabled             = false;
            exportAsZipToolStripMenuItem.Enabled       = false;
            renameSessionToolStripMenuItem.Enabled     = false;
            favouriteSessionToolStripMenuItem.Enabled  = false;
            listFilesToolStripMenuItem.Enabled         = false;
            aspectToolStripMenuItem.Enabled            = false;
            sessionPropertiesToolStripMenuItem.Enabled = false;

            if (!useDefaultToolStripMenuItem.Checked)
            {
                OptionManager.CheckTabCloseButton(form, ConfigUtil.GetIntParameter("TabCloseButtonMode"));
                OptionManager.CheckTabPosition(form, ConfigUtil.GetIntParameter("TabPosition"));
                OptionManager.CheckTabOrientation(form, ConfigUtil.GetIntParameter("TabOrientation"));
            }

            useDefaultToolStripMenuItem.Enabled     = false;
            closeButtonToolStripMenuItem.Enabled    = false;
            tabPositionToolStripMenuItem.Enabled    = false;
            tabOrientationToolStripMenuItem.Enabled = false;

            //verticalSplitContainer.Panel1.Padding = new Padding(3, 0, 0, 0);
            toolStripStatusLabel.Text = String.Format(LanguageUtil.GetCurrentLanguageString("Closed", className), sessionToolStripButton.Text);
        }