diff options
author | Michael Vrhel <michael.vrhel@artifex.com> | 2014-05-14 23:22:39 -0700 |
---|---|---|
committer | Michael Vrhel <michael.vrhel@artifex.com> | 2014-09-09 16:39:37 -0700 |
commit | 80d82a6f9fadbb57a0ac0de945dfd9145a837b8b (patch) | |
tree | 3fe4ca9c914cf6e211e96e1b188331628beef928 /platform/winrt | |
parent | 345d7e3daa98580e9cd54d002ff0d0611867b65d (diff) | |
download | mupdf-80d82a6f9fadbb57a0ac0de945dfd9145a837b8b.tar.xz |
Addition of registry for storing program state. Plus open with for gsview.
Also addition of AA on/off control.
Diffstat (limited to 'platform/winrt')
-rw-r--r-- | platform/winrt/gsview/DocPage.cs | 11 | ||||
-rw-r--r-- | platform/winrt/gsview/Install64/Install64.vdproj | 53 | ||||
-rw-r--r-- | platform/winrt/gsview/Links.cs | 2 | ||||
-rw-r--r-- | platform/winrt/gsview/MainWindow.xaml | 4 | ||||
-rw-r--r-- | platform/winrt/gsview/MainWindow.xaml.cs | 137 | ||||
-rw-r--r-- | platform/winrt/gsview/mudocument.cs | 48 | ||||
-rw-r--r-- | platform/winrt/mupdfnet/mupdfnet.cpp | 6 | ||||
-rw-r--r-- | platform/winrt/mupdfnet/mupdfnet.h | 2 | ||||
-rw-r--r-- | platform/winrt/mupdfwinrt/muctx.cpp | 5 | ||||
-rw-r--r-- | platform/winrt/mupdfwinrt/muctx.h | 1 |
10 files changed, 245 insertions, 24 deletions
diff --git a/platform/winrt/gsview/DocPage.cs b/platform/winrt/gsview/DocPage.cs index 97391b40..a4f01662 100644 --- a/platform/winrt/gsview/DocPage.cs +++ b/platform/winrt/gsview/DocPage.cs @@ -201,6 +201,12 @@ namespace gsview set { pagenum = value; } } + public bool AA + { + get; + set; + } + public event PropertyChangedEventHandler PropertyChanged; // Create the OnPropertyChanged method to raise the event @@ -227,11 +233,13 @@ namespace gsview this.PageNum = -1; this.PageName = ""; this.TextBlocks = null; + this.AA = true; } public DocPage(int Height, int Width, double Zoom, BitmapSource BitMap, List<RectList> TextBox, List<RectList> LinkBox, - Page_Content_t Content, int PageNum, BlocksText TextBlocks) + Page_Content_t Content, int PageNum, BlocksText TextBlocks, + bool AA) { this.Height = Height; this.Width = Width; @@ -243,6 +251,7 @@ namespace gsview this.PageNum = PageNum; this.PageName = ("Page " + (PageNum + 1)); this.TextBlocks = TextBlocks; + this.AA = AA; } }; public class Pages : ObservableCollection<DocPage> diff --git a/platform/winrt/gsview/Install64/Install64.vdproj b/platform/winrt/gsview/Install64/Install64.vdproj index 6139218b..25fceb9f 100644 --- a/platform/winrt/gsview/Install64/Install64.vdproj +++ b/platform/winrt/gsview/Install64/Install64.vdproj @@ -55,6 +55,14 @@ "PrivateKeyFile" = "8:" "TimeStampServer" = "8:" "InstallerBootstrapper" = "3:2" + "BootstrapperCfg:{63ACBE69-63AA-4F98-B2B6-99F9E24495F2}" + { + "Enabled" = "11:TRUE" + "PromptEnabled" = "11:TRUE" + "PrerequisitesLocation" = "2:1" + "Url" = "8:" + "ComponentsUrl" = "8:" + } } "Release" { @@ -71,6 +79,22 @@ "PrivateKeyFile" = "8:" "TimeStampServer" = "8:" "InstallerBootstrapper" = "3:2" + "BootstrapperCfg:{63ACBE69-63AA-4F98-B2B6-99F9E24495F2}" + { + "Enabled" = "11:TRUE" + "PromptEnabled" = "11:TRUE" + "PrerequisitesLocation" = "2:1" + "Url" = "8:" + "ComponentsUrl" = "8:" + "Items" + { + "{EDC2488A-8267-493A-A98E-7D9C3B36CDF3}:.NETFramework,Version=v4.5" + { + "Name" = "8:Microsoft .NET Framework 4.5 (x86 and x64)" + "ProductCode" = "8:.NETFramework,Version=v4.5" + } + } + } } } "Deployable" @@ -174,6 +198,29 @@ } "FileType" { + "{5EB83D71-FA18-4901-BE56-DE22E13CC478}:_A8EDD49D509A4974B971BF4FBD093455" + { + "Name" = "8:PDF" + "Description" = "8:PDF" + "Extensions" = "8:pdf;ps;eps;xps;oxps;png;jpeg;jpg;cbz" + "MIME" = "8:" + "Icon" = "8:_44A71C9401B94929A3DF6828309FE684" + "IconIndex" = "3:32512" + "Command" + { + "Command" = "8:_44A71C9401B94929A3DF6828309FE684" + } + "Verbs" + { + "{95C0C507-CBF0-42B8-B119-07219E384A4A}:_9396BB7A2A2841B0890D2DB6A6360F4E" + { + "Command" = "8:&Open" + "Verb" = "8:open" + "Arguments" = "8:\"%1\"" + "Order" = "3:0" + } + } + } } "Folder" { @@ -237,9 +284,9 @@ "Product" { "Name" = "8:Microsoft Visual Studio" - "ProductName" = "8:GSview 6.0 " + "ProductName" = "8:GSview 6.0" "ProductCode" = "8:{A22596C0-BCF4-46F9-9CF2-1C66E8588C30}" - "PackageCode" = "8:{9134FE53-5F05-449C-9B39-317BDE645FA5}" + "PackageCode" = "8:{2D4D7754-2AE5-45B4-B5CD-D3672BA861A7}" "UpgradeCode" = "8:{B494B7A2-738F-4F9D-87F4-31830A16FB76}" "AspNetVersion" = "8:4.0.30319.0" "RestartWWWService" = "11:FALSE" @@ -689,7 +736,7 @@ "Type" = "3:8" "ContextData" = "8:Bitmap" "Attributes" = "3:4" - "Setting" = "3:1" + "Setting" = "3:0" "UsePlugInResources" = "11:TRUE" } "CopyrightWarning" diff --git a/platform/winrt/gsview/Links.cs b/platform/winrt/gsview/Links.cs index 4dc69086..ef902381 100644 --- a/platform/winrt/gsview/Links.cs +++ b/platform/winrt/gsview/Links.cs @@ -18,8 +18,6 @@ namespace gsview class Links { link_t type; - //PointF upper_left; - //PointF lower_right; Uri uri; int page_num; diff --git a/platform/winrt/gsview/MainWindow.xaml b/platform/winrt/gsview/MainWindow.xaml index 21bbbde3..2b048ee5 100644 --- a/platform/winrt/gsview/MainWindow.xaml +++ b/platform/winrt/gsview/MainWindow.xaml @@ -3,7 +3,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="gsview" Height="850" Width="714" UseLayoutRounding="True" - KeyDown="OnKeyDownHandler"> + KeyDown="OnKeyDownHandler" Closing="AppClosing"> <!-- UseLayoutRounding needed to avoid funny interpolation effects on pages --> <Window.Resources> @@ -217,7 +217,7 @@ <MenuItem Header="_Options"> <MenuItem Header="Output Intents" Click="OutputIntents" /> <MenuItem Header="Zoom Control" IsCheckable="true" Checked="ShowFooter" Unchecked="HideFooter"/> - <MenuItem Header="Enable AntiAlias" IsCheckable="True" IsChecked="True" Checked="OnAAChecked"/> + <MenuItem x:Name="xaml_AA" Header="Enable AntiAlias" IsCheckable="True" IsChecked="True" Checked="OnAAChecked" Unchecked="OnAAChecked"/> </MenuItem> <MenuItem Header="_Help"> diff --git a/platform/winrt/gsview/MainWindow.xaml.cs b/platform/winrt/gsview/MainWindow.xaml.cs index e3a8542a..cb98f25a 100644 --- a/platform/winrt/gsview/MainWindow.xaml.cs +++ b/platform/winrt/gsview/MainWindow.xaml.cs @@ -20,6 +20,7 @@ using System.Windows.Xps.Packaging; using System.Printing; using System.Windows.Markup; using System.Runtime.InteropServices; +using Microsoft.Win32; /* For registry */ enum PDFType_t { @@ -212,6 +213,7 @@ namespace gsview double m_doczoom; ghostsharp m_ghostscript; String m_currfile; + String m_origfile; private gsprint m_ghostprint = null; bool m_isXPS; gsOutput m_gsoutput; @@ -238,12 +240,16 @@ namespace gsview double m_maxY; bool m_ignorescrollchange; double m_totalpageheight; + bool m_AA; + bool m_regstartup; + int m_initpage; public MainWindow() { InitializeComponent(); this.Closing += new System.ComponentModel.CancelEventHandler(Window_Closing); m_file_open = false; + m_regstartup = true; status_t result = CleanUp(); /* Allocations and set up */ @@ -269,7 +275,18 @@ namespace gsview xaml_PageGrid.AddHandler(Grid.DragOverEvent, new System.Windows.DragEventHandler(Grid_DragOver), true); xaml_PageGrid.AddHandler(Grid.DropEvent, new System.Windows.DragEventHandler(Grid_Drop), true); DimSelections(); - /* Set up for windows forms control */ + + string[] arguments = Environment.GetCommandLineArgs(); + if (arguments.Length > 1) + { + string filePath = arguments[1]; + ProcessFile(filePath); + } + else + { + if (m_regstartup) + InitFromRegistry(); + } } catch (OutOfMemoryException e) { @@ -461,9 +478,78 @@ namespace gsview CloseExtraWindows(false); ResetScroll(); m_totalpageheight = 0; + m_AA = xaml_AA.IsChecked; + m_origfile = null; + m_initpage = 0; return result; } + /* Initialize from registry */ + private void InitFromRegistry() + { + RegistryKey key = Registry.CurrentUser.CreateSubKey("Software"); + RegistryKey keyA = key.CreateSubKey("Artifex Software"); + RegistryKey keygs = keyA.CreateSubKey("GSview 6.0"); + String filepath = null; + Int32 page; + bool aa_on = true; + + try + { + filepath = (String)keygs.GetValue("File", null); + aa_on = System.Convert.ToBoolean((Int32) keygs.GetValue("AA")); + page = (Int32)keygs.GetValue("Page"); + } + catch + { + return; + } + keygs.Close(); + keyA.Close(); + key.Close(); + + xaml_AA.IsChecked = aa_on; + m_AA = aa_on; + + if (filepath != null && File.Exists(filepath)) + { + m_initpage = page; + ProcessFile(filepath); + } + else + m_initpage = 0; + } + + private void SetRegistry() + { + if (m_currfile == null) + return; + + RegistryKey key = Registry.CurrentUser.CreateSubKey("Software"); + RegistryKey keyA = key.CreateSubKey("Artifex Software"); + RegistryKey keygs = keyA.CreateSubKey("GSview 6.0"); + + if (m_origfile != null && (m_document_type == DocumentTypes.PS || + m_document_type == DocumentTypes.EPS)) + { + keygs.SetValue("File", m_origfile, RegistryValueKind.String); + } + else + { + keygs.SetValue("File", m_currfile, RegistryValueKind.String); + } + keygs.SetValue("Page", m_currpage, RegistryValueKind.DWord); + keygs.SetValue("AA", System.Convert.ToInt32(xaml_AA.IsChecked), RegistryValueKind.DWord); + keygs.Close(); + keyA.Close(); + key.Close(); + } + + private void AppClosing(object sender, CancelEventArgs e) + { + SetRegistry(); + } + private void ShowMessage(NotifyType_t type, String Message) { if (type == NotifyType_t.MESS_ERROR) @@ -485,7 +571,7 @@ namespace gsview /* Set the page with the new raster information */ private void UpdatePage(int page_num, Byte[] bitmap, Point ras_size, - Page_Content_t content, double zoom_in) + Page_Content_t content, double zoom_in, bool AA) { DocPage doc_page = this.m_docPages[page_num]; @@ -496,8 +582,10 @@ namespace gsview doc_page.Zoom = zoom_in; int stride = doc_page.Width * 4; - doc_page.BitMap = BitmapSource.Create(doc_page.Width, doc_page.Height, 72, 72, PixelFormats.Pbgra32, BitmapPalettes.Halftone256, bitmap, stride); + doc_page.BitMap = BitmapSource.Create(doc_page.Width, doc_page.Height, + 72, 72, PixelFormats.Pbgra32, BitmapPalettes.Halftone256, bitmap, stride); doc_page.PageNum = page_num; + doc_page.AA = AA; if (content == Page_Content_t.THUMBNAIL) { @@ -529,7 +617,7 @@ namespace gsview return; } - OpenFileDialog dlg = new OpenFileDialog(); + System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog(); dlg.Filter = "Document Files(*.ps;*.eps;*.pdf;*.xps;*.cbz)|*.ps;*.eps;*.pdf;*.xps;*.cbz|All files (*.*)|*.*"; dlg.FilterIndex = 1; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) @@ -711,7 +799,7 @@ namespace gsview m_textset[k] = true; m_textptrs[k] = result.charlist; m_docPages[k].TextBlocks = result.charlist; - UpdatePage(k, result.bitmap, result.size, Page_Content_t.FULL_RESOLUTION, 1.0); + UpdatePage(k, result.bitmap, result.size, Page_Content_t.FULL_RESOLUTION, 1.0, m_AA); m_docPages[k].NativeHeight = (int) result.size.Y; m_docPages[k].NativeWidth = (int)result.size.X; } @@ -1103,7 +1191,7 @@ namespace gsview /* Check if page is already rendered */ var doc = m_docPages[k]; if (doc.Content != Page_Content_t.FULL_RESOLUTION || - doc.Zoom != m_doczoom) + doc.Zoom != m_doczoom || m_AA != doc.AA) { Point ras_size; double scale_factor = m_doczoom; @@ -1175,7 +1263,7 @@ namespace gsview ScrollPageToTop(new_page, zoom_offset, false); } UpdatePage(k, bitmap, ras_size, - Page_Content_t.FULL_RESOLUTION, m_doczoom); + Page_Content_t.FULL_RESOLUTION, m_doczoom, m_AA); if (k == new_page && scrollto && new_page != m_currpage) { m_doscroll = true; @@ -1279,6 +1367,10 @@ namespace gsview xaml_open.IsEnabled = false; xaml_file.Opacity = 0.5; xaml_file.IsEnabled = false; + /* And to drag - drop or registry start up */ + xaml_PageGrid.RemoveHandler(Grid.DragOverEvent, new System.Windows.DragEventHandler(Grid_DragOver)); + xaml_PageGrid.RemoveHandler(Grid.DropEvent, new System.Windows.DragEventHandler(Grid_Drop)); + m_regstartup = false; } private void gsIO(object gsObject, String mess, int len) @@ -1376,6 +1468,7 @@ namespace gsview case GS_Task_t.PS_DISTILL: xaml_DistillGrid.Visibility = System.Windows.Visibility.Collapsed; + m_origfile = gs_result.inputfile; OpenFile2(gs_result.outputfile); break; @@ -1520,7 +1613,7 @@ namespace gsview } /* Get a filename */ - SaveFileDialog dlg = new SaveFileDialog(); + System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog(); dlg.Filter = "All files (*.*)|*.*"; dlg.FilterIndex = 1; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) @@ -1647,7 +1740,7 @@ namespace gsview } /* Get a filename */ - SaveFileDialog dlg = new SaveFileDialog(); + System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog(); dlg.Filter = "All files (*.pdf)|*.pdf"; dlg.FilterIndex = 1; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) @@ -1689,8 +1782,16 @@ namespace gsview if (m_file_open) { + String filename; + + if (m_origfile != null && (m_document_type == DocumentTypes.PS || + m_document_type == DocumentTypes.EPS)) + filename = m_origfile; + else + filename = m_currfile; + Message = - " File: " + m_currfile + "\n" + + " File: " + filename + "\n" + "Document Type: " + m_document_type + "\n" + " Pages: " + m_num_pages + "\n" + " Current Page: " + (m_currpage + 1) + "\n"; @@ -2062,7 +2163,7 @@ namespace gsview var bitmap = System.Windows.Clipboard.GetImage(); BitmapEncoder encoder; - SaveFileDialog dlg = new SaveFileDialog(); + System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog(); dlg.FilterIndex = 1; switch (tag) @@ -2157,7 +2258,7 @@ namespace gsview if (!m_file_open) return; - SaveFileDialog dlg = new SaveFileDialog(); + System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog(); dlg.FilterIndex = 1; /* PDF output types */ @@ -2442,7 +2543,7 @@ namespace gsview /* Do the actual extraction */ String options; - SaveFileDialog dlg = new SaveFileDialog(); + System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog(); dlg.FilterIndex = 1; /* Get us set up to do a fixed size */ @@ -4113,7 +4214,11 @@ namespace gsview private void OnAAChecked(object sender, RoutedEventArgs e) { - + m_AA = xaml_AA.IsChecked; + if (mu_doc != null) + mu_doc.SetAA(m_AA); + if (m_init_done) + RenderRange(m_currpage, false, false, 0); } private void OnKeyDownHandler(object sender, System.Windows.Input.KeyEventArgs e) @@ -4140,14 +4245,14 @@ namespace gsview if (!m_init_done) return; e.Handled = true; - OffsetScroll(-Constants.VERT_SCROLL_STEP); + OffsetScroll(-Constants.VERT_SCROLL_STEP * m_doczoom); break; case Key.Down: if (!m_init_done) return; e.Handled = true; - OffsetScroll(Constants.VERT_SCROLL_STEP); + OffsetScroll(Constants.VERT_SCROLL_STEP * m_doczoom); break; } } diff --git a/platform/winrt/gsview/mudocument.cs b/platform/winrt/gsview/mudocument.cs index f2c6f4e7..e0c56ea6 100644 --- a/platform/winrt/gsview/mudocument.cs +++ b/platform/winrt/gsview/mudocument.cs @@ -134,6 +134,10 @@ namespace gsview CallingConvention = CallingConvention.StdCall)] private static extern void mReleaseContents64(); + [DllImport("mupdfnet64.dll", EntryPoint = "mSetAA", CharSet = CharSet.Auto, + CallingConvention = CallingConvention.StdCall)] + private static extern void mSetAA64(IntPtr ctx, int level); + /* The managed code Marshal actually releases the allocated string from C */ [DllImport("mupdfnet64.dll", EntryPoint = "mGetContentsItem", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] @@ -268,6 +272,10 @@ namespace gsview CallingConvention = CallingConvention.StdCall)] private static extern void mReleaseContents32(); + [DllImport("mupdfnet32.dll", EntryPoint = "mSetAA", CharSet = CharSet.Auto, + CallingConvention = CallingConvention.StdCall)] + private static extern void mSetAA32(IntPtr ctx, int level); + /* The managed code Marshal actually releases the allocated string from C */ [DllImport("mupdfnet32.dll", EntryPoint = "mGetContentsItem", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] @@ -692,6 +700,32 @@ namespace gsview return output; } + private int tc_mSetAA(IntPtr ctx, int level) + { + try + { + if (is64bit) + mSetAA64(ctx, level); + else + mSetAA32(ctx, level); + } + catch (DllNotFoundException) + { + /* DLL not found */ + String err = "DllNotFoundException: MuPDF DLL not found"; + mupdfDLLProblemMain(this, err); + return -1; + } + catch (BadImageFormatException) + { + /* Using 32 bit with 64 or vice versa */ + String err = "BadImageFormatException: Incorrect MuPDF DLL"; + mupdfDLLProblemMain(this, err); + return -1; + } + return 0; + } + private IntPtr tc_mCreateDisplayListText(IntPtr ctx, int page_num, ref int page_width, ref int page_height, ref IntPtr text, ref int length) { @@ -1165,6 +1199,20 @@ namespace gsview return tc_mApplyPassword(mu_object, password); } + public void SetAA(bool AAon) + { + if (AAon) + lock (m_lock) + { + tc_mSetAA(mu_object, 8); + } + else + lock (m_lock) + { + tc_mSetAA(mu_object, 0); + } + } + public int RenderPage(int page_num, Byte[] bmp_data, int bmp_width, int bmp_height, double scale, bool flipy, bool use_dlist, bool get_text, out BlocksText blocks) diff --git a/platform/winrt/mupdfnet/mupdfnet.cpp b/platform/winrt/mupdfnet/mupdfnet.cpp index 53518764..c52b5b1e 100644 --- a/platform/winrt/mupdfnet/mupdfnet.cpp +++ b/platform/winrt/mupdfnet/mupdfnet.cpp @@ -189,6 +189,12 @@ SYMBOL_DECLSPEC int __stdcall mGetLinksPage(void *ctx, int page_num) return mu_ctx->GetLinks(page_num, gLinkResults); } +SYMBOL_DECLSPEC void __stdcall mSetAA(void *ctx, int level) +{ + muctx *mu_ctx = static_cast<muctx*>(ctx); + mu_ctx->SetAA(level); +} + SYMBOL_DECLSPEC char* __stdcall mGetVers() { int len = strlen(FZ_VERSION); diff --git a/platform/winrt/mupdfnet/mupdfnet.h b/platform/winrt/mupdfnet/mupdfnet.h index 927a34e2..0f2915a2 100644 --- a/platform/winrt/mupdfnet/mupdfnet.h +++ b/platform/winrt/mupdfnet/mupdfnet.h @@ -65,6 +65,8 @@ EXTERN_C SYMBOL_DECLSPEC int __stdcall mGetTextCharacter(void *text, int block_n EXTERN_C SYMBOL_DECLSPEC void __stdcall mReleaseText(void *ctx, void *page); +EXTERN_C SYMBOL_DECLSPEC void __stdcall mSetAA(void *ctx, int level); + /* pdfclean methods */ EXTERN_C SYMBOL_DECLSPEC int __stdcall mExtractPages(PCWSTR infile, PCWSTR outfile, PCWSTR password, bool has_password, bool linearize, int num_pages, void *pages); diff --git a/platform/winrt/mupdfwinrt/muctx.cpp b/platform/winrt/mupdfwinrt/muctx.cpp index f7dfd20b..4153c1db 100644 --- a/platform/winrt/mupdfwinrt/muctx.cpp +++ b/platform/winrt/mupdfwinrt/muctx.cpp @@ -158,6 +158,11 @@ void muctx::CleanUp(void) this->mu_outline = NULL; } +void muctx::SetAA(int level) +{ + fz_set_aa_level(mu_ctx, level); +} + /* Set up the context, mutex and cookie */ status_t muctx::InitializeContext() { diff --git a/platform/winrt/mupdfwinrt/muctx.h b/platform/winrt/mupdfwinrt/muctx.h index 8db81f1d..2e95fc61 100644 --- a/platform/winrt/mupdfwinrt/muctx.h +++ b/platform/winrt/mupdfwinrt/muctx.h @@ -101,6 +101,7 @@ public: int MeasurePage(int page_num, point_t *size); point_t MeasurePage(fz_page *page); unsigned int GetLinks(int page_num, sh_vector_link links_vec); + void SetAA(int level); int GetTextSearch(int page_num, char* needle, sh_vector_text texts_vec); int GetContents(sh_vector_content contents_vec); std::string GetHTML(int page_num); |