Пример #1
0
        private void CreateItems()
        {
            var item = TreeView.SelectedItem as ItemTreeViewItem;

            if (item == null)
            {
                return;
            }

            var databaseName = item.Item.ItemUri.DatabaseName;

            var logWindow = new ProjectLogWindow
            {
                Maximum = createItems.Count
            };

            logWindow.AutoStart = delegate
            {
                var iterator = new ElementIterator <CreateItem>(createItems);

                iterator.Process = delegate(CreateItem element)
                {
                    if (!element.IsChecked)
                    {
                        logWindow.Increment();
                        iterator.Next();
                        return;
                    }

                    if (element.ProjectItem == null)
                    {
                        element.ProjectItem = Add(element);
                    }

                    var projectItem = element.ProjectItem;

                    ProcessedEventHandler callback = delegate(object sender, ProcessedEventArgs args)
                    {
                        WriteResult(logWindow, projectItem, args);
                        logWindow.Increment();
                        iterator.Next();
                    };

                    element.Handler.Handle(databaseName, projectItem, element.ItemPath, callback);
                };

                iterator.Finish = delegate
                {
                    logWindow.Write(Rocks.Resources.Finished, string.Empty, string.Empty);
                    logWindow.Finish();
                };

                iterator.Start();
            };

            AppHost.Shell.ShowDialog(logWindow);

            SaveProjects();
        }
Пример #2
0
        private void WriteResult([NotNull] ProjectLogWindow projectLogWindow, [NotNull] ProjectItem projectItem, [NotNull] ProcessedEventArgs args)
        {
            Debug.ArgumentNotNull(projectLogWindow, nameof(projectLogWindow));
            Debug.ArgumentNotNull(projectItem, nameof(projectItem));
            Debug.ArgumentNotNull(args, nameof(args));

            if (!args.Ignore)
            {
                projectLogWindow.Dispatcher.Invoke(new Action(() => projectLogWindow.Write(projectItem.Path, args.Text, args.Comment)));
            }
        }
Пример #3
0
        private void WriteResult([NotNull] ProjectLogWindow projectLogWindow, [NotNull] ProjectItem projectItem, [NotNull] ProcessedEventArgs args)
        {
            Debug.ArgumentNotNull(projectLogWindow, nameof(projectLogWindow));
            Debug.ArgumentNotNull(projectItem, nameof(projectItem));
            Debug.ArgumentNotNull(args, nameof(args));

            if (!args.Ignore)
            {
                ThreadHelper.JoinableTaskFactory.Run(async delegate
                {
                    await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                    projectLogWindow.Write(projectItem.Path, args.Text, args.Comment);
                });
            }
        }
Пример #4
0
        private void Add()
        {
            var logWindow = new ProjectLogWindow
            {
                Maximum = addItems.Count
            };

            logWindow.AutoStart = delegate
            {
                var iterator = new ElementIterator <AddItem>(addItems);

                iterator.Process = delegate(AddItem element)
                {
                    logWindow.Increment();
                    if (!element.IsChecked)
                    {
                        iterator.Next();
                        return;
                    }

                    var project = element.Project;

                    var fileName    = project.GetProjectItemFileName(element.Item);
                    var projectItem = ProjectFileItem.Load(project, fileName);
                    project.Add(projectItem);

                    logWindow.Write(projectItem.Path, Rocks.Resources.AddWindow_Add_added, string.Empty);

                    logWindow.Increment();
                    iterator.Next();
                };

                iterator.Finish = delegate
                {
                    logWindow.Write(Rocks.Resources.Finished, string.Empty, string.Empty);
                    logWindow.Finish();
                };

                iterator.Start();
            };

            AppHost.Shell.ShowDialog(logWindow);

            SaveProjects();
        }
Пример #5
0
        private void Commit()
        {
            var logWindow = new ProjectLogWindow
            {
                Maximum = commitItems.Count
            };

            logWindow.AutoStart = delegate
            {
                var iterator = new ElementIterator <CommitItem>(commitItems);

                iterator.Process = delegate(CommitItem element)
                {
                    if (!element.IsChecked)
                    {
                        logWindow.Increment();
                        iterator.Next();
                        return;
                    }

                    var projectItem = element.ProjectItem;

                    projectItem.Commit(delegate(object sender, ProcessedEventArgs args)
                    {
                        WriteResult(logWindow, projectItem, args);
                        logWindow.Increment();
                        iterator.Next();
                    });
                };

                iterator.Finish = delegate
                {
                    logWindow.Write(Rocks.Resources.Finished, string.Empty, string.Empty);
                    logWindow.Finish();
                };

                iterator.Start();
            };

            AppHost.Shell.ShowDialog(logWindow);

            SaveProjects();
        }
Пример #6
0
        private void Exclude()
        {
            var logWindow = new ProjectLogWindow
            {
                Maximum = excludeItems.Count
            };

            logWindow.AutoStart = delegate
            {
                var iterator = new ElementIterator <ExcludeItem>(excludeItems);

                iterator.Process = delegate(ExcludeItem element)
                {
                    if (element.IsChecked)
                    {
                        var projectItem = element.ProjectItem;
                        projectItem.Project.Remove(projectItem);

                        logWindow.Write(projectItem.Path, Rocks.Resources.ExcludeWindow_Exclude_excluded, string.Empty);
                    }

                    logWindow.Increment();
                    iterator.Next();
                };

                iterator.Finish = delegate
                {
                    logWindow.Write(Rocks.Resources.Finished, string.Empty, string.Empty);
                    logWindow.Finish();
                };

                iterator.Start();
            };

            AppHost.Shell.ShowDialog(logWindow);

            SaveProjects();
        }