public CampusMapPage()
 {
     this.InitializeComponent();
     this.initialScale = 1.0;
     this.previousOrientation = base.Orientation;
     base.OrientationChanged += FullImage_OrientationChanged;
 }
Exemplo n.º 2
0
        public PageDimensions(PaperType paperType, PageOrientation orientation, int dpi = 72)
        {
            _paperType   = paperType;
            _orientation = orientation;
            _dpi         = dpi;

            _unitInPoints = new float[]
            {
                1.0f,                   // Point
                dpi,                    // Inch
                dpi / 2.54f,            // cm
                dpi / 25.4f,            // mm
            };

            _size = PaperTypeSize.GetSize(_paperType, _dpi);

            if (_orientation == PageOrientation.Landscape)
            {
                _size = new Size(_size.Height, _size.Width);
            }

            _marginTop    = (int)ConvertUnits(0.15f, UnitOfMeasure.Inch, UnitOfMeasure.Point);
            _marginBottom = _marginTop;

            _marginLeft  = (int)ConvertUnits(0.5f, UnitOfMeasure.Inch, UnitOfMeasure.Point);
            _marginRight = _marginLeft;
        }
Exemplo n.º 3
0
        private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e)
        {
            if (m_d3dInterop == null)
            {
                PageOrientation     pageOrientation    = (PageOrientation)GetValue(OrientationProperty);
                DisplayOrientations displayOrientation = ConvertToNativeOrientation(pageOrientation);

                m_d3dInterop = new Direct3DInterop(displayOrientation);

                // Set WindowBounds to size of DrawingSurface
                m_d3dInterop.WindowBounds = new Windows.Foundation.Size(
                    (float)Application.Current.Host.Content.ActualWidth,
                    (float)Application.Current.Host.Content.ActualHeight
                    );

                // Hook-up native component to DrawingSurfaceBackgroundGrid
                DrawingSurfaceBackground.SetBackgroundContentProvider(m_d3dInterop.CreateContentProvider());
                DrawingSurfaceBackground.SetBackgroundManipulationHandler(m_d3dInterop);

                // Hook-up Cocos2d-x delegates
                m_d3dInterop.SetCocos2dEventDelegate(OnCocos2dEvent);
                m_d3dInterop.SetCocos2dMessageBoxDelegate(OnCocos2dMessageBoxEvent);
                m_d3dInterop.SetCocos2dEditBoxDelegate(OpenEditBox);
                m_d3dInterop.SetCocos2dOpenURLDelegate(OpenURL);
            }
        }
Exemplo n.º 4
0
        public static DeviceOrientation ToDeviceOrientation(this PageOrientation pageOrientation)
        {
            switch (pageOrientation)
            {
            case PageOrientation.None:
                return(DeviceOrientation.Other);

            case PageOrientation.Portrait:
                return(DeviceOrientation.Portrait);

            case PageOrientation.Landscape:
                return(DeviceOrientation.Landscape);

            case PageOrientation.PortraitUp:
                return(DeviceOrientation.PortraitUp);

            case PageOrientation.PortraitDown:
                return(DeviceOrientation.PortraitDown);

            case PageOrientation.LandscapeRight:
                return(DeviceOrientation.LandscapeRight);

            case PageOrientation.LandscapeLeft:
                return(DeviceOrientation.LandscapeLeft);

            default:
                return(DeviceOrientation.Other);
            }
        }
