Esempio n. 1
0
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------

        #region Constructors

        /// <summary>
        /// Static constructor for TextBox.
        /// </summary>
        static TextBox()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(TextBox), new FrameworkPropertyMetadata(typeof(TextBox)));
            _dType = DependencyObjectType.FromSystemTypeInternal(typeof(TextBox));

            // Add handlers for height properties so we can manage min/maxLines
            PropertyChangedCallback callback = new PropertyChangedCallback(OnMinMaxChanged);

            HeightProperty.OverrideMetadata(typeof(TextBox), new FrameworkPropertyMetadata(callback));
            MinHeightProperty.OverrideMetadata(typeof(TextBox), new FrameworkPropertyMetadata(callback));
            MaxHeightProperty.OverrideMetadata(typeof(TextBox), new FrameworkPropertyMetadata(callback));
            FontFamilyProperty.OverrideMetadata(typeof(TextBox), new FrameworkPropertyMetadata(callback));
            FontSizeProperty.OverrideMetadata(typeof(TextBox), new FrameworkPropertyMetadata(callback));

            // Registering typography properties metadata
            PropertyChangedCallback onTypographyChanged = new PropertyChangedCallback(OnTypographyChanged);
            DependencyProperty[] typographyProperties = Typography.TypographyPropertiesList;
            for (int i = 0; i < typographyProperties.Length; i++)
            {
                typographyProperties[i].OverrideMetadata(typeof(TextBox), new FrameworkPropertyMetadata(onTypographyChanged));
            }

            HorizontalScrollBarVisibilityProperty.OverrideMetadata(typeof(TextBox), new FrameworkPropertyMetadata(
             ScrollBarVisibility.Hidden,
             new PropertyChangedCallback(OnScrollViewerPropertyChanged), // PropertyChangedCallback
             new CoerceValueCallback(CoerceHorizontalScrollBarVisibility)));

        }
        /// <summary>
        /// Static ctor for QuaternionAnimation establishes
        /// dependency properties, using as much shared data as possible.
        /// </summary>
        static QuaternionAnimation()
        {
            Type typeofProp = typeof(Quaternion?);
            Type typeofThis = typeof(QuaternionAnimation);
            PropertyChangedCallback propCallback = new PropertyChangedCallback(AnimationFunction_Changed);
            ValidateValueCallback validateCallback = new ValidateValueCallback(ValidateFromToOrByValue);

            FromProperty = DependencyProperty.Register(
                "From",
                typeofProp,
                typeofThis,
                new PropertyMetadata((Quaternion?)null, propCallback),
                validateCallback);

            ToProperty = DependencyProperty.Register(
                "To",
                typeofProp,
                typeofThis,
                new PropertyMetadata((Quaternion?)null, propCallback),
                validateCallback);

            ByProperty = DependencyProperty.Register(
                "By",
                typeofProp,
                typeofThis,
                new PropertyMetadata((Quaternion?)null, propCallback),
                validateCallback);

            EasingFunctionProperty = DependencyProperty.Register(
                "EasingFunction",
                typeof(IEasingFunction),
                typeofThis);
        }
Esempio n. 3
0
 public PropertyMetadata(object defaultValue = null, PropertyChangedCallback propertyChangedCallback = null, CoerceValueCallback coerceValueCallback = null, bool inherits = false)
 {
     this.DefaultValue = defaultValue;
     this.PropertyChangedCallback = propertyChangedCallback;
     this.CoerceValueCallback = coerceValueCallback;
     this.Inherits = inherits;
 }
        static CornerRadiusAnimation()
        {
            Type typeofProp = typeof(CornerRadius?);
            Type typeofThis = typeof(CornerRadiusAnimation);
            PropertyChangedCallback propCallback = new PropertyChangedCallback(AnimationFunction_Changed);
            ValidateValueCallback validateCallback = new ValidateValueCallback(ValidateFromToOrByValue);

            FromProperty = DependencyProperty.Register(
                "From",
                typeofProp,
                typeofThis,
                new PropertyMetadata((CornerRadius?)null, propCallback),
                validateCallback);

            ToProperty = DependencyProperty.Register(
                "To",
                typeofProp,
                typeofThis,
                new PropertyMetadata((CornerRadius?)null, propCallback),
                validateCallback);

            ByProperty = DependencyProperty.Register(
                "By",
                typeofProp,
                typeofThis,
                new PropertyMetadata((CornerRadius?)null, propCallback),
                validateCallback);
        }
 protected override void OnApply(DependencyProperty dp, Type targetType)
 {
     doType = DependencyObjectType.FromSystemType(targetType);
     propertyChangedCallbackInternal = PropertyChangedCallback;
     PropertyChangedCallback = OnPropertyChanged;
     base.OnApply(dp, targetType);
 }
Esempio n. 6
0
 public UIPropertyMetadata(
             object defaultValue,
             PropertyChangedCallback propertyChangedCallback,
             CoerceValueCallback coerceValueCallback)
             : base(defaultValue, propertyChangedCallback, coerceValueCallback)
 {
 }
 public FrameworkPropertyMetadata(
             PropertyChangedCallback propertyChangedCallback,
             CoerceValueCallback coerceValueCallback)
             : base(propertyChangedCallback)
 {
     this.CoerceValueCallback = coerceValueCallback;
 }
Esempio n. 8
0
 public PropertyMetadata(MetadataOption options, PropertyChangedCallback propertyChangedCallback = null,
     CoerceValueCallback coerceValueCallback = null)
 {
     Options = options;
     PropertyChanged = propertyChangedCallback;
     CoerceValue = coerceValueCallback;
 }
 public FunctionalPropertyMetadata(object defaultValue, FunctionalPropertyMetadataOptions flags, PropertyChangedCallback propertyChangedCallback, CoerceValueCallback coerceValueCallback)
 {
     DefaultValue = defaultValue;
     PropertyChangedCallback = propertyChangedCallback;
     CoerceValueCallback = coerceValueCallback;
     _flags = flags;
 }
 public ReadOnlyPropertyMetadata(object defaultValue, 
                                 GetReadOnlyValueCallback getValueCallback,
                                 PropertyChangedCallback propertyChangedCallback) :
                                 base(defaultValue, propertyChangedCallback)
 {
     _getValueCallback = getValueCallback;
 }
