Exemple #1
0
        internal static void ShowFileInBrowser(Form1 form)
        {
            XtraTabControl pagesTabControl = form.pagesTabControl;

            if (String.IsNullOrEmpty(ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage).Text))
            {
                WindowManager.ShowInfoBox(form, LanguageUtil.GetCurrentLanguageString("NoContent", className));
                return;
            }

            String fileAndPathName;

            if (!String.IsNullOrEmpty(ProgramUtil.GetFilenameTabPage(pagesTabControl.SelectedTabPage)) && !ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage).CustomModified)
            {
                fileAndPathName = ProgramUtil.GetFilenameTabPage(pagesTabControl.SelectedTabPage);
            }
            else
            {
                String fileName = String.Format("{0}.html", Guid.NewGuid());
                String pathName = Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.internetCacheDirectoryName);

                if (!Directory.Exists(pathName))
                {
                    Directory.CreateDirectory(pathName);
                }

                fileAndPathName = Path.Combine(pathName, fileName);
                if (FileManager.SaveFileCoreWithEncoding(form, fileAndPathName) == false)
                {
                    return;
                }
            }

            OtherManager.StartProcessBrowser(form, fileAndPathName);
        }
Exemple #2
0
        internal static void OpenFileFolder(Form1 form)
        {
            String           fileName         = ProgramUtil.GetFilenameTabPage(form.pagesTabControl.SelectedTabPage);
            ProcessStartInfo processStartInfo = new ProcessStartInfo("explorer.exe")
            {
                Arguments = String.Format("/select, {0}", fileName)
            };

            OtherManager.StartProcessInfo(form, processStartInfo);
        }
 internal static void OpenIntoWindowsExplorer(Form1 form, TreeNode parentNode)
 {
     if (parentNode.Tag != null && parentNode.Tag.ToString() == "Desktop")
     {
         OtherManager.StartProcess(form, Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
     }
     else
     {
         OtherManager.StartProcess(form, parentNode.ToolTipText);
     }
 }
Exemple #4
0
        internal static void SendBugReport(ReportBug form)
        {
            if (!RegularExpressionValidator.ValidateSingleString(form.emailTextBox.Text, RegularExpressionValidator.RegularExpression.Email))
            {
                WindowManager.ShowAlertBox(form, LanguageUtil.GetCurrentLanguageString("EmailInvalid", className));
                return;
            }

            String mailString = PrepareMailBugReport(form.sendMeACopyCheckBox.Checked, form.emailTextBox.Text, form.nameTextBox.Text, form.areaComboBox.SelectedItem.ToString(), form.errorMessageTextBox.Text, form.descriptionTextBox.Text);

            OtherManager.StartProcess(form, mailString);
        }
        private static void MakeSearch(Form1 form, SearchProvider provider, String search)
        {
            switch (provider)
            {
            case SearchProvider.Google:
                OtherManager.StartProcessBrowser(form, String.Format("http://www.google.{0}/search?as_q={1}", LanguageUtil.GetDomainExtension(), search));
                break;

            case SearchProvider.Wikipedia:
                OtherManager.StartProcessBrowser(form, String.Format("http://{0}.wikipedia.org/w/index.php?search={1}", LanguageUtil.GetReallyShortCulture(), search));
                break;
            }
        }
Exemple #6
0
        internal static void OpenDtHelp()
        {
            String language = LanguageUtil.GetReallyShortCulture();

            String guideFileName = String.Format("{0}{1}{2}", ConstantUtil.defaultDtPadGuideName, language, ConstantUtil.defaultDtPadGuideExtension);

            guideFileName = String.Format("\"{0}\"", Path.Combine(ConstantUtil.ApplicationExecutionPath(), guideFileName));

            ProcessStartInfo processStartInfo = new ProcessStartInfo(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.dtHelpExecutable), guideFileName)
            {
                WorkingDirectory = ConstantUtil.ApplicationExecutionPath(),
                UseShellExecute  = false
            };

            OtherManager.StartProcessInfo(null, processStartInfo);
        }
Exemple #7
0
        internal static void OpenFileFolderPrompt(Form1 form)
        {
            String fileName     = ProgramUtil.GetFilenameTabPage(form.pagesTabControl.SelectedTabPage);
            String workingDrive = Path.GetPathRoot(Path.GetDirectoryName(fileName));

            if (String.IsNullOrEmpty(workingDrive))
            {
                workingDrive = @"C:\";
            }

            ProcessStartInfo processStartInfo = new ProcessStartInfo("cmd.exe")
            {
                WorkingDirectory = workingDrive,
                Arguments        = String.Format("/k \"cd {0}", Path.GetDirectoryName(fileName))
            };

            OtherManager.StartProcessInfo(form, processStartInfo);
        }
