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 SetOpenWithLink()
        {
            if (ExistsOpenWithLink())
            {
                return;
            }

            RegistryKey key = Registry.CurrentUser.OpenSubKey(String.Format(@"Software\Classes\*\shell\{0}", LanguageUtil.GetCurrentLanguageString("ShellString", className)));

            if (key == null)
            {
                key = Registry.CurrentUser.CreateSubKey(String.Format(@"Software\Classes\*\shell\{0}", LanguageUtil.GetCurrentLanguageString("ShellString", className)));
            }
            key.SetValue("icon", Path.Combine(Path.Combine(ConstantUtil.ApplicationExecutionPath(), "Icons"), "DtPad.ico"));

            key = Registry.CurrentUser.OpenSubKey(String.Format(@"Software\Classes\*\shell\{0}\command", LanguageUtil.GetCurrentLanguageString("ShellString", className)));
            if (key == null)
            {
                key = Registry.CurrentUser.CreateSubKey(String.Format(@"Software\Classes\*\shell\{0}\command", LanguageUtil.GetCurrentLanguageString("ShellString", className)));
            }
            key.SetValue(String.Empty, Path.Combine(ConstantUtil.ApplicationExecutionPath(), "DtPad.exe") + " \"%1\"");

            //RegistryKey key = Registry.CurrentUser.OpenSubKey(String.Format(@"Software\Classes\*\shell\{0}\command", LanguageUtil.GetCurrentLanguageString("ShellString", className)));
            //if (key == null)
            //{
            //    key = Registry.CurrentUser.CreateSubKey(String.Format(@"Software\Classes\*\shell\{0}\command", LanguageUtil.GetCurrentLanguageString("ShellString", className)));
            //}
            //key.SetValue(String.Empty, Path.Combine(ConstantUtil.ApplicationExecutionPath(), "DtPad.exe") + " \"%1\"");
        }
Exemple #3
0
        internal static void LoadRecentFiles(Form1 form, bool forceLoad, bool shortUrl = false)
        {
            ToolStripMenuItem recentFilesToolStripMenuItem = form.recentFilesToolStripMenuItem;

            if (!forceLoad && recentFilesToolStripMenuItem.DropDownItems.Count > 3)
            {
                return;
            }

            while (recentFilesToolStripMenuItem.DropDownItems.Count > 3)
            {
                recentFilesToolStripMenuItem.DropDownItems.Remove(recentFilesToolStripMenuItem.DropDownItems[3]);
            }

            String fileContent = FileUtil.ReadToEndWithStandardEncoding(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.rfFile));

            String[] separator           = { Environment.NewLine };
            String[] splittedFileContent = fileContent.Split(separator, StringSplitOptions.RemoveEmptyEntries);

            foreach (String splittedFileContentString in splittedFileContent)
            {
                String text = splittedFileContentString;

                if (shortUrl)
                {
                    text = StringUtil.CheckStringLength(text, maxCharsNumber);
                }

                recentFilesToolStripMenuItem.DropDownItems.Add(text, null, form.recentFileToolStripMenuItem_Click);
            }
        }
Exemple #4
0
        internal static void ClearInternetCache(Form form)
        {
            try
            {
                String controlTempPath = Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.internetCacheDirectoryName);
                if (!Directory.Exists(controlTempPath))
                {
                    return;
                }

                String[] files = Directory.GetFiles(controlTempPath);
                foreach (String file in files)
                {
                    if (file == Path.Combine(controlTempPath, ConstantUtil.internetCacheInfoFileName))
                    {
                        continue;
                    }

                    File.Delete(file);
                }
            }
            catch (Exception exception)
            {
                WindowManager.ShowErrorBox(form, exception.Message, exception);
            }
        }