Esempio n. 11
0
 /// <summary> 
 ///     Type meta construction
 /// </summary>
 /// <param name="defaultValue">Default value of property</param>
 /// <param name="propertyChangedCallback">Called when the property has been changed</param> 
 /// <param name="coerceValueCallback">Called on update of value</param>
 public PropertyMetadata(object defaultValue, 
                         PropertyChangedCallback propertyChangedCallback, 
                         CoerceValueCallback coerceValueCallback)
 { 
     DefaultValue = defaultValue;
     PropertyChangedCallback = propertyChangedCallback;
     CoerceValueCallback = coerceValueCallback;
 } 
 public FrameworkPropertyMetadata(
             object defaultValue,
             FrameworkPropertyMetadataOptions flags,
             PropertyChangedCallback propertyChangedCallback)
             : base(defaultValue, propertyChangedCallback)
 {
     this.LoadFlags(flags);
 }
Esempio n. 13
0
 public static void RegisterForNotification(string property, FrameworkElement frameworkElement, PropertyChangedCallback OnCallBack)
 {
     Binding binding2 = new Binding(property);
     binding2.set_Source(frameworkElement);
     Binding binding = binding2;
     DependencyProperty property2 = DependencyProperty.RegisterAttached("ListenAttached" + property, typeof(object), typeof(UserControl), new PropertyMetadata(OnCallBack));
     frameworkElement.SetBinding(property2, binding);
 }
Esempio n. 14
0
        public PropertyMetadata(object defaultValue, PropertyChangedCallback propertyChangedCallback)
        {
            if (defaultValue == DependencyProperty.UnsetValue)
                throw new ArgumentException("Cannot initialize property metadata's default value to 'Unset'");

            DefaultValue = defaultValue;
            PropertyChangedCallback = propertyChangedCallback;
        }
 /// <summary>
 ///     UI metadata construction
 /// </summary>
 /// <param name="defaultValue">Default value of property</param>
 /// <param name="propertyChangedCallback">Called when the property has been changed</param>
 /// <param name="coerceValueCallback">Called on update of value</param>
 /// <param name="isAnimationProhibited">Should animation be prohibited?</param>
 public UIPropertyMetadata(object defaultValue,
                         PropertyChangedCallback propertyChangedCallback,
                         CoerceValueCallback coerceValueCallback,
                         bool isAnimationProhibited) :
     base(defaultValue, propertyChangedCallback, coerceValueCallback)
 {
     WriteFlag(MetadataFlags.UI_IsAnimationProhibitedID, isAnimationProhibited);
 }
Esempio n. 16
0
		public UIPropertyMetadata (object defaultValue,
					   PropertyChangedCallback propertyChangedCallback,
					   CoerceValueCallback coerceValueCallback,
					   bool isAnimationProhibited)
			: base (defaultValue, propertyChangedCallback, coerceValueCallback)
		{
			this.isAnimationProhibited = false;
		}
 public FrameworkPropertyMetadata(object defaultValue = null, PropertyChangedCallback propertyChangedCallback = null, CoerceValueCallback coerceValueCallback = null, bool inherits = false,
     bool affectsMeasure = false, bool affectsArrange = false, bool bindsTwoWayByDefault = false, UpdateSourceTrigger defaultUpdateSourceTrigger = UpdateSourceTrigger.Default)
     : base(defaultValue, propertyChangedCallback, coerceValueCallback, inherits)
 {
     this.AffectsMeasure = affectsMeasure;
     this.AffectsArrange = affectsArrange;
     this.BindsTwoWayByDefault = bindsTwoWayByDefault;
     this.DefaultUpdateSourceTrigger = defaultUpdateSourceTrigger;
 }
Esempio n. 18
0
 public FontPropertyMetadata(
     object defaultValue,
     PropertyChangedCallback changeCallback,
     DependencyProperty targetProperty
     )
     : base(defaultValue, changeCallback)
 {
     TargetProperty = targetProperty;
 }
 static StylizedTextBlock()
 {
     var metadata = TextProperty.GetMetadata(typeof(TextBlock));
     _originalTtextPropertyChangedCallback = metadata.PropertyChangedCallback;
     var originalCoerceValueCallback = metadata.CoerceValueCallback;
     TextProperty.OverrideMetadata(typeof(StylizedTextBlock), new FrameworkPropertyMetadata(string.Empty,
         FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender,
         OnTextChanged, originalCoerceValueCallback));
 }
        /// <summary>
        /// Register an attached dependency / bindable property
        /// </summary>
        /// <param name="name">The property name</param>
        /// <param name="propertyType">The property type</param>
        /// <param name="ownerType">The owner type</param>
        /// <param name="defaultValue">The default value</param>
        /// <param name="propertyChangedCallback">Callback to executed on property changed</param>
        /// <returns>The registred attached dependecy property</returns>
        public static DependencyProperty RegisterAttached(string name, Type propertyType, Type ownerType, object defaultValue = null, PropertyChangedCallback propertyChangedCallback = null) {
#if XFORMS
            return DependencyProperty.CreateAttached(name, propertyType, ownerType, defaultValue, propertyChanged: (obj, oldValue, newValue) => {
                if (propertyChangedCallback != null)
                    propertyChangedCallback(obj, new DependencyPropertyChangedEventArgs(newValue, oldValue, null));
            });
#else
            return DependencyProperty.RegisterAttached(name, propertyType, ownerType, new PropertyMetadata(defaultValue, propertyChangedCallback));
#endif
        }
