示例#1
0
        public void addMenuItem(String text, int ordinal, int priority, int wrapper_callback, int callback, int push_at_start)
        {
            for (int i = 0; i < m_menuItems.Count; i++)
            {
                WazeMenuItem m = (WazeMenuItem)m_menuItems[i];
                if (text.CompareTo(m.ToString()) == 0)
                {
                    return; // item already exists, don't add.
                }
            }

            // Do not add the exit menu item any more - add save logs instead
            if (text.ToLower().Equals("exit") || text.Equals("יציאה") || text.Equals(LanguageResources.Instance.Translate("Quit")))
            {
                System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(LanguageResources.Instance.Translate("Save logs"));
                    appBarMenuItem.Click += (delegate
                    {
                        EmailLogFile(null, null);

                        //Logger.WriteToFile();
                    });
                    ApplicationBar.MenuItems.Add(appBarMenuItem);

                });

                return; // We added the save logs, but we don't want to add the exit item...

                //System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
                //{
                //    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem("Delete Cache");
                //    appBarMenuItem.Click += (delegate
                //    {
                //        TileStorage ts = CRunTime.objectRepository[Syscalls.ts_id] as TileStorage;
                //        if (ts != null)
                //        {
                //            ts.eraseStorage();
                //            ts.initialize();
                //        }
                //        //Logger.WriteToFile();
                //    });
                //    ApplicationBar.MenuItems.Add(appBarMenuItem);

                //});

            }

            WazeMenuItem new_item = new WazeMenuItem(text, ordinal, priority, wrapper_callback, callback);
            if (push_at_start == 1)
            {
                m_menuItems.Insert(0, new_item);
            }
            else
            {
                m_menuItems.Add(new_item);
            }

            bool addMenuItem = true;

            if (text.ToLower().Equals("me on map") || text.Equals("הצג אותי") || text.Equals(LanguageResources.Instance.Translate("Me on map")))
            {
                MeOnMapItem = new_item;

                addIconMenuItem("Resources/compas.png", text, MeOnMapItem);
                addMenuItem = false;
            }
            else if (text.ToLower().Equals("drive to") || text.Equals("נווט") || text.Equals(LanguageResources.Instance.Translate("Drive to")))
            {
                addIconMenuItem("Resources/search.png", text, new_item);
                addMenuItem = false;
            }
            else if (text.ToLower().Equals("report") || text.Equals("דווח") || text.Equals(LanguageResources.Instance.Translate("Report")))
            {
                addIconMenuItem("Resources/i.png", text, new_item);
                Report = new_item;
                addMenuItem = false;
            }
            else if (text.ToLower().Equals("my favorites") || text.Equals("המועדפים שלי") || text.Equals(LanguageResources.Instance.Translate("My favorites")))
            {
                addIconMenuItem("Resources/favorites.png", text, new_item);
                addMenuItem = false;
            }
            else if (text.ToLower().Equals("zoom in") || text.Equals(LanguageResources.Instance.Translate("Zoom In")))
            {
                ZoomIn = new_item;
                addMenuItem = false;
            }
            else if (text.ToLower().Equals("zoom out") || text.Equals(LanguageResources.Instance.Translate("Zoom Out")))
            {
                ZoomOut = new_item;
                addMenuItem = false;
            }
            else if (text.ToLower().Contains("favorites") || text.Equals(LanguageResources.Instance.Translate("Restore Favorites")))
            {
                RestoreFavorites = new_item;
                addMenuItem = false;
            }

            //else if (text.ToLower().Equals("settings") || text.Equals("הגדרות"))
            //{
            //    addIconMenuItem("Resources/appbar.feature.settings.rest.png", text, new_item);
            //    addMenuItem = false;
            //}
            /*
            if (!perf_button_added)
            {
                perf_button_added = true;
                System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem("Save perf data");
                    appBarMenuItem.Click += EmailLogFile;
                    ApplicationBar.MenuItems.Add(appBarMenuItem);
                });

                System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem("Clear perf data");
                    appBarMenuItem.Click += delegate { Syscalls.fis.Clear(); };
                    ApplicationBar.MenuItems.Add(appBarMenuItem);
                });

            }
             */

            /*
            if (!isSendMailAdded)
            {
                isSendMailAdded = true;
                System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem("Email log file");
                    appBarMenuItem.Click += EmailLogFile;
                    ApplicationBar.MenuItems.Add(appBarMenuItem);
                });
            }*/

            if (addMenuItem)
            {
                System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    // Create a new menu item with the localized string from AppResources
                    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(text);
                    if (text.ToLower().Equals("about") || text.Equals("אודות") || text.Equals(LanguageResources.Instance.Translate("About")))
                    {
                        appBarMenuItem.Click += delegate
                        {
                            String s = GetAppVersion();
                            AboutDialog ad = new AboutDialog();
                            ad.SetVersion(s);

                            GamePage.get().GetPopupPanel().Children.Add(ad);
                        };

                        //appBarMenuItem = new ApplicationBarMenuItem("טען מפה");
                        //appBarMenuItem.Click += delegate
                        //{
                        //    UnZipper uz = new UnZipper(Application.GetResourceStream(new Uri("/WazeWP7;component/resources/tel_aviv_till_hod_hasharon.zip", UriKind.Relative)).Stream);
                        //    foreach (string filename in uz.FileNamesInZip)
                        //    {
                        //        Stream st = uz.GetFileStream(filename);
                        //        Syscalls.CopyFileFromStream(st, filename);
                        //    }

                        //    Syscalls.NOPH_TileStorage_initialize(Syscalls.ts_id);

                        //    MessageBox.Show("Finished");
                        //};
                    }
                    else
                    {
                        appBarMenuItem.Click += (delegate
                        {
                            new_item.CallCallback();
                        });
                    }

                    ApplicationBar.MenuItems.Add(appBarMenuItem);

                });
            }
        }
