public TextInfo(ICanvasResourceCreator rc, String text)
 {
     
     format = RendererSettings.getInstance().getLabelFont();
     textLayout = new CanvasTextLayout(rc, text, format, 0.0f, 0.0f);
     bounds = getTextBounds();
 }
Пример #2
0
        public static bool IsFullyVisibile(this FrameworkElement element, FrameworkElement parent)
        {
            if (element == null || parent == null)
            {
                return(false);
            }

            if (element.Visibility != Visibility.Visible)
            {
                return(false);
            }

            var elementBounds   = element.TransformToVisual(parent).TransformBounds(new Foundation.Rect(0, 0, element.ActualWidth, element.ActualHeight));
            var containerBounds = new Foundation.Rect(0, 0, parent.ActualWidth, parent.ActualHeight);

            var originalElementWidth  = elementBounds.Width;
            var originalElementHeight = elementBounds.Height;

            elementBounds.Intersect(containerBounds);

            var newElementWidth  = elementBounds.Width;
            var newElementHeight = elementBounds.Height;

            return(originalElementWidth.Equals(newElementWidth) && originalElementHeight.Equals(newElementHeight));
        }
Пример #3
0
        public void When_Child_Has_Fixed_Size_Smaller_than_Parent()
        {
            var parentSize = new Windows.Foundation.Size(100, 100);
            var childSize  = new Windows.Foundation.Size(500, 500);

            var SUT = new Border()
            {
                Width  = parentSize.Width,
                Height = parentSize.Height
            };

            var child = new View()
            {
                Width  = childSize.Width,
                Height = childSize.Height
            };

            SUT.Child = child;

            SUT.Measure(new Windows.Foundation.Size(100, 100));
            var measuredSize = SUT.DesiredSize;

            SUT.Arrange(new Windows.Foundation.Rect(0, 0, 100, 100));

            Assert.AreEqual(parentSize, measuredSize, $"(parentSize:{parentSize}) != (measuredSize:{measuredSize})");
            var expectedArrange = new Windows.Foundation.Rect(0, 0, parentSize.Width, parentSize.Height);
            var layoutSlot      = LayoutInformation.GetLayoutSlot(child);

            Assert.AreEqual(expectedArrange, layoutSlot, $"(expectedArrange:{expectedArrange}) != (layoutSlot: {layoutSlot})");
        }
        private async Task SaveStrokesToBitmap(WriteableBitmap b)
        {
            Rect imgRect = new Rect(0, 0, b.PixelWidth, b.PixelHeight);
            InkStrokeContainer container = TheInkCanvas.InkPresenter.StrokeContainer;
            InkStrokeBuilder builder = new InkStrokeBuilder();

            // Unsichtbare Tinte!
            InkDrawingAttributes da = TheInkCanvas.InkPresenter.CopyDefaultDrawingAttributes();
            da.Size = new Size(0.1, 0.1);
            builder.SetDefaultDrawingAttributes(da);

            // Strich in oberer linker Ecke einfügen
            InkStroke topLeft = builder.CreateStroke(new List<Point>() {
                new Point(1, 1),
                new Point(2, 2) });
            container.AddStroke(topLeft);

            // Strich in unterer Rechter Ecke einfügen
            InkStroke bottomRight = builder.CreateStroke(new List<Point>() {
                new Point(imgRect.Width -2, imgRect.Height -2),
                new Point(imgRect.Width -1, imgRect.Height -1) });   
            container.AddStroke(bottomRight);

            // Striche in WriteableBitmap speichern
            WriteableBitmap bmp;
            using (InMemoryRandomAccessStream ims =
                new InMemoryRandomAccessStream())
            {
                await container.SaveAsync(ims);
                bmp = await new WriteableBitmap(1, 1)
                    .FromStream(ims, BitmapPixelFormat.Bgra8);
            }
            // Bilder zusammenfügen
            b.Blit(imgRect, bmp, imgRect, WriteableBitmapExtensions.BlendMode.Alpha);
        }
Пример #5
0
        public static PointCollection GetSelectionPolygon(Rect topRect, Rect bottomRect, double width, double offsetX, double lineInterval)
        {
            double lineIntervalCompensation = 0;
            if(lineInterval < 1)
            {
                lineIntervalCompensation = 1 - lineInterval;
            }
            double topRectCompensation = topRect.Height * lineIntervalCompensation;
            double bottmRectCompensation = bottomRect.Height * lineIntervalCompensation;

            var pointCollection = new PointCollection();
            if (topRect.Top < bottomRect.Top)
            {
                pointCollection.Add(new Point(offsetX, topRect.Bottom));
                pointCollection.Add(new Point(topRect.Left, topRect.Bottom));
                pointCollection.Add(new Point(topRect.Left, topRect.Top + topRectCompensation));
                pointCollection.Add(new Point(width - offsetX, topRect.Top + topRectCompensation));
                pointCollection.Add(new Point(width - offsetX, bottomRect.Top + bottmRectCompensation));
                pointCollection.Add(new Point(bottomRect.Right, bottomRect.Top + bottmRectCompensation));
                pointCollection.Add(new Point(bottomRect.Right, bottomRect.Bottom));
                pointCollection.Add(new Point(offsetX, bottomRect.Bottom));
            }
            else
            {
                pointCollection.Add(new Point(topRect.Left, topRect.Bottom));
                pointCollection.Add(new Point(topRect.Left, topRect.Top + topRectCompensation));
                pointCollection.Add(new Point(bottomRect.Right, bottomRect.Top + bottmRectCompensation));
                pointCollection.Add(new Point(bottomRect.Right, bottomRect.Bottom));
            }
            return pointCollection;
        } 
Пример #6
0
        public async static Task<bool> Delete(string appointmentId, bool ignoreExceptions = false)
        {
            var selection = new Rect(new Point(Window.Current.Bounds.Width / 2, Window.Current.Bounds.Height / 2), new Size());
            try
            {
                var success = await AppointmentManager.ShowRemoveAppointmentAsync(appointmentId, selection);
                if (success)
                {
                    RemoveAppointmentId(appointmentId);
                }

                return success;
            }
            catch (Exception)
            {
                if (!ignoreExceptions)
                {
                    throw;
                }
                else
                {
                    RemoveAppointmentId(appointmentId);
                    return true;
                }
            }
        }
Пример #7
0
        private async Task RefreshImage(CancellationToken ct, Windows.Foundation.Rect drawRect)
        {
            if (ImageSource is ImageSource imageSource && (_imageSourceChanged || imageSource.ImageData == null) && !drawRect.HasZeroArea())
            {
                try
                {
                    var image = await imageSource.Open(ct, targetWidth : (int)drawRect.Width, targetHeight : (int)drawRect.Height);

                    if (image != null || imageSource.IsImageLoadedToUiDirectly)
                    {
                        OnImageOpened();
                    }
                    else
                    {
                        OnImageFailed();
                    }
                }
                catch (Exception ex)
                {
                    this.Log().Error("RefreshImage failed", ex);
                    OnImageFailed();
                }
            }
            _onImageLoaded?.Invoke();
        }
