summaryrefslogtreecommitdiff
path: root/winrt/winapp
diff options
context:
space:
mode:
Diffstat (limited to 'winrt/winapp')
-rw-r--r--winrt/winapp/MainPage.xaml9
-rw-r--r--winrt/winapp/MainPage.xaml.cpp114
-rw-r--r--winrt/winapp/MainPage.xaml.h16
-rw-r--r--winrt/winapp/winapp.vcxproj2
4 files changed, 115 insertions, 26 deletions
diff --git a/winrt/winapp/MainPage.xaml b/winrt/winapp/MainPage.xaml
index d7feaeac..011bd8d7 100644
--- a/winrt/winapp/MainPage.xaml
+++ b/winrt/winapp/MainPage.xaml
@@ -6,7 +6,8 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
- <Page.BottomAppBar>
+
+ <Page.BottomAppBar>
<AppBar>
<Grid Margin="38,0,0,0">
<Grid.ColumnDefinitions>
@@ -19,14 +20,13 @@
</AppBar>
</Page.BottomAppBar>
<Page.TopAppBar>
- <AppBar x:Name="TopAppBar1" AutomationProperties.Name="Top App Bar">
+ <AppBar x:Name="TopAppBar1" AutomationProperties.Name="Top App Bar" Loaded="topAppBar_Loaded">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel x:Name="LeftPanel" Orientation="Horizontal">
-
</StackPanel>
<StackPanel x:Name="RightPanel" Orientation="Horizontal" HorizontalAlignment="Right">
<Button x:Name="Search" Style="{StaticResource SearchAppBarButtonStyle}" Tag="Search" Click="Searcher"/>
@@ -38,6 +38,7 @@
</Grid>
</AppBar>
</Page.TopAppBar>
+
<Grid x:Name="xaml_OutsideGrid">
<Grid.Background>
<LinearGradientBrush EndPoint="-0.074,-0.068" StartPoint="1.027,1.024">
@@ -112,4 +113,4 @@
</RichEditBox>
</StackPanel>
</Grid>
- </Page>
+</Page>
diff --git a/winrt/winapp/MainPage.xaml.cpp b/winrt/winapp/MainPage.xaml.cpp
index e93682f7..a649d1e5 100644
--- a/winrt/winapp/MainPage.xaml.cpp
+++ b/winrt/winapp/MainPage.xaml.cpp
@@ -105,19 +105,6 @@ MainPage::MainPage()
ctx = fz_new_context(NULL, NULL, 128<<20);
}
-void run_async_non_interactive(std::function<void ()>&& action)
-{
- Windows::UI::Core::CoreWindow^ wnd = Windows::ApplicationModel::Core::CoreApplication::MainView->CoreWindow;
- assert(wnd != nullptr);
-
- wnd->Dispatcher->RunAsync(
- Windows::UI::Core::CoreDispatcherPriority::Low,
- ref new Windows::UI::Core::DispatchedHandler([action]()
- {
- action();
- }));
-}
-
/// <summary>
/// Invoked when this page is about to be displayed in a Frame.
/// </summary>
@@ -128,9 +115,69 @@ void MainPage::OnNavigatedTo(NavigationEventArgs^ e)
(void) e; // Unused parameter
}
+void winapp::MainPage::ExitInvokedHandler(Windows::UI::Popups::IUICommand^ command)
+{
+
+}
+
+void winapp::MainPage::OKInvokedHandler(Windows::UI::Popups::IUICommand^ command)
+{
+
+}
+
+void winapp::MainPage::NotifyUser(String^ strMessage, NotifyType_t type)
+{
+ MessageDialog^ msg = ref new MessageDialog(strMessage);
+ UICommand^ ExitCommand = nullptr;
+ UICommand^ OKCommand = nullptr;
+
+ switch (type)
+ {
+ case StatusMessage:
+ OKCommand = ref new UICommand("OK",
+ ref new UICommandInvokedHandler(this, &winapp::MainPage::OKInvokedHandler));
+ msg->Commands->Append(OKCommand);
+ /// Set the command that will be invoked by default
+ msg->DefaultCommandIndex = 0;
+ // Set the command to be invoked when escape is pressed
+ msg->CancelCommandIndex = 1;
+ break;
+ case ErrorMessage:
+ ExitCommand = ref new UICommand("Exit",
+ ref new UICommandInvokedHandler(this, &winapp::MainPage::ExitInvokedHandler));
+ msg->Commands->Append(ExitCommand);
+ /// Set the command that will be invoked by default
+ msg->DefaultCommandIndex = 0;
+ // Set the command to be invoked when escape is pressed
+ msg->CancelCommandIndex = 1;
+ break;
+ default:
+ break;
+ }
+ // Show the message dialog
+ msg->ShowAsync();
+}
+
+bool winapp::MainPage::EnsureUnsnapped()
+{
+ // FilePicker APIs will not work if the application is in a snapped state.
+ // If an app wants to show a FilePicker while snapped, it must attempt to unsnap first
+
+ bool unsnapped = (ApplicationView::Value != ApplicationViewState::Snapped ||
+ ApplicationView::TryUnsnap());
+ if (!unsnapped)
+ {
+ NotifyUser("Cannot unsnap the application", StatusMessage);
+ }
+ return unsnapped;
+}
+
void winapp::MainPage::Picker(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
- FileOpenPicker^ openPicker = ref new FileOpenPicker();
+ if (!EnsureUnsnapped())
+ return;
+
+ FileOpenPicker^ openPicker = ref new FileOpenPicker();
openPicker->ViewMode = PickerViewMode::List;
openPicker->SuggestedStartLocation = PickerLocationId::PicturesLibrary;
openPicker->FileTypeFilter->Append(".pdf");
@@ -414,12 +461,8 @@ static void win_close_file(fz_context *ctx, void *state)
delete dataReader;
}
-void PixToMemStream(fz_pixmap *pix, DataWriter ^dw, Platform::Array<unsigned char> ^arr)
+void PixToMemStream(DataWriter ^dw, Platform::Array<unsigned char> ^arr)
{
- unsigned char *samples = fz_pixmap_samples(ctx, pix);
- int w = fz_pixmap_width(ctx, pix);
- int h = fz_pixmap_height(ctx, pix);
-
/* Write the data */
dw->WriteBytes(arr);
@@ -492,7 +535,7 @@ InMemoryRandomAccessStream^ RenderBitMap(fz_document *doc, fz_page *page, int *w
fz_run_page(doc, page, dev, pctm, NULL);
fz_free_device(dev);
/* Now the data into the memory stream */
- PixToMemStream(pix, dw, bmp_data);
+ PixToMemStream(dw, bmp_data);
/* Return raster stream */
return ras;
}
@@ -599,7 +642,7 @@ void winapp::MainPage::CleanUp()
fz_close_document(m_doc);
this->m_curr_flipView = nullptr;
- m_currpage = 0;
+ m_currpage = -1;
m_file_open = false;
m_doc = NULL;
m_slider_min = 0;
@@ -1233,6 +1276,12 @@ void winapp::MainPage::Searcher(Platform::Object^ sender, Windows::UI::Xaml::Rou
}
else if (leftPanel != nullptr && !m_insearch)
{
+ /* Search is not going to work in snapped view for now to simplify UI
+ in this cramped case. So see if we can get out of snapped mode. */
+
+ if (!EnsureUnsnapped())
+ return;
+
m_insearch = true;
Windows::UI::Xaml::Controls::Button^ PrevButton = ref new Button();
PrevButton->Style = safe_cast<Windows::UI::Xaml::Style^>(App::Current->Resources->Lookup("PreviousAppBarButtonStyle"));
@@ -1499,6 +1548,12 @@ void winapp::MainPage::GridSizeChanged()
int width = this->ActualWidth;
FlipView^ old_flip = m_curr_flipView;
+
+ if (TopAppBar1->IsOpen)
+ {
+ UpdateAppBarButtonViewState();
+ }
+
if (m_zoom_mode)
{
Canvas_Double(nullptr, nullptr);
@@ -1969,3 +2024,20 @@ void winapp::MainPage::Reflower(Platform::Object^ sender, Windows::UI::Xaml::Rou
}, task_continuation_context::use_current());
}
}
+
+/* Need to handle resizing of app bar to make sure everything fits */
+
+void winapp::MainPage::topAppBar_Loaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
+{
+ UpdateAppBarButtonViewState();
+}
+
+void winapp::MainPage::UpdateAppBarButtonViewState()
+{
+ String ^viewState = Windows::UI::ViewManagement::ApplicationView::Value.ToString();
+ VisualStateManager::GoToState(Search, viewState, true);
+ VisualStateManager::GoToState(Contents, viewState, true);
+ VisualStateManager::GoToState(Links, viewState, true);
+ VisualStateManager::GoToState(Reflow, viewState, true);
+ VisualStateManager::GoToState(Help, viewState, true);
+} \ No newline at end of file
diff --git a/winrt/winapp/MainPage.xaml.h b/winrt/winapp/MainPage.xaml.h
index 3b1b1530..47e1bfab 100644
--- a/winrt/winapp/MainPage.xaml.h
+++ b/winrt/winapp/MainPage.xaml.h
@@ -30,6 +30,15 @@ using namespace Windows::UI::Xaml::Shapes;
using namespace Windows::Foundation::Collections;
using namespace Platform::Collections;
using namespace ListViewContents;
+using namespace Windows::UI::ViewManagement;
+using namespace Windows::UI::Popups;
+using namespace Windows::UI::Xaml::Navigation;
+
+typedef enum
+{
+ StatusMessage,
+ ErrorMessage
+} NotifyType_t;
typedef enum {
REN_AVAILABLE = 0,
@@ -126,6 +135,7 @@ namespace winapp
cancellation_token_source m_ThumbCancel;
fz_link *m_links;
content_t m_content;
+ TextBlock^ m_StatusBlock;
bool m_zoom_mode;
bool m_from_doubleflip;
bool m_scaling_occured;
@@ -193,5 +203,11 @@ namespace winapp
void RichGridManipulationDelta(Platform::Object^ sender, Windows::UI::Xaml::Input::ManipulationDeltaRoutedEventArgs^ e);
void RichGridManipulationStarted(Platform::Object^ sender, Windows::UI::Xaml::Input::ManipulationStartedRoutedEventArgs^ e);
void RichGridManipulationCompleted(Platform::Object^ sender, Windows::UI::Xaml::Input::ManipulationCompletedRoutedEventArgs^ e);
+ void topAppBar_Loaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
+ void UpdateAppBarButtonViewState();
+ bool EnsureUnsnapped();
+ void NotifyUser(String^ strMessage, NotifyType_t type);
+ void ExitInvokedHandler(Windows::UI::Popups::IUICommand^ command);
+ void OKInvokedHandler(Windows::UI::Popups::IUICommand^ command);
};
}
diff --git a/winrt/winapp/winapp.vcxproj b/winrt/winapp/winapp.vcxproj
index 49bf0062..27030488 100644
--- a/winrt/winapp/winapp.vcxproj
+++ b/winrt/winapp/winapp.vcxproj
@@ -222,7 +222,7 @@
<ClCompile>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4453</DisableSpecificWarnings>
- <AdditionalIncludeDirectories>../../xps/;../../fitz/;../../pdf/;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>../../fitz/;../../pdf/;../../xps/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<AdditionalDependencies>kernel32.lib;%(AdditionalDependencies);../$(Platform)/$(Configuration)/libmupdf_winRT.lib;../$(Platform)/$(Configuration)/libthirdparty_winRT.lib;../$(Platform)/$(Configuration)/libmupdf-nov8_winRT.lib</AdditionalDependencies>