コード例 #1
0
        public override void Load(SettingsStorage storage)
        {
            base.Load(storage);

            var compositionType = storage.GetValue <CompositionType>("CompositionType");
            var compositionId   = storage.GetValue <Guid>("CompositionId");

            var registry = ConfigManager.GetService <StrategiesRegistry>();

            var composition = compositionType == CompositionType.Composition
                                                  ? registry.Compositions.FirstOrDefault(c => c.TypeId == compositionId)
                                                  : registry.Strategies.FirstOrDefault(c => c.TypeId == compositionId);

            Composition = new CompositionItem(compositionType, (CompositionDiagramElement)composition);

            var layout = storage.GetValue <string>("Layout");

            if (!layout.IsEmpty())
            {
                _layoutManager.LoadLayout(layout);
            }

            var diagramEditor = storage.GetValue <SettingsStorage>("DiagramEditor");

            if (diagramEditor != null)
            {
                DiagramEditor.Load(diagramEditor);
            }
        }
コード例 #2
0
        private void OpenComposition(CompositionItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            var content = new DiagramEditorControl
            {
                Composition = item
            };

            _layoutManager.OpenDocumentWindow(content);
        }
コード例 #3
0
        private void OpenLive(CompositionItem item)
        {
            var strategy = new DiagramStrategy
            {
                Composition = _strategiesRegistry.Clone(item.Element)
            };

            var content = new LiveStrategyControl
            {
                Strategy = strategy
            };

            _layoutManager.OpenDocumentWindow(content);
        }
コード例 #4
0
        private void AddCommand_OnExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            var type = (CompositionType)e.Parameter;

            var element = new CompositionDiagramElement
            {
                Name = "New " + type.ToString().ToLower()
            };
            var item = new CompositionItem(type, element);

            _strategiesRegistry.Save(item);

            OpenComposition(item);
        }
コード例 #5
0
        private void OpenEmulation(CompositionItem item)
        {
            var strategy = new EmulationDiagramStrategy
            {
                Composition       = _strategiesRegistry.Clone(item.Element),
                EmulationSettings = _emulationSettings.Clone()
            };

            var content = new EmulationStrategyControl
            {
                Strategy = strategy
            };

            _layoutManager.OpenDocumentWindow(content);
        }
コード例 #6
0
        public SolutionExplorerItem(CompositionDiagramElement element, SolutionExplorerItem parent)
            : this(element.TypeId, element.Name, parent)
        {
            if (element == null)
            {
                throw new ArgumentNullException(nameof(element));
            }

            if (parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }

            Type = parent.Type;

            Element = new CompositionItem(parent.Type, element);
            Element.Element.PropertyChanged += OnElementPropertyChanged;
        }
コード例 #7
0
        private void CompositionPropertyChanged(CompositionItem oldComposition, CompositionItem newComposition)
        {
            if (oldComposition != null)
            {
                oldComposition.Element.Changed -= CompositionChanged;
            }

            if (newComposition != null)
            {
                NoStrategyLabel.Visibility = Visibility.Hidden;
                DiagramEditor.Composition  = newComposition.Element;

                newComposition.Element.Changed += CompositionChanged;
            }
            else
            {
                NoStrategyLabel.Visibility = Visibility.Visible;
                DiagramEditor.Composition  = new CompositionDiagramElement {
                    Name = string.Empty
                };
            }

            IsChanged = false;
        }
コード例 #8
0
 public void Save(CompositionItem element)
 {
     Save(element.Element, element.Type == CompositionType.Composition);
 }
コード例 #9
0
 public void Discard(CompositionItem element)
 {
     Discard(element.Element, element.Type == CompositionType.Composition);
 }
コード例 #10
0
 private void SolutionExplorer_OnOpen(CompositionItem element)
 {
     OpenComposition(element);
 }
コード例 #11
0
 public void Reload(CompositionItem element)
 {
     Reload(element.Element, element.Type == CompositionType.Composition);
 }