Пример #8
0
 public async Task LoadSurfaceAsync(ICanvasResourceCreator creator, IRandomAccessStream stream)
 {
     tempSurface = await CanvasBitmap.LoadAsync(creator, stream);
     bound = tempSurface.Bounds;
     center = tempSurface.Size.ToVector2() / 2;
     blur.Source = tempSurface;
 }
Пример #9
0
        private double ScaleFactor; //Variable to hold the device scale factor (use to determine phone screen resolution)

        public Splash(SplashScreen splashscreen, Shell shell, bool loadState)
        {
            this.InitializeComponent();

            this.shell = shell;

            // Subscribe to changed size
            Window.Current.SizeChanged += new WindowSizeChangedEventHandler(Splash_OnResize);

            ScaleFactor = (double)DisplayInformation.GetForCurrentView().ResolutionScale / 100;

            splash = splashscreen;

            if (splash != null)
            {
                // Register an event handler to be executed when the splash screen has been dismissed.
                splash.Dismissed += new TypedEventHandler<SplashScreen, Object>(DismissedEventHandler);

                // Retrieve the window coordinates of the splash screen image.
                splashImageRect = splash.ImageLocation;
                PositionImage();
            }

            CheckMedDatabaseUpdateAsync();
        }
Пример #10
0
 public async static Task CreateSecondaryTileFromWebImage(string title, string id, Uri image, Rect TileProptRect, string navigateUri)
 {
     try
     {
         string filename = string.Format("{0}.png", id);
         //download thumb
         HttpClient httpClient = new HttpClient();
         var response = await httpClient.GetAsync(image);
         var imageFile = await ApplicationData.Current.LocalFolder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
         using (var fs = await imageFile.OpenAsync(FileAccessMode.ReadWrite))
         {
             using (var outStream = fs.GetOutputStreamAt(0))
             {
                 DataWriter writer = new DataWriter(outStream);
                 writer.WriteBytes(await response.Content.ReadAsByteArrayAsync());
                 await writer.StoreAsync();
                 writer.DetachStream();
                 await outStream.FlushAsync();
             }
         }
         await DarkenImageBottom(filename, filename); //in-place replacement of downloaded image
         Uri logo = new Uri(string.Format("ms-appdata:///local/{0}", filename));
         CreateSecondaryTile(title, id, logo, TileProptRect, navigateUri);
     }
     catch
     {
         //oops
     }
 }
Пример #11
0
 public MainPage()
 {
     this.InitializeComponent();
     var _settingsViewModel = (Application.Current as App).SettingsViewModel;
     _windowBounds = Window.Current.Bounds;
     SettingsPane.GetForCurrentView().CommandsRequested += MainPage_CommandsRequested;
 }
        public ExtendedSplash(SplashScreen splashscreen, bool loadState)
        {
            InitializeComponent();
            setuptitle();
            LoginVM vm = this.DataContext as LoginVM;
            STARTUP(vm);

          //  LearnMoreButton.Click += new RoutedEventHandler(LearnMoreButton_Click);
            // Listen for window resize events to reposition the extended splash screen image accordingly.
            // This is important to ensure that the extended splash screen is formatted properly in response to snapping, unsnapping, rotation, etc...
            Window.Current.SizeChanged += new WindowSizeChangedEventHandler(ExtendedSplash_OnResize);

            ScaleFactor = (double)DisplayInformation.GetForCurrentView().ResolutionScale / 100;

            splash = splashscreen;

            if (splash != null)
            {
                // Register an event handler to be executed when the splash screen has been dismissed.
                splash.Dismissed += new TypedEventHandler<SplashScreen, Object>(DismissedEventHandler);

                // Retrieve the window coordinates of the splash screen image.
                splashImageRect = splash.ImageLocation;
                PositionImage();
            }

            // Create a Frame to act as the navigation context
            rootFrame = new Frame();

            // Restore the saved session state if necessary
            RestoreStateAsync(loadState);
        }
        protected override Size ArrangeOverride(Size finalSize)
        {
            Clip = new RectangleGeometry { Rect = new Rect(0, 0, finalSize.Width, finalSize.Height) };

            double positionLeft = 0d;

            foreach (var item in Children)
            {
                if (item != null)
                {
                    Size desiredSize = item.DesiredSize;

                    if (!double.IsNaN(desiredSize.Width) && !double.IsNaN(desiredSize.Height))
                    {
                        var rect = new Rect(positionLeft, 0, desiredSize.Width, desiredSize.Height);
                        item.Arrange(rect);
                        item.RenderTransform = new TranslateTransform();
                        positionLeft += desiredSize.Width;
                    }
                }
            }

            _templateApplied = true;

            return finalSize;
        }
        protected override Size ArrangeOverride(Size arrangeSize)
        {
            var finalRect = new Rect(
                0.0,
                0.0,
                arrangeSize.Width / _columns,
                arrangeSize.Height / _rows);
            var width = finalRect.Width;
            var num2 = arrangeSize.Width - 1.0;
            finalRect.X += finalRect.Width * this.FirstColumn;

            foreach (var element in Children)
            {
                element.Arrange(finalRect);

                if (element.Visibility != Visibility.Collapsed)
                {
                    finalRect.X += width;

                    if (finalRect.X >= num2)
                    {
                        finalRect.Y += finalRect.Height;
                        finalRect.X = 0.0;
                    }
                }
            }

            return arrangeSize;
        }
Пример #15
0
        private SplashScreen splash; // Variable to hold the splash screen object.

        public Splash(SplashScreen splashscreen, bool loadState)
        {
            InitializeComponent();

            //LearnMoreButton.Click += new RoutedEventHandler(LearnMoreButton_Click);
            // Listen for window resize events to reposition the extended splash screen image accordingly.
            // This is important to ensure that the extended splash screen is formatted properly in response to snapping, unsnapping, rotation, etc...
            Window.Current.SizeChanged += new WindowSizeChangedEventHandler(ExtendedSplash_OnResize);

            splash = splashscreen;

            if (splash != null)
            {
                // Register an event handler to be executed when the splash screen has been dismissed.
                splash.Dismissed += new TypedEventHandler<SplashScreen, Object>(DismissedEventHandler);

                // Retrieve the window coordinates of the splash screen image.
                splashImageRect = splash.ImageLocation;
                PositionImage();
            }

            // Create a Frame to act as the navigation context
            rootFrame = new Frame();

            // Restore the saved session state if necessary
            RestoreStateAsync(loadState);


           // await Task.Delay(5000);
            //Waiting();

            //rootFrame.Navigate(typeof(MainPage));

            //Window.Current.Content = rootFrame;
        }