Esempio n. 21
0
 public PropertyMetadata(
             object defaultValue,
             PropertyChangedCallback propertyChangedCallback,
             CoerceValueCallback coerceValueCallback)
 {
     this.CheckNotUnset(defaultValue);
     this.defaultValue = defaultValue;
     this.propertyChangedCallback = propertyChangedCallback;
     this.coerceValueCallback = coerceValueCallback;
 }
Esempio n. 22
0
        static GameManagerProperties()
        {
            PropertyChangedCallback dockingManagerChanged =
                new PropertyChangedCallback(OnDockingManagerChanged);
            PropertyMetadata dockingManagerMetadata =
                new PropertyMetadata(null, dockingManagerChanged);

            DockingManagerProperty = DependencyProperty.RegisterAttached("DockingManager",
                typeof(DockingManager), typeof(GameManagerProperties), dockingManagerMetadata);
        }
        /// Listen for change of the dependency property  
        public static void RegisterForNotification(this FrameworkElement element, string propertyName,  PropertyChangedCallback callback)
        {
            //Bind to a depedency property
            Binding b = new Binding(propertyName) { Source = element };
            var prop = System.Windows.DependencyProperty.RegisterAttached(
                "ListenAttached" + propertyName,
                typeof(object),
                typeof(UserControl),
                new System.Windows.PropertyMetadata(callback));

            element.SetBinding(prop, b);
        }
        // Listen for change of the dependency property
        public void RegisterForNotification(string propertyName, FrameworkElement element, PropertyChangedCallback callback)
        {
            // bind to dependency property
            var b = new Binding(propertyName) { Source = element };
            var prop = DependencyProperty.RegisterAttached(
                "NotifyAttached" + propertyName,
                typeof(object),
                typeof(UserControl),
                new PropertyMetadata(callback));

            element.SetBinding(prop, b);
        }
Esempio n. 25
0
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------

        #region Constructors

        static TextElement()
        {
            // For attached properties metadata specific to the type needs to be set using OverrideMetadata
            // instead of passing it during property registration. Otherwise all types will get it.
            PropertyChangedCallback typographyChanged = new PropertyChangedCallback(OnTypographyChanged);

            // Registering typography properties metadata
            DependencyProperty[] typographyProperties = Typography.TypographyPropertiesList;
            for (int i = 0; i < typographyProperties.Length; i++)
            {
                typographyProperties[i].OverrideMetadata(typeof(TextElement), new FrameworkPropertyMetadata(typographyChanged));
            }
        }
 //监听依赖属性变化,调用属性变化方法
 public static void Watch(this DependencyObject source, string dependencyPropertyName, PropertyChangedCallback callback)
 {
     if (dependencyPropertyName == null || source == null || callback == null)
         throw new ArgumentNullException();
     Binding binding = new Binding(dependencyPropertyName) { Source = source, Mode = BindingMode.OneWay };
     BindingSlave bs = new BindingSlave();
     _bindings.Add(bs);
     bs.PropertyChanged += (o, e) =>
     {
         callback(source, new DependencyPropertyChangedEventArgs());
     };
     BindingOperations.SetBinding(bs, BindingSlave.ValueProperty, binding);
 }
Esempio n. 27
0
        //-------------------------------------------------------------------
        //
        //  Constructors
        //
        //-------------------------------------------------------------------

        #region Constructors

        /// <summary>
        /// Static constructor. Registers metadata for its properties.
        /// </summary>
        static FlowDocument()
        {
            PropertyChangedCallback typographyChanged = new PropertyChangedCallback(OnTypographyChanged);

            // Registering typography properties metadata
            DependencyProperty[] typographyProperties = Typography.TypographyPropertiesList;
            for (int i = 0; i < typographyProperties.Length; i++)
            {
                typographyProperties[i].OverrideMetadata(_typeofThis, new FrameworkPropertyMetadata(typographyChanged));
            }

            DefaultStyleKeyProperty.OverrideMetadata(_typeofThis, new FrameworkPropertyMetadata(_typeofThis));
            FocusableProperty.OverrideMetadata(_typeofThis, new FrameworkPropertyMetadata(true));
        }
        /// <summary>
        /// Registers for a notification whenever a DependencyProperty changes.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="dependencyPropertyName">Name of the dependency property.</param>
        /// <param name="callback">The callback.</param>
        public static void RegisterForNotification(this FrameworkElement element, string dependencyPropertyName,
                                                   PropertyChangedCallback callback)
        {
            //Bind to a dependency property
            var b = new Binding(dependencyPropertyName) { Source = element };

            var prop = DependencyProperty.RegisterAttached(
                "ListenAttached" + dependencyPropertyName + _uniqueListenerNumber,
                typeof(object),
                typeof(UserControl),
                new PropertyMetadata(callback));

            element.SetBinding(prop, b);

            //Increment the _uniqueListenerNumber
            _uniqueListenerNumber++;
        }
Esempio n. 29
0
        public static void InitCache()
        {
            var nmeta = FrameworkElement.NameProperty.GetMetadata(DependencyObjectType.FromSystemType(typeof(FrameworkElement)));
            var fi = typeof(PropertyMetadata).GetField("_propertyChangedCallback", BindingFlags.NonPublic | BindingFlags.Instance);
            var newcb = new PropertyChangedCallback((o, e) =>
            {
                if (!string.IsNullOrEmpty((string)e.NewValue))
                {

                    //MessageBox.Show(string.Format("object:{0},\r\nname:{1}", o.ToString(), e.NewValue.ToString()));
                    LinkedList<WeakReference<FrameworkElement>> targetList;
                    var key = e.NewValue.ToString();
                    targetList = GetListByKey(key);
                    targetList.AddLast(new WeakReference<FrameworkElement>(o as FrameworkElement));
                }
            });

            var oldcb = (PropertyChangedCallback)fi.GetValue(nmeta);
            oldcb += newcb;
            fi.SetValue(nmeta, oldcb);
        }
