コード例 #1
0
 private Document CreateTempFile()
 {
     Directory root = new Directory(PathBase.Root);
     string path = FileUtils.GetNumberedDocumentPath("Temp", root.Path.PathString);
     var doc = new Document(new PathStr(path)) { IsTemp = true };
     FileUtils.CreateDocument(doc.Path.Parent.PathString, doc.DisplayName);
     return doc;
 }
コード例 #2
0
 private void Doc_Tap(object sender, System.Windows.Input.GestureEventArgs e)
 {
     // Create a temporary document that will be renamed in the next window
     string tempPath = FileUtils.GetNumberedDocumentPath("Untitled", _currentDirectory.Path.PathString);
     Document newDocument = new Document(new PathStr(tempPath)) { IsTemp = true };
     FileUtils.CreateDocument(newDocument.Path.Parent.PathString, newDocument.DisplayName);
     newDocument.NavToRename(NavigationService, this);
 }
コード例 #3
0
ファイル: AddNewItem.xaml.cs プロジェクト: hmehart/Notepad
        private void Doc_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
            {
                // Create a temporary document that will be renamed in the next window
                string tempName = "." + Utils.GetUniqueName(_currentDirectory, isf);
                Document newDocument = new Document(_currentDirectory, tempName + ".txt") { IsTemp = true };
                IsolatedStorageFileStream fs = isf.CreateFile(newDocument.Path.PathString);
                fs.Close();

                newDocument.NavToRename(NavigationService);
            }
        }
コード例 #4
0
ファイル: Listings.xaml.cs プロジェクト: hmehart/Notepad
        // Changes the currently-viewed folder and updates the view
        private void UpdateItems(Action OnCompleted)
        {
            _isUpdatingItems = true;
            _items.Clear();

            // Re-fill ContentBox
            using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
            {
                List<string> dirs = new List<string>();
                foreach (string dir in isf.GetDirectoryNames(_curr.Path.PathString + "/*"))
                    if (!dir.StartsWith("."))
                        dirs.Add(dir);
                dirs.Sort();

                // Add directories
                foreach (string dir in dirs)
                {
                    Directory d = new Directory(_curr.Path.NavigateIn(dir));
                    ListingsListItem li = ListingsListItem.CreateListItem(d);
                    _items.Add(li);
                }

                List<string> docs = new List<string>();
                foreach (string doc in isf.GetFileNames(_curr.Path.PathString + "/*"))
                    if (!doc.StartsWith("."))
                        docs.Add(doc);
                docs.Sort();

                // Add documents
                foreach (string doc in docs)
                {
                    Document d = new Document(_curr.Path.NavigateIn(doc));
                    ListingsListItem li = ListingsListItem.CreateListItem(d);
                    _items.Add(li);
                }
            }

            _isUpdatingItems = false;
            if (_isShowingLoadingNotice)
                UpdateView(OnCompleted);

            RemoveNotice(Notice.Empty);
            RemoveNotice(Notice.Loading);
        }
コード例 #5
0
 private void GetArgs()
 {
     _doc = (Document)Utils.CreateActionableFromPath(new PathStr(NavigationContext.QueryString["param"]));
     if (NavigationContext.QueryString.ContainsKey("istemp"))
         _doc.IsTemp = bool.Parse(NavigationContext.QueryString["istemp"]);
 }
コード例 #6
0
ファイル: Document.cs プロジェクト: hmehart/Notepad
        public IActionable Delete()
        {
            if (isTrash)
            {
                using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    isf.DeleteFile(Path.PathString);
                }
                return null;
            }
            else // if (!isTrash)
            {
                Directory trash = new Directory(new Path(PathBase.Trash));
                Document newLoc = new Document(trash.Path.NavigateIn(Name));
                if (newLoc.Exists())
                    newLoc.Delete();

                this.Move(trash);
                return newLoc;
            }
        }
コード例 #7
0
ファイル: SendAs.xaml.cs プロジェクト: hmehart/Notepad
 private void GetArgs()
 {
     IList<object> args = Utils.GetArguments();
     _currentDocument = (Document)args[0];
 }
コード例 #8
0
ファイル: App.xaml.cs プロジェクト: ireynolds/Document-Store
        // Code to execute when the application is launching (eg, from Start)
        // This code will not execute when the application is reactivated
        private void Application_Launching(object sender, LaunchingEventArgs e)
        {
            var rootName = SettingUtils.GetSetting<string>(Setting.RootDirectoryName);
            using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (!isf.DirectoryExists(rootName))
                    isf.CreateDirectory(rootName);
                if (!isf.DirectoryExists("trash.dir"))
                    isf.CreateDirectory("trash.dir");
                if (isf.DirectoryExists("root") && !IsolatedStorageSettings.ApplicationSettings.Contains("HasMovedRoot"))
                {
                    IActionable a = new Models.Directory(new PathStr("root"));

                    //var newName = "lost_files_" + new Random().Next();
                    var newName = "lost_files_";
                    var newLoc = new Models.Directory(new PathStr(PathBase.Root).NavigateIn(newName, ItemType.Directory));
                    if (!isf.DirectoryExists(newName) && !newLoc.Exists())
                    {
                        a = a.Rename(newName);
                        a = a.Move(new Models.Directory(PathBase.Root));

                        //var apologyName = "apology_" + new Random().Next();
                        var apologyName = "apology_";
                        var apologyFile = new Models.Document(new PathStr(PathBase.Root).NavigateIn(apologyName, ItemType.Document));
                        if (!apologyFile.Exists())
                        {
                            var f = isf.CreateFile(apologyFile.Path.PathString);
                            var sw = new StreamWriter(f);
                            sw.Write("When I last updated the app I changed the folder that all of your documents were stored in. This made it look like you lost all of your documents. It was a careless oversight and a huge mistake, and I can promise it won't happen again. You should find all of your files in the lost_files directory. Sorry!");
                            sw.Close();
                        }

                        IsolatedStorageSettings.ApplicationSettings["HasMovedRoot"] = true;
                        IsolatedStorageSettings.ApplicationSettings.Save();
                    }
                }
            }

            // Add test data
            //using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
            //{
            //    IsolatedStorageFileStream s1 = isf.CreateFile(rootName + "/new1.doc");
            //    s1.Close();
            //    IsolatedStorageFileStream s2 = isf.CreateFile(rootName + "/new2.doc");
            //    s2.Close();
            //    isf.CreateDirectory(rootName + "/Dir1.dir");
            //    isf.CreateDirectory(rootName + "/Dir2.dir");
            //    isf.CreateDirectory(rootName + "/Dir1.dir/SubDir1.dir");
            //    isf.CreateDirectory(rootName + "/Dir2.dir/SubDir2.dir");
            //    WriteFiles(new string[] { "FileDir1.dir", "FileDir2.dir" });
            //}
        }
コード例 #9
0
 private void GetArgs()
 {
     _currentDocument = (Document)Utils.CreateActionableFromPath(new PathStr(NavigationContext.QueryString["param"]));
 }