/// <summary>
        /// Adds selected item (photo) to the SelectedPhotos collection
        /// </summary>
        private void allPhotosListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // TODO When switching folders automatically select photos that are in the SelectedPhotos collection
            // TODO DO NOT remove the first selected photo when changing folders

            if (allPhotosListBox.SelectedItems.Count > Constants.MaxSelectedPhotos)
            {
                // Maximum number of selected photos reached
                allPhotosListBox.SelectedItems.RemoveAt(allPhotosListBox.SelectedItems.Count - 1);
                return;
            }

            System.Collections.IList     eAdded        = e.AddedItems;
            System.Collections.IList     eRemoved      = e.RemovedItems;
            ObservableCollection <Photo> selectedItems = AttachedProperties.GetSelectedPhotos(allPhotosListBox);

            if (eAdded.Count != 0)
            {
                // New photo selected
                selectedItems.Add((Photo)eAdded[0]);
            }
            else if (eRemoved.Count != 0)
            {
                // Photo unselected
                selectedItems.Remove((Photo)eRemoved[0]); // When folders change and SelectionChanged is raised this removes the first photo from the SelectedPhotos
            }
        }
예제 #2
0
        private double GetDeltaYCrop(Image imageOriginal)
        {
            ViewportControl viewportControl = null;

            for (FrameworkElement frameworkElement = (FrameworkElement)imageOriginal; frameworkElement != null; frameworkElement = VisualTreeHelper.GetParent((DependencyObject)frameworkElement) as FrameworkElement)
            {
                if (frameworkElement is ViewportControl)
                {
                    viewportControl = frameworkElement as ViewportControl;
                    break;
                }
            }
            double num1 = 0.0;

            if (viewportControl != null)
            {
                Rect rect = ((UIElement)imageOriginal).TransformToVisual((UIElement)viewportControl).TransformBounds(new Rect(0.0, 0.0, ((FrameworkElement)imageOriginal).ActualWidth, ((FrameworkElement)imageOriginal).ActualHeight));
                // ISSUE: explicit reference operation
                double num2 = rect.Top - AttachedProperties.GetExtraDeltaYCropWhenHidingImage((DependencyObject)viewportControl);
                if (num2 < 0.0)
                {
                    num1 = -num2;
                }
            }
            return(num1);
        }
        protected override void OnAttached()
        {
            base.OnAttached();

            _expire.Elapsed += (sneder, args) =>
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    Debug.WriteLine("EXPIRE ELAPSED");
                    SetExpiration(false);
                    if (_notYetOpened)
                    {
                        AttachedProperties.SetLastClickWasTouch(AssociatedObject, false);
                    }
                }));
            };

            AssociatedObject.Initialized += (sneder, args) =>
            {
                Touch.FrameReported += Touch_FrameReported;
            };

            DependencyPropertyDescriptor.FromProperty(ContextMenu.PlacementTargetProperty, typeof(ContextMenu)).AddValueChanged(AssociatedObject, AssociatedObject_PlacementTargetChanged);

            if (AssociatedObject.IsOpen)
            {
                _notYetOpened = false;
            }

            AssociatedObject.Opened += AssociatedObject_Opened;

            AssociatedObject.Loaded += AssociatedObject_Loaded;
        }