Exemple #5
0
        internal static void ChangeNoteColor(Form1 form, TagEnum color)
        {
            TreeView notesTreeView = form.notePanel.notesTreeView;

            TreeNode selectedNode      = notesTreeView.SelectedNode;
            int      selectedNodeIndex = notesTreeView.SelectedNode.Index;

            try
            {
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.noFile));

                //Save XML
                XmlNodeList nodeNodeList    = xmldoc.GetElementsByTagName("note");
                XmlElement  selectedNodeXml = (XmlElement)nodeNodeList[selectedNodeIndex];
                selectedNodeXml.SetAttribute("tag", color.ToString());

                SaveXml(xmldoc, Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.noFile));

                selectedNode.ImageIndex         = Convert.ToInt32(color);
                selectedNode.SelectedImageIndex = Convert.ToInt32(color);
                selectedNode.ForeColor          = Color.FromKnownColor((KnownColor)Enum.Parse(typeof(KnownColor), color.ToString(), true));
            }
            catch (XmlException exception)
            {
                ManageError(form, exception);
            }
        }
        internal static void GetClipboardList(Form1 form, bool forceLoad)
        {
            ListBox        clipboardListBox   = form.clipboardPanel.clipboardListBox;
            XtraTabControl verticalTabControl = form.verticalTabControl;
            XtraTabPage    clipboardTabPage   = form.clipboardTabPage;

            if ((verticalTabControl.SelectedTabPage != clipboardTabPage) || (!forceLoad && clipboardListBox.Items.Count > 0))
            {
                return;
            }

            ClearClipboardList(form);

            try
            {
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.clFile));

                XmlNodeList clipList = xmldoc.GetElementsByTagName("clip");

                foreach (XmlNode clip in clipList)
                {
                    clipboardListBox.Items.Add(clip.ChildNodes[1].InnerText); //short
                }
            }
            catch (XmlException exception)
            {
                WindowManager.ShowErrorBox(form, LanguageUtil.GetCurrentLanguageString("ErrorReading", className), exception);
                FileListManager.SaveFileList(ConstantUtil.clFile, ConstantUtil.defaultClipboardFileContent);
            }
        }
Exemple #7
0
        internal static void ImportOptions(Form1 form)
        {
            OpenFileDialog       openFileDialog       = form.openFileDialog;
            ToolStripStatusLabel toolStripStatusLabel = form.toolStripStatusLabel;
            ToolStripProgressBar toolStripProgressBar = form.toolStripProgressBar;

            openFileDialog.InitialDirectory = ConstantUtil.ApplicationExecutionPath();
            openFileDialog.Multiselect      = false;
            openFileDialog.Filter           = String.Format("{0} (*.{1})|*.{1}", LanguageUtil.GetCurrentLanguageString("ExportFileDescription", className), ConstantUtil.exportFileExtension); //DtPad export files (*.dpe)|*.dpe
            openFileDialog.FileName         = String.Format("*.{0}", ConstantUtil.exportFileExtension);

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

            ZipFile toImportFile = null;

            try
            {
                toImportFile = new ZipFile(openFileDialog.FileName);

                if (toImportFile.ZipFileComment != AssemblyUtil.AssemblyVersion)
                {
                    if (WindowManager.ShowQuestionBox(form, LanguageUtil.GetCurrentLanguageString("WarningImport", className)) == DialogResult.No)
                    {
                        return;
                    }
                }
            }
            finally
            {
                if (toImportFile != null)
                {
                    toImportFile.Close();
                }
            }

            toolStripProgressBar.Value   = 0;
            toolStripProgressBar.Visible = true;

            FastZip importFile = new FastZip();

            toolStripProgressBar.PerformStep();

            importFile.ExtractZip(openFileDialog.FileName, ConstantUtil.ApplicationExecutionPath(), FastZip.Overwrite.Always, null, String.Empty, String.Empty, true);

            toolStripProgressBar.PerformStep();

            //String importStatus = String.Format("{0} \"{1}\" {2}", LanguageUtil.GetCurrentLanguageString("ImportStatusLabel1", className), openFileDialog.FileName, LanguageUtil.GetCurrentLanguageString("ImportStatusLabel2", className));
            String importStatus = String.Format(LanguageUtil.GetCurrentLanguageString("ImportStatusLabel", className), openFileDialog.FileName);

            toolStripProgressBar.PerformStep();
            toolStripProgressBar.PerformStep();

            toolStripStatusLabel.Text = importStatus;
            WindowManager.ShowInfoBox(form, importStatus + "!");

            toolStripProgressBar.Visible = false;
        }
        private static bool IsContentAlreadyClipboarded(Form form, String newContent)
        {
            try
            {
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.clFile));

                XmlNodeList contentList = xmldoc.GetElementsByTagName("content");

                //foreach (XmlNode content in contentList)
                //{
                //    if (content.InnerText == newContent)
                //    {
                //        return true;
                //    }
                //}
                if (contentList.Cast <XmlNode>().Any(content => content.InnerText == newContent))
                {
                    return(true);
                }
            }
            catch (XmlException exception)
            {
                WindowManager.ShowErrorBox(form, LanguageUtil.GetCurrentLanguageString("ErrorReading", className), exception);
                FileListManager.SaveFileList(ConstantUtil.clFile, ConstantUtil.defaultClipboardFileContent);
            }

            return(false);
        }
        private static String GetContent(int number)
        {
            try
            {
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.clFile));

                XmlNodeList clipList = xmldoc.GetElementsByTagName("clip");

                foreach (XmlNode clip in clipList)
                {
                    if (clip.ChildNodes[0].InnerText == number.ToString())
                    {
                        return(clip.ChildNodes[2].InnerText);
                    }
                }
            }
            catch (XmlException exception)
            {
                WindowManager.ShowErrorBox(null, LanguageUtil.GetCurrentLanguageString("ErrorReading", className), exception);
                FileListManager.SaveFileList(ConstantUtil.clFile, ConstantUtil.defaultClipboardFileContent);
            }

            return(String.Empty);
        }
