public void tabbarAddTab(string label, string icon, string action, bool disabled, string web_bkg_color, string selected_color, string background_color, bool reload, bool use_current_view_for_tab, bool hasCallback, IMethodResult oResult)
        {
            if (!isUIThread) { Dispatcher.BeginInvoke(delegate() { tabbarAddTab(label, icon, action, disabled, web_bkg_color, selected_color, background_color, reload, use_current_view_for_tab, hasCallback, oResult); }); return; }
            PivotItem tab = new PivotItem();
            TabHeader th = new TabHeader();
            th.Label = label;
            th.Background = th.UnselectedBackground = new SolidColorBrush(
                (background_color != null) && (background_color.Length > 0) ?
                getColorFromString(background_color) :
                Color.FromArgb(255, 0, 0, 0)
                );
            th.SelectedBackground = (selected_color != null) && (selected_color.Length > 0) ?
                new SolidColorBrush(getColorFromString(selected_color)) :
                th.UnselectedBackground;
            th.IconImage = (icon == null) || (icon.Length == 0) ?
                new BitmapImage() : new BitmapImage(new Uri(prependWithSlash(icon), UriKind.Relative));
            tab.Header = th;

            _tabProps[TabbarPivot.Items.Count] = new TabProps();
            _tabProps[TabbarPivot.Items.Count]._isReload = reload;
            if(hasCallback == true)
                _oTabResult = oResult;

            // TODO: implement useCurrentViewForTab
            // throws expection:
            //if (use_current_view_for_tab)
            //{
            //    tab.Content = RhodesWebBrowser;
            //}
            //else
            //{

            WebBrowser wv = new WebBrowser();
            wv.Height = double.NaN;
            wv.Width = double.NaN;
            wv.IsScriptEnabled = true;
            wv.SizeChanged += RhodesWebBrowser_SizeChanged;
            wv.Navigated += RhodesWebBrowser_Navigated;
            wv.NavigationFailed += RhodesWebBrowser_NavigationFailed;
            wv.LoadCompleted += RhodesWebBrowser_LoadCompleted;
            wv.Loaded += RhodesWebBrowser_Loaded;
            wv.Unloaded += RhodesWebBrowser_Unloaded;
            wv.ScriptNotify += RhodesWebBrowser_JSNotify;
            wv.Source = new Uri("about:blank");
            wv.TabIndex = TabbarPivot.Items.Count;
            if ((web_bkg_color != null) && (web_bkg_color.Length > 0))
                wv.Background = new SolidColorBrush(getColorFromString(web_bkg_color));
            //wv.SetValue(FrameworkElement.NameProperty, "tabWeb" + TabbarPivot.Items.Count.ToString());
            //if ((action != null) && (action.Length > 0))
            //    wv.Navigate(new Uri(CRhoRuntime.getInstance().canonicalizeRhoUrl(action)));
            tab.Content = wv;
            //}

            tab.IsEnabled = !disabled;
            tab.Tag = action;
            //tab.SetValue(FrameworkElement.NameProperty, "tabItem" + TabbarPivot.Items.Count.ToString());

            TabbarPivot.Items.Add(tab);
        }
Beispiel #2
0
        public void tabbarAddTab(string label, string icon, string action, bool disabled, string web_bkg_color, string selected_color, string background_color, bool reload, bool use_current_view_for_tab, bool hasCallback, IMethodResult oResult)
        {
            if (!isUIThread)
            {
                Dispatcher.BeginInvoke(delegate() { tabbarAddTab(label, icon, action, disabled, web_bkg_color, selected_color, background_color, reload, use_current_view_for_tab, hasCallback, oResult); }); return;
            }
            PivotItem tab = new PivotItem();
            TabHeader th  = new TabHeader();

            th.Label      = label;
            th.Background = th.UnselectedBackground = new SolidColorBrush(
                (background_color != null) && (background_color.Length > 0) ?
                getColorFromString(background_color) :
                Color.FromArgb(255, 0, 0, 0)
                );
            th.SelectedBackground = (selected_color != null) && (selected_color.Length > 0) ?
                                    new SolidColorBrush(getColorFromString(selected_color)) :
                                    th.UnselectedBackground;
            th.IconImage = (icon == null) || (icon.Length == 0) ?
                           new BitmapImage() : new BitmapImage(new Uri(prependWithSlash(icon), UriKind.Relative));
            tab.Header = th;

            _tabProps[TabbarPivot.Items.Count]           = new TabProps();
            _tabProps[TabbarPivot.Items.Count]._isReload = reload;
            if (hasCallback == true)
            {
                _oTabResult = oResult;
            }

            // TODO: implement useCurrentViewForTab
            // throws expection:
            //if (use_current_view_for_tab)
            //{
            //    tab.Content = RhodesWebBrowser;
            //}
            //else
            //{

            WebBrowser wv = new WebBrowser();

            wv.Height            = double.NaN;
            wv.Width             = double.NaN;
            wv.IsScriptEnabled   = true;
            wv.SizeChanged      += RhodesWebBrowser_SizeChanged;
            wv.Navigated        += RhodesWebBrowser_Navigated;
            wv.NavigationFailed += RhodesWebBrowser_NavigationFailed;
            wv.LoadCompleted    += RhodesWebBrowser_LoadCompleted;
            wv.Loaded           += RhodesWebBrowser_Loaded;
            wv.Unloaded         += RhodesWebBrowser_Unloaded;
            wv.ScriptNotify     += RhodesWebBrowser_JSNotify;
            wv.Source            = new Uri("about:blank");
            wv.TabIndex          = TabbarPivot.Items.Count;
            if ((web_bkg_color != null) && (web_bkg_color.Length > 0))
            {
                wv.Background = new SolidColorBrush(getColorFromString(web_bkg_color));
            }
            //wv.SetValue(FrameworkElement.NameProperty, "tabWeb" + TabbarPivot.Items.Count.ToString());
            //if ((action != null) && (action.Length > 0))
            //    wv.Navigate(new Uri(CRhoRuntime.getInstance().canonicalizeRhoUrl(action)));
            tab.Content = wv;
            //}

            tab.IsEnabled = !disabled;
            tab.Tag       = action;
            //tab.SetValue(FrameworkElement.NameProperty, "tabItem" + TabbarPivot.Items.Count.ToString());

            TabbarPivot.Items.Add(tab);
        }