public void OpenFile(Workspace workspace = null)
        {
            GlobalService.PropertyHandler.PreventIndexUpdate = true;
            UnloadAnimationData();
            var fd = new OpenFileDialog();

            fd.DefaultExt = "*.bin";
            fd.Filter     = string.Join("", FilterOpen);
            GenerateShortcuts();
            fd.CustomPlaces.Add(new FileDialogCustomPlace(Services.PathService.GetShortcutsPath()));
            if (workspace != null)
            {
                fd.InitialDirectory = workspace.Path;
                fd.FilterIndex      = GetFilterIndexFromTypeString(workspace.DefaultFormat);
            }
            if (fd.ShowDialog() == true)
            {
                AddRecentDataFolder(fd.FileName, fd.FileName, GetTypeStringFromFilterIndex(fd.FilterIndex));
                LoadFile(fd);
            }
            GlobalService.PropertyHandler.PreventIndexUpdate = false;

            if (workspace != null)
            {
                GlobalService.PropertyHandler.UpdateControls();
                GlobalService.PropertyHandler.UpdateCanvasVisual();
                Instance.InvalidateCanvasSize();
            }
        }
        private MenuItem CreateWorkSpaceMenuLink(Workspace directory)
        {
            MenuItem newItem = new MenuItem();

            newItem.Header           = directory.Name;
            newItem.InputGestureText = directory.DefaultFormat;
            newItem.Tag = directory;
            newItem.StaysOpenOnClick = IsWorkspaceOnRemoveMode;
            newItem.Click           += WorkspaceFolderClicked;
            return(newItem);
        }
 public void SelectNewWorkspaceFolder()
 {
     GenerationsLib.Core.FolderSelectDialog fsd = new GenerationsLib.Core.FolderSelectDialog();
     if (fsd.ShowDialog())
     {
         AddWorkspaceDialog awd = new AddWorkspaceDialog();
         awd.Owner = Instance;
         if (awd.ShowDialog() == true)
         {
             Workspace workspace = new Workspace(awd.WorkspaceName, fsd.FileName, awd.SelectedFormat);
             AddWorkspaceFolder(workspace);
         }
     }
 }
        public void WorkspaceFolderClicked(object sender, RoutedEventArgs e)
        {
            var       menuItem  = sender as System.Windows.Controls.MenuItem;
            Workspace directory = menuItem.Tag as Workspace;

            if (IsWorkspaceOnRemoveMode)
            {
                AnimationEditor.Classes.Settings.Default.Workspaces.Remove(directory);
                CleanUpWorkspaceList();
                RefreshWorkspaces();
            }
            else
            {
                OpenFile(directory);
            }

            AnimationEditor.Classes.Settings.Save();
        }
        public void AddWorkspaceFolder(Workspace workspace)
        {
            try
            {
                if (AnimationEditor.Classes.Settings.Default.Workspaces == null)
                {
                    AnimationEditor.Classes.Settings.Default.Workspaces = new List <Workspace>();
                }

                AnimationEditor.Classes.Settings.Default.Workspaces.Insert(0, workspace);

                AnimationEditor.Classes.Settings.Save();
                AnimationEditor.Classes.Settings.Reload();

                RefreshWorkspaces();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Write("Failed to add data folder to recent list: " + ex);
            }
        }