Example #1
0
        private void OnBackStageOpening(object obj)
        {
            if (!string.IsNullOrEmpty(this.selectedFileName))
            {
                this.SaveSelectedFile();

                RecentFileButton currentFileButton = null;
                foreach (var element in this.View.RecentArea.Children)
                {
                    if ((element as RecentFileButton).FileName == this.selectedFileName)
                    {
                        currentFileButton = element as RecentFileButton;
                        break;
                    }
                }

                if (currentFileButton != null)
                {
                    this.View.RecentArea.Children.Remove(currentFileButton);
                    this.View.RecentArea.Children.Insert(0, currentFileButton);
                }

                this.SelectedFileName = String.Empty;
                this.ShowMainView     = false;
                this.ShowBackStage    = true;
            }
        }
Example #2
0
 private void PopulateRecentFiles(bool singleFile = false)
 {
     if (!singleFile)
     {
         var folderPath = IOPath.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FloorPlanner");
         if (!Directory.Exists(folderPath))
         {
             Directory.CreateDirectory(folderPath);
         }
         DirectoryInfo info  = new DirectoryInfo(folderPath);
         FileInfo[]    files = info.GetFiles().OrderByDescending(p => p.LastWriteTime).ToArray();
         foreach (var file in files)
         {
             string extension        = IOPath.GetExtension(file.Name);
             string recentFileName   = file.Name.Substring(0, file.Name.Length - extension.Length);
             var    recentFileButton = new RecentFileButton()
             {
                 FileName = recentFileName, FolderPath = folderPath, Command = OpenCommand
             };
             this.View.RecentArea.Children.Add(recentFileButton);
         }
     }
     else
     {
         var recentFileButton = new RecentFileButton()
         {
             FileName = this.selectedFileName, FolderPath = this.selectedFolderPath, Command = OpenCommand
         };
         this.View.RecentArea.Children.Insert(0, recentFileButton);
     }
 }
        private void Duplicate()
        {
            int i = 1;

            while (File.Exists(Path.Combine(folderPath, this.FileName + "(" + i + ")" + ".xml")))
            {
                i++;
            }

            File.Copy(Path.Combine(folderPath, this.FileName + ".xml"), Path.Combine(folderPath, this.FileName + "(" + i + ")" + ".xml"));

            var parentElement = this.Parent as Panel;
            var duplicateFile = new RecentFileButton()
            {
                FileName = this.FileName + "(" + i + ")", FolderPath = this.FolderPath, Command = this.Command
            };

            if (parentElement != null)
            {
                parentElement.Children.Insert(parentElement.Children.IndexOf(this) + 1, duplicateFile);
            }
        }