Exemplo n.º 5
0
        private void PrintPages(IEnumerable <IPrintPage> pages, PageOrientation pageOrientation, string documentLabel)
        {
            PrintDialog printDialog = new PrintDialog();

            if (printDialog.ShowDialog() == true)
            {
                FixedDocument fixedDocument = new FixedDocument();
                fixedDocument.Name = documentLabel;
                foreach (IPrintPage page in pages)
                {
                    PageContent pageContent = new PageContent();
                    FixedPage   fixedPage   = new FixedPage();

                    fixedPage.Children.Add(page.PrintElement);
                    (pageContent as System.Windows.Markup.IAddChild).AddChild(fixedPage);
                    fixedDocument.Pages.Add(pageContent);
                }

                XpsDocumentWriter writer = PrintQueue.CreateXpsDocumentWriter(printDialog.PrintQueue);
                printDialog.PrintTicket.PageOrientation = pageOrientation;
                fixedDocument.PrintTicket = printDialog.PrintTicket;
                writer.Write(fixedDocument, printDialog.PrintTicket);

                UIApplication.MessageDialogs.Info("SentToPrinter".Localize());
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Converts the <paramref name="orientation"/> given to a proper page rotation angle, in degrees.
        /// </summary>
        /// <param name="orientation">Page orientation.</param>
        /// <returns>Rotation angle.</returns>
        public static int GetRotationAngle(PageOrientation orientation)
        {
            int angle = 0;

            switch (orientation)
            {
                case PageOrientation.None:
                case PageOrientation.Portrait:
                case PageOrientation.PortraitUp:
                    angle = 90;
                    break;
                case PageOrientation.PortraitDown:
                    angle = 270;
                    break;
                case PageOrientation.Landscape:
                case PageOrientation.LandscapeLeft:
                    angle = 0;
                    break;
                case PageOrientation.LandscapeRight:
                    angle = 180;
                    break;
            }

            return angle;
        }
Exemplo n.º 7
0
        //page: 8.5x11 = 816 * 1056
        public static void AddPageToPdf(PdfDocument document, IList <Image> images, PageOrientation pageOrientation)
        {
            var firstXImage = XImage.FromGdiPlusImage(images.First());
            var page        = document.AddPage();

            page.Size        = PageSize.Letter;
            page.Orientation = pageOrientation;
            var       pageWidth            = page.Width;
            var       pageHeight           = page.Height;
            const int padding              = 7;
            var       horizontalWhiteSpace = (pageWidth - (3 * firstXImage.PointWidth)) / (padding * 2 + 2);
            var       verticalWhiteSpace   = (pageHeight - (3 * firstXImage.PointHeight)) / (padding * 2 + 2);
            var       xGraphics            = XGraphics.FromPdfPage(page);

            for (var index = 0; index < images.Count; index++)
            {
                var xImage = XImage.FromGdiPlusImage(images[index]);

                var row    = index % 3;
                var column = index / 3;

                var x = (row * (xImage.PointWidth + horizontalWhiteSpace)) + padding * horizontalWhiteSpace;
                var y = (column * (xImage.PointHeight + verticalWhiteSpace)) + padding * verticalWhiteSpace;

                xGraphics.DrawImage(xImage, x, y);
            }
        }
        /// <summary>
        /// Convert a standard page size to its dimensions.
        /// </summary>
        /// <param name="pageSize">The physical page size to convert.</param>
        /// <param name="orientation">The orientation of the page.  "Arbitrary" orientation returns the same dimensions as portrait orientation.</param>
        /// <returns>A <see cref="UniSize" /> instance representing the physical dimensions of the paper size, in points.</returns>
        public static UniSize ToUniSize(this PhysicalPageSize pageSize, PageOrientation orientation)
        {
            if (orientation != PageOrientation.Landscape)
            {
                return(pageSize.ToUniSize());
            }
            switch (pageSize)
            {
            case PhysicalPageSize.A1:
                return(_a1Landscape.Value);

            case PhysicalPageSize.A2:
                return(_a2Landscape.Value);

            case PhysicalPageSize.A3:
                return(_a3Landscape.Value);

            case PhysicalPageSize.A4:
                return(_a4Landscape.Value);

            case PhysicalPageSize.A5:
                return(_a5Landscape.Value);

            case PhysicalPageSize.A6:
                return(_a6Landscape.Value);

            default:
                throw new ArgumentOutOfRangeException(nameof(pageSize));
            }
        }
Exemplo n.º 9
0
        private static Point GetHostCoordinates(Point point)
        {
            PhoneApplicationFrame rootVisual  = (PhoneApplicationFrame)Application.Current.RootVisual;
            PageOrientation       orientation = rootVisual.Orientation;

            if (orientation != PageOrientation.LandscapeLeft)
            {
                if (orientation != PageOrientation.LandscapeRight)
                {
                    return(point);
                }
                // ISSUE: explicit reference operation
                double y          = ((Point)point).Y;
                Size   renderSize = ((UIElement)rootVisual).RenderSize;
                // ISSUE: explicit reference operation
                // ISSUE: explicit reference operation
                double num = ((Size)renderSize).Height - ((Point)point).X;
                return(new Point(y, num));
            }
            Size renderSize1 = ((UIElement)rootVisual).RenderSize;

            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            return(new Point(((Size)renderSize1).Width - ((Point)point).Y, ((Point)point).X));
        }
Exemplo n.º 10
0
 public PdfSharpExporter(int[] arrayLayoutIndices, string sExportFile, PageOrientation ePageOrientation) : base(arrayLayoutIndices)
 {
     m_sExportFile      = sExportFile;
     m_ePageOrientation = ePageOrientation;
     m_zDocument        = new PdfDocument();
     AddPage();
 }
Exemplo n.º 11
0
        private void RotateIamgeViewer(PageOrientation orientation)
        {
            var duration = new Duration(TimeSpan.FromSeconds(0.5));
            var sb       = new Storyboard();

            sb.Duration = duration;

            var da = new DoubleAnimation();

            da.Duration = duration;

            sb.Children.Add(da);
            //Storyboard.SetTarget(da, mediaViewerTranform);
            Storyboard.SetTarget(da, mediaViewerTransform);
            Storyboard.SetTargetProperty(da, new PropertyPath("Rotation"));

            if (orientation == PageOrientation.Landscape ||
                orientation == PageOrientation.LandscapeLeft ||
                orientation == PageOrientation.LandscapeRight)
            {
                da.From = 90;
                da.To   = 0;
            }
            else if (orientation == PageOrientation.Portrait ||
                     orientation == PageOrientation.PortraitDown ||
                     orientation == PageOrientation.PortraitUp)
            {
                da.From = -90;
                da.To   = 0;
            }
            sb.Begin();
        }
Exemplo n.º 12
0
        protected override void OnManipulationDelta(ManipulationDeltaEventArgs e)
        {
            base.OnManipulationDelta(e);
            PageOrientation orientation   = (App.Current.RootVisual as PhoneApplicationFrame).Orientation;
            bool            reverseCoords = orientation == PageOrientation.Landscape || orientation == PageOrientation.LandscapeLeft || orientation == PageOrientation.LandscapeRight;
            double          scaleDelta    = reverseCoords ? e.DeltaManipulation.Scale.Y : e.DeltaManipulation.Scale.X;

            //Process scale
            if (scaleDelta != 1)
            {
                // Dont let user zoom out further than the width of the graph
                double scaleX = scaleDelta == 0 ? 1 : scaleDelta;
                if (scaleX * scale.ScaleX * (maxX - minX) < graphWidth)
                {
                    scaleX = graphWidth / (scale.ScaleX * (maxX - minX));
                }

                if (scaleX != scale.ScaleX)
                {
                    CombineScaleTransform(e.ManipulationOrigin.X, scaleX);
                }
            }

            // Process translation
            if (e.DeltaManipulation.Translation.X != 0)
            {
                scale.CenterX += e.DeltaManipulation.Translation.X;
            }

            double maxTranslate = -minX * scale.ScaleX;
            double minTranslate = graphWidth - maxX * scale.ScaleX;

            scale.CenterX = Math.Min(maxTranslate, scale.CenterX);
            scale.CenterX = Math.Max(minTranslate, scale.CenterX);
        }
Exemplo n.º 13
0
        public void ReloadPreview(double scale, Thickness margin, PageOrientation pageOrientation, PaperSize paperSize)
        {
            try
            {
                FitToPage_Scale();
                scale = Scale;
                PrintControlView.ScalePreviewPaneVisibility(false);
                ReloadingPreview = true;
                ShowWaitScreen();
                var printSize = GetPrintSize(paperSize, pageOrientation);
                var visual    = GetScaledVisual(scale);
                CreatePaginator(visual, printSize);
                var visualPaginator = ((VisualPaginator)Paginator);
                visualPaginator.Initialize(IsMarkPageNumbers);
                PagesAcross = visualPaginator.HorizontalPageCount;

                ApproaxNumberOfPages = MaxCopies = Paginator.PageCount;
                if (Scale == 1)
                {
                    NumberOfPages = ApproaxNumberOfPages;
                }

                DisplayPagePreviewsAll(visualPaginator);
                ReloadingPreview = false;
            }
            catch (Exception ex)
            {
            }
            finally
            {
                WaitScreen.Hide();
            }
        }
Exemplo n.º 14
0
 protected override void OnOrientationChanged(PageOrientation pageOrientation)
 {
     screanHeight = Height;
     if (pageOrientation == PageOrientation.Horizontal)
     {
         yVideo.SetFullScrean?.Invoke(true);
     }
     else
     {
         yVideo.SetFullScrean?.Invoke(false);
         expandableView.IsVisible = true;
         if (expandableViewPlayList.IsExpanded)
         {
             expandableViewPlayList.HeightRequest = (float)screanHeight / 2;
         }
         else if (expandableView.IsExpanded)
         {
             expandableView.HeightRequest = (float)screanHeight / 2;
         }
         if (expandableViewPlayList.IsExpanded || expandableView.IsExpanded)
         {
             yVideo.HeightRequest = (float)screanHeight / 2;
         }
         else
         {
             yVideo.HeightRequest = -1;
         }
         expandableViewPlayList.IsVisible = _video.HasVideos;
     }
 }
Exemplo n.º 15
0
        public byte[] GetPdfFromHtml(string html, string baseUrl, PageOrientation orientation = PageOrientation.Portrait)
        {
            var htmlToPdfConverter = new HtmlToPdf()
            {
                SerialNumber = HiQPDFSerial,
                BrowserWidth = 1300,
                //LayoutWithHinting = true,
                TriggerMode       = ConversionTriggerMode.WaitTime,
                WaitBeforeConvert = 5,
                HtmlLoadedTimeout = 2400
            };

            htmlToPdfConverter.Document.PageSize        = PdfPageSize.Letter;
            htmlToPdfConverter.Document.Margins         = new PdfMargins(5);
            htmlToPdfConverter.Document.PageOrientation = PdfPageOrientation.Portrait;
            if (orientation == PageOrientation.Landscape)
            {
                htmlToPdfConverter.Document.PageOrientation = PdfPageOrientation.Landscape;
            }

            byte[] pdfBuffer;

            pdfBuffer = htmlToPdfConverter.ConvertHtmlToMemory(html, baseUrl);

            return(pdfBuffer);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Event for when the orientation of the target page changes.
        /// </summary>
        /// <param name="sender">The PhoneApplicationPage that raised the event.</param>
        /// <param name="ocea">The event args associated with this OrientationChanged event.</param>
        private void ParentPage_OrientationChanged(object sender, OrientationChangedEventArgs ocea)
        {
            // Make into an attached property.
            PageOrientation  newOrientation = ocea.Orientation;
            RotateTransition rotation       = new RotateTransition();

            switch (_lastOrientation)
            {
            // Dont need to worry about case where you go from landscape left to landscape right or vice versa (180 degrees).
            case PageOrientation.LandscapeLeft:
                // New orientation should never be == old orientation.
                if (newOrientation == PageOrientation.PortraitUp)
                {
                    // From landscape left to portrait up.
                    rotation.Mode = RotateTransitionMode.In90Counterclockwise;
                }
                else
                {
                    // From landscape left to landscape right.
                    rotation.Mode = RotateTransitionMode.In180Counterclockwise;
                }
                break;

            case PageOrientation.LandscapeRight:
                if (newOrientation == PageOrientation.PortraitUp)
                {
                    // From landscape right to portrait up.
                    rotation.Mode = RotateTransitionMode.In90Clockwise;
                }
                else
                {
                    // From landscape right to portrait down.
                    rotation.Mode = RotateTransitionMode.In180Clockwise;
                }
                break;

            // Dont need to worry about case where you go from landscape left to landscape right or vice versa (180 degrees).
            case PageOrientation.PortraitUp:
                // New orientation should never be == old orientation.
                if (newOrientation == PageOrientation.LandscapeLeft)
                {
                    rotation.Mode = RotateTransitionMode.In90Clockwise;
                }
                else
                {
                    rotation.Mode = RotateTransitionMode.In90Counterclockwise;
                }
                break;

            default:
                break;
            }

            // Execute the transition
            ITransition transition = rotation.GetTransition(_target);

            transition.Completed += (o, e) => transition.Stop();
            transition.Begin();
            _lastOrientation = newOrientation;
        }
Exemplo n.º 17
0
        /// <summary>
        /// Makes adjustments to UI depending on device orientation. Ensures
        /// that the viewfinder stays fully visible in the middle of the
        /// screen. This requires dynamic changes to title and video canvas.
        /// </summary>
        /// <param name="orientation">Device orientation.</param>
        private void SetOrientation(PageOrientation orientation)
        {
            int videoBrushTransformRotation = 0;

            // Orientation.specific changes to default values
            if (orientation == PageOrientation.PortraitUp)
            {
                videoBrushTransformRotation = 90;
            }
            else if (orientation == PageOrientation.LandscapeRight)
            {
                videoBrushTransformRotation = 180;
            }

            // Set correct values
            if (_sizeMode == Constant.SQUARE_MODE)
            {
                VideoCanvas.Width = VideoCanvas.Height = 480.0;
            }
            else
            {
                VideoCanvas.Width  = 480;
                VideoCanvas.Height = 640;
            }

            VideoBrushTransform.Rotation = videoBrushTransformRotation;

            if (_photoCaptureDevice != null)
            {
                _photoCaptureDevice.SetProperty(
                    KnownCameraGeneralProperties.EncodeWithOrientation,
                    VideoBrushTransform.Rotation);
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Adds a page.
        /// </summary>
        /// <param name="pageSize">The page size.</param>
        /// <param name="pageOrientation">The page orientation.</param>
        public void AddPage(PageSize pageSize, PageOrientation pageOrientation = PageOrientation.Portrait)
        {
            double shortLength = double.NaN, longLength = double.NaN;

            switch (pageSize)
            {
            case PageSize.A4:
                shortLength = 595;
                longLength  = 842;
                break;

            case PageSize.A3:
                shortLength = 842;
                longLength  = 1190;
                break;

            case PageSize.Letter:
                shortLength = 612;
                longLength  = 792;
                break;
            }

            if (pageOrientation == PageOrientation.Portrait)
            {
                this.AddPage(shortLength, longLength);
            }
            else
            {
                this.AddPage(longLength, shortLength);
            }
        }
Exemplo n.º 19
0
        //***********************************************************************************************************************
        /// <summary>
        /// Convertit la valeur <b>PageOrientation</b> en valeur <b>PhoneOrientation</b>.
        /// </summary>
        /// <param name="Value">Valeur <b>PageOrientation</b>.</param>
        /// <returns>Valeur <b>PhoneOrientation</b>.</returns>
        //-----------------------------------------------------------------------------------------------------------------------
        public static PhoneOrientation ToPhoneOrientation(this PageOrientation Value)
        {
            //-------------------------------------------------------------------------------------------------------------------
            switch (Value)
            {
            //---------------------------------------------------------------------------------------------------------------
            case PageOrientation.None: return(PhoneOrientation.Portrait);

            case PageOrientation.Portrait: return(PhoneOrientation.Portrait);

            case PageOrientation.Landscape: return(PhoneOrientation.LandscapeLeft);

            case PageOrientation.PortraitUp: return(PhoneOrientation.Portrait);

            case PageOrientation.PortraitDown: return(PhoneOrientation.Portrait);

            case PageOrientation.LandscapeLeft: return(PhoneOrientation.LandscapeLeft);

            case PageOrientation.LandscapeRight: return(PhoneOrientation.LandscapeRight);
                //---------------------------------------------------------------------------------------------------------------
            }
            //-------------------------------------------------------------------------------------------------------------------

            //-------------------------------------------------------------------------------------------------------------------
            return(PhoneOrientation.Portrait);
            //-------------------------------------------------------------------------------------------------------------------
        }
Exemplo n.º 20
0
        private void SetOrientation(double width = 0, double height = 0)
        {
            double tempWidth  = 0;
            double tempHeight = 0;

            if (width == 0 || height == 0)
            {
                tempWidth  = default_width;
                tempHeight = default_height;
            }
            else
            {
                tempWidth  = width;
                tempHeight = height;
            }

            if (tempWidth > tempHeight)
            {
                pageOrientation = PageOrientation.landscape;
            }
            else
            {
                pageOrientation = PageOrientation.portait;
            }
        }
Exemplo n.º 21
0
        private static (Unit width, Unit height) _pageSize(Models.PageSize pageSize, PageOrientation orientation)
        {
            (Unit width, Unit height)result;

            switch (pageSize)
            {
            case Models.PageSize.Letter:
                result = (new Unit(21.59d, UnitType.cm), new Unit(27.94d, UnitType.cm));
                break;

            case Models.PageSize.A5:
                result = (new Unit(14.8d, UnitType.cm), new Unit(21d, UnitType.cm));
                break;

            case Models.PageSize.A4:
                result = (new Unit(21d, UnitType.cm), new Unit(29.7d, UnitType.cm));
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, null);
            }

            if (orientation == PageOrientation.Portrait)
            {
                return(result);
            }

            var tmp = result.height;

            result.height = result.width;
            result.width  = tmp;

            return(result);
        }
Exemplo n.º 22
0
        public void Run(Pages pages, PageOrientation pageOrientation)
        {
            _pages = pages;
            PrintOperation printOperation = null;

            try
            {
                printOperation                              = new PrintOperation();
                printOperation.Unit                         = Unit.Points;
                printOperation.UseFullPage                  = true;
                printOperation.DefaultPageSetup             = new PageSetup();
                printOperation.DefaultPageSetup.Orientation = pageOrientation;

                printOperation.BeginPrint += HandlePrintBeginPrint;
                printOperation.DrawPage   += HandlePrintDrawPage;

                printOperation.Run(PrintOperationAction.PrintDialog, null);
            }
            catch (Exception e) when(e.Message == "Error from StartDoc")
            {
                _logger.Debug("Операция печати отменена");
            }
            finally
            {
                if (printOperation != null)
                {
                    printOperation.BeginPrint -= HandlePrintBeginPrint;
                    printOperation.DrawPage   -= HandlePrintDrawPage;
                    printOperation.Dispose();
                }
            }
        }
Exemplo n.º 23
0
 public static void OrientationChanged(PageOrientation page_ori)
 {
     if (OnOrientationChange != null)
     {
         OnOrientationChange(null, page_ori);
     }
 }
Exemplo n.º 24
0
 // Constructor
 public MainPage()
 {
     InitializeComponent();
     this.Loaded += MainPage_Loaded;
     lastOrientation = this.Orientation;
    
 }
Exemplo n.º 25
0
        /// <summary>
        /// Value-setting constructor.
        /// </summary>
        /// <param name="parent">The parent node of this page in the document page tree.</param>
        /// <param name="objectId">The indirect object ID of this page.</param>
        /// <param name="size">The paper size of this page.</param>
        /// <param name="orientation">The orientation of this page.</param>
        /// <param name="horizontalMarginProportion">The proportion of the page taken up by each of the left and right margins.</param>
        /// <param name="verticalMarginProportion">The proportion of the page taken up by each of the top and bottom margins.</param>
        /// <param name="generation">The object generation number.  Defaults to zero.  As we do not currently support rewriting existing documents, this should not be set.</param>
        public PdfPage(
            PdfPageTreeNode parent,
            int objectId,
            PhysicalPageSize size,
            PageOrientation orientation,
            double horizontalMarginProportion,
            double verticalMarginProportion,
            int generation = 0)
            : base(parent, objectId, generation)
        {
            if (parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }

            PageSize        = size;
            PageOrientation = orientation;

            UniSize pagePtSize = size.ToUniSize(orientation);

            TopMarginPosition     = pagePtSize.Height * verticalMarginProportion;
            BottomMarginPosition  = pagePtSize.Height - TopMarginPosition;
            LeftMarginPosition    = pagePtSize.Width * horizontalMarginProportion;
            RightMarginPosition   = pagePtSize.Width - LeftMarginPosition;
            PageAvailableWidth    = RightMarginPosition - LeftMarginPosition;
            CurrentVerticalCursor = TopMarginPosition;
            MediaBox = size.ToPdfRectangle(orientation);
        }
Exemplo n.º 26
0
 public PageConfiguration(
     Size size,
     PageOrientation pageOrientation)
 {
     this.Size            = size;
     this.PageOrientation = pageOrientation;
 }
Exemplo n.º 27
0
        private void RotateIamgeViewer(PageOrientation orientation)
        {
            var duration = new Duration(TimeSpan.FromSeconds(0.5));
            var sb = new Storyboard();
            sb.Duration = duration;

            var da = new DoubleAnimation();
            da.Duration = duration;

            sb.Children.Add(da);
            //Storyboard.SetTarget(da, mediaViewerTranform);
            Storyboard.SetTarget(da, mediaViewerTransform);
            Storyboard.SetTargetProperty(da, new PropertyPath("Rotation"));

            if (orientation == PageOrientation.Landscape ||
                orientation == PageOrientation.LandscapeLeft ||
                orientation == PageOrientation.LandscapeRight)
            {
                da.From = 90;
                da.To = 0;
            }
            else if (orientation == PageOrientation.Portrait ||
                orientation == PageOrientation.PortraitDown ||
                orientation == PageOrientation.PortraitUp)
            {
                da.From = -90;
                da.To = 0;
            }
            sb.Begin();
        }
Exemplo n.º 28
0
 void ChangeOrientation(PageOrientation e)
 {
     orientation = e;
     if (e == PageOrientation.PortraitUp)
     {
         m_Videohost.ChangeOrientation(0);
         VideoPreviewSurface.Margin = new Thickness(98, 257, 0, 0);
     }
     else if (e == PageOrientation.PortraitDown)
     {
         m_Videohost.ChangeOrientation(1);
         VideoPreviewSurface.Margin = new Thickness(98, 257, 0, 0);
     }
     else if (e == PageOrientation.LandscapeLeft)
     {
         m_Videohost.ChangeOrientation(2);
         //VideoPreviewSurface.Margin = new Thickness(-450, 200, 0, 0);
         VideoPreviewSurface.Margin = new Thickness(0, 257, 98, 0);
     }
     else if (e == PageOrientation.LandscapeRight)
     {
         m_Videohost.ChangeOrientation(3);
         //VideoPreviewSurface.Margin = new Thickness(-450, 200, 0, 0);
         VideoPreviewSurface.Margin = new Thickness(98, 257, 0, 0);
     }
 }
Exemplo n.º 29
0
 protected override void OnOrientationChanged(PageOrientation pageOrientation)
 {
     screanHeight = Height;
     if (pageOrientation == PageOrientation.Horizontal)
     {
         lVideo.SetFullScrean(true);
     }
     else
     {
         lVideo.SetFullScrean(false);
         expandableView.IsVisible = true;
         if (expandableView.IsExpanded)
         {
             expandableView.HeightRequest = (float)screanHeight / 2;
         }
         if (expandableView.IsExpanded)
         {
             lVideo.HeightRequest = (float)screanHeight / 2;
         }
         else
         {
             lVideo.HeightRequest = -1;
         }
     }
 }
Exemplo n.º 30
0
        public static void Show(List <FrameworkElement> Pages, string documentName, PageOrientation pageOrientation)
        {
            if (System.IO.File.Exists("PrintPreview.xps"))
            {
                System.IO.File.Delete("PrintPreview.xps");
            }

            XpsDocument       xpsDocument = new XpsDocument("PrintPreview.xps", System.IO.FileAccess.ReadWrite);
            XpsDocumentWriter writer      = XpsDocument.CreateXpsDocumentWriter(xpsDocument);

            FixedDocument fixedDocument = new FixedDocument();
            PageContent   pageContent;
            FixedPage     fixedPage;

            for (int i = 0; i < Pages.Count; i++)
            {
                fixedPage = new FixedPage
                {
                    Width = Pages[i].Width, Height = Pages[i].Height, Margin = new Thickness(-10)
                };
                fixedPage.Children.Add(Pages[i]);
                pageContent = new PageContent();
                ((IAddChild)pageContent).AddChild(fixedPage);
                fixedDocument.Pages.Add(pageContent);
            }

            writer.Write(fixedDocument);

            var printWindow = new PrintWindow(fixedDocument, documentName, pageOrientation);

            printWindow.Show();
            xpsDocument.Close();
        }
        public ScanBarcodeViewModel(INavigationService navigationService, IVibrationService vibrationService, IPhotoCameraService photoCameraService)
        {
            _navigationService  = navigationService;
            _vibrationService   = vibrationService;
            _photoCameraService = photoCameraService;

            _photoCameraService.Initialized += (s, e) =>
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    _photoCameraService.FlashMode = Microsoft.Devices.FlashMode.Off;

                    _scanning = true;

                    _scanBarcodeThread = new Thread(ScanBarcode);
                    _scanBarcodeThread.Start();

                    _focusCameraTimer = new Timer(FocusCamera, null, 1000, 4000);
                });
            };

            OrientationChangedCommand = new RelayCommand <OrientationChangedEventArgs>(e =>
            {
                _orientation = e.Orientation;

                CheckVideoPreviewOrientation(_videoPreviewBrush);
            });

            _barcodeReader = new com.google.zxing.oned.Code39Reader(false);
        }
 public CampusMapPage()
 {
     this.InitializeComponent();
     this.initialScale        = 1.0;
     this.previousOrientation = base.Orientation;
     base.OrientationChanged += FullImage_OrientationChanged;
 }
Exemplo n.º 33
0
        public static void Show(FrameworkElement Page, string documentName, PageOrientation pageOrientation)
        {
            if (System.IO.File.Exists("PrintPreview.xps"))
            {
                System.IO.File.Delete("PrintPreview.xps");
            }

            XpsDocument       xpsDocument = new XpsDocument("PrintPreview.xps", System.IO.FileAccess.ReadWrite);
            XpsDocumentWriter writer      = XpsDocument.CreateXpsDocumentWriter(xpsDocument);

            FixedDocument fixedDocument = new FixedDocument();
            PageContent   pageContent;
            FixedPage     fixedPage;

            fixedPage = new FixedPage
            {
                Width = Page.Width, Height = Page.Height
            };
            fixedPage.Children.Add(Page);

            pageContent = new PageContent();
            ((IAddChild)pageContent).AddChild(fixedPage);

            fixedDocument.Pages.Add(pageContent);

            writer.Write(fixedDocument);

            var printWindow = new PrintWindow(fixedDocument, documentName, pageOrientation);

            printWindow.ShowDialog();
            xpsDocument.Close();
        }
Exemplo n.º 34
0
        public MainPage()
        {
            System.Diagnostics.Debug.WriteLine("UserAgent: " + getUserAgent());
            _instance   = this;
            _uiThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId;
            updateScreenSize();
            InitializeComponent();
            ApplicationBar.IsVisible = false;
            _screenOrientation       = Orientation;
            try
            {
                // initialize C# extensions factories
                CSharpExtensions.InitializeExtensions();
                // create rhodes runtime object
                var _rhoruntime = CRhoRuntime.getInstance(new MainPageWrapper(this));
                _rhoruntime.setCryptoEngine(new CryptoEngineWrapper(new RhoCrypt()));
                // create and start rhodes main thread
                _rhoruntimeThread = new Thread(_rhoruntime.Execute);
                _rhoruntimeThread.Start();

                //temporary solutions, to do refactoring
                //Thread.Sleep(200);
                _rhoruntime.onActivate(0);
            }
            catch (Exception e)
            {
                RhodesWebBrowser.NavigateToString("<html><head><title>Exception</title></head><body>Exception: " + e.Message + "</body></html>");
            }
        }
Exemplo n.º 35
0
        public ShowImage()
        {
            InitializeComponent();

            this.OrientationChanged += new EventHandler<OrientationChangedEventArgs>(MainPage_OrientationChanged);
            lastOrientation = this.Orientation;
            this.ManipulationDelta += new EventHandler<ManipulationDeltaEventArgs>(MainPage_ManipulationDelta);
        }
Exemplo n.º 36
0
 public ThreadView()
 {
     InitializeComponent();
     BindEvents();
     this.SupportedOrientations = SupportedPageOrientation.PortraitOrLandscape;
     this._currentOrientation = this.Orientation;
     this._defaultAppBar = this.ApplicationBar;
 }
Exemplo n.º 37
0
        public ExportSettings()
        {
            m_page_orientation = PageOrientation.Landscape;
            if (GetTotalScreens() > 1)
                m_template_doc_path = Directory.GetParent(Assembly.GetExecutingAssembly().Location) + "\\Documents\\Template Landscape.docx";
            else
                m_template_doc_path = Directory.GetParent(Assembly.GetExecutingAssembly().Location) + "\\Documents\\Template Portrait.docx";

        }
Exemplo n.º 38
0
 // Constructor
 public MainPage()
 {
     InitializeComponent();
     Loaded += MainPage_Loaded;
     Unloaded += new RoutedEventHandler(MainPage_Unloaded);
     OrientationChanged += new EventHandler<OrientationChangedEventArgs>(MainPage_OrientationChanged);
     lastOrientation = this.Orientation;
     VisualStateManager.GoToState(this, PortraitState.Name, true);
 }
Exemplo n.º 39
0
        private void CaptureButton_Click(object sender, EventArgs e)
        {
            this.LayoutRoot.Tap -= LayoutRoot_Tap;

            _capture.CaptureImageAsync();

            _captureOrientation = Orientation;
            _isVideoLive = false;
        }
Exemplo n.º 40
0
        public static void SetOrientation(this PhoneApplicationPage page, PageOrientation? orientation = null)
        {
            var app = Resolver.Resolve<IXFormsApp>() as XFormsAppWP;

            if (app != null)
            {
                app.SetOrientation(orientation ?? page.Orientation);
            }
        }
Exemplo n.º 41
0
        public GamePage()
        {
            InitializeComponent();

            var gameViewModel = new GameViewModel(DisMenu, MenuPlayer);
            DataContext = gameViewModel;
            gameViewModel.OpenListPicker += (sender, e) => ListPickerPrizeLand.Open();

            OrientationChanged += MainPage_OrientationChanged;
            _lastOrientation = Orientation;
        }
Exemplo n.º 42
0
        //PdfPage m_page;
        //public PdfPrintTarget(PdfPage page)
        //{
        //    m_page = page;
        //}

        /*
        #region IPrintTarget Members

        public float Width
        {
            get { return PageSizeConverter.ToSize(m_page.Size).Width; }
        }

        public float Height
        {
            get { return PageSizeConverter.ToSize(m_page.Size).Height; }
        }

        #endregion
        */

        #region IPrintTarget Members

        public SizeF GetPageSize(PageOrientation orientation)
        {
            switch (orientation)
            {
                case PageOrientation.Portrait:
                    return new SizeF(m_size.Width, m_size.Height);
                case PageOrientation.Landscape:
                    return new SizeF(m_size.Height, m_size.Width);
            }
            throw new Exception("The method or operation is not implemented.");
        }
Exemplo n.º 43
0
        private void SetOrientation(PageOrientation orientation)
        {
            switch (orientation)
            {
                case PageOrientation.Landscape:

                case PageOrientation.LandscapeLeft:

                case PageOrientation.LandscapeRight:

                case PageOrientation.None:
                    TopMenu.Visibility = System.Windows.Visibility.Collapsed;
                    break;
                case PageOrientation.Portrait:

                case PageOrientation.PortraitDown:

                case PageOrientation.PortraitUp:
                    TopMenu.Visibility = System.Windows.Visibility.Visible;
                    break;
                default:
                    break;
            }

            switch (orientation)
            {
                case PageOrientation.Landscape:

                    break;
                case PageOrientation.LandscapeLeft:
                    ContentPanel.Margin = new Thickness(0, 0, 75, 0);
                    IndexNav.Margin = new Thickness(0, 0, 75, 0);
                    break;
                case PageOrientation.LandscapeRight:
                    ContentPanel.Margin = new Thickness(75, 0, 0, 0);
                    IndexNav.Margin = new Thickness(75, 0, 0, 0);
                    break;
                case PageOrientation.None:


                case PageOrientation.Portrait:

                case PageOrientation.PortraitDown:

                case PageOrientation.PortraitUp:


                default:
                    ContentPanel.Margin = new Thickness(0, 0, 0, 0);
                    IndexNav.Margin = new Thickness(0, 0, 0, 0);
                    break;
            }
        }
Exemplo n.º 44
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            var locator = new ViewModelLocator();
            _mainViewModel = locator.Main;
            DataContext = _mainViewModel;

            OrientationChanged += MainPageOrientationChanged;
            _lastOrientation = Orientation;

            UpdateOrientation();
        }
        void determineStyle(PageOrientation newOrientation, IList<ResourceDictionary> resources)
        {
            var lastOrientation = state;
            state = newOrientation;

            //some flags to simplify detecting an orientation change
            var wasBlank = (lastOrientation == null ||
                            lastOrientation == PageOrientation.None);
            var wasPortrait = (lastOrientation == PageOrientation.Portrait ||
                               lastOrientation == PageOrientation.PortraitDown ||
                               lastOrientation == PageOrientation.PortraitUp);
            var wasLandscape = (lastOrientation == PageOrientation.Landscape ||
                                lastOrientation == PageOrientation.LandscapeLeft ||
                                lastOrientation == PageOrientation.LandscapeRight);
            var isPortrait = (newOrientation == PageOrientation.Portrait ||
                              newOrientation == PageOrientation.PortraitDown ||
                              newOrientation == PageOrientation.PortraitUp);
            var isLandscape = (newOrientation == PageOrientation.Landscape ||
                               newOrientation == PageOrientation.LandscapeLeft ||
                               newOrientation == PageOrientation.LandscapeRight);


            //STYLE SWITCHING

            //only switch on orientation change
            if (isLandscape && (wasBlank || wasPortrait))
            {
                //clear existing responsive styles if any
                removeExistingStyles(resources);

                //add compact style xaml to resources
                if (this.LandscapeStyles != null)
                {
                    foreach (var style in this.LandscapeStyles)
                        resources.Add(style);
                }

            }
            else if (isPortrait && (wasBlank || wasLandscape))
            {
                //clear existing responsive styles if any
                removeExistingStyles(resources);

                //add regular style xaml to resources
                if (this.PortraitStyles != null)
                {
                    foreach (var style in this.PortraitStyles)
                        resources.Add(style);
                }

            }
        }
        /// <summary>
        /// Tells the Viewfinder to update its UI to reflect a new PageOrientation
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void OnOrientationChanged(PageOrientation newOrientation)
        {
            if (IsPortrait(newOrientation))
            {
                this.rotateArrowButtonToPortrait.Begin();
            }
            else
            {
                this.rotateArrowButtonToLandscape.Begin();
            }

            ApplyRotation();
        }