Пример #16
0
        public static void Render(Viewport viewport, Canvas canvas, IEnumerable<Tile<Image>> tiles)
        {
            if (viewport == null) return;

            canvas.Children.Clear();

            var tileList = tiles.ToList();
            for (int i = 0; i < tileList.Count; i++)
            {
                var tile = tileList[i];
                if (tile.Image == null) continue;
                var point1 = viewport.WorldToScreen(tile.Info.Extent.MinX, tile.Info.Extent.MaxY);
                var point2 = viewport.WorldToScreen(tile.Info.Extent.MaxX, tile.Info.Extent.MinY);

                var dest = new Rect(point1.ToMetroPoint(), point2.ToMetroPoint());
                dest = RoundToPixel(dest);

                Canvas.SetLeft(tile.Image, dest.X);
                Canvas.SetTop(tile.Image, dest.Y);
                tile.Image.Width = dest.Width;
                tile.Image.Height = dest.Height;
                canvas.Children.Add(tile.Image);

                if (tile.StartAnimation == default(long))
                {
                    tile.StartAnimation = DateTime.Now.Ticks;
                    Animate(tile.Image, "Opacity", 0, 1, 600, (s, e) => { });
                }
            }
        }
Пример #17
0
        public void Attach(DependencyObject associatedObject)
        {
            if ((associatedObject != AssociatedObject) && !DesignMode.DesignModeEnabled)
            {
                if (AssociatedObject != null)
                    throw new InvalidOperationException("Cannot attach behavior multiple times.");

                AssociatedObject = associatedObject;
                var control = AssociatedObject as FrameworkElement;
                if (control == null)
                {
                    throw new InvalidOperationException("Cannot attach behavior you must have Control.");
                }
                popupInputPane = InputPane.GetForCurrentView();
                popupInputPane.Showing += popupInputPane_Showing;
                popupInputPane.Hiding += popupInputPane_Hiding;
                Window.Current.SizeChanged += Current_SizeChanged;

                var popup = ((FrameworkElement) AssociatedObject).Parent as Popup;
                if (popup == null) return;
                //키보드가 보인다는 이야기
                orignalRect = new Rect
                {
                    X = popup.HorizontalOffset,
                    Y = popup.VerticalOffset,
                    Width = ((FrameworkElement) AssociatedObject).Width,
                    Height = ((FrameworkElement) AssociatedObject).Height
                };
                resizePopup();
            }
        }
Пример #18
0
        public override object GetInstance(string value, string[] formatStrings, IScalarUnmarshallingContext unmarshallingContext)
        {
            Object result = null;
            try
            {
                double x = 0, y = 0, width = 0, height = 0;
                string[] values = value.Split(' ');

                if (values.Length > 1)
                {
                    x = double.Parse(values[0]);
                    y = double.Parse(values[1]);
                }

                if (values.Length > 3)
                {
                    width = double.Parse(values[2]);
                    height = double.Parse(values[3]);
                }

                result = new Rect(x, y, width, height);
            }
            catch (ArgumentNullException e) { }
            catch (ArgumentException e) { }

            return result;
        }
Пример #19
0
        public XyAxis(Rect rect)
        {
            _rect = rect;
            _stroq = new Stroq();
            _stroq.Points.Add(new Point(rect.X, rect.Y));
            _stroq.Points.Add(new Point(rect.X, rect.Y + rect.Height));
            _stroq.Points.Add(new Point(rect.X + rect.Width,
                rect.Y + rect.Height));

            _hotspots = new Dictionary<XyAxisLabelPosition, Rect>();

            int maxDelta = 100;
            int nw = (int) _rect.Width/3;
            int nh = (int) _rect.Height/3;

            var ytop = new Rect(_rect.X - maxDelta, _rect.Y, nw, nh);
            var ycenter = new Rect(_rect.X - maxDelta, _rect.Y + nh, nw, nh);
            var ybottom = new Rect(_rect.X - maxDelta, _rect.Y + nh*2, nw, nh);

            var xleft = new Rect(_rect.X, _rect.Y + _rect.Height, nw, nh);
            var xcenter = new Rect(_rect.X + nw, _rect.Y + _rect.Height, nw, nh);
            var xright = new Rect(_rect.X + nw*2, _rect.Y + _rect.Height, nw, nh);

            _hotspots[XyAxisLabelPosition.Y_Top] = ytop;
            _hotspots[XyAxisLabelPosition.Y_Center] = ycenter;
            _hotspots[XyAxisLabelPosition.Y_Bottom] = ybottom;
            _hotspots[XyAxisLabelPosition.X_Left] = xleft;
            _hotspots[XyAxisLabelPosition.X_Center] = xcenter;
            _hotspots[XyAxisLabelPosition.X_Right] = xright;
        }
Пример #20
0
        public static bool IsItemVisible(this FrameworkElement container, FrameworkElement element)
        {
            var elementBounds = element.TransformToVisual(container).TransformBounds(new Rect(0, 0, element.ActualWidth, element.ActualHeight));
            var containerBounds = new Rect(0, 0, container.ActualWidth, container.ActualHeight);

            return (elementBounds.Top < containerBounds.Bottom && elementBounds.Bottom > containerBounds.Top);
        }
        public ExtendedSplash(SplashScreen splashscreen, bool loadState)
        {
            InitializeComponent();

            // Listen for window resize events to reposition the extended _splash screen image accordingly.
            // This is important to ensure that the extended _splash screen is formatted properly in response to snapping, unsnapping, rotation, etc...
            Window.Current.SizeChanged += new WindowSizeChangedEventHandler(ExtendedSplash_OnResize);

            _splash = splashscreen;

            if (_splash != null)
            {
                // Register an event handler to be executed when the _splash screen has been Dismissed.
                _splash.Dismissed += DismissedEventHandler;

                // Retrieve the window coordinates of the _splash screen image.
                SplashImageRect = _splash.ImageLocation;
                PositionImage();

                // Optional: Add a progress ring to your _splash screen to show users that content is loading
                PositionRing();
            }

            // Create a Frame to act as the navigation context
            RootFrame = new Frame();

            // Restore the saved session state if necessary
            Task.Run(async () => await RestoreStateAsync(loadState));
        }
 public ImageInfo(CanvasRenderTarget image, Point offset, Rect symbolBounds, Rect imageBounds)
 {
     _crt = image;
     _offset = offset;
     _symbolBounds = symbolBounds;
     _imageBounds = imageBounds;
 }
