Esempio n. 1
0
        internal static void ShowXmlEditor(Form1 form)
        {
            CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(form.pagesTabControl.SelectedTabPage);

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

            String error;

            if (!XmlValidator.Validate(form, false, ValidationType.Schema, null, out error))
            {
                ShowAlertBox(form, error);
                return;
            }

            XmlEditor fileRename = new XmlEditor {
                Owner = form
            };

            fileRename.InitializeForm();
            fileRename.Show(form);
        }
Esempio n. 2
0
        internal static void CheckLineNumbers(Form1 form, bool checkStatus, bool refreshConfig)
        {
            XtraTabControl    pagesTabControl = form.pagesTabControl;
            ToolStripMenuItem lineNumbersToolStripMenuItem = form.lineNumbersToolStripMenuItem;
            ToolStripButton   lineNumbersToolStripButton   = form.lineNumbersToolStripButton;

            foreach (XtraTabPage tabPage in pagesTabControl.TabPages)
            {
                CustomLineNumbers customLineNumbers = ProgramUtil.GetCustomLineNumbers(tabPage);
                customLineNumbers.Visible = checkStatus;

                ColumnRulerManager.UpdatePanelAppearance(tabPage, checkStatus);

                if (!checkStatus)
                {
                    continue;
                }

                customLineNumbers.Size = new Size(customLineNumbers.Size.Width + 1, customLineNumbers.Size.Height);
                customLineNumbers.Size = new Size(customLineNumbers.Size.Width - 1, customLineNumbers.Size.Height);
            }

            lineNumbersToolStripMenuItem.Checked = checkStatus;
            lineNumbersToolStripButton.Checked   = checkStatus;

            UpdateConfigParameter("LineNumbersVisible", checkStatus.ToString(), refreshConfig);
        }
Esempio n. 3
0
        internal static void FormatXml(Form1 form, bool validationFirst = true, bool indentation = true)
        {
            XtraTabControl    pagesTabControl = form.pagesTabControl;
            CustomRichTextBox pageTextBox     = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage);

            if (validationFirst && !XmlValidator.Validate(form, ValidationType.Schema, false))
            {
                return;
            }

            int indentationNum = indentation ? 1 : 0;

            XmlDocument xd = new XmlDocument();

            xd.LoadXml(pageTextBox.Text); //xd.LoadXml(EncodeHTMLTagsForXMLValidation(pageTextBox.Text));

            StringBuilder builder = new StringBuilder();

            using (StringWriter writer = new StringWriter(builder))
            {
                using (XmlTextWriter xtw = new XmlTextWriter(writer))
                {
                    xtw.IndentChar  = '\t';
                    xtw.Indentation = indentationNum;
                    xtw.Formatting  = Formatting.Indented;

                    xd.WriteTo(xtw);
                }

                pageTextBox.SelectAll();
                pageTextBox.SelectedText = builder.ToString(); //pageTextBox.SelectedText = DecodeHTMLTagsForXMLValidation(builder.ToString());
                TextManager.RefreshUndoRedoExternal(form);
            }
        }
Esempio n. 4
0
        public static void Start(string[] menu)
        {
            if (menu.Length == 0)
            {
                new Program(new PirateConsole());
            }
            else if (ProgramUtil.TryParseInt(menu[0]).didParse)
            {
                int choice = ProgramUtil.ParseInt(menu[0]);
                switch (choice)
                {
                case 1:
                    new Program(new PirateConsole());
                    break;

                case 2:
                    new Program(new PrettyConsole());
                    break;

                case 3:
                    new Program(new AngryConsole());
                    break;

                default:
                    new Program(new PirateConsole());
                    break;
                }
            }
            else
            {
                new Program(new PirateConsole());
            }
            Program.Run();
        }