Esempio n. 30
0
 private static IntPtr Create(object defaultValue,
                              PropertyChangedCallback propertyChangedCallback)
 {
     return(Create(defaultValue, propertyChangedCallback,
                   (def, invoke) => Noesis_CreatePropertyMetadata_(def, invoke)));
 }
Esempio n. 31
0
 public PropertyMetadata(object defaultValue,
                         PropertyChangedCallback propertyChangedCallback)
     : this(Create(defaultValue, propertyChangedCallback), true)
 {
 }
Esempio n. 32
0
 internal FrameworkPropertyMetadata(
     PropertyChangedCallback propertyChangedCallback,
     CoerceValueCallback coerceValueCallback
     ) : base(propertyChangedCallback, coerceValueCallback)
 {
 }
 public UIPropertyMetadata(PropertyChangedCallback propertyChangedCallback) :
     this()
 {
     this.PropertyChangedCallback = propertyChangedCallback;
 }
Esempio n. 34
0
 public PropertyMetadataHelper(PropertyChangedCallback propertyChangedCallback = null, object defaultValue = null)
 {
     DefaultValue = defaultValue;
     Callback     = propertyChangedCallback;
 }
Esempio n. 35
0
 public PropertyMetadata(object defaultValue, PropertyChangedCallback callback)
 {
     this.DefaultValue            = defaultValue;
     this.PropertyChangedCallback = callback;
 }
Esempio n. 36
0
 public RadElementPropertyMetadata(object defaultValue, ElementPropertyOptions options, PropertyChangedCallback propertyChangedCallback)
     : base(defaultValue, propertyChangedCallback)
 {
     this._options = options;
 }
Esempio n. 37
0
        public static DependencyProperty Register <TControl, TProperty>(Expression <Func <TControl, TProperty> > property, TProperty defaultValue, PropertyChangedCallback <TControl, TProperty> propertyChangedCallback = null) where TControl : DependencyObject
        {
            if (propertyChangedCallback == null)
            {
                return(DependencyProperty.Register(GetPropertyName(property), typeof(TProperty), typeof(TControl), new PropertyMetadata(defaultValue)));
            }

            return(DependencyProperty.Register(GetPropertyName(property), typeof(TProperty), typeof(TControl), new PropertyMetadata(defaultValue, (obj, args) =>
            {
                propertyChangedCallback(obj as TControl, (TProperty)args.OldValue, (TProperty)args.NewValue);
            })));
        }
Esempio n. 38
0
 public IFluentPropertyChanged <T> OnChanged(PropertyChangedCallback <T> action) => this;
Esempio n. 39
0
 static PropertyMetadata \u206C‬‫‪‌‬‪​‍‪‮‏‎‏‭‭‏‭‫‪‫‭‭‍‪‌‮([In] object obj0, [In] PropertyChangedCallback obj1)
 {
     return(new PropertyMetadata(obj0, obj1));
 }
 public UIPropertyMetadata(object defaultValue, PropertyChangedCallback propertyChangedCallback, CoerceValueCallback coerceValueCallback, bool isAnimationProhibited) :
     this(defaultValue, propertyChangedCallback, coerceValueCallback)
 {
 }
Esempio n. 41
0
 public IFluentPropertyChanged <T> OnChanged(PropertyChangedCallback <T> action)
 {
     action(oldValue);
     return(this);
 }
Esempio n. 42
0
 public FrameworkPropertyMetadata(
     PropertyChangedCallback propertyChangedCallback,
     CoerceValueCallback coerceValueCallback)
     : base(new PropertyChangedCallback(new PropertyChangeHook(FrameworkPropertyMetadataOptions.None, propertyChangedCallback, coerceValueCallback).OnPropertyChanged))
 {
 }
Esempio n. 43
0
 public PropertyMetadata(PropertyChangedCallback callback)
 {
     this.PropertyChangedCallback = callback;
 }
Esempio n. 44
0
 public static PropertyMetadata CreatePropertyMetadata <TPROP>(TPROP defaultValue, PropertyChangedCallback propertyChangedCallback, CoerceValueCallback coerceValueCallback)
 {
     return(new PropertyMetadata(defaultValue, propertyChangedCallback, coerceValueCallback));
 }
Esempio n. 45
0
 static PropertyMetadata \u202B‬‫‎‭‬‮‭‏‭​‪‬‫‌‌‎‎‌‏‪​‬‮([In] object obj0, [In] PropertyChangedCallback obj1)
 {
     return(new PropertyMetadata(obj0, obj1));
 }
        private static PropertyChangedCallback AttachCallback(object defaultValue, DrawingPropertyMetadataOptions options, PropertyChangedCallback propertyChangedCallback)
        {
            DrawingPropertyMetadata metadata = new DrawingPropertyMetadata(options, defaultValue)
            {
                options = options,
                propertyChangedCallback = propertyChangedCallback
            };

            return(metadata.InternalCallback);
        }