Пример #23
0
            public void Reset()
            {
                Children.Clear();
                InvalidateArrange();
                content = null;
                contentsCenter = new Rect(0, 0, 1, 1);
                contentGravity = ContentGravity.Resize;
                Clip = null;
                InvOriginTransform = new TranslateTransform();
                ClipGeometry = new RectangleGeometry();
                ClipGeometry.Transform = InvOriginTransform;
                RenderTransform = new TranslateTransform();
                _position = new Point(0, 0);
                _origin = new Point(0, 0);
                _size = new Size(0, 0);
                _hidden = false;
                originSet = false;
                _createdTransforms = false;
                LayerOpacity = 1.0;
                backgroundBrush = TransparentBrush;
                backgroundColor.R = 0;
                backgroundColor.G = 0;
                backgroundColor.B = 0;
                backgroundColor.A = 0;

                Set("anchorPoint", new Point(0.5, 0.5));
                _masksToBounds = false;

                this.Background = TransparentBrush;
            }
Пример #24
0
        //public LoginPageViewModel vm { get; private set; }
        public LoginPage()
        {
            this.InitializeComponent();
            DataContextChanged += LoginPage_DataContextChanged;
            _toRegSb = new Storyboard();
            Duration duration = new Duration(TimeSpan.FromSeconds(0.2));
            _logspda = new DoubleAnimation()
            {
                From = 0,
                To = -FrameWidth,
                AutoReverse = false,
                Duration = duration
            };
            _regspda = new DoubleAnimation()
            {
                From = FrameWidth,
                To = 0,
                AutoReverse = false,
                Duration = duration
            };
            Storyboard.SetTargetProperty(_regspda, "(UIElement.RenderTransform).(CompositeTransform.TranslateX)");
            Storyboard.SetTargetProperty(_logspda, "(UIElement.RenderTransform).(CompositeTransform.TranslateX)");
            Storyboard.SetTarget(_logspda, logSP);
            Storyboard.SetTarget(_regspda, regSP);

            _toRegSb.Children.Add(_regspda);
            _toRegSb.Children.Add(_logspda);

            Rect rect = new Rect(0, 0, FrameWidth, 300);
            RectangleGeometry reo = new RectangleGeometry();
            reo.Rect = rect;
            this.infoBorder.Clip = reo;
        }
Пример #25
0
        public ExtendedSplash(SplashScreen splashscreen, bool loadState)
        {
            InitializeComponent();

            // Listen for window resize events to reposition the extended splash screen image accordingly.
            // This is important to ensure that the extended splash screen is formatted properly in response to snapping, unsnapping, rotation, etc...
            Window.Current.SizeChanged += new WindowSizeChangedEventHandler(ExtendedSplash_OnResize);

            splash = splashscreen;

            if (splash != null)
            {
                // Register an event handler to be executed when the splash screen has been dismissed.
                splash.Dismissed += new TypedEventHandler<SplashScreen, Object>(DismissedEventHandler);

                // Retrieve the window coordinates of the splash screen image.
                splashImageRect = splash.ImageLocation;
                PositionImage();

                PositionRing();
            }

            // Create a Frame to act as the navigation context
            rootFrame = new Frame();

            RestoreStateAsync(true).Wait();
        }
Пример #26
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            double offset = 0;
            var finalRect = new Rect(0, 0, 0, finalSize.Height);

            var childrenList = Children.OrderBy(GetPanelIndex);

            _childrenPositions.Clear();
            foreach (FrameworkElement child in childrenList)
            {
                finalRect.X = offset;
                _childrenPositions.Add(new SlideViewPanelItemOffset(child, offset));

                finalRect.Width = child.Width > 0 ? child.DesiredSize.Width : _viewportWidth;
                if (finalRect.Width <= 0)
                    finalRect.Width = _viewportWidth;

                child.Arrange(finalRect);

                offset += finalRect.Width;
            }

            finalSize.Width = _totalWidth = offset;

            // Constraint the different panel positions
            foreach (var childPosition in _childrenPositions)
            {
                childPosition.OffsetX = Math.Min(_totalWidth - _viewportWidth, childPosition.OffsetX);
            }

            return finalSize;
        }
        public ExtendedSplashPage(SplashScreen splashscreen, bool loadState) {
            this.InitializeComponent();
            // Listen for window resize events to reposition the extended splash screen image accordingly.
            // This ensures that the extended splash screen formats properly in response to window resizing.
            Window.Current.SizeChanged += new WindowSizeChangedEventHandler(ExtendedSplash_OnResize);
            
            // Is this a phone? Then set the scaling factor
            if (String.Equals(AnalyticsInfo.VersionInfo.DeviceFamily, "Windows.Mobile")) {
                scaleFactor = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;
            }
            
            splash = splashscreen;
            if (splash != null) {
                // Register an event handler to be executed when the splash screen has been dismissed.
                splash.Dismissed += new TypedEventHandler<SplashScreen, Object>(DismissedEventHandler);

                // Retrieve the window coordinates of the splash screen image.
                splashImageRect = splash.ImageLocation;
                PositionImage();

                // If applicable, include a method for positioning a progress control.
                PositionRing();
            }

            // Create a Frame to act as the navigation context 
            rootFrame = new Frame();

            // Restore the saved session state if necessary
            RestoreStateAsync(loadState);

        }
Пример #28
0
 private static bool RectsOverlap(Rect r1, Rect r2)
 {
     r1.Intersect(r2);
     if (r1.Width > 0 || r1.Height > 0)
         return true;
     return false;
 }
        public ExtendedSplashScreen(SplashScreen splashscreen)
        {
            InitializeComponent();

            // Listen for window resize events to reposition the extended splash screen image accordingly.
            // This ensures that the extended splash screen formats properly in response to window resizing.
            Window.Current.SizeChanged += ExtendedSplash_OnResize;

            _splash = splashscreen;
            if (_splash != null)
            {
                // Register an event handler to be executed when the splash screen has been dismissed.
                _splash.Dismissed += DismissedEventHandler;

                // Retrieve the window coordinates of the splash screen image.
                _splashImageRect = _splash.ImageLocation;
                PositionImage();

                // If applicable, include a method for positioning a progress control.
                PositionRing();
            }

            // Create a Frame to act as the navigation context
            _rootFrame = new Frame();

            this.Loaded += async (sender, args) => { await this.AppBootstrapper(); };
        }
