コード例 #1
0
        private void InitializeCommands(WebViewer element)
        {
            element.Refresh = () =>
            {
                ((UIWebView)NativeView).Reload();
            };

            element.GoBack = () =>
            {
                var control = ((UIWebView)NativeView);
                if (control.CanGoBack)
                {
                    control.GoBack();
                }
            };

            element.CanGoBackFunction = () =>
            {
                return(((UIWebView)NativeView).CanGoBack);
            };

            var ctl = ((UIWebView)NativeView);

            ctl.ScalesPageToFit = true;
        }
コード例 #2
0
        private void InitializeCommands(WebViewer element)
        {
            /*
             *          element.RefreshCommand = new Command(() =>
             *          {
             *                  ((UIWebView)NativeView).Reload();
             *          });
             *
             *          element.GoBackCommand = new Command(() =>
             *          {
             *                  var control = ((UIWebView)NativeView);
             *                  if (control.CanGoBack)
             *                  {
             *                          element.IsBackNavigating = true;
             *                          control.GoBack();
             *                  }
             *          });*/

            element.CanGoBackFunction = () =>
            {
                return(((UIWebView)NativeView).CanGoBack);
            };

            var ctl = ((UIWebView)NativeView);

            ctl.ScalesPageToFit = true;
        }
コード例 #3
0
        /// <summary>
        /// Will wire up the commands in the WebViewer control to the native method calls
        /// </summary>
        /// <param name="element"></param>
        private void InitializeCommands(WebViewer element)
        {
            element.RefreshCommand = new Command(() =>
            {
                Control?.Reload();
            });

            element.GoBackCommand = new Command(() =>
            {
                var ctrl = Control;
                if (ctrl == null)
                {
                    return;
                }

                if (ctrl.CanGoBack())
                {
                    ctrl.GoBack();
                }
            });

            element.CanGoBackFunction = () =>
            {
                var ctrl = Control;
                if (ctrl == null)
                {
                    return(false);
                }

                return(ctrl.CanGoBack());
            };

            // This allows you to show a file chooser dialog from the WebView
            Control.SetWebChromeClient(new WebViewChromeClient((uploadMsg, acceptType, capture) =>
            {
                MainActivity.UploadMessage = uploadMsg;
                if (Build.VERSION.SdkInt < BuildVersionCodes.Kitkat)
                {
                    var i = new Intent(Intent.ActionGetContent);

                    //To set all type of files
                    i.SetType("image/*");

                    //Here File Chooser dialog is started as Activity, and it gives result while coming back from that Activity.
                    ((MainActivity)this.Context).StartActivityForResult(Intent.CreateChooser(i, "File Chooser"), MainActivity.FILECHOOSER_RESULTCODE);
                }
                else
                {
                    var i = new Intent(Intent.ActionOpenDocument);
                    i.AddCategory(Intent.CategoryOpenable);

                    //To set all image file types. You can change to whatever you need
                    i.SetType("image/*");

                    //Here File Chooser dialog is started as Activity, and it gives result while coming back from that Activity.
                    ((MainActivity)this.Context).StartActivityForResult(Intent.CreateChooser(i, "File Chooser"), MainActivity.FILECHOOSER_RESULTCODE);
                }
            }));
        }
コード例 #4
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            var path = String.Format("https://stackexchange.com/oauth/dialog?client_id={0}&scope=read_inbox&redirect_uri={1}", App.ClientId, App.RedirectUri);

            WebViewer.Navigate(new Uri(path));
        }
コード例 #5
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            var site = (e.Parameter as Dictionary <string, string>)["site"];

            WebViewer.Navigate(new Uri(site));
        }
コード例 #6
0
    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        base.OnNavigatedTo(e);
        var currentView = SystemNavigationManager.GetForCurrentView();

        currentView.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
        SystemNavigationManager.GetForCurrentView().BackRequested += WebViewPage_BackRequested;
        var site = (e.Parameter as Dictionary <string, string>)["site"];

        WebViewer.Navigate(new Uri(site));
    }
