Пример #1
0
        internal static FrameworkElement ToFrameworkElement(this VisualElement visualElement)
        {
            if (!Forms.IsInitialized)
            {
                throw new InvalidOperationException("call Forms.Init() before this");
            }

            var root = new Windows.UI.Xaml.Controls.Page();

            // Yes, this looks awkward. But the page needs to be Platformed or several things won't work
            new WindowsPlatform(root);

            var renderer = visualElement.GetOrCreateRenderer();

            if (renderer == null)
            {
                throw new InvalidOperationException($"Could not find or create a renderer for {visualElement}");
            }

            var frameworkElement = renderer.ContainerElement;

            frameworkElement.Loaded += (sender, args) =>
            {
                visualElement.Layout(new Rectangle(0, 0, frameworkElement.ActualWidth, frameworkElement.ActualHeight));
            };

            return(frameworkElement);
        }
 public WindowsPhonePlatform(Windows.UI.Xaml.Controls.Page page)
     : base(page)
 {
     _status          = StatusBar.GetForCurrentView();
     _status.Showing += OnStatusBarShowing;
     _status.Hiding  += OnStatusBarHiding;
 }
Пример #3
0
        public static UIElement ConvertPageToUIElement(this Page page, Windows.UI.Xaml.Controls.Page applicationPage)
        {
            Platform platform = new Platform(applicationPage);

            platform.SetPage(page);
            return(platform);
        }
        internal static FrameworkElement ToFrameworkElement(this VisualElement visualElement)
        {
            if (!Forms.IsInitialized)
            {
                throw new InvalidOperationException("call Forms.Init() before this");
            }

            var root = new Windows.UI.Xaml.Controls.Page();

            new WindowsPlatform(root).SetPlatformDisconnected(visualElement);

            var renderer = visualElement.GetOrCreateRenderer();

            if (renderer == null)
            {
                throw new InvalidOperationException($"Could not find or create a renderer for {visualElement}");
            }

            var frameworkElement = renderer.ContainerElement;

            frameworkElement.Loaded += (sender, args) =>
            {
                visualElement.Layout(new Rectangle(0, 0, frameworkElement.ActualWidth, frameworkElement.ActualHeight));
            };

            return(frameworkElement);
        }
        public static async Task <Windows.UI.Xaml.Controls.ContentDialogResult> ShowConfirmPrompt
            (this Windows.UI.Xaml.Controls.Page parent, string title,
            string message, string primaryText, string secondaryText)
        {
            var dialog = new UserPrompt(primaryText, secondaryText, title, message, false);
            var result = await dialog.ShowAsync();

            return(result);
        }
        /// <summary>
        /// Shows a generic prompt for user input.
        /// </summary>
        public static async Task <string> ShowTextboxPrompt
            (this Windows.UI.Xaml.Controls.Page parent, string title,
            string message, string primaryText, string secondaryText)
        {
            var dialog = new UserPrompt(primaryText, secondaryText, title, message, true);
            var result = await dialog.ShowAsync();

            return(result == Windows.UI.Xaml.Controls.ContentDialogResult.Primary ? dialog.Input : null);
        }
        private static void Page_Creating(object sender, EventArgs e)
        {
            Windows.UI.Xaml.Controls.Page page = sender as Windows.UI.Xaml.Controls.Page;

            // Pageインスタンスを記憶
            instPages.Add(page);

            // Unloadイベントを設定
            page.Unloaded += Page_Unloaded;
        }
Пример #8
0
        /// <summary>
        /// Jaffaフレームワークにページ開始を通知します。
        /// InitializeComponentの前に実行する必要があります。
        /// </summary>
        /// <param name="win">Jaffaフレームワークを利用するページのインスタンスを指定します。</param>
        public static void Start(Windows.UI.Xaml.Controls.Page page)
        {
            // ページ生成完了通知イベント
            Creating?.Invoke(page, new EventArgs());

            // カルチャに合わせてリソースを切り替え
            if (Jaffa.Application.WaitingChangeCulture == true)
            {
                Jaffa.Application.Current.Resources    = Internal.Core.MakeChangedResources(Jaffa.Application.Current.Resources, Jaffa.International.GetAvailableLanguageCodeList(), Jaffa.International.CurrentCulture);
                Jaffa.Application.WaitingChangeCulture = false;
            }
            page.Resources = Internal.Core.MakeChangedResources(page.Resources, Jaffa.International.GetAvailableLanguageCodeList(), Jaffa.International.CurrentCulture);
        }
