Esempio n. 1
0
    public void Execute(CreateGraphCommand command)
    {
        var workspaceService = Container.Resolve <WorkspaceService>();
        var repo             = Container.Resolve <IRepository>();
        var graph            = Activator.CreateInstance(command.GraphType) as IGraphData;

        repo.Add(graph);
        graph.Name = command.Name;
        workspaceService.CurrentWorkspace.AddGraph(graph);
        workspaceService.CurrentWorkspace.CurrentGraphId = graph.Identifier;
        InvertApplication.SignalEvent <INotify>(_ => _.Notify(command.Name + " graph has been created!", NotificationIcon.Info));
    }
Esempio n. 2
0
        private void Document_Changed(object sender, DocumentChangeEventArgs e)
        {
            Packages.Clear();

            if (string.IsNullOrEmpty(Document.Text))
            {
                return;
            }

            try
            {
                var spec = SpecUtils.Deserialize(Document.Text);

                // initially specs do not have Ids - generate them once and keep them
                bool idsGenerated = false;
                foreach (var cluster in spec.Packages.SelectMany(p => p.Clusters))
                {
                    if (cluster.Id == null)
                    {
                        cluster.Id   = Guid.NewGuid().ToString();
                        idsGenerated = true;
                    }
                }

                if (idsGenerated)
                {
                    // we cannot change the doc while handling a doc change
                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        Document.Text = SpecUtils.Serialize(spec);
                        Save();
                    }));
                }

                Packages.AddRange(spec.Packages.Select(p => p.Name));
            }
            catch (Exception ex)
            {
                myStatusMessageService.Publish(new StatusMessage("ERROR:" + ex));
            }

            CreateGraphCommand.RaiseCanExecuteChanged();
        }