public TransactionConsumer(TransactionContexts transactionContexts, IServiceProvider serviceProvider) { this.transactionContexts = transactionContexts; this.serviceProvider = serviceProvider; lazyBusControl = new Lazy <IBusControl>(serviceProvider.GetRequiredService <IBusControl>); }
private void AddBookmark() { IList <Bookmark> bookmarkList = null; Bookmark parentBookmark = LastHit.As <Bookmark>(); if (parentBookmark != null) { bookmarkList = parentBookmark.Bookmarks; } else { var bookmarkContext = TreeView.As <BookmarkingContext>(); if (bookmarkContext != null) { bookmarkList = bookmarkContext.Bookmarks; } } if (bookmarkList != null) { Bookmark newBookmark = new DomNode(Schema.bookmarkType.Type).As <Bookmark>(); newBookmark.Name = "New bookmark".Localize(); newBookmark.Camera = m_designView.ActiveView.Camera; ITransactionContext transactionContext = TreeView.As <ITransactionContext>(); TransactionContexts.DoTransaction( transactionContext, delegate { bookmarkList.Add(newBookmark); }, "Add bookmark".Localize()); } }
/// <summary> /// Performs custom actions on adaptable control MouseUp events; base method should /// be called first</summary> /// <param name="sender">Adaptable control</param> /// <param name="e">Event args</param> protected override void OnMouseUp(object sender, MouseEventArgs e) { base.OnMouseUp(sender, e); if (e.Button == MouseButtons.Left) { if (m_draggingNodes != null) { if (m_initiated) { ITransactionContext transactionContext = AdaptedControl.ContextAs <ITransactionContext>(); TransactionContexts.DoTransaction(transactionContext, delegate { foreach (IItemDragAdapter itemDragAdapter in AdaptedControl.AsAll <IItemDragAdapter>()) { itemDragAdapter.EndDrag(); } }, "Drag Items".Localize()); m_initiated = false; } AdaptedControl.Invalidate(); } if (m_autoTranslateAdapter != null) { m_autoTranslateAdapter.Enabled = false; } } }
private void listViewAdapter_LabelEdited(object sender, LabelEditedEventArgs <object> e) { Event _event = Adapters.As <Event>(e.Item); TransactionContexts.DoTransaction( m_eventSequenceContext, delegate { _event.Name = e.Label; }, Localizer.Localize("Rename Event")); if (m_statusService != null) { m_statusService.ShowStatus(Localizer.Localize("Rename Event")); } }
private void resourcesListViewAdapter_LabelEdited(object sender, LabelEditedEventArgs <object> e) { Resource resource = Adapters.As <Resource>(e.Item); TransactionContexts.DoTransaction( m_eventSequenceContext, delegate { resource.Name = e.Label; }, Localizer.Localize("Rename Resource")); if (m_statusService != null) { m_statusService.ShowStatus(Localizer.Localize("Rename Resource")); } }
private void listView_DragDrop(object sender, DragEventArgs e) { IInstancingContext context = m_eventSequenceContext; if (context.CanInsert(e.Data)) { ITransactionContext transactionContext = context as ITransactionContext; TransactionContexts.DoTransaction(transactionContext, delegate { context.Insert(e.Data); }, Localizer.Localize("Drag and Drop")); if (m_statusService != null) { m_statusService.ShowStatus(Localizer.Localize("Drag and Drop")); } } }
void ICommandClient.DoCommand(object commandTag) { if (CommandTag.AddLayerFolder.Equals(commandTag)) { ILayer newLayer = new DomNode(Schema.layerType.Type).As <ILayer>(); newLayer.Name = "New Layer".Localize(); IList <ILayer> layerList = null; object target = m_targetRef.Target; if (target != null) { ILayer parentLayer = Adapters.As <ILayer>(target); if (parentLayer != null) { layerList = parentLayer.Layers; } else { LayeringContext layeringContext = Adapters.As <LayeringContext>(target); if (layeringContext != null) { layerList = layeringContext.Layers; } } } if (layerList != null) { ILayeringContext layeringContext = m_contextRegistry.GetMostRecentContext <ILayeringContext>(); ITransactionContext transactionContext = Adapters.As <ITransactionContext>(layeringContext); TransactionContexts.DoTransaction( transactionContext, delegate { layerList.Add(newLayer); }, "Add Layer".Localize()); } } }
void ICommandClient.DoCommand(object commandTag) { if (Commands.AddBookmark.Equals(commandTag)) { IList <Bookmark> bookmarkList = null; Bookmark parentBookmark = Adapters.As <Bookmark>(LastHit); if (parentBookmark != null) { bookmarkList = parentBookmark.Bookmarks; } else { BookmarkingContext bookmarkContext = Adapters.As <BookmarkingContext>(LastHit); if (bookmarkContext != null) { bookmarkList = bookmarkContext.Bookmarks; } else if (Context != null) { bookmarkList = Context.Bookmarks; } } if (bookmarkList != null) { Bookmark newBookmark = new DomNode(Schema.bookmarkType.Type).As <Bookmark>(); newBookmark.Name = "New bookmark".Localize(); newBookmark.Camera = m_designView.ActiveView.Camera; ITransactionContext transactionContext = Adapters.As <ITransactionContext>(m_bookmarkContext); TransactionContexts.DoTransaction( transactionContext, delegate { bookmarkList.Add(newBookmark); }, "Add bookmark".Localize()); } } }
/// <summary> /// Ends the current label editing operation</summary> public void EndEdit() { m_labelEditTimer.Enabled = false; if (m_namingContext == null || m_item == null) { return; } if (!m_textBox.Visible) { return; } string text = m_textBox.Text; if (text != m_namingContext.GetName(m_item)) { var transactionContext = AdaptedControl.ContextAs <ITransactionContext>(); // check that some other transaction hasn't ended our edit if (transactionContext == null || !transactionContext.InTransaction) { TransactionContexts.DoTransaction(transactionContext, delegate { m_namingContext.SetName(m_item, text); }, "Edit Label".Localize()); } } m_textBox.Visible = false; m_namingContext = null; m_item = null; AdaptedControl.Invalidate(); }
/// <summary> /// Performs custom actions on adaptable control MouseUp events; base method should /// be called first</summary> /// <param name="sender">Adaptable control</param> /// <param name="e">Event args</param> protected override void OnMouseUp(object sender, MouseEventArgs e) { base.OnMouseUp(sender, e); if (e.Button == MouseButtons.Left) { if (m_isDragging) { if (m_existingEdge != null) { m_graphAdapter.ResetStyle(m_existingEdge); } if (m_disconnectEdge != null) { m_graphAdapter.ResetStyle(m_disconnectEdge); } // make sure drag changed the edge if (m_existingEdge == null || // this is a new edge m_existingEdge.ToNode != m_dragToNode || m_existingEdge.ToRoute != m_dragToRoute || m_existingEdge.FromNode != m_dragFromNode || m_existingEdge.FromRoute != m_dragFromRoute) { ITransactionContext transactionContext = AdaptedControl.ContextAs <ITransactionContext>(); TransactionContexts.DoTransaction(transactionContext, delegate { // disconnect any existing edge on the node route if (m_disconnectEdge != null) { m_editableGraph.Disconnect(m_disconnectEdge); } if (m_existingEdge != null) { m_editableGraph.Disconnect(m_existingEdge); } if (m_dragToNode != null && m_dragToRoute != null && m_dragFromNode != null && m_dragFromRoute != null) { m_editableGraph.Connect( m_dragFromNode, m_dragFromRoute, m_dragToNode, m_dragToRoute, m_existingEdge); } }, "Drag Edge".Localize()); } AdaptedControl.Invalidate(); } } if (m_autoTranslateAdapter != null) { m_autoTranslateAdapter.Enabled = false; } m_isDragging = false; m_dragFromNode = null; m_dragFromRoute = null; m_dragToNode = null; m_dragToRoute = null; m_existingEdge = null; m_disconnectEdge = null; AdaptedControl.Cursor = m_oldCursor; }
public TransactionConsumer(TransactionContexts transactionContexts) { this.transactionContexts = transactionContexts; }