Exemple #10
0
        internal static void SaveTextNode(Form1 form, String title, String text)
        {
            try
            {
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.noFile));

                XmlNodeList noteNodeList = xmldoc.GetElementsByTagName("note");

                foreach (XmlNode noteNode in noteNodeList)
                {
                    if (noteNode.ChildNodes[0].InnerText != title)
                    {
                        continue;
                    }

                    noteNode.ChildNodes[1].InnerText = text;
                    break;
                }

                SaveXml(xmldoc, Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.noFile));
            }
            catch (XmlException exception)
            {
                ManageError(form, exception);
            }
        }
Exemple #11
0
 public CssController(IOptionsSnapshot <BackgroundSetting> bgSetting, ICompositeViewEngine viewEngine, IActionContextAccessor actionAccessor, ConstantUtil constantUtil)
 {
     _bgSetting      = bgSetting.Value;
     _viewEngine     = viewEngine;
     _actionAccessor = actionAccessor;
     _constantUtil   = constantUtil;
 }
Exemple #12
0
        internal static void SetNewRecentSearchInFilesDirs(SearchInFiles form, String path)
        {
            String fileContent = FileUtil.ReadToEndWithStandardEncoding(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.sfFile));

            const int maxRecentFolders = 10;

            //Opening-saving patterns has already been censed into file
            if (fileContent.IndexOf(path + Environment.NewLine) >= 0)
            {
                fileContent = fileContent.Remove(fileContent.IndexOf(path + Environment.NewLine), path.Length + Environment.NewLine.Length);
            }

            String[] rows = fileContent.Replace(Environment.NewLine, ConstantUtil.newLine).Split(new[] { Convert.ToChar(ConstantUtil.newLine) }, StringSplitOptions.RemoveEmptyEntries);

            if (rows.Length >= maxRecentFolders)
            {
                fileContent = String.Empty;

                for (int i = 0; i < maxRecentFolders - 1; i++)
                {
                    fileContent += rows[i] + Environment.NewLine;
                }
            }

            fileContent = path + Environment.NewLine + fileContent;

            SaveFileList(ConstantUtil.sfFile, fileContent);
            LoadRecentSearchInFilesDirs(form);
        }
