public ContentPageXaml(Document selecteDocument, string parentName,INavigation navigation)
        {
            InitializeComponent();
            try
            {
                if (Device.OS == TargetPlatform.iOS)
                {
                    // move layout under the status bar
				   this.pageButton.HeightRequest = 30;
				   this.pageButton.BackgroundColor = Color.Gray;
                   this.Padding = new Thickness(0, Device.OnPlatform(20,0,0), 0, 0);
                }

                (Application.Current.MainPage as MasterDetailPage).IsGestureEnabled = false;
                
                _navigation = navigation;
                NavigationPage.SetHasNavigationBar(this,false);
                BindingContext = new ViewModels.TransformImageViewModel(selecteDocument);

                this.backButton.Clicked += async(sender, e) =>
                {
                    (Application.Current.MainPage as MasterDetailPage).IsGestureEnabled = true;
                    _navigation.PopAsync();
                };

				this.pageButton.Clicked+= async(sender, e) =>
				{
				    var str = new List<string>();
					for (int i = 1; i <= ViewModel.TotalPage; i++)
				    {
						str.Add("Page " + i.ToString());
				    }

					var action = await DisplayActionSheet ("Go To Page", "Cancel", null, str.ToArray());
					
					if(action != null)
					{
						if(action.ToUpper().Contains("PAGE"))
						{
							int page = Convert.ToInt32(action.ToUpper().Replace("PAGE ",""));
							if(ViewModel.CurrentPage != page)
							{
								ViewModel.CurrentPage = page;
								ViewModel.CurrentPickerPage = ViewModel.CurrentPage.ToString();
							    ViewModel.ImageSource = null;
								Task.Run(() => ViewModel.RefreshImage(page, ViewModel.FolderName, "", false));
							}
						}
					}
				};

            }
            catch (Exception ex)
            {
               DisplayAlert("Error", "An exception occurred.", "OK");
            }
        }
