Exemplo n.º 1
0
        async Task Rename(DocumentReference docRef, string newName)
        {
            try {
                var oldIndex = Docs.FindIndex(x => x.File.Path == docRef.File.Path);

                var r = await docRef.Rename(newName);

                if (r)
                {
                    Console.WriteLine("RENAME to {0}: {1}", newName, r);

                    if (oldIndex >= 0)
                    {
                        await LoadDocs();

                        var newIndex = Docs.FindIndex(x => x.File.Path == docRef.File.Path);
                        if (newIndex >= 0 && newIndex != oldIndex)
                        {
                            docsView.ShowItem(newIndex, true);
                        }
                    }
                }
                else
                {
                    alert = new UIAlertView("Failed to Rename", "You may not have permission.", null, "OK");
                    alert.Show();
                }

//				AppDelegate.Shared.UpdateDocListName (docIndex);
            } catch (Exception ex) {
                Debug.WriteLine(ex);
            }
        }
Exemplo n.º 2
0
        public UIViewController GetViewControllerForPreview(IUIViewControllerPreviewing previewingContext, CoreGraphics.CGPoint location)
        {
            try {
                if (docsView == null)
                {
                    return(null);
                }

                var p    = new Praeclarum.Graphics.PointF((float)location.X, (float)location.Y);
                var item = docsView.GetItemAtPoint(p);

                if (item == null)
                {
                    return(null);
                }

                var dref = item.Reference;
                if (dref == null)
                {
                    return(null);
                }

                var docIndex = Docs.FindIndex(x => x.File.Path == dref.File.Path);
                if (docIndex < 0)
                {
                    return(null);
                }

                var newEditor = DocumentAppDelegate.Shared.App.CreateDocumentEditor(docIndex, Docs);
                if (newEditor == null)
                {
                    return(null);
                }

                newEditor.IsPreviewing = true;

                BindEditorAsync(newEditor).ContinueWith(t => {
                    if (t.IsFaulted)
                    {
                        Log.Error(t.Exception);
                    }
                });

                return((UIViewController)newEditor);
            } catch (Exception ex) {
                Log.Error(ex);
                return(null);
            }
        }