Exemple #13
0
        internal static void AddNote(Form1 form, String title)
        {
            try
            {
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.noFile));

                if (CheckNoteTitleExists(form, title))
                {
                    WindowManager.ShowAlertBox(form, LanguageUtil.GetCurrentLanguageString("AlreadyExists", className));
                    GetNotesList(form);
                    return;
                }

                XmlElement newNote = xmldoc.CreateElement("note");

                XmlElement noteTitleNode = xmldoc.CreateElement("title");
                noteTitleNode.InnerText = title;
                newNote.AppendChild(noteTitleNode);
                XmlElement noteTextNode = xmldoc.CreateElement("text");
                noteTextNode.InnerText = String.Empty;
                newNote.AppendChild(noteTextNode);

                xmldoc.DocumentElement.InsertAfter(newNote, xmldoc.DocumentElement.LastChild);
                SaveXml(xmldoc, Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.noFile));
            }
            catch (XmlException exception)
            {
                ManageError(form, exception);
            }
        }
Exemple #14
0
        internal static void LoadSearchHistory(Form1 form)
        {
            ToolStripDropDownButton historyToolStripDropDownButton = form.searchPanel.historyToolStripDropDownButton;

            while (historyToolStripDropDownButton.DropDownItems.Count > 2)
            {
                historyToolStripDropDownButton.DropDownItems.Remove(historyToolStripDropDownButton.DropDownItems[2]);
            }

            String fileContent = FileUtil.ReadToEndWithStandardEncoding(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.shFile));

            String[] separator           = { Environment.NewLine };
            String[] splittedFileContent = fileContent.Split(separator, StringSplitOptions.RemoveEmptyEntries);

            foreach (String splittedFileContentString in splittedFileContent)
            {
                ToolStripMenuItem newItem = new ToolStripMenuItem
                {
                    Text        = StringUtil.CheckStringLengthEnd(splittedFileContentString.Replace(ConstantUtil.newLine, "\\n"), 50),
                    Tag         = splittedFileContentString.Replace(ConstantUtil.newLine, Environment.NewLine),
                    ToolTipText = splittedFileContentString
                };
                newItem.Click += form.historyToolStripDropDownButton_Click;

                historyToolStripDropDownButton.DropDownItems.Add(newItem);
            }
        }
Exemple #15
0
        private static bool CheckNoteTitleExists(Form1 form, String title)
        {
            try
            {
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.noFile));
                XmlNodeList noteNodeList = xmldoc.GetElementsByTagName("note");

                //foreach (XmlNode noteNode in noteNodeList)
                //{
                //    if (noteNode.ChildNodes[0].InnerText == title)
                //    {
                //        return true;
                //    }
                //}
                if (noteNodeList.Cast <XmlNode>().Any(noteNode => noteNode.ChildNodes[0].InnerText == title))
                {
                    return(true);
                }
            }
            catch (XmlException exception)
            {
                ManageError(form, exception);
            }

            return(false);
        }
Exemple #16
0
        private static void Validate(Form1 form, String validation, String title)
        {
            CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(form.pagesTabControl.SelectedTabPage);

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

            String fileName = String.Format("{0}.html", Guid.NewGuid());
            String pathName = Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.internetCacheDirectoryName);

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

            String text = String.Format(validation, title, pageTextBox.Text, LanguageUtil.GetCurrentLanguageString("Validate", className));

            String fileAndPathName = Path.Combine(pathName, fileName);

            if (FileManager.SaveFileCoreWithEncoding(form, fileAndPathName, text) == false)
            {
                return;
            }

            OtherManager.StartProcessBrowser(form, fileAndPathName);
        }