예제 #4
0
        private void ParseTag(IEnumerable <string> tag)
        {
            var chars = tag.First().SkipWhile(c => c == ' ' || c == '<').TakeWhile(c => char.IsLetter(c));

            NodeName = new string(chars.ToArray());

            Regex attributes = new Regex("[ ,\t]{1}[a-z,A-Z,0-9]{1,}[ ]{0,}[=]{1}[ ]{0,}[\"]{1}[a-z,A-Z,0-9,_ ]{0,}[\"]{1}");

            System.Text.StringBuilder tagStr = new System.Text.StringBuilder();

            foreach (string str in tag)
            {
                tagStr.Append($" {str.Trim('\n')} ");
            }

            IEnumerable <string> attr = attributes.Matches(tagStr.ToString()).Select(m => m.Value);

            foreach (string attribute in attr)
            {
                string[] parts = attribute.Split('=');
                ObjectProperties.Add(parts[0].Trim(), parts[1].Trim().Trim('"'));
            }

            attributes = new Regex("[a-z,A-Z,0-9]{1,}[:]{1}[a-z,A-Z,0-9]{1,}[ ]{0,}[=]{1}[ ]{0,}[\"]{1}[a-z,A-Z,0-9]{0,}[\"]{1}");

            attr = attributes.Matches(tagStr.ToString()).Select(m => m.Value);

            foreach (string attribute in attr)
            {
                string[] parts = attribute.Split('=');
                AttachedProperties.Add(parts[0], parts[1].Trim('"'));
            }
        }
 void UpdateLastClickWasTouch()
 {
     if (_target != null)
     {
         AttachedProperties.SetLastClickWasTouch(AssociatedObject, AttachedProperties.GetLastClickWasTouch(_target));
     }
 }
 private void Touch_FrameReported(object sender, TouchFrameEventArgs e)
 {
     Debug.WriteLine("Touch_FrameReported");
     if (_notYetOpened)
     {
         AttachedProperties.SetLastClickWasTouch(AssociatedObject, true);
         SetExpiration(true);
     }
 }
예제 #7
0
        public void MatrixExtendedWithXPropertyYieldsX()
        {
            var engine = new Engine();

            AttachedProperties.Register <Double[, ]>("x", matrix => matrix[0, 0]);
            var result = engine.Interpret("M = [1,2,3]; M.x");

            AttachedProperties.Unregister <Double[, ]>("x");
            Assert.AreEqual(1.0, result);
        }
예제 #8
0
 private void RemoveStopsFromMap(params string[] stops)
 {
     foreach (var item in StopIconWrappers.ToArray())
     {
         if (stops.Contains(AttachedProperties.GetElementID(item.Element)))
         {
             MapElementsShown.Remove(item.Element);
             StopIconWrappers.Remove(item);
         }
     }
 }
예제 #9
0
        protected override void OnAttached()
        {
            base.OnAttached();

            DependencyPropertyDescriptor.FromProperty(FrameworkElement.ContextMenuProperty, typeof(FrameworkElement)).AddValueChanged(AssociatedObject, UpdateContextMenu);

            UpdateEventHandlers();
            if (AssociatedObject.ContextMenu != null)
            {
                AttachedProperties.SetLastClickWasTouch(AssociatedObject, AttachedProperties.GetLastClickWasTouch(AssociatedObject.ContextMenu));
            }
        }
예제 #10
0
        protected void Refresh()
        {
            // Remove existing children and attached properties
            foreach (var child in children.DepthFirst(x => x.Children))
            {
                child.Dispose();
            }
            children.Clear();
            AttachedProperties.Clear();

            // And recompute them from the current value.
            factory.CreateChildren(this, ParentingNode, PropertyProvider);
        }
예제 #11
0
        private void AssociatedObject_PreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.OriginalSource is UIElement srcUiel)
            {
                AttachedProperties.SetLastClickWasTouch(AssociatedObject, srcUiel.AreAnyTouchesOver);

                Debug.WriteLine("AssociatedObject_PreviewMouseDown, " + AttachedProperties.GetLastClickWasTouch(AssociatedObject).ToString());
            }
            else
            {
                Debug.WriteLine("AssociatedObject_PreviewMouseDown, null");
            }
        }
예제 #12
0
        protected override Task <HttpResponseMessage> SendAsync(
            HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var id      = Interlocked.Increment(ref _messageId); //.ToString("X8");
            var context = new AttachedProperties(id);

            request.SetAttachedContext(context);
            var polly = new Context($"({request.Method}) {request.RequestUri}");

            request.SetPolicyExecutionContext(polly);

            return(base.SendAsync(request, cancellationToken));
        }
예제 #13
0
 public object GetDragDropObject(object sender, System.Windows.Input.MouseEventArgs e)
 {
     if (_element != null)
     {
         var value    = AttachedProperties.GetDragObject(_element);
         var accessor = value as Func <object>;
         if (accessor != null)
         {
             return(accessor());
         }
         return(value);
     }
     return(null);
 }
