Beispiel #1
0
        public void createToolBar(int barType, Object barParams)
        {
            m_appMainPage.Dispatcher.BeginInvoke(() =>
            {
                createEmptyToolBar();

                Object[] hashArray = null;
                Hash paramHash     = null;
                object val         = null;

                if (barParams is RubyArray)
                {
                    hashArray = ((RubyArray)barParams).ToArray();
                }
                else
                {
                    paramHash = (Hash)barParams;
                }

                if (paramHash != null && paramHash.TryGetValue(CRhoRuby.CreateSymbol("background_color"), out val))
                {
                    m_appMainPage.ApplicationBar.BackgroundColor = getColorFromString(val.ToString());
                }

                if (paramHash != null && paramHash.TryGetValue(CRhoRuby.CreateSymbol("buttons"), out val) && val is RubyArray)
                {
                    hashArray = ((RubyArray)val).ToArray();
                }

                createToolBarButtons(barType, hashArray);
                setMenuItems(m_menuItems);
                m_barIsStarted = true;
            });
        }
Beispiel #2
0
        private void createToolBarButtons(int barType, Object[] hashArray)
        {
            int bCount = 0;

            for (int i = 0; hashArray != null && i < hashArray.Length; i++)
            {
                if (hashArray[i] != null && hashArray[i] is Hash)
                {
                    String action = null;
                    String icon   = null;
                    String label  = null;
                    object val    = null;

                    Hash values = (Hash)hashArray[i];
                    if (values.TryGetValue(CRhoRuby.CreateSymbol("action"), out val))
                    {
                        action = val.ToString();
                    }
                    if (values.TryGetValue(CRhoRuby.CreateSymbol("icon"), out val))
                    {
                        icon = val.ToString();
                    }
                    if (values.TryGetValue(CRhoRuby.CreateSymbol("label"), out val))
                    {
                        label = val.ToString();
                    }

                    if (label == null && barType == 0)
                    {
                        label = ".";  //Text can not be empty. it's WP7's restriction!!!
                    }
                    if (icon == null) //icon can not be null or empty. so now i don't know how to create separator
                    {
                        icon = getDefaultImagePath(action);
                    }

                    if (icon == null || action == null)
                    {
                        continue;
                    }

                    if (action == "forward" || action == "close")// && RHOCONF().getBool("jqtouch_mode"))
                    {
                        continue;
                    }
                    ApplicationBarIconButton button = new ApplicationBarIconButton(new Uri(icon, UriKind.Relative));
                    button.Text   = label;
                    button.Click += delegate(object sender, EventArgs e) { processToolBarCommand(sender, e, action); };

                    m_appMainPage.ApplicationBar.Buttons.Add(button);
                    //ApplicationBar Allows developers to create and display an application bar
                    //with between 1 and 4 buttons and a set of text menu items
                    //in Windows Phone applications.
                    if (++bCount == 4)
                    {
                        return;
                    }
                }
            }
        }
Beispiel #3
0
        public void writeLogMessage(String strMsg)
        {
            IDictionary <object, object> map = new Dictionary <object, object>();
            Hash values = new Hash(map);

            values.Add(CRhoRuby.CreateSymbol("url"), MutableString.Create(m_URL));
            values.Add(CRhoRuby.CreateSymbol("body"), MutableString.Create(strMsg));
            RhoParams p = new RhoParams(values);

            m_aHttp.addHttpCommand(new CAsyncHttp.HttpCommand("POST", p));
        }
Beispiel #4
0
        public Object findHashParam(String name)
        {
            if (!(m_pParams is Hash))
            {
                return(null);
            }

            Object val    = null;
            Hash   values = (Hash)m_pParams;

            values.TryGetValue(CRhoRuby.CreateSymbol(name), out val);
            return((val != null) ? val : null);
        }
Beispiel #5
0
        public void createTabBar(int tabBarType, Object tabBarParams)
        {
            m_appMainPage.Dispatcher.BeginInvoke(() =>
            {
                /*m_tabControl = new TabControl();
                 * if (tabBarType == 1)
                 *  m_tabControl.TabStripPlacement = Dock.Top;
                 * else if (tabBarType == 3)
                 *  m_tabControl.TabStripPlacement = Dock.Left;*/

                m_tabControl = new Pivot();
                m_tabControl.SelectionChanged += Pivot_OnChanged;

                Object[] hashArray = null;
                Hash paramHash     = null;
                object val         = null;

                if (tabBarParams is RubyArray)
                {
                    hashArray = ((RubyArray)tabBarParams).ToArray();
                }
                else
                {
                    paramHash = (Hash)tabBarParams;
                }

                if (paramHash != null && paramHash.TryGetValue(CRhoRuby.CreateSymbol("background_color"), out val))
                {
                    m_tabControl.Background = new SolidColorBrush(getColorFromString(val.ToString()));
                }

                if (paramHash != null && paramHash.TryGetValue(CRhoRuby.CreateSymbol("tabs"), out val) && val is RubyArray)
                {
                    hashArray = ((RubyArray)val).ToArray();
                }

                createTabBarButtons(tabBarType, hashArray);
                m_tabControl.Margin = new Thickness(0, 70, 0, 0);
                m_layoutRoot.Children.Add(m_tabControl);
                m_masterView.removeBrowser();
            });
        }