Exemple #17
0
        public static void Main(String[] args)
        {
            String culture      = ConfigUtil.GetStringParameter("Language", "English", Application.StartupPath);
            String shortCulture = LanguageUtil.GetReallyShortCulture(culture);

            if (!CheckPermissions(shortCulture))
            {
                Application.DoEvents();
                Application.Exit();
                return;
            }

            if (Process.GetProcessesByName("DtPadUpdater").Length > 1)
            {
                String error = LanguageUtil.GetCurrentLanguageString("InstanceDtPadUpdater", "Program", shortCulture);
                WindowManager.ShowAlertProgramBox(null, error, shortCulture);
                Application.Exit();
                return;
            }

            if (args.Length == 0 || args[0] != "-nocheck")
            {
                if (Process.GetProcessesByName("DtPad").Length > 0)
                {
                    String error = LanguageUtil.GetCurrentLanguageString("InstanceDtPad", "Program", shortCulture);
                    WindowManager.ShowAlertProgramBox(null, error, shortCulture);
                    Application.Exit();
                    return;
                }
                if (Process.GetProcessesByName("DtHelp").Length > 0)
                {
                    String error = LanguageUtil.GetCurrentLanguageString("InstanceDtHelp", "Program", shortCulture);
                    WindowManager.ShowAlertProgramBox(null, error, shortCulture);
                    Application.Exit();
                    return;
                }
                if (Process.GetProcessesByName("DtPadUninstaller").Length > 0)
                {
                    String error = LanguageUtil.GetCurrentLanguageString("InstanceDtPadUninstaller", "Program", shortCulture);
                    WindowManager.ShowAlertProgramBox(null, error, shortCulture);
                    Application.Exit();
                    return;
                }
            }
            else if (args.Length > 0 && args[0] == "-nocheck")
            {
                Process[] winProcessList = Process.GetProcessesByName("DtPad");

                foreach (Process winProcess in winProcessList)
                {
                    winProcess.Kill();
                }
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.ThreadException += Main_ThreadExceptionEventHandler;
            Application.Run(new Form1(ConstantUtil.ApplicationExecutionPath()));
        }
Exemple #18
0
        internal static void ExportNotes(Form1 form, ExportTypeEnum exportType)
        {
            XtraTabControl    pagesTabControl = form.pagesTabControl;
            CustomRichTextBox pageTextBox     = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage);

            String content;

            switch (exportType)
            {
            case ExportTypeEnum.Xml:
                if (TabManager.IsCurrentTabInUse(form))
                {
                    form.TabIdentity = TabManager.AddNewPage(form, form.TabIdentity);
                    pageTextBox      = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage);
                }

                content = FileUtil.ReadToEndWithStandardEncoding(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.noFile));

                //Row number check
                WindowManager.CheckLineNumbersForTextLenght(form, content);

                pageTextBox.SelectedText = content;

                TextManager.RefreshUndoRedoExternal(form);
                break;

            case ExportTypeEnum.Txt:
                try
                {
                    XmlDocument xmldoc = new XmlDocument();
                    xmldoc.Load(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.noFile));

                    XmlNodeList noteNodeList = xmldoc.GetElementsByTagName("note");

                    foreach (XmlNode noteNode in noteNodeList)
                    {
                        if (TabManager.IsCurrentTabInUse(form))
                        {
                            form.TabIdentity = TabManager.AddNewPage(form, form.TabIdentity);
                            pageTextBox      = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage);
                        }

                        content = noteNode.ChildNodes[0].InnerText + ConstantUtil.newLine + ConstantUtil.newLine + noteNode.ChildNodes[1].InnerText;

                        //Row number check
                        WindowManager.CheckLineNumbersForTextLenght(form, content);

                        pageTextBox.SelectedText = content;

                        TextManager.RefreshUndoRedoExternal(form);
                    }
                }
                catch (XmlException exception)
                {
                    ManageError(form, exception);
                }
                break;
            }
        }
