public static void OnAddAnnotationCommandExecuted(ExecutedRoutedEventArgs e, ModelItem modelItem) { ModelProperty property = modelItem.Properties.Find(Annotation.AnnotationTextPropertyName); if (property != null) { using (ModelEditingScope editingScope = modelItem.BeginEdit(SR.AddAnnotationDescription)) { property.SetValue(string.Empty); ViewStateService viewStateService = modelItem.GetEditingContext().Services.GetService <ViewStateService>(); viewStateService.StoreViewStateWithUndo(modelItem, Annotation.IsAnnotationDockedViewStateName, false); editingScope.Complete(); } if (modelItem.View != null) { WorkflowViewElement element = modelItem.View as WorkflowViewElement; if (element != null) { element.OnEditAnnotation(); } } } e.Handled = true; }
public static void OnDeleteAnnotationCommandExecuted(ExecutedRoutedEventArgs e, ModelItem modelItem) { using (ModelEditingScope editingScope = modelItem.BeginEdit(SR.DeleteAnnotationDescription)) { modelItem.Properties[Annotation.AnnotationTextPropertyName].SetValue(null); ViewStateService viewStateService = modelItem.GetEditingContext().Services.GetService <ViewStateService>(); viewStateService.StoreViewStateWithUndo(modelItem, Annotation.IsAnnotationDockedViewStateName, null); editingScope.Complete(); } e.Handled = true; }
protected override void OnModelItemChanged(object newItem) { ViewStateService viewStateService = this.Context.Services.GetService <ViewStateService>(); if (viewStateService != null) { // Make StateMachine designer always collapsed by default, but only if the user didn't explicitly specify collapsed or expanded. bool?isExpanded = (bool?)viewStateService.RetrieveViewState((ModelItem)newItem, ExpandViewStateKey); if (isExpanded == null) { viewStateService.StoreViewState((ModelItem)newItem, ExpandViewStateKey, false); } } base.OnModelItemChanged(newItem); }
void UpdateViewState(string oldValue, string newValue) { EditingContext context = this.flowSwitchModelItem.GetEditingContext(); ViewStateService viewStateService = (ViewStateService)context.Services.GetService(typeof(ViewStateService)); if (viewStateService != null) { object viewState = viewStateService.RetrieveViewState(this.flowSwitchModelItem, oldValue); if (viewState != null) { viewStateService.StoreViewStateWithUndo(this.flowSwitchModelItem, oldValue, null); viewStateService.StoreViewStateWithUndo(this.flowSwitchModelItem, newValue, viewState); } } }
protected override void OnPreviewMouseLeftButtonUp(MouseButtonEventArgs e) { if (e != null && !this.Disabled && this.scope != null) { ModelItem stateContainerModelItem = this.ParentStateContainerEditor.ModelItem; ViewStateService viewStateService = this.ParentStateContainerEditor.Context.Services.GetService <ViewStateService>(); viewStateService.StoreViewStateWithUndo(stateContainerModelItem, StateContainerEditor.StateContainerWidthViewStateKey, this.ParentStateContainerEditor.StateContainerWidth); viewStateService.StoreViewStateWithUndo(stateContainerModelItem, StateContainerEditor.StateContainerHeightViewStateKey, this.ParentStateContainerEditor.StateContainerHeight); Mouse.OverrideCursor = null; Mouse.Capture(null); StateMachineDesigner stateMachineDesigner = VisualTreeUtils.FindVisualAncestor <StateMachineDesigner>(this.ParentStateContainerEditor); stateMachineDesigner.IsResizing = false; e.Handled = true; } base.OnPreviewMouseLeftButtonUp(e); }
void OnLoaded(object sender, RoutedEventArgs e) { this.Context.Items.Subscribe <Selection>(OnSelectionChanged); this.ModelItem.PropertyChanged += OnModelItemPropertyChanged; ViewStateService viewStateService = this.Context.Services.GetService <ViewStateService>(); foreach (ModelItem modelItem in this.ModelItem.Properties["Cases"].Dictionary.Properties["ItemsCollection"].Collection) { bool?isExpanded = (bool?)viewStateService.RetrieveViewState(modelItem, ExpandViewStateKey); if (isExpanded != null && isExpanded.Value) { this.SelectedCase = modelItem; CollapseDefaultView(); break; } } }
protected override void OnPreviewMouseLeftButtonUp(MouseButtonEventArgs e) { if (e != null && !this.Disabled) { ModelItem stateContainerModelItem = this.ParentStateContainerEditor.ModelItem; // Save the new size to view state. using (ModelEditingScope scope = stateContainerModelItem.BeginEdit(SR.Resize)) { ViewStateService viewStateService = this.ParentStateContainerEditor.Context.Services.GetService <ViewStateService>(); viewStateService.StoreViewStateWithUndo(stateContainerModelItem, StateContainerEditor.StateContainerWidthViewStateKey, this.ParentStateContainerEditor.StateContainerWidth); viewStateService.StoreViewStateWithUndo(stateContainerModelItem, StateContainerEditor.StateContainerHeightViewStateKey, this.ParentStateContainerEditor.StateContainerHeight); scope.Complete(); } Mouse.OverrideCursor = null; Mouse.Capture(null); e.Handled = true; } base.OnPreviewMouseLeftButtonUp(e); }
static void Main(string[] args) { _userService = new UserService(); _vsService = new ViewStateService(); _telegramService = new TelegramService(); MyBot.Api.OnCallbackQuery += BotOnCallbackQueryReceived; MyBot.Api.OnMessage += BotOnMessageReceived; MyBot.Api.OnMessageEdited += BotOnMessageReceived; MyBot.Api.OnReceiveError += BotOnReceiveError; MyBot.Api.SetWebhookAsync().Wait(); var me = MyBot.Api.GetMeAsync().Result; Console.Title = me.Username; MyBot.Api.StartReceiving(); Console.ReadLine(); MyBot.Api.StopReceiving(); }
void OnLoaded(object sender, RoutedEventArgs e) { this.Context.Items.Subscribe <Selection>(OnSelectionChanged); // at this time, this.ModelItem is already set this.ModelItem.PropertyChanged += OnModelItemPropertyChanged; this.ModelItem.Properties[CatchesPropertyName].Collection.CollectionChanged += OnModelItemCollectionChanged; ViewStateService viewStateService = this.Context.Services.GetService <ViewStateService>(); foreach (ModelItem modelItem in this.ModelItem.Properties["Catches"].Collection) { bool?isExpanded = (bool?)viewStateService.RetrieveViewState(modelItem, ExpandViewStateKey); if (isExpanded != null && isExpanded.Value) { this.SelectedCatch = modelItem; CollapseTryView(); CollapseFinallyView(); break; } } }
public sealed override void Initialize(EditingContext context, Type modelType) { this.modelType = modelType; context.Services.Subscribe <ViewStateService>(delegate(ViewStateService viewStateService) { this.viewStateService = viewStateService; viewStateService.ViewStateChanged += this.OnViewStateChanged; if (this.attachedPropertiesService != null) { RegisterAttachedProperties(); } }); context.Services.Subscribe <AttachedPropertiesService>(delegate(AttachedPropertiesService attachedPropertiesService) { this.attachedPropertiesService = attachedPropertiesService; if (this.viewStateService != null) { RegisterAttachedProperties(); } }); }
public PublicState() { _userService = new UserService(); _vsService = new ViewStateService(); }