Beispiel #1
0
        /// <summary>
        /// Saves the existing project.
        /// </summary>
        /// <param name="projectFacade">The object that contains the methods that allow interaction with the project system.</param>
        /// <param name="persistenceInformation">The object that describes how the project should be persisted.</param>
        /// <param name="timer">The function that creates and stores timing intervals.</param>
        private static void OnSaveProject(
            ILinkToProjects projectFacade,
            IPersistenceInformation persistenceInformation,
            Func <string, IDisposable> timer)
        {
            // If there is no facade then we're in design mode or something
            // else weird.
            if (projectFacade == null)
            {
                return;
            }

            if (!projectFacade.HasActiveProject())
            {
                return;
            }

            using (timer("Saving project"))
            {
                var project = projectFacade.ActiveProject();
                project.SaveProject(persistenceInformation);

                projectFacade.ActiveProject().History.Mark(Resources.SaveProjectCommand_HistoryMark);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Called when the last undo action should be redone.
        /// </summary>
        /// <param name="projectFacade">
        /// The object that contains the methods that allow interaction with
        /// the project system.
        /// </param>
        /// <param name="timer">The function that creates and stores timing intervals.</param>
        private static void OnRedo(ILinkToProjects projectFacade, Func <string, IDisposable> timer)
        {
            // If there is no facade then we're in design mode or something
            // else weird.
            if (projectFacade == null)
            {
                return;
            }

            if (!projectFacade.HasActiveProject())
            {
                return;
            }

            using (timer("Redoing change"))
            {
                var project = projectFacade.ActiveProject();
                if (project.History.CanRollForward)
                {
                    var markers = project.History.MarkersInTheFuture();

                    var markerToRollBackTo = markers.FirstOrDefault(m => !m.Equals(project.History.Current));
                    if (markerToRollBackTo != null)
                    {
                        project.History.RollForwardTo(markerToRollBackTo);
                    }
                }
            }
        }
Beispiel #3
0
        private static bool CanRedo(ILinkToProjects projectFacade)
        {
            // If there is no facade then we're in design mode or something
            // else weird.
            if (projectFacade == null)
            {
                return(false);
            }

            if (!projectFacade.HasActiveProject())
            {
                return(false);
            }

            var project = projectFacade.ActiveProject();

            if (project.History.CanRollForward)
            {
                var markers = project.History.MarkersInTheFuture();

                var markerToRollBackTo = markers.FirstOrDefault(m => !m.Equals(project.History.Current));
                return(markerToRollBackTo != null);
            }

            return(false);
        }
        /// <summary>
        /// Called when the dataset should be activated.
        /// </summary>
        /// <param name="projectFacade">The object that contains the methods that allow interaction with the project system.</param>
        /// <param name="dataset">The dataset.</param>
        /// <param name="selector">
        ///     The function that is used to select the most suitable machine to distribute the dataset to.
        /// </param>
        /// <param name="timer">The function that creates and stores timing intervals.</param>
        private static void OnActivate(
            ILinkToProjects projectFacade,
            DatasetFacade dataset,
            Func <IEnumerable <DistributionSuggestion>, SelectedProposal> selector,
            Func <string, IDisposable> timer)
        {
            // If there is no application facade, then we're in
            // designer mode, or something else silly.
            if (dataset == null)
            {
                return;
            }

            if (dataset.IsActivated || !dataset.CanActivate)
            {
                return;
            }

            using (timer("Loading dataset onto machine"))
            {
                var source = new CancellationTokenSource();
                dataset.Activate(
                    DistributionLocations.All,
                    selector,
                    source.Token)
                .ContinueWith(t => source.Dispose());
                projectFacade.ActiveProject().History.Mark();
            }
        }
Beispiel #5
0
        /// <summary>
        /// Returns the currently active project.
        /// </summary>
        /// <returns>
        /// The currently active project.
        /// </returns>
        public ScriptBackEndProjectFacade ActiveProject()
        {
            if (m_Current == null)
            {
                m_Current = new ScriptBackEndProjectFacade(m_Projects.ActiveProject());
            }

            return(m_Current);
        }
        /// <summary>
        /// Called when a new child dataset should be added.
        /// </summary>
        /// <param name="projectFacade">The object that contains the methods that allow interaction with the project system.</param>
        /// <param name="datasetFacade">The object that contains the methods that allow interaction with a dataset.</param>
        /// <param name="timer">The function that creates and stores timing intervals.</param>
        private static void OnAddNewChild(ILinkToProjects projectFacade, DatasetFacade datasetFacade, Func <string, IDisposable> timer)
        {
            // If there is no dataset facade, then we're in
            // designer mode, or something else silly.
            if (datasetFacade == null)
            {
                return;
            }

            using (timer("Add dataset to graph"))
            {
                datasetFacade.AddChild();
                projectFacade.ActiveProject().History.Mark();
            }
        }
Beispiel #7
0
        private static bool ShouldSaveProject(ILinkToProjects projectFacade)
        {
            // If there is no facade then we're in design mode or something
            // else weird.
            if (projectFacade == null)
            {
                return(false);
            }

            if (!projectFacade.HasActiveProject())
            {
                return(false);
            }

            var project = projectFacade.ActiveProject();

            return(project.ShouldSaveProject());
        }
        /// <summary>
        /// Called when the dataset should be deactivated.
        /// </summary>
        /// <param name="projectFacade">The object that contains the methods that allow interaction with the project system.</param>
        /// <param name="dataset">The dataset.</param>
        /// <param name="timer">The function that creates and stores timing intervals.</param>
        private static void OnDeactivate(ILinkToProjects projectFacade, DatasetFacade dataset, Func<string, IDisposable> timer)
        {
            // If there is no application facade, then we're in 
            // designer mode, or something else silly.
            if (dataset == null)
            {
                return;
            }

            if (!dataset.IsActivated)
            {
                return;
            }

            using (timer("Unloading dataset"))
            {
                dataset.Deactivate();
                projectFacade.ActiveProject().History.Mark();
            }
        }