Beispiel #6
0
        public static void ShowPopup(RubyModule /*!*/ self, Object args)
        {
            String message = "";
            String title   = "";

            Object[] buttons = null;
            object   val     = null;

            if (args != null && args is MutableString)
            {
                message    = ((MutableString)args).ToString();
                buttons    = new String[1];
                buttons[0] = "Ok";
            }
            if (args != null && args is Hash && ((Hash)args).TryGetValue(CRhoRuby.CreateSymbol("title"), out val))
            {
                title = val.ToString();
            }
            if (args != null && args is Hash && ((Hash)args).TryGetValue(CRhoRuby.CreateSymbol("message"), out val))
            {
                message = val.ToString();
            }
            if (args != null && args is Hash && ((Hash)args).TryGetValue(CRhoRuby.CreateSymbol("callback"), out val))
            {
                m_callback = val.ToString();
            }
            if (args != null && args is Hash && ((Hash)args).TryGetValue(CRhoRuby.CreateSymbol("buttons"), out val) && val is RubyArray)
            {
                buttons = ((RubyArray)val).ToArray();
            }

            RHODESAPP().MainPage.Dispatcher.BeginInvoke(() =>
            {
                m_messagePrompt = new MessagePrompt
                {
                    Title   = title,
                    Message = message
                };
                m_messagePrompt.Completed += messagePrompt_Completed;
                m_messagePrompt.ActionPopUpButtons.Clear();
                for (int i = 0; buttons != null && i < buttons.Length; i++)
                {
                    if (buttons[i] != null)
                    {
                        Button customButton = new Button();
                        if (buttons[i] is Hash)
                        {
                            ((Hash)buttons[i]).TryGetValue(CRhoRuby.CreateSymbol("title"), out val);
                            if (val != null)
                            {
                                customButton.Content = val;
                            }
                        }
                        else
                        {
                            customButton.Content = buttons[i];
                        }
                        customButton.Click += new RoutedEventHandler(customButton_Click);
                        m_messagePrompt.ActionPopUpButtons.Add(customButton);
                    }
                }
                m_messagePrompt.Show();
            });
        }
Beispiel #7
0
        private void createTabBarButtons(int barType, Object[] hashArray)
        {
            for (int i = 0; hashArray != null && i < hashArray.Length; i++)
            {
                if (hashArray[i] != null && hashArray[i] is Hash)
                {
                    String action                   = null;
                    String icon                     = null;
                    String label                    = null;
                    Brush  web_bkg_color            = null;
                    bool   reload                   = false;
                    bool   use_current_view_for_tab = false;
                    object val = null;

                    Hash values = (Hash)hashArray[i];
                    if (values.TryGetValue(CRhoRuby.CreateSymbol("action"), out val))
                    {
                        action = val.ToString();
                    }
                    if (values.TryGetValue(CRhoRuby.CreateSymbol("icon"), out val))
                    {
                        icon = val.ToString();
                    }
                    if (values.TryGetValue(CRhoRuby.CreateSymbol("label"), out val))
                    {
                        label = val.ToString();
                    }
                    if (values.TryGetValue(CRhoRuby.CreateSymbol("reload"), out val))
                    {
                        reload = Convert.ToBoolean(val);
                    }
                    if (values.TryGetValue(CRhoRuby.CreateSymbol("web_bkg_color"), out val))
                    {
                        web_bkg_color = new SolidColorBrush(getColorFromString(val.ToString()));
                    }
                    if (values.TryGetValue(CRhoRuby.CreateSymbol("use_current_view_for_tab"), out val))
                    {
                        use_current_view_for_tab = Convert.ToBoolean(val);
                    }

                    //if (label == null && barType == 0)
                    //    label = ".";//Text can not be empty. it's WP7's restriction!!!

                    if (icon == null)//icon can not be null or empty. so now i don't know how to create separator
                    {
                        icon = getDefaultImagePath(action);
                    }

                    //if (icon == null || action == null)
                    // continue;


                    //PivotItem.Header = "Test";to do
                    //PivotItem PivotItem = new PivotItem();
                    PivotItem PivotItem = new PivotItem();
                    PivotItem.Header = new RhoTabHeader(label, icon);
                    if (i == 0)
                    {// && use_current_view_for_tab)
                        ((Grid)m_masterView.Parent).Children.Remove(m_masterView);
                        m_masterView.Init(m_appMainPage, m_layoutRoot, action, reload, web_bkg_color, i);
                        PivotItem.Content = m_masterView;
                    }
                    else
                    {
                        PivotItem.Content = new RhoView(m_appMainPage, m_layoutRoot, action, reload, web_bkg_color, i);
                    }
                    if (values.TryGetValue(CRhoRuby.CreateSymbol("selected_color"), out val))
                    {
                        PivotItem.Background = new SolidColorBrush(getColorFromString(val.ToString()));
                    }
                    if (values.TryGetValue(CRhoRuby.CreateSymbol("disabled"), out val))
                    {
                        PivotItem.IsEnabled = !Convert.ToBoolean(val);
                    }
                    m_tabControl.Items.Add(PivotItem);
                }
            }
        }