Esempio n. 47
0
        public void performOnStartup()
        {
            defaultBrush = StudyFocusForeignWord.Background;
            StudyFocusForeignWord.Items.Add("General Review");
            StudyFocusForeignWord.SelectedIndex = 0;

            /*
             * foreach (var x in stringHeights.Take(100))
             * {
             *  Debug.WriteLine(x.Key + x.Value);
             * }
             */
            /*
             * TreeView tree = new TreeView();
             *
             * TreeViewItem t = new TreeViewItem();
             *
             * tree.Items.Add(t);
             *
             * for (int i = 0; i < 50; ++i)
             * {
             *  //                CheckBox c = new CheckBox();
             *  //                t.Items.Add(c);
             *  //            }
             *  Polygon p = new Polygon();
             *  p.Points.Add(new Point(0, 0));
             *  p.Points.Add(new Point(4, 0));
             *  p.Points.Add(new Point(0, 4));
             *  p.Fill = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));
             *  t.Items.Add(p);
             * }
             *
             * //            StackPanel s = ;
             * //           tree.Items.Add(obj);
             *
             * VocabSelectionScrollViewer.Content = tree;
             */
            StudyFocus = "";

            // load books

            /*
             * Dictionary<string, int> wordFreqs = new Dictionary<string,int>();
             * foreach (var y in mainPage.sentenceDictionary.getSentences("", q => true))
             * {
             *  foreach (var x in mainPage.sentenceDictionary.getWords(y))
             *  {
             *      if (!wordFreqs.ContainsKey(x))
             *      {
             *          wordFreqs[x] = 0;
             *      }
             ++wordFreqs[x];
             *  }
             * }
             * List<Tuple<int, string>> wordFreqsL = new List<Tuple<int, string>>();
             * foreach (var x in wordFreqs)
             * {
             *  wordFreqsL.Add(Tuple.Create(x.Value, x.Key));
             * }
             * wordFreqsL.Sort();
             * wordFreqsL.Reverse();
             * FileStream f = new FileStream(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\gezaSpecialFile2.txt", FileMode.Create);
             * //IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream("gezaFileSilverlight.txt", FileMode.Create, isoFile);
             * StreamWriter sw = new StreamWriter(f);
             * foreach (var x in wordFreqsL)
             * {
             *  sw.WriteLine(x.Item2 + "\t" + x.Item1);
             * }
             * sw.Close();
             * f.Close();
             */

            /*
             * foreach (string word in wordDictionary.listWordsByFrequency().Take(2000))
             * {
             *  this.kSetAllowedWords.Add(word);
             * }
             */

            selectedTextbook = allTextbooks;
            selectedChapter  = allChapters;
            //this.textbookSelect.Items.Add(allTextbooks);

            for (int i = 0; i < textbooks.textbooks.Length; ++i)
            {
                ComboBoxItem kItem = new ComboBoxItem();
                kItem.Content = textbooks.textbooks[i].textbookName;
                this.textbookSelect.Items.Add(textbooks.textbooks[i].textbookName);
            }
            this.textbookSelect.SelectedIndex = 0;
            textbookSelect.SelectionChanged  += (s, e) =>
            {
                this.kPrevSearchTerm = "";
                if (this.textbookSelect.SelectedItem.ToString() != this.selectedTextbook)
                {
                    this.chapterSelect.Items.Clear();
                    this.selectedTextbook = this.textbookSelect.SelectedItem.ToString();

                    if (textbooks.textbookDictionary.ContainsKey(textbookSelect.SelectedItem.ToString()))
                    {
                        Textbooks.Textbook t = textbooks.textbookDictionary[textbookSelect.SelectedItem.ToString()];
                        this.chapterSelect.Items.Add(allChapters);
                        for (int i = 0; i < t.chapters.Length; ++i)
                        {
                            this.chapterSelect.Items.Add(t.chapters[i].chapterName);
                        }
                    }
                    if (this.chapterSelect.Items.Count > 0)
                    {
                        this.chapterSelect.SelectedIndex = 0;
                    }
                    Search_TextChanged(null, null);
                }
            };

            Textbooks.Textbook t1 = textbooks.textbookDictionary[textbookSelect.SelectedItem.ToString()];
            this.chapterSelect.Items.Add(allChapters);
            for (int i = 0; i < t1.chapters.Length; ++i)
            {
                this.chapterSelect.Items.Add(t1.chapters[i].chapterName);
            }

            this.chapterSelect.SelectedIndex = 0;

            chapterSelect.SelectionChanged += (s, e) =>
            {
                this.kPrevSearchTerm = "";
                if (this.chapterSelect.SelectedItem != null &&
                    this.chapterSelect.SelectedItem.ToString() != this.selectedChapter)
                {
                    this.selectedChapter = this.chapterSelect.SelectedItem.ToString();
                    Search_TextChanged(null, null);
                }
            };


            //this.kSetAllowedWords = new HashSet<string>();



            //Label showVocab = new Label();
            //showVocab.Height = 20.0;
            //showVocab.Content = "show all vocab";
            //kMatches = wordDictionary.listWords();

            /*
             * IList<UIElement> elementList = new List<UIElement>();
             * showVocab.SetValue(Canvas.LeftProperty, 0.0);
             * showVocab.SetValue(Canvas.TopProperty, 0.0);
             * elementList.Add(showVocab);
             */
            // going ahead to create an Element List of every possible UI element that could ever be displayed on the canvas


            /*
             * IList<string> allWords = wordDictionary.listWords();
             * IList<UIElement> elementList = new List<UIElement>();
             * TreeView tree = new TreeView();
             *
             * VocabSelectionScrollViewer.Content = tree;
             *
             * //tree
             *
             *
             *
             */
            /*
             * for (int i = 0; i < allWords.Count; ++i)
             * {
             *  string word = allWords[i];
             *  CheckBox newVocab = new CheckBox();
             *  newVocab.Height = 20.0;
             *  newVocab.Content = word;
             *  newVocab.Checked += (s,e) =>
             *  {
             *      this.kSetAllowedWords.Add(word);
             *  };
             *  newVocab.Unchecked += (s,e) =>
             *  {
             *      this.kSetAllowedWords.Remove(word);
             *  };
             *
             *  //newVocab.SetValue(Canvas.LeftProperty, 10.0);
             *  //newVocab.SetValue(Canvas.TopProperty, 20.0 * i + 20.0);
             *  elementList.Add(newVocab);
             * }
             */


            //int iOffset = 0;

            //Search_TextChanged(null,null);
            findMatchingTextSynchronous("");
            sortPinYin(null, null);
            //VocabSelectionCanvas.Height = dLineHeight * this.kMatches.Count;
            VocabSelectionCanvas.Height = canvasHeight;

            PropertyChangedCallback onScrollChanged = (s, e) =>
            {
                //if (!vocabShownClicked) return;
                DrawSearchMatches();
            };

            // attach onScrolledChanged, so it is called everytime scrolling happens
            VocabSelectionScrollViewer.AddScrollCallback(onScrollChanged);


            /*            double dLineHeight = 20.0;
             *
             *          int iFirstVisibleItem = (int)(VocabSelectionScrollViewer.VerticalOffset/20.0);
             *          int iLastItemVisible = (int)((VocabSelectionScrollViewer.VerticalOffset+VocabSelectionScrollViewer.Height)/20.0);
             *
             *          for (int i = iFirstVisibleItem; i <= iLastItemVisible; ++i)
             *          {
             *              CheckBox kCheckBoxBook = new CheckBox();
             *              kCheckBoxBook.Height = dLineHeight;
             *              kCheckBoxBook.Content = this.kMatches[i];
             *              kCheckBoxBook.SetValue(Canvas.LeftProperty,10.0);
             *              kCheckBoxBook.SetValue(Canvas.TopProperty,dLineHeight*i+dLineHeight);
             *              VocabSelectionCanvas.Children.Add(kCheckBoxBook);
             *          }
             *
             */

            /*
             * // for each book
             * for (int i = 0; i < Textbooks.textbooks.Length; ++i)
             * {
             *
             *  CheckBox kCheckBoxBook = new CheckBox();
             *  kCheckBoxBook.Height = dLineHeight;
             *  kCheckBoxBook.Content = textbooks.textbooks[i].textbookName;
             *  kCheckBoxBook.SetValue(Canvas.LeftProperty, 10.0);
             *  kCheckBoxBook.SetValue(Canvas.TopProperty, 20.0 * iOffset + 20.0);
             *  VocabSelectionCanvas.Children.Add(kCheckBoxBook);
             *  iOffset += 1;
             *  // for each chapter
             *  for (int j = 0; j < textbooks[i].Length; ++j)
             *  {
             *      CheckBox kCheckBoxChapter = new CheckBox();
             *      elementList.Add(kCheckBoxChapter);
             *
             *      iOffset += 1;
             *      // for each word
             *      for (int k = 0; k < textbooks[i][j].Length; ++k)
             *      {
             *          CheckBox kCheckBoxWord = new CheckBox();
             *          elementList.Add(newVocab);
             *          // read in the word
             *          string kWord = "word";
             *          textbooks[i][j][k] = kWord;
             *          iOffset += 1;
             *      }
             *  }
             * }
             */


            /*
             *          VocabSelectionCanvas.Children.Add(showVocab);
             *          // given two input integers, draws the ui elements whos indices are in the list designated by the range indices
             *          Action<int, int> drawItemsInRange = (int firstItemVisible, int lastItemVisible) =>
             *          {
             *              VocabSelectionCanvas.Children.Clear();
             *              int startpos = Math.Max(firstItemVisible - 2, 0);
             *              int endpos = Math.Min(lastItemVisible + 2, allWords.Count - 1);
             *              for (int i = startpos; i < endpos; ++i)
             *              {
             *                  //elementList[i].SetValue(Canvas.LeftProperty, 10.0);
             *                  //elementList[i].SetValue(Canvas.TopProperty, 20.0 * i + 20.0);
             *                  CheckBox newVocab = new CheckBox();
             *                  newVocab.Height = 20.0;
             *                  newVocab.Content = allWords[i];
             *                  newVocab.SetValue(Canvas.LeftProperty, 10.0);
             *                  newVocab.SetValue(Canvas.TopProperty, 20.0 * i + 20.0);
             *                  VocabSelectionCanvas.Children.Add(newVocab);
             *              }
             *          };
             *
             *
             *          bool vocabShownClicked = false;
             *          showVocab.MouseLeftButtonDown += (s, e) =>
             *          {
             *              vocabShownClicked = true;
             *              VocabSelectionCanvas.Height = 20.0 + 20.0 * allWords.Count;
             *              int firstItemVisible = (int) (VocabSelectionScrollViewer.VerticalOffset / 20.0);
             *              int lastItemVisible = (int) ((VocabSelectionScrollViewer.VerticalOffset + VocabSelectionScrollViewer.Height) / 20.0);
             *              drawItemsInRange(firstItemVisible, lastItemVisible);
             *          };
             *
             *          // function that determines what ui elements are visible, and then calls drawItemsInRange to draw them
             *          PropertyChangedCallback onScrollChanged = (s, e) =>
             *          {
             *              if (!vocabShownClicked) return;
             *              int firstItemVisible = (int)(VocabSelectionScrollViewer.VerticalOffset / 20.0);
             *              int lastItemVisible = (int)((VocabSelectionScrollViewer.VerticalOffset + VocabSelectionScrollViewer.Height) / 20.0);
             *              drawItemsInRange(firstItemVisible, lastItemVisible);
             *          };
             *
             *          // attach onScrolledChanged, so it is called everytime scrolling happens
             *          VocabSelectionScrollViewer.AddScrollCallback(onScrollChanged);
             */
            /*
             * foreach (string word in wordDictionary.listWords().Take(50)) // first 50 words in dictionary
             * {
             *  CheckBox checkbox = new CheckBox();
             *  checkbox.Content = word;
             *  this.AllVocabList.Items.Add(checkbox);
             * }
             */
            //#endif
        }