Пример #30
0
        private static void MergePixels(byte[] pixels1, int width, byte[] pixels2, Rect rect)
        {
            try
            {
                int x0 = (int)rect.X;
                int y0 = (int)rect.Y;
                int stride = (int)rect.Width;

                for (int y = 0; y < rect.Height; y++)
                {
                    for (int x = 0; x < rect.Width; x++)
                    {
                        int index1 = (x0 + x + (y0 + y) * width) * 4;
                        int index2 = (x + y * stride) * 4;
                        if (pixels2[index2 + 3] > 0)
                        {
                            pixels1[index1 + 0] = pixels2[index2 + 0];
                            pixels1[index1 + 1] = pixels2[index2 + 1];
                            pixels1[index1 + 2] = pixels2[index2 + 2];
                            pixels1[index1 + 3] = pixels2[index2 + 3];
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("MergePixels. {0}", ex.Message);
            }
        }
Пример #31
0
        void DrawDrawingSurface()
        {
            ++drawCount;

            using (var ds = CanvasComposition.CreateDrawingSession(drawingSurface))
            {
                ds.Clear(Colors.Transparent);

                var rect = new Rect(new Point(2, 2), (drawingSurface.Size.ToVector2() - new Vector2(4, 4)).ToSize());

                ds.FillRoundedRectangle(rect, 15, 15, Colors.LightBlue);
                ds.DrawRoundedRectangle(rect, 15, 15, Colors.Gray, 2);

                ds.DrawText("This is a composition drawing surface", rect, Colors.Black, new CanvasTextFormat()
                {
                    FontFamily = "Comic Sans MS",
                    FontSize = 32,
                    WordWrapping = CanvasWordWrapping.WholeWord,
                    VerticalAlignment = CanvasVerticalAlignment.Center,
                    HorizontalAlignment = CanvasHorizontalAlignment.Center
                });

                ds.DrawText("Draws: " + drawCount, rect, Colors.Black, new CanvasTextFormat()
                {
                    FontSize = 10,
                    VerticalAlignment = CanvasVerticalAlignment.Bottom,
                    HorizontalAlignment = CanvasHorizontalAlignment.Center
                });
            }
        }
Пример #32
0
        public async static Task<string> Add(Appointment appt, Rect selection)
        {
            var id = await AppointmentManager.ShowAddAppointmentAsync(appt, selection, Placement.Default);
            AddAppointmentId(id);

            return id;
        }
        private void DrawRegion(CanvasVirtualImageSource sender, Rect region)
        {
            var tryPanningOrZoomingLayout = new CanvasTextLayout(sender.Device, "Try panning or zooming.", format, 500, 0);

            var infoLayout = new CanvasTextLayout(sender.Device,
                "In this demo, each time a region is updated, it is cleared to a different background color.  " +
                "This is to make it possible to see which regions get redrawn.",
                format, 500, 0);

            var youMadeIt = new CanvasTextLayout(sender.Device,
                "You made it to the end!", endFormat, 1000, 0);

            using (var ds = sender.CreateDrawingSession(NextColor(), region))
            {
                var left = ((int)(region.X / gridSize) - 1) * gridSize;
                var top = ((int)(region.Y / gridSize) - 1) * gridSize;
                var right = ((int)((region.X + region.Width) / gridSize) + 1) * gridSize;
                var bottom = ((int)((region.Y + region.Height) / gridSize) + 1) * gridSize;

                for (var x = left; x <= right; x += gridSize)
                {
                    for (var y = top; y <= bottom; y += gridSize)
                    {
                        var pos = new Vector2((float)x, (float)y);
                        ds.DrawCircle(pos, 10, Colors.White);

                        ds.DrawText(string.Format("{0}\n{1}", x, y), pos, Colors.DarkBlue, coordFormat);
                    }
                }

                DrawTextWithBackground(ds, tryPanningOrZoomingLayout, gridSize / 2, gridSize / 2);
                DrawTextWithBackground(ds, infoLayout, gridSize * 3.5, gridSize * 5.5);
                DrawTextWithBackground(ds, youMadeIt, width - youMadeIt.RequestedSize.Width, height - youMadeIt.RequestedSize.Height);
            }
        }
 private void OnResize()
 {
     if (splash != null)
     {
         splashImageRect = splash.ImageLocation;
         PositionImage();
     }
 }
Пример #35
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Dt.Cells.Data.GcPageRectangles" /> class.
 /// </summary>
 public GcPageRectangles()
 {
     this.contentRectangle    = Windows.Foundation.Rect.Empty;
     this.cropRectangle       = Windows.Foundation.Rect.Empty;
     this.pageHeaderRectangle = Windows.Foundation.Rect.Empty;
     this.pageFooterRectangle = Windows.Foundation.Rect.Empty;
     this.pageRectangle       = Windows.Foundation.Rect.Empty;
 }
Пример #36
0
 internal Windows.Foundation.Rect TransFormRect(Windows.Foundation.Rect rect, Windows.Foundation.Size availableSize)
 {
     Windows.Foundation.Rect rect2 = rect;
     if (this.SparklineInfo.Setting.RightToLeft)
     {
         rect2.X = (availableSize.Width - rect2.X) - rect2.Width;
     }
     return(rect2);
 }
Пример #37
0
 public static Rect PhysicalToLogicalPixels(this Rect size)
 {
     return(new Rect(
                size.X / Scale,
                size.Y / Scale,
                size.Width / Scale,
                size.Height / Scale
                ));
 }
Пример #38
0
 public static Rect LogicalToPhysicalPixels(this Rect size)
 {
     return(new Rect(
                LogicalToPhysicalPixels(size.X),
                LogicalToPhysicalPixels(size.Y),
                LogicalToPhysicalPixels(size.Width),
                LogicalToPhysicalPixels(size.Height)
                ));
 }
Пример #39
0
        private Android.Graphics.Path GetPath(Rect availableSize)
        {
            var output = new Android.Graphics.Path();

            output.AddOval(
                availableSize.ToRectF(),
                Android.Graphics.Path.Direction.Cw);

            return(output);
        }
Пример #40
0
        internal void SetFramePriorArrange(Rect frame /* a.k.a 'finalRect' */, Rect physicalFrame)
        {
            var physicalWidth  = ViewHelper.LogicalToPhysicalPixels(frame.Width);
            var physicalHeight = ViewHelper.LogicalToPhysicalPixels(frame.Height);

            TransientArrangeFinalRect = frame;
            FrameRoundingAdjustment   = new Size(
                (int)physicalFrame.Width - physicalWidth,
                (int)physicalFrame.Height - physicalHeight);
        }
Пример #41
0
 protected override void OnRender(swm.DrawingContext dc)
 {
     base.OnRender(dc);
     if (!Handler.tiled)
     {
         var rect     = new wf.Rect(0, 0, ActualWidth, ActualHeight);
         var graphics = new Graphics(Handler.Widget.Generator, new GraphicsHandler(this, dc, rect, false));
         Handler.Widget.OnPaint(new PaintEventArgs(graphics, rect.ToEto()));
     }
 }
Пример #42
0
        private async void RefreshImageAsync(Windows.Foundation.Rect drawRect)
        {
            CoreDispatcher.CheckThreadAccess();

            var cd = new CancellationDisposable();

            _refreshPaint.Disposable = cd;

            await RefreshImage(cd.Token, drawRect);
        }
Пример #43
0
        /// <summary>
        /// Loads the ImageBrush's source bitmap and transforms it based on target bounds and shape, Stretch mode, and RelativeTransform.
        /// </summary>
        /// <param name="drawRect">The destination bounds</param>
        /// <param name="maskingPath">An optional path to clip the bitmap by (eg an ellipse)</param>
        /// <returns>A bitmap transformed based on target bounds and shape, Stretch mode, and RelativeTransform</returns>
        internal async Task <Bitmap> GetBitmap(CancellationToken ct, Windows.Foundation.Rect drawRect, Path maskingPath = null)
        {
            await RefreshImage(ct, drawRect);

            if (ct.IsCancellationRequested)
            {
                return(null);
            }
            return(GetTransformedBitmap(drawRect, maskingPath));
        }
Пример #44
0
 /// <summary>
 /// Gets the block.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <returns></returns>
 internal virtual GcBlock GetBlock(GcReportContext context)
 {
     Windows.Foundation.Size actualSize = this.GetActualSize(context);
     if (this.RotationAngle != 0.0)
     {
         Windows.Foundation.Rect rect = Shape.GetRotatedBounds(0.0, 0.0, actualSize.Width, actualSize.Height, this.RotationAngle, actualSize.Width / 2.0, actualSize.Height / 2.0);
         actualSize = new Windows.Foundation.Size(rect.Width, rect.Height);
     }
     return(new GcBlock((double)this.X, (double)this.Y, actualSize.Width, actualSize.Height, this));
 }
Пример #45
0
        CanvasGeometry StretchGeometry()
        {
            if (baseGeometry == null)
            {
                return(null);
            }

            if (elementSize.Width == 0 || elementSize.Height == 0)
            {
                return(null);
            }

            Matrix3x2 matrix = Matrix3x2.Identity;

            // Get bounds of this control reduced by stroke thickness.
            winFound.Rect ctrlBounds = new winFound.Rect(strokeWidth / 2,
                                                         strokeWidth / 2,
                                                         Math.Max(0, elementSize.Width - strokeWidth),
                                                         Math.Max(0, elementSize.Height - strokeWidth));

            // Calculate scaling factors
            float widthScale  = (float)(ctrlBounds.Width / geometryBounds.Width);
            float heightScale = (float)(ctrlBounds.Height / geometryBounds.Height);

            switch (stretch)
            {
            case Stretch.None:
                break;

            case Stretch.Fill:
                matrix = Matrix3x2.Multiply(Matrix3x2.CreateScale(widthScale, heightScale),
                                            Matrix3x2.CreateTranslation((float)(ctrlBounds.Left - widthScale * geometryBounds.Left),
                                                                        (float)(ctrlBounds.Top - heightScale * geometryBounds.Top)));
                break;

            case Stretch.Uniform:
                float minScale = Math.Min(widthScale, heightScale);
                matrix = Matrix3x2.Multiply(Matrix3x2.CreateScale(minScale, minScale),
                                            Matrix3x2.CreateTranslation((float)(ctrlBounds.Left - minScale * geometryBounds.Left +
                                                                                (ctrlBounds.Width - minScale * geometryBounds.Width) / 2),
                                                                        (float)(ctrlBounds.Top - minScale * geometryBounds.Top +
                                                                                (ctrlBounds.Height - minScale * geometryBounds.Height) / 2)));
                break;

            case Stretch.UniformToFill:
                float maxScale = Math.Max(widthScale, heightScale);
                matrix = Matrix3x2.Multiply(Matrix3x2.CreateScale(maxScale, maxScale),
                                            Matrix3x2.CreateTranslation((float)(ctrlBounds.Left - maxScale * geometryBounds.Left),
                                                                        (float)(ctrlBounds.Top - maxScale * geometryBounds.Top)));
                break;
            }

            return(baseGeometry.Transform(matrix));
        }
        public static bool IntersectsWith(this Rect rect1, Rect rect2)
        {
            if (rect1.IsEmpty || rect2.IsEmpty)
            {
                return(false);
            }

            return((rect1.Left <= rect2.Right) &&
                   (rect1.Right >= rect2.Left) &&
                   (rect1.Top <= rect2.Bottom) &&
                   (rect1.Bottom >= rect2.Top));
        }
Пример #47
0
 /// <summary>
 /// Gets the rectangle.
 /// </summary>
 /// <returns></returns>
 public Windows.Foundation.Rect GetRect()
 {
     this.CheckRects();
     Windows.Foundation.Rect empty = Windows.Foundation.Rect.Empty;
     empty.Union(this.cellRect);
     empty.Union(this.headerRect);
     empty.Union(this.frozenRect);
     empty.Union(this.repeatRect);
     empty.Union(this.frozenTrailingRect);
     empty.Union(this.footerRect);
     return(empty);
 }
Пример #48
0
 // Used for both baseGeometry and stretchedGeometry
 void ComputeGeometryBounds(CanvasGeometry geometry, ref winFound.Rect geometryBounds, ref winFound.Rect geometryStrokeBounds)
 {
     if (geometry != null)
     {
         geometryBounds       = geometry.ComputeBounds();
         geometryStrokeBounds = geometry.ComputeStrokeBounds(strokeWidth, strokeStyle);
     }
     else
     {
         geometryBounds       = new winFound.Rect();
         geometryStrokeBounds = new winFound.Rect();
     }
 }
        public static Windows.Foundation.Rect GetWindowRectXY(IntPtr hWnd)
        {
            RECT r;

            GetWindowRect(new HandleRef(new Object(), hWnd), out r);

            Windows.Foundation.Rect myRect = new Windows.Foundation.Rect();
            myRect.X      = r.Left;
            myRect.Y      = r.Top;
            myRect.Width  = r.Right - r.Left;
            myRect.Height = r.Bottom - r.Top;
            return(myRect);
        }
Пример #50
0
 /// <summary>
 /// Create a playable Hero character.
 /// </summary>
 /// <param name="name">The name of the hero character</param>
 public Hero(string name)
     : base(name)
 {
     //hero's speed and initial direction
     Velocity      = (float)(15.0 / 60.0);
     DirectionY    = 0;
     DirectionX    = 0;
     ArrowRange    = 100;
     ArrowDamage   = 100.0f;
     MaxHealth     = 500.0f;
     CurrentHealth = MaxHealth;
     HealthBar     = new Windows.Foundation.Rect(Location.X - 10, Location.Y - 10, 50, 5);
 }
Пример #51
0
        /// <summary>
        /// Gets the data point position.
        /// </summary>
        /// <param name="index">The index.</param>
        /// <param name="availableSize">The available size.</param>
        /// <returns></returns>
        public virtual Windows.Foundation.Rect GetDataPointPosition(int index, Windows.Foundation.Size availableSize)
        {
            double itemWidth = this.GetItemWidth(availableSize);
            double itemX     = this.GetItemX(availableSize, index);

            if (itemWidth < 0.0)
            {
                itemWidth = 0.0;
            }
            itemWidth = Math.Floor(itemWidth);
            if ((itemWidth % 2.0) == 1.0)
            {
                itemWidth++;
            }
            double itemHeight     = this.GetItemHeight(availableSize, index);
            double axisY          = this.GetAxisY(availableSize);
            double actualMaxValue = this.GetActualMaxValue();
            double actualMinValue = this.GetActualMinValue();
            double y = 0.0;

            if ((actualMaxValue < 0.0) && (actualMinValue < 0.0))
            {
                y = Math.Max(this.TopSpace, axisY);
            }
            else
            {
                y = axisY;
                if (itemHeight >= 0.0)
                {
                    y = axisY - itemHeight;
                }
            }
            double itemVisibleHeight = this.GetItemVisibleHeight(availableSize, index);

            Windows.Foundation.Rect rect = new Windows.Foundation.Rect(itemX, y, itemWidth, Math.Abs(itemVisibleHeight));
            if (itemHeight != 0.0)
            {
                if ((rect.Y < this.TopSpace) && (rect.Bottom < (this.TopSpace + 1.0)))
                {
                    rect.Height = Math.Floor((double)(rect.Height + 1.0));
                    return(rect);
                }
                double num9 = availableSize.Height - this.BottomSpace;
                if ((rect.Bottom > num9) && (rect.Y > (num9 - 1.0)))
                {
                    rect.Y--;
                    rect.Height++;
                }
            }
            return(rect);
        }
        /// <summary>
        /// Creates a Visual using the specific color and constraints
        /// </summary>
        private SpriteVisual CreateVisualWithColorAndPosition(Windows.UI.Color color,
                                                              Windows.Foundation.Rect finalBounds)
        {
            var offset = new Vector3((float)finalBounds.Right, (float)finalBounds.Top, 0f);
            var size   = new Vector2((float)finalBounds.Width, (float)finalBounds.Height);

            SpriteVisual coloredRectangle = _compositor.CreateSpriteVisual();

            coloredRectangle.Brush  = _compositor.CreateColorBrush(color);
            coloredRectangle.Offset = offset;
            coloredRectangle.Size   = size;

            return(coloredRectangle);
        }
Пример #53
0
        public static Rect Transform(this Rect rectangle, Matrix matrix)
        {
            Point leftTop     = matrix.Transform(new Point(rectangle.Left, rectangle.Top));
            Point rightTop    = matrix.Transform(new Point(rectangle.Right, rectangle.Top));
            Point leftBottom  = matrix.Transform(new Point(rectangle.Left, rectangle.Bottom));
            Point rightBottom = matrix.Transform(new Point(rectangle.Right, rectangle.Bottom));

            double left   = Math.Min(Math.Min(leftTop.X, rightTop.X), Math.Min(leftBottom.X, rightBottom.X));
            double top    = Math.Min(Math.Min(leftTop.Y, rightTop.Y), Math.Min(leftBottom.Y, rightBottom.Y));
            double right  = Math.Max(Math.Max(leftTop.X, rightTop.X), Math.Max(leftBottom.X, rightBottom.X));
            double bottom = Math.Max(Math.Max(leftTop.Y, rightTop.Y), Math.Max(leftBottom.Y, rightBottom.Y));

            return(new(left, top, right - left, bottom - top));
        }
Пример #54
0
        /// <summary>
        /// Transforms ImageBrush's source bitmap based on target bounds and shape, Stretch mode, and RelativeTransform.
        /// </summary>
        /// <param name="drawRect">The destination bounds</param>
        /// <param name="maskingPath">An optional path to clip the bitmap by (eg an ellipse)</param>
        /// <returns></returns>
        private Bitmap GetTransformedBitmap(Windows.Foundation.Rect drawRect, Path maskingPath = null)
        {
            var sourceBitmap = ImageSource?.ImageData;

            if (sourceBitmap == null)
            {
                return(null);
            }

            if (sourceBitmap.Handle == IntPtr.Zero || sourceBitmap.IsRecycled)
            {
                if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Error))
                {
                    this.Log().Error("Attempted to use a collected or recycled bitmap.");
                }
                return(null);
            }

            var outputBitmap = Bitmap.CreateBitmap((int)drawRect.Width, (int)drawRect.Height, Android.Graphics.Bitmap.Config.Argb8888);

            //and a temporary canvas that will draw into the bitmap
            using (var bitmapCanvas = new Canvas(outputBitmap))
            {
                var matrix = GenerateMatrix(drawRect, sourceBitmap);
                var paint  = new Paint()
                {
                    //Smoothes edges of painted area
                    AntiAlias = true,
                    //Applies bilinear sampling (smoothing) to interior of painted area
                    FilterBitmap = true,
                    //The color is not important, we just want an alpha of 100%
                    Color = Colors.White
                };

                //Draw ImageBrush's bitmap to temporary canvas
                bitmapCanvas.DrawBitmap(sourceBitmap, matrix, paint);

                //If a path was supplied, mask the area outside of it
                if (maskingPath != null)
                {
                    //This will draw an alpha of 0 everywhere *outside* the supplied path, leaving the bitmap within the path http://developer.android.com/reference/android/graphics/PorterDuff.Mode.html
                    paint.SetXfermode(new PorterDuffXfermode(PorterDuff.Mode.DstOut));
                    maskingPath.ToggleInverseFillType();
                    bitmapCanvas.DrawPath(maskingPath, paint);
                    maskingPath.ToggleInverseFillType();
                }
                return(outputBitmap);
            }
        }
Пример #55
0
        private void treePivot_SelectionChanged(object sender, SelectionChangedEventArgs e)

        {
            var beforeheader      = sender as Pivot;
            var rightBeforeHeader = beforeheader.SelectedItem as PivotItem;

            var header = rightBeforeHeader.Header as StackPanel;

            var headerPosition = header.TransformToVisual(UICanvas).TransformPoint(new Windows.Foundation.Point(0d, 0d));


            var initialBounds = new Windows.Foundation.Rect()
            {
                Width  = header.RenderSize.Width,
                Height = header.RenderSize.Height,
                X      = headerPosition.X,
                Y      = headerPosition.Y
            };

            var finalBounds = Window.Current.Bounds;  // maps to the bounds of the current window

            //The code is super easy to understand if you set a break point here and
            //check to see what happens step by step ;)
            transition.Start((Windows.UI.Color)_colorsByPivotItem[header.Name],  // the color for the circlular bloom
                             initialBounds,                                      // the initial size and position
                             finalBounds);                                       // the area to fill over the animation duration

            // Add item to queue of transitions

            var pivotItem = (PivotItem)mainPivot.Items.Single(i => ((StackPanel)((PivotItem)i).Header).Name.Equals(header.Name));

            pendingTransitions.Enqueue(pivotItem);

            //This code deals with a bug that occurs when you go navigate to a new page then come back to this one.
            if (carefulPlz == true)
            {
                var item         = pendingTransitions.Dequeue();
                var headerFinish = item;
                UICanvas.Background = new SolidColorBrush((Windows.UI.Color)_colorsByPivotItem[headerFinish.Name]);
                carefulPlz          = false;
            }
            // Make the content visible immediately, when first clicked. Subsequent clicks will be handled by Pivot Control
            var content = (FrameworkElement)pivotItem.Content;

            if (content.Visibility == Visibility.Collapsed)
            {
                content.Visibility = Visibility.Visible;
            }
        }
Пример #56
0
        public void SetGradientPoints(winFound.Rect bounds)
        {
            CanvasLinearGradientBrush brush = Brush as CanvasLinearGradientBrush;

            if (brush == null)
            {
                return;
            }

            brush.StartPoint = new Vector2((float)(bounds.Left + StartPoint.X * bounds.Width),
                                           (float)(bounds.Top + StartPoint.Y * bounds.Height));

            brush.EndPoint = new Vector2((float)(bounds.Left + EndPoint.X * bounds.Width),
                                         (float)(bounds.Top + EndPoint.Y * bounds.Height));
        }
Пример #57
0
        internal override void Paint(Graphics gs, Windows.Foundation.Size avilableSize)
        {
            List <Windows.UI.Xaml.Shapes.Line> lines = this.GetLines(avilableSize);

            if (lines != null)
            {
                using (List <Windows.UI.Xaml.Shapes.Line> .Enumerator enumerator = lines.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Windows.UI.Xaml.Shapes.Line item = enumerator.Current;
                        base.TransFormLine(item, avilableSize);
                        double num1   = item.X1;
                        double num3   = item.Y1;
                        double width  = Math.Abs((double)(item.X2 - item.X1));
                        double height = Math.Abs((double)(item.Y2 - item.Y1));
                        if ((width >= 0.0) && (height >= 0.0))
                        {
                            gs.SaveState();
                            gs.MoveTo(new Windows.Foundation.Point(item.X1, item.Y1));
                            gs.LineTo(new Windows.Foundation.Point(item.X2, item.Y2));
                            gs.ApplyFillEffect(item.Stroke, new Windows.Foundation.Rect(item.X1, item.Y1, width, height), true, false);
                            gs.SetLineWidth(item.StrokeThickness);
                            gs.Stroke();
                            gs.RestoreState();
                        }
                    }
                }
            }
            List <DrawRectInfo> drawRects = base.GetDrawRects(avilableSize);

            if (drawRects != null)
            {
                foreach (DrawRectInfo info in drawRects)
                {
                    if (((info.brush != null) && (info.rect.Height > 0.0)) && (info.rect.Height > 0.0))
                    {
                        gs.SaveState();
                        Windows.Foundation.Rect rect = base.TransFormRect(info.rect, avilableSize);
                        gs.Translate(rect.Left + (rect.Width / 2.0), rect.Top + (rect.Height / 2.0));
                        gs.Rotate(-45.0);
                        rect = new Windows.Foundation.Rect(-rect.Width / 2.0, -rect.Height / 2.0, rect.Width, rect.Height);
                        gs.FillRectangle(rect, info.brush);
                        gs.RestoreState();
                    }
                }
            }
        }