Exemplo n.º 47
0
        void handleChangeEvents(Size size, PageOrientation orientation)
        {
            if (ResponsiveMethods == null)
                return;

            foreach (var method in ResponsiveMethods)
            {
                method.HandleChange(size,
                                    orientation,
                                    this.Resources.MergedDictionaries);
            }

        }
Exemplo n.º 48
0
 public PdfSharpExporter(int nLayoutStartIndex, int nLayoutEndIndex, string sExportFile, string sPageOrientation)
     : base(nLayoutStartIndex, nLayoutEndIndex)
 {
     m_sExportFile = sExportFile;
     try
     {
         m_ePageOrientation = (PageOrientation)Enum.Parse(typeof(PageOrientation), sPageOrientation);
     }
     catch (Exception)
     {
         Logger.AddLogLine(sPageOrientation + " is an unknow page orientation.");
     }
     m_zDocument = new PdfDocument();
     AddPage();
 }
Exemplo n.º 49
0
        public MainPage()
        {
            InitializeComponent();
            lastOrientation = this.Orientation;

            //TODO
            //OSA_Configuration.Instance.load(stream);
            //show loading animation while authorizing

            this.DataContext = OSA_Configuration.Instance;
            if (OSA_Configuration.Instance.UseCurrentLocationSetting)
            {
                App.watcher.PositionChanged += watcher_InitialPositionChanged;
            }
        }