Esempio n. 48
0
 private static Dictionary <string, DependencyProperty> RegistredDependencyProperties = new Dictionary <string, DependencyProperty>();// = new KeyValuePair<string, DependencyProperty>();
 private static DependencyProperty GetOrCreateAttachedProperty(string sDpName, Type t = null, object defaulevalue = null, PropertyChangedCallback cb = null)
 {
     if (RegistredDependencyProperties.ContainsKey(sDpName))
     {
         return(RegistredDependencyProperties[sDpName]);
     }
     else
     {
         DependencyProperty dp = DependencyProperty.RegisterAttached(sDpName, t, typeof(BindingBase), new PropertyMetadata(defaulevalue, cb));
         RegistredDependencyProperties.Add(sDpName, dp);
         return(dp);
     }
 }
Esempio n. 49
0
 public PropertyMetadata(
     PropertyChangedCallback propertyChangedCallback
     )
 {
     PropertyChangedCallback = propertyChangedCallback;
 }
Esempio n. 50
0
 /// <summary>
 /// 依存関係プロパティのバインディング方法を明示して依存関係プロパティを登録します。
 /// </summary>
 /// <typeparam name="T">依存関係プロパティのデータ型</typeparam>
 /// <param name="name">名前</param>
 /// <param name="owner">依存関係プロパティを保持するクラスの型</param>
 /// <param name="defaultValue">デフォルト値</param>
 /// <param name="bindingOption">依存関係プロパティのバインディング方法</param>
 /// <param name="callback">値変更時の処理</param>
 /// <param name="validate">値変更時の検証処理</param>
 /// <returns></returns>
 public static DependencyProperty Register <T>(
     string name, Type owner, T defaultValue, FrameworkPropertyMetadataOptions bindingOption, PropertyChangedCallback callback = null, ValidateValueCallback validate = null
     )
 {
     return(Register(name, owner, defaultValue, callback, validate, bindingOption));
 }
