Пример #1
0
        private void RefreshLyricTime()
        {
            if (HyPlayList.lyricpos < 0 || HyPlayList.lyricpos >= LyricList.Count)
            {
                return;
            }
            if (HyPlayList.lyricpos == -1)
            {
                lastitem?.OnHind();
                LyricBoxContainer.ChangeView(null, 0, null, false);
            }
            LyricItem item = LyricList[HyPlayList.lyricpos];

            if (item == null)
            {
                return;
            }
            lastitem?.OnHind();
            item?.OnShow();
            lastitem = item;
            if (sclock > 0)
            {
                sclock--;
                return;
            }
            GeneralTransform transform = item?.TransformToVisual((UIElement)LyricBoxContainer.Content);
            Point?           position  = transform?.TransformPoint(new Point(0, 0));

            LyricBoxContainer.ChangeView(null, position?.Y - (LyricBoxContainer.ViewportHeight / 3), null, false);
        }
Пример #2
0
        /// <summary>
        /// Click handler for camera button. Spawns device picker UI
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void UICameraButton_Click(object sender, RoutedEventArgs e)
        {
            // Disable the top menu while handling the click
            await UpdateMediaSourceButtonsAsync(false);

            var devicePicker = new DevicePicker();

            devicePicker.Filter.SupportedDeviceClasses.Add(DeviceClass.VideoCapture);

            // Calculate the position to show the picker (right below the buttons)
            GeneralTransform ge = UICameraButton.TransformToVisual(null);

            Windows.Foundation.Point point = ge.TransformPoint(new Windows.Foundation.Point());
            Windows.Foundation.Rect  rect  = new Windows.Foundation.Rect(point, new Windows.Foundation.Point(point.X + UICameraButton.ActualWidth, point.Y + UICameraButton.ActualHeight));

            DeviceInformation di = await devicePicker.PickSingleDeviceAsync(rect);

            if (di != null)
            {
                try
                {
                    NotifyUser("Attaching to camera " + di.Name);
                    await ConfigureFrameSourceAsync(di, m_inputImageFeatureDescriptor);
                }
                catch (Exception ex)
                {
                    NotifyUser("Error occurred while initializating MediaCapture:\n" + ex.Message);
                }
            }

            // Re-enable the top menu once done handling the click
            await UpdateMediaSourceButtonsAsync(true);
        }
Пример #3
0
        public Rect GetElementRect(FrameworkElement element)
        {
            GeneralTransform buttonTransform = element.TransformToVisual(null);
            Point            point           = buttonTransform.TransformPoint(new Point());

            return(new Rect(point, new Size(element.ActualWidth, element.ActualHeight)));
        }
Пример #4
0
    // Appointment를 생성하는 메소드이다.
    public async void Add(Object sender, DatePicker startDate, TimePicker startTime, TextBox subject, TextBox location, TextBox details, ComboBox duration, CheckBox allDay)
    {
        FrameworkElement element   = (FrameworkElement)sender;
        GeneralTransform transform = element.TransformToVisual(null);
        Point            point     = transform.TransformPoint(new Point());
        Rect             rect      = new Rect(point, new Size(element.ActualWidth, element.ActualHeight));
        DateTimeOffset   date      = startDate.Date;
        TimeSpan         time      = startTime.Time;
        int         minutes        = int.Parse((string)((ComboBoxItem)duration.SelectedItem).Tag);
        Appointment appointment    = new Appointment()
        {
            StartTime = new DateTimeOffset(date.Year, date.Month, date.Day, time.Hours, time.Minutes, 0, TimeZoneInfo.Local.GetUtcOffset(DateTime.Now)),
            Subject   = subject.Text,
            Location  = location.Text,
            Details   = details.Text,
            Duration  = TimeSpan.FromMinutes(minutes),
            AllDay    = (bool)allDay.IsChecked
        };
        string id = await AppointmentManager.ShowAddAppointmentAsync(appointment, rect, Placement.Default);

        if (string.IsNullOrEmpty(id))
        {
            Show("Appintment not Added", app_title);
        }
        else
        {
            Show($"Appointment {id} Added", app_title);
        }
    }