Exemplo n.º 50
0
		private void AdjustForOrientation(PageOrientation orientation)
		{
			Messenger.Default.Send<OrientationChangedMessage>(new OrientationChangedMessage { Orientation = orientation });
			lastKnownOrientation = orientation;

			if (LayoutRoot != null)
			{
				if (orientation == PageOrientation.LandscapeRight)
					LayoutRoot.Margin = new Thickness(40, 0, 0, 0);
				else if (orientation == PageOrientation.LandscapeLeft)
					LayoutRoot.Margin = new Thickness(0, 0, 35, 0);
				else
					LayoutRoot.Margin = new Thickness(0, 0, 0, 0);
			}
		}
 private void SetRotation(PageOrientation orientation)
 {
     if (orientation.HasFlag(PageOrientation.LandscapeLeft))
     {
         BufferRotate = 0;
     }
     else if (orientation.HasFlag(PageOrientation.LandscapeRight))
     {
         BufferRotate = 180;
     }
     else if (orientation.HasFlag(PageOrientation.PortraitUp))
     {
         //The back camera renders upsidedown so use a different rotate
         if (Capture != null && Capture.SensorLocation == CameraSensorLocation.Front)
         {
             BufferRotate = 270;
         }
         else if (Capture != null && Capture.SensorLocation == CameraSensorLocation.Back)
         {
             BufferRotate = 90;
         }
         else
         {
             BufferRotate = 270;
         }
     }
     else if (orientation.HasFlag(PageOrientation.PortraitDown))
     {
         //The back camera renders upsidedown so use a different rotate
         if (Capture != null && Capture.SensorLocation == CameraSensorLocation.Front)
         {
             BufferRotate = 90;
         }
         else if (Capture != null && Capture.SensorLocation == CameraSensorLocation.Back)
         {
             BufferRotate = 270;
         }
         else
         {
             BufferRotate = 90;
         }
     }
     if (Preview != null)
     {
         Preview.Rotate(BufferRotate);
     }
 }