Esempio n. 51
0
 public static DependencyProperty Register <TOBJ, TPROP>(string name, TPROP defaultValue, PropertyChangedCallback propertyChangedCallback, CoerceValueCallback coerceValueCallback)
     where TOBJ : DependencyObject
 {
     return(DependencyProperty.Register(name, typeof(TPROP), typeof(TOBJ), CreatePropertyMetadata(defaultValue, propertyChangedCallback, coerceValueCallback)));
 }
Esempio n. 52
0
 public FrameworkPropertyMetadata(PropertyChangedCallback propertyChangedCallback)
     : base(propertyChangedCallback)
 {
 }
 public DrawingPropertyMetadata(object defaultValue, DrawingPropertyMetadataOptions options, PropertyChangedCallback propertyChangedCallback) : base(defaultValue, (FrameworkPropertyMetadataOptions)options, AttachCallback(defaultValue, options, propertyChangedCallback))
 {
 }
Esempio n. 54
0
 public FrameworkPropertyMetadata(
     object defaultValue,
     PropertyChangedCallback propertyChangedCallback)
     : base(defaultValue, propertyChangedCallback)
 {
 }
Esempio n. 55
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            UnbindMediaPlayer();

            var trueToVisible = new FromNullableBoolToVisibilityConverter();

            _playPauseButton = this.GetTemplateChild(PlayPauseButtonName) as Button;

            _playPauseButtonOnLeft = this.GetTemplateChild(PlayPauseButtonOnLeftName) as Button;

            _volumeMuteButton = this.GetTemplateChild(VolumeMuteButtonName) as Button;
            _volumeMuteButton?.SetBinding(Button.VisibilityProperty, new Binding {
                Path = "IsVolumeButtonVisible", Source = this, Mode = BindingMode.OneWay, FallbackValue = Visibility.Collapsed, Converter = trueToVisible
            });
            _volumeMuteButton?.SetBinding(Button.IsEnabledProperty, new Binding {
                Path = "IsVolumeEnabled", Source = this, Mode = BindingMode.OneWay, FallbackValue = true
            });

            _audioMuteButton = this.GetTemplateChild(AudioMuteButtonName) as Button;

            _volumeSlider = this.GetTemplateChild(VolumeSliderName) as Slider;
            if (_volumeSlider != null)
            {
                _volumeSlider.Maximum = 100;
                _volumeSlider.Value   = 100;
            }

            _fullWindowButton = this.GetTemplateChild(FullWindowButtonName) as Button;
            if (_fullWindowButton != null)
            {
                _fullWindowButton.SetBinding(Button.VisibilityProperty, new Binding {
                    Path = "IsFullWindowButtonVisible", Source = this, Mode = BindingMode.OneWay, FallbackValue = Visibility.Collapsed, Converter = trueToVisible
                });
                _fullWindowButton.SetBinding(Button.IsEnabledProperty, new Binding {
                    Path = "IsFullWindowEnabled", Source = this, Mode = BindingMode.OneWay, FallbackValue = true
                });
                _fullWindowButton.Tapped -= FullWindowButtonTapped;
                _fullWindowButton.Tapped += FullWindowButtonTapped;
            }

            _castButton = this.GetTemplateChild(CastButtonName) as Button;

            _zoomButton = this.GetTemplateChild(ZoomButtonName) as Button;

            if (_zoomButton != null)
            {
                _zoomButton?.SetBinding(Button.VisibilityProperty, new Binding {
                    Path = "IsZoomButtonVisible", Source = this, Mode = BindingMode.OneWay, FallbackValue = Visibility.Collapsed, Converter = trueToVisible
                });
                _zoomButton?.SetBinding(Button.IsEnabledProperty, new Binding {
                    Path = "IsZoomEnabled", Source = this, Mode = BindingMode.OneWay, FallbackValue = true
                });
                _zoomButton.Tapped -= ZoomButtonTapped;
                _zoomButton.Tapped += ZoomButtonTapped;
            }

            _playbackRateButton = this.GetTemplateChild(PlaybackRateButtonName) as Button;
            _playbackRateButton?.SetBinding(Button.VisibilityProperty, new Binding {
                Path = "IsPlaybackRateButtonVisible", Source = this, Mode = BindingMode.OneWay, FallbackValue = Visibility.Collapsed, Converter = trueToVisible
            });
            _playbackRateButton?.SetBinding(Button.IsEnabledProperty, new Binding {
                Path = "IsPlaybackRateEnabled", Source = this, Mode = BindingMode.OneWay, FallbackValue = true
            });

            _skipForwardButton = this.GetTemplateChild(SkipForwardButtonName) as Button;
            _skipForwardButton?.SetBinding(Button.VisibilityProperty, new Binding {
                Path = "IsSkipForwardButtonVisible", Source = this, Mode = BindingMode.OneWay, FallbackValue = Visibility.Collapsed, Converter = trueToVisible
            });
            _skipForwardButton?.SetBinding(Button.IsEnabledProperty, new Binding {
                Path = "IsSkipForwardEnabled", Source = this, Mode = BindingMode.OneWay, FallbackValue = true
            });

            _nextTrackButton = this.GetTemplateChild(NextTrackButtonName) as Button;
            _nextTrackButton?.SetBinding(Button.VisibilityProperty, new Binding {
                Path = "IsNextTrackButtonVisible", Source = this, Mode = BindingMode.OneWay, FallbackValue = Visibility.Collapsed, Converter = trueToVisible
            });

            _fastForwardButton = this.GetTemplateChild(FastForwardButtonName) as Button;
            _fastForwardButton?.SetBinding(Button.VisibilityProperty, new Binding {
                Path = "IsFastForwardButtonVisible", Source = this, Mode = BindingMode.OneWay, FallbackValue = Visibility.Collapsed, Converter = trueToVisible
            });
            _fastForwardButton?.SetBinding(Button.IsEnabledProperty, new Binding {
                Path = "IsFastForwardEnabled", Source = this, Mode = BindingMode.OneWay, FallbackValue = true
            });

            _rewindButton = this.GetTemplateChild(RewindButtonName) as Button;
            _rewindButton?.SetBinding(Button.VisibilityProperty, new Binding {
                Path = "IsFastRewindButtonVisible", Source = this, Mode = BindingMode.OneWay, FallbackValue = Visibility.Collapsed, Converter = trueToVisible
            });
            _rewindButton?.SetBinding(Button.IsEnabledProperty, new Binding {
                Path = "IsFastRewindEnabled", Source = this, Mode = BindingMode.OneWay, FallbackValue = true
            });

            _previousTrackButton = this.GetTemplateChild(PreviousTrackButtonName) as Button;
            _previousTrackButton?.SetBinding(Button.VisibilityProperty, new Binding {
                Path = "IsPreviousTrackButtonVisible", Source = this, Mode = BindingMode.OneWay, FallbackValue = Visibility.Collapsed, Converter = trueToVisible
            });

            _skipBackwardButton = this.GetTemplateChild(SkipBackwardButtonName) as Button;
            _skipBackwardButton?.SetBinding(Button.VisibilityProperty, new Binding {
                Path = "IsSkipBackwardButtonVisible", Source = this, Mode = BindingMode.OneWay, FallbackValue = Visibility.Collapsed, Converter = trueToVisible
            });
            _skipBackwardButton?.SetBinding(Button.IsEnabledProperty, new Binding {
                Path = "IsSkipBackwardEnabled", Source = this, Mode = BindingMode.OneWay, FallbackValue = true
            });

            _stopButton = this.GetTemplateChild(StopButtonName) as Button;
            _stopButton?.SetBinding(Button.VisibilityProperty, new Binding {
                Path = "IsStopButtonVisible", Source = this, Mode = BindingMode.OneWay, FallbackValue = Visibility.Collapsed, Converter = trueToVisible
            });
            _stopButton?.SetBinding(Button.IsEnabledProperty, new Binding {
                Path = "IsStopEnabled", Source = this, Mode = BindingMode.OneWay, FallbackValue = true
            });

            _audioTracksSelectionButton = this.GetTemplateChild(AudioTracksSelectionButtonName) as Button;

            _ccSelectionButton = this.GetTemplateChild(CCSelectionButtonName) as Button;

            _timeElapsedElement = this.GetTemplateChild(TimeElapsedElementName) as TextBlock;

            _timeRemainingElement = this.GetTemplateChild(TimeRemainingElementName) as TextBlock;

            _progressSlider = this.GetTemplateChild(ProgressSliderName) as Slider;
            PropertyChangedCallback callback = OnSliderTemplateChanged;

            _progressSlider?.RegisterDisposablePropertyChangedCallback(Slider.TemplateProperty, callback);

            _bufferingProgressBar = this.GetTemplateChild(BufferingProgressBarName) as ProgressBar;

            _timelineContainer = this.GetTemplateChild(TimelineContainerName) as Border;

            _downloadProgressIndicator = _progressSlider?.GetTemplateChild(DownloadProgressIndicatorName) as ProgressBar;

            _rootGrid = this.GetTemplateChild(RootGridName) as Grid;
            if (_rootGrid != null)
            {
                _rootGrid.Tapped -= OnRootGridTapped;
                _rootGrid.Tapped += OnRootGridTapped;
            }

            if (_mediaPlayer != null)
            {
                BindMediaPlayer();
            }
        }
