Example #1
0
        public void ObserveValueForKeyPathOfObject(string keyPath, object obj, Dictionary<string, object> change, object context)
        {
            if (keyPath.Equals("TabHeight") || keyPath.Equals("LeftControl")) {
                UpdateTabViewLayout();
                InvalidateArrange();
            } else if (keyPath.Equals("ActiveItem")) {

                if (ActiveItem != null && ActiveItem.ViewController != null) {
                    contentCanvas.Child = ActiveItem.ViewController.View;
                    ActiveItem.ViewController.ViewWillBeShown();
                } else {
                    contentCanvas.Child = null;
                }

                if (ActiveItem.TintColor == Color.FromArgb(0,0,0,0)) {
                    contentCanvas.Background = new SolidColorBrush(kDefaultTintColor);
                } else {
                    contentCanvas.Background = new SolidColorBrush(ActiveItem.TintColor);
                }

                UpdateTabViewLayout();
                InvalidateArrange();

            } else if (keyPath.Equals("Items")) {

                KNTabViewItem[] oldItems = (KNTabViewItem[])change.ValueForKey(KNKVOConstants.KNKeyValueChangeOldKey);

                if (oldItems != null) {
                    foreach (KNTabViewItem item in oldItems) {
                        RemoveTabForItem(item);
                    }
                }

                KNTabViewItem[] newItems = (KNTabViewItem[])change.ValueForKey(KNKVOConstants.KNKeyValueChangeNewKey);
                if (newItems != null) {
                    foreach (KNTabViewItem item in newItems) {
                        CreateTabForItem(item);
                    }

                    if (newItems.Length > 0) {
                        ActiveItem = newItems[0];
                    }

                }
                UpdateTabViewLayout();
                InvalidateArrange();
            }
        }
Example #2
0
            public void ObserveValueForKeyPathOfObject(string keyPath, object obj, Dictionary<string, object> change, object context)
            {
                if (keyPath.Equals("IsActive")) {

                    if (IsActive) {

                        DropShadowEffect effect = new DropShadowEffect();
                        effect.BlurRadius = 3.0;
                        effect.Color = Colors.Black;
                        effect.Direction = 90.0;
                        effect.ShadowDepth = 0.0;

                        Effect = effect;

                    } else {

                        DropShadowEffect effect = new DropShadowEffect();
                        effect.BlurRadius = 2.0;
                        effect.Color = Colors.DarkGray;
                        effect.Direction = 90.0;
                        effect.ShadowDepth = 0.0;

                        Effect = null;

                    }
                    InvalidateVisual();

                } else if (keyPath.Equals("RepresentedObject")) {

                    KNTabViewItem oldItem = (KNTabViewItem)change.ValueForKey(KNKVOConstants.KNKeyValueChangeOldKey);
                    if (oldItem != null) {
                        oldItem.RemoveObserverFromKeyPath(this, "Title");
                        oldItem.RemoveObserverFromKeyPath(this, "Icon");
                        oldItem.RemoveObserverFromKeyPath(this, "TintColor");
                    }

                    KNTabViewItem newItem = (KNTabViewItem)change.ValueForKey(KNKVOConstants.KNKeyValueChangeNewKey);
                    if (newItem != null) {
                        newItem.AddObserverToKeyPathWithOptions(this, "Title", 0, null);
                        newItem.AddObserverToKeyPathWithOptions(this, "Icon", 0, null);
                        newItem.AddObserverToKeyPathWithOptions(this, "TintColor", 0, null);
                    }

                    formattedText = null;
                    InvalidateVisual();

                } else if (keyPath.Equals("Title")) {

                    EventHandler<EventArgs> handler = TabMayWantNewSize;
                    if (handler != null) {
                        handler(this, null);
                    }

                    formattedText = null;
                    InvalidateVisual();

                } else if (keyPath.Equals("Icon")) {

                    EventHandler<EventArgs> handler = TabMayWantNewSize;
                    if (handler != null) {
                        handler(this, null);
                    }
                    InvalidateVisual();
                } else if (keyPath.Equals("TintColor")) {
                    InvalidateVisual();
                }
            }
        public UpdateSigningKey(Dictionary<string, object> plistRep) {

            Name = (string)plistRep.ValueForKey("Name");
            PublicKey = Convert.FromBase64String((string)plistRep.ValueForKey("PublicKey"));
            PrivateKey = Convert.FromBase64String((string)plistRep.ValueForKey("PrivateKey"));
        }