Ejemplo n.º 1
0
        public static void Command_SaveAs()
        {
            if (DialogWindowOpen)
            {
                return;
            }

            DialogWindowOpen = true;

            SaveFileDialog sfd = new SaveFileDialog();

            sfd.AddExtension = true;
            sfd.Filter       = "Level Files (*.lvl)|*.lvl";
            sfd.DefaultExt   = "lvl";
            sfd.ShowDialog(MainWindow.Instance);

            if (sfd.FileName != "")
            {
                SaverLoader sl = new SaverLoader();
                sl.SaveAs(sfd.FileName);
                Global.Unsaved      = false;
                Global.OpenFilePath = sfd.FileName;

                RecentFilesController.AddFile(sfd.FileName);
            }

            DialogWindowOpen = false;
        }
Ejemplo n.º 2
0
        public void LoadRecentFiles()
        {
            Menu_RecentFiles.IsEnabled = false;

            Menu_RecentFiles.Items.Clear();

            List <string> recentFiles = RecentFilesController.GetRecentFiles();

            recentFiles.Reverse();

            foreach (var item in recentFiles)
            {
                MenuItem newMenuItem = new MenuItem();
                newMenuItem.Header = item;
                newMenuItem.Click += LoadRecentFile;
                Menu_RecentFiles.Items.Add(newMenuItem);
            }

            if (Menu_RecentFiles.Items.Count > 0)
            {
                HasClearOption             = true;
                Menu_RecentFiles.IsEnabled = true;

                MenuItem clearRecentMenuItem = new MenuItem();
                clearRecentMenuItem.Header = "Clear";
                clearRecentMenuItem.Click += ClearRecentMenuItem_Click;
                Menu_RecentFiles.Items.Add(clearRecentMenuItem);
            }

            if (Menu_RecentFiles.Items.Count == 0)
            {
                HasClearOption             = false;
                Menu_RecentFiles.IsEnabled = false;
            }
        }
Ejemplo n.º 3
0
        public static void Command_Open(string filePath = "")
        {
            if (DialogWindowOpen)
            {
                return;
            }

            if (filePath.Length == 0)
            {
                DialogWindowOpen = true;
                OpenFileDialog sfd = new OpenFileDialog();
                sfd.ShowDialog(MainWindow.Instance);

                if (sfd.FileName != "")
                {
                    filePath = sfd.FileName;
                    RecentFilesController.AddFile(sfd.FileName);
                }
            }

            if (filePath != "")
            {
                if (Global.State == States.MapOpen)
                {
                    Global.Command_Close();
                }
                SaverLoader sl = new SaverLoader();
                sl.Load(filePath);
                Global.OpenFilePath = filePath;
                RecentFilesController.AddFile(filePath);
            }
            Global.Unsaved   = false;
            DialogWindowOpen = false;
        }
Ejemplo n.º 4
0
 private void ClearRecentMenuItem_Click(object sender, RoutedEventArgs e)
 {
     RecentFilesController.Clear();
 }