Esempio n. 56
0
        public static DependencyProperty Register(string name, Type ownerType, object defaultValue, PropertyChangedCallback propertyChangedCallback)
        {
            return(DependencyProperty.Register(name, typeof(Storyboard), ownerType, new PropertyMetadata(defaultValue, propertyChangedCallback
#if !SL
                                                                                                         , CoerceStoryboard
#endif
                                                                                                         )));
        }
 public UIPropertyMetadata(object defaultValue, PropertyChangedCallback propertyChangedCallback) :
     this(defaultValue)
 {
     this.PropertyChangedCallback = propertyChangedCallback;
 }
 /// <summary>
 ///     Type meta construction
 /// </summary>
 /// <param name="defaultValue">Default value of property</param>
 /// <param name="propertyChangedCallback">Called when the property has been changed</param>
 public PropertyMetadata(object defaultValue,
                         PropertyChangedCallback propertyChangedCallback)
 {
     DefaultValue            = defaultValue;
     PropertyChangedCallback = propertyChangedCallback;
 }
Esempio n. 59
0
 public FrameworkPropertyMetadata(PropertyChangedCallback propertyChangedCallback) :
     base(propertyChangedCallback)
 {
     Initialize();
 }
 public UIPropertyMetadata(object defaultValue, PropertyChangedCallback propertyChangedCallback, CoerceValueCallback coerceValueCallback) :
     this(defaultValue, propertyChangedCallback)
 {
     this.CoerceValueCallback = coerceValueCallback;
 }