예제 #14
0
        public void MatrixExtendedWithXPropertiesYieldsRightValue()
        {
            var engine = new Engine();

            AttachedProperties.Register <Double[, ]>("x", matrix => matrix[0, 0]);
            AttachedProperties.Register <Double[, ]>("y", matrix => matrix[0, 1]);
            AttachedProperties.Register <Double[, ]>("z", matrix => matrix[0, 2]);
            var result = engine.Interpret("M = [1,2,3]; M.x + M.y + M.z");

            AttachedProperties.Unregister <Double[, ]>("x");
            AttachedProperties.Unregister <Double[, ]>("y");
            AttachedProperties.Unregister <Double[, ]>("z");
            Assert.AreEqual(6.0, result);
        }
예제 #15
0
        public void RenderCoreHasFlagsSetCorrectlyForSpecialRenderPackage()
        {
            var ws = ViewModel.Model.CurrentWorkspace as HomeWorkspaceModel;
            var mockManipulator = new DynamoGeometryModel3D()
            {
                Transform                   = MatrixTransform3D.Identity,
                Material                    = PhongMaterials.Red,
                IsHitTestVisible            = true,
                RequiresPerVertexColoration = false,
            };

            Assert.False((mockManipulator.SceneNode.RenderCore as DynamoGeometryMeshCore).dataCore.IsSpecialRenderPackageData);
            AttachedProperties.SetIsSpecialRenderPackage(mockManipulator, true);
            //assert that setting this attached property updated the meshcore data.
            Assert.IsTrue((mockManipulator.SceneNode.RenderCore as DynamoGeometryMeshCore).dataCore.IsSpecialRenderPackageData);
        }
예제 #16
0
        public void Invoke(IExecutionContext context)
        {
            var instance = context.Pop();
            var name     = context.Pop() as String;
            var obj      = instance as IDictionary <String, Object>;
            var result   = default(Object);

            if (name != null && instance != null)
            {
                if (obj == null || !obj.TryGetValue(name, out result))
                {
                    AttachedProperties.TryFind(instance, name, out result);
                }
            }

            context.Push(result);
        }
 public TransitStopIconWrapper(TransitStop stop)
 {
     if (stop.Path == null)
     {
         Element = new MapIcon()
         {
             Location = stop.Position.ToGeopoint(), NormalizedAnchorPoint = new Windows.Foundation.Point(0.5, 0.5), CollisionBehaviorDesired = MapElementCollisionBehavior.RemainVisible, ZIndex = 5
         };
     }
     else
     {
         Element = new MapPolygon()
         {
             Path = new Windows.Devices.Geolocation.Geopath(GooglePolylineConverter.Decode(stop.Path).Select(ll => ll.ToBasicGeoposition())), StrokeColor = Colors.Black, FillColor = Colors.DarkGray, StrokeThickness = 2, ZIndex = 4
         };
     }
     AttachedProperties.SetElementType(Element, "TransitStop");
     AttachedProperties.SetElementID(Element, stop.ID);
     Stop = stop;
     SetStopSize();
 }
예제 #18
0
        private static void AddToQATExecuted(object sender, ExecutedRoutedEventArgs args)
        {
            var    ribbon0 = (MyRibbon)sender;
            object model   = AttachedProperties.GetModel(ribbon0);

            if ((model is PrimaryRibbonModel primary))
            {
                if (!(MyRibbon.FindElementThatCanBeAddedToQAT((DependencyObject)(args.OriginalSource as UIElement)) is UIElement thatCanBeAddedToQat))
                {
                    return;
                }
                RibbonQuickAccessToolBarCloneEventArgs barCloneEventArgs = new RibbonQuickAccessToolBarCloneEventArgs(thatCanBeAddedToQat);
                thatCanBeAddedToQat.RaiseEvent((RoutedEventArgs)barCloneEventArgs);
                MyRibbon ribbon = RibbonControlService.GetRibbon((DependencyObject)thatCanBeAddedToQat) as MyRibbon;
                if (barCloneEventArgs.CloneInstance == null)
                {
                    return;
                }
                primary.QuickAccessToolBar.Items.Add((object)barCloneEventArgs.CloneInstance);
                args.Handled = true;
            }
        }