Пример #5
0
        public PointerPoint GetCurrentPoint(UIElement relativeTo)
        {
            if (relativeTo == null)
            {
                //-----------------------------------
                // Return the absolute pointer coordinates:
                //-----------------------------------
                PointerPoint pointerPoint = new PointerPoint()
                {
                    Position = new Point(_pointerAbsoluteX, _pointerAbsoluteY)
                };
                return(pointerPoint);
            }
            else
            {
                //-----------------------------------
                // Returns the pointer coordinates relative to the "relativeTo" element:
                //-----------------------------------

                // Get the opposite of the absolute position of the "relativeTo" element:
                GeneralTransform generalTransform = Window.Current.TransformToVisual(relativeTo);

                // Get the pointer coordinates relative to "relativeTo" element:
                PointerPoint pointerPoint = new PointerPoint()
                {
                    Position = generalTransform.TransformPoint(new Point(_pointerAbsoluteX, _pointerAbsoluteY))
                };
                return(pointerPoint);
            }
        }
        public void Initialize(UIElement host, CompositionImage sourceElement, object payload)
        {
            _host    = host;
            _parent  = host;
            _payload = payload;

            // Make a copy of the sourceElement's sprite so we can hand it off to the next page
            SpriteVisual sourceSprite = sourceElement.SpriteVisual;
            Compositor   compositor   = sourceSprite.Compositor;

            _sprite       = compositor.CreateSpriteVisual();
            _sprite.Size  = sourceSprite.Size;
            _sprite.Brush = sourceElement.SurfaceBrush;

            // We're going to use the backing surface, make sure it doesn't get released
            sourceElement.SharedSurface = true;

            // Determine the offset from the host to the source element used in the transition
            GeneralTransform coordinate = sourceElement.TransformToVisual(_parent);
            Point            position   = coordinate.TransformPoint(new Point(0, 0));

            // Set the sprite to that offset relative to the host
            _sprite.Offset = new Vector3((float)position.X, (float)position.Y, 0);

            // Set the sprite as the content under the host
            ElementCompositionPreview.SetElementChildVisual(_parent, _sprite);
        }
Пример #7
0
        public static bool ScrollToElement(ScrollViewer sv, UIElement element)
        {
            GeneralTransform transform = element.TransformToVisual(sv);
            Point            position  = transform.TransformPoint(new Point(0, 0));

            return(sv.ChangeView(sv.HorizontalOffset, position.Y, sv.ZoomFactor));
        }
Пример #8
0
        private Rect MenuPos()
        {
            GeneralTransform transform        = TransformToVisual(null);
            Point            pointTransformed = transform.TransformPoint(new Point(0, 0));

            return(new Rect(pointTransformed.X, pointTransformed.Y, ActualWidth, ActualHeight));
        }
Пример #9
0
 private async void Sv_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
 {
     await Dispatcher.TryRunAsync(CoreDispatcherPriority.Normal, delegate
     {
         ScrollViewer sv       = sender as ScrollViewer;
         GeneralTransform gt   = sv.TransformToVisual(this);
         Point p               = gt.TransformPoint(new Point(0, 0));
         List <UIElement> list = new List <UIElement>(VisualTreeHelper.FindElementsInHostCoordinates(p, sv));
         ListViewItem item     = list.OfType <ListViewItem>().FirstOrDefault();
         if (item != null)
         {
             int index = mylist.IndexFromContainer(item);
             //Debug.WriteLine("Visible item at top of list is " + index);
             var meds = mylist.ItemsSource as GenerateHomePage <InstaMedia>;
             foreach (InstaMedia med in meds)
             {
                 if (med.Play)
                 {
                     med.Play = false;
                 }
             }
             ((InstaMedia)meds[index]).Play = true;
         }
     });
 }
        private async void pinUnpinButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (SecondaryTile.Exists(thisItem.Title))
                {
                    SecondaryTile    secondaryTile = new SecondaryTile(thisItem.Title);
                    FrameworkElement element       = (FrameworkElement)sender;
                    GeneralTransform transform     = element.TransformToVisual(null);
                    Point            point         = transform.TransformPoint(new Point());
                    Rect             rect          = new Rect(point, new Size(element.ActualWidth, element.ActualHeight));
                    await secondaryTile.RequestDeleteForSelectionAsync(rect, Placement.Above);

                    pinButton.Content = "pin";
                    thisItem.IsPinned = false;
                }
                else
                {
                    SecondaryTile secondaryTile = new SecondaryTile(
                        thisItem.Title, thisItem.Title, thisItem.Title,
                        new Uri(string.Format(CultureInfo.CurrentCulture, "ms-appx://{0}", thisItem.Photo)), TileSize.Square150x150);
                    secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;
                    await secondaryTile.RequestCreateAsync();

                    pinButton.Content = "unpin";
                    thisItem.IsPinned = true;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("SecondaryTilePage.pinUnpinButton_Click: " + ex.ToString());
            }
        }