Esempio n. 5
0
        internal void InitializeForm()
        {
            InitializeComponent();
            LookFeelUtil.SetLookAndFeel(contentContextMenuStrip);
            SetLanguage();

            Form1 form = (Form1)Owner;

            String            filename    = ProgramUtil.GetFilenameTabPage(form.pagesTabControl.SelectedTabPage);
            CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(form.pagesTabControl.SelectedTabPage);
            String            xmlString   = pageTextBox.Text;

            //XmlUrlResolver resolver = new XmlUrlResolver();
            //resolver.Credentials = CredentialCache.DefaultCredentials;
            XmlDocument       xmldoc   = new XmlDocument();
            XmlReaderSettings settings = new XmlReaderSettings
            {
                IgnoreWhitespace = true,
                //XmlResolver = resolver,
                IgnoreComments = true,
                DtdProcessing  = DtdProcessing.Parse                                 //ProhibitDtd = false
            };
            StringReader reader = new StringReader(xmlString);
            XmlReader    render = !String.IsNullOrEmpty(filename) ? XmlReader.Create(reader, settings, filename) : XmlReader.Create(reader, settings);

            try
            {
                xmldoc.Load(render);
            }
            catch (Exception exception)
            {
                String error = String.Format(LanguageUtil.GetCurrentLanguageString("Error", Name), exception.Message);
                WindowManager.ShowAlertBox(form, error);

                reader.Dispose();
                render.Close();
                return;
            }

            reader.Dispose();
            render.Close();

            GridBuilder   builder  = new GridBuilder();
            GridCellGroup xmlgroup = new GridCellGroup {
                Flags = GroupFlags.Overlapped | GroupFlags.Expanded
            };

            builder.ParseNodes(xmlgroup, null, xmldoc.ChildNodes);
            root = new GridCellGroup();
            root.Table.SetBounds(1, 2);
            root.Table[0, 0] = new GridHeadLabel {
                Text = "XML"
            };
            root.Table[0, 1] = xmlgroup;
            xmlGridView.Cell = root;

            xmlGridView.Font      = pageTextBox.Font;
            xmlGridView.ForeColor = pageTextBox.ForeColor;
            xmlGridView.BackColor = pageTextBox.BackColor;
        }
Esempio n. 6
0
        private void SetFileDialogFilter()
        {
            XtraTabControl pagesTabControl = form.pagesTabControl;

            int    defaultExtension;
            String defaultExtensionShortString;
            String extensions = ExtensionManager.GetFileDialogFilter(out defaultExtension, out defaultExtensionShortString);

            String[] extensionsSplit = extensions.Split(new[] { '|' });

            int i = 0;

            while (i < extensionsSplit.Length)
            {
                saveAsComboBox.Items.Add(extensionsSplit[i]);
                i = i + 2;
            }

            if (defaultExtension != -1 && defaultExtension < saveAsComboBox.Items.Count)
            {
                saveAsComboBox.SelectedIndex = defaultExtension;
            }
            fileNameTextBox.Text = defaultExtensionShortString;

            String fileNameTab = ProgramUtil.GetFilenameTabPage(pagesTabControl.SelectedTabPage);

            if (windowType == WindowType.Save && !String.IsNullOrEmpty(fileNameTab))
            {
                fileNameTextBox.Text = Path.GetFileName(fileNameTab);
            }
        }
Esempio n. 7
0
        public static void Execute(ProgramExecutionOptions options)
        {
            if (ProgramUtil.ShowHelpIfNeeded(options))
            {
                return;
            }

            if (CommandLineUtil.ValidateArguments(options.ParsedArguments, Validations))
            {
                var target   = CommandLineUtil.FindArgumentByName(options.ParsedArguments, TargetArgName).Value;
                var userName = CommandLineUtil.FindArgumentByName(options.ParsedArguments, UserNameArgName).Value;
                var password = CommandLineUtil.FindArgumentByName(options.ParsedArguments, PasswordArgName).Value;

                var device = DeviceUtil.FindDeviceByIpOrName(target);
                if (device == null)
                {
                    var msg = string.Format("No device found with IP or Name equal to '{0}'.", target);
                    msg = TextUtil.Error(msg);
                    TerminalUtil.ShowText(msg);
                }
                else
                {
                    RunOnDevice(device, userName, password);
                }
            }
            else
            {
                TerminalUtil.ShowText("ERROR, PLEASE USE HELP. DUMB ASS");
            }
        }