Exemplo n.º 52
0
        public static CompositeTransform GetCameraTransformByOrientation(CameraType cameraType, PageOrientation orientation)
        {
            var scaleX = 1;
            var scaleY = 1;
            var rotation = 0;

            if (cameraType == CameraType.FrontFacing)
            {
                scaleX = -1;
                if (orientation == PageOrientation.LandscapeRight)
                {
                    rotation = 180;
                }
                else if (orientation == PageOrientation.LandscapeLeft)
                {
                }
                else if (orientation == PageOrientation.PortraitUp)
                {
                    rotation = 90;
                }
            }
            else
            {
                if (orientation == PageOrientation.LandscapeRight)
                {
                    scaleX = -1;
                    scaleY = -1;
                }
                else if (orientation == PageOrientation.LandscapeLeft)
                {
                    // all good
                }
                else if (orientation == PageOrientation.PortraitUp)
                {
                    rotation = 90;
                }
            }

            return new CompositeTransform
            {
                CenterX = 0.5, 
                CenterY = 0.5, 
                ScaleX = scaleX, 
                ScaleY = scaleY, 
                Rotation = rotation 
            };
        }
Exemplo n.º 53
0
 private static DisplayOrientations ConvertToNativeOrientation(PageOrientation xamlOrientation)
 {
     switch (xamlOrientation)
     {
         case PageOrientation.Portrait:
         case PageOrientation.PortraitUp:
             return DisplayOrientations.Portrait;
         case PageOrientation.PortraitDown:
             return DisplayOrientations.PortraitFlipped;
         case PageOrientation.Landscape:
         case PageOrientation.LandscapeLeft:
             return DisplayOrientations.Landscape;
         case PageOrientation.LandscapeRight:
             return DisplayOrientations.LandscapeFlipped;
         default:
             return DisplayOrientations.Landscape;
     }
 }
        public void ReloadPreview(PageOrientation pageOrientation, PaperSize currentPaper)
        {
            ReloadingPreview = true;
            if (FullScreenPrintWindow != null)
            {
                WaitScreen.Show("Loading Preview");
            }
            
            if (PageOrientation == PageOrientation.Portrait)
            {
                FlowDocument.PageHeight = currentPaper.Height;
                FlowDocument.PageWidth = currentPaper.Width;
            }
            else
            {
                FlowDocument.PageHeight = currentPaper.Width;
                FlowDocument.PageWidth = currentPaper.Height;
            }

	        var s = new FileStream("c:\\aa.xps", FileMode.OpenOrCreate, FileAccess.ReadWrite);
			_ms = new MemoryStream();
            _pkg = Package.Open(s, FileMode.Create, FileAccess.ReadWrite);
            //const string pack = "pack://temp.xps";
            //var oldPackage = PackageStore.GetPackage(new Uri(pack));
            //if (oldPackage == null)
            //    PackageStore.AddPackage(new Uri(pack), _pkg);
            //else
            //{
            //    PackageStore.RemovePackage(new Uri(pack));
            //    PackageStore.AddPackage(new Uri(pack), _pkg);
            //}
            _xpsDocument = new XpsDocument(_pkg);//, CompressionOption.SuperFast, pack);
            var xpsWriter = XpsDocument.CreateXpsDocumentWriter(_xpsDocument);

            var documentPaginator = ((IDocumentPaginatorSource)FlowDocument).DocumentPaginator;
            xpsWriter.Write(documentPaginator);
            Paginator = documentPaginator;
            MaxCopies = NumberOfPages = ApproaxNumberOfPages = Paginator.PageCount;
            PagesAcross = 2;
            DisplayPagePreviewsAll(documentPaginator);
            WaitScreen.Hide();
            ReloadingPreview = false;
        }