Пример #11
0
        internal static async Task <Boolean> PinSecondaryTile(FrameworkElement _element)
        {
            string tileActivationArguments = _logoSecondaryTileId;

            Uri square150x150Logo = new Uri("ms-appx:///Assets/Square150x150Logo.scale-100.png");
            Uri wide310x150Logo   = new Uri("ms-appx:///Assets/Wide310x150Logo.scale-100.png");
            Uri square310x310Logo = new Uri("ms-appx:///Assets/Square310x310Logo.scale-100.png");

            ResourceLoader _res = ResourceLoader.GetForCurrentView();

            SecondaryTile secondaryTile =
                new SecondaryTile(_logoSecondaryTileId,
                                  "GlobeTrotter",
                                  tileActivationArguments,
                                  square150x150Logo,
                                  TileSize.Square150x150);

            secondaryTile.VisualElements.Wide310x150Logo   = wide310x150Logo;
            secondaryTile.VisualElements.Square310x310Logo = square310x310Logo;

            GeneralTransform buttonTransform = _element.TransformToVisual(null);
            Point            point           = buttonTransform.TransformPoint(new Point());
            Rect             rect            = new Rect(point, new Size(_element.ActualWidth, _element.ActualHeight));

            return(await secondaryTile.RequestCreateForSelectionAsync(rect, Placement.Above));
        }
        // 演示如何获取 UIElement 相对于另一个 UIElement 原点(左上角顶点)的位置
        private void Demo2()
        {
            GeneralTransform generalTransform = rectangle1.TransformToVisual(rectangle2);         // 获取 rectangle1 相对于 rectangle2 原点(左上角顶点)的 GeneralTransform
            Point            point            = generalTransform.TransformPoint(new Point(0, 0)); // rectangle1 的原点(左上角顶点)相对于 rectangle2 的原点(左上角顶点)的位置

            lblMsg.Text += "红色矩形的原点(左上角顶点)相对于绿色矩形的原点(左上角顶点)的位置:" + point.ToString();
        }
Пример #13
0
        public void ScrollToSectionAnimated(Hub hub, HubSection section)
        {
            GeneralTransform transform = section.TransformToVisual(hub);
            Point            point     = transform.TransformPoint(new Point(0, 0));
            ScrollViewer     viewer    = Hub.GetFirstDescendantOfType <ScrollViewer>();

            viewer.ChangeView(point.X, null, null, false);
        }
        public override void StartSelection(Windows.Foundation.Point point)
        {
            GeneralTransform gt = MainViewController.Instance.InkableScene.TransformToVisual(dxSurface);

            _selectionPoints = new List <Windows.Foundation.Point> {
                gt.TransformPoint(point)
            };
        }
Пример #15
0
        void OnSliceManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
        {
            GeneralTransform gt = (sender as Slice).TransformToVisual(_sliceCanvasDecorator);

            DisplayBalloon(sender as Slice, gt.TransformPoint(e.Position));
            //e.Handled = true;
            isSliceEvent = true;
        }