예제 #19
0
        private void Source_TouchDown(Object sender, TouchEventArgs e)
        {
            Debug.WriteLine("Source_TouchDown(object sender, TouchEventArgs e)");
            //TouchStarted = DateTime.Now;
            Timer touchTimer = new Timer(1);

            touchTimer.Elapsed += delegate
            {
                _targetMenu.Dispatcher.Invoke(new Action(() =>
                {
                    if (_targetMenu.IsOpen)
                    {
                        _wasOpenedWithTouch = true;
                        AttachedProperties.SetLastClickWasTouch(_targetMenu, _wasOpenedWithTouch);
                        //else if (!((e.OriginalSource as UIElement).AreAnyTouchesOver))
                        touchTimer.Stop();
                    }

                    //if (_wasOpenedWithTouch)
                }));
            };
            touchTimer.Start();
        }
예제 #20
0
        protected override void OnAttached()
        {
            _targetMenu = AssociatedObject;

            base.OnAttached();

            _targetMenu.Opened += (sneder, args) =>
            {
                //Debug.WriteLine("OpenedWithTouch: " + AttachedProperties.GetOpenedWithTouch(_targetMenu).ToString());
                //Debug.WriteLine(args.Source.GetType().FullName);
                AttachedProperties.SetLastClickWasTouch(_targetMenu, _wasOpenedWithTouch);
            };
            if (_targetMenu.IsLoaded)
            {
                Load();
            }
            else
            {
                _targetMenu.Loaded += TargetMenu_Loaded;
                //_targetMenu.Initialized += TargetMenu_Initialized;
                _targetMenu.ApplyTemplate();
                //_targetMenu.UpdateLayout();
            }
        }
예제 #21
0
        private void InputField_OnTextChanged(object sender, TextChangedEventArgs e)
        {
            var inputfield = sender as TextBox;

            AttachedProperties.SetIsEmpty(inputfield, string.IsNullOrEmpty(inputfield.Text));
        }
        /// <summary>
        /// Adds the DependencyPropertyInfo object for the given.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="typeInfo">The type info.</param>
        /// <param name="dependencyProperty">The dependency property.</param>
        /// <param name="propertyName">Name of the dependency property.</param>
        /// <param name="propertyList">The non-attached dependency property list for the given type.</param>
        private static void AddDependencyPropertyInfo(
            Type type,
            TypeInfo typeInfo,
            DependencyProperty dependencyProperty,
            string propertyName,
            ref List <DependencyPropertyInfo> propertyList)
        {
            try
            {
                bool?isAttached = null;

                // Check for plain property matching the dependency property.
                if (typeInfo.GetDeclaredProperty(propertyName) == null)
                {
                    isAttached = true;
                }
                else
                {
                    // Check for the Get method typically only specified for attached properties
                    var getMethodName = string.Format("Get{0}", propertyName);
                    var getMethod     = typeInfo.GetDeclaredMethod(getMethodName);

                    if (getMethod != null)
                    {
                        isAttached = true;
                    }
                    else
                    {
                        isAttached = false;
                    }
                }

                if (isAttached == true)
                {
                    // Attached property
                    var displayName = string.Format("{0}.{1}", type.Name, propertyName);

                    AttachedProperties.Add(
                        new DependencyPropertyInfo(
                            dependencyProperty,
                            propertyName,
                            type,
                            displayName,
                            true));
                }
                else
                {
                    // non-attached property
                    if (propertyList == null)
                    {
                        propertyList = new List <DependencyPropertyInfo>();
                        DependencyProperties.Add(type, propertyList);
                    }

                    propertyList.Add(
                        new DependencyPropertyInfo(
                            dependencyProperty,
                            propertyName,
                            type,
                            propertyName,
                            false));
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
예제 #23
0
 public void SetNewOverheadContent(ViewsEnum viewsEnum, IDataContextHolder newContent)
 {
     AttachedProperties.SetCurrentMainWindowSection(this, viewsEnum);
     OverheadContent.Content = newContent;
 }
예제 #24
0
 public static void SetAttachedContext(this HttpRequestMessage request, AttachedProperties context)
 {
     request.Properties[AttachedProperties.Key] = context;
 }