Exemplo n.º 55
0
        private void MainPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
        {
            var newOrientation = e.Orientation;
            // Orientations are (clockwise) 'PortraitUp', 'LandscapeRight', 'LandscapeLeft'

            var transitionElement = new RotateTransition();
            switch (newOrientation)
            {
                case PageOrientation.Landscape:
                case PageOrientation.LandscapeRight:
                    // Come here from PortraitUp (i.e. clockwise) or LandscapeLeft?
                    transitionElement.Mode = _lastOrientation == PageOrientation.PortraitUp
                        ? RotateTransitionMode.In90Counterclockwise
                        : RotateTransitionMode.In180Clockwise;
                    break;
                case PageOrientation.LandscapeLeft:
                    // Come here from LandscapeRight or PortraitUp?
                    transitionElement.Mode = _lastOrientation == PageOrientation.LandscapeRight
                        ? RotateTransitionMode.In180Counterclockwise
                        : RotateTransitionMode.In90Clockwise;
                    break;
                case PageOrientation.Portrait:
                case PageOrientation.PortraitUp:
                    // Come here from LandscapeLeft or LandscapeRight?
                    transitionElement.Mode = _lastOrientation == PageOrientation.LandscapeLeft
                        ? RotateTransitionMode.In90Counterclockwise
                        : RotateTransitionMode.In90Clockwise;
                    break;
            }

            // Execute the transition
            var phoneApplicationPage =
                (PhoneApplicationPage) (((PhoneApplicationFrame) Application.Current.RootVisual)).Content;
            var transition = transitionElement.GetTransition(phoneApplicationPage);
            transition.Completed += delegate
            {
                transition.Stop();
            };
            transition.Begin();

            _lastOrientation = newOrientation;
        }