コード例 #7
0
        private void Model_OnMouseDown(object sender, MouseButtonEventArgs e)
        {
            var button = sender as Border;

            if (button == null)
            {
                return;
            }
            var view = new WebViewer($"http:\\localhost\\locations\\{button.Tag}\\3d model\\start.html");

            view.ShowDialog();
        }
コード例 #8
0
 private void WebViewPage_BackRequested(object sender, BackRequestedEventArgs e)
 {
     //always try to go back within the WebView first, then try the frame!
     if (this.Frame.CanGoBack)
     {
         if (WebViewer.CanGoBack)
         {
             WebViewer.GoBack();
             e.Handled = true;
         }
         else
         {
             WebViewer.NavigateToString("<html>Unloaded.</html>");
             WebViewer.NavigateToString("");
             var source = WebViewer.Source;     // is cleared to null
             Frame.GoBack();
             e.Handled = true;
         }
     }
 }
コード例 #9
0
        public WebViewPage()
        {
            this.InitializeComponent();

            Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += (s, a) =>
            {
                // always try to go back within the WebView first, then try the frame!
                if (WebViewer.CanGoBack)
                {
                    WebViewer.GoBack();
                    a.Handled = true;
                }
                else
                {
                    WebViewer.NavigateToString("<html>Unloaded.</html>");
                    WebViewer.NavigateToString("");
                    var source = WebViewer.Source; // is cleared to null
                }
            };
        }
コード例 #10
0
        /// <summary>
        /// Will wire up the commands in the WebViewer control to the native method calls
        /// </summary>
        /// <param name="element"></param>
        private void InitializeCommands(WebViewer element)
        {
            element.Refresh = () =>
            {
                Control.Refresh();
            };

            element.GoBack = () =>
            {
                if (Control.CanGoBack)
                {
                    Control.GoBack();
                }
            };

            element.CanGoBackFunction = () =>
            {
                return(Control.CanGoBack);
            };
        }
コード例 #11
0
        public BimPlusViewerPort(string name, PortTypes portType, Type type, Core.VplControl hostCanvas)
            : base(name, portType, type, hostCanvas)
        {
            _dataController = DataController.Instance;

            if (_dataController.IntBase == null)
            {
                return;
            }

            _webViewer = new WebViewer(_dataController.IntBase);
            ViewerGrid = new Grid()
            {
                Height = 600,
                Width  = 400
            };
            ViewerGrid.Children.Add(_webViewer);

            SetAllowTransparencyForPopup(false);
            AddPopupContent(ViewerGrid);

            DataChanged += OnDataChanged;
        }
コード例 #12
0
        public void LoadContent(IntegrationBase integrationBase, WPFWindows.Window parent)
        {
            _integrationBase = integrationBase;
            _integrationBase.EventHandlerCore.DataLoaded += EventHandlerCore_DataLoaded;
            _parentWindow = parent;

            _webViewer = new WebViewer(integrationBase);
            NavigateToControl();

            _model = GetConnectionsModel(false);

            if (_model != null)
            {
                DeleteModelAndObject.IsEnabled = true;
                if (_savedDtoConnectionsId != null && _savedDtoConnectionsId != Guid.Empty)
                {
                    DeleteConnection.IsEnabled = true;
                    CreateConnection.IsEnabled = false;
                }
            }

            BimExplorer.Content = _webViewer;
        }
コード例 #13
0
        /// <summary>
        /// Load start properties and controls.
        /// </summary>
        /// <param name="integrationBase"></param>
        /// <param name="parent"></param>
        public void LoadContent(IntegrationBase integrationBase)
        {
            _integrationBase = integrationBase;

            _integrationBase.EventHandlerCore.IssueViewSelected += EventHandlerCore_IssueViewSelected;
            _integrationBase.EventHandlerCore.IssueSelected     += EventHandlerCore_IssueSelected;
            _integrationBase.EventHandlerCore.ObjectSelected    += EventHandlerCore_ObjectSelected;
            _integrationBase.EventHandlerCore.ProjectChanged    += EventHandlerCore_ProjectChanged;
            _integrationBase.EventHandlerCore.DataLoaded        += EventHandlerCore_DataLoaded;

            _webViewer = new WebViewer(integrationBase);

            _webViewer.NavigateToControl(integrationBase.CurrentProject.Id);
            _webViewer.LoadCompleted += webViewer_LoadCompleted;

            BimExplorer.Content = _webViewer;

            _listControl = new IssueListControl(integrationBase);
            _listControl.LoadCompleted += listControl_LoadCompleted;
            IssueList.Content           = _listControl;

            _detailsControl      = new IssueDetailsControl(integrationBase);
            IssueDetails.Content = _detailsControl;
        }