Exemple #19
0
        internal static void GetNotesList(Form1 form)
        {
            TreeView         notesTreeView        = form.notePanel.notesTreeView;
            ContextMenuStrip noteContextMenuStrip = form.notePanel.noteContextMenuStrip;

            notesTreeView.BeginUpdate();
            notesTreeView.Nodes.Clear();

            try
            {
                XmlNodeList noteNodeList;
                using (StreamReader reader = new StreamReader(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.noFile)))
                {
                    XmlDocument xmldoc = new XmlDocument();
                    xmldoc.Load(reader);

                    noteNodeList = xmldoc.GetElementsByTagName("note");
                }

                foreach (XmlNode noteNode in noteNodeList)
                {
                    TagEnum color;

                    try
                    {
                        color = (TagEnum)Enum.Parse(typeof(TagEnum), noteNode.Attributes["tag"].Value, true);
                    }
                    catch (Exception)
                    {
                        color = TagEnum.Black;
                    }

                    TreeNode node = new TreeNode(noteNode.ChildNodes[0].InnerText)
                    {
                        ContextMenuStrip   = noteContextMenuStrip,
                        ImageIndex         = Convert.ToInt32(color),
                        SelectedImageIndex = Convert.ToInt32(color),
                        ForeColor          = Color.FromKnownColor((KnownColor)Enum.Parse(typeof(KnownColor), color.ToString(), true))
                    };
                    notesTreeView.Nodes.Add(node);
                }

                if (notesTreeView.Nodes.Count > 0)
                {
                    notesTreeView.SelectedNode = notesTreeView.Nodes[0];
                }

                ExplorerManager.ToggleNoteInput(form);
                notesTreeView.EndUpdate();
            }
            catch (XmlException exception)
            {
                ManageError(form, exception);
            }
            catch (DirectoryNotFoundException exception)
            {
                ManageError(form, exception);
            }
        }
Exemple #20
0
        internal static bool ExistsFavouriteFile()
        {
            String fileContent = FileUtil.ReadToEndWithStandardEncoding(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.fvFile));

            String[] separator           = { Environment.NewLine };
            String[] splittedFileContent = fileContent.Split(separator, StringSplitOptions.RemoveEmptyEntries);

            return(splittedFileContent.Length > 0);
        }
Exemple #21
0
        internal static TemplateObjectList LoadTemplatesList(Templates form)
        {
            TreeView templateTreeView   = form.templateTreeView;
            TextBox  descriptionTextBox = form.descriptionTextBox;
            TextBox  textTextBox        = form.textTextBox;
            Button   removeButton       = form.removeButton;

            TemplateObjectList templateObjectList = new TemplateObjectList();

            String fileContent = FileUtil.ReadToEndWithStandardEncoding(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.tmFile));

            String[] separator           = { Environment.NewLine };
            String[] splittedFileContent = fileContent.Split(separator, StringSplitOptions.RemoveEmptyEntries);

            if (splittedFileContent.Length > 0)
            {
                templateTreeView.BeginUpdate();
            }

            foreach (String templateString in splittedFileContent) //HTML@|-<html></html>
            {
                separator[0] = "@|-";
                String[] splittedExtensionContent = templateString.Split(separator, StringSplitOptions.None);

                if (splittedExtensionContent.Length != 2)
                {
                    WindowManager.ShowAlertBox(form, LanguageUtil.GetCurrentLanguageString("ErrorReading", className));
                    FileListManager.SaveFileList(ConstantUtil.tmFile, String.Empty);
                    return(LoadTemplatesList(form));
                }

                templateTreeView.Nodes.Add(splittedExtensionContent[0]); //HTML

                TemplateObject templateObject = new TemplateObject(splittedExtensionContent[0], splittedExtensionContent[1]);
                templateObjectList.Add(templateObject);
            }

            if (splittedFileContent.Length > 0)
            {
                templateTreeView.EndUpdate();
            }

            templateTreeView.Focus();

            if (templateTreeView.Nodes.Count > 0)
            {
                templateTreeView.SelectedNode = templateTreeView.Nodes[0];
            }
            else
            {
                descriptionTextBox.Enabled = false;
                textTextBox.Enabled        = false;
                removeButton.Enabled       = false;
            }

            return(templateObjectList);
        }