示例#2
0
        public void addMenuItem(String text, int ordinal, int priority, int wrapper_callback, int callback, int push_at_start)
        {
            for (int i = 0; i < m_menuItems.Count; i++)
            {
                WazeMenuItem m = (WazeMenuItem)m_menuItems[i];
                if (text.CompareTo(m.ToString()) == 0)
                {
                    return; // item already exists, don't add.
                }
            }

            /*            if (text.Equals("Accept"))
                        {
                            int c_on_menuItem = CibylCallTable.getAddressByName("rim_on_menuItem");
                            if (c_on_menuItem != 0)
                            {
                                UIWorker.addUIEvent(c_on_menuItem, wrapper_callback, callback, 0, 0, true);
                            }
                        }*/

            WazeMenuItem new_item = new WazeMenuItem(text, ordinal, priority, wrapper_callback, callback);
            if (push_at_start == 1)
            {
                m_menuItems.Insert(0, new_item);
            }
            else
            {
                m_menuItems.Add(new_item);
            }

            System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
            {

                // Create a new menu item with the localized string from AppResources
                ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(text);
                if (text.ToLower().Equals("About") || text.Equals("אודות"))
                {
                    appBarMenuItem.Click += delegate
                    {
                        string name = System.Reflection.Assembly.GetExecutingAssembly().FullName;
                        System.Reflection.AssemblyName asmName = new System.Reflection.AssemblyName(name);

                        //System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
                        Version version = asmName.Version;
                        String s = String.Format("{0}.{1}.{2}.{3}",
                                                            version.Major,
                                                            version.Minor,
                                                            version.Build,
                                                            version.Revision);
                        AboutDialog ad = new AboutDialog();
                        ad.SetVersion(s);

                        FreeMapMainScreen.get().LayoutRoot.Children.Add(ad);
                    };
                    ApplicationBar.MenuItems.Add(appBarMenuItem);

                    appBarMenuItem = new ApplicationBarMenuItem("טען מפה");
                    appBarMenuItem.Click += delegate
                    {
            /*                        TileStorage ts = (TileStorage)CRunTime.objectRepository[Syscalls.ts_id];
                        UnZipper uz = new UnZipper(Application.GetResourceStream(new Uri("/WazeWP7;component/resources/tiles.zip", UriKind.Relative)).Stream);
                        int index = 0;
                        foreach (string filename in uz.FileNamesInZip)
                        {
                            int tile_index = int.Parse(filename);
                            Stream st = uz.GetFileStream(filename);
                            BinaryReader br = new BinaryReader(st);
                            byte[] tile_bytes = new byte[st.Length];
                            br.Read(tile_bytes, 0, tile_bytes.Length);
                            ts.storeTileEx(77001, tile_index, tile_bytes);
                            index++;
                        }*/

                        UnZipper uz = new UnZipper(Application.GetResourceStream(new Uri("/WazeWP7;component/resources/tel_aviv_till_hod_hasharon.zip", UriKind.Relative)).Stream);
                        foreach (string filename in uz.FileNamesInZip)
                        {
                            Stream st = uz.GetFileStream(filename);
                            Syscalls.CopyFileFromStream(st, filename);
                        }

                        Syscalls.NOPH_TileStorage_initialize(Syscalls.ts_id);

                        /*
                        StreamResourceInfo info = Application.GetResourceStream(new Uri("/WazeWP7;component/resources/tiles/file_list.txt", UriKind.Relative));
                        using (StreamReader reader = new StreamReader(info.Stream))
                        {
                            string line = reader.ReadLine();
                            while (line != null)
                            {
                                int tile_index = int.Parse(line);
                                Stream tile = Application.GetResourceStream(new Uri("/WazeWP7;component/resources/tiles/" + line, UriKind.Relative)).Stream;
                                BinaryReader br = new BinaryReader(tile);
                                byte[] tile_bytes = new byte[tile.Length];
                                br.Read(tile_bytes, 0, tile_bytes.Length);
                                ts.storeTileEx(77001, tile_index, tile_bytes);
                                line = reader.ReadLine();
                            }
                        }*/
                        MessageBox.Show("Finished");

                    };
                }
                else
                {
                    appBarMenuItem.Click += (delegate
                    {
                        new_item.CallCallback();
                    });
                }
                ApplicationBar.MenuItems.Add(appBarMenuItem);
            });

            if (text.ToLower().Equals("me on map") || text.Equals("הצג אותי"))
            {
                MeOnMapItem = new_item;

                ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("Resources/compas.png", UriKind.Relative));
                appBarButton.Text = "Me on map";
                appBarButton.IconUri = new Uri("Resources/compas.png", UriKind.Relative);
                appBarButton.Click += delegate
                {
                    new_item.CallCallback();
                };
                System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    ApplicationBar.Buttons.Add(appBarButton);
                });

            }

            if (text.ToLower().Equals("drive to") || text.Equals("נווט"))
            {
                ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("Resources/search.png", UriKind.Relative));
                appBarButton.Text = "Navigate";
                appBarButton.IconUri = new Uri("Resources/search.png", UriKind.Relative);
                appBarButton.Click += delegate
                {
                    new_item.CallCallback();
                };
                System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    ApplicationBar.Buttons.Add(appBarButton);
                });

            }

            //if (text.ToLower().Equals("stop navigation") || text.Equals("הפסק ניווט"))
            //{
            //    ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("Resources/cancel.png", UriKind.Relative));
            //    appBarButton.Text = "Navigate";
            //    appBarButton.IconUri = new Uri("Resources/cancel.png", UriKind.Relative);
            //    appBarButton.Click += delegate
            //    {
            //        new_item.CallCallback();
            //    };
            //    System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
            //    {
            //        ApplicationBar.Buttons.Add(appBarButton);
            //    });

            //}

            if (text.ToLower().Equals("report") || text.Equals("דווח"))
            {
                ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("Resources/i.png", UriKind.Relative));
                appBarButton.Text = "Report";
                appBarButton.IconUri = new Uri("Resources/i.png", UriKind.Relative);
                appBarButton.Click += delegate
                {
                    new_item.CallCallback();
                };

                System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    ApplicationBar.Buttons.Add(appBarButton);
                });

            }

            if (text.ToLower().Equals("Saved locations") || text.Equals("מקומות שמורים"))
            //if (text.ToLower().Equals("exit") || text.Equals("יציאה"))
            {
                ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("Resources/favorites.png", UriKind.Relative));
                appBarButton.Text = "Saved Locs";
                appBarButton.IconUri = new Uri("Resources/favorites.png", UriKind.Relative);
                appBarButton.Click += delegate
                {
                    new_item.CallCallback();

                    //MessageBoxResult res = MessageBox.Show("Are you sure you want to exit", "Exit", MessageBoxButton.OKCancel);
                    //if (res == MessageBoxResult.OK)
                    //    new_item.CallCallback();
                };

                System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    ApplicationBar.Buttons.Add(appBarButton);
                });

            }

            /*
            if (!perf_button_added)
            {
                perf_button_added = true;
                System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem("Save perf data");
                    appBarMenuItem.Click += EmailLogFile;
                    ApplicationBar.MenuItems.Add(appBarMenuItem);
                });

                System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem("Clear perf data");
                    appBarMenuItem.Click += delegate { Syscalls.fis.Clear(); };
                    ApplicationBar.MenuItems.Add(appBarMenuItem);
                });

            }
             */

            /*
            if (!isSendMailAdded)
            {
                isSendMailAdded = true;
                System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem("Email log file");
                    appBarMenuItem.Click += EmailLogFile;
                    ApplicationBar.MenuItems.Add(appBarMenuItem);
                });
            }*/
        }