Esempio n. 1
0
        public void ConnectTo(DnsEndPoint hostEntry)
        {
            _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            SocketError          _lastError      = SocketError.NotConnected;
            SocketAsyncEventArgs socketEventArgs = new SocketAsyncEventArgs();

            socketEventArgs.RemoteEndPoint = hostEntry;
            socketEventArgs.Completed     += new EventHandler <SocketAsyncEventArgs>(delegate(object s, SocketAsyncEventArgs e)
            {
                _lastError = e.SocketError;
                _End();
                // Install read and write handler
                _socketReadEventArgs = new SocketAsyncEventArgs();
                _socketReadEventArgs.RemoteEndPoint = _socket.RemoteEndPoint;
                _socketReadEventArgs.SetBuffer(new byte[MAX_BUFFER_SIZE], 0, MAX_BUFFER_SIZE);
                _socketReadEventArgs.Completed += new EventHandler <SocketAsyncEventArgs>(_AsyncCallComplete);

                _socketWriteEventArgs = new SocketAsyncEventArgs();
                _socketWriteEventArgs.RemoteEndPoint = _socket.RemoteEndPoint;
                _socketWriteEventArgs.Completed     += new EventHandler <SocketAsyncEventArgs>(_AsyncCallComplete);
            });

            // async connect
            _Reset();
            _socket.ConnectAsync(socketEventArgs);
            _BlockUI();

            if (_lastError != SocketError.Success)
            {
                // connection failed
                throw new Exception(String.Format(LocalizedStrings.Get("Net_StreamSocket_ConnectFailed"), hostEntry, _lastError.ToString()));
            }
        }
        private async void FindCurrentLocationAnRestaurantsNearby()
        {
            BeforeLoading();

            Geolocator geolocator = new Geolocator();

            geolocator.DesiredAccuracyInMeters = 50;
            if (geolocator.LocationStatus == PositionStatus.Disabled)
            {
                AfterLoading();
                MessageBox(LocalizedStrings.Get("NearByRestaurantPage_LocationDisabled"));
            }
            else
            {
                try
                {
                    // Getting Current Location
                    _geoposition = await geolocator.GetGeopositionAsync(
                        maximumAge : TimeSpan.FromMinutes(5),
                        timeout : TimeSpan.FromSeconds(10));

                    DownloadNearbyRestaurant("" + _geoposition.Coordinate.Point.Position.Latitude, "" + _geoposition.Coordinate.Point.Position.Longitude);
                }
                catch (UnauthorizedAccessException)
                {
                    AfterLoading();
                    MessageBox(LocalizedStrings.Get("NearByRestaurantPage_LocationDisabled"));
                }
            }
        }
        public static void Create()
        {
            Current = new ScoreboardDialog();

            TextBlock title = new TextBlock()
            {
                Text = LocalizedStrings.Get(LocalizedString.Scoreboard), Style = App.Current.Resources["TitleStyle"] as Style
            };
            StackPanel panel  = new StackPanel();
            StackPanel Scores = new StackPanel();

            int i = 1;

            foreach (var item in Database.Current.Scoreboard)
            {
                Scores.Children.Add(GetScoresGrid(item, i++));
            }

            ScrollViewer scroll = new ScrollViewer()
            {
                Height = 250
            };

            scroll.Content = Scores;
            panel.Children.Add(title);
            panel.Children.Add(scroll);

            Current.Children.Add(panel);
        }
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     tbFeedbackTitle.Text = LocalizedStrings.Get(LocalizedString.FeedbackTitle);
     tbFeedbackText.Text  = LocalizedStrings.Get(LocalizedString.FeedbackText);
     tbName.Text          = LocalizedStrings.Get(LocalizedString.YourName);
     tbEmail.Text         = LocalizedStrings.Get(LocalizedString.YourEmail);
     tbMessage.Text       = LocalizedStrings.Get(LocalizedString.YourMessage);
     btnSend.Content      = LocalizedStrings.Get(LocalizedString.SendButton);
     btnCancel.Content    = LocalizedStrings.Get(LocalizedString.CancelButton);
 }