Exemple #22
0
        internal static void LoadFavouriteWindowFiles(Favourites form)
        {
            ListBox favouritesListBox = form.favouritesListBox;

            String fileContent = FileUtil.ReadToEndWithStandardEncoding(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.fvFile));

            String[] separator           = { Environment.NewLine };
            String[] splittedFileContent = fileContent.Split(separator, StringSplitOptions.RemoveEmptyEntries);

            foreach (String splittedFileContentString in splittedFileContent)
            {
                favouritesListBox.Items.Add(splittedFileContentString); //StringUtil.CheckStringLength(splittedFileContentString, 60)
            }
        }
Exemple #23
0
        internal static void SetSendToLink()
        {
            String sendToDir       = Environment.GetFolderPath(Environment.SpecialFolder.SendTo);
            String destinationPath = ConstantUtil.ApplicationExecutionPath();

            ShellShortcut shortcut = new ShellShortcut(Path.Combine(sendToDir, "DtPad.lnk"))
            {
                Path             = Path.Combine(destinationPath, "DtPad.exe"),
                WorkingDirectory = destinationPath,
                Description      = LanguageUtil.GetCurrentLanguageString("LinkLaunchDtPad", className),
                IconPath         = Path.Combine(destinationPath, "Icons\\DtPad.ico")
            };

            shortcut.Save();
        }
Exemple #24
0
        internal static void SetNewRecentPattern(SearchPattern form, String regularExpression)
        {
            String fileContent = FileUtil.ReadToEndWithStandardEncoding(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.rpFile));

            //Opening-saving patterns has already been censed into file
            if (fileContent.IndexOf(regularExpression + Environment.NewLine) >= 0)
            {
                fileContent = fileContent.Remove(fileContent.IndexOf(regularExpression + Environment.NewLine), regularExpression.Length + Environment.NewLine.Length);
            }

            fileContent = regularExpression + Environment.NewLine + fileContent;

            SaveFileList(ConstantUtil.rpFile, fileContent);
            LoadRecentPatterns(form);
        }
Exemple #25
0
        private void ClipboardData(Form1 form)
        {
            String textToClipboard = String.Empty;

            textToClipboard += usernameLabel1.Text + " " + usernameLabel.Text + Environment.NewLine;
            textToClipboard += domainLabel1.Text + " " + domainLabel.Text + Environment.NewLine;
            textToClipboard += workingDirectoryLabel1.Text + " " + ConstantUtil.ApplicationExecutionPath() + Environment.NewLine;
            textToClipboard += machineNameLabel1.Text + " " + machineNameLabel.Text + Environment.NewLine;
            textToClipboard += osLabel1.Text + " " + osLabel.Text + Environment.NewLine;
            textToClipboard += processorsLabel1.Text + " " + processorsLabel.Text + Environment.NewLine;
            textToClipboard += frameworkVersionLabel1.Text + " " + frameworkVersionLabel.Text + Environment.NewLine;
            textToClipboard += memoryLabel1.Text + " " + memoryLabel.Text + Environment.NewLine;

            Clipboard.SetDataObject(textToClipboard, true, ConstantUtil.clipboardRetryTimes, ConstantUtil.clipboardRetryDelay);
            ClipboardManager.AddContent(form);
        }