Esempio n. 8
0
        private static void SearchLastInAllFiles(Form1 form)
        {
            XtraTabControl       pagesTabControl      = form.pagesTabControl;
            ToolStripStatusLabel toolStripStatusLabel = form.toolStripStatusLabel;

            int initialSelectedIndex = pagesTabControl.SelectedTabPageIndex;

            for (int i = pagesTabControl.TabPages.Count; i >= 0; i--)
            {
                pagesTabControl.SelectedTabPage = pagesTabControl.TabPages[i];
                if (i != initialSelectedIndex)
                {
                    ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage).Select(0, 0);
                }

                if (SearchLast(form, true))
                {
                    return;
                }
            }

            String notFoundMessage = LanguageUtil.GetCurrentLanguageString("NotFound", className);

            WindowManager.ShowInfoBox(form, notFoundMessage);
            toolStripStatusLabel.Text = notFoundMessage;
        }
Esempio n. 9
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);
        }
Esempio n. 10
0
        private static bool IsOpenedSessionModified(Form1 form)
        {
            ToolStripDropDownButton sessionImageToolStripButton = form.sessionImageToolStripButton;
            XtraTabControl          pagesTabControl             = form.pagesTabControl;

            //First control: session files are opened?
            for (int i = startPositionToReadSessionFiles; i < sessionImageToolStripButton.DropDownItems.Count; i++)
            {
                XtraTabPage tabPage;
                if (FileUtil.IsFileAlreadyOpen(form, sessionImageToolStripButton.DropDownItems[i].Text, out tabPage))
                {
                    continue;
                }

                return(true);
            }

            //Second control: opened files are saved into session?
            for (int i = 0; i < pagesTabControl.TabPages.Count; i++)
            {
                if (String.IsNullOrEmpty(ProgramUtil.GetPageTextBox(pagesTabControl.TabPages[i]).Text) || IsFileAlreadyInSession(form, ProgramUtil.GetFilenameTabPage(pagesTabControl.TabPages[i])))
                {
                    continue;
                }

                return(true);
            }

            return(false);
        }
Esempio n. 11
0
        internal static bool IsCurrentTabInUse(Form1 form)
        {
            XtraTabControl    pagesTabControl = form.pagesTabControl;
            CustomRichTextBox pageTextBox     = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage);

            return(!String.IsNullOrEmpty(pageTextBox.Text) || !String.IsNullOrEmpty(ProgramUtil.GetFilenameTabPage(pagesTabControl.SelectedTabPage)));
        }
Esempio n. 12
0
        internal static void DeleteFile(Form1 form)
        {
            XtraTabControl       pagesTabControl      = form.pagesTabControl;
            ToolStripStatusLabel toolStripStatusLabel = form.toolStripStatusLabel;

            String fileName = ProgramUtil.GetFilenameTabPage(pagesTabControl.SelectedTabPage);

            if (String.IsNullOrEmpty(fileName))
            {
                return;
            }

            if (WindowManager.ShowQuestionCancelBox(form, String.Format(LanguageUtil.GetCurrentLanguageString("SureDeleteFile", className), fileName)) != DialogResult.Yes)
            {
                return;
            }

            FileInfo fileInfo = new FileInfo(fileName);

            if (fileInfo.IsReadOnly)
            {
                ToggleReadonly(form);
            }

            FileSystem.DeleteFile(fileName, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin); //File.Delete(fileName);
            toolStripStatusLabel.Text = String.Format(LanguageUtil.GetCurrentLanguageString("FileDeleted", className), fileName);

            TabManager.ClosePage(form, false);
        }
Esempio n. 13
0
        internal static void TabTextChange(Form1 form)
        {
            XtraTabControl    pagesTabControl = form.pagesTabControl;
            CustomRichTextBox pageTextBox     = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage);

            if (pageTextBox.Text.GetHashCode().ToString() != pageTextBox.CustomOriginal && !TabUtil.IsTabPageModified(pagesTabControl.SelectedTabPage))
            {
                pagesTabControl.SelectedTabPage.ImageIndex = pagesTabControl.SelectedTabPage.ImageIndex + 1;
                pagesTabControl.SelectedTabPage.Text       = String.Format("*{0}", pagesTabControl.SelectedTabPage.Text);
                pageTextBox.CustomModified = true;
            }
            else if ((pageTextBox.Text.GetHashCode().ToString() == pageTextBox.CustomOriginal && TabUtil.IsTabPageModified(pagesTabControl.SelectedTabPage)) || String.IsNullOrEmpty(pageTextBox.Text) && String.IsNullOrEmpty(pageTextBox.CustomOriginal))
            {
                switch (pagesTabControl.SelectedTabPage.ImageIndex)
                {
                case 1:
                    pagesTabControl.SelectedTabPage.ImageIndex = 0;
                    break;

                case 3:
                    pagesTabControl.SelectedTabPage.ImageIndex = 2;
                    break;
                }
                pagesTabControl.SelectedTabPage.Text = String.Format("{0}", pagesTabControl.SelectedTabPage.Text.Substring(1));
                pageTextBox.CustomModified           = false;
            }

            form.Text = String.Format("DtPad - {0}", pagesTabControl.SelectedTabPage.Text);
        }