Esempio n. 5
0
        public static void Create()
        {
            Current = new PauseDialog();
            StackPanel sp = new StackPanel()
            {
                VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Stretch
            };

            sp.Background = new SolidColorBrush(Colors.Orange);
            sp.Children.Add(new TextBlock()
            {
                Text = LocalizedStrings.Get(LocalizedString.Paused), Foreground = new SolidColorBrush(Colors.White), FontSize = 45, TextAlignment = TextAlignment.Center
            });
            sp.Children.Add(new TextBlock()
            {
                Text = Game.Current.Point + " " + LocalizedStrings.Get(LocalizedString.Point), Foreground = new SolidColorBrush(Colors.White), FontSize = 30, TextAlignment = TextAlignment.Center
            });
            Image imgPlayAgain = new Image()
            {
                Source = new BitmapImage(new Uri("ms-appx:///assets/play.png")), Width = 76, Height = 76
            };
            TextBlock playText = new TextBlock()
            {
                Foreground = new SolidColorBrush(Colors.White), FontSize = 20, TextAlignment = TextAlignment.Center
            };

            imgPlayAgain.Tapped += (c, r) =>
            {
                //Animations.ButtonAnimation(imgPlayAgain);
                DispatcherTimer timer = new DispatcherTimer();
                timer.Interval = TimeSpan.FromSeconds(1);
                int to = 0;
                playText.Text = string.Format(LocalizedStrings.Get(LocalizedString.PlayTimerText), 3 - to);
                timer.Tick   += (t, k) =>
                {
                    imgPlayAgain.IsTapEnabled = false;
                    if (to == 3)
                    {
                        timer.Stop();
                        GamePanel.Current.HideDialog();
                        Game.Current.ResumeAllBlocks();
                        Game.Current.StartTimer();
                    }
                    else
                    {
                        to++;
                        playText.Text = string.Format(LocalizedStrings.Get(LocalizedString.PlayTimerText), 3 - to);
                    }
                };
                timer.Start();
            };
            sp.Children.Add(imgPlayAgain);
            sp.Children.Add(playText);
            Current.Children.Add(sp);
        }
Esempio n. 6
0
        public static List <Word> GetWords()
        {
            List <Word>   wordList = new List <Word>();
            List <string> words    = LocalizedStrings.Get(LocalizedString.Words).Split(',').ToList();

            foreach (var word in words)
            {
                wordList.Add(CreateWord(word.Trim()));
            }
            return(wordList);
        }
Esempio n. 7
0
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            if (targetType != typeof(string))
            {
                throw new InvalidOperationException("The target must be a string");
            }

            string identifier = value as string;

            if (identifier == null)
            {
                throw new InvalidOperationException("The value must be a string");
            }

            return(LocalizedStrings.Get(identifier));
        }
        private async void Send_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtName.Text))
                {
                    await new MessageDialog(LocalizedStrings.Get(LocalizedString.NameError)).ShowAsync();
                }
                else if (txtMessage.Text.Length < 20)
                {
                    await new MessageDialog(LocalizedStrings.Get(LocalizedString.MessageError)).ShowAsync();
                }
                else
                {
                    IMobileServiceTable <Feedback> feedbackTable = App.MobileService.GetTable <Feedback>();
                    Feedback fb = new Feedback();
                    fb.Name              = txtName.Text;
                    fb.Email             = txtEmail.Text;
                    fb.Message           = txtMessage.Text;
                    fb.DeviceId          = Database.Current.DeviceId;
                    fb.Region            = System.Globalization.RegionInfo.CurrentRegion.EnglishName;
                    fb.Culture           = System.Globalization.CultureInfo.CurrentCulture.EnglishName;
                    txtName.IsEnabled    = false;
                    txtEmail.IsEnabled   = false;
                    txtMessage.IsEnabled = false;
                    btnSend.IsEnabled    = false;
                    btnCancel.IsEnabled  = false;
                    await feedbackTable.InsertAsync(fb);

                    await new MessageDialog(LocalizedStrings.Get(LocalizedString.FeedbackSuccessful)).ShowAsync();
                    this.Frame.Navigate(typeof(GamePage));
                }
            }
            catch (Exception)
            {
                new MessageDialog(LocalizedStrings.Get(LocalizedString.FeedbackError)).ShowAsync();
                txtName.IsEnabled    = true;
                txtEmail.IsEnabled   = true;
                txtMessage.IsEnabled = true;
                btnSend.IsEnabled    = true;
                btnCancel.IsEnabled  = true;
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Returns the Name for the MIME type if exists. If the complete MIME declaration is missing for the given language
        /// it will return the "en"-values. Otherwise it
        /// will return the string for "File_Type_Default"
        /// </summary>
        /// <param name="type">A MIME type</param>
        /// <returns>Translated Name of the MIME type regarding the current language</returns>
        static public string GetNameOf(string type)
        {
            if (_types == null)
            {
                _types = new Dictionary <string, string>();
                Stream stream = null;

                try
                {
                    stream = ResourceLoader.GetStream(String.Format("/Resource/Localization/Mime.{0:g}.xml", CultureInfo.CurrentCulture.ToString().Substring(0, 2)));
                }
                catch (Exception)
                {
                    stream = ResourceLoader.GetStream("/Resource/Localization/Mime.en.xml");
                }

                try
                {
                    XDocument doc = XDocument.Load(stream);
                    foreach (var el in doc.Element("mimelist").Elements("mime"))
                    {
                        string key = el.Attribute("type").Value.ToLower();
                        if (!_types.ContainsKey(key))
                        {
                            _types.Add(el.Attribute("type").Value, el.Value);
                        }
                    }
                }
                catch (Exception)
                {
                }
            }

            try
            {
                return(_types[type.ToLower()]);
            }
            catch (Exception)
            {
                return(LocalizedStrings.Get("File_Type_Default"));
            }
        }
Esempio n. 10
0
 private void LoadMenuItems()
 {
     MenuItems = new ObservableCollection <MenuItemViewModel>();
     MenuItems.Add(new MenuItemViewModel()
     {
         Name = LocalizedStrings.Get("strHome"),
         Type = PageTypes.Home,
         Icon = "ic_home_white_24dp"
     });
     MenuItems.Add(new MenuItemViewModel()
     {
         Name = LocalizedStrings.Get("strRate"),
         Type = PageTypes.Rate,
         Icon = "ic_star_rate_white_18dp"
     });
     MenuItems.Add(new MenuItemViewModel()
     {
         Name = LocalizedStrings.Get("strContact"),
         Type = PageTypes.Contact,
         Icon = "ic_email_white_18dp"
     });
 }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (ConnectionContext.CheckNetworkConnection())
            {
                ((TextBlock)(this.NoConnectionText ?? FindName("NoConnectionText"))).Visibility = Visibility.Collapsed;

                var parameterReceived = e.Parameter;
                if (parameterReceived == null)
                {
                    this.PagerHeader.Label = LocalizedStrings.Get("HotRestaurantPage_Title");
                    DownloadRestaurants((int)ListType.Recommended, "", _currentPage++);
                }
                else
                {
                    _restaurantTag         = parameterReceived as string;
                    this.PagerHeader.Label = _restaurantTag;
                    DownloadRestaurants((int)ListType.Tag, _restaurantTag, _currentPage++);
                }
            }
            else
            {
                ((TextBlock)(this.NoConnectionText ?? FindName("NoConnectionText"))).Visibility = Visibility.Visible;
            }
        }