Exemplo n.º 56
0
		private void SetVisibilityProperties(PageOrientation orientation)
		{
			switch (orientation)
			{
				case PageOrientation.Landscape:
				case PageOrientation.LandscapeLeft:
				case PageOrientation.LandscapeRight:
					this.PortraitVisibility = Visibility.Collapsed;
					this.LandscapeVisibility = Visibility.Visible;
					break;

				case PageOrientation.None:
				case PageOrientation.Portrait:
				case PageOrientation.PortraitDown:
				case PageOrientation.PortraitUp:
					this.PortraitVisibility = Visibility.Visible;
					this.LandscapeVisibility = Visibility.Collapsed;
					break;
			}

			this.OnPropertyChanged("PortraitVisibility");
			this.OnPropertyChanged("LandscapeVisibility");
		}
 private static bool IsLandscape(PageOrientation orientation)
 {
     return orientation == PageOrientation.Landscape || orientation == PageOrientation.LandscapeLeft || orientation == PageOrientation.LandscapeRight;
 }
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            OrientationChanged += OnOrientationChanged;
            lastOrientation = Orientation;

            // Customize the ApplicationBar Buttons by providing the right text
            if (null != ApplicationBar)
            {
                foreach (object obj in ApplicationBar.Buttons)
                {
                    IApplicationBarIconButton button = obj as IApplicationBarIconButton;
                    if (null != button)
                    {
                        if ("DONE" == button.Text)
                        {
                            button.Text = LocalizedResources.ControlResources.DateTimePickerDoneText;
                            button.Click += OnDoneButtonClick;
                        }
                        else if ("CANCEL" == button.Text)
                        {
                            button.Text = LocalizedResources.ControlResources.DateTimePickerCancelText;
                            button.Click += OnCancelButtonClick;
                        }
                    }
                }
            }

            SetupListItems(-90);

            PlaneProjection headerProjection = (PlaneProjection)HeaderTitle.Projection;
            if (null == headerProjection)
            {
                headerProjection = new PlaneProjection();
                HeaderTitle.Projection = headerProjection;
            }
            headerProjection.RotationX = -90;

            Picker.Opacity = 1;

            Dispatcher.BeginInvoke(() =>
                {
                    IsOpen = true;
                });
                
        }
        private void OnOrientationChanged(object sender, OrientationChangedEventArgs e)
        {
            PageOrientation newOrientation = e.Orientation;

            RotateTransition transitionElement = new RotateTransition();

            // Adjust padding if possible
            
            if (null != MainGrid)
            {
                switch (newOrientation)
                {
                    case PageOrientation.Portrait:
                    case PageOrientation.PortraitUp:
                        HeaderTitle.Margin = new Thickness(20, 12, 12, 12);
                        Picker.Margin = new Thickness(8, 12, 0, 0);

                        transitionElement.Mode = (lastOrientation == PageOrientation.LandscapeLeft) ?
                        RotateTransitionMode.In90Counterclockwise : RotateTransitionMode.In90Clockwise;

                        break;
                    case PageOrientation.Landscape:
                    case PageOrientation.LandscapeLeft:
                        HeaderTitle.Margin = new Thickness(72, 0, 0, 0);
                        Picker.Margin = new Thickness(60, 0, 0, 0);

                        transitionElement.Mode = (lastOrientation == PageOrientation.LandscapeRight) ?
                        RotateTransitionMode.In180Counterclockwise : RotateTransitionMode.In90Clockwise;
                        break;
                    case PageOrientation.LandscapeRight:
                        HeaderTitle.Margin = new Thickness(20, 0, 0, 0);
                        Picker.Margin = new Thickness(8, 0, 0, 0);

                        transitionElement.Mode = (lastOrientation == PageOrientation.PortraitUp) ? 
                        RotateTransitionMode.In90Counterclockwise : RotateTransitionMode.In180Clockwise;
                        break;
                }
            }

            PhoneApplicationPage phoneApplicationPage = (PhoneApplicationPage)(((PhoneApplicationFrame)Application.Current.RootVisual)).Content;
            ITransition transition = transitionElement.GetTransition(phoneApplicationPage);
            transition.Completed += delegate
            {
                transition.Stop();
            };
            transition.Begin();

            lastOrientation = newOrientation;
        }
Exemplo n.º 60
0
 private static Size GetPrintSize(PaperSize paperSize, PageOrientation pageOrientation)
 {
     var printSize = new Size(paperSize.Width, paperSize.Height);
     if (pageOrientation == PageOrientation.Landscape)
     {
         printSize = new Size(paperSize.Height, paperSize.Width);
     }
     return printSize;
 }