Exemple #26
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);
        }
        private static ExtensionObjectList LoadExtensionsListPrivate(Extensions form, bool suppressMessageBox)
        {
            TreeView extensionTreeView = form.extensionTreeView;

            ExtensionObjectList extensionObjectList = new ExtensionObjectList();

            String fileContent = FileUtil.ReadToEndWithStandardEncoding(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.exFile));

            String[] separator           = { Environment.NewLine };
            String[] splittedFileContent = fileContent.Split(separator, StringSplitOptions.RemoveEmptyEntries);

            if (splittedFileContent.Length > 0)
            {
                extensionTreeView.BeginUpdate();
            }

            foreach (String extensionString in splittedFileContent)
            {
                separator[0] = "|";
                String[] splittedExtensionContent = extensionString.Split(separator, StringSplitOptions.RemoveEmptyEntries);

                if (splittedExtensionContent.Length != 3)
                {
                    if (!suppressMessageBox)
                    {
                        WindowManager.ShowAlertBox(form, LanguageUtil.GetCurrentLanguageString("Reading", className));
                    }
                    FileListManager.SaveFileList(ConstantUtil.exFile, ConstantUtil.defaultExtensionFileContent);
                    return(LoadExtensionsList(form));
                }

                extensionTreeView.Nodes.Add(splittedExtensionContent[0]); //Text document

                ExtensionObject extensionObject = new ExtensionObject(splittedExtensionContent[0], splittedExtensionContent[1], Convert.ToBoolean(splittedExtensionContent[2]));
                extensionObjectList.Add(extensionObject);
            }

            if (splittedFileContent.Length > 0)
            {
                extensionTreeView.EndUpdate();
            }

            extensionTreeView.Focus();
            extensionTreeView.SelectedNode = extensionTreeView.Nodes[0];

            return(extensionObjectList);
        }
Exemple #28
0
        internal static void SaveFileList(String file, String content)
        {
            //StreamWriter textFileWriter = null;
            //try
            //{
            //    textFileWriter = File.CreateText(Path.Combine(ConstantUtil.ApplicationExecutionPath(), file));
            //    textFileWriter.Write(content);
            //}
            //finally
            //{
            //    if (textFileWriter != null)
            //    {
            //        textFileWriter.Close();
            //    }
            //}

            FileStream   fileStream      = null;
            StreamWriter textFile        = null;
            String       fileNameAndPath = Path.Combine(ConstantUtil.ApplicationExecutionPath(), file);

            //Check for read-only flag
            FileInfo fileInfo = new FileInfo(fileNameAndPath);

            if (fileInfo.Exists && fileInfo.IsReadOnly)
            {
                File.SetAttributes(fileNameAndPath, FileAttributes.Normal);
            }

            try
            {
                fileStream = File.Create(fileNameAndPath);
                textFile   = new StreamWriter(fileStream, Encoding.Default);
                textFile.Write(content);
            }
            finally
            {
                if (textFile != null)
                {
                    textFile.Close();
                }
                if (fileStream != null)
                {
                    fileStream.Close();
                }
            }
        }
Exemple #29
0
        internal static void LoadRecentSearchInFilesDirs(SearchInFiles form)
        {
            ComboBox searchFolderComboBox = form.searchFolderComboBox;

            searchFolderComboBox.Items.Clear();
            searchFolderComboBox.Items.Add(String.Empty);

            String fileContent = FileUtil.ReadToEndWithStandardEncoding(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.sfFile));

            String[] separator           = { Environment.NewLine };
            String[] splittedFileContent = fileContent.Split(separator, StringSplitOptions.RemoveEmptyEntries);

            foreach (String splittedFileContentString in splittedFileContent)
            {
                searchFolderComboBox.Items.Add(splittedFileContentString);
            }
        }
Exemple #30
0
        internal static void LoadRecentURLs(UrlEntry form)
        {
            ComboBox urlAddressComboBox = form.urlAddressComboBox;

            urlAddressComboBox.Items.Clear();
            urlAddressComboBox.Items.Add("http://");

            String fileContent = FileUtil.ReadToEndWithStandardEncoding(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.ruFile));

            String[] separator           = { Environment.NewLine };
            String[] splittedFileContent = fileContent.Split(separator, StringSplitOptions.RemoveEmptyEntries);

            foreach (String splittedFileContentString in splittedFileContent)
            {
                urlAddressComboBox.Items.Add(splittedFileContentString);
            }
        }