Esempio n. 12
0
        public static void Create()
        {
            Current = new OptionsDialog();
            StackPanel panel = new StackPanel();

            panel.Children.Add(new TextBlock()
            {
                Text = LocalizedStrings.Get(LocalizedString.Options), Style = App.Current.Resources["TitleStyle"] as Style, Margin = new Thickness(0, 0, 0, 5)
            });
            Grid selectColorPanel = new Grid();

            selectColorPanel.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Auto)
            });
            selectColorPanel.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Auto)
            });
            selectColorPanel.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Auto)
            });
            selectColorPanel.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Auto)
            });
            selectColorPanel.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Auto)
            });
            selectColorPanel.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Auto)
            });
            selectColorPanel.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Auto)
            });
            selectColorPanel.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Auto)
            });
            Border border = new Border()
            {
                BorderThickness = new Thickness(2), BorderBrush = new SolidColorBrush(Colors.White)
            };
            Grid currentGrid = new Grid();
            int  index       = 0;

            foreach (var color in Database.Current.ColorList)
            {
                Grid colorGrid = new Grid()
                {
                    Background = new SolidColorBrush(color), Width = 45, Height = 45, Margin = new Thickness(5)
                };
                if (color == Database.Current.SelectedBackgroundColor)
                {
                    currentGrid = colorGrid;
                    currentGrid.Children.Add(border);
                }
                colorGrid.Tapped += (c, r) =>
                {
                    currentGrid.Children.Remove(border);
                    Database.Current.SelectedBackgroundColor = color;
                    currentGrid = colorGrid;
                    colorGrid.Children.Add(border);
                    Functions.UpdateDatabase();
                };
                Grid.SetRow(colorGrid, index / 6);
                Grid.SetColumn(colorGrid, index % 6);
                selectColorPanel.Children.Add(colorGrid);
                index++;
            }
            panel.Children.Add(new TextBlock()
            {
                Text = LocalizedStrings.Get(LocalizedString.SelectColor), Opacity = .7, FontSize = 20, Foreground = new SolidColorBrush(Colors.White), Margin = new Thickness(0, 10, 0, 10)
            });
            panel.Children.Add(selectColorPanel);
            panel.Children.Add(new TextBlock()
            {
                Text = LocalizedStrings.Get(LocalizedString.WriteName), Opacity = .7, FontSize = 20, Foreground = new SolidColorBrush(Colors.White), Margin = new Thickness(0, 10, 0, 10)
            });
            TextBox tbName = new TextBox()
            {
                Text = Database.Current.Player.Name
            };

            tbName.TextChanged += (c, r) =>
            {
                Database.Current.Player.Name = tbName.Text;
                Functions.UpdateDatabase();
            };
            panel.Children.Add(tbName);
            Current.Children.Add(panel);
        }
 /// <summary>
 /// Translates a string
 /// </summary>
 /// <param name="value">Translation index key</param>
 /// <param name="param">String.Format parameters</param>
 /// <returns></returns>
 public static string Translate(this string key, params object[] param)
 {
     return(string.Format(LocalizedStrings.Get(key), param));
 }
