/// <summary> /// Initializes a new instance of the <see cref="ActiveViewManager"/> class. /// </summary> /// <param name="hostControl">Control that host region</param> /// <param name="observableRegion">The region</param> public ActiveViewManager(DependencyObject hostControl, ObservableObject<IRegion> observableRegion) { HostControl = hostControl; ObservableRegion = observableRegion; ObservableRegion.PropertyChanged += ObservableRegionOnPropertyChanged; EnsureBehaviorAdded(); }
public MainWindowViewModel() { content = new LaunchMenuViewModel(); BeginGame = new RelayCommand<NumberOfPlayers>(n => { Content = new GameViewModel(); ((GameViewModel)Content).StartGame(n); }); AbandonGame = new RelayCommand(() => Content = new LaunchMenuViewModel()); }
/// <summary> /// Returns an <see cref="ObservableObject{T}"/> wrapper that can hold an <see cref="IRegion"/>. Using this wrapper /// you can detect when an <see cref="IRegion"/> has been created by the <see cref="RegionAdapterBase{T}"/>. /// /// If the <see cref="ObservableObject{T}"/> wrapper does not yet exist, a new wrapper will be created. When the region /// gets created and assigned to the wrapper, you can use the <see cref="ObservableObject{T}.PropertyChanged"/> event /// to get notified of that change. /// </summary> /// <param name="view">The view that will host the region. </param> /// <returns>Wrapper that can hold an <see cref="IRegion"/> value and can notify when the <see cref="IRegion"/> value changes. </returns> public static ObservableObject <IRegion> GetObservableRegion(DependencyObject view) { ObservableObject <IRegion> regionWrapper = view.GetValue(ObservableRegionProperty) as ObservableObject <IRegion>; if (regionWrapper == null) { regionWrapper = new ObservableObject <IRegion>(); view.SetValue(ObservableRegionProperty, regionWrapper); } return(regionWrapper); }
/// <summary> /// Returns an <see cref="ObservableObject{T}"/> wrapper around the RegionContext value. The RegionContext /// will be set on any views (dependency objects) that are inside the <see cref="IRegion.Views"/> collection by /// the <see cref="BindRegionContextToDependencyObjectBehavior"/> Behavior. /// The RegionContext will also be set to the control that hosts the Region, by the <see cref="SyncRegionContextWithHostBehavior"/> Behavior. /// /// If the <see cref="ObservableObject{T}"/> wrapper does not already exist, an empty one will be created. This way, an observer can /// notify when the value is set for the first time. /// </summary> /// <param name="view">Any view that hold the RegionContext value. </param> /// <returns>Wrapper around the Regioncontext value. </returns> public static ObservableObject<object> GetObservableContext(DependencyObject view) { ObservableObject<object> context = view.GetValue(ObservableRegionContextProperty) as ObservableObject<object>; if (context == null) { context = new ObservableObject<object>(); view.SetValue(ObservableRegionContextProperty, context); } return context; }
private static void SetContextToViews(IEnumerable views, object context) { foreach (var view in views) { DependencyObject dependencyObjectView = view as DependencyObject; if (dependencyObjectView != null) { ObservableObject <object> contextWrapper = RegionContext.GetObservableContext(dependencyObjectView); contextWrapper.Value = context; } } }
private void DetachNotifyChangeEvent(IEnumerable views) { foreach (var view in views) { var dependencyObject = view as DependencyObject; if (dependencyObject != null) { ObservableObject <object> viewRegionContext = RegionContext.GetObservableContext(dependencyObject); viewRegionContext.PropertyChanged -= this.ViewRegionContext_OnPropertyChangedEvent; } } }
public MainPage() { InitializeComponent(); Client = ((App)Application.Current).client; Profile = new ObservableObject <FB_User>(); SelectedThread = new ObservableObject <FB_Thread>(); Threads = new ObservableCollection <FB_Thread>(); Messages = new ObservableCollection <FB_Message>(); this.DataContext = this; this.Loaded += MainPage_Loaded; this.Unloaded += MainPage_Unloaded; }
/// <summary> /// Returns an <see cref="ObservableObject{T}"/> wrapper around the RegionContext value. The RegionContext /// will be set on any views (dependency objects) that are inside the <see cref="IRegion.Views"/> collection by /// the <see cref="BindRegionContextToDependencyObjectBehavior"/> Behavior. /// The RegionContext will also be set to the control that hosts the Region, by the <see cref="SyncRegionContextWithHostBehavior"/> Behavior. /// /// If the <see cref="ObservableObject{T}"/> wrapper does not already exist, an empty one will be created. This way, an observer can /// notify when the value is set for the first time. /// </summary> /// <param name="view">Any view that hold the RegionContext value. </param> /// <returns>Wrapper around the Regioncontext value. </returns> public static ObservableObject <object> GetObservableContext(DependencyObject view) { ObservableObject <object> context = view.GetValue(ObservableRegionContextProperty) as ObservableObject <object>; if (context == null) { context = new ObservableObject <object>(); view.SetValue(ObservableRegionContextProperty, context); } return(context); }
public static void Update(ObservableObject sender, VcProperties property, object newValue, Boolean isAxisChanged) { Boolean isDataPoint = sender.GetType().Equals(typeof(DataPoint)); if (isDataPoint) { UpdateDataPoint(sender as DataPoint, property, newValue, isAxisChanged); } else { UpdateDataSeries(sender as DataSeries, property, newValue, isAxisChanged); } }
static ModelValueNodeAdapter() { IPropertyAdapterFactory <ModelValueNodeAdapter> Factory = ObservableObject.GetPropertyAdapterFactory <ModelValueNodeAdapter>(); ModelValueNodeAdapter.typenameAdapter = Factory.Create( nameof(ModelValueNodeAdapter.Typename), instance => instance.model.Type == null ? "<null>" : instance.model.Type.Name ); ModelValueNodeAdapter.valueAdapter = Factory.Create( nameof(ModelValueNodeAdapter.Value), instance => instance.model.Value ); }
internal static bool HasObservableProperties([NotNull] ObservableObject observableObject) { var type = observableObject.GetType(); var propertyAccessors = ObservableObjectTypeCache.TryGet(type); if (propertyAccessors != null) { return(propertyAccessors.Count > 0); } return(GetPropertiesAnnotatedAsObservable(type).Any(property => property.GetIndexParameters().Length == 0)); }
internal void Register([NotNull] ObservableObject observableObject) { var observableObjectInfo = observableObjectTable.GetValue(observableObject, o => new ObservableObjectInfo(o)); Debug.Assert(observableObjectInfo != null); var set = observableObject.IsThreadSafe ? observableObjectInfos.ThreadSafe : observableObjectInfos.ThreadAffine; lock (observableObjectTable) { set.Add(observableObjectInfo); } }
/// <summary> /// Returns an <see cref="ObservableObject{T}"/> wrapper around the RegionContext value. The RegionContext /// will be set on any views (dependency objects) that are inside the <see cref="IRegion.Views"/> collection by /// the <see cref="BindRegionContextToDependencyObjectBehavior"/> Behavior. /// The RegionContext will also be set to the control that hosts the Region, by the <see cref="SyncRegionContextWithHostBehavior"/> Behavior. /// /// If the <see cref="ObservableObject{T}"/> wrapper does not already exist, an empty one will be created. This way, an observer can /// notify when the value is set for the first time. /// </summary> /// <param name="view">Any view that hold the RegionContext value. </param> /// <returns>Wrapper around the Regioncontext value. </returns> public static ObservableObject<object> GetObservableContext(DependencyObject view) { if (view == null) throw new ArgumentNullException("view"); var context = view.GetValue(ObservableRegionContextProperty) as ObservableObject<object>; if (context == null) { context = new ObservableObject<object>(); view.SetValue(ObservableRegionContextProperty, context); } return context; }
/// <summary> /// Raises the property change notification for the specified <see cref="ObservableObject"/>. /// </summary> /// <param name="observable">The target observable.</param> /// <param name="propertyName">The name of the property that changed.</param> public void Raise(ObservableObject observable, string propertyName) { if (string.IsNullOrEmpty(propertyName)) { observable.OnPropertyChanged(EventArgsCache.ObjectPropertyChanged); return; } observable.ValidateProperty(propertyName); observable.OnPropertyChanged(new PropertyChangedEventArgs(propertyName)); }
public InsureeAddOrEditViewModel(ILogger <InsureeAddOrEditViewModel> logger, IInsureeManagementAppService insureeManagementAppService, INavigationAppService navigationAppService) { _logger = logger; _insureeManagementAppService = insureeManagementAppService; _navigationAppService = navigationAppService; ConfirmationRequest = new InteractionRequest <IConfirmation>(); Insuree = new ObservableObject <AddOrEditInsuree>(); SaveAddOrEditInsureeCommand = new DelegateCommand(SaveAddOrEditInsureeExecute, CanSaveAddOrEditInsuree); CancelAddOrEditInsureeCommand = new DelegateCommand(CancelAddOrEditInsureeExecute); }
void View_RegionContextChanged(object sender, EventArgs e) { ObservableObject <object> regionContext = sender as ObservableObject <object>; if (regionContext == null) { return; } if (this.Region.Context != regionContext.Value) { this.Region.Context = regionContext.Value; } }
IEnumerator Start() { // Just a little hack to make sure the found object is set. // Unity is going to have race conditions when all objects are added // to the scene on start up, you don't know order scripts will execute in yield return(new WaitForEndOfFrame()); GameObject foundObj = gameObject.GetComponent <Finder>().FoundObject; if (foundObj) { objToObserve = foundObj.GetComponent <ObservableObject>(); } }
/// <summary> /// Returns an <see cref="ObservableObject{T}"/> wrapper around the RegionContext value. The RegionContext /// will be set on any views (dependency objects) that are inside the <see cref="IRegion.Views"/> collection by /// the <see cref="BindRegionContextToDependencyObjectBehavior"/> Behavior. /// The RegionContext will also be set to the control that hosts the Region, by the <see cref="SyncRegionContextWithHostBehavior"/> Behavior. /// /// If the <see cref="ObservableObject{T}"/> wrapper does not already exist, an empty one will be created. This way, an observer can /// notify when the value is set for the first time. /// </summary> /// <param name="view">Any view that hold the RegionContext value. </param> /// <returns>Wrapper around the Regioncontext value. </returns> public static ObservableObject<object> GetObservableContext(DependencyObject view) { if (view == null) throw new ArgumentNullException("view"); ObservableObject<object> context = view.GetValue(ObservableRegionContextProperty) as ObservableObject<object>; if (context == null) { context = new ObservableObject<object>(); view.SetValue(ObservableRegionContextProperty, context); } return context; }
public static void Update(ObservableObject sender, VcProperties property, object newValue, Boolean isAxisChanged) { Boolean isDataPoint = sender.GetType().Equals(typeof(DataPoint)); if (isDataPoint) { DataSeries ds = (sender as DataPoint).Parent; if (ds != null && (property == VcProperties.YValue || property == VcProperties.XValue)) UpdateDataSeries(ds, property, newValue); } else UpdateDataSeries(sender as DataSeries, property, newValue); }
public void ParameteredConstructor_AssessmentSectionIsNull_ThrowsArgumentNullException() { // Setup var observableObject = new ObservableObject(); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); // Call TestDelegate call = () => new SimpleGrassCoverErosionInwardsContext <ObservableObject>(observableObject, failureMechanism, null); // Assert var exception = Assert.Throws <ArgumentNullException>(call); Assert.AreEqual("assessmentSection", exception.ParamName); }
static T0ProtocolParameterAdapter() { IPropertyAdapterFactory <T0ProtocolParameterAdapter> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <T0ProtocolParameterAdapter>(); T0ProtocolParameterAdapter.waitingTimeIntegerAdapter = PropertyFactory.Create( nameof(T0ProtocolParameterAdapter.WaitingTimeInteger), instance => instance.protocolParameters.WaitingTimeIntegerValue, // read value or default (instance, value) => instance.protocolParameters.WaitingTimeInteger = value // set fix value ); T0ProtocolParameterAdapter.waitingTimeIntegerIsDefaultAdapter = PropertyFactory.Create( nameof(T0ProtocolParameterAdapter.WaitingTimeIntegerIsDefault), instance => instance.protocolParameters.WaitingTimeInteger.HasValue == false ); }
internal PropertyValueBag([NotNull] ObservableObject observableObject, [NotNull] PropertyPropertyAccessor propertyAccessor) { this.propertyAccessor = propertyAccessor; try { currentValue = propertyAccessor.Getter(observableObject); isValueValid = true; } catch (Exception e) { EventSource.Log.UnableInitiallyToReadProperty(propertyAccessor.ObjectTypeName, propertyAccessor.Name, e.ToString()); } }
/// <summary> /// Shows the exception dialog. /// </summary> /// <param name="exception">The exception.</param> /// <returns></returns> public Task ShowExceptionDialog(Exception exception) { if (IsOpen) // no exception spam, could probably be improved TODO ? { return(Task.CompletedTask); } TitleDetail = string.Empty; Context = ExceptionDialogViewModel; Title = exception.GetType().Name; ExceptionDialogViewModel.Exception = exception; IsCancelVisible = false; return(Open()); }
/// <summary> /// Shows the message dialog. /// </summary> /// <param name="message">The message.</param> /// <param name="title">The title.</param> /// <returns></returns> /// <exception cref="System.InvalidOperationException"></exception> public Task ShowMessageDialog(string message, string title) { if (IsOpen) { throw new InvalidOperationException(Resources.DialogOpenAlready); } TitleDetail = string.Empty; Context = MessageDialogViewModel; Title = title; MessageDialogViewModel.Message = message; IsCancelVisible = false; return(Open()); }
static TestProxy() { TestProxy.propertyAdapter = ObservableObject.GetPropertyAdapterFactory <TestProxy>().Create( nameof(TestProxy.Property), _ => _.value.Property, (_, value) => _.value.Property = value); TestProxy.twoPropertiesAdapter = ObservableObject.GetPropertyAdapterFactory <TestProxy>().Create( nameof(TestProxy.TwoProperties), _ => _.value.Property + _.value.Property2); TestProxy.complexPropertyAdapter = ObservableObject.GetPropertyAdapterFactory <TestProxy>().Create( nameof(TestProxy.ComplexProperty), _ => _.value.Property + _.value.Property + _.value.Property); }
static ModelGroupAdapter() { IPropertyAdapterFactory <ModelGroupAdapter> Factory = ObservableObject.GetPropertyAdapterFactory <ModelGroupAdapter>(); ModelGroupAdapter.modelsAdapter = Factory.Create( nameof(ModelGroupAdapter.Models), instance => instance.Group.Models, (instance, model) => new ModelInfoAdapter(instance, model) ); ModelGroupAdapter.nameAdapter = Factory.Create( nameof(ModelGroupAdapter.Name), instance => instance.Group.Name, (instance, value) => instance.Group.Name = value ); }
/// <summary> /// Returns an <see cref="ObservableObject{T}"/> wrapper around the RegionContext value. The RegionContext /// will be set on any views (BindableObject's) that are inside the <see cref="IRegion.Views"/> collection by /// the <see cref="BindRegionContextToVisualElementBehavior"/> Behavior. /// The RegionContext will also be set to the control that hosts the Region, by the <see cref="SyncRegionContextWithHostBehavior"/> Behavior. /// /// If the <see cref="ObservableObject{T}"/> wrapper does not already exist, an empty one will be created. This way, an observer can /// notify when the value is set for the first time. /// </summary> /// <param name="view">Any view that hold the RegionContext value. </param> /// <returns>Wrapper around the Regioncontext value. </returns> public static ObservableObject <object> GetObservableContext(VisualElement view) { if (view == null) { throw new ArgumentNullException(nameof(view)); } if (!(view.GetValue(ObservableRegionContextProperty) is ObservableObject <object> context)) { context = new ObservableObject <object>(); view.SetValue(ObservableRegionContextProperty, context); } return(context); }
public static ObservableObject <IRegion> GetObservableRegion(DependencyObject view) { if (view == null) { throw new ArgumentNullException("view"); } ObservableObject <IRegion> regionWrapper = view.GetValue(ObservableRegionProperty) as ObservableObject <IRegion>; if (regionWrapper == null) { regionWrapper = new ObservableObject <IRegion>(); view.SetValue(ObservableRegionProperty, regionWrapper); } return(regionWrapper); }
/// <summary> /// Returns an <see cref="ObservableObject{T}"/> wrapper that can hold an <see cref="IRegion"/>. Using this wrapper /// you can detect when an <see cref="IRegion"/> has been created by the <see cref="RegionAdapterBase{T}"/>. /// /// If the <see cref="ObservableObject{T}"/> wrapper does not yet exist, a new wrapper will be created. When the region /// gets created and assigned to the wrapper, you can use the <see cref="ObservableObject{T}"/> event /// to get notified of that change. /// </summary> /// <param name="view">The view that will host the region. </param> /// <returns>Wrapper that can hold an <see cref="IRegion"/> value and can notify when the <see cref="IRegion"/> value changes. </returns> public static ObservableObject <IRegion> GetObservableRegion(VisualElement view) { if (view is null) { throw new ArgumentNullException(nameof(view)); } if (!(view.GetValue(ObservableRegionProperty) is ObservableObject <IRegion> regionWrapper)) { regionWrapper = new ObservableObject <IRegion>(); view.SetValue(ObservableRegionProperty, regionWrapper); } return(regionWrapper); }
public static void NavigateToView(UserControl view, ObservableObject viewModel) { if (view != null) { ((MainWindow)App.Current.MainWindow).ContentHolder.Children.Remove(NavigationController.currentView); if (viewModel != null) { view.DataContext = viewModel; } ((MainWindow)App.Current.MainWindow).ContentHolder.Children.Add(view); NavigationController.currentView = view; } }
public static bool DispatchSet <T>(this ObservableObject observableObject, string propertyName, ref T field, T newValue) { #if PORTABLE throw NotSupported(); #else if (EqualityComparer <T> .Default.Equals(field, newValue)) { return(false); } field = newValue; MainThreadDispatcher.Instance.Execute(() => observableObject.RaisePropertyChanged(propertyName)); return(true); #endif }
public virtual void EntityViewModelPropertyChanged(object sender, EventArgs e) { ObservableObject observableObj = sender as ObservableObject; if (observableObj != null) { observableObj.RaisePropertyChanged(String.Empty); Debug.WriteLine("a domain has changed"); } else { throw new Exception("sender of propertychanged is not of type ObservableObject"); } //This will get called when the property of an object inside the collection changes }
static AtrRfuHistoricalBytesAdapter() { IPropertyAdapterFactory <AtrRfuHistoricalBytesAdapter> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <AtrRfuHistoricalBytesAdapter>(); AtrRfuHistoricalBytesAdapter.structureIndicatorAdapter = PropertyFactory.Create( nameof(AtrRfuHistoricalBytesAdapter.CategoryIndicator), instance => instance.historicalCharacters.CategoryIndicator.ToHexString(), (instance, value) => Helper.SetAsHexByteValue(value, _ => instance.historicalCharacters.CategoryIndicator = _) ); AtrRfuHistoricalBytesAdapter.dataAdapter = PropertyFactory.Create( nameof(AtrRfuHistoricalBytesAdapter.Bytes), instance => instance.historicalCharacters.Bytes.ToHexString(" "), (instance, value) => Helper.SetAsHexValue(value, 0, 15, _ => instance.historicalCharacters.Bytes = _) ); }
internal void Unregister([NotNull] ObservableObject observableObject) { ObservableObjectInfo observableObjectInfo; if (observableObjectTable.TryGetValue(observableObject, out observableObjectInfo)) { var set = observableObject.IsThreadSafe ? observableObjectInfos.ThreadSafe : observableObjectInfos.ThreadAffine; lock (observableObjectTable) { set.Remove(observableObjectInfo); } } observableObjectTable.Remove(observableObject); }
private bool ViewModel_OpenLockWindowEvent(ObservableObject viewModel) { bool isDialogResult = false; if (viewModel is LockWindowViewModel lockWindowViewModel) { LockWindow configWindow = new LockWindow() { Owner = this, DataContext = lockWindowViewModel }; isDialogResult = (configWindow.ShowDialog() == true); } return(isDialogResult); }
public ViewModelBinding(ConsoleControl control, PropertyInfo controlProperty, ObservableObject viewModel, string observablePropertyName) { var viewModelObservableProperty = viewModel.GetType().GetProperty(observablePropertyName); if (viewModelObservableProperty.PropertyType != controlProperty.PropertyType && viewModelObservableProperty.PropertyType.IsSubclassOf(controlProperty.PropertyType) == false && viewModelObservableProperty.PropertyType.GetInterfaces().Contains(controlProperty.PropertyType) == false) { throw new InvalidOperationException($"ViewModel property '{viewModel.GetType().FullName}.{observablePropertyName}' of type {viewModelObservableProperty.PropertyType.FullName} is not compatible with control property '{controlProperty.DeclaringType.FullName}.{controlProperty.Name}' of type {controlProperty.PropertyType.FullName} "); } viewModel.SynchronizeForLifetime(observablePropertyName, () => { var newValue = viewModelObservableProperty.GetValue(viewModel); if (newValue == latestValue) return; latestValue = newValue; controlProperty.SetValue(control, newValue); }, control.LifetimeManager); control.SubscribeForLifetime(controlProperty.Name, () => { var newValue = controlProperty.GetValue(control); if (newValue == latestValue) return; latestValue = newValue; viewModelObservableProperty.SetValue(viewModel, newValue); }, control.LifetimeManager); }
/// <summary> /// Returns an <see cref="ObservableObject{T}"/> wrapper that can hold an <see cref="IRegion"/>. Using this wrapper /// you can detect when an <see cref="IRegion"/> has been created by the <see cref="RegionAdapterBase{T}"/>. /// /// If the <see cref="ObservableObject{T}"/> wrapper does not yet exist, a new wrapper will be created. When the region /// gets created and assigned to the wrapper, you can use the <see cref="ObservableObject{T}.PropertyChanged"/> event /// to get notified of that change. /// </summary> /// <param name="view">The view that will host the region. </param> /// <returns>Wrapper that can hold an <see cref="IRegion"/> value and can notify when the <see cref="IRegion"/> value changes. </returns> public static ObservableObject<IRegion> GetObservableRegion(DependencyObject view) { ObservableObject<IRegion> regionWrapper = view.GetValue(ObservableRegionProperty) as ObservableObject<IRegion>; if (regionWrapper == null) { regionWrapper = new ObservableObject<IRegion>(); view.SetValue(ObservableRegionProperty, regionWrapper); } return regionWrapper; }
/// <summary> /// Attach events to Area faces /// </summary> /// <param name="Object">Object where events to be attached</param> internal void AttachEvent2AreaVisualFaces(ObservableObject Object) { if (Faces != null) { foreach (FrameworkElement face in Faces.VisualComponents) AttachEvents2AreaVisual(Object, this, face); } foreach (DataPoint dp in InternalDataPoints) { dp.AttachEvent2DataPointVisualFaces(this); } }
/// <summary> /// /// </summary> /// <param name="obj">Object may be DataSeries or DataPoint</param> /// <param name="property"></param> /// <param name="newValue"></param> private static void UpdateDataSeries(ObservableObject obj, VcProperties property, object newValue) { DataPoint dataPoint = null; DataSeries dataSeries = obj as DataSeries; Boolean isDataPoint = false; if (dataSeries == null) { isDataPoint = true; dataPoint = obj as DataPoint; dataSeries = dataPoint.Parent; } Chart chart = dataSeries.Chart as Chart; if (chart == null) return; PlotGroup plotGroup = dataSeries.PlotGroup; Canvas line2dCanvas = null; Canvas label2dCanvas = null; Path linePath = null; Path lineShadowPath = null; if (dataSeries.Faces != null) { if (dataSeries.Faces.Parts.Count > 0) { linePath = dataSeries.Faces.Parts[0] as Path; if (dataSeries.Faces.Parts.Count > 1) lineShadowPath = dataSeries.Faces.Parts[1] as Path; } line2dCanvas = dataSeries.Faces.Visual as Canvas; label2dCanvas = dataSeries.Faces.LabelCanvas as Canvas; } else if (dataSeries.Faces == null && property == VcProperties.Enabled && (Boolean)newValue == true) { ColumnChart.Update(chart, dataSeries.RenderAs, (from ds in chart.InternalSeries where ds.RenderAs == RenderAs.Spline || ds.RenderAs == RenderAs.Line select ds).ToList()); return; } else return; Double height = chart.ChartArea.ChartVisualCanvas.Height; Double width = chart.ChartArea.ChartVisualCanvas.Width; switch (property) { case VcProperties.Color: if (linePath != null) { Brush lineColorValue = (newValue != null) ? newValue as Brush : dataSeries.Color; linePath.Stroke = ((Boolean)dataSeries.LightingEnabled) ? Graphics.GetLightingEnabledBrush(lineColorValue, "Linear", new Double[] { 0.65, 0.55 }) : lineColorValue; //dataPoint.Color; } break; case VcProperties.LightingEnabled: if (linePath != null) linePath.Stroke = ((Boolean)newValue) ? Graphics.GetLightingEnabledBrush(dataSeries.Color, "Linear", new Double[] { 0.65, 0.55 }) : dataSeries.Color; break; case VcProperties.Opacity: if (linePath != null) linePath.Opacity = (Double)dataSeries.Opacity; break; case VcProperties.LineStyle: case VcProperties.LineThickness: if (lineShadowPath != null) lineShadowPath.StrokeThickness = (Double)dataSeries.LineThickness; if (linePath != null) linePath.StrokeThickness = (Double)dataSeries.LineThickness; if (lineShadowPath != null) lineShadowPath.StrokeDashArray = ExtendedGraphics.GetDashArray(dataSeries.LineStyle); if (linePath != null) linePath.StrokeDashArray = ExtendedGraphics.GetDashArray(dataSeries.LineStyle); break; case VcProperties.Enabled: if (!isDataPoint && line2dCanvas != null) { if ((Boolean)newValue == false) { line2dCanvas.Visibility = Visibility.Collapsed; label2dCanvas.Visibility = Visibility.Collapsed; } else { if (line2dCanvas.Parent == null) { ColumnChart.Update(chart, dataSeries.RenderAs, (from ds in chart.InternalSeries where ds.RenderAs == RenderAs.Line || ds.RenderAs == RenderAs.Spline select ds).ToList()); return; } line2dCanvas.Visibility = Visibility.Visible; label2dCanvas.Visibility = Visibility.Visible; } chart._toolTip.Hide(); break; } goto RENDER_SERIES; case VcProperties.ShadowEnabled: case VcProperties.DataPoints: case VcProperties.YValue: case VcProperties.YValues: case VcProperties.XValue: case VcProperties.ViewportRangeEnabled: case VcProperties.DataPointUpdate: RENDER_SERIES: if (dataSeries.RenderAs == RenderAs.Spline && property != VcProperties.DataPointUpdate) dataSeries.StopDataSeriesAnimation(); else if(dataSeries.RenderAs == RenderAs.Line) dataSeries.StopDataPointsAnimation(); if(dataSeries.RenderAs == RenderAs.Line) UpdateLineSeries(dataSeries, width, height, label2dCanvas); else UpdateSplineSeries(property, dataSeries, width, height, label2dCanvas); break; } }
public static void Update(ObservableObject sender, VcProperties property, object newValue, Boolean isAxisChanged) { Boolean isDataPoint = sender.GetType().Equals(typeof(DataPoint)); if (isDataPoint) UpdateDataPoint(sender as DataPoint, property, newValue); else UpdateDataSeries(sender as DataSeries, property, newValue); }
//internal static void Update(Chart chart, RenderAs currentRenderAs, List<DataSeries> selectedDataSeries4Rendering, VcProperties property, object newValue) //{ // foreach( //} //internal static void Update(Chart chart, RenderAs currentRenderAs, List<DataSeries> selectedDataSeries4Rendering, VcProperties property, object newValue) //{ // Boolean is3D = chart.View3D; // ChartArea chartArea = chart.ChartArea; // Canvas ChartVisualCanvas = chart.ChartArea.ChartVisualCanvas; // // Double width = chart.ChartArea.ChartVisualCanvas.Width; // // Double height = chart.ChartArea.ChartVisualCanvas.Height; // Panel preExistingPanel = null; // Dictionary<RenderAs, Panel> RenderedCanvasList = chart.ChartArea.RenderedCanvasList; // if (chartArea.RenderedCanvasList.ContainsKey(currentRenderAs)) // { // preExistingPanel = RenderedCanvasList[currentRenderAs]; // } // Panel renderedChart = chartArea.RenderSeriesFromList(preExistingPanel, selectedDataSeries4Rendering); // if (preExistingPanel == null) // { // chartArea.RenderedCanvasList.Add(currentRenderAs, renderedChart); // ChartVisualCanvas.Children.Add(renderedChart); // } //} /// <summary> /// /// </summary> /// <param name="obj">Object may be DataSeries or DataPoint</param> /// <param name="property"></param> /// <param name="newValue"></param> private static void UpdateDataSeries(ObservableObject obj, VcProperties property, object newValue) { DataPoint dataPoint = null; DataSeries dataSeries = obj as DataSeries; Boolean isDataPoint = false; if (dataSeries == null) { isDataPoint = true; dataPoint = obj as DataPoint; dataSeries = dataPoint.Parent; } Chart chart = dataSeries.Chart as Chart; if (chart == null) return; PlotGroup plotGroup = dataSeries.PlotGroup; Canvas line2dCanvas = null; Canvas label2dCanvas = null; Path linePath = null; Path lineShadowPath = null; if (dataSeries.Faces != null) { if (dataSeries.Faces.Parts.Count > 0) { linePath = dataSeries.Faces.Parts[0] as Path; if (dataSeries.Faces.Parts.Count > 1) lineShadowPath = dataSeries.Faces.Parts[1] as Path; } line2dCanvas = dataSeries.Faces.Visual as Canvas; label2dCanvas = dataSeries.Faces.LabelCanvas as Canvas; } else if (dataSeries.Faces == null && property == VcProperties.Enabled && (Boolean)newValue == true) { ColumnChart.Update(chart, RenderAs.StepLine, (from ds in chart.InternalSeries where ds.RenderAs == RenderAs.StepLine select ds).ToList()); return; } else return; Double height = chart.ChartArea.ChartVisualCanvas.Height; Double width = chart.ChartArea.ChartVisualCanvas.Width; switch (property) { case VcProperties.Color: if (linePath != null) { Brush lineColorValue = (newValue != null) ? newValue as Brush : dataSeries.Color; linePath.Stroke = ((Boolean)dataSeries.LightingEnabled) ? Graphics.GetLightingEnabledBrush(lineColorValue, "Linear", new Double[] { 0.65, 0.55 }) : lineColorValue; //dataPoint.Color; } break; case VcProperties.LightingEnabled: if (linePath != null) linePath.Stroke = ((Boolean)newValue) ? Graphics.GetLightingEnabledBrush(dataSeries.Color, "Linear", new Double[] { 0.65, 0.55 }) : dataSeries.Color; break; case VcProperties.Opacity: if (linePath != null) linePath.Opacity = (Double)dataSeries.Opacity; break; case VcProperties.LineStyle: case VcProperties.LineThickness: if (lineShadowPath != null) lineShadowPath.StrokeThickness = (Double)dataSeries.LineThickness; if (linePath != null) linePath.StrokeThickness = (Double)dataSeries.LineThickness; if (lineShadowPath != null) lineShadowPath.StrokeDashArray = ExtendedGraphics.GetDashArray(dataSeries.LineStyle); if (linePath != null) linePath.StrokeDashArray = ExtendedGraphics.GetDashArray(dataSeries.LineStyle); break; case VcProperties.Enabled: if (!isDataPoint && line2dCanvas != null) { if ((Boolean)newValue == false) { line2dCanvas.Visibility = Visibility.Collapsed; label2dCanvas.Visibility = Visibility.Collapsed; } else { if (line2dCanvas.Parent == null) { ColumnChart.Update(chart, RenderAs.StepLine, (from ds in chart.InternalSeries where ds.RenderAs == RenderAs.StepLine select ds).ToList()); return; } line2dCanvas.Visibility = Visibility.Visible; label2dCanvas.Visibility = Visibility.Visible; } chart._toolTip.Hide(); break; } goto RENDER_SERIES; case VcProperties.ShadowEnabled: case VcProperties.DataPoints: case VcProperties.YValue: case VcProperties.YValues: case VcProperties.XValue: case VcProperties.ViewportRangeEnabled: RENDER_SERIES: if (dataSeries.Enabled == false) return; dataSeries.StopDataPointsAnimation(); Axis axisX = plotGroup.AxisX; Axis axisY = plotGroup.AxisY; // line2dCanvas.OpacityMask = new SolidColorBrush(Colors.Transparent); // label2dCanvas.OpacityMask = new SolidColorBrush(Colors.Transparent); (dataSeries.Faces.Visual as Canvas).Width = width; (dataSeries.Faces.Visual as Canvas).Height = height; (dataSeries.Faces.LabelCanvas as Canvas).Width = width; (dataSeries.Faces.LabelCanvas as Canvas).Height = height; Canvas chartsCanvas = dataSeries.Faces.Visual.Parent as Canvas; Canvas labelsCanvas = dataSeries.Faces.LabelCanvas.Parent as Canvas; chartsCanvas.Width = width; chartsCanvas.Height = height; labelsCanvas.Width = width; labelsCanvas.Height = height; List<DataPoint> pc = new List<DataPoint>(); List<List<DataPoint>> pointCollectionList = new List<List<DataPoint>>(); pointCollectionList.Add(pc); foreach (DataPoint dp in dataSeries.InternalDataPoints) { if (dp.Marker != null && dp.Marker.Visual != null) dp.Marker.Visual.Visibility = Visibility.Collapsed; if (dp.LabelVisual != null) dp.LabelVisual.Visibility = Visibility.Collapsed; if(Double.IsNaN(dp.InternalYValue)) dp.Faces = null; } List<DataPoint> viewPortDataPoints = RenderHelper.GetDataPointsUnderViewPort(dataSeries, false); foreach (DataPoint dp in viewPortDataPoints) { if (dp.Enabled == false) { chart._toolTip.Hide(); continue; } if (Double.IsNaN(dp.InternalYValue)) { pc = new List<DataPoint>(); pointCollectionList.Add(pc); continue; } Double x = Graphics.ValueToPixelPosition(0, width, axisX.InternalAxisMinimum, axisX.InternalAxisMaximum, dp.InternalXValue); Double y = Graphics.ValueToPixelPosition(height, 0, axisY.InternalAxisMinimum, axisY.InternalAxisMaximum, dp.InternalYValue); //Point newMarkerPosition; dp._visualPosition = new Point(x, y); pc.Add(dp); } // gg.Children.Clear(); GeometryGroup gg = (dataSeries.Faces.Parts[0] as Path).Data as GeometryGroup; // Apply new Data for Line StepLineChart.GetPathGeometry(gg, pointCollectionList, false, width, height, label2dCanvas); if (!VisifireControl.IsMediaEffectsEnabled) { // Update GeometryGroup for shadow if (dataSeries.Faces.Parts[1] != null) { if ((Boolean)dataSeries.ShadowEnabled) { (dataSeries.Faces.Parts[1] as Path).Visibility = Visibility.Visible; // gg.Children.Clear(); GeometryGroup ggShadow = (dataSeries.Faces.Parts[1] as Path).Data as GeometryGroup; // Apply new Data for Line StepLineChart.GetPathGeometry(ggShadow, pointCollectionList, true, width, height, label2dCanvas); } else (dataSeries.Faces.Parts[1] as Path).Visibility = Visibility.Collapsed; } } else { if (dataSeries.Faces != null && dataSeries.Faces.Visual != null) { #if !WP if ((Boolean)dataSeries.ShadowEnabled) { dataSeries.Faces.Visual.Effect = ExtendedGraphics.GetShadowEffect(315, 2.5, 1); } else dataSeries.Faces.Visual.Effect = null; #endif } } dataSeries._movingMarker.Visibility = Visibility.Collapsed; LineChart.Clip(chart, chartsCanvas, labelsCanvas, dataSeries.PlotGroup); //if (label2dCanvas.Parent != null) //{ // RectangleGeometry clipRectangle = new RectangleGeometry(); // Double depth3d = chart.ChartArea.PLANK_DEPTH; // Double clipLeft = 0; // Double clipTop = -depth3d - 4; // Double clipWidth = line2dCanvas.Width + depth3d; // Double clipHeight = line2dCanvas.Height + depth3d + chart.ChartArea.PLANK_THICKNESS + 10; // AreaChart.GetClipCoordinates(chart, ref clipLeft, ref clipTop, ref clipWidth, ref clipHeight, plotGroup.MinimumX, plotGroup.MaximumX); // clipRectangle.Rect = new Rect(clipLeft, clipTop, clipWidth, clipHeight); // (label2dCanvas.Parent as Canvas).Clip = clipRectangle; // clipRectangle = new RectangleGeometry(); // clipRectangle.Rect = new Rect(0, -depth3d - 4, line2dCanvas.Width + depth3d, line2dCanvas.Height + chart.ChartArea.PLANK_DEPTH + 10); // (line2dCanvas.Parent as Canvas).Clip = clipRectangle; //} break; } }
/// <summary> /// Returns an <see cref="ObservableObject{T}"/> wrapper that can hold an <see cref="IRegion"/>. Using this wrapper /// you can detect when an <see cref="IRegion"/> has been created by the <see cref="RegionAdapterBase{T}"/>. /// /// If the <see cref="ObservableObject{T}"/> wrapper does not yet exist, a new wrapper will be created. When the region /// gets created and assigned to the wrapper, you can use the <see cref="ObservableObject{T}.PropertyChanged"/> event /// to get notified of that change. /// </summary> /// <param name="view">The view that will host the region. </param> /// <returns>Wrapper that can hold an <see cref="IRegion"/> value and can notify when the <see cref="IRegion"/> value changes. </returns> public static ObservableObject<IRegion> GetObservableRegion(DependencyObject view) { if (view == null) throw new ArgumentNullException("view"); ObservableObject<IRegion> regionWrapper = view.GetValue(ObservableRegionProperty) as ObservableObject<IRegion>; if (regionWrapper == null) { regionWrapper = new ObservableObject<IRegion>(); view.SetValue(ObservableRegionProperty, regionWrapper); } return regionWrapper; }
public MainViewModel() { NewMortgage = new NewMortgageViewModel(); ExistingMortgage = new ExistingMortgageViewModel(); }
internal static void Update(ObservableObject sender, VcProperties property, object newValue, Boolean isAxisChanged) { Boolean isDataPoint; if (property == VcProperties.Bevel) { sender = (sender as DataPoint).Parent; isDataPoint = false; } else isDataPoint = sender.GetType().Equals(typeof(DataPoint)); if (isDataPoint ) UpdateDataPoint(sender as DataPoint, property, newValue, isAxisChanged); else UpdateDataSeries(sender as DataSeries, property, newValue); }
public MockContextAwareView() { RegionContext = new ObservableObject<object>(); }
public NewEmailViewModel() { this.Email = new ObservableObject<EmailMessage>(); }
/// <summary> /// Attach events to each and every individual face of Faces /// </summary> /// <param name="Object">Object where events to be attached</param> internal void AttachEvent2DataPointVisualFaces(ObservableObject Object) { if (Parent.RenderAs == RenderAs.Pie || Parent.RenderAs == RenderAs.Doughnut || Parent.RenderAs == RenderAs.SectionFunnel || Parent.RenderAs == RenderAs.StreamLineFunnel) { if (Faces != null) { if ((Parent.Chart as Chart).View3D) { foreach (FrameworkElement element in Faces.VisualComponents) { AttachEvents2Visual(Object, this, element); if ((Chart as Chart).ChartArea != null && (Chart as Chart).ChartArea._isDefaultInteractivityAllowed) { element.MouseLeftButtonUp -= new MouseButtonEventHandler(Visual_MouseLeftButtonUp); element.MouseLeftButtonUp += new MouseButtonEventHandler(Visual_MouseLeftButtonUp); } } } else { AttachEvents2Visual(Object, this, Faces.Visual); if ((Chart as Chart).ChartArea != null && (Chart as Chart).ChartArea._isDefaultInteractivityAllowed) { Faces.Visual.MouseLeftButtonUp -= new MouseButtonEventHandler(Visual_MouseLeftButtonUp); Faces.Visual.MouseLeftButtonUp += new MouseButtonEventHandler(Visual_MouseLeftButtonUp); } } if (this.ExplodeAnimation != null) { this.ExplodeAnimation.Completed -= new EventHandler(ExplodeAnimation_Completed); this.ExplodeAnimation.Completed += new EventHandler(ExplodeAnimation_Completed); } if (this.UnExplodeAnimation != null) { this.UnExplodeAnimation.Completed -= new EventHandler(UnExplodeAnimation_Completed); this.UnExplodeAnimation.Completed += new EventHandler(UnExplodeAnimation_Completed); } } } else if (Parent.RenderAs == RenderAs.StackedArea || Parent.RenderAs == RenderAs.StackedArea100 || Parent.RenderAs == RenderAs.Line) { if (Parent.RenderAs != RenderAs.Line) { if (Parent.Faces != null) { if (Object.GetType().Equals(typeof(DataPoint))) { foreach (FrameworkElement face in Parent.Faces.VisualComponents) AttachEvents2AreaVisual(Object, this, face); } } } if (Marker != null) AttachEvents2Visual(Object, this, Marker.Visual); } else if (Faces != null) { if (Parent.RenderAs == RenderAs.Bubble || Parent.RenderAs == RenderAs.Point || Parent.RenderAs == RenderAs.Stock || Parent.RenderAs == RenderAs.CandleStick || Parent.RenderAs == RenderAs.SectionFunnel || Parent.RenderAs == RenderAs.StreamLineFunnel) { foreach (FrameworkElement face in Faces.VisualComponents) { AttachEvents2Visual(Object, this, face); } } else { AttachEvents2Visual(Object, this, Faces.Visual); if (Marker != null) AttachEvents2Visual(Object, this, Marker.Visual); if (LabelVisual != null) AttachEvents2Visual(Object, this, LabelVisual); } } }
/// <summary> /// Attach tooltip with a framework element /// </summary> /// <param name="control">Control reference</param> /// <param name="element">Object reference</param> /// <param name="visualElements">FrameworkElements list</param> public void AttachToolTip(VisifireControl control, ObservableObject element, System.Collections.Generic.List<FrameworkElement> visualElements) { // Show ToolTip on mouse move over the chart element foreach (FrameworkElement visualElement in visualElements) AttachToolTip(control, element, visualElement); }
public void Update(ObservableObject obj) { Remove(); Add(obj); }
public virtual void Add(ObservableObject obj) { }