Exemplo n.º 1
0
 protected override void OnMouseLeave(MouseEventArgs e)
 {
     base.OnMouseLeave(e);
     if (!_wasOpen)
     {
         SelectedField = null;
     }
 }
 private static void OnDetachDataContextDisposed(WeakEventListener<DynamicItemsSelectorView, IFieldViewModel, EventArgs> listener, IFieldViewModel source)
 {
     source.Disposed -= listener.OnEvent;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="FieldVisibilityChangedEvent"/> class.
 /// </summary>
 /// <param name="field">The field.</param>
 public FieldVisibilityChangedEvent(IFieldViewModel field)
 {
     Field = field;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SelectableField"/> class.
 /// </summary>
 /// <param name="fieldVM">The field vm.</param>
 public SelectableField(IFieldViewModel fieldVM, double minWidth, bool isFilteredMCR = false)
 {
     FieldVM = fieldVM;
     MinWidth = minWidth;
     IsFilteredMCR = isFilteredMCR;
 }
 /// <summary>
 /// Setups the field.
 /// </summary>
 /// <param name="prop">The property.</param>
 /// <param name="promptAttr">The prompt attribute.</param>
 /// <param name="display">The display.</param>
 /// <param name="fieldViewModel">The field view model.</param>
 /// <param name="model">The model.</param>
 /// <param name="defaultValue">The default value.</param>
 private static void SetupField(PropertyInfo prop, PromptAttribute promptAttr, DisplayAttribute display, IFieldViewModel fieldViewModel, IEditableRoot model, object defaultValue = null)
 {
     fieldViewModel.Property = prop;
     fieldViewModel.Init(model, prop.GetValue(model, null) ?? defaultValue, null);
     fieldViewModel.Label = display == null ? prop.Name : display.GetName();
     fieldViewModel.IsCalculated = prop.GetCustomAttributes(typeof(CalculatedAttribute), false).Length > 0;
     //fieldViewModel.WidthPercentage = 1.0; // (commonSettingsAttr == null || commonSettingsAttr.HideFromDetails) ? 0.4 : commonSettingsAttr.Width / 100;
     fieldViewModel.IsVisible = true;
     fieldViewModel.Prompt = promptAttr == null ? string.Format(CultureInfo.InvariantCulture, LanguageService.Translate("Tooltip_EnterPrompt"), fieldViewModel.Label) : promptAttr.PromptString;
     //fieldViewModel.ShowDocumentation = docAttr != null;
     //fieldViewModel.Documentation = docAttr == null ? null : ClrUnicodeConverter.ToText(docAttr.DocumentationBody);
 }
Exemplo n.º 6
0
 protected override void OnMouseEnter(MouseEventArgs e)
 {
     base.OnMouseEnter(e);
     _wasOpen = SelectedField != null;
     SelectedField = (IFieldViewModel)DataContext;
 }
Exemplo n.º 7
0
 private static void SetupField(PropertyInfo prop, CommonSettingsAttribute commonSettingsAttr, DocumentationAttribute docAttr, PromptAttribute promptAttr, object display, IFieldViewModel fieldViewModel, IEditableRoot model, IDetailsViewModel detailsViewModel)
 {
     fieldViewModel.Property = prop;
     fieldViewModel.Init(model, prop.GetValue(model, null), detailsViewModel);
     fieldViewModel.Label = display == null ? prop.Name : ((DisplayAttribute)display).GetName();
     fieldViewModel.WidthPercentage = (commonSettingsAttr == null || commonSettingsAttr.HideFromDetails) ? 0.4 : commonSettingsAttr.Width / 100;
     fieldViewModel.Section = (commonSettingsAttr == null || commonSettingsAttr.HideFromDetails) ? string.Empty : commonSettingsAttr.Section;
     fieldViewModel.Position = (commonSettingsAttr == null || commonSettingsAttr.HideFromDetails) ? 0 : commonSettingsAttr.Position;
     fieldViewModel.RowSpan = (commonSettingsAttr == null) ? 1 : commonSettingsAttr.RowSpan;
     fieldViewModel.Section = commonSettingsAttr == null ? string.Empty : commonSettingsAttr.Section;
     fieldViewModel.ShowDocumentation = docAttr != null;
     fieldViewModel.Documentation = docAttr == null ? null : ClrUnicodeConverter.ToText(docAttr.DocumentationBody);
     fieldViewModel.Prompt = promptAttr == null ? string.Format(CultureInfo.InvariantCulture, LanguageService.Translate("Tooltip_EnterPrompt"), fieldViewModel.Label) : promptAttr.PromptString;
     fieldViewModel.IsCalculated = prop.GetCustomAttributes(typeof(CalculatedAttribute), false).Length > 0;
     fieldViewModel.ParentDetailsVM = detailsViewModel;
 }
        /// <summary>
        /// Overloaded Implementation of Dispose.
        /// </summary>
        /// <param name="isDisposing"></param>
        /// <remarks>
        /// <para><list type="bulleted">Dispose(bool isDisposing) executes in two distinct scenarios.
        /// <item>If <paramref name="isDisposing"/> equals true, the method has been called directly
        /// or indirectly by a user's code. Managed and unmanaged resources
        /// can be disposed.</item>
        /// <item>If <paramref name="isDisposing"/> equals false, the method has been called by the 
        /// runtime from inside the finalizer and you should not reference 
        /// other objects. Only unmanaged resources can be disposed.</item></list></para>
        /// </remarks>
        protected virtual void Dispose(bool isDisposing) 
        {
            if (isDisposing)
            {
                _parentModel = null;
                _parentDetailsVM = null;
                _propertyInfo = null;
                _fieldViewModelType = null;

                _fieldViewModel = null;
                if (_displayInfo != null)
                {
                    _displayInfo.Value = null;
                    _displayInfo = null;
                }

                _allProperties.Clear();
                _allMasterProperties.Clear();

                _parentProperty = null;
                _childProperty = null;
                _parentPropertyOwner = null;
            }
            
            IsDisposed = true;
        }