コード例 #14
0
        public WebViewerView(BrowserType type, IBrowserParentPage parentPage = null, bool withTopMargin = false, bool isExternal     = false,
                             Orientation orientation = Orientation.Portrait, bool fullScreen            = false, bool showTitlePanel = true)
        {
            InitializeComponent();

            this.Orientation = orientation;

            if (Device.RuntimePlatform == Device.iOS)
            {
                Browser = new WebViewer(orientation, fullScreen)
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.FillAndExpand
                };
                slWebContainer.Children.Add(Browser);
            }
            else
            {
                var container = new WebviewContainer()
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.FillAndExpand,
                };
                container.WebViewer = new WebViewer(orientation, fullScreen);
                Browser             = container.WebViewer;
                slWebContainer.Children.Add(container);
            }

            Browser.BrowserType      = type;
            Browser.ParentPage       = parentPage;
            Browser.IsExternal       = isExternal;
            Browser.PropertyChanged += Browser_PropertyChanged;
            if (withTopMargin && Device.RuntimePlatform == Device.iOS)
            {
                Content.Margin = new Thickness(0, 20, 0, 0);
            }

            BindingContext = this;



            var tapGesture = new TapGestureRecognizer()
            {
                NumberOfTapsRequired = 2
            };

            lblTitle.GestureRecognizers.Add(tapGesture);
            lblTitleView.GestureRecognizers.Add(tapGesture);
            tapGesture.Tapped += TapGesture_Tapped;

            // this.OnTitleTripleTapped += () => AppContentPage.Instance.WVTitleTripleClicked(this);

            // var tapGesture2= new TapGestureRecognizer();
            // lblTitle.GestureRecognizers.Add(tapGesture2);
            //  lblTitleView.GestureRecognizers.Add(tapGesture2);
            // tapGesture2.Tapped += TapGesture_Tapped1; ;
            if (!showTitlePanel)
            {
                rd0.Height             = 0;
                lblTitleView.IsVisible = false;
            }
        }