Пример #16
0
        private void Cast_Click(object sender, RoutedEventArgs e)
        {
            //Retrieve the location of the casting button
            GeneralTransform transform = (sender as MenuFlyoutItem).TransformToVisual(Window.Current.Content as UIElement);
            Point            pt        = transform.TransformPoint(new Point(0, 0));

            Context.ShowCastingUI(new Rect(pt.X, pt.Y, (sender as MenuFlyoutItem).ActualWidth, (sender as MenuFlyoutItem).ActualHeight));
        }
        // 演示如何获取 UIElement 相对于 app 原点(左上角顶点)的位置
        private void Demo1()
        {
            GeneralTransform generalTransform = rectangle1.TransformToVisual(null);               // 获取 rectangle1 相对于 app 原点(左上角顶点)的 GeneralTransform
            Point            point            = generalTransform.TransformPoint(new Point(0, 0)); // rectangle1 的原点(左上角顶点)相对于屏幕 0,0 点的位置

            lblMsg.Text += "红色矩形的原点(左上角顶点)相对于屏幕的原点(左上角顶点)的位置:" + point.ToString();
            lblMsg.Text += Environment.NewLine;
        }
 private void mainPointerManager_Added(object sender, PointerManagerEvent e)
 {
     if (e.NumActiveContacts == 1)
     {
         GeneralTransform gt = this.TransformToVisual(MainViewController.Instance.InkableScene);
         _mainPointerManagerPreviousPoint = gt.TransformPoint(e.CurrentContacts[e.TriggeringPointer.PointerId].Position);
     }
 }
Пример #19
0
        private double GetRelativeOffset()
        {
            ScrollContentPresenter scp       = MainScrollViewer.GetFirstDescendantOfType <ScrollContentPresenter>();
            FrameworkElement       content   = scp?.Content as FrameworkElement;
            GeneralTransform       transform = ScrollingTabs.TransformToVisual(content);

            return(transform.TransformPoint(new Point(0, 0)).Y - MainScrollViewer.VerticalOffset);
        }
Пример #20
0
        private Rect GetRect(object sender)
        {
            FrameworkElement element          = sender as FrameworkElement;
            GeneralTransform elementTransform = element.TransformToVisual(null);
            Point            point            = elementTransform.TransformPoint(new Point());

            return(new Rect(point, new Size(element.ActualWidth, element.ActualHeight)));
        }
Пример #21
0
        /// <summary>
        /// 调整歌词控件滚动条位置
        /// </summary>
        public void ResetLrcviewScroll()
        {
            GeneralTransform gf = FoucsLrc.LrcTb.TransformToVisual(c_lrc_items);
            Point            p  = gf.TransformPoint(new Point(0, 0));
            double           os = p.Y - (c_scrollviewer.ActualHeight / 2) + 10;

            c_scrollviewer.ChangeView(c_scrollviewer.HorizontalOffset, os, 1);
        }
Пример #22
0
        //get the bounding rect of an element relative to 0,0
        private static Rect GetElementRect(FrameworkElement element)
        {
            //get the element point to open the window at the correct point
            GeneralTransform transform = element.TransformToVisual(null);
            Point            point     = transform.TransformPoint(new Point());

            return(new Rect(point, new Size(element.ActualWidth, element.ActualHeight)));
        }
        private void SessionsPinButton_Click(object sender, RoutedEventArgs e)
        {
            FrameworkElement element         = (FrameworkElement)sender;
            GeneralTransform buttonTransform = element.TransformToVisual(null);
            Point            point           = buttonTransform.TransformPoint(new Point());
            Rect             rect            = new Rect(point, new Size(element.ActualWidth, element.ActualHeight));

            (this.DataContext as EventDetailViewModel).PinToStartCommand.Execute(rect);
        }
Пример #24
0
        private void Cast_Click(object sender, RoutedEventArgs e)
        {
            //Retrieve the location of the casting button
            GeneralTransform transform = Cast.TransformToVisual(Window.Current.Content);
            Point            pt        = transform.TransformPoint(new Point(0, 0));

            //Show the picker above our casting button
            castingPicker.Show(new Rect(pt.X, pt.Y, Cast.ActualWidth, Cast.ActualHeight), Windows.UI.Popups.Placement.Above);
        }
