Exemplo n.º 1
0
		public WrappedReflexiveEntry(ObservableCollection<MetaField> visibleItems, int index, double width, bool last)
		{
			_index = index;
			_width = width;
			_last = last;
			_wrappedField = visibleItems[index];
			_visibleItems = visibleItems;
			visibleItems.CollectionChanged += visibleItems_CollectionChanged;
		}
Exemplo n.º 2
0
		public WrappedReflexiveEntry WrapField(MetaField field, double width, bool last)
		{
			_loadedFields.Add(field);
			_fieldVisibility.Add(true);
			_tracker.AttachTo(field);

			var wrapper = new WrappedReflexiveEntry(_loadedFields, _wrappers.Count, width, last);
			_wrappers.Add(wrapper);
			return wrapper;
		}
Exemplo n.º 3
0
        public void FilterFields(IEnumerable<MetaField> fields, string filter)
        {
            _filter = filter.ToLower();

            float numberValue;
            if (float.TryParse(filter, out numberValue))
                _numberFilter = numberValue;

            foreach (MetaField field in fields)
            {
                _topLevelField = field;
                field.Accept(this);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Attaches to a single field, listening for changes made to it.
        /// </summary>
        /// <param name="field">The field to attach to.</param>
        public void AttachTo(MetaField field)
        {
            field.PropertyChanged += field_PropertyChanged;

            // If the field is a raw data field (raw or dataref),
            // then subscribe to the TextChanged event on its document
            RawData rawField = field as RawData;
            if (rawField != null)
            {
                rawField.Document.TextChanged += delegate
                {
                    if (Enabled)
                        MarkChanged(rawField);
                };
            }
        }
Exemplo n.º 5
0
		private bool FilterNumber(MetaField field, float value)
		{
			if (_numberFilter.HasValue && value == _numberFilter.Value)
			{
				AcceptField(field);
				return true;
			}
			RejectField(field);
			return false;
		}
Exemplo n.º 6
0
		// Passed as the callback to ReflexiveFlattener.EnumWrappers in VisitReflexive
		private void ReflexiveFlattener_HandleWrapper(WrappedReflexiveEntry wrapper)
		{
			_topLevelField = _flattener.GetTopLevelWrapper(_currentReflexive, wrapper);
			_highlighter(wrapper, _highlightLevel > 0);
			wrapper.WrappedField.Accept(this);
		}
Exemplo n.º 7
0
		private bool FilterString(MetaField field, string fieldName)
		{
			if (fieldName.ToLower().Contains(_filter))
			{
				AcceptField(field);
				return true;
			}
			RejectField(field);
			return false;
		}
Exemplo n.º 8
0
 /// <summary>
 /// Constructs a new search result holder.
 /// </summary>
 /// <param name="foundField">The field that was found and highlighted.</param>
 /// <param name="listField">The top-level field in the field list. For reflexive entries, this is the topmost wrapper field, otherwise, this may be the same as foundField.</param>
 /// <param name="parent">The reflexive that the field is in. Can be null.</param>
 public SearchResult(MetaField foundField, MetaField listField, ReflexiveData parent)
 {
     ListField = listField;
     Field = foundField;
     Reflexive = parent;
 }
Exemplo n.º 9
0
		/// <summary>
		///     Attaches to a single field, listening for changes made to it.
		/// </summary>
		/// <param name="field">The field to attach to.</param>
		public void AttachTo(MetaField field)
		{
			field.PropertyChanged += field_PropertyChanged;
		}
Exemplo n.º 10
0
 private void MetaFilterer_CollectResult(MetaField foundField, MetaField listField, ReflexiveData parent)
 {
     _resultIndices[listField] = _searchResults.Count;
     _searchResults.Add(new SearchResult(foundField, listField, parent));
 }
Exemplo n.º 11
0
 // Thread-safe
 private void SelectField(MetaField field)
 {
     Dispatcher.Invoke(new Action(delegate
         {
             panelMetaComponents.SelectedItem = field;
             if (field != null)
                 panelMetaComponents.ScrollIntoView(field);
         }
     ));
 }
Exemplo n.º 12
0
		private void AcceptField(MetaField field)
		{
			_highlighter(field, true);
			_resultCollector(field, _topLevelField, _currentReflexive);
		}
Exemplo n.º 13
0
 private static MetaField GetWrappedField(MetaField field)
 {
     WrappedReflexiveEntry wrapper = null;
     while (true)
     {
         wrapper = field as WrappedReflexiveEntry;
         if (wrapper == null)
             return field;
         field = wrapper.WrappedField;
     }
 }
Exemplo n.º 14
0
        private void AddValue(MetaField value)
        {
            if (_reflexives.Count > 0)
                _reflexives[_reflexives.Count - 1].Template.Add(value);
            else
                Values.Add(value);
            /*MetaField wrappedValue = value;
            for (int i = _reflexives.Count - 1; i >= 0; i--)
            {
                ReflexiveData reflexive = _reflexives[i];
                reflexive.Pages[0].Fields.Add(wrappedValue);

                // hax, use a null parent for now so MetaReader doesn't have to cause it to unsubscribe
                wrappedValue = new WrappedReflexiveEntry(null, reflexive.Pages[0].Fields.Count - 1);
            }

            Values.Add(wrappedValue);*/
        }
Exemplo n.º 15
0
 private void ReadField(MetaField field)
 {
     if (_ignoredFields == null || !_ignoredFields.HasChanged(field) || (field is ReflexiveData))
         field.Accept(this);
 }
Exemplo n.º 16
0
 void visibleItems_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     // This is necessary in order for the NotifyPropertyChanged on WrappedField to work
     if ((e.Action == NotifyCollectionChangedAction.Replace || e.Action == NotifyCollectionChangedAction.Add) && e.NewStartingIndex == _index)
         WrappedField = (MetaField)e.NewItems[0];
 }
Exemplo n.º 17
0
 public void Add(MetaField field)
 {
     field.Accept(this);
 }
Exemplo n.º 18
0
 private void WriteField(MetaField field)
 {
     if (_changes == null || _changes.HasChanged(field) || field is ReflexiveData)
         field.Accept(this);
 }
Exemplo n.º 19
0
		private void RejectField(MetaField field)
		{
			_highlighter(field, _highlightLevel > 0);
		}
Exemplo n.º 20
0
 /// <summary>
 /// Marks a field as unchanged in all registered change sets.
 /// </summary>
 /// <param name="field">The field to mark as unchanged.</param>
 public void MarkUnchanged(MetaField field)
 {
     foreach (FieldChangeSet set in _changeSets)
         set.MarkUnchanged(field);
 }
Exemplo n.º 21
0
 private int FindResultByListField(MetaField field)
 {
     int index;
     if (field != null && _resultIndices.TryGetValue(field, out index))
         return index;
     return -1;
 }
Exemplo n.º 22
0
        private void WriteField(MetaField field)
        {
            if (_changes == null || _changes.HasChanged(field))
                field.Accept(this);

            var reflexive = field as ReflexiveData;
            if (reflexive != null)
                WriteReflexiveChildren(reflexive);
        }
Exemplo n.º 23
0
 private void MetaFilterer_HighlightField(MetaField field, bool highlight)
 {
     if (highlight)
         field.Opacity = 1f;
     else
         field.Opacity = .3f;
 }
Exemplo n.º 24
0
 /// <summary>
 /// Returns whether or not a field is marked as changed.
 /// </summary>
 /// <param name="field">The field to check.</param>
 /// <returns>true if the field has been marked as changed.</returns>
 public bool HasChanged(MetaField field)
 {
     return _fields.Contains(field);
 }
Exemplo n.º 25
0
        private void ShowField(MetaField field)
        {
            field.Opacity = 1.0f;

            // If the field is a reflexive, recursively set the opacity of its children
            ReflexiveData reflexive = field as ReflexiveData;
            if (reflexive != null)
            {
                // Show wrappers
                _flattener.EnumWrappers(reflexive, ShowField);

                // Show template fields
                foreach (MetaField child in reflexive.Template)
                    ShowField(child);

                // Show modified fields
                foreach (ReflexivePage page in reflexive.Pages)
                {
                    foreach (MetaField child in page.Fields)
                    {
                        if (child != null)
                            ShowField(child);
                    }
                }
            }
        }
Exemplo n.º 26
0
 /// <summary>
 /// Marks a field as changed.
 /// </summary>
 /// <param name="field">The field to mark as changed.</param>
 public void MarkChanged(MetaField field)
 {
     _fields.Add(field);
 }
Exemplo n.º 27
0
        private void ReadField(MetaField field)
        {
            // Update the field's memory address
            ValueField valueField = field as ValueField;
            if (valueField != null)
                valueField.FieldAddress = _cache.MetaArea.OffsetToPointer((int)(BaseOffset + valueField.Offset));

            // Read its contents if it has changed (or if change detection is disabled)
            if (_ignoredFields == null || !_ignoredFields.HasChanged(field))
                field.Accept(this);

            // If it's a reflexive, read its children
            ReflexiveData reflexive = field as ReflexiveData;
            if (reflexive != null)
                ReadReflexiveChildren(reflexive);
        }
Exemplo n.º 28
0
 /// <summary>
 /// Marks a field as unchanged.
 /// </summary>
 /// <param name="field">The field to mark as unchanged.</param>
 public void MarkUnchanged(MetaField field)
 {
     _fields.Remove(field);
 }