Пример #9
0
        internal async void OnPrint(Windows.UI.Xaml.Controls.Page owningPage)
        {
            try {
                // For printing a `Canvas` UIElement is required on the current page in the visual tree
                var printHelper = new PrintHelper(PDFView.Document, owningPage, "PrintCanvas", "My Lovely Document.pdf");

                printHelper.PrintingCompleteHandler += PrintHelper_PrintingCompleteHandler;

                await printHelper.ShowPrintUIAsync();
            } catch (Exception e) {
                var messageDialog = new MessageDialog(e.ToString());
                await messageDialog.ShowAsync();
            }
        }
Пример #10
0
        private async void Msdock_DockDeviceDisconnected(object sender, EventArgs e)
        {
            var xaml = Properties.Resources.Flyout;

            xaml = xaml.Replace("$CONNECTIONSTATUS", "Disconnected");
            xaml = xaml.Replace("$PROTOCOLVERSION", "N/A");
            xaml = xaml.Replace("$DEVICENAME", "N/A");
            xaml = xaml.Replace("$DEVICENAME", "N/A");
            xaml = xaml.Replace("$HWVERSION", "N/A");
            xaml = xaml.Replace("$SWLOCATION", "N/A");
            xaml = xaml.Replace("$SWVERSION", "N/A");
            xaml = xaml.Replace("$ANX7737FWVERSION", "N/A");
            xaml = xaml.Replace("$ANX7750FWVERSION", "N/A");

            if (sender == this)
            {
                Windows.UI.Xaml.Controls.Page control = (Windows.UI.Xaml.Controls.Page)XamlReader.Load(xaml);

                var maingrid           = control.Content as Windows.UI.Xaml.Controls.Grid;
                var lastgridinmaingrid = maingrid.Children.Last() as Windows.UI.Xaml.Controls.Grid;
                var button             = lastgridinmaingrid.Children[0] as Windows.UI.Xaml.Controls.Button;

                button.IsEnabled = false;
                button.Click    += Form1_Click;

                windowsXamlHost1.Child = control;
            }
            else
            {
                await windowsXamlHost1.Child.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    Windows.UI.Xaml.Controls.Page control = (Windows.UI.Xaml.Controls.Page)XamlReader.Load(xaml);

                    var maingrid           = control.Content as Windows.UI.Xaml.Controls.Grid;
                    var lastgridinmaingrid = maingrid.Children.Last() as Windows.UI.Xaml.Controls.Grid;
                    var button             = lastgridinmaingrid.Children[0] as Windows.UI.Xaml.Controls.Button;

                    button.IsEnabled = false;
                    button.Click    += Form1_Click;

                    windowsXamlHost1.Child = control;
                });
            }
        }
Пример #11
0
        /// <summary>
        /// ページをリロードします。
        /// </summary>
        /// <param name="frame">フレームのインスタンス</param>
        /// <param name="page">ページのインスタンス</param>
        /// <param name="preprocess">リロードの前処理 (async)</param>
        /// <param name="postprocess">リロードの後処理 (async)</param>
        /// <returns></returns>
        public static void Reload(Windows.UI.Xaml.Controls.Frame frame, Windows.UI.Xaml.Controls.Page page, Preprocess preprocess = null, Postprocess postprocess = null)
        {
            Logging.SysLogWriteWaiting = true;

            // 前処理
            if (preprocess != null)
            {
                preprocess(frame, page);
            }

            // コンポーネント再構築
            Windows.UI.Xaml.Application.LoadComponent(page, page.BaseUri, Windows.UI.Xaml.Controls.Primitives.ComponentResourceLocation.Application);

            // 後処理
            if (postprocess != null)
            {
                postprocess(frame, page);
            }

            Logging.SysLogWriteWaiting = false;
        }
Пример #12
0
        /*
         * This method takes an ElementChangedEventArgs parameter that contains OldElement and NewElement properties.
         * These properties represent the Xamarin.Forms element that the renderer was attached to,
         * and the Xamarin.Forms element that the renderer is attached to, respectively.
         * In the sample application the OldElement property will be null
         * and the NewElement property will contain a reference to the CameraPage instance.
         */
        protected override void OnElementChanged(ElementChangedEventArgs <Page> e)
        {
            base.OnElementChanged(e);
            Debug.Write(e.OldElement == null);
            Debug.Write(e.NewElement == null);
            if (e.OldElement != null || Element == null)
            {
                return;
            }
            Windows.UI.Xaml.Controls.Image image = new Windows.UI.Xaml.Controls.Image()
            {
                Width  = 100,
                Height = 100,
                HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Left
            };
            BitmapImage bitmapImage = new BitmapImage(new Uri("ms-appx://XamarinCustomContentPage.UWP/Assets/picture.png"));

            image.Source = bitmapImage;

            sta = new Windows.UI.Xaml.Controls.StackPanel();

            bt            = new Windows.UI.Xaml.Controls.Button();
            bt.Content    = "hello , my custom page";
            bt.Background = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Color.FromArgb(25, 0, 0, 255));
            bt.Click     += OnClicked;
            sta.Children.Add(image);
            sta.Children.Add(bt);

            //instantiate a page
            page = new Windows.UI.Xaml.Controls.Page();
            //add content to a page
            page.Content = sta;

            //put this page to this custom render as a children
            //must add content to the renderer,the content can be a stackpanel or the page or the image

            //a control only can be add into a contain control such as,if the image control add to the stackpanel ,
            //it can not be added to page.content or this render.content
            this.Children.Add(page);
        }