Пример #25
0
        private void SetDistance(Side side)
        {
            FrameworkElement ancestor;

            switch (side)
            {
            case Side.Top:
                ancestor = _topAncenstor;
                break;

            case Side.Left:
                ancestor = _leftAncenstor;
                break;

            default:
                throw new ArgumentOutOfRangeException("side");
            }

            Rect             ancestorObjectBounds   = LayoutInformation.GetLayoutSlot(ancestor);
            Rect             associatedObjectBounds = LayoutInformation.GetLayoutSlot(AssociatedObject);
            GeneralTransform transform             = AssociatedObject.TransformToVisual(ancestor);
            Point            associatedObjectPoint = transform.TransformPoint(new Point(associatedObjectBounds.X, associatedObjectBounds.Y));

            double distance;

            switch (side)
            {
            case Side.Top:
                distance = associatedObjectPoint.Y / ancestorObjectBounds.Height;
                distance = Math.Round(distance, 5);

                if (!double.IsInfinity(distance) && !double.IsNaN(distance))
                {
                    if (Math.Abs(_distanceFromTopCached - distance) > 0.0001)
                    {
                        DistanceFromTop = _distanceFromTopCached = distance;
                    }
                }
                break;

            case Side.Left:
                distance = associatedObjectPoint.X / ancestorObjectBounds.Width;
                distance = Math.Round(distance, 5);

                if (!double.IsInfinity(distance) && !double.IsNaN(distance))
                {
                    if (Math.Abs(_distanceFromLeftCached - distance) > 0.0001)
                    {
                        DistanceFromLeft = _distanceFromLeftCached = distance;
                    }
                }
                break;

            default:
                throw new ArgumentOutOfRangeException("side");
            }
        }
Пример #26
0
        public static Rect GetElementRect(FrameworkElement element, Point point)
        {
            point.X -= 70;
            point.Y += 50;
            GeneralTransform buttonTransform = element.TransformToVisual(null);

            buttonTransform.TransformPoint(point);
            return(new Rect(point, new Size(element.ActualWidth, element.ActualHeight)));
        }
Пример #27
0
        private Point GetPosition(FrameworkElement sender)
        {
            GeneralTransform transform = sender.TransformToVisual(null);
            Point            location  = transform.TransformPoint(new Point());

            location.Y = location.Y + sender.ActualHeight;

            return(location);
        }
Пример #28
0
        // 获取“打开方式”对话框的显示位置,即关联 Button 的左下角点的坐标
        private Point GetOpenWithPosition(FrameworkElement element)
        {
            GeneralTransform buttonTransform = element.TransformToVisual(null);

            Point desiredLocation = buttonTransform.TransformPoint(new Point());

            desiredLocation.Y = desiredLocation.Y + element.ActualHeight;

            return(desiredLocation);
        }
 /// <summary>
 /// Recalculates the size of the presenter to match its parent.
 /// </summary>
 /// <param name="sender">Sender</param>
 /// <param name="e">Event args</param>
 private void OnSizeChanged(object sender, SizeChangedEventArgs e)
 {
     if (_presenter != null)
     {
         ExpanderView     parent = _presenter.GetParentByType <ExpanderView>();
         GeneralTransform gt     = parent.TransformToVisual(_presenter);
         Point            childToParentCoordinates = gt.TransformPoint(new Point(0, 0));
         _presenter.Width = parent.RenderSize.Width + childToParentCoordinates.X;
     }
 }
Пример #30
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            InitDialDeivcePicker();
            // 從按下的 button 出現 picker 内容
            Button           btn       = sender as Button;
            GeneralTransform transform = btn.TransformToVisual(Window.Current.Content as UIElement);
            Point            pt        = transform.TransformPoint(new Point(0, 0));

            picker.Show(new Rect(pt.X, pt.Y, btn.ActualWidth, btn.ActualHeight), Windows.UI.Popups.Placement.Above);
        }