Esempio n. 14
0
        internal static void RefreshStatistics(Form1 form)
        {
            ToolStripMenuItem charactersStatToolStripMenuItem = form.charactersStatToolStripMenuItem;
            ToolStripMenuItem rowsStatToolStripMenuItem       = form.rowsStatToolStripMenuItem;
            ToolStripMenuItem columnsStatToolStripMenuItem    = form.columnsStatToolStripMenuItem;
            ToolStripMenuItem wordsStatToolStripMenuItem      = form.wordsStatToolStripMenuItem;
            CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(form.pagesTabControl.SelectedTabPage);

            charactersStatToolStripMenuItem.Text = LanguageUtil.GetCurrentLanguageString("charactersStatToolStripMenuItem", form.Name) + " " + pageTextBox.Text.Replace(ConstantUtil.newLine, String.Empty).Replace("\t", String.Empty).Length;

            int rowNumbers = pageTextBox.Lines.Length;

            if (rowNumbers == 0)
            {
                rowNumbers = 1;
            }
            rowsStatToolStripMenuItem.Text = LanguageUtil.GetCurrentLanguageString("rowsStatToolStripMenuItem", form.Name) + " " + rowNumbers;

            String[] separator = { ConstantUtil.newLine };
            //String[] lines = pageTextBox.Text.Split(separator, StringSplitOptions.None);
            //foreach (String line in lines)
            //{
            //    if (line.Length > columnNumbers)
            //    {
            //        columnNumbers = line.Length;
            //    }
            //}
            String[] lines         = pageTextBox.Text.Split(separator, StringSplitOptions.None);
            int      columnNumbers = lines.Select(line => line.Length).Concat(new[] { 0 }).Max();

            columnsStatToolStripMenuItem.Text = LanguageUtil.GetCurrentLanguageString("columnsStatToolStripMenuItem", form.Name) + " " + columnNumbers;

            String[] separator2 = { " ", ConstantUtil.newLine };
            wordsStatToolStripMenuItem.Text = LanguageUtil.GetCurrentLanguageString("wordsStatToolStripMenuItem", form.Name) + " " + pageTextBox.Text.Split(separator2, StringSplitOptions.RemoveEmptyEntries).Length;
        }
Esempio n. 15
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);
        }
Esempio n. 16
0
        internal static void WriteZipFile(String filename, IEnumerable <XtraTabPage> tabPages, String keepFoldersStartDir = "", IEnumerable <String> otherFiles = null)
        {
            ZipFile zipFile = ZipFile.Create(filename);

            zipFile.BeginUpdate();

            if (otherFiles != null)
            {
                foreach (String file in otherFiles)
                {
                    zipFile.Add(file, Path.GetFileName(file));
                }
            }

            foreach (XtraTabPage tabPage in tabPages)
            {
                String fileName  = ProgramUtil.GetFilenameTabPage(tabPage);
                String entryName = Path.GetFileName(ProgramUtil.GetFilenameTabPage(tabPage));

                if (keepFoldersStartDir != String.Empty)
                {
                    entryName = fileName.Substring(keepFoldersStartDir.Length + 1);
                }

                zipFile.Add(fileName, entryName);
            }

            zipFile.CommitUpdate();
            zipFile.Close();
        }
