private void SavePaper() { //从注册表寻找pmp文件的位置 string keyPath = @"Software\Autodesk\AutoCAD\R22.0\ACAD-1001:804"; string keyName = "RoamableRootFolder"; object FindPC3_Path = RegistryHelpers.GetRegistryValue(keyPath, keyName); string pmp_path = (string)FindPC3_Path + "Plotters\\PMP Files\\"; PrinterSetting paper = new PrinterSetting(); DB.BLL.PAPER_SIZE papers = new DB.BLL.PAPER_SIZE(); DataSet papers_list = papers.GetList("1=1"); DataTable row = papers_list.Tables[0]; foreach (DataGridViewRow r in dgv_PaperSizeList.Rows) { paper.PaperX = Convert.ToDouble(r.Cells[2].Value) * 10; paper.PaperY = Convert.ToDouble(r.Cells[3].Value) * 10; paper.userdef_name = (string)r.Cells[1].Value; //三个打印机,添加三次 paper.AddPrinter(pmp_path + "DWG To PDF.pmp"); paper.AddPrinter(pmp_path + "PublishToWeb JPG.pmp"); paper.AddPrinter(pmp_path + "PublishToWeb PNG.pmp"); } }
/// <summary> /// 附着pmp路径到pc3内 /// </summary> /// <param name="plotDevice">当前调用的打印机</param> /// <param name="dwgtopdfpmp">pmp路径</param> public void ChangUserDefinedModel(string plotDevice, string dwgtopdfpmp) { //获取这个打印机的完整路径 string keyPath = @"Software\Autodesk\AutoCAD\R22.0\ACAD-1001:804"; string keyName = "RoamableRootFolder"; object FindPC3_Path = RegistryHelpers.GetRegistryValue(keyPath, keyName); string printerConfigDir = FindPC3_Path + "Plotters\\" + plotDevice; var ns = new string[] { printerConfigDir, dwgtopdfpmp }; foreach (var path in ns) { if (!File.Exists(path)) { continue; } var PdfConfig = new PlotterConfiguration(path); //解压了打印机信息之后,遍历打印机节点 foreach (var nodeA in PdfConfig) { if (nodeA.NodeName == "meta") { nodeA.ValueChang("user_defined_model_pathname" + "_str", dwgtopdfpmp); break; } } PdfConfig.Saves(); } }
private void cbShellContextMenu_CheckedChanged(object sender, EventArgs e) { if (loaded) { RegistryHelpers.SetShellContextMenu(cbShellContextMenu.Checked); } }
private void button_DeletPaper_Click(object sender, EventArgs e) { //从注册表寻找pmp文件位置 string keyPath = @"Software\Autodesk\AutoCAD\R22.0\ACAD-1001:804"; string keyName = "RoamableRootFolder"; object FindPC3_Path = RegistryHelpers.GetRegistryValue(keyPath, keyName); string pmp_path = (string)FindPC3_Path + "Plotters\\PMP Files\\"; //从数据库删除 DB.BLL.PAPER_SIZE bll = new DB.BLL.PAPER_SIZE(); DataGridViewSelectedRowCollection rows = dgv_PaperSizeList.SelectedRows; foreach(DataGridViewRow r in rows) { string PAPER_NAME = (string)r.Cells[1].Value; bll.Delete(PAPER_NAME); //删除纸张 PrinterTool.RemovePrinters(pmp_path + "DWG To PDF.pmp", new string[] { PAPER_NAME }); PrinterTool.RemovePrinters(pmp_path + "PublishToWeb JPG.pmp", new string[] { PAPER_NAME }); PrinterTool.RemovePrinters(pmp_path + "PublishToWeb PNG.pmp", new string[] { PAPER_NAME }); } Init_dgv_PaperSizeList(); }
public static string GetMimeType(string fileName) { if (!string.IsNullOrEmpty(fileName)) { string ext = Path.GetExtension(fileName).ToLowerInvariant(); if (!string.IsNullOrEmpty(ext)) { string mimeType = MimeTypes.GetMimeType(ext); if (!string.IsNullOrEmpty(mimeType)) { return(mimeType); } mimeType = RegistryHelpers.GetRegistryValue(ext, "Content Type", RegistryHive.ClassesRoot); if (!string.IsNullOrEmpty(mimeType)) { return(mimeType); } } } return(MimeTypes.DefaultMimeType); }
private static bool GetSystemOptionBoolean(string name) { object value = RegistryHelpers.GetValue(RegistryPath, name, RegistryHive.LocalMachine); if (value != null) { try { return(Convert.ToBoolean(value)); } catch { } } value = RegistryHelpers.GetValue(RegistryPath, name, RegistryHive.CurrentUser); if (value != null) { try { return(Convert.ToBoolean(value)); } catch { } } return(false); }
public string GetFFmpegCommands() { string commands; if (IsRecording && !string.IsNullOrEmpty(FFmpeg.VideoSource) && FFmpeg.VideoSource.Equals("screen-capture-recorder", StringComparison.InvariantCultureIgnoreCase)) { // https://github.com/rdp/screen-capture-recorder-to-video-windows-free string registryPath = "Software\\screen-capture-recorder"; RegistryHelpers.CreateRegistry(registryPath, "start_x", CaptureArea.X); RegistryHelpers.CreateRegistry(registryPath, "start_y", CaptureArea.Y); RegistryHelpers.CreateRegistry(registryPath, "capture_width", CaptureArea.Width); RegistryHelpers.CreateRegistry(registryPath, "capture_height", CaptureArea.Height); RegistryHelpers.CreateRegistry(registryPath, "default_max_fps", 60); RegistryHelpers.CreateRegistry(registryPath, "capture_mouse_default_1", DrawCursor ? 1 : 0); } if (!IsLossless && FFmpeg.UseCustomCommands && !string.IsNullOrEmpty(FFmpeg.CustomCommands)) { commands = FFmpeg.CustomCommands. Replace("$fps$", FPS.ToString(), StringComparison.InvariantCultureIgnoreCase). Replace("$area_x$", CaptureArea.X.ToString(), StringComparison.InvariantCultureIgnoreCase). Replace("$area_y$", CaptureArea.Y.ToString(), StringComparison.InvariantCultureIgnoreCase). Replace("$area_width$", CaptureArea.Width.ToString(), StringComparison.InvariantCultureIgnoreCase). Replace("$area_height$", CaptureArea.Height.ToString(), StringComparison.InvariantCultureIgnoreCase). Replace("$cursor$", DrawCursor ? "1" : "0", StringComparison.InvariantCultureIgnoreCase). Replace("$duration$", Duration.ToString("0.0", CultureInfo.InvariantCulture), StringComparison.InvariantCultureIgnoreCase). Replace("$output$", Path.ChangeExtension(OutputPath, FFmpeg.Extension), StringComparison.InvariantCultureIgnoreCase); } else { commands = GetFFmpegArgs(); } return(commands.Trim()); }
public string GetFFmpegCommands() { if (!string.IsNullOrEmpty(FFmpeg.VideoSource) && FFmpeg.VideoSource.Equals("screen-capture-recorder", StringComparison.InvariantCultureIgnoreCase)) { // https://github.com/rdp/screen-capture-recorder-to-video-windows-free string registryPath = "Software\\screen-capture-recorder"; RegistryHelpers.CreateRegistry(registryPath, "start_x", CaptureArea.X); RegistryHelpers.CreateRegistry(registryPath, "start_y", CaptureArea.Y); RegistryHelpers.CreateRegistry(registryPath, "capture_width", CaptureArea.Width); RegistryHelpers.CreateRegistry(registryPath, "capture_height", CaptureArea.Height); RegistryHelpers.CreateRegistry(registryPath, "default_max_fps", ScreenRecordFPS); RegistryHelpers.CreateRegistry(registryPath, "capture_mouse_default_1", DrawCursor ? 1 : 0); } if (FFmpeg.UseCustomCommands && !string.IsNullOrEmpty(FFmpeg.CustomCommands)) { string commands = FFmpeg.CustomCommands.Trim(); // Replace output path if (commands[commands.Length - 1] == '"') { int index = commands.LastIndexOf('"', commands.Length - 2); if (index >= 0) { commands = commands.Remove(index); commands += string.Format("\"{0}\"", Path.ChangeExtension(OutputPath, FFmpeg.Extension)); } } return(commands); } return(GetFFmpegArgs()); }
/// <summary> /// 获取自动搜索路径 /// </summary> /// <returns>GMS2 安装路径</returns> private static void GetAutoSearchPath() { try { Log.WriteLog(Log.LogLevel.信息, "从注册表获取GameMaker Studio 2安装路径"); installedDictionary.Clear(); Log.WriteLog(Log.LogLevel.信息, "搜索官网下载版安装路径"); RegistryKey standaloneKey = RegistryHelpers .GetRegistryKey(RegistryHive.CurrentUser, @"Software\GameMakerStudio2"); if (standaloneKey != null) { // 官网下载板 installedDictionary.Add("官网下载版", standaloneKey.GetValue("Install_Dir").ToString()); standaloneKey.Close(); } Log.WriteLog(Log.LogLevel.信息, "搜索 steam Desktop 版安装路径"); RegistryKey steamDesktopKey = RegistryHelpers .GetRegistryKey(RegistryHive.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 585410"); if (steamDesktopKey != null) { // Steam Desktop 板 installedDictionary.Add("Steam Desktop 版", steamDesktopKey.GetValue("InstallLocation").ToString()); steamDesktopKey.Close(); } Log.WriteLog(Log.LogLevel.信息, "搜索 steam Web 版安装路径"); RegistryKey steamWebKey = RegistryHelpers .GetRegistryKey(RegistryHive.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 585600"); if (steamWebKey != null) { // Steam Web 版 installedDictionary.Add("Steam Web 版", steamWebKey.GetValue("InstallLocation").ToString()); steamWebKey.Close(); } Log.WriteLog(Log.LogLevel.信息, "搜索 steam UWP 版安装路径"); RegistryKey steamUwpKey = RegistryHelpers .GetRegistryKey(RegistryHive.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 585610"); if (steamUwpKey != null) { // Steam UWP 版 installedDictionary.Add("Steam UWP 版", steamUwpKey.GetValue("InstallLocation").ToString()); steamUwpKey.Close(); } Log.WriteLog(Log.LogLevel.信息, "搜索 steam Mobile 版安装路径"); RegistryKey steamMobileKey = RegistryHelpers .GetRegistryKey(RegistryHive.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 585620"); if (steamMobileKey != null) { // Steam Mobile 版 installedDictionary.Add("Steam Mobile 版", steamMobileKey.GetValue("InstallLocation").ToString()); steamMobileKey.Close(); } Log.WriteLog(Log.LogLevel.信息, "搜索安装路径完毕"); } catch { Log.WriteLog(Log.LogLevel.警告, "搜索安装路径失败"); throw new Exception("搜索安装路径失败"); } }
private void LoadSettings() { Text = Program.Title + " - Settings"; Icon = Resources.ShareX_Icon; // General cbShowTray.Checked = Program.Settings.ShowTray; cbStartWithWindows.Checked = ShortcutHelpers.CheckShortcut(Environment.SpecialFolder.Startup); //RegistryHelper.CheckStartWithWindows(); cbSendToMenu.Checked = ShortcutHelpers.CheckShortcut(Environment.SpecialFolder.SendTo); cbShellContextMenu.Checked = RegistryHelpers.CheckShellContextMenu(); cbCheckUpdates.Checked = Program.Settings.AutoCheckUpdate; cbTrayIconProgressEnabled.Checked = Program.Settings.TrayIconProgressEnabled; cbTaskbarProgressEnabled.Enabled = TaskbarManager.IsPlatformSupported; cbTaskbarProgressEnabled.Checked = Program.Settings.TaskbarProgressEnabled; // Paths cbUseCustomUploadersConfigPath.Checked = Program.Settings.UseCustomUploadersConfigPath; txtCustomUploadersConfigPath.Text = Program.Settings.CustomUploadersConfigPath; cbUseCustomHistoryPath.Checked = Program.Settings.UseCustomHistoryPath; txtCustomHistoryPath.Text = Program.Settings.CustomHistoryPath; cbUseCustomScreenshotsPath.Checked = Program.Settings.UseCustomScreenshotsPath; txtCustomScreenshotsPath.Text = Program.Settings.CustomScreenshotsPath; txtSaveImageSubFolderPattern.Text = Program.Settings.SaveImageSubFolderPattern; cmsSaveImageSubFolderPattern = NameParser.CreateCodesMenu(txtSaveImageSubFolderPattern, ReplacementVariables.n); // Proxy cbProxyMethod.Items.AddRange(Enum.GetNames(typeof(ProxyMethod))); cbProxyType.Items.AddRange(Helpers.GetEnumDescriptions <ProxyType>()); cbProxyMethod.SelectedIndex = (int)Program.Settings.ProxySettings.ProxyMethod; txtProxyUsername.Text = Program.Settings.ProxySettings.Username; txtProxyPassword.Text = Program.Settings.ProxySettings.Password; txtProxyHost.Text = Program.Settings.ProxySettings.Host ?? string.Empty; nudProxyPort.Value = Program.Settings.ProxySettings.Port; cbProxyType.SelectedIndex = (int)Program.Settings.ProxySettings.ProxyType; UpdateProxyControls(); // Upload cbIfUploadFailRetryOnce.Checked = Program.Settings.IfUploadFailRetryOnce; nudUploadLimit.Value = Program.Settings.UploadLimit; for (int i = 0; i < MaxBufferSizePower; i++) { string size = ((long)(Math.Pow(2, i) * 1024)).ToSizeString(Program.Settings.BinaryUnits, 0); cbBufferSize.Items.Add(size); } cbBufferSize.SelectedIndex = Program.Settings.BufferSizePower.Between(0, MaxBufferSizePower); foreach (ClipboardFormat cf in Program.Settings.ClipboardContentFormats) { AddClipboardFormat(cf); } // Print cbDontShowPrintSettingDialog.Checked = Program.Settings.DontShowPrintSettingsDialog; // Advanced pgSettings.SelectedObject = Program.Settings; }
/// <summary> /// Gets an enumerable of the available sub keys full paths /// </summary> /// <param name="registryKey">The registry key</param> /// <returns>The enumerable of the available sub keys full paths</returns> public static IEnumerable <string> GetSubKeyFullPaths(this RegistryKey registryKey) { // Get the sub key names var names = registryKey.GetSubKeyNames(); // Combines their names with the current key path return(names.Select(x => RegistryHelpers.CombinePaths(registryKey.Name, x))); }
private static void RegisterCustomUploaderExtension() { RegistryHelpers.CreateRegistry(ShellCustomUploaderExtensionPath, ShellCustomUploaderExtensionValue); RegistryHelpers.CreateRegistry(ShellCustomUploaderAssociatePath, ShellCustomUploaderAssociateValue); RegistryHelpers.CreateRegistry(ShellCustomUploaderIconPath, ShellCustomUploaderIconValue); RegistryHelpers.CreateRegistry(ShellCustomUploaderCommandPath, ShellCustomUploaderCommandValue); NativeMethods.SHChangeNotify(HChangeNotifyEventID.SHCNE_ASSOCCHANGED, HChangeNotifyFlags.SHCNF_FLUSH, IntPtr.Zero, IntPtr.Zero); }
private static void UnregisterChromeExtensionSupport() { if (File.Exists(Program.ChromeHostManifestFilePath)) { File.Delete(Program.ChromeHostManifestFilePath); } RegistryHelpers.RemoveRegistry(ChromeNativeMessagingHosts); }
private static void UnregisterFirefoxAddonSupport() { if (File.Exists(Program.FirefoxHostManifestFilePath)) { File.Delete(Program.FirefoxHostManifestFilePath); } RegistryHelpers.RemoveRegistry(FirefoxNativeMessagingHosts); }
/// <summary> /// Will stream a file to the client. /// </summary> private void SendFile(Guid requestId, HttpListenerContext context, string file) { HttpListenerResponse response = context.Response; response.SendChunked = true; response.StatusCode = (int)HttpStatusCode.OK; response.ContentType = RegistryHelpers.GetContentType(file); using (Stream local = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) { // response.ContentLength64 = local.Length; Stream client = response.OutputStream; byte[] data = new byte[_chunkSize]; int bytesRead = 0; DateTime chunkStart; DateTime start = DateTime.Now; while (local.Position < local.Length) { chunkStart = DateTime.Now; bytesRead = local.Read(data, 0, _chunkSize); try { client.Write(data, 0, bytesRead); client.Flush(); // balance of time to wait ThrottleByteRate(chunkStart); } catch (HttpListenerException hle) { TraceMessage(requestId, "Error sending chunk {0}-{1}/{2}. {3}", local.Position - bytesRead, local.Position, local.Length, hle.Message); return; // will ab end } } response.Close(); double elapsed = DateTime.Now.Subtract(start).TotalMilliseconds; TraceMessage( requestId, "Request of {1} bytes completed in {0}ms at {2} Kbps.", elapsed, local.Length, (float)local.Length * 8 / 1024 // bytes * (bits per byte) / Kilo / (elapsed / 1000)); // divided by milliseconds / (milliseconds per second) } }
private static void RegisterEditShellContextMenuButton() { RegistryHelpers.CreateRegistry(ShellExtEditMenuJpeg, ShellExtEditDesc); RegistryHelpers.CreateRegistry(ShellExtEditMenuJpeg, "Icon", ShellExtEditIcon); RegistryHelpers.CreateRegistry(ShellExtEditMenuJpegCmd, ShellExtEditPath); RegistryHelpers.CreateRegistry(ShellExtEditMenuPng, ShellExtEditDesc); RegistryHelpers.CreateRegistry(ShellExtEditMenuPng, "Icon", ShellExtEditIcon); RegistryHelpers.CreateRegistry(ShellExtEditMenuPngCmd, ShellExtEditPath); }
private static void RegisterShellContextMenuButton() { RegistryHelpers.CreateRegistry(ShellExtMenuFiles, ShellExtDesc); RegistryHelpers.CreateRegistry(ShellExtMenuFiles, "Icon", ShellExtIcon); RegistryHelpers.CreateRegistry(ShellExtMenuFilesCmd, ShellExtPath); RegistryHelpers.CreateRegistry(ShellExtMenuDirectory, ShellExtDesc); RegistryHelpers.CreateRegistry(ShellExtMenuDirectory, "Icon", ShellExtIcon); RegistryHelpers.CreateRegistry(ShellExtMenuDirectoryCmd, ShellExtPath); }
public bool IsCommunityKeyActivated() { bool foundKey = RegistryHelpers.GetSetting("IsCommunity", null) != null; if (foundKey) { MainWindow.ProfilDetailEdition.Text = Constants.COMMUNITY_EDITION_FRIENDLY_NAME; } return(foundKey); }
private static string GetSystemOptionString(string name) { string value = RegistryHelpers.GetValueString(RegistryPath, name, RegistryHive.LocalMachine); if (value == null) { value = RegistryHelpers.GetValueString(RegistryPath, name, RegistryHive.CurrentUser); } return(value); }
/// <summary> /// Creates a new <see cref="RegistryValue"/> from a key path, the value name and view used to get the key /// </summary> /// <param name="keyPath">The full path of the key</param> /// <param name="valueName">The name of the value</param> /// <param name="view">The view used to get the key</param> public RegistryValue(string keyPath, string valueName, RegistryView view) { using (var key = RegistryHelpers.GetKeyFromFullPath(keyPath, view)) { Value = key.GetValue(valueName); ValueKind = key.GetValueKind(valueName); Name = valueName; KeyPath = key.Name; KeyView = key.View; } }
private static void AddExternalProgramFromRegistry(TaskSettings taskSettings, string name, string filename) { if (!taskSettings.ExternalPrograms.Exists(x => x.Name == name)) { ExternalProgram externalProgram = RegistryHelpers.FindProgram(name, filename); if (externalProgram != null) { taskSettings.ExternalPrograms.Add(externalProgram); } } }
private static void AddExternalProgramFromRegistry(TaskSettings taskSettings, string name, string fileName) { if (!taskSettings.ExternalPrograms.Exists(x => x.Name == name)) { string filePath = RegistryHelpers.SearchProgramPath(fileName); if (!string.IsNullOrEmpty(filePath)) { ExternalProgram externalProgram = new ExternalProgram(name, filePath); taskSettings.ExternalPrograms.Add(externalProgram); } } }
public static void SetLaunchAtLogin(bool launch) { var key = RegistryHelpers.GetRegistryKey(RegKeyPath, true); if (launch) { key?.SetValue(AppName, ExecutablePath); } else if (key?.GetValue(AppName) != null) { key.DeleteValue(AppName); } }
private void SetKeyGuidAsCookie() { Guid keyGuid; if (Guid.TryParse(RegistryHelpers.GetSetting("Feature_" + ActivatedFeatureID, null), out keyGuid)) { Browser.CookieStorage.SetSessionCookie(CSHTML5_COOKIES_URL, LICENSE_KEY_GUID_COOKIE, keyGuid.ToString(), "localhost", "/", true, true); foreach (var cookie in Browser.CookieStorage.GetAllCookies(CSHTML5_COOKIES_URL)) { Debug.WriteLine(cookie); } } }
public static bool CheckShellContextMenuButton() { try { return(RegistryHelpers.CheckRegistry(ShellExtMenuFilesCmd, null, ShellExtPath) && RegistryHelpers.CheckRegistry(ShellExtMenuDirectoryCmd, null, ShellExtPath)); } catch (Exception e) { DebugHelper.WriteException(e); } return(false); }
public static bool CheckFirefoxAddonSupport() { try { return(RegistryHelpers.CheckRegistry(FirefoxNativeMessagingHosts, null, Program.FirefoxHostManifestFilePath) && File.Exists(Program.FirefoxHostManifestFilePath)); } catch (Exception e) { DebugHelper.WriteException(e); } return(false); }
public static void ClearCookies(WPFBrowserView wpfBrowserView, string registryName = null) { if (!string.IsNullOrEmpty(registryName)) { RegistryHelpers.DeleteSetting(registryName + "_" + MICROSOFT_COOKIES_URL); } if (wpfBrowserView.Browser != null && wpfBrowserView.Browser.CookieStorage != null) { int numberOfDeletedCookies = wpfBrowserView.Browser.CookieStorage.DeleteAll(); wpfBrowserView.Browser.CookieStorage.Save(); MessageBox.Show(numberOfDeletedCookies.ToString() + " cookies have been deleted."); } }
public static bool CheckEditShellContextMenuButton() { try { return(RegistryHelpers.CheckRegistry(ShellExtEditImageCmd, null, ShellExtEditPath)); } catch (Exception e) { DebugHelper.WriteException(e); } return(false); }
public static bool CheckCustomUploaderExtension() { try { return(RegistryHelpers.CheckRegistry(ShellCustomUploaderExtensionPath, null, ShellCustomUploaderExtensionValue) && RegistryHelpers.CheckRegistry(ShellCustomUploaderCommandPath, null, ShellCustomUploaderCommandValue)); } catch (Exception e) { DebugHelper.WriteException(e); } return(false); }
public static bool CheckImageEffectExtension() { try { return(RegistryHelpers.CheckRegistry(ShellImageEffectExtensionPath, null, ShellImageEffectExtensionValue) && RegistryHelpers.CheckRegistry(ShellImageEffectCommandPath, null, ShellImageEffectCommandValue)); } catch (Exception e) { DebugHelper.WriteException(e); } return(false); }