Exemple #8
0
        internal static void ResetTab(Form1 form)
        {
            XtraTabControl    pagesTabControl   = form.pagesTabControl;
            CustomRichTextBox pageTextBox       = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage);
            CustomLineNumbers customLineNumbers = ProgramUtil.GetCustomLineNumbers(pagesTabControl.SelectedTabPage);

            if (ColumnRulerManager.IsPanelOpen(form))
            {
                ColumnRulerManager.TogglePanel(form);
            }

            String newTabTitle = LanguageUtil.GetCurrentLanguageString("tabPage1", form.Name);

            SetTabColor(pagesTabControl.SelectedTabPage, Color.Black); //pagesTabControl.SelectedTabPage.Appearance.Header.ForeColor = Color.Black;
            pagesTabControl.SelectedTabPage.Appearance.Header.Reset();
            pageTextBox.Text = String.Empty;
            pagesTabControl.SelectedTabPage.ImageIndex = 0;
            pagesTabControl.SelectedTabPage.Text       = newTabTitle;
            pagesTabControl.SelectedTabPage.Tooltip    = newTabTitle;
            form.Text = String.Format("DtPad - {0}", newTabTitle);
            ProgramUtil.SetFilenameTabPage(pagesTabControl.SelectedTabPage, String.Empty);
            pageTextBox.CustomZoom           = 100;
            pageTextBox.CustomModified       = false;
            pageTextBox.CustomOriginal       = String.Empty.GetHashCode().ToString();
            pageTextBox.CustomEncoding       = String.Empty;
            pageTextBox.CustomEncodingForced = false;
            customLineNumbers.Width          = customLineNumbers.MinimumSize.Width;
            ZoomSelect(form, 100);
            pageTextBox.ClearUndo();

            TextManager.RefreshUndoRedoExternal(form);

            if (String.IsNullOrEmpty(ProgramUtil.GetFilenameTabPage(pagesTabControl.SelectedTabPage)))
            {
                ToggleTabFileTools(form, false);
            }
            OtherManager.FocusOnEditor(form);
        }