예제 #2
0
        public int SaveItem(Document item) 
		{
			lock (locker)
			{
			    if (item.Id != 0) {
					database.Update(item);
					return item.Id;
				}
			    return database.Insert(item);
			}
		}
        public TransformImageViewModel(Document selecteDocument)
            : base()
        {
            try
            {
				DocName = selecteDocument.Name;
				CurrentPickerPage = _currentPage.ToString();
                          
                Task.Run(() => RefreshImage(_currentPage, selecteDocument.Name, selecteDocument.RelativePath, true));
                
				var recentItem = new Recent()
                {
                    Ext = selecteDocument.Ext,
                    Name = selecteDocument.Name,
                    CreatedBy = selecteDocument.CreatedBy,
                    CreatedDateTime = selecteDocument.CreatedDateTime,
                    Size = selecteDocument.Size,
                    ModifiedBy = selecteDocument.ModifiedBy,
                    ModifiedDateTime = selecteDocument.ModifiedDateTime,
                    LibraryGuid = selecteDocument.LibraryGuid,
                    RelativePath = selecteDocument.RelativePath
                };
                UpdateRecentList(recentItem);
            }
            catch (Exception ex)
            {
				Alert (ex.Message);
            }
            
             
        }
		public DocumentDetailPage(Document selecteDocument, string parentName,bool isRecent,int totalPage=10)
		{
		    try
		    {
                NavigationPage.SetHasNavigationBar(this, true);
		        Title = parentName;
		        _totalPage = totalPage;
		        lblPage = new Label()
		        {
		            Text = " Of " + _totalPage,
		            VerticalOptions = LayoutOptions.CenterAndExpand
		        };
		        if (isRecent == false)
		        {
		            var database = new RecentDatabase();
		            database.SaveItem(new Recent()
		            {
		                Ext = selecteDocument.Ext,
		                Name = selecteDocument.Name,
		                CreatedBy = selecteDocument.CreatedBy,
		                CreatedDateTime = selecteDocument.CreatedDateTime,
		                Size = selecteDocument.Size,
		                ModifiedBy = selecteDocument.ModifiedBy,
		                ModifiedDateTime = selecteDocument.ModifiedDateTime,
		                LibraryGuid = selecteDocument.LibraryGuid,
		                RelativePath = selecteDocument.RelativePath
		            });
		        }

		        this.Padding = new Thickness(5, Device.OnPlatform(5, 0, 0), 5, 5);

		        var relativeLayout = new RelativeLayout();
		        _webImage = new Image()
		        {
		            Aspect = Aspect.AspectFill,
		            HorizontalOptions = LayoutOptions.FillAndExpand,
		            VerticalOptions = LayoutOptions.FillAndExpand,
		            Source = getImage(_currentPage)

		        };

		        relativeLayout.Children.Add(_webImage, Constraint.RelativeToParent((parent) =>
		        {
		            return 0;
		        }));

		        top = new StackLayout()
		        {
		            Orientation = StackOrientation.Horizontal

		        };
               		        
				var image = new Image() {Source = "back.png",MinimumWidthRequest = 32,MinimumHeightRequest = 32};
                var tapGestureRecognizer = new TapGestureRecognizer();
                tapGestureRecognizer.Tapped += tapGestureRecognizer_Tapped;
                image.GestureRecognizers.Add(tapGestureRecognizer);
               

		        pkrPage = new Picker() {MinimumHeightRequest = 60, MinimumWidthRequest = 80};
		        for (int i = 1; i <= totalPage; i++)
		        {
		            pkrPage.Items.Add("  " + i + "  ");
		        }
		        pkrPage.SelectedIndex = 0;

		        pkrPage.SelectedIndexChanged += (sender, e) =>
		        {
		            _currentPage = pkrPage.SelectedIndex + 1;
		            DisableButton();
		        };

                top.Children.Add(image);
		        top.Children.Add(pkrPage);
		        top.Children.Add(lblPage);



		        prevButton = new Button {Text = "<", TextColor = Color.FromHex("#666")};
		        nextButton = new Button {Text = ">", TextColor = Color.FromHex("#666")};
		        prevButton.Clicked += prevButton_Clicked;
		        nextButton.Clicked += nextButton_Clicked;

		        relativeLayout.Children.Add(nextButton,
		            Constraint.RelativeToParent((parent) =>
		            {
		                return (parent.Width - 60);
		            }),
		            Constraint.RelativeToParent((parent) =>
		            {
		                return (parent.Height/2);
		            }));

		        relativeLayout.Children.Add(prevButton,
		            Constraint.RelativeToParent((parent) =>
		            {
		                return (0);
		            }),
		            Constraint.RelativeToParent((parent) =>
		            {
		                return (parent.Height/2);
		            }));

		        var mainLayout = new StackLayout()
		        {
		            Orientation = StackOrientation.Vertical,
		            HorizontalOptions = LayoutOptions.FillAndExpand,
		            VerticalOptions = LayoutOptions.FillAndExpand
		        };
		        mainLayout.Children.Add(top);
		        mainLayout.Children.Add(relativeLayout);
		        this.Content = new ScrollView {Content = mainLayout};
		        DisableButton();
		    }
		    catch (Exception ex)
		    {
                DisplayAlert(ex.Message, "Error", "OK");
		    }
		}
예제 #5
0
        public RecentPage()
        {
            try
            {
                var cell = new DataTemplate(typeof(RecentListCell));
                
                _recentListView = new ListView()
                {
                    ItemsSource = GetRecentList(),
                    RowHeight = 65,
                    ItemTemplate = cell
                };
                
                _recentListView.ItemTapped += async (sender, e) =>
                {
                    if (CrossConnectivity.Current.IsConnected == false)
                    {
                        await DisplayAlert("Error", "Please check internet connectivity.", "OK");
                        return;
                    }
                    
                    if (this.AcquireTapLock())
                    {
                        var selectedItem = (Recent) e.Item;
                        var doc = new Document()
                        {
                            RelativePath = selectedItem.RelativePath,
                            CreatedBy = selectedItem.CreatedBy,
                            CreatedDateTime = selectedItem.CreatedDateTime,
                            Ext = selectedItem.Ext,
                            Size=selectedItem.Size,
                            Id = selectedItem.Id,
                            IsFolder = false,
                            ModifiedBy = selectedItem.ModifiedBy,
                            ModifiedDateTime = selectedItem.ModifiedDateTime,
                            Name = selectedItem.Name,
                            LibraryGuid = selectedItem.LibraryGuid

                        };
                        await Navigation.PushAsync(new ContentPageXaml(doc, "Recent", this.Navigation),true);
                        this.ReleaseTapLock();
                        ((ListView) sender).SelectedItem = null;
                    }
                    
                };
                
                var upperPanel = new StackLayout
                {
                    Orientation = StackOrientation.Horizontal,
                    Children = {
                                _recentListView
                           }
                };
                Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
                Content = new Xamarin.Forms.ScrollView { Content = upperPanel };
            }
            catch (Exception ex)
            {
                DisplayAlert("Error", "An exception occurred.", "OK");
            }
        }