Пример #13
0
        private async void Msdock_DockDeviceInitialized(object sender, EventArgs e)
        {
            var dockDevice = Program.msdock.DockDevice;

            string protocolver = await DoStringRequest(dockDevice, DataType.Request, 0x01, QueryType.ProtocolVersion);

            if (protocolver != "1.1")
            {
                //Console.WriteLine("Unsupported protocol version! Update your device.");
                return;
            }

            int frameSize = await DoIntRequest(dockDevice, DataType.Request, 0x01, QueryType.FrameSize);

            if (frameSize != 64)
            {
                //Console.WriteLine("Unsupported frame size! Update your device.");
                return;
            }

            string devicetype = await DoStringRequest(dockDevice, DataType.Request, 0x02, QueryType.DeviceType);

            string hwversion = await DoStringRequest(dockDevice, DataType.Request, 0x03, QueryType.HwVersion);

            hwversion = hwversion.Substring(0, hwversion.Length - 1);

            int swloc = await DoIntRequest(dockDevice, DataType.Request, 0x04, QueryType.MunchkinSWLocation);

            MunchkinContent content = (MunchkinContent)swloc;

            string swver = await DoVersionRequest(dockDevice, DataType.Request, 0x05, QueryType.SwVersion);

            string Anx7737FW = await DoVersionRequest(dockDevice, DataType.Request, 0x06, QueryType.Anx7737FWVersion);

            string Anx7750FW = await DoVersionRequest(dockDevice, DataType.Request, 0x07, QueryType.Anx7750FWVersion);

            var xaml = Properties.Resources.Flyout;

            xaml = xaml.Replace("$CONNECTIONSTATUS", "Connected");
            xaml = xaml.Replace("$PROTOCOLVERSION", protocolver);
            xaml = xaml.Replace("$DEVICENAME", devicetype);
            xaml = xaml.Replace("$DEVICENAME", devicetype);
            xaml = xaml.Replace("$HWVERSION", hwversion);
            xaml = xaml.Replace("$SWLOCATION", content.ToString());
            xaml = xaml.Replace("$SWVERSION", swver);
            xaml = xaml.Replace("$ANX7737FWVERSION", Anx7737FW);
            xaml = xaml.Replace("$ANX7750FWVERSION", Anx7750FW);

            if (sender == this)
            {
                Windows.UI.Xaml.Controls.Page control = (Windows.UI.Xaml.Controls.Page)XamlReader.Load(xaml);

                var maingrid           = control.Content as Windows.UI.Xaml.Controls.Grid;
                var lastgridinmaingrid = maingrid.Children.Last() as Windows.UI.Xaml.Controls.Grid;
                var button             = lastgridinmaingrid.Children[0] as Windows.UI.Xaml.Controls.Button;

                button.Click += Form1_Click;

                windowsXamlHost1.Child = control;
            }
            else
            {
                await windowsXamlHost1.Child.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    Windows.UI.Xaml.Controls.Page control = (Windows.UI.Xaml.Controls.Page)XamlReader.Load(xaml);

                    var maingrid           = control.Content as Windows.UI.Xaml.Controls.Grid;
                    var lastgridinmaingrid = maingrid.Children.Last() as Windows.UI.Xaml.Controls.Grid;
                    var button             = lastgridinmaingrid.Children[0] as Windows.UI.Xaml.Controls.Button;

                    button.Click += Form1_Click;

                    windowsXamlHost1.Child = control;
                });
            }
        }
Пример #14
0
 public View(Windows.UI.Xaml.Controls.Page screen, World world)
 {
     this.screen = screen;
     this.world  = world;
 }
Пример #15
0
 public WindowsPlatform(Windows.UI.Xaml.Controls.Page page) : base(page)
 {
 }
 /// <summary>
 /// Shows a generic informational message to the user.
 /// </summary>
 public static async void ShowMessage(this Windows.UI.Xaml.Controls.Page parent, string message)
 {
     var dialog = new Windows.UI.Popups.MessageDialog(message);
     var result = await dialog.ShowAsync();
 }