internal static WebClient InitWebClientProxy() { bool enableProxy = ConfigUtil.GetBoolParameter("ProxyEnabled"); List <PasswordObject> passwordList = PasswordUtil.GetStringParameters(new[] { "ProxyUsername", "ProxyPassword", "ProxyDomain" }); String proxyUsername = (passwordList[0]).value; String proxyPassword = CodingUtil.DecodeByte((passwordList[1]).value); String proxyDomain = (passwordList[2]).value; WebClient webClient = new WebClient { CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore) }; if (!enableProxy) { return(webClient); } if (!String.IsNullOrEmpty(proxyDomain)) { webClient.Proxy.Credentials = new NetworkCredential(proxyUsername, proxyPassword, proxyDomain); } else { webClient.Proxy.Credentials = new NetworkCredential(proxyUsername, proxyPassword); } return(webClient); }
internal static String ReadToEndWithEncoding(String absoluteFilePath, out Encoding fileEncoding) { fileEncoding = EncodingUtil.GetFileEncoding(absoluteFilePath); StreamReader textFile = null; String fileContent; try { textFile = new StreamReader(absoluteFilePath, fileEncoding); fileContent = textFile.ReadToEnd(); } finally { if (textFile != null) { textFile.Close(); } } if (ConfigUtil.GetBoolParameter("IgnoreNullChar")) { fileContent = fileContent.Replace("\0", String.Empty); } return(fileContent); }
internal static bool AreLinesTooMuchForPasteWithRowLines(String text) { if (!ConfigUtil.GetBoolParameter("CheckLineNumber")) { return(false); } String[] split = text.Split(new[] { ConstantUtil.newLine }, StringSplitOptions.None); return(split.Length > ConfigUtil.GetIntParameter("CheckLineNumberMax")); }
internal static bool AreLinesTooMuchForPasteWithRowLines_External(String text) { if (!ConfigUtil.GetBoolParameter("CheckLineNumber")) { return(false); } text = text.Replace(Environment.NewLine, ConstantUtil.newLine); String[] split = text.Split(new[] { ConstantUtil.newLine, "\r" }, StringSplitOptions.None); return(split.Length > ConfigUtil.GetIntParameter("CheckLineNumberMax")); }
internal static String GetInitialFolder(Form1 form) { XtraTabControl pagesTabControl = form.pagesTabControl; String filename = ProgramUtil.GetFilenameTabPage(pagesTabControl.SelectedTabPage); if (!String.IsNullOrEmpty(filename) && ConfigUtil.GetBoolParameter("OverrideFolderWithActiveFile")) { String path = Path.GetDirectoryName(filename); if (!String.IsNullOrEmpty(path) && Directory.Exists(path)) { return(path); } } return(ConfigUtil.GetStringParameter(ConfigUtil.GetIntParameter("SettingFolder") == 1 ? "LastUserFolder" : "SpecificFolder")); }
internal static bool IsEncodingDefaultEnabled() { return(ConfigUtil.GetBoolParameter("DefaultEncoding")); }
internal static void SetWindowsJumpList(Form1 form) { #if Debug return; #endif try { switch (GetOSInfo()) { case OS.Seven: { if (!ConfigUtil.GetBoolParameter("RecreateJumpList") || !ConfigUtil.GetBoolParameter("ActiveJumpList")) { return; } JumpList list = JumpList.CreateJumpListForIndividualWindow(ConstantUtil.jumpListApplicationId, form.Handle); JumpListSeparator separator = null; JumpListLink listLink = null; try { separator = new JumpListSeparator(); listLink = new JumpListLink(Assembly.GetEntryAssembly().Location, LanguageUtil.GetCurrentLanguageString("New", className)); listLink.Arguments = ConstantUtil.cmdLineJLNew; listLink.IconReference = new IconReference(String.Format(@"{0}\Icons\JL\NewTab.ico", ConstantUtil.ApplicationExecutionPath()), 0); listLink.WorkingDirectory = ConstantUtil.ApplicationExecutionPath(); list.AddUserTasks(listLink); listLink = new JumpListLink(Assembly.GetEntryAssembly().Location, LanguageUtil.GetCurrentLanguageString("NewAndPaste", className)); listLink.Arguments = ConstantUtil.cmdLineJLNewAndPaste; listLink.WorkingDirectory = ConstantUtil.ApplicationExecutionPath(); list.AddUserTasks(listLink); listLink = new JumpListLink(Assembly.GetEntryAssembly().Location, LanguageUtil.GetCurrentLanguageString("OpenFile", className)); listLink.Arguments = ConstantUtil.cmdLineJLOpenFile; listLink.IconReference = new IconReference(String.Format(@"{0}\Icons\JL\OpenFile.ico", ConstantUtil.ApplicationExecutionPath()), 0); listLink.WorkingDirectory = ConstantUtil.ApplicationExecutionPath(); list.AddUserTasks(listLink); listLink = new JumpListLink(Assembly.GetEntryAssembly().Location, LanguageUtil.GetCurrentLanguageString("OpenSession", className)); listLink.Arguments = ConstantUtil.cmdLineJLOpenSession; listLink.IconReference = new IconReference(String.Format(@"{0}\Icons\JL\OpenSession.ico", ConstantUtil.ApplicationExecutionPath()), 0); listLink.WorkingDirectory = ConstantUtil.ApplicationExecutionPath(); list.AddUserTasks(listLink); listLink = new JumpListLink(Assembly.GetEntryAssembly().Location, LanguageUtil.GetCurrentLanguageString("SearchInFiles", className)); listLink.Arguments = ConstantUtil.cmdLineJLSearchInFiles; listLink.IconReference = new IconReference(String.Format(@"{0}\Icons\JL\SearchInFiles.ico", ConstantUtil.ApplicationExecutionPath()), 0); listLink.WorkingDirectory = ConstantUtil.ApplicationExecutionPath(); list.AddUserTasks(listLink); list.AddUserTasks(separator); listLink = new JumpListLink(Assembly.GetEntryAssembly().Location, LanguageUtil.GetCurrentLanguageString("CheckNewVersion", className)); listLink.Arguments = ConstantUtil.cmdLineJLCheckNewVersion; listLink.IconReference = new IconReference(String.Format(@"{0}\Icons\JL\CheckNewVersion.ico", ConstantUtil.ApplicationExecutionPath()), 0); listLink.WorkingDirectory = ConstantUtil.ApplicationExecutionPath(); list.AddUserTasks(listLink); #if Release listLink = new JumpListLink(ConstantUtil.dtPadURL, LanguageUtil.GetCurrentLanguageString("WebSite", className)); listLink.IconReference = new IconReference(String.Format(@"{0}\Icons\JL\WebSite.ico", ConstantUtil.ApplicationExecutionPath()), 0); list.AddUserTasks(listLink); #endif list.Refresh(); } finally { if (separator != null) { separator.Dispose(); } if (listLink != null) { listLink.Dispose(); } } ConfigUtil.UpdateParameter("RecreateJumpList", false.ToString()); } break; } } catch (Exception exception) { WindowManager.ShowErrorBox(form, exception.Message, exception); } }
internal static int SearchCountOccurences(String text, String stringToSearch, Form1 form = null, CustomRichTextBox textBox = null, bool forceDisableHighlight = false, bool useRegularExpressions = false) { int counter = 0; bool highlights = false; if (!forceDisableHighlight) { highlights = ConfigUtil.GetBoolParameter("SearchHighlightsResults"); } RichTextBox tempRichTextBox = new RichTextBox(); //Temporary RichTextBox to avoid too much undo/redo into buffer try { if (textBox != null) //Research inside a textbox (usually the pageTextBox) { tempRichTextBox.Rtf = textBox.Rtf; tempRichTextBox.SelectAll(); tempRichTextBox.SelectionBackColor = textBox.BackColor; int positionSearchedText; int selectionLength; SearchReplaceUtil.FindStringPositionAndLength(text, stringToSearch, SearchReplaceUtil.SearchType.First, useRegularExpressions, tempRichTextBox, out positionSearchedText, out selectionLength); while (positionSearchedText != -1) { tempRichTextBox.Select(positionSearchedText, selectionLength); if (highlights) { tempRichTextBox.SelectionBackColor = (textBox.BackColor == Color.Yellow) ? Color.Red : Color.Yellow; } SearchReplaceUtil.FindStringPositionAndLength(text, stringToSearch, SearchReplaceUtil.SearchType.Next, useRegularExpressions, tempRichTextBox, out positionSearchedText, out selectionLength); counter++; } } else //Search inside a string { int i = 0; while ((i = text.IndexOf(stringToSearch, i)) != -1) { i += stringToSearch.Length; counter++; } } if (textBox != null && highlights) { textBox.IsHighlighting = true; RichTextBoxUtil.ReplaceRTFContent(textBox, tempRichTextBox); TextManager.RefreshUndoRedoExternal(form); } } finally { tempRichTextBox.Dispose(); } return(counter); }