コード例 #15
0
        private void openFileViewer(Int32 fileID)
        {
            string connectionStringPBox  = DBSource.ConnectionStringPBox;
            string connectionStringPData = DBSource.ConnectionStringPData;
            string commandText           = @"SELECT file_id,file_name,file_type,file_size,file_nodeid FROM FileMemo where file_id = " + fileID;

            helperPBox = new dBHelper(connectionStringPBox);
            if (helperPBox.Load(commandText, "") == true)
            {
                if (fileID > 0 && helperPBox.DataSet.Tables[0].Rows.Count > 0)
                {
                    DataRow       dataRow    = helperPBox.DataSet.Tables[0].Select("file_id=" + fileID)[0];
                    string        filename   = dataRow["file_name"].ToString();
                    string        filetype   = dataRow["file_type"].ToString();
                    List <Byte[]> l_fileData = new FileDBHelper().getFileData(fileID);
                    if (l_fileData.Count == 0)
                    {
                        MessageBoxEx.Show("找不到对应数据文件!");
                        return;
                    }
                    SkinTabPage tp = new SkinTabPage();
                    tp.Text = filename;
                    switch (filetype)
                    {
                    case ".jpg":
                    case ".png":
                    case ".bmp":
                    case ".gif":
                    {
                        if (Directory.Exists(Application.StartupPath + "\\temp") == false)
                        {
                            Directory.CreateDirectory(Application.StartupPath + "\\temp");
                        }
                        FileStream fs;
                        FileInfo   fi = new FileInfo(Application.StartupPath + "\\temp\\" + filename + filetype);
                        if (!fi.Exists || !IsFileInUse(fi.FullName))
                        {
                            fs = fi.OpenWrite();
                            for (int i = 0; i < l_fileData.Count; i++)
                            {
                                fs.Write(l_fileData[i], 0, l_fileData[i].Length);
                            }
                            fs.Close();
                            try
                            {
                                Bitmap    bmap         = new Bitmap(Application.StartupPath + "\\temp\\" + filename + filetype);
                                PicViewer uc_picviewer = new PicViewer();
                                uc_picviewer.showPic(filename, bmap);
                                uc_picviewer.Dock = DockStyle.Fill;
                                tp.Controls.Add(uc_picviewer);
                                tabControl_Viewer.TabPages.Add(tp);
                            }
                            catch (Exception exp) { }
                        }
                        break;
                    }

                    case ".doc":
                    case ".docx":
                    case ".xls":
                    case ".xlsx":
                    case ".ppt":
                    case ".pptx":
                    {
                        if (Directory.Exists(Application.StartupPath + "\\temp") == false)
                        {
                            Directory.CreateDirectory(Application.StartupPath + "\\temp");
                        }
                        FileStream fs;
                        FileInfo   fi = new FileInfo(Application.StartupPath + "\\temp\\" + filename + filetype);
                        if (!fi.Exists || !IsFileInUse(fi.FullName))
                        {
                            fs = fi.OpenWrite();
                            for (int i = 0; i < l_fileData.Count; i++)
                            {
                                fs.Write(l_fileData[i], 0, l_fileData[i].Length);
                            }
                            fs.Close();
                            DocViewer uc_docviewer = new DocViewer();
                            tp.Tag            = uc_docviewer;
                            uc_docviewer.Dock = DockStyle.Fill;
                            tp.Controls.Add(uc_docviewer);
                            tabControl_Viewer.TabPages.Add(tp);
                            uc_docviewer.openFile(Application.StartupPath + "\\temp\\" + filename + filetype);
                        }
                        break;
                    }

                    case ".txt":
                    case ".sql":
                    case ".log":
                    {
                        if (Directory.Exists(Application.StartupPath + "\\temp") == false)
                        {
                            Directory.CreateDirectory(Application.StartupPath + "\\temp");
                        }
                        FileStream fs;
                        FileInfo   fi = new FileInfo(Application.StartupPath + "\\temp\\" + filename + filetype);
                        if (!fi.Exists || !IsFileInUse(fi.FullName))
                        {
                            fs = fi.OpenWrite();
                            for (int i = 0; i < l_fileData.Count; i++)
                            {
                                fs.Write(l_fileData[i], 0, l_fileData[i].Length);
                            }
                            fs.Close();
                            StreamReader sr        = new StreamReader(Application.StartupPath + "\\temp\\" + filename + filetype, Encoding.Default);
                            TxtViewer    txtViewer = new TxtViewer();
                            txtViewer.Dock = DockStyle.Fill;
                            tp.Controls.Add(txtViewer);
                            tabControl_Viewer.TabPages.Add(tp);
                            txtViewer.showTxt(sr.ReadToEnd());
                            sr.Close();
                        }
                        break;
                    }

                    case ".htm":
                    case ".html":
                    case ".mht":
                    {
                        if (Directory.Exists(Application.StartupPath + "\\temp") == false)
                        {
                            Directory.CreateDirectory(Application.StartupPath + "\\temp");
                        }
                        FileStream fs;
                        FileInfo   fi = new FileInfo(Application.StartupPath + "\\temp\\" + filename + filetype);
                        if (!fi.Exists || !IsFileInUse(fi.FullName))
                        {
                            fs = fi.OpenWrite();
                            for (int i = 0; i < l_fileData.Count; i++)
                            {
                                fs.Write(l_fileData[i], 0, l_fileData[i].Length);
                            }
                            fs.Close();
                            WebViewer webViewer = new WebViewer();
                            webViewer.Dock = DockStyle.Fill;
                            tp.Controls.Add(webViewer);
                            tabControl_Viewer.TabPages.Add(tp);
                            webViewer.openFile(Application.StartupPath + "\\temp\\" + filename + filetype);
                        }
                        break;
                    }

                    case ".pdf":
                    {
                        if (Directory.Exists(Application.StartupPath + "\\temp") == false)
                        {
                            Directory.CreateDirectory(Application.StartupPath + "\\temp");
                        }
                        FileStream fs;
                        FileInfo   fi = new FileInfo(Application.StartupPath + "\\temp\\" + filename + filetype);
                        if (!fi.Exists || !IsFileInUse(fi.FullName))
                        {
                            fs = fi.OpenWrite();
                            for (int i = 0; i < l_fileData.Count; i++)
                            {
                                fs.Write(l_fileData[i], 0, l_fileData[i].Length);
                            }
                            fs.Close();
                            PDFViewer pdfViewer = new PDFViewer();
                            pdfViewer.Dock = DockStyle.Fill;
                            tp.Controls.Add(pdfViewer);
                            tabControl_Viewer.TabPages.Add(tp);
                            pdfViewer.openFile(Application.StartupPath + "\\temp\\" + filename + filetype);
                        }
                        break;
                    }

                    case ".mp4":
                    case ".avi":
                    case ".rm":
                    case ".rmvb":
                    case ".flv":
                    case ".xr":
                    case ".wmv":
                    {
                        if (Directory.Exists(Application.StartupPath + "\\temp") == false)
                        {
                            Directory.CreateDirectory(Application.StartupPath + "\\temp");
                        }
                        FileStream fs;
                        FileInfo   fi = new FileInfo(Application.StartupPath + "\\temp\\" + filename + filetype);
                        if (!fi.Exists || !IsFileInUse(fi.FullName))
                        {
                            fs = fi.OpenWrite();
                            for (int i = 0; i < l_fileData.Count; i++)
                            {
                                fs.Write(l_fileData[i], 0, l_fileData[i].Length);
                            }
                            fs.Close();
                        }
                        FrmPlayer aplayer = new FrmPlayer();
                        aplayer.Text = filename;
                        aplayer.Show();
                        aplayer.openFile(Application.StartupPath + "\\temp\\" + filename + filetype);
                        break;
                    }
                    }
                    tabControl_Viewer.SelectedTab = tp;
                }
            }
        }
