/// <summary> /// 如果存在 message,则设置为第一个 message 的 text。否则返回 null。 /// </summary> /// <param name="imageArchive"></param> /// <returns></returns> public static string GetFirstMessageIfExist(this ImageArchive imageArchive) { Message[] messages = imageArchive.Messages; return(messages == null ? null : messages.Select(temp => temp.Text).FirstOrDefault(temp => string.IsNullOrEmpty(temp) == false)); }
public async void Init() { // 确保至少能正确执行一次,能正常设置背景。 while (true) { try { ImageArchiveCollection imageArchiveCollection = await _bingWallpaperService.GetWallpaperInformationsAsync(0, 1, Settings.Area); if (imageArchiveCollection != null) { ImageArchive imageArchive = imageArchiveCollection.Images.FirstOrDefault(); if (imageArchive != null) { // 设置背景。 BackgroundUrl = imageArchive.GetUrlWithSize(WallpaperSize._1920x1080); // 立即更新主磁贴。 TileHelper.UpdateTile(imageArchive); } } break; } catch (HttpRequestException ex) { if (_hadNotifyNetworkError == false) { _hadNotifyNetworkError = true; SideToastHelper.Error(ResourcesHelper.NetworkError); } } } }
public static string GetUrlWithSize(this ImageArchive imageArchive, WallpaperSize size) { if (imageArchive == null) { return(null); } return(string.Format("http://www.bing.com{0}_{1}.jpg", imageArchive.UrlBase, size.GetName())); }
/// <summary> /// 如果存在 message,则以 message 作为壁纸的标题,否则截取 copyright。 /// </summary> /// <param name="imageArchive"></param> /// <returns></returns> public static string GetTitle(this ImageArchive imageArchive) { string title = imageArchive.GetFirstMessageIfExist(); if (string.IsNullOrEmpty(title)) { title = imageArchive.GetCopyright(); } return(title); }
/// <summary> /// 根据壁纸信息更新磁贴。 /// </summary> /// <param name="image"></param> public static void UpdateTile(ImageArchive image) { string tileText = image.GetCopyright(); string _150x150url = image.GetUrlWithSize(WallpaperSize._150x150); string _310x150url = image.GetUrlWithSize(WallpaperSize._310x150); TileNotification tile = new TileNotification(TileTemplateHelper.CreateTileTemplate(tileText, _150x150url, _310x150url)); TileUpdateManager.CreateTileUpdaterForApplication().Update(tile); }
/// <summary> /// 截取 copyright。 /// </summary> /// <param name="imageArchive"></param> /// <returns></returns> public static string GetCopyright(this ImageArchive imageArchive) { string copyright = imageArchive.Copyright; int index = copyright.IndexOf('('); if (index > -1) { copyright = copyright.Substring(0, index).Trim(); } return(copyright); }
public async Task SaveToSavedPictures() { try { StorageFile file = await KnownFolders.SavedPictures.CreateFileAsync(ImageArchive.GetTitle() + ".jpg", CreationCollisionOption.ReplaceExisting); await SaveFile(file); } catch { Messenger.Default.Send("Save Failed"); } }
public void SaveToChooseLocation() { FileSavePicker savePicker = new FileSavePicker(); savePicker.FileTypeChoices.Add(".jpg", new List <string>() { ".jpg" }); savePicker.SuggestedFileName = ImageArchive.GetTitle(); savePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; savePicker.PickSaveFileAndContinue(); }
private async void BackOrForward(ImageArchive imageArchive) { // 点击上一幅或下一幅时关闭热点。 if (btnHotspot.IsChecked == true) { btnHotspot.IsChecked = false; } // 在上一幅或下一幅图片加载完成之前显示进度圈。 prgIsImageOpened.IsActive = true; // 尝试加载更多,防止下一幅按钮无法点击。 await Global.WallpaperCollection.LoadMoreItemsAsync(1); }
void compile(bool Interactive) { bool error = false; if (!Directory.Exists(this.sourceDirectory.Text)) { if (Interactive) { MessageBox.Show("Source directory does not exist!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } error = true; } if (!Directory.Exists(this.destinationDirectory.Text)) { Directory.CreateDirectory(this.destinationDirectory.Text); if (!Directory.Exists(this.destinationDirectory.Text)) { if (Interactive) { MessageBox.Show("Failed to create destination directory!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } error = true; } } if (this.archiveName.Text.Length == 0) { if (Interactive) { MessageBox.Show("Archive name too short! Must be at least one character long.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } error = true; } if (!error) { ImageArchive ia = new ImageArchive(); int imgloaded = ia.Add(new DirectoryInfo(this.sourceDirectory.Text)); bool saved = ia.Save(new DirectoryInfo(this.destinationDirectory.Text), this.archiveName.Text); if (Interactive) { if (saved) { MessageBox.Show("GUI saved to " + this.destinationDirectory.Text, "Compile Done", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("GUI was not saved.", "Compile Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
public void SetImageArchive(ImageArchive imageArchive) { ImageArchive = imageArchive; var wallpaperSize = Datas.Settings.WallpaperSize; WallpaperWidth = wallpaperSize.GetWidth(); WallpaperHeight = wallpaperSize.GetHeight(); IsLoading = true; string url = imageArchive.GetUrlWithSize(wallpaperSize); Uri uri = new Uri(url, UriKind.Absolute); WebClient client = new WebClient(); client.DownloadDataAsync(uri); client.DownloadDataCompleted += Wallpaper_DownloadCompleted; }
public async Task SaveFile(StorageFile file) { string url = ImageArchive.GetUrlWithSize(Settings.WallpaperSize); Uri uri = new Uri(url, UriKind.Absolute); try { using (HttpClient client = new HttpClient()) { byte[] bytes = await client.GetByteArrayAsync(uri); await FileIO.WriteBytesAsync(file, bytes); } } catch (HttpRequestException) { Messenger.Default.Send("Network Error"); return; } Messenger.Default.Send("Save Success"); }
private async void UpdateTile() { try { IBingWallpaperService service = new BingWallpaperJsonService(); ImageArchiveCollection imageArchiveCollection = await service.GetWallpaperInformationsAsync(0, 1, Settings.Area); ImageArchive image = imageArchiveCollection.Images.FirstOrDefault(); string tileText = image.GetTitle(); // ReSharper disable InconsistentNaming string _150x150url = image.GetUrlWithSize(WallpaperSize._150x150); string _310x150url = image.GetUrlWithSize(WallpaperSize._310x150); // ReSharper restore InconsistentNaming TileNotification tile = new TileNotification(TileTemplateHelper.CreateTileTemplate(tileText, _150x150url, _310x150url)); TileUpdateManager.CreateTileUpdaterForApplication().Update(tile); } finally { _deferral.Complete(); } }
private void DecompileGuiArchive() { var fileDialog = new OpenFileDialog(); fileDialog.Filter = "Graphics Index|*.uvgi"; var folderDialog = new FolderBrowserDialog(); folderDialog.Description = "Select a folder to save the images to."; var dr = fileDialog.ShowDialog(); if (dr != DialogResult.OK) { return; } dr = folderDialog.ShowDialog(); if (dr == DialogResult.OK) { FileInfo index = new FileInfo(fileDialog.FileName); ImageArchive ia = new ImageArchive(index); ia.Save(new DirectoryInfo(String.Format("{1}{0}images", Path.DirectorySeparatorChar, folderDialog.SelectedPath))); MessageBox.Show("GUI extraction complete.", "GUI extracted", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public static void Main(string[] args) { #if DEBUG // Program.DesignMode should not be queried before executing // Main (e.g. by a static Control) when running the program // normally Debug.Assert(!m_bDesignModeQueried); #endif m_bDesignMode = false; // Designer doesn't call Main method m_cmdLineArgs = new CommandLineArgs(args); // Before loading the configuration string strWaDisable = m_cmdLineArgs[ AppDefs.CommandLineOptions.WorkaroundDisable]; if (!string.IsNullOrEmpty(strWaDisable)) { MonoWorkarounds.SetEnabled(strWaDisable, false); } DpiUtil.ConfigureProcess(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.DoEvents(); // Required #if DEBUG string strInitialWorkDir = WinUtil.GetWorkingDirectory(); #endif if (!CommonInit()) { CommonTerminate(); return; } if (m_appConfig.Application.Start.PluginCacheClearOnce) { PlgxCache.Clear(); m_appConfig.Application.Start.PluginCacheClearOnce = false; AppConfigSerializer.Save(Program.Config); } if (m_cmdLineArgs[AppDefs.CommandLineOptions.FileExtRegister] != null) { ShellUtil.RegisterExtension(AppDefs.FileExtension.FileExt, AppDefs.FileExtension.ExtId, KPRes.FileExtName, WinUtil.GetExecutable(), PwDefs.ShortProductName, false); MainCleanUp(); return; } if (m_cmdLineArgs[AppDefs.CommandLineOptions.FileExtUnregister] != null) { ShellUtil.UnregisterExtension(AppDefs.FileExtension.FileExt, AppDefs.FileExtension.ExtId); MainCleanUp(); return; } if (m_cmdLineArgs[AppDefs.CommandLineOptions.PreLoad] != null) { // All important .NET assemblies are in memory now already try { SelfTest.Perform(); } catch (Exception) { Debug.Assert(false); } MainCleanUp(); return; } /* if(m_cmdLineArgs[AppDefs.CommandLineOptions.PreLoadRegister] != null) * { * string strPreLoadPath = WinUtil.GetExecutable().Trim(); * if(strPreLoadPath.StartsWith("\"") == false) * strPreLoadPath = "\"" + strPreLoadPath + "\""; * ShellUtil.RegisterPreLoad(AppDefs.PreLoadName, strPreLoadPath, * @"--" + AppDefs.CommandLineOptions.PreLoad, true); * MainCleanUp(); * return; * } * if(m_cmdLineArgs[AppDefs.CommandLineOptions.PreLoadUnregister] != null) * { * ShellUtil.RegisterPreLoad(AppDefs.PreLoadName, string.Empty, * string.Empty, false); * MainCleanUp(); * return; * } */ if ((m_cmdLineArgs[AppDefs.CommandLineOptions.Help] != null) || (m_cmdLineArgs[AppDefs.CommandLineOptions.HelpLong] != null)) { AppHelp.ShowHelp(AppDefs.HelpTopics.CommandLine, null); MainCleanUp(); return; } if (m_cmdLineArgs[AppDefs.CommandLineOptions.ConfigSetUrlOverride] != null) { Program.Config.Integration.UrlOverride = m_cmdLineArgs[ AppDefs.CommandLineOptions.ConfigSetUrlOverride]; AppConfigSerializer.Save(Program.Config); MainCleanUp(); return; } if (m_cmdLineArgs[AppDefs.CommandLineOptions.ConfigClearUrlOverride] != null) { Program.Config.Integration.UrlOverride = string.Empty; AppConfigSerializer.Save(Program.Config); MainCleanUp(); return; } if (m_cmdLineArgs[AppDefs.CommandLineOptions.ConfigGetUrlOverride] != null) { try { string strFileOut = UrlUtil.EnsureTerminatingSeparator( UrlUtil.GetTempPath(), false) + "KeePass_UrlOverride.tmp"; string strContent = ("[KeePass]\r\nKeeURLOverride=" + Program.Config.Integration.UrlOverride + "\r\n"); File.WriteAllText(strFileOut, strContent); } catch (Exception) { Debug.Assert(false); } MainCleanUp(); return; } if (m_cmdLineArgs[AppDefs.CommandLineOptions.ConfigSetLanguageFile] != null) { Program.Config.Application.LanguageFile = m_cmdLineArgs[ AppDefs.CommandLineOptions.ConfigSetLanguageFile]; AppConfigSerializer.Save(Program.Config); MainCleanUp(); return; } if (m_cmdLineArgs[AppDefs.CommandLineOptions.PlgxCreate] != null) { PlgxPlugin.CreateFromCommandLine(); MainCleanUp(); return; } if (m_cmdLineArgs[AppDefs.CommandLineOptions.PlgxCreateInfo] != null) { PlgxPlugin.CreateInfoFile(m_cmdLineArgs.FileName); MainCleanUp(); return; } if (m_cmdLineArgs[AppDefs.CommandLineOptions.ShowAssemblyInfo] != null) { MessageService.ShowInfo(Assembly.GetExecutingAssembly().ToString()); MainCleanUp(); return; } if (m_cmdLineArgs[AppDefs.CommandLineOptions.MakeXmlSerializerEx] != null) { XmlSerializerEx.GenerateSerializers(m_cmdLineArgs); MainCleanUp(); return; } if (m_cmdLineArgs[AppDefs.CommandLineOptions.MakeXspFile] != null) { XspArchive.CreateFile(m_cmdLineArgs.FileName, m_cmdLineArgs["d"]); MainCleanUp(); return; } if (m_cmdLineArgs[AppDefs.CommandLineOptions.Version] != null) { Console.WriteLine(PwDefs.ShortProductName + " " + PwDefs.VersionString); Console.WriteLine(PwDefs.Copyright); MainCleanUp(); return; } #if DEBUG if (m_cmdLineArgs[AppDefs.CommandLineOptions.TestGfx] != null) { List <Image> lImg = new List <Image>(); lImg.Add(Properties.Resources.B16x16_Browser); lImg.Add(Properties.Resources.B48x48_Keyboard_Layout); ImageArchive aHighRes = new ImageArchive(); aHighRes.Load(Properties.Resources.Images_Client_HighRes); lImg.Add(aHighRes.GetForObject("C12_IRKickFlash")); if (File.Exists("Test.png")) { lImg.Add(Image.FromFile("Test.png")); } Image img = GfxUtil.ScaleTest(lImg.ToArray()); img.Save("GfxScaleTest.png", ImageFormat.Png); return; } #endif // #if (DEBUG && !KeePassLibSD) // if(m_cmdLineArgs[AppDefs.CommandLineOptions.MakePopularPasswordTable] != null) // { // PopularPasswords.MakeList(); // MainCleanUp(); // return; // } // #endif try { m_nAppMessage = NativeMethods.RegisterWindowMessage(m_strWndMsgID); } catch (Exception) { Debug.Assert(NativeLib.IsUnix()); } if (m_cmdLineArgs[AppDefs.CommandLineOptions.ExitAll] != null) { BroadcastAppMessageAndCleanUp(AppMessage.Exit); return; } if (m_cmdLineArgs[AppDefs.CommandLineOptions.AutoType] != null) { BroadcastAppMessageAndCleanUp(AppMessage.AutoType); return; } if (m_cmdLineArgs[AppDefs.CommandLineOptions.AutoTypeSelected] != null) { BroadcastAppMessageAndCleanUp(AppMessage.AutoTypeSelected); return; } if (m_cmdLineArgs[AppDefs.CommandLineOptions.OpenEntryUrl] != null) { string strEntryUuid = m_cmdLineArgs[AppDefs.CommandLineOptions.Uuid]; if (!string.IsNullOrEmpty(strEntryUuid)) { IpcParamEx ipUrl = new IpcParamEx(IpcUtilEx.CmdOpenEntryUrl, strEntryUuid, null, null, null, null); IpcUtilEx.SendGlobalMessage(ipUrl); } MainCleanUp(); return; } if (m_cmdLineArgs[AppDefs.CommandLineOptions.LockAll] != null) { BroadcastAppMessageAndCleanUp(AppMessage.Lock); return; } if (m_cmdLineArgs[AppDefs.CommandLineOptions.UnlockAll] != null) { BroadcastAppMessageAndCleanUp(AppMessage.Unlock); return; } if (m_cmdLineArgs[AppDefs.CommandLineOptions.IpcEvent] != null) { string strName = m_cmdLineArgs[AppDefs.CommandLineOptions.IpcEvent]; if (!string.IsNullOrEmpty(strName)) { string[] vFlt = KeyUtil.MakeCtxIndependent(args); IpcParamEx ipEvent = new IpcParamEx(IpcUtilEx.CmdIpcEvent, strName, CommandLineArgs.SafeSerialize(vFlt), null, null, null); IpcUtilEx.SendGlobalMessage(ipEvent); } MainCleanUp(); return; } // Mutex mSingleLock = TrySingleInstanceLock(AppDefs.MutexName, true); bool bSingleLock = GlobalMutexPool.CreateMutex(AppDefs.MutexName, true); // if((mSingleLock == null) && m_appConfig.Integration.LimitToSingleInstance) if (!bSingleLock && m_appConfig.Integration.LimitToSingleInstance) { ActivatePreviousInstance(args); MainCleanUp(); return; } Mutex mGlobalNotify = TryGlobalInstanceNotify(AppDefs.MutexNameGlobal); AutoType.InitStatic(); CustomMessageFilterEx cmfx = new CustomMessageFilterEx(); Application.AddMessageFilter(cmfx); #if DEBUG if (m_cmdLineArgs[AppDefs.CommandLineOptions.DebugThrowException] != null) { throw new Exception(AppDefs.CommandLineOptions.DebugThrowException); } m_formMain = new MainForm(); Application.Run(m_formMain); #else try { if (m_cmdLineArgs[AppDefs.CommandLineOptions.DebugThrowException] != null) { throw new Exception(AppDefs.CommandLineOptions.DebugThrowException); } m_formMain = new MainForm(); Application.Run(m_formMain); } catch (Exception exPrg) { // Catch message box exception; // https://sourceforge.net/p/keepass/patches/86/ try { MessageService.ShowFatal(exPrg); } catch (Exception) { Console.Error.WriteLine(exPrg.ToString()); } } #endif Application.RemoveMessageFilter(cmfx); Debug.Assert(GlobalWindowManager.WindowCount == 0); Debug.Assert(MessageService.CurrentMessageCount == 0); MainCleanUp(); #if DEBUG string strEndWorkDir = WinUtil.GetWorkingDirectory(); Debug.Assert(strEndWorkDir.Equals(strInitialWorkDir, StrUtil.CaseIgnoreCmp)); #endif if (mGlobalNotify != null) { GC.KeepAlive(mGlobalNotify); } // if(mSingleLock != null) { GC.KeepAlive(mSingleLock); } }
private static string GenerateDoc(PwDatabase pd, bool bEmSheet, bool bKeyFile) { string strDbFile = pd.IOConnectionInfo.Path; KcpKeyFile kf = (pd.MasterKey.GetUserKey(typeof(KcpKeyFile)) as KcpKeyFile); string strKeyFile = ((kf != null) ? kf.Path : string.Empty); if (bKeyFile) { if (strKeyFile.Length == 0) { Debug.Assert(false); return(string.Empty); } if (!KfxFile.CanLoad(strKeyFile)) { throw new FormatException(strKeyFile + MessageService.NewParagraph + KPRes.KeyFileNoXml + MessageService.NewParagraph + KPRes.KeyFilePrintReqXml + MessageService.NewParagraph + KPRes.KeyFileGenHint); } } string strName = UrlUtil.StripExtension(UrlUtil.GetFileName(bEmSheet ? strDbFile : strKeyFile)); if (strName.Length == 0) { strName = (bEmSheet ? KPRes.Database : KPRes.KeyFile); } string strDocKind = (bEmSheet ? KPRes.EmergencySheet : KPRes.KeyFileBackup); bool bRtl = Program.Translation.Properties.RightToLeft; string strLogLeft = (bRtl ? "right" : "left"); string strLogRight = (bRtl ? "left" : "right"); GFunc <string, string> h = new GFunc <string, string>(StrUtil.StringToHtml); GFunc <string, string> ne = delegate(string str) { if (string.IsNullOrEmpty(str)) { return(" "); } return(str); }; GFunc <string, string> ltrPath = delegate(string str) { return(bRtl ? StrUtil.EnsureLtrPath(str) : str); }; StringBuilder sb = new StringBuilder(); sb.AppendLine("<!DOCTYPE html>"); sb.Append("<html xmlns=\"http://www.w3.org/1999/xhtml\""); string strLang = Program.Translation.Properties.Iso6391Code; if (string.IsNullOrEmpty(strLang)) { strLang = "en"; } strLang = h(strLang); sb.Append(" xml:lang=\"" + strLang + "\" lang=\"" + strLang + "\""); if (bRtl) { sb.Append(" dir=\"rtl\""); } sb.AppendLine(">"); sb.AppendLine("<head>"); sb.AppendLine("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"); sb.AppendLine("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />"); sb.AppendLine("<meta http-equiv=\"expires\" content=\"0\" />"); sb.AppendLine("<meta http-equiv=\"cache-control\" content=\"no-cache\" />"); sb.AppendLine("<meta http-equiv=\"pragma\" content=\"no-cache\" />"); sb.Append("<title>"); sb.Append(h(strName + " - " + strDocKind)); sb.AppendLine("</title>"); sb.AppendLine("<style type=\"text/css\">"); sb.AppendLine("/* <![CDATA[ */"); string strFont = "\"Arial\", \"Tahoma\", \"Verdana\", sans-serif;"; // https://sourceforge.net/p/keepass/discussion/329220/thread/f98dece5/ if (Program.Translation.IsFor("fa")) { strFont = "\"Tahoma\", \"Arial\", \"Verdana\", sans-serif;"; } sb.AppendLine("body {"); sb.AppendLine("\tcolor: #000000;"); sb.AppendLine("\tbackground-color: #FFFFFF;"); sb.AppendLine("\tfont-family: " + strFont); sb.AppendLine("\tfont-size: 12pt;"); sb.AppendLine("}"); sb.AppendLine("h3, p {"); sb.AppendLine("\tmargin: 0.5em 0em 0.5em 0em;"); sb.AppendLine("}"); sb.AppendLine("ol, ul {"); sb.AppendLine("\tmargin-bottom: 0em;"); sb.AppendLine("}"); sb.AppendLine("h1, h2, h3 {"); sb.AppendLine("\tfont-family: \"Verdana\", \"Arial\", \"Tahoma\", sans-serif;"); sb.AppendLine("}"); sb.AppendLine("h1, h2 {"); sb.AppendLine("\tmargin: 0pt 0pt 0pt 0pt;"); sb.AppendLine("\ttext-align: center;"); sb.AppendLine("}"); sb.AppendLine("h1 {"); sb.AppendLine("\tpadding: 3pt 0pt 0pt 0pt;"); sb.AppendLine("}"); sb.AppendLine("h2 {"); sb.AppendLine("\tpadding: 1pt 0pt 3pt 0pt;"); sb.AppendLine("}"); // sb.AppendLine("h3 {"); // sb.AppendLine("\tpadding: 3pt 3pt 3pt 3pt;"); // sb.AppendLine("\tcolor: #000000;"); // sb.AppendLine("\tbackground-color: #EEEEEE;"); // sb.AppendLine("\tbackground-image: -webkit-linear-gradient(top, #E2E2E2, #FAFAFA);"); // sb.AppendLine("\tbackground-image: -moz-linear-gradient(top, #E2E2E2, #FAFAFA);"); // sb.AppendLine("\tbackground-image: -ms-linear-gradient(top, #E2E2E2, #FAFAFA);"); // sb.AppendLine("\tbackground-image: linear-gradient(to bottom, #E2E2E2, #FAFAFA);"); // sb.AppendLine("}"); sb.AppendLine("a {"); sb.AppendLine("\tcolor: #0000DD;"); sb.AppendLine("\ttext-decoration: none;"); sb.AppendLine("}"); sb.AppendLine("a:hover, a:active {"); sb.AppendLine("\tcolor: #6699FF;"); sb.AppendLine("\ttext-decoration: underline;"); sb.AppendLine("}"); sb.AppendLine("img {"); sb.AppendLine("\tborder: 0px none;"); sb.AppendLine("}"); sb.AppendLine(".withspc > li + li {"); sb.AppendLine("\tmargin-top: 0.5em;"); sb.AppendLine("}"); sb.AppendLine("table.docheader {"); sb.AppendLine("\twidth: 100%;"); sb.AppendLine("\tbackground-color: #EEEEEE;"); sb.AppendLine("\tmargin: 0px 0px 0px 0px;"); sb.AppendLine("\tpadding: 0px 0px 0px 0px;"); sb.AppendLine("\tborder: thin solid #808080;"); // border-collapse is incompatible with border-radius // sb.AppendLine("\tborder-collapse: collapse;"); sb.AppendLine("\t-webkit-border-radius: 5px;"); sb.AppendLine("\t-moz-border-radius: 5px;"); sb.AppendLine("\tborder-radius: 5px;"); sb.AppendLine("}"); sb.AppendLine("table.docheader tr td {"); sb.AppendLine("\tborder: 0px none;"); sb.AppendLine("\tborder-collapse: collapse;"); sb.AppendLine("\tpadding: 0px 15px 0px 15px;"); sb.AppendLine("\tvertical-align: middle;"); sb.AppendLine("}"); sb.AppendLine("table.fillinline {"); sb.AppendLine("\twidth: 100%;"); sb.AppendLine("\tmargin: 0px 0px 0px 0px;"); sb.AppendLine("\tpadding: 0px 0px 0px 0px;"); sb.AppendLine("\tborder: thin solid #808080;"); sb.AppendLine("\tborder-collapse: collapse;"); sb.AppendLine("\ttable-layout: fixed;"); sb.AppendLine("\tempty-cells: show;"); sb.AppendLine("}"); sb.AppendLine("table.fillinline tr td {"); sb.AppendLine("\tpadding: 4pt 4pt 4pt 4pt;"); sb.AppendLine("\tvertical-align: middle;"); sb.AppendLine("\tword-break: break-all;"); sb.AppendLine("\toverflow-wrap: break-word;"); sb.AppendLine("\tword-wrap: break-word;"); sb.AppendLine("}"); sb.AppendLine("table.fillinline tr td img {"); sb.AppendLine("\tdisplay: block;"); // Inline results in additional space at the bottom sb.AppendLine("\tmargin: 0px " + (bRtl ? "auto 0px 0px;" : "0px 0px auto;")); sb.AppendLine("}"); // sb.AppendLine("span.fillinlinesym {"); // sb.AppendLine("\tdisplay: inline-block;"); // sb.AppendLine("\ttransform: scale(1.75, 1.75) translate(-0.5pt, -0.5pt);"); // sb.AppendLine("}"); sb.AppendLine("table.fillinline tr td pre {"); sb.AppendLine("\tmargin: 0px 0px 0px 0px;"); sb.AppendLine("\tpadding: 0px 0px 0px 0px;"); sb.AppendLine("\tborder: 0px none;"); sb.AppendLine("\tborder-collapse: collapse;"); sb.AppendLine("\twhite-space: pre-wrap;"); sb.AppendLine("\toverflow: auto;"); sb.AppendLine("\toverflow-wrap: break-word;"); sb.AppendLine("\tword-wrap: break-word;"); sb.AppendLine("\tword-break: break-all;"); sb.AppendLine("}"); // sb.AppendLine("@media print {"); // sb.AppendLine(".scronly {"); // sb.AppendLine("\tdisplay: none;"); // sb.AppendLine("}"); // sb.AppendLine("}"); sb.AppendLine("@media print {"); sb.AppendLine(".ems_break_before {"); sb.AppendLine("\tpage-break-before: always;"); // CSS 2 sb.AppendLine("\tbreak-before: page;"); // CSS 3 sb.AppendLine("}"); sb.AppendLine("}"); // Add the temporary content identifier // (always, as the sheet should be printed, not saved) sb.AppendLine("." + Program.TempFilesPool.TempContentTag + " {"); sb.AppendLine("\tfont-size: 12pt;"); sb.AppendLine("}"); sb.AppendLine("/* ]]> */"); sb.AppendLine("</style>"); sb.AppendLine("</head><body>"); ImageArchive ia = new ImageArchive(); ia.Load(Properties.Resources.Images_App_HighRes); sb.AppendLine("<table class=\"docheader\"><tr>"); sb.AppendLine("<td style=\"text-align: " + strLogLeft + ";\">"); Debug.Assert(Properties.Resources.B16x16_KeePass != null); // Name ref. sb.AppendLine("<img src=\"" + GfxUtil.ImageToDataUri(ia.GetForObject( "KeePass")) + "\" width=\"48\" height=\"48\" alt=\"" + h(PwDefs.ShortProductName) + "\" /></td>"); sb.AppendLine("<td style=\"text-align: center;\">"); sb.AppendLine("<h1>" + h(PwDefs.ShortProductName) + "</h1>"); sb.AppendLine("<h2>" + h(strDocKind) + "</h2>"); sb.AppendLine("</td>"); sb.AppendLine("<td style=\"text-align: " + strLogRight + ";\">"); Debug.Assert(Properties.Resources.B16x16_KOrganizer != null); // Name ref. sb.AppendLine("<img src=\"" + GfxUtil.ImageToDataUri(ia.GetForObject( "KOrganizer")) + "\" width=\"48\" height=\"48\" alt=\"" + h(strDocKind) + "\" /></td>"); sb.AppendLine("</tr></table>"); sb.AppendLine("<p style=\"text-align: " + strLogRight + ";\">" + h(TimeUtil.ToDisplayStringDateOnly(DateTime.Now)) + "</p>"); const string strFillInit = "<table class=\"fillinline\"><tr><td>"; const string strFillInitLtr = "<table class=\"fillinline\"><tr><td dir=\"ltr\">"; const string strFillEnd = "</td></tr></table>"; string strFillSym = "<img src=\"" + GfxUtil.ImageToDataUri( Properties.Resources.B48x35_WritingHand) + "\" style=\"width: 1.3714em; height: 1em;" + (bRtl ? " transform: scaleX(-1);" : string.Empty) + "\" alt=\"✍\" />"; string strFill = strFillInit + ne(string.Empty) + // "</td><td style=\"text-align: right;\"><span class=\"fillinlinesym\">✍</span>" + // "</td><td style=\"text-align: " + strLogRight + ";\">" + "</td><td>" + strFillSym + strFillEnd; string strFillInitEx = (bRtl ? strFillInitLtr : strFillInit); if (bEmSheet) { GenerateEms(sb, pd, strDbFile, h, ne, ltrPath, strFillInit, strFillInitEx, strFillEnd, strFill); } if (bEmSheet && bKeyFile) { sb.AppendLine("<table class=\"docheader ems_break_before\"><tr>"); sb.AppendLine("<td style=\"text-align: center;\">"); sb.AppendLine("<h2>" + h(KPRes.KeyFileBackup) + "</h2>"); sb.AppendLine("</td></tr></table><br />"); } if (bKeyFile) { GenerateKfb(sb, pd, strDbFile, strKeyFile, h, ne, ltrPath, strFillInit, strFillInitEx, strFillEnd, strFill); } sb.AppendLine("</body></html>"); string strDoc = sb.ToString(); #if DEBUG XmlUtilEx.ValidateXml(strDoc, true); #endif return(strDoc); }
public object Convert(object value, Type targetType, object parameter, string language) { ImageArchive imageArchive = (ImageArchive)value; return(imageArchive.GetCopyright()); }
public async Task <JsonResult> saveArchive(MailArchiveVM model, string user, int UserWorkPlace) { var userName = accessor.HttpContext.User.Identity.Name; model.FK_StatusId = 1; var eArchive = new MailArchiveVM { classificationList = classificationService.GetQueryable(c => c.IsDeleted == false).GetListItems("ClassificationName", "Id", 0).ToList(), mailTypeList = mailTypeService.GetQueryable(c => c.IsDeleted == false).GetListItems("MailName", "Id", 0).ToList(), postTypeList = postTypeService.GetQueryable(c => c.IsDeleted == false).GetListItems("PostName", "Id", 0).ToList(), securityList = securityService.GetQueryable(c => c.IsDeleted == false).GetListItems("SecurityName", "Id", 0).ToList(), statusList = statusService.GetQueryable(c => c.IsDeleted == false).GetListItems("StatusName", "Id", 0).ToList(), }; //model.FK_StatusId = 2; /// هذي انت انسيتها في الفيو if (model.ID == 0) { if (ModelState.IsValid & !string.IsNullOrEmpty(model.ScannedFiles)) { if (await mailArchiveService.CheckIfArchivceNumberExist(model.MailId)) { return(Json(new { status = JsonStatus.Exist, link = "تنبيه", color = NotificationColor.warning.ToString().ToLower(), msg = "هذا الرقم موجود مسبقا ", })); } model.InsertDate = DateTime.UtcNow; model.InsertUser = USER_NAME.UserName; model.UserWorkPlaceID = USER_NAME.WorkPlace.Id; model.Year = DateTime.UtcNow.Year.ToString(); var newModel = mapper.Map <MailArchive>(model); //try //{ var getByteForFiles = default(byte[]); if (model.ScannedFiles != null) { var stringTOArray = model.ScannedFiles.Split("|"); getByteForFiles = GetStream(stringTOArray); } ImageArchive imageArchiveVM = new ImageArchive { Id = 0, Name = $"{ Guid.NewGuid().ToString()}.PDF", ContentMail = getByteForFiles, Extension = ".PDF", Type = "application/pdf" }; newModel.imageArchives = new List <ImageArchive> { imageArchiveVM }; var result = await mailArchiveService.AddAndLogAsync(newModel, USERNAME); if (result > 0) { return(Json(new { status = JsonStatus.Success, link = "جيد", color = NotificationColor.success.ToString().ToLower(), msg = "تم الحفظ بنجاح", ObjectID = newModel.ID })); } else { return(Json(new { status = JsonStatus.Error, link = "يوجد خطا", color = NotificationColor.error.ToString().ToLower(), msg = "يوجد خطا في عملية الحفظ", ObjectID = newModel.ID, })); } //} //catch (Exception) //{ // return Json(new // { // status = JsonStatus.Error, // link = "يوجد خطا", // color = NotificationColor.error.ToString().ToLower(), // msg = "يوجد خطا في عملية الحفظ", // ObjectID = newModel.ID, // }); // throw; //} } return(Json(new { status = JsonStatus.Error, link = "", color = NotificationColor.error.ToString().ToLower(), msg = ModelState.Keys.SelectMany(k => ModelState[k].Errors) .Select(m => m.ErrorMessage).ToArray() })); } else { if (ModelState.IsValid) { var getMailArchiveById = await mailArchiveService.GetAsync(m => m.ID == model.ID); var firstMailArchive = getMailArchiveById.FirstOrDefault(); firstMailArchive.FK_MailTypeId = model.FK_MailTypeId; firstMailArchive.FK_ClassificationId = model.FK_ClassificationId; firstMailArchive.FK_PostTypeId = model.FK_PostTypeId; firstMailArchive.FK_SecurityId = model.FK_SecurityId; firstMailArchive.FK_StatusId = model.FK_StatusId; firstMailArchive.FK_FromJehazId = model.FK_FromJehazId; firstMailArchive.FK_ToJehazId = model.FK_ToJehazId; firstMailArchive.Topic = model.Topic; firstMailArchive.Note = model.Note; firstMailArchive.UpdatedDate = DateTime.UtcNow; firstMailArchive.UpdateUser = USER_NAME.UserName; firstMailArchive.UserWorkPlaceID = USER_NAME.WorkPlace.Id; var result = await mailArchiveService.UpdateAndLogAsync(firstMailArchive, USERNAME); if (result > 0) { return(Json(new { status = JsonStatus.Success, link = "جيد", color = NotificationColor.success.ToString().ToLower(), msg = "تم الحفظ بنجاح", ObjectID = firstMailArchive.ID })); } else { return(Json(new { status = JsonStatus.Error, link = "يوجد خطا", color = NotificationColor.error.ToString().ToLower(), msg = "يوجد خطا في عملية الحفظ", ObjectID = firstMailArchive.ID, })); } } } return(Json(new { status = JsonStatus.Error, link = "", color = NotificationColor.error.ToString().ToLower(), msg = ModelState.Keys.SelectMany(k => ModelState[k].Errors) .Select(m => m.ErrorMessage).ToArray() })); }
private static string GenerateHtml(PwDatabase pd, string strName) { bool bRtl = Program.Translation.Properties.RightToLeft; string strLogLeft = (bRtl ? "right" : "left"); string strLogRight = (bRtl ? "left" : "right"); GFunc <string, string> h = new GFunc <string, string>(StrUtil.StringToHtml); GFunc <string, string> ne = delegate(string str) { if (string.IsNullOrEmpty(str)) { return(" "); } return(str); }; GFunc <string, string> ltrPath = delegate(string str) { return(bRtl ? StrUtil.EnsureLtrPath(str) : str); }; StringBuilder sb = new StringBuilder(); sb.AppendLine("<!DOCTYPE html>"); sb.Append("<html xmlns=\"http://www.w3.org/1999/xhtml\""); string strLang = Program.Translation.Properties.Iso6391Code; if (string.IsNullOrEmpty(strLang)) { strLang = "en"; } strLang = h(strLang); sb.Append(" xml:lang=\"" + strLang + "\" lang=\"" + strLang + "\""); if (bRtl) { sb.Append(" dir=\"rtl\""); } sb.AppendLine(">"); sb.AppendLine("<head>"); sb.AppendLine("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"); sb.AppendLine("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />"); sb.AppendLine("<meta http-equiv=\"expires\" content=\"0\" />"); sb.AppendLine("<meta http-equiv=\"cache-control\" content=\"no-cache\" />"); sb.AppendLine("<meta http-equiv=\"pragma\" content=\"no-cache\" />"); sb.Append("<title>"); sb.Append(h(strName + " - " + KPRes.EmergencySheet)); sb.AppendLine("</title>"); sb.AppendLine("<style type=\"text/css\">"); sb.AppendLine("/* <![CDATA[ */"); string strFont = "\"Arial\", \"Tahoma\", \"Verdana\", sans-serif;"; // https://sourceforge.net/p/keepass/discussion/329220/thread/f98dece5/ if (Program.Translation.IsFor("fa")) { strFont = "\"Tahoma\", \"Arial\", \"Verdana\", sans-serif;"; } sb.AppendLine("body {"); sb.AppendLine("\tcolor: #000000;"); sb.AppendLine("\tbackground-color: #FFFFFF;"); sb.AppendLine("\tfont-family: " + strFont); sb.AppendLine("\tfont-size: 12pt;"); sb.AppendLine("}"); sb.AppendLine("h3, p {"); sb.AppendLine("\tmargin: 0.5em 0em 0.5em 0em;"); sb.AppendLine("}"); sb.AppendLine("ol, ul {"); sb.AppendLine("\tmargin-bottom: 0em;"); sb.AppendLine("}"); sb.AppendLine("h1, h2, h3 {"); sb.AppendLine("\tfont-family: \"Verdana\", \"Arial\", \"Tahoma\", sans-serif;"); sb.AppendLine("}"); sb.AppendLine("h1, h2 {"); sb.AppendLine("\tmargin: 0pt 0pt 0pt 0pt;"); sb.AppendLine("\ttext-align: center;"); sb.AppendLine("}"); sb.AppendLine("h1 {"); sb.AppendLine("\tpadding: 3pt 0pt 0pt 0pt;"); sb.AppendLine("}"); sb.AppendLine("h2 {"); sb.AppendLine("\tpadding: 1pt 0pt 3pt 0pt;"); sb.AppendLine("}"); // sb.AppendLine("h3 {"); // sb.AppendLine("\tpadding: 3pt 3pt 3pt 3pt;"); // sb.AppendLine("\tcolor: #000000;"); // sb.AppendLine("\tbackground-color: #EEEEEE;"); // sb.AppendLine("\tbackground-image: -webkit-linear-gradient(top, #E2E2E2, #FAFAFA);"); // sb.AppendLine("\tbackground-image: -moz-linear-gradient(top, #E2E2E2, #FAFAFA);"); // sb.AppendLine("\tbackground-image: -ms-linear-gradient(top, #E2E2E2, #FAFAFA);"); // sb.AppendLine("\tbackground-image: linear-gradient(to bottom, #E2E2E2, #FAFAFA);"); // sb.AppendLine("}"); sb.AppendLine("a {"); sb.AppendLine("\tcolor: #0000DD;"); sb.AppendLine("\ttext-decoration: none;"); sb.AppendLine("}"); sb.AppendLine("a:hover, a:active {"); sb.AppendLine("\tcolor: #6699FF;"); sb.AppendLine("\ttext-decoration: underline;"); sb.AppendLine("}"); sb.AppendLine("img {"); sb.AppendLine("\tborder: 0px none;"); sb.AppendLine("}"); sb.AppendLine(".withspc > li + li {"); sb.AppendLine("\tmargin-top: 0.5em;"); sb.AppendLine("}"); sb.AppendLine("table.docheader {"); sb.AppendLine("\twidth: 100%;"); sb.AppendLine("\tbackground-color: #EEEEEE;"); sb.AppendLine("\tmargin: 0px 0px 0px 0px;"); sb.AppendLine("\tpadding: 0px 0px 0px 0px;"); sb.AppendLine("\tborder: thin solid #808080;"); // border-collapse is incompatible with border-radius // sb.AppendLine("\tborder-collapse: collapse;"); sb.AppendLine("\t-webkit-border-radius: 5px;"); sb.AppendLine("\t-moz-border-radius: 5px;"); sb.AppendLine("\tborder-radius: 5px;"); sb.AppendLine("}"); sb.AppendLine("table.docheader tr td {"); sb.AppendLine("\tborder: 0px none;"); sb.AppendLine("\tborder-collapse: collapse;"); sb.AppendLine("\tpadding: 0px 15px 0px 15px;"); sb.AppendLine("\tvertical-align: middle;"); sb.AppendLine("}"); sb.AppendLine("table.fillinline {"); sb.AppendLine("\twidth: 100%;"); sb.AppendLine("\tmargin: 0px 0px 0px 0px;"); sb.AppendLine("\tpadding: 0px 0px 0px 0px;"); sb.AppendLine("\tborder: thin solid #808080;"); sb.AppendLine("\tborder-collapse: collapse;"); sb.AppendLine("\ttable-layout: fixed;"); sb.AppendLine("\tempty-cells: show;"); sb.AppendLine("}"); sb.AppendLine("table.fillinline tr td {"); sb.AppendLine("\tpadding: 4pt 4pt 4pt 4pt;"); sb.AppendLine("\tvertical-align: middle;"); sb.AppendLine("\tword-break: break-all;"); sb.AppendLine("\toverflow-wrap: break-word;"); sb.AppendLine("\tword-wrap: break-word;"); sb.AppendLine("}"); sb.AppendLine("table.fillinline tr td img {"); sb.AppendLine("\tdisplay: block;"); // Inline results in additional space at the bottom sb.AppendLine("\tmargin: 0px " + (bRtl ? "auto 0px 0px;" : "0px 0px auto;")); sb.AppendLine("}"); // sb.AppendLine("span.fillinlinesym {"); // sb.AppendLine("\tdisplay: inline-block;"); // sb.AppendLine("\ttransform: scale(1.75, 1.75) translate(-0.5pt, -0.5pt);"); // sb.AppendLine("}"); // sb.AppendLine("@media print {"); // sb.AppendLine(".scronly {"); // sb.AppendLine("\tdisplay: none;"); // sb.AppendLine("}"); // sb.AppendLine("}"); // Add the temporary content identifier // (always, as the sheet should be printed, not saved) sb.AppendLine("." + Program.TempFilesPool.TempContentTag + " {"); sb.AppendLine("\tfont-size: 12pt;"); sb.AppendLine("}"); sb.AppendLine("/* ]]> */"); sb.AppendLine("</style>"); sb.AppendLine("</head><body>"); ImageArchive ia = new ImageArchive(); ia.Load(Properties.Resources.Images_App_HighRes); sb.AppendLine("<table class=\"docheader\"><tr>"); sb.AppendLine("<td style=\"text-align: " + strLogLeft + ";\">"); sb.AppendLine("<img src=\"" + GfxUtil.ImageToDataUri(ia.GetForObject( "KeePass")) + "\" width=\"48\" height=\"48\" alt=\"" + h(PwDefs.ShortProductName) + "\" /></td>"); sb.AppendLine("<td style=\"text-align: center;\">"); sb.AppendLine("<h1>" + h(PwDefs.ShortProductName) + "</h1>"); sb.AppendLine("<h2>" + h(KPRes.EmergencySheet) + "</h2>"); sb.AppendLine("</td>"); sb.AppendLine("<td style=\"text-align: " + strLogRight + ";\">"); sb.AppendLine("<img src=\"" + GfxUtil.ImageToDataUri(ia.GetForObject( "KOrganizer")) + "\" width=\"48\" height=\"48\" alt=\"" + h(KPRes.EmergencySheet) + "\" /></td>"); sb.AppendLine("</tr></table>"); sb.AppendLine("<p style=\"text-align: " + strLogRight + ";\">" + h(TimeUtil.ToDisplayStringDateOnly(DateTime.Now)) + "</p>"); const string strFillInit = "<table class=\"fillinline\"><tr><td>"; const string strFillInitLtr = "<table class=\"fillinline\"><tr><td dir=\"ltr\">"; const string strFillEnd = "</td></tr></table>"; string strFillSym = "<img src=\"" + GfxUtil.ImageToDataUri( Properties.Resources.B48x35_WritingHand) + "\" style=\"width: 1.3714em; height: 1em;" + (bRtl ? " transform: scaleX(-1);" : string.Empty) + "\" alt=\"✍\" />"; string strFill = strFillInit + ne(string.Empty) + // "</td><td style=\"text-align: right;\"><span class=\"fillinlinesym\">✍</span>" + // "</td><td style=\"text-align: " + strLogRight + ";\">" + "</td><td>" + strFillSym + strFillEnd; string strFillInitEx = (bRtl ? strFillInitLtr : strFillInit); IOConnectionInfo ioc = pd.IOConnectionInfo; sb.AppendLine("<p><strong>" + h(KPRes.DatabaseFile) + ":</strong></p>"); sb.AppendLine(strFillInitEx + ne(h(ltrPath(ioc.Path))) + strFillEnd); // if(pd.Name.Length > 0) // sb.AppendLine("<p><strong>" + h(KPRes.Name) + ":</strong> " + // h(pd.Name) + "</p>"); // if(pd.Description.Length > 0) // sb.AppendLine("<p><strong>" + h(KPRes.Description) + ":</strong> " + // h(pd.Description)); sb.AppendLine("<p>" + h(KPRes.BackupDatabase) + " " + h(KPRes.BackupLocation) + "</p>"); sb.AppendLine(strFill); CompositeKey ck = pd.MasterKey; if (ck.UserKeyCount > 0) { sb.AppendLine("<br />"); sb.AppendLine("<h3>" + h(KPRes.MasterKey) + "</h3>"); sb.AppendLine("<p>" + h(KPRes.MasterKeyComponents) + "</p>"); sb.AppendLine("<ul>"); foreach (IUserKey k in ck.UserKeys) { KcpPassword p = (k as KcpPassword); KcpKeyFile kf = (k as KcpKeyFile); KcpUserAccount a = (k as KcpUserAccount); KcpCustomKey c = (k as KcpCustomKey); if (p != null) { sb.AppendLine("<li><p><strong>" + h(KPRes.MasterPassword) + ":</strong></p>"); sb.AppendLine(strFill + "</li>"); } else if (kf != null) { sb.AppendLine("<li><p><strong>" + h(KPRes.KeyFile) + ":</strong></p>"); sb.AppendLine(strFillInitEx + ne(h(ltrPath(kf.Path))) + strFillEnd); sb.AppendLine("<p>" + h(KPRes.BackupFile) + " " + h(KPRes.BackupLocation) + "</p>"); sb.AppendLine(strFill); sb.AppendLine("</li>"); } else if (a != null) { sb.AppendLine("<li><p><strong>" + h(KPRes.WindowsUserAccount) + ":</strong></p>"); sb.Append(strFillInitEx); try { sb.Append(ne(h(ltrPath(Environment.UserDomainName + "\\" + Environment.UserName)))); } catch (Exception) { Debug.Assert(false); sb.Append(ne(string.Empty)); } sb.AppendLine(strFillEnd); sb.AppendLine("<p>" + h(KPRes.WindowsUserAccountBackup) + " " + h(KPRes.BackupLocation) + "</p>"); sb.AppendLine(strFill + "</li>"); } else if (c != null) { sb.AppendLine("<li><p><strong>" + h(KPRes.KeyProvider) + ":</strong></p>"); sb.AppendLine(strFillInitEx + ne(h(ltrPath(c.Name))) + strFillEnd); sb.AppendLine("</li>"); } else { Debug.Assert(false); sb.AppendLine("<li><p><strong>" + h(KPRes.Unknown) + ".</strong></p></li>"); } } sb.AppendLine("</ul>"); } sb.AppendLine("<br />"); sb.AppendLine("<h3>" + h(KPRes.InstrAndGenInfo) + "</h3>"); sb.AppendLine("<ul class=\"withspc\">"); sb.AppendLine("<li>" + h(KPRes.EmergencySheetInfo) + "</li>"); // sb.AppendLine("<form class=\"scronly\" action=\"#\" onsubmit=\"javascript:window.print();\">"); // sb.AppendLine("<input type=\"submit\" value=\"🖶 " + // h(KPRes.Print) + "\" />"); // sb.AppendLine("</form></li>"); sb.AppendLine("<li>" + h(KPRes.DataLoss) + "</li>"); sb.AppendLine("<li>" + h(KPRes.LatestVersionWeb) + ": <a href=\"" + h(PwDefs.HomepageUrl) + "\" target=\"_blank\">" + h(PwDefs.HomepageUrl) + "</a>.</li>"); sb.AppendLine("</ul>"); sb.AppendLine("</body></html>"); string strDoc = sb.ToString(); #if DEBUG XmlUtilEx.ValidateXml(strDoc, true); #endif return(strDoc); }
private static string GenerateHtml(PwDatabase pd, string strName) { StrToStrDelegate h = new StrToStrDelegate(StrUtil.StringToHtml); StrToStrDelegate ne = delegate(string str) { if (string.IsNullOrEmpty(str)) { return(" "); } return(str); }; StringBuilder sb = new StringBuilder(); bool bRtl = Program.Translation.Properties.RightToLeft; sb.AppendLine("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\""); sb.AppendLine("\t\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"); sb.Append("<html xmlns=\"http://www.w3.org/1999/xhtml\""); string strLang = Program.Translation.Properties.Iso6391Code; if (string.IsNullOrEmpty(strLang)) { strLang = "en"; } strLang = h(strLang); sb.Append(" lang=\"" + strLang + "\" xml:lang=\"" + strLang + "\""); if (bRtl) { sb.Append(" dir=\"rtl\""); } sb.AppendLine(">"); sb.AppendLine("<head>"); sb.AppendLine("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />"); sb.Append("<title>"); sb.Append(h(strName + " - " + KPRes.EmergencySheet)); sb.AppendLine("</title>"); sb.AppendLine("<meta http-equiv=\"expires\" content=\"0\" />"); sb.AppendLine("<meta http-equiv=\"cache-control\" content=\"no-cache\" />"); sb.AppendLine("<meta http-equiv=\"pragma\" content=\"no-cache\" />"); sb.AppendLine("<style type=\"text/css\"><!--"); sb.AppendLine("body, p, div, h1, h2, h3, h4, h5, h6, ol, ul, li, td, th, dd, dt, a {"); sb.AppendLine("\tfont-family: \"Arial\", \"Tahoma\", \"Verdana\", sans-serif;"); sb.AppendLine("\tfont-size: 12pt;"); sb.AppendLine("}"); sb.AppendLine("body, p, div, table {"); sb.AppendLine("\tcolor: #000000;"); sb.AppendLine("\tbackground-color: #FFFFFF;"); sb.AppendLine("}"); sb.AppendLine("p, h3 {"); sb.AppendLine("\tmargin: 0.5em 0em 0.5em 0em;"); sb.AppendLine("}"); sb.AppendLine("ol, ul {"); sb.AppendLine("\tmargin-bottom: 0em;"); sb.AppendLine("}"); sb.AppendLine("h1, h2, h3 {"); sb.AppendLine("\tfont-family: \"Verdana\", \"Arial\", \"Tahoma\", sans-serif;"); sb.AppendLine("}"); sb.AppendLine("h1, h2 {"); sb.AppendLine("\ttext-align: center;"); sb.AppendLine("\tmargin: 0pt 0pt 0pt 0pt;"); sb.AppendLine("}"); sb.AppendLine("h1 {"); sb.AppendLine("\tfont-size: 2em;"); sb.AppendLine("\tpadding: 3pt 0pt 0pt 0pt;"); sb.AppendLine("}"); sb.AppendLine("h2 {"); sb.AppendLine("\tfont-size: 1.5em;"); sb.AppendLine("\tpadding: 1pt 0pt 3pt 0pt;"); sb.AppendLine("}"); sb.AppendLine("h3 {"); sb.AppendLine("\tfont-size: 1.2em;"); // sb.AppendLine("\tpadding: 3pt 3pt 3pt 3pt;"); // sb.AppendLine("\tcolor: #000000;"); // sb.AppendLine("\tbackground-color: #EEEEEE;"); // sb.AppendLine("\tbackground-image: -webkit-linear-gradient(top, #E2E2E2, #FAFAFA);"); // sb.AppendLine("\tbackground-image: -moz-linear-gradient(top, #E2E2E2, #FAFAFA);"); // sb.AppendLine("\tbackground-image: -ms-linear-gradient(top, #E2E2E2, #FAFAFA);"); // sb.AppendLine("\tbackground-image: linear-gradient(to bottom, #E2E2E2, #FAFAFA);"); sb.AppendLine("}"); sb.AppendLine("h4 { font-size: 1em; }"); sb.AppendLine("h5 { font-size: 0.89em; }"); sb.AppendLine("h6 { font-size: 0.6em; }"); sb.AppendLine("a:visited {"); sb.AppendLine("\ttext-decoration: none;"); sb.AppendLine("\tcolor: #0000DD;"); sb.AppendLine("}"); sb.AppendLine("a:active {"); sb.AppendLine("\ttext-decoration: none;"); sb.AppendLine("\tcolor: #6699FF;"); sb.AppendLine("}"); sb.AppendLine("a:link {"); sb.AppendLine("\ttext-decoration: none;"); sb.AppendLine("\tcolor: #0000DD;"); sb.AppendLine("}"); sb.AppendLine("a:hover {"); sb.AppendLine("\ttext-decoration: underline;"); sb.AppendLine("\tcolor: #6699FF;"); sb.AppendLine("}"); sb.AppendLine("img {"); sb.AppendLine("\tborder: 0px none;"); sb.AppendLine("}"); sb.AppendLine(".withspc > li + li {"); sb.AppendLine("\tmargin-top: 0.5em;"); sb.AppendLine("}"); sb.AppendLine("table.docheader {"); sb.AppendLine("\twidth: 100%;"); sb.AppendLine("\tbackground-color: #EEEEEE;"); sb.AppendLine("\tmargin: 0px 0px 0px 0px;"); sb.AppendLine("\tpadding: 0px 0px 0px 0px;"); sb.AppendLine("\tborder: thin solid #808080;"); // border-collapse is incompatible with border-radius // sb.AppendLine("\tborder-collapse: collapse;"); sb.AppendLine("\t-webkit-border-radius: 5px;"); sb.AppendLine("\t-moz-border-radius: 5px;"); sb.AppendLine("\tborder-radius: 5px;"); sb.AppendLine("}"); sb.AppendLine("table.docheader tr td {"); sb.AppendLine("\tvertical-align: middle;"); sb.AppendLine("\tpadding: 0px 15px 0px 15px;"); sb.AppendLine("}"); sb.AppendLine("table.fillinline {"); sb.AppendLine("\twidth: 100%;"); sb.AppendLine("\tmargin: 0px 0px 0px 0px;"); sb.AppendLine("\tpadding: 0px 0px 0px 0px;"); sb.AppendLine("\tborder: thin solid #808080;"); sb.AppendLine("\tborder-collapse: collapse;"); sb.AppendLine("\tempty-cells: show;"); sb.AppendLine("}"); sb.AppendLine("table.fillinline tr td {"); sb.AppendLine("\tpadding: 4pt 4pt 4pt 4pt;"); sb.AppendLine("\tvertical-align: middle;"); sb.AppendLine("\tword-break: break-all;"); sb.AppendLine("\toverflow-wrap: break-word;"); sb.AppendLine("\tword-wrap: break-word;"); sb.AppendLine("}"); // sb.AppendLine("span.fillinlinesym {"); // sb.AppendLine("\tdisplay: inline-block;"); // sb.AppendLine("\ttransform: scale(1.75, 1.75) translate(-0.5pt, -0.5pt);"); // sb.AppendLine("}"); // sb.AppendLine("@media print {"); // sb.AppendLine(".scronly {"); // sb.AppendLine("\tdisplay: none;"); // sb.AppendLine("}"); // sb.AppendLine("}"); // Add the temporary content identifier sb.AppendLine("." + Program.TempFilesPool.TempContentTag + " {"); sb.AppendLine("\tfont-size: 12pt;"); sb.AppendLine("}"); sb.AppendLine("--></style>"); sb.AppendLine("</head><body>"); ImageArchive ia = new ImageArchive(); ia.Load(Properties.Resources.Images_App_HighRes); sb.AppendLine("<table class=\"docheader\" cellspacing=\"0\" cellpadding=\"0\"><tr>"); sb.AppendLine("<td style=\"text-align: left;\">"); sb.AppendLine("<img src=\"" + GfxUtil.ImageToDataUri(ia.GetForObject( "KeePass")) + "\" width=\"48\" height=\"48\" alt=\"" + h(PwDefs.ShortProductName) + "\" /></td>"); sb.AppendLine("<td style=\"text-align: center;\">"); sb.AppendLine("<h1>" + h(PwDefs.ShortProductName) + "</h1>"); sb.AppendLine("<h2>" + h(KPRes.EmergencySheet) + "</h2>"); sb.AppendLine("</td>"); sb.AppendLine("<td style=\"text-align: right;\">"); sb.AppendLine("<img src=\"" + GfxUtil.ImageToDataUri(ia.GetForObject( "KOrganizer")) + "\" width=\"48\" height=\"48\" alt=\"" + h(KPRes.EmergencySheet) + "\" /></td>"); sb.AppendLine("</tr></table>"); sb.AppendLine("<p style=\"text-align: right;\">" + h( TimeUtil.ToDisplayStringDateOnly(DateTime.Now)) + "</p>"); const string strFillInit = "<table class=\"fillinline\"><tr><td>"; const string strFillEnd = "</td></tr></table>"; string strFillSym = "<img src=\"" + GfxUtil.ImageToDataUri( Properties.Resources.B48x35_WritingHand) + "\" style=\"width: 1.3714em; height: 1em;\" alt=\"✍\" />"; string strFill = strFillInit + ne(string.Empty) + // "</td><td style=\"text-align: right;\"><span class=\"fillinlinesym\">✍</span>" + "</td><td style=\"text-align: right;\">" + strFillSym + strFillEnd; IOConnectionInfo ioc = pd.IOConnectionInfo; sb.AppendLine("<p><strong>" + h(KPRes.DatabaseFile) + ":</strong></p>"); sb.AppendLine(strFillInit + ne(h(ioc.Path)) + strFillEnd); // if(pd.Name.Length > 0) // sb.AppendLine("<p><strong>" + h(KPRes.Name) + ":</strong> " + // h(pd.Name) + "</p>"); // if(pd.Description.Length > 0) // sb.AppendLine("<p><strong>" + h(KPRes.Description) + ":</strong> " + // h(pd.Description)); sb.AppendLine("<p>" + h(KPRes.BackupDatabase) + " " + h(KPRes.BackupLocation) + "</p>"); sb.AppendLine(strFill); CompositeKey ck = pd.MasterKey; if (ck.UserKeyCount > 0) { sb.AppendLine("<br />"); sb.AppendLine("<h3>" + h(KPRes.MasterKey) + "</h3>"); sb.AppendLine("<p>" + h(KPRes.MasterKeyComponents) + "</p>"); sb.AppendLine("<ul>"); foreach (IUserKey k in ck.UserKeys) { KcpPassword p = (k as KcpPassword); KcpKeyFile kf = (k as KcpKeyFile); KcpUserAccount a = (k as KcpUserAccount); KcpCustomKey c = (k as KcpCustomKey); if (p != null) { sb.AppendLine("<li><p><strong>" + h(KPRes.MasterPassword) + ":</strong></p>"); sb.AppendLine(strFill + "</li>"); } else if (kf != null) { sb.AppendLine("<li><p><strong>" + h(KPRes.KeyFile) + ":</strong></p>"); sb.AppendLine(strFillInit + ne(h(kf.Path)) + strFillEnd); sb.AppendLine("<p>" + h(KPRes.BackupFile) + " " + h(KPRes.BackupLocation) + "</p>"); sb.AppendLine(strFill); sb.AppendLine("</li>"); } else if (a != null) { sb.AppendLine("<li><p><strong>" + h(KPRes.WindowsUserAccount) + ":</strong></p>"); sb.Append(strFillInit); try { sb.Append(ne(h(Environment.UserDomainName + "\\" + Environment.UserName))); } catch (Exception) { Debug.Assert(false); sb.Append(ne(string.Empty)); } sb.AppendLine(strFillEnd); sb.AppendLine("<p>" + h(KPRes.WindowsUserAccountBackup) + " " + h(KPRes.BackupLocation) + "</p>"); sb.AppendLine(strFill + "</li>"); } else if (c != null) { sb.AppendLine("<li><p><strong>" + h(KPRes.KeyProvider) + ":</strong></p>"); sb.AppendLine(strFillInit + ne(h(c.Name)) + strFillEnd); sb.AppendLine("</li>"); } else { Debug.Assert(false); sb.AppendLine("<li><p><strong>" + h(KPRes.Unknown) + ".</strong></p></li>"); } } sb.AppendLine("</ul>"); } sb.AppendLine("<br />"); sb.AppendLine("<h3>" + h(KPRes.InstrAndGenInfo) + "</h3>"); sb.AppendLine("<ul class=\"withspc\">"); sb.AppendLine("<li>" + h(KPRes.EmergencySheetInfo) + "</li>"); // sb.AppendLine("<form class=\"scronly\" action=\"#\" onsubmit=\"javascript:window.print();\">"); // sb.AppendLine("<input type=\"submit\" value=\"🖶 " + // h(KPRes.Print) + "\" />"); // sb.AppendLine("</form></li>"); sb.AppendLine("<li>" + h(KPRes.DataLoss) + "</li>"); sb.AppendLine("<li>" + h(KPRes.LatestVersionWeb) + ": <a href=\"" + h(PwDefs.HomepageUrl) + "\" target=\"_blank\">" + h(PwDefs.HomepageUrl) + "</a>.</li>"); sb.AppendLine("</ul>"); sb.AppendLine("</body></html>"); return(sb.ToString()); }
/// <summary> /// Returns -1 on config error, 0 on success. /// </summary> /// <param name="args"></param> /// <returns></returns> static int Main(string[] args) { Console.Title = "Demoder's GUI Compiler (Console) v" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); DateTime starttime = DateTime.Now; Console.WriteLine("Checking configuration parameters"); CommandLineParameters cmdParams = new CommandLineParameters(args); uint batch = cmdParams.LongFlag("batch"); //Source directory. DirectoryInfo srcDir = null; if (!String.IsNullOrEmpty(cmdParams.Argument("srcdir"))) { if (Directory.Exists(cmdParams.Argument("srcdir"))) { srcDir = new DirectoryInfo(cmdParams.Argument("srcdir")); } } if (srcDir == null) { Console.WriteLine("You need to provide a source directory containing the GUI image files: --srcdir=\"directory\""); if (batch == 0) { Console.ReadLine(); } return(-1); } else { Console.WriteLine(" Source Directory: {0} ", srcDir); } //Destination directory. DirectoryInfo dstDir = null; if (!String.IsNullOrEmpty(cmdParams.Argument("dstdir"))) { dstDir = new DirectoryInfo(cmdParams.Argument("dstdir")); } if (dstDir == null) { Console.WriteLine("You need to provide a directory to store the archive to: --dstdir=\"directory\""); if (batch == 0) { Console.ReadLine(); } return(-1); } else { Console.WriteLine(" Destination Directory: {0} ", dstDir); } //Destination directory. string archiveName = null; if (!String.IsNullOrEmpty(cmdParams.Argument("name"))) { archiveName = cmdParams.Argument("name"); } if (archiveName == null) { Console.WriteLine("You need to provide an archive name (without extension): --name=\"archivename\""); if (batch == 0) { Console.ReadLine(); } return(-1); } else { Console.WriteLine(" Archive Name: {0} ", archiveName); } Console.WriteLine(); Console.WriteLine(" Loading images"); ImageArchive ia = new ImageArchive(); int imgloaded = ia.Add(srcDir); Console.WriteLine(" {0} images loaded.", imgloaded); Console.WriteLine("Saving archive"); ia.Save(dstDir, archiveName); Console.WriteLine("\nDone.\n Archive: {1} KiB.\n Index: {2} KiB\n Worktime: {0} seconds.", Math.Round((DateTime.Now - starttime).TotalSeconds, 3), Math.Round((double)(new FileInfo(dstDir.FullName + Path.DirectorySeparatorChar + archiveName + ".UVGA").Length) / 1024), Math.Round((double)(new FileInfo(dstDir.FullName + Path.DirectorySeparatorChar + archiveName + ".UVGI").Length) / 1024)); if (batch == 0) { Console.ReadLine(); } return(0); }
public static DateTime GetStartDate(this ImageArchive imageArchive) { return(DateTimeHelper.Parse(imageArchive.StartDate)); }
public static void LoadArchive(String filePath) { stLoadedArchives.Add(ImageArchive.Load(filePath)); }