Esempio n. 17
0
        internal static void OpenNoteOnEditor(Form1 form)
        {
            XtraTabControl pagesTabControl = form.pagesTabControl;
            TreeView       notesTreeView   = form.notePanel.notesTreeView;

            TreeNode selectedNode = notesTreeView.SelectedNode;
            String   content;

            try
            {
                content = GetNoteText(form, selectedNode.Text);
            }
            catch (XmlException exception)
            {
                ManageError(form, exception);
                return;
            }

            if (TabManager.IsCurrentTabInUse(form))
            {
                form.TabIdentity = TabManager.AddNewPage(form, form.TabIdentity);
            }

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

            ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage).Text = content;
        }
Esempio n. 18
0
        public async Task RestartBot()
        {
            await ReplyAsync("**Attempting to restart the bot instance..**");

            MessageUtil.AttemptGuildsMessage(Context, "**NoseBot is current restarting, apologies for the inconvenience. Monitors will be stopped**");
            ProgramUtil.RestartBot();
        }
        internal static void ShowGoogleTranslation(Form1 form)
        {
            XtraTabControl    pagesTabControl = form.pagesTabControl;
            CustomRichTextBox pageTextBox     = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage);

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

            if (!ConfigUtil.GetBoolParameter("TranslationUseSelect"))
            {
                if (WindowManager.ShowTranslateText(form) == DialogResult.Cancel)
                {
                    return;
                }
            }

            String languagePair = ConfigUtil.GetStringParameter("Translation");
            bool   success;
            String result = TranslateText(form, languagePair, out success);

            if (success)
            {
                WindowManager.ShowContent(form, result);
            }
        }
Esempio n. 20
0
        private static void ReplaceAllInAllFiles(Form1 form)
        {
            XtraTabControl       pagesTabControl      = form.pagesTabControl;
            ToolStripStatusLabel toolStripStatusLabel = form.toolStripStatusLabel;

            bool valueFounded = false;

            for (int i = 0; i < pagesTabControl.TabPages.Count; i++)
            {
                pagesTabControl.SelectedTabPage = pagesTabControl.TabPages[i];
                CustomRichTextBox textBox = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage);
                textBox.SelectionStart  = 0;
                textBox.SelectionLength = 0;

                bool tempValueFounded = ReplaceAllInOneFile(form, true);

                if (!valueFounded)
                {
                    valueFounded = tempValueFounded;
                }
            }

            if (valueFounded)
            {
                return;
            }

            String notFoundMessage = LanguageUtil.GetCurrentLanguageString("NotFound", className);

            WindowManager.ShowInfoBox(form, notFoundMessage);
            toolStripStatusLabel.Text = notFoundMessage;
        }
Esempio n. 21
0
        internal static void FontPages(Form1 form)
        {
            XtraTabControl pagesTabControl = form.pagesTabControl;

            DialogResult dialogResult = WindowManager.ShowFontSelect(form);

            if (dialogResult == DialogResult.Cancel)
            {
                return;
            }

            foreach (XtraTabPage tabPage in pagesTabControl.TabPages)
            {
                CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(tabPage);

                pageTextBox.Font      = form.TextFont;
                pageTextBox.ForeColor = form.TextFontColor;
                ProgramUtil.GetCustomLineNumbers(tabPage).Font = form.TextFont;
            }

            TypeConverter tc = TypeDescriptor.GetConverter(typeof(Font));

            ConfigUtil.UpdateParameter("FontInUse", tc.ConvertToString(form.TextFont));
            ConfigUtil.UpdateParameter("FontInUseColorARGB", FontManager.SetARGBString(form.TextFontColor));
        }
Esempio n. 22
0
        private static void ReadInsertMode(Form1 form)
        {
            CustomRichTextBox    pageTextBox = ProgramUtil.GetPageTextBox(form.pagesTabControl.SelectedTabPage);
            ToolStripStatusLabel insertModeToolStripStatusLabel = form.insertModeToolStripStatusLabel;

            insertModeToolStripStatusLabel.Text = pageTextBox.CustomInsertMode;
        }
Esempio n. 23
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;
            }
        }
Esempio n. 24
0
        internal static void TabKeyUp(Form1 form)
        {
            ToolStripStatusLabel rowToolStripStatusLabel1 = form.rowToolStripStatusLabel1;

            CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(form.pagesTabControl.SelectedTabPage);

            rowToolStripStatusLabel1.Text = (TextManager.ReadRTBLineFromCharIndex(form, pageTextBox.GetFirstCharIndexOfCurrentLine()) + 1).ToString();
        }
