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); } }
private void OpenComposition(CompositionItem item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } var content = new DiagramEditorControl { Composition = item }; _layoutManager.OpenDocumentWindow(content); }
private void OpenLive(CompositionItem item) { var strategy = new DiagramStrategy { Composition = _strategiesRegistry.Clone(item.Element) }; var content = new LiveStrategyControl { Strategy = strategy }; _layoutManager.OpenDocumentWindow(content); }
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); }
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); }
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; }
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; }
public void Save(CompositionItem element) { Save(element.Element, element.Type == CompositionType.Composition); }
public void Discard(CompositionItem element) { Discard(element.Element, element.Type == CompositionType.Composition); }
private void SolutionExplorer_OnOpen(CompositionItem element) { OpenComposition(element); }
public void Reload(CompositionItem element) { Reload(element.Element, element.Type == CompositionType.Composition); }