Exemple #9
0
        internal static int AddNewPage(Form1 form, int tabIdentity)
        {
            XtraTabControl    pagesTabControl              = form.pagesTabControl;
            ToolStripMenuItem wordWrapToolStripMenuItem    = form.wordWrapToolStripMenuItem;
            ToolStripMenuItem lineNumbersToolStripMenuItem = form.lineNumbersToolStripMenuItem;
            ContextMenuStrip  textBoxContextMenuStrip      = form.textBoxContextMenuStrip;

            bool rowNumbersVisibile = lineNumbersToolStripMenuItem.Checked;
            bool wordWrapEnabled    = wordWrapToolStripMenuItem.Checked;

            if (form.WindowMode == CustomForm.WindowModeEnum.Note)
            {
                rowNumbersVisibile = false;
                wordWrapEnabled    = true;
            }

            String newTabTitle = LanguageUtil.GetCurrentLanguageString("tabPage1", form.Name);

            tabIdentity++;
            String newTabPageName = String.Format("tabPage{0}", tabIdentity);

            XtraTabPage newTabPageControl = new XtraTabPage
            {
                ImageIndex = 0,
                Name       = newTabPageName,
                Padding    = new Padding(3),
                Text       = newTabTitle,
                Tooltip    = newTabTitle
            };

            //newTabPageControl.Appearance.Header.ForeColor = Color.Black;
            //newTabPageControl.Appearance.PageClient.BackColor = Color.White;
            newTabPageControl.TextChanged += form.tabPage_TextChanged;

            CustomRichTextBox newTabPageTextBox = new CustomRichTextBox
            {
                AcceptsTab           = true,
                AllowDrop            = true,
                AutoWordSelection    = false,
                BackColor            = form.TextBackgroundColor,
                BorderStyle          = BorderStyle.None,
                ContextMenuStrip     = textBoxContextMenuStrip,
                CustomEncodingForced = false,
                CustomInsertMode     = "INS",
                CustomModified       = false,
                CustomOriginal       = String.Empty.GetHashCode().ToString(),
                CustomZoom           = 100,
                DetectUrls           = ConfigUtil.GetBoolParameter("HighlightURL"),
                Dock          = DockStyle.Fill,
                Font          = form.TextFont,
                ForeColor     = form.TextFontColor,
                HideSelection = false,
                //Multiline = true,
                Name = "pageTextBox",
                //ScrollBars = RichTextBoxScrollBars.Both,
                Text     = String.Empty,
                WordWrap = wordWrapEnabled
            };

            newTabPageControl.Controls.Add(newTabPageTextBox);

            CustomLineNumbers customLineNumbers = new CustomLineNumbers
            {
                AutoSizing = true,
                BackColor  = form.TextBackgroundColor,
                BackgroundGradient_AlphaColor = Color.FromArgb(0, 0, 0, 0),
                BackgroundGradient_BetaColor  = SystemColors.Window,
                BackgroundGradient_Direction  = LinearGradientMode.Horizontal,
                BorderLines_Color             = Color.DeepSkyBlue,
                BorderLines_Style             = DashStyle.Solid,
                BorderLines_Thickness         = 1F,
                Dock                           = DockStyle.Left,
                DockSide                       = CustomLineNumbers.LineNumberDockSide.Left,
                Font                           = form.TextFont,
                ForeColor                      = SystemColors.AppWorkspace,
                GridLines_Color                = Color.DeepSkyBlue,
                GridLines_Style                = DashStyle.Solid,
                GridLines_Thickness            = 1F,
                LineNrs_Alignment              = ContentAlignment.TopRight,
                LineNrs_AntiAlias              = false,
                LineNrs_ClippedByItemRectangle = true,
                LineNrs_Offset                 = new Size(0, 0),
                Location                       = new Point(3, 3),
                Margin                         = new Padding(0),
                MarginLines_Color              = Color.DeepSkyBlue,
                MarginLines_Side               = CustomLineNumbers.LineNumberDockSide.Right,
                MarginLines_Style              = DashStyle.Dash,
                MarginLines_Thickness          = 1F,
                MinimumSize                    = new Size(47, 0),
                Name                           = "customLineNumbers",
                Padding                        = new Padding(0, 0, 7, 0),
                ParentRichTextBox              = newTabPageTextBox,
                Show_LineNrs                   = true,
                Show_MarginLines               = true,
                Size                           = new Size(47, 308),
                TabIndex                       = 2,
                Visible                        = rowNumbersVisibile
            };

            newTabPageControl.Controls.Add(customLineNumbers);

            Label newTabPageLabel = new Label
            {
                AutoSize = true,
                Location = new Point(3, 3),
                Name     = "filenameTabPage",
                Size     = new Size(0, 13),
                Visible  = false
            };

            newTabPageLabel.TextChanged += form.filenameTabPage_TextChanged;
            newTabPageControl.Controls.Add(newTabPageLabel);

            pagesTabControl.TabPages.Add(newTabPageControl);
            pagesTabControl.SelectedTabPage = newTabPageControl;

            ExplorerManager.AddNodeToTabExplorer(form, newTabPageControl.Text, newTabPageControl.Name, 0, 0);
            OtherManager.FocusOnEditor(form);
            WindowModeManager.AddRelaxModeMargins(form);

            return(tabIdentity);
        }
Exemple #10
0
        private static bool ClosePage(Form1 form, bool showMessages, bool moreTabs, out bool closeAll)
        {
            XtraTabControl pagesTabControl = form.pagesTabControl;

            closeAll = false;

            if (showMessages && TabUtil.IsTabPageModified(pagesTabControl.SelectedTabPage))
            {
                if (moreTabs)
                {
                    DialogResult dialogResult = WindowManager.ShowQuestionCancelNoAllBox(form, LanguageUtil.GetCurrentLanguageString("SaveUntitled", className));

                    if ((dialogResult == DialogResult.Cancel) || (dialogResult == DialogResult.Yes && !FileManager.SaveFile(form, false)))
                    {
                        return(false);
                    }
                    if (dialogResult == DialogResult.Retry)
                    {
                        closeAll = true;
                    }
                }
                else
                {
                    DialogResult dialogResult = WindowManager.ShowQuestionCancelBox(form, LanguageUtil.GetCurrentLanguageString("SaveUntitled", className));

                    if ((dialogResult == DialogResult.Cancel) || (dialogResult == DialogResult.Yes && !FileManager.SaveFile(form, false)))
                    {
                        return(false);
                    }
                }
            }
            else if (!showMessages)
            {
                closeAll = true;
            }

            CustomPanel sectionsPanel   = ProgramUtil.GetSectionsPanel(pagesTabControl.SelectedTabPage);
            CustomPanel annotationPanel = ProgramUtil.GetAnnotationPanel(pagesTabControl.SelectedTabPage);

            if (sectionsPanel != null)
            {
                pagesTabControl.SelectedTabPage.Controls.Remove(sectionsPanel);
            }
            if (annotationPanel != null)
            {
                pagesTabControl.SelectedTabPage.Controls.Remove(annotationPanel);
            }

            if (pagesTabControl.TabPages.Count > 1)
            {
                String selectedTabName  = pagesTabControl.SelectedTabPage.Name;
                int    selectedTabIndex = pagesTabControl.SelectedTabPageIndex;

                pagesTabControl.TabPages.Remove(pagesTabControl.SelectedTabPage);
                ExplorerManager.RemoveNodeToTabExplorer(form, selectedTabName);

                pagesTabControl.SelectedTabPage = selectedTabIndex < pagesTabControl.TabPages.Count ? pagesTabControl.TabPages[selectedTabIndex] : pagesTabControl.TabPages[pagesTabControl.TabPages.Count - 1];

                if (String.IsNullOrEmpty(ProgramUtil.GetFilenameTabPage(pagesTabControl.SelectedTabPage)))
                {
                    ToggleTabFileTools(form, false);
                }
                OtherManager.FocusOnEditor(form);
            }
            else
            {
                ResetTab(form);
            }

            return(true);
        }