Esempio n. 25
0
        internal static void GoToLine(Form1 form, int row)
        {
            ToolStripStatusLabel rowToolStripStatusLabel1 = form.rowToolStripStatusLabel1;
            CustomRichTextBox    pageTextBox = ProgramUtil.GetPageTextBox(form.pagesTabControl.SelectedTabPage);

            pageTextBox.Select(TextManager.ReadRTBFirstCharIndexFromLine(form, row - 1), 0);
            rowToolStripStatusLabel1.Text = row.ToString();
        }
Esempio n. 26
0
        internal static void MergeTab(Form1 form, String[] selectedTabNames, bool indicateMerge, String markSeparation)
        {
            XtraTabControl       pagesTabControl      = form.pagesTabControl;
            ToolStripStatusLabel toolStripStatusLabel = form.toolStripStatusLabel;
            ToolStripProgressBar toolStripProgressBar = form.toolStripProgressBar;

            bool linesDisabled   = false;
            int  previousMaximum = toolStripProgressBar.Maximum;
            int  previousStep    = toolStripProgressBar.Step;

            toolStripProgressBar.Maximum = selectedTabNames.Length + 1;
            toolStripProgressBar.Step    = 1;
            toolStripProgressBar.Value   = 0;
            toolStripProgressBar.Visible = true;

            if (indicateMerge)
            {
                ConfigUtil.UpdateParameter("MergeTabSeparation", markSeparation.Replace(ConstantUtil.newLine, "\\r\\n"));
            }

            XtraTabPage       firstTab    = GetXtraTabPageFromName(pagesTabControl, selectedTabNames[0]);
            CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(firstTab);

            for (int i = 1; i < selectedTabNames.Length; i++)
            {
                String textPostMerge;
                if (indicateMerge)
                {
                    textPostMerge = pageTextBox.Text + ConstantUtil.newLine + markSeparation + ConstantUtil.newLine + ProgramUtil.GetPageTextBox(GetXtraTabPageFromName(pagesTabControl, selectedTabNames[i])).Text;
                }
                else
                {
                    textPostMerge = pageTextBox.Text + ConstantUtil.newLine + ProgramUtil.GetPageTextBox(GetXtraTabPageFromName(pagesTabControl, selectedTabNames[i])).Text;
                }

                if (linesDisabled != true)
                {
                    linesDisabled = WindowManager.CheckLineNumbersForTextLenght(form, textPostMerge, true);
                }
                pageTextBox.Text = textPostMerge;

                pagesTabControl.TabPages.Remove(GetXtraTabPageFromName(pagesTabControl, selectedTabNames[i]));
                toolStripProgressBar.PerformStep();
            }

            toolStripStatusLabel.Text = String.Format("{0} {1}", selectedTabNames.Length, LanguageUtil.GetCurrentLanguageString("TabMerged", className));
            toolStripProgressBar.PerformStep();
            toolStripProgressBar.Visible = false;
            toolStripProgressBar.Maximum = previousMaximum;
            toolStripProgressBar.Step    = previousStep;

            pagesTabControl.SelectedTabPage = firstTab;

            if (linesDisabled)
            {
                WindowManager.ShowInfoBox(form, LanguageUtil.GetCurrentLanguageString("LineNumbersDisabled", className));
            }
        }
Esempio n. 27
0
        internal static void Normalize(Form1 form)
        {
            XtraTabControl    pagesTabControl = form.pagesTabControl;
            CustomRichTextBox pageTextBox     = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage);

            pageTextBox.SelectAll();
            pageTextBox.SelectedText = FormatManager.EncodeHTMLTagsForXMLValidation(pageTextBox.Text);
            TextManager.RefreshUndoRedoExternal(form);
        }
Esempio n. 28
0
        internal static void CopyFileName(Form1 form)
        {
            String fileName = Path.GetFileName(ProgramUtil.GetFilenameTabPage(form.pagesTabControl.SelectedTabPage));

            if (!String.IsNullOrEmpty(fileName))
            {
                Clipboard.SetDataObject(fileName, true, ConstantUtil.clipboardRetryTimes, ConstantUtil.clipboardRetryDelay);
            }
        }
