protected AbstractTextInputHandler(UIElement parentElement, SimplePropertyDataDescriptor textDataDescriptor,
                                    SimplePropertyDataDescriptor caretIndexDataDescriptor)
 {
     _parentElement            = parentElement;
     _textDataDescriptor       = textDataDescriptor;
     _caretIndexDataDescriptor = caretIndexDataDescriptor;
 }
示例#2
0
 public CellPhoneTextInputHandler(UIElement parentElement, SimplePropertyDataDescriptor textDataDescriptor,
                                  SimplePropertyDataDescriptor caretIndexDataDescriptor) :
     base(parentElement, textDataDescriptor, caretIndexDataDescriptor)
 {
     _timer          = new Timer(CURSOR_ADVANCE_TIMESPAN_MS);
     _timer.Elapsed += OnTimerElapsed;
     SetCurrentLayout(0);
 }
        protected AbstractTextInputHandler CreateTextInputHandler()
        {
            AppSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <AppSettings>();
            SimplePropertyDataDescriptor internalTextPropertyDataDescriptor;
            SimplePropertyDataDescriptor caretIndexDataDescriptor;

            if (!SimplePropertyDataDescriptor.CreateSimplePropertyDataDescriptor(
                    this, "InternalText", out internalTextPropertyDataDescriptor) ||
                !SimplePropertyDataDescriptor.CreateSimplePropertyDataDescriptor(
                    this, "CaretIndex", out caretIndexDataDescriptor))
            {
                throw new FatalException("One of the properties 'InternalText' or 'CaretIndex' was not found");
            }
            return(settings.CellPhoneInputStyle ?
                   (AbstractTextInputHandler) new CellPhoneTextInputHandler(this, internalTextPropertyDataDescriptor, caretIndexDataDescriptor) :
                   new DefaultTextInputHandler(this, internalTextPropertyDataDescriptor, caretIndexDataDescriptor));
        }
示例#4
0
        private HeaderItemWrapper GetGroupHeader(int itemIndex)
        {
            var headerWrapper = _materializedGroupHeaders[itemIndex];

            if (headerWrapper != null)
            {
                return(headerWrapper);
            }

            if (_groupingValueProvider != null)
            {
                headerWrapper = new HeaderItemWrapper(_groupingValueProvider.GetGroupingValue(_items[itemIndex]));
            }
            else
            {
                // to get the grouping value of the item we use a dummy header item and apply the DataContext and group value binding to it
                if (_getValueGroupHeader == null)
                {
                    _getValueGroupHeader = new GroupHeaderItem();
                    var dd      = new SimplePropertyDataDescriptor(_getValueGroupHeader, typeof(GroupHeaderItem).GetProperty("GroupingValue"));
                    var binding = MpfCopyManager.DeepCopyCutLVPs(_groupPropertyBinding);
                    binding.SetTargetDataDescriptor(dd);
                    binding.Activate();
                }

                _getValueGroupHeader.DataContext = new BindingExtension()
                {
                    Source = _items[itemIndex],
                    Path   = "."
                };
                // then we create the actual header item and apply the value to it
                headerWrapper = new HeaderItemWrapper(_getValueGroupHeader.GroupingValue);

                // finally cleanup the datacontext binding
                MPF.TryCleanupAndDispose(_getValueGroupHeader.DataContext);
                _getValueGroupHeader.DataContext = null;
            }
            _materializedGroupHeaders[itemIndex] = headerWrapper;
            return(headerWrapper);
        }
示例#5
0
 public virtual bool FindContentProperty(out IDataDescriptor dd)
 {
     dd = new SimplePropertyDataDescriptor(this, GetType().GetProperty("BindingValue"));
     return(true);
 }
示例#6
0
        protected virtual void PrepareItemsOverride(bool force)
        {
            if (_panelTemplateApplied && _itemsHostPanel != null && !force)
            {
                return;
            }
            // Check properties which are necessary in each case
            if (ItemsPanel == null)
            {
                return;
            }

            ItemsPresenter presenter = FindItemsPresenter();

            if (presenter == null)
            {
                return;
            }

            if (!_panelTemplateApplied)
            {
                _panelTemplateApplied = true;
                presenter.ApplyTemplate(ItemsPanel);
                _itemsHostPanel = null;
            }

            if (_itemsHostPanel == null)
            {
                _itemsHostPanel = presenter.ItemsHostPanel;
            }
            if (_itemsHostPanel == null)
            {
                return;
            }

            // Albert: We cannot exit the method if one of the styles is not set because the styles
            // might be found by the SkinEngine's automatic Style assignment (FrameworkElement.CopyDefaultStyle)
            //if (ItemContainerStyle == null || ItemTemplate == null)
            //  return;

            IEnumerable itemsSource = ItemsSource;

            if (itemsSource == null)
            { // In this case, we must set up the items control using the Items property
                ItemCollection items            = _items;
                ItemCollection preparedChildren = new ItemCollection();
                bool           setItems         = false;
                if (items == null)
                {
                    // Restore items from "ItemsSource mode" where they have been set to null
                    items    = new ItemCollection();
                    setItems = true;
                }
                foreach (object item in items)
                {
                    object           itemCopy = MpfCopyManager.DeepCopyWithFixedObject(item, this); // Keep this object as LogicalParent
                    FrameworkElement element  = itemCopy as FrameworkElement ?? PrepareItemContainer(itemCopy);
                    if (element.Style == null && element is ContentControl)
                    {
                        element.Style = ItemContainerStyle;
                    }
                    element.LogicalParent = this;
                    preparedChildren.Add(element);
                }
                presenter.SetDataStrings(BuildDataStrings(items));

                SetPreparedItems(setItems, setItems ? items : null, true, preparedChildren);
            }
            else
            {
                IList <object>  l    = new List <object>();
                ISynchronizable sync = itemsSource as ISynchronizable;
                if (sync != null)
                {
                    lock (sync.SyncRoot)
                        CollectionUtils.AddAll(l, itemsSource);
                }
                else
                {
                    CollectionUtils.AddAll(l, itemsSource);
                }

                presenter.SetDataStrings(BuildDataStrings(l));

                var vsp = _itemsHostPanel as IVirtualizingPanel;
                if (vsp != null)
                {
                    // In this case, the VSP will generate its items by itself
                    ListViewItemGenerator lvig = new ListViewItemGenerator();
                    lvig.Initialize(this, l, ItemContainerStyle, ItemTemplate,
                                    GroupingValueProvider, GroupingBindingWrapper == null ? null :  GroupingBindingWrapper.Binding, GroupHeaderContainerStyle, GroupHeaderTemplate);
                    SimplePropertyDataDescriptor dd;
                    if (SimplePropertyDataDescriptor.CreateSimplePropertyDataDescriptor(this, "IsEmpty", out dd))
                    {
                        SetValueInRenderThread(dd, l.Count == 0);
                    }
                    vsp.SetItemProvider(lvig);

                    SetPreparedItems(true, null, false, null);
                }
                else
                {
                    ItemCollection preparedItems = new ItemCollection();
                    preparedItems.AddAll(l.Select(PrepareItemContainer));

                    SetPreparedItems(true, null, true, preparedItems);
                }
            }
        }
 public DefaultTextInputHandler(UIElement parentElement, SimplePropertyDataDescriptor textDataDescriptor,
                                SimplePropertyDataDescriptor caretIndexDataDescriptor) :
     base(parentElement, textDataDescriptor, caretIndexDataDescriptor)
 {
 }