コード例 #16
0
ファイル: WebViewer.cs プロジェクト: Avatarchik/SJ_Modeler
 void Awake()
 {
     web = this;
 }
コード例 #17
0
        public void LoadRateCards()
        {
            if (RateCards.Any())
            {
                return;
            }

            var files = _rootFolder.GetLocalFiles().ToList();

            foreach (var rateCardFile in files.Select(f => new FileInfo(f.LocalPath)))
            {
                IRateCardViewer rateCard;
                switch (rateCardFile.Extension.ToLower())
                {
                case ".pdf":
                    try
                    {
                        rateCard = new PDFViewer(rateCardFile);
                    }
                    catch
                    {
                        rateCard = new DefaultViewer(rateCardFile);
                    }
                    break;

                case ".xls":
                case ".xlsx":
                    try
                    {
                        rateCard = new ExcelViewer(rateCardFile);
                    }
                    catch
                    {
                        rateCard = new DefaultViewer(rateCardFile);
                    }
                    break;

                case ".doc":
                case ".docx":
                    try
                    {
                        rateCard = new WordViewer(rateCardFile);
                    }
                    catch
                    {
                        rateCard = new DefaultViewer(rateCardFile);
                    }
                    break;

                case ".txt":
                    try
                    {
                        rateCard = new WebViewer(rateCardFile);
                    }
                    catch
                    {
                        rateCard = new DefaultViewer(rateCardFile);
                    }
                    break;

                default:
                    rateCard = new DefaultViewer(rateCardFile);
                    break;
                }
                RateCards.Add(rateCard);
            }
            RateCardContainer.xtraTabControlRateCards.TabPages.AddRange(RateCards.Select(x => x as XtraTabPage).ToArray());
        }