Esempio n. 29
0
        static void Main()
        {
            ClientInfo.TypeOfProgram = typeof(Program);

            if (StringUtil.IsDevelopMode() == false)
            {
                ClientInfo.PrepareCatchException();
            }

            // http://stackoverflow.com/questions/184084/how-to-force-c-sharp-net-app-to-run-only-one-instance-in-windows

            context = ExecutionContext.Capture();
            mutex   = new Mutex(true,
                                "{CF1B7B4A-C7ED-4DB8-B5CC-59A067880F92}",
                                out bool createdNew);
            try
            {
                List <string> args = StringUtil.GetCommandLineArgs();

                if (createdNew ||
                    args.IndexOf("newinstance") != -1)
                {
                    ClientInfo.AddShortcutToStartupGroup("dp2-RFID中心");

                    ProgramUtil.SetDpiAwareness();

                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    _mainForm = new MainForm();
                    Application.Run(_mainForm);
                }
                else
                {
                    Process current = Process.GetCurrentProcess();
                    foreach (Process process in Process.GetProcessesByName(current.ProcessName))
                    {
                        if (process.Id != current.Id)
                        {
                            API.SetForegroundWindow(process.MainWindowHandle);
                            if (API.IsIconic(process.MainWindowHandle))
                            {
                                // API.ShowWindow(process.MainWindowHandle, API.SW_SHOW);
                                API.ShowWindow(process.MainWindowHandle, API.SW_RESTORE);
                            }
                        }
                    }
                }
            }
            finally
            {
                if (mutex != null)
                {
                    mutex.Close();
                }
            }
        }
Esempio n. 30
0
        private static bool ReplaceAllInOneFile(Form1 form, bool searchInAllFiles)
        {
            CustomRichTextBox    textBox                       = ProgramUtil.GetPageTextBox(form.pagesTabControl.SelectedTabPage);
            TextBox              searchTextBox                 = form.searchPanel.searchTextBox;
            TextBox              replaceTextBox                = form.searchPanel.replaceTextBox;
            ToolStripStatusLabel toolStripStatusLabel          = form.toolStripStatusLabel;
            CheckBox             caseCheckBox                  = form.searchPanel.caseCheckBox;
            CheckBox             useRegularExpressionsCheckBox = form.searchPanel.regularExpressionsCheckBox;

            if (String.IsNullOrEmpty(searchTextBox.Text))
            {
                return(false);
            }

            FileListManager.SetNewSearchHistory(form, searchTextBox.Text);

            String textWhereToSearch;
            String textToSearch;

            GetTextCaseNormalization(form, out textWhereToSearch, out textToSearch);

            int positionSearchedText;
            int selectionLength;

            SearchReplaceUtil.FindStringPositionAndLength(textWhereToSearch, textToSearch, SearchReplaceUtil.SearchType.First, useRegularExpressionsCheckBox.Checked, textBox, out positionSearchedText, out selectionLength);

            if (positionSearchedText != -1)
            {
                int counter = SearchReplaceUtil.SearchCountOccurency(form, false, true);
                textBox.SelectAll();

                if (caseCheckBox.Checked)
                {
                    textBox.SelectedText = Replace(useRegularExpressionsCheckBox.Checked, textBox.Text, GetTextNewLineNormalization(searchTextBox.Text), GetTextNewLineNormalization(replaceTextBox.Text), StringComparison.Ordinal);
                }
                else
                {
                    textBox.SelectedText = Replace(useRegularExpressionsCheckBox.Checked, textBox.Text, GetTextNewLineNormalization(searchTextBox.Text), GetTextNewLineNormalization(replaceTextBox.Text), StringComparison.OrdinalIgnoreCase);
                }

                TextManager.RefreshUndoRedoExternal(form);
                textBox.Select(0, 0);

                toolStripStatusLabel.Text = String.Format("{0} {1}", counter, LanguageUtil.GetCurrentLanguageString("Replaced", className, counter));

                return(true);
            }
            if (!searchInAllFiles)
            {
                String notFoundMessage = LanguageUtil.GetCurrentLanguageString("NotFound", className);
                WindowManager.ShowInfoBox(form, notFoundMessage);
                toolStripStatusLabel.Text = notFoundMessage;
            }

            return(false);
        }