Exemple #11
0
        internal static bool SaveAsPdf(Form1 form)
        {
            XtraTabControl       pagesTabControl      = form.pagesTabControl;
            CustomRichTextBox    pageTextBox          = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage);
            SaveFileDialog       saveFileDialog       = form.saveFileDialog;
            ToolStripStatusLabel toolStripStatusLabel = form.toolStripStatusLabel;
            ToolStripProgressBar toolStripProgressBar = form.toolStripProgressBar;

            if (String.IsNullOrEmpty(pageTextBox.Text))
            {
                WindowManager.ShowInfoBox(form, LanguageUtil.GetCurrentLanguageString("NoTextForPDF", className));
                return(false);
            }

            try
            {
                saveFileDialog.InitialDirectory = FileUtil.GetInitialFolder(form);
                saveFileDialog.Filter           = LanguageUtil.GetCurrentLanguageString("PDFFile", className); //"PDF document (*.pdf)|*.pdf";
                saveFileDialog.FilterIndex      = 0;

                String filenameTabPage = ProgramUtil.GetFilenameTabPage(pagesTabControl.SelectedTabPage);
                if (String.IsNullOrEmpty(filenameTabPage))
                {
                    saveFileDialog.FileName = "*.pdf";
                }
                else if (filenameTabPage.Contains("."))
                {
                    saveFileDialog.FileName = filenameTabPage.Substring(0, filenameTabPage.LastIndexOf('.')) + ".pdf";
                }
                else
                {
                    saveFileDialog.FileName = filenameTabPage + ".pdf";
                }

                if (saveFileDialog.ShowDialog() != DialogResult.OK)
                {
                    toolStripProgressBar.Visible = false;
                    return(false);
                }

                Application.DoEvents();
                toolStripProgressBar.Value   = 0;
                toolStripProgressBar.Visible = true;

                String fileName = saveFileDialog.FileName;
                toolStripProgressBar.PerformStep();

                ConfigUtil.UpdateParameter("LastUserFolder", Path.GetDirectoryName(fileName));
                FileInfo fileInfo = new FileInfo(fileName);
                if (fileInfo.IsReadOnly && fileInfo.Exists)
                {
                    toolStripProgressBar.Visible = false;
                    WindowManager.ShowInfoBox(form, LanguageUtil.GetCurrentLanguageString("SavingReadonly", className));
                    return(SaveAsPdf(form));
                }

                toolStripProgressBar.PerformStep();
                String fileTitle = fileName.Substring(0, fileName.LastIndexOf(".pdf"));

                //Document document = new Document();
                //FileStream fileStream = File.Create(fileName);
                //PdfWriter.GetInstance(document, fileStream);

                //document.Open();
                //document.AddTitle(fileTitle);
                //document.AddCreationDate();
                //document.AddCreator("DtPad " + AssemblyUtil.AssemblyVersion);
                //document.Add(new Paragraph(pageTextBox.Text));

                //if (document.IsOpen())
                //{
                //    document.CloseDocument();
                //}
                //fileStream.Dispose();
                PdfUtil.SaveText(fileName, fileTitle, pageTextBox.Text);

                toolStripProgressBar.PerformStep();
                toolStripStatusLabel.Text = String.Format("{0} \"{1}\" {2}", LanguageUtil.GetCurrentLanguageString("File", className), Path.GetFileName(fileName), LanguageUtil.GetCurrentLanguageString("Saved", className));

                toolStripProgressBar.PerformStep();
                toolStripProgressBar.Visible = false;

                OtherManager.StartProcess(form, fileName);
                saveFileDialog.FileName = "*.txt";
                return(true);
            }
            catch (Exception exception)
            {
                toolStripProgressBar.Visible = false;
                saveFileDialog.FileName      = "*.txt";
                WindowManager.ShowErrorBox(form, exception.Message, exception);
                return(false);
            }
        }