Пример #58
0
        private void header_Click(object sender, RoutedEventArgs e)
        {
            var header = sender as AppBarButton;

            var headerPosition = header.TransformToVisual(UICanvas).TransformPoint(new Windows.Foundation.Point(0d, 0d));


            //Uses values of the rectangle size as the size of the "header" (Initially
            //I wanted it to use the pivot's size but I couldn't get it to work.
            //Would be awesome if someonebody found a way to make it work...
            //UPDATE: I Made it Work!
            var initialBounds = new Windows.Foundation.Rect()
            {
                Width  = header.RenderSize.Width,
                Height = header.RenderSize.Height,
                X      = headerPosition.X,
                Y      = headerPosition.Y
            };

            var finalBounds = Window.Current.Bounds;  // maps to the bounds of the current window

            //The code is super easy to understand if you set a break point here and
            //check to see what happens step by step ;)
            transition.Start((Windows.UI.Color)_colorsByPivotItem[header.Name],  // the color for the circlular bloom
                             initialBounds,                                      // the initial size and position
                             finalBounds);                                       // the area to fill over the animation duration

            // Add item to queue of transitions
            var pivotItem = (PivotItem)mainPivot.Items.Single(i => ((AppBarButton)((PivotItem)i).Header).Name.Equals(header.Name));

            pendingTransitions.Enqueue(pivotItem);

            //This code deals with a bug that occurs when you go navigate to a new page then come back to this one.
            if (carefulPlz == true)
            {
                var item         = pendingTransitions.Dequeue();
                var headerFinish = item;
                UICanvas.Background = new SolidColorBrush((Windows.UI.Color)_colorsByPivotItem[headerFinish.Name]);
                carefulPlz          = false;
            }
            // Make the content visible immediately, when first clicked. Subsequent clicks will be handled by Pivot Control
            var content = (FrameworkElement)pivotItem.Content;

            if (content.Visibility == Visibility.Collapsed)
            {
                content.Visibility = Visibility.Visible;
            }
        }
