void OnApplicationViewChanged(object sender, ViewStateChangedEventArgs e) { ApplicationViewState = e.ViewState; // Update the world viewport based on the view state if (ApplicationViewState == ApplicationViewState.FullScreenLandscape) { WorldViewport.Width = 1600; WorldViewport.Height = 900; } if (ApplicationViewState == ApplicationViewState.FullScreenPortrait) { WorldViewport.Width = 900; WorldViewport.Height = 1600; } if (ApplicationViewState == ApplicationViewState.Snapped) { WorldViewport.Width = GraphicsManager.ScreenViewport.Width; WorldViewport.Height = GraphicsManager.ScreenViewport.Height; } if (ApplicationViewState == ApplicationViewState.Filled) { WorldViewport.Width = 1600; WorldViewport.Height = 1200; } // Show the windows mouse if the game is snapped (to make it easier to change back to a supported state) IsMouseVisible = ApplicationViewState == ApplicationViewState.Snapped ? true : false; }
void OnViewStateChanged(object sender, ViewStateChangedEventArgs e) { if (attachedProperties.ContainsKey(e.Key)) { // Checking is required to avoid infinite loop of ViewState -> AttachedProperty -> ... if ((e.NewValue == null && e.OldValue != null) || !e.NewValue.Equals(e.OldValue)) { attachedProperties[e.Key].SetValue(e.ParentModelItem, e.NewValue); } } }
private void OnViewStateChanged(object sender, ViewStateChangedEventArgs e) { if (e.ParentModelItem == this.ModelItem && e.Key == Annotation.IsAnnotationDockedViewStateName && !this.isViewStateChangedInternally) { bool?isAnnotationDocked = e.NewValue as bool?; if (isAnnotationDocked.HasValue) { if (this.hasAnnotation) { if (isAnnotationDocked.Value) { this.DockAnnotation(); } else { this.HideAnnotation(); } } } } }
void OnViewStateChanged(object sender, ViewStateChangedEventArgs e) { Debug.Assert(e.ParentModelItem != null, "ViewState should be associated with some modelItem"); if (!this.internalViewStateChange) { if (e.ParentModelItem == this.ModelItem) { if (string.Equals(e.Key, StateContainerWidthViewStateKey, StringComparison.Ordinal)) { double defaultWidth = ((this.ModelItem.ItemType == typeof(State)) ? DefaultStateWidth : DefaultStateMachineWidth); object widthViewState = this.ViewStateService.RetrieveViewState(this.ModelItem, StateContainerWidthViewStateKey); this.StateContainerWidth = (widthViewState != null) ? (double)widthViewState : defaultWidth; } else if (string.Equals(e.Key, StateContainerHeightViewStateKey, StringComparison.Ordinal)) { double defaultHeight = ((this.ModelItem.ItemType == typeof(State)) ? DefaultStateHeight : DefaultStateMachineHeight); object heightViewState = this.ViewStateService.RetrieveViewState(this.ModelItem, StateContainerHeightViewStateKey); this.StateContainerHeight = (heightViewState != null) ? (double)heightViewState : defaultHeight; } } if (e.ParentModelItem.ItemType == typeof(State) && e.Key.Equals(ShapeLocationViewStateKey)) { if (this.modelItemToUIElement.ContainsKey(e.ParentModelItem)) { if (e.NewValue != null) { FreeFormPanel.SetLocation(this.modelItemToUIElement[e.ParentModelItem], (Point)e.NewValue); this.panel.InvalidateMeasure(); if (e.OldValue != null) { this.shapeLocations.Remove((Point)e.OldValue); } this.shapeLocations.Add((Point)e.NewValue); // To reroute the links this.InvalidateMeasureForOutmostPanel(); } } } else if (e.ParentModelItem.ItemType == typeof(State) && e.Key.Equals(ShapeSizeViewStateKey)) { // To reroute the links this.InvalidateMeasureForOutmostPanel(); } // Only the outmost editor should respond to connector changes because all connectors are // only added to the outmost editor else if (e.Key.Equals(ConnectorLocationViewStateKey) && this.IsOutmostStateContainerEditor()) { Connector changedConnector = this.GetConnectorOnOutmostEditor(e.ParentModelItem); if (changedConnector != null) { if (e.NewValue != null) { Debug.Assert(e.NewValue is PointCollection, "e.NewValue is not PointCollection"); changedConnector.Points = e.NewValue as PointCollection; this.panel.RemoveConnectorEditor(); this.InvalidateMeasureForOutmostPanel(); if (IsConnectorFromInitialNode(changedConnector)) { this.initialStateChanged = true; } } } } } }
void OnViewStateChanged(object sender, ViewStateChangedEventArgs e) { Fx.Assert(this.panel != null, "This code should not be hit if panel is null"); Fx.Assert(e.ParentModelItem != null, "ViewState should be associated with some modelItem"); Connector changedConnector = null; if (e.ParentModelItem == this.ModelItem) { if (string.Equals(e.Key, FlowchartSizeFeature.WidthPropertyName, StringComparison.Ordinal)) { this.FlowchartWidth = (double)TypeDescriptor.GetProperties(this.ModelItem)[FlowchartSizeFeature.WidthPropertyName].GetValue(this.ModelItem); } else if (string.Equals(e.Key, FlowchartSizeFeature.HeightPropertyName, StringComparison.Ordinal)) { this.FlowchartHeight = (double)TypeDescriptor.GetProperties(this.ModelItem)[FlowchartSizeFeature.HeightPropertyName].GetValue(this.ModelItem); } } if ((IsFlowNode(e.ParentModelItem) || this.ModelItem.Equals(e.ParentModelItem)) && !this.internalViewStateChange) { ModelItem itemOnCanvas = this.GetCorrespondingElementOnCanvas(e.ParentModelItem); if (this.modelElement.ContainsKey(itemOnCanvas)) { if (e.Key.Equals(shapeLocation)) { if (e.NewValue != null) { FreeFormPanel.SetLocation(this.modelElement[itemOnCanvas], (Point)e.NewValue); this.panel.InvalidateMeasure(); if (e.OldValue != null) { this.shapeLocations.Remove((Point)e.OldValue); } this.shapeLocations.Add((Point)e.NewValue); } } else { if (this.ModelItem.Equals(e.ParentModelItem) && e.Key.Equals(ConnectorViewStateKey)) { changedConnector = this.GetLinkOnCanvas(e.ParentModelItem, e.ParentModelItem.Properties["StartNode"].Value, "StartNode"); } else if (typeof(FlowStep).IsAssignableFrom(e.ParentModelItem.ItemType) && e.Key.Equals(ConnectorViewStateKey)) { changedConnector = this.GetLinkOnCanvas(e.ParentModelItem, e.ParentModelItem.Properties["Next"].Value, "Next"); } else if (typeof(FlowDecision).IsAssignableFrom(e.ParentModelItem.ItemType)) { if (e.Key.Equals(TrueConnectorViewStateKey)) { changedConnector = this.GetLinkOnCanvas(e.ParentModelItem, e.ParentModelItem.Properties["True"].Value, "True"); } else if (e.Key.Equals(FalseConnectorViewStateKey)) { changedConnector = this.GetLinkOnCanvas(e.ParentModelItem, e.ParentModelItem.Properties["False"].Value, "False"); } } else if (GenericFlowSwitchHelper.IsGenericFlowSwitch(e.ParentModelItem.ItemType)) { if (e.Key.Equals(FlowchartDesigner.FlowSwitchDefaultViewStateKey, StringComparison.CurrentCulture)) { changedConnector = this.GetLinkOnCanvas(e.ParentModelItem, e.ParentModelItem.Properties["Default"].Value, e.Key); } else if (e.Key.EndsWith(CaseViewStateKeyAppendString, StringComparison.CurrentCulture)) { string switchCaseName = e.Key.Substring(0, e.Key.Length - CaseViewStateKeyAppendString.Length); object switchCase = switchCaseName; Type genericType = e.ParentModelItem.ItemType.GetGenericArguments()[0]; switchCase = GenericFlowSwitchHelper.GetObject(switchCaseName, genericType); if (GenericFlowSwitchHelper.ContainsCaseKey(e.ParentModelItem.Properties["Cases"], switchCase)) { //Prepending with GenericFlowSwitchHelper.FlowSwitchCasesKeyIdentifier to differentiate between the property Default and the key Default. changedConnector = this.GetLinkOnCanvas(e.ParentModelItem, GenericFlowSwitchHelper.GetCaseModelItem(e.ParentModelItem.Properties["Cases"], switchCase), GenericFlowSwitchHelper.FlowSwitchCasesKeyIdentifier + switchCase); } } } } } } if (changedConnector != null) { if (e.NewValue != null) { Fx.Assert(e.NewValue is PointCollection, "e.NewValue is not PointCollection"); changedConnector.Points = e.NewValue as PointCollection; this.panel.RemoveConnectorEditor(); this.panel.InvalidateMeasure(); } } }
void OnViewStateChanged(object sender, ViewStateChangedEventArgs e) { NotifyModelChanged(); }