Esempio n. 14
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     btnStart.Content = LocalizedStrings.Get(LocalizedString.StartButton);
 }
Esempio n. 15
0
        public static void Create()
        {
            Current = new AboutDialog();
            Grid grid = new Grid();

            grid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Star)
            });
            grid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Auto)
            });
            StackPanel panel = new StackPanel();

            panel.Children.Add(new TextBlock()
            {
                Text = LocalizedStrings.Get(LocalizedString.About), Style = App.Current.Resources["TitleStyle"] as Style
            });
            panel.Children.Add(new TextBlock()
            {
                Text = LocalizedStrings.Get(LocalizedString.AppName), FontSize = 25
            });
            panel.Children.Add(new TextBlock()
            {
                Text = LocalizedStrings.Get(LocalizedString.VersionText), FontSize = 20, Opacity = .7, Margin = new Thickness(2, 0, 0, 10)
            });
            panel.Children.Add(new TextBlock()
            {
                Text = LocalizedStrings.Get(LocalizedString.AboutText), LineHeight = 30, TextWrapping = TextWrapping.Wrap, FontSize = 20
            });

            Grid buttonPanel = new Grid()
            {
                Margin = new Thickness(0, 0, 0, 16)
            };

            buttonPanel.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });
            buttonPanel.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });
            buttonPanel.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Auto)
            });
            buttonPanel.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Auto)
            });

            Button goTutorial = new Button()
            {
                Content = LocalizedStrings.Get(LocalizedString.GoTutorial), HorizontalAlignment = HorizontalAlignment.Stretch, Margin = new Thickness(0, 0, 0, -5)
            };

            goTutorial.Click += (c, r) =>
            {
                GamePage.CurrentFrame.Navigate(typeof(TutorialPage));
            };

            Button goStore = new Button()
            {
                Content = LocalizedStrings.Get(LocalizedString.GoStore), HorizontalAlignment = HorizontalAlignment.Stretch, Margin = new Thickness(0, 0, 0, -5)
            };

            goStore.Click += (c, r) =>
            {
                GamePage.CurrentFrame.Navigate(typeof(FeedbackPage));
            };
            Grid.SetColumn(goTutorial, 0);
            Grid.SetColumn(goStore, 1);
            Grid.SetRow(goTutorial, 0);
            Grid.SetRow(goStore, 0);

            Button feedbackButton = new Button()
            {
                Content = LocalizedStrings.Get(LocalizedString.SendFeedback), HorizontalAlignment = HorizontalAlignment.Stretch
            };

            feedbackButton.Click += (c, r) =>
            {
                GamePage.CurrentFrame.Navigate(typeof(FeedbackPage));
            };

            Button resetButton = new Button()
            {
                Content = LocalizedStrings.Get(LocalizedString.Reset), HorizontalAlignment = HorizontalAlignment.Stretch
            };

            resetButton.Click += (c, r) =>
            {
                Functions.ResetDatabase();
                Functions.DeleteMyScore();
                GamePage.CurrentFrame.Navigate(typeof(TutorialPage));
            };
            Grid.SetColumn(feedbackButton, 0);
            Grid.SetColumn(resetButton, 1);
            Grid.SetRow(feedbackButton, 1);
            Grid.SetRow(resetButton, 1);
            buttonPanel.Children.Add(goTutorial);
            buttonPanel.Children.Add(goStore);
            buttonPanel.Children.Add(feedbackButton);
            buttonPanel.Children.Add(resetButton);

            Grid.SetRow(panel, 0);
            Grid.SetRow(buttonPanel, 1);
            grid.Children.Add(panel);
            grid.Children.Add(buttonPanel);
            Current.Children.Add(grid);
        }