Пример #59
0
        /// <summary>
        /// Gets the outside cell range.
        /// </summary>
        /// <returns></returns>
        public CellRange GetOutsideCellRage()
        {
            Windows.Foundation.Rect empty      = Windows.Foundation.Rect.Empty;
            IEnumerator             enumerator = this.GetEnumerator(-1, -1, -1, -1);

            while (enumerator.MoveNext())
            {
                CellRange current = (CellRange)enumerator.Current;
                empty = Utilities.Union(empty, new Windows.Foundation.Rect((double)current.Column, (double)current.Row, (double)current.ColumnCount, (double)current.RowCount));
            }
            if (!empty.IsEmpty)
            {
                return(new CellRange((int)empty.Y, (int)empty.X, (int)empty.Height, (int)empty.Width));
            }
            return(null);
        }
Пример #60
0
        public static Rect LogicalToPhysicalPixels(this Rect size)
        {
            var physicalBottom = LogicalToPhysicalPixels(size.Bottom);
            var physicalRight  = LogicalToPhysicalPixels(size.Right);

            var physicalX = LogicalToPhysicalPixels(size.X);
            var physicalY = LogicalToPhysicalPixels(size.Y);

            // We convert bottom and right to physical pixels and then determine physical width and height from them, rather than the other way around, to ensure that adjacent views touch (otherwise there can be a +/-1-pixel gap due to rounding error, in the case of non-integer logical dimensions).
            return(new Rect(
                       physicalX,
                       physicalY,
                       physicalRight - physicalX,
                       physicalBottom - physicalY
                       ));
        }