public OssHttpRequestMessage(Uri endpoint, string bucketName, string key, IDictionary<string, string> _parameters = null)
        {
            if (bucketName != NONEEDBUKETNAME)
            {
                var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
                if (string.IsNullOrEmpty(bucketName))
                {
                    var text = loader.GetString("ExceptionIfArgumentStringIsNullOrEmpty");
                    throw new ArgumentException(text, "bucketName");
                }

                if (!string.IsNullOrEmpty(bucketName) && !OssUtils.IsBucketNameValid(bucketName))
                {
                    var text = loader.GetString("BucketNameInvalid");
                    throw new ArgumentException(text, "bucketName");
                }
            }
            else
            {
                bucketName = "";
            }
            Endpoint = endpoint;
            ResourcePath = "/" + ((bucketName != null) ? bucketName : "") + ((key != null) ? ("/" + key) : "");
            ResourcePathUrl = OssUtils.MakeResourcePath(bucketName, key);
             parameters = _parameters;
             RequestUri = new Uri(BuildRequestUri());
        }
 private void OnDataRequested(DataTransferManager sender, DataRequestedEventArgs args)
 {
     var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
     args.Request.Data.SetText(
         $"{loader.GetString("SendMeFriendRequest/Text")} {_link} {Environment.NewLine} {loader.GetString("SentFromPlayStationApp/Text")}");
     args.Request.Data.Properties.Title = loader.GetString("InviteFriendsToPsn/Text");
 }
Beispiel #3
0
        public async Task<ObservableCollection<Categorie>> GetCategories()
        {
            client.BaseAddress = new Uri(allCategorie);
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            HttpResponseMessage response = await client.GetAsync("");

            if (response.IsSuccessStatusCode)
            {
                string json = await response.Content.ReadAsStringAsync();
                var categoriesResponse = JsonConvert.DeserializeObject<Categorie[]>(json);
                ObservableCollection<Categorie> listCategories = new ObservableCollection<Categorie>();

                foreach (var c in categoriesResponse)
                {
                    Categorie categorie = new Categorie();
                    categorie.CodeCategorie = c.CodeCategorie;
                    categorie.LibelleCategorie = c.LibelleCategorie;
                    listCategories.Add(categorie);
                }
                return listCategories;
            }
            else
            {
                var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
                string str = loader.GetString("noNetwork");
                throw new NoNetworkException(str);
            }
        }
Beispiel #4
0
 private async void SearchBook()
 {
     BookAccess bookAccess = new BookAccess();
     var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
     try
     {
         if (CanExecute() == true)
         {
             var codeCategorie = SelectedCategory.CodeCategorie;
             codeCategorie = codeCategorie.Replace(" ", "_");
             BooksSearch = await bookAccess.GetBookSearch(WordSearch, codeCategorie);
             if(BooksSearch.Count == 0)
             {
                 string str = loader.GetString("NoResult");
                 ShowToast(str);
             }
         }
         else
         {                    
             string str = loader.GetString("Search_Missing");
             throw new EmptyFieldsException(str);
         }
     }
     catch (EmptyFieldsException e)
     {
         ShowToast(e.ErrorMessage);
     }
     catch (NoNetworkException e)
     {
         ShowToast(e.ErrorMessage);
     }
 }
		private async Task SetNameField(Boolean login)
		{
			// If login == false, just update the name field. 
			await App.updateUserName(this.UserNameTextBlock, login);

			// Test to see if the user can sign out.
			Boolean userCanSignOut = true;

			var LCAuth = new LiveAuthClient();
			LiveLoginResult LCLoginResult = await LCAuth.InitializeAsync();

			if (LCLoginResult.Status == LiveConnectSessionStatus.Connected)
			{
				userCanSignOut = LCAuth.CanLogout;
			}

			var loader = new Windows.ApplicationModel.Resources.ResourceLoader();

			if (String.IsNullOrEmpty(UserNameTextBlock.Text) 
				|| UserNameTextBlock.Text.Equals(loader.GetString("MicrosoftAccount/Text")))
			{
				// Show sign-in button.
				SignInButton.Visibility = Visibility.Visible;
				SignOutButton.Visibility = Visibility.Collapsed;
			}
			else
			{
				// Show sign-out button if they can sign out.
				SignOutButton.Visibility = userCanSignOut ? Visibility.Visible : Visibility.Collapsed;
				SignInButton.Visibility = Visibility.Collapsed;
			}
		}
        public async Task AddReservation(string email,List<Book> list)
        {
            List<String> listNumBook = new List<string>();

            foreach(var book in list)
            {
                listNumBook.Add(book.NumBook);
            }

            var listeJSONBook = Newtonsoft.Json.JsonConvert.SerializeObject(listNumBook);
            var linkForPost = Newtonsoft.Json.JsonConvert.SerializeObject("");

            HttpContent content = new StringContent(linkForPost, Encoding.UTF8, "application/json");
            HttpResponseMessage reponse = await client.PostAsync(addReservation + email + "&content=" + listeJSONBook, content);

            if (reponse.StatusCode == System.Net.HttpStatusCode.BadGateway)
            {
                var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
                string str = loader.GetString("noNetwork");
                throw new NoNetworkException(str);
            }
            else
            {
                if (reponse.StatusCode == System.Net.HttpStatusCode.NotFound)
                {
                    var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
                    string str = loader.GetString("errorAddReseration");
                    throw new ErrorData(str);
                }
            }
        }
		private async void SignOutButton_OnClick(object sender, RoutedEventArgs e)
		{
			try
			{
				// Initialize access to the Live Connect SDK.
				LiveAuthClient LCAuth = new LiveAuthClient();
				LiveLoginResult LCLoginResult = await LCAuth.InitializeAsync();
				// Sign the user out, if he or she is connected;
				//  if not connected, skip this and just update the UI
				if (LCLoginResult.Status == LiveConnectSessionStatus.Connected)
				{
					LCAuth.Logout();
				}

				// At this point, the user should be disconnected and signed out, so
				//  update the UI.
				var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
				this.UserNameTextBlock.Text = loader.GetString("MicrosoftAccount/Text");

				// Show sign-in button.
				SignInButton.Visibility = Visibility.Visible;
				SignOutButton.Visibility = Visibility.Collapsed;
			}
			catch (LiveConnectException x)
			{
				// Handle exception.
			}
		}
        private void RecuperaDados(object sender, RoutedEventArgs e)
        {
            var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
            var str = loader.GetString("MeuDado");

            lblResultado.Text = str;
        }
 public object Convert(object value, Type targetType, object parameter, string culture)
 {
     Windows.ApplicationModel.Resources.ResourceLoader loader = new Windows.ApplicationModel.Resources.ResourceLoader();
     DateTime dateTimeToConvert = (DateTime)value;
     string commentTimeString = "";
     TimeSpan commentTimeLag = System.DateTime.Now - dateTimeToConvert;
     if (dateTimeToConvert.Date == System.DateTime.Now.Date)
     {
         if (TimeSpan.FromHours(1) > commentTimeLag)
         {
             if (commentTimeLag.Minutes <= 1)
                 commentTimeString = string.Format("{0}" + loader.GetString("TimeConverter_Recent_1"), commentTimeLag.Minutes);
             else
                 commentTimeString = string.Format("{0}" + loader.GetString("TimeConverter_Recent"), commentTimeLag.Minutes);
         }
         else
         {
             commentTimeString = string.Format(loader.GetString("TimeConverter_Today") + "{0}:{1:d2}", dateTimeToConvert.Hour, dateTimeToConvert.Minute);
         }
     }
     else if (dateTimeToConvert.AddDays(1).Date == System.DateTime.Now.Date)
     {
         commentTimeString = string.Format(loader.GetString("TimeConverter_Yesterday") + "{0}:{1:d2}", dateTimeToConvert.Hour, dateTimeToConvert.Minute);
     }
     //else if (dateTimeToConvert.AddDays(2).Date == System.DateTime.Now.Date)
     //{
     //    commentTimeString = string.Format(loader.GetString("TimeConverter_DayBeforeYesterday") + "{0}:{1:d2}", dateTimeToConvert.Hour, dateTimeToConvert.Minute);
     //}
     else
     {
         commentTimeString = dateTimeToConvert.ToString("yyyy-MM-dd");
     }
     return commentTimeString;
 }
Beispiel #10
0
        /// <summary>
        /// Initializes the widget, specifying the page name and extracting it from the source.
        /// </summary>
        private void init()
        {
            if (this.Source.Contains("http://"))
            {
                this.Source = this.Source.Substring(Source.IndexOf("//") + 2);
            }
            if (this.Source.Contains("facebook.com"))
            {
                this.Source = this.Source.Substring(Source.IndexOf("/") + 1);
            }

            if (this.sel == Selection.Likes)
            {
                var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
                this.Title = String.Format(loader.GetString("FBWidgetLikes"), Source);
            }
            else if (this.sel == Selection.TalkingAbout)
            {
                var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
                this.Title = String.Format(loader.GetString("FBWidgetPeopleTalkingAbout"), Source);
            }
            this.Background = "#385998";
            this.Foreground = "white";
            this.WidgetForeground = "#33ffffff";
            this.WidgetName = "facebook";
        }
 public CicloStationsManager(IHttpCommunicator httpCommunicator, ITokenManager tokenManager)
 {
     _httpCommunicator = httpCommunicator;
     _tokenManager = tokenManager;
     var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
     fileName = loader.GetString("CicloStationFile");
 }
        public TutorialHelloBlinkyPage()
        {
            this.InitializeComponent();

            if (DeviceTypeInformation.Type == DeviceTypes.DB410)
            {
                LED_PIN = 115; // on-board LED on the DB410c
            }

            var rootFrame = Window.Current.Content as Frame;
            rootFrame.Navigated += RootFrame_Navigated;
            Unloaded += MainPage_Unloaded;

            this.NavigationCacheMode = NavigationCacheMode.Enabled;

            this.DataContext = LanguageManager.GetInstance();

            this.Loaded += (sender, e) =>
            {
                UpdateDateTime();

                timer = new DispatcherTimer();
                timer.Tick += timer_Tick;
                timer.Interval = TimeSpan.FromSeconds(30);
                timer.Start();

                blinkyTimer = new DispatcherTimer();
                blinkyTimer.Interval = TimeSpan.FromMilliseconds(500);
                blinkyTimer.Tick += Timer_Tick;

                loader = new Windows.ApplicationModel.Resources.ResourceLoader();
                BlinkyStartStop.Content = loader.GetString("BlinkyStart");
            };
        }
 public async static Task SendMessageDialogAsync(string message, bool isSuccess)
 {
     var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
     var title = isSuccess ? loader.GetString("SuccessText/Text") : loader.GetString("ErrorText/Text");
     var dialog = new MessageDialog((string.Concat(title, Environment.NewLine, Environment.NewLine, message)));
     await dialog.ShowAsync();
 }
Beispiel #14
0
    private static string GetResourceString([CallerMemberName] string resourceName = null)
    {
#pragma warning disable
      var loader = new Windows.ApplicationModel.Resources.ResourceLoader("Csla/Resources");
#pragma warning enable
      return loader.GetString(resourceName);
    }
Beispiel #15
0
        /// <summary>
        /// 프로퍼티로 호출
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string this[string id]
        {
            get
            {
                string str = string.Empty;
                if (Windows.ApplicationModel.DesignMode.DesignModeEnabled == false)
                {
                    if (_rl == null)
                    {
                        _rl = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView(ResourceName);
                    }

                    str = _rl.GetString(id);
                    if (string.IsNullOrEmpty(str) == true)
                    {
                        str = string.Empty;
                    }
                }
                else
                {   
                    //디자인 타임에서는 키값을 반환
                    str = id;
                }
                return str;
            }
        }
Beispiel #16
0
        private async void BookReseravation_Click(Book book)
        {
            var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
            string strVR = loader.GetString("ValideReservation");
            string yes = loader.GetString("Yes");
            string no = loader.GetString("No");
            var dialog = new Windows.UI.Popups.MessageDialog(book.Title+"\n" + strVR);      
            dialog.Commands.Add(new Windows.UI.Popups.UICommand(yes) { Id = 1 });
            dialog.Commands.Add(new Windows.UI.Popups.UICommand(no) { Id = 0 });

            var result = await dialog.ShowAsync();

            if ((int)result.Id == 1)
            {
                var duplicate = false;
                foreach (var b in bookReservation)
                {
                    if (b.NumBook == book.NumBook)
                        duplicate = true;
                }
                if(duplicate == false)
                    bookReservation.Add(book);
                else
                {
                    var str = loader.GetString("Duplicate");
                    dialog = new Windows.UI.Popups.MessageDialog(str);
                    await dialog.ShowAsync();
                }
            }
        }
 public ListRecipesViewModel(INavigationService navigationService)
 {
     _navigationService = navigationService;
     Recipes = new ObservableCollection<Recipe>();
     var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
     var tradSearch = loader.GetString("searchDesc");
 }
        public async Task<bool> VerifiyLoginAsync(string email, string password)
        {
            if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
            {
                HttpClient client = new HttpClient();
                HttpResponseMessage response = await client.GetAsync("http://keyregisterweb.azurewebsites.net/api/people/searchPersonByEmail/?email=" + email);

                string json = await response.Content.ReadAsStringAsync();
                var userFromDB = Newtonsoft.Json.JsonConvert.DeserializeObject<Person>(json);

                string cryptedPassword = MyCrypt(password);

                if (cryptedPassword.Equals(userFromDB.Password))
                {
                    return true;
                }

                return false;
            }
            else
            {
                var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
                string str = loader.GetString("noNetwork");
                throw new NoNetworkException(str);
            }
        }
Beispiel #19
0
 public EmptyWidget()
 {
     this.WidgetName = "EmptyWidget";
     this.Foreground = "white";
     var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
     this.Title = loader.GetString("EmptyWidgetTitle");
 }
 public void CreatePopUp(string value)
 {
     var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
     var str = loader.GetString(value);
     var messageDialog = new MessageDialog(str);
     messageDialog.ShowAsync();
 }
Beispiel #21
0
        public override async Task Update()
        {
            var client = new GZipHttpClient();
            client.MaxResponseContentBufferSize = 1024 * 1024;
            string url = "https://api.stackexchange.com/2.0/users/" + Source + "?site=" + Site;
            var response = await client.GetAsync(new Uri(url));
            if (response.StatusCode == System.Net.HttpStatusCode.BadRequest)
            {
                Counter = 0;
                return;
                //throw new NullReferenceException("The selected site was not found. Please check spelling.");
            }

            var result = await response.Content.ReadAsStringAsync();
            var recipes = JsonObject.Parse(result);

            if (recipes["items"].GetArray().Count == 0)
            {
                throw new NullReferenceException("The user id was not found.");
            }

            this.Title = recipes["items"].GetArray()[0].GetObject()["display_name"].GetString() + " reputation";
            var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
            this.Title = String.Format(loader.GetString("StackOverflowWidgetReputation"), recipes["items"].GetArray()[0].GetObject()["display_name"].GetString());
            Counter = (int)recipes["items"].GetArray()[0].GetObject()["reputation"].GetNumber();
        }
Beispiel #22
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            CoreWindow.GetForCurrentThread().PointerCursor = new CoreCursor(CoreCursorType.Arrow, 1);
            if (e.NavigationMode == NavigationMode.New)
            {
                frame.Navigate(typeof(Setting));
                List<MenuItem> mylist1 = new List<MenuItem>();
                var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
                //str = loader.GetString("back");
                //mylist1.Add(new MenuItem() { Icon = "Back", Title = str });
                var str = loader.GetString("setting");
                mylist1.Add(new MenuItem() { Icon = "Setting", Title = str });
                str = loader.GetString("histroy");
                mylist1.Add(new MenuItem() { Icon = "Favorite", Title = str });
                str = loader.GetString("help");
                mylist1.Add(new MenuItem() { Icon = "Help", Title = str });
                list1.ItemsSource = mylist1;

                mylist1 = new List<MenuItem>();
                str = loader.GetString("about");
                mylist1.Add(new MenuItem() { Icon = "Contact", Title = str });
                str = loader.GetString("like");
                mylist1.Add(new MenuItem() { Icon = "Like", Title = str });
                //str = loader.GetString("back");
                //mylist1.Add(new MenuItem() { Icon = "Back", Title = str });
                list2.ItemsSource = mylist1;
            }
            base.OnNavigatedTo(e);
            CoreWindow.GetForCurrentThread().PointerReleased += (sender, args) =>
            {
                args.Handled = true;
                if (args.CurrentPoint.Properties.PointerUpdateKind == Windows.UI.Input.PointerUpdateKind.XButton1Released) if (Frame.CanGoBack) Frame.GoBack();
            };
        }
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            var item = await ControlInfoDataSource.GetItemAsync((String)e.NavigationParameter);

            if (item != null)
            {
                Item = item;

                // Load control page into frame.
                var loader = new Windows.ApplicationModel.Resources.ResourceLoader();

                string pageRoot = loader.GetString("PageStringRoot");

                string pageString = pageRoot + item.UniqueId + "Page";
                Type pageType = Type.GetType(pageString);

                if (pageType != null)
                {
                    this.contentFrame.Navigate(pageType);
                }

                if(item.Title == "AppBar")
                {
                    //Child pages don't follow the visible bounds, so we need to add margin to account for this
                    header.Margin = new Thickness(0, 24, 0, 0);
                }
            }
        }
Beispiel #24
0
        async public Task SignUp()
        {
            try
            {
                var loader = new Windows.ApplicationModel.Resources.ResourceLoader();

                this.StatusMessage = string.Empty;
                this.Status = Enumerations.TravelerStatus.Working;

                if (this.CheckData())
                {
                    this.Identifier = await model.SignUpAsync(this);
                    
                    if (this.Identifier == new Guid(loader.GetString("GuidNull")))
                    {
                        this.StatusMessage = "The username already exists";
                        this.Status = Enumerations.TravelerStatus.Stopped;
                    }
                    else
                    {
                        this.StatusMessage = "Your account has been created";
                        this.Status = Enumerations.TravelerStatus.AccountCreated;
                    }
                }
            }
            catch (Exception)
            {
                this.StatusMessage = "Sorry, something is wrong, please try later";
                this.Status = Enumerations.TravelerStatus.Stopped;
            }
        }
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            var list = (IList<Filter>)value;
            var text = string.Empty;
            var separator = parameter != null ? parameter.ToString() : " ";

            if (list != null && list.Count > 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    text += list[i].ToString();

                    if (i < list.Count - 1)
                    {
                        text += separator;
                    }
                }
            }
            else
            {
                text = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("PhotoPageZeroFiltersText");
            }

            return text;
        }
Beispiel #26
0
        public UserViewModel()
        {
            var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
            model = new DatabaseModel();

            this.Identifier = new Guid(loader.GetString("GuidNull"));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GameScreen"/> class.
        /// </summary>
        /// <param name="graphicsManager">The graphics manager.</param>
        protected GameScreen(IBallerburgGraphicsManager graphicsManager)
        {
            this.graphicsManager = graphicsManager;

              controls = new Collection<Control>();
              resourceLoader = new Windows.ApplicationModel.Resources.ResourceLoader();
              ////Viewport viewport = this.GraphicsManager.GraphicsDevice.Viewport;
        }
        public AboutFlyout()
        {
            this.InitializeComponent();

            DataContext = _viewModel;

            Title = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("AboutFlyoutCommandLabel");
        }
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            var version = (Version)value;
            var versionText = String.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Build, version.Revision);
            var format = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("AboutPageVersionText");

            return String.Format(format, versionText);
        }
 public SearchRecipeViewModel(INavigationService navigationService)
 {
     _navigationService = navigationService;
     var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
     var tradSearchDesc = loader.GetString("searchDesc");
     var tradSearch = loader.GetString("searchInput");
     var tradSearchTitle = loader.GetString("searchTitle");
 }
        // Method for activating Radio
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            var loader = new Windows.ApplicationModel.Resources.ResourceLoader();

            networkStatus.Text       = loader.GetString("CS_Text2");
            networkStatus.Foreground = new SolidColorBrush(Colors.Yellow);
            InternetTest.Navigate(new Uri("http://curiosity.shoutca.st:8019/128"));

            if (InternetAvailable == true)
            {
                if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable() == true)
                {
                    streamStatus.Text        = loader.GetString("CS_Text20");
                    streamStatus.Foreground  = new SolidColorBrush(Colors.Gray);
                    networkStatus.Text       = "...";
                    networkStatus.Foreground = new SolidColorBrush(Colors.Green);
                    try
                    {
                        streamStatus.Text = loader.GetString("CS_Text21");

                        if (MediaPlayerState.Playing != BackgroundMediaPlayer.Current.CurrentState)
                        {
                            BackgroundAudioTask.MyBackgroundAudioTask backgroundAccess = new BackgroundAudioTask.MyBackgroundAudioTask();
                            streamStatus.Text = loader.GetString("CS_Text22");
                            var message = new ValueSet();
                            streamStatus.Text = loader.GetString("CS_Text23");
                            ApplicationSettingsHelper.SaveSettingsValue(Constants.CurrentTrack, "128");
                            streamStatus.Text = loader.GetString("CS_Text24");
                            message.Add(Constants.StartPlayback, "0");
                            streamStatus.Text = loader.GetString("CS_Text25");
                            BackgroundMediaPlayer.SendMessageToBackground(message);
                        }

                        streamStatus.Text = "...";
                    }
                    catch (Exception)
                    {
                        networkStatus.Text       = loader.GetString("CS_Text26");
                        networkStatus.Foreground = new SolidColorBrush(Colors.Red);
                        if (MediaPlayerState.Playing == BackgroundMediaPlayer.Current.CurrentState)
                        {
                            streamStatus.Text = loader.GetString("CS_Text27");
                        }
                        else
                        {
                            try
                            {
                                BackgroundMediaPlayer.Current.Play();
                            }
                            catch (Exception) { }
                        }
                    }
                }
                else
                {
                    networkStatus.Text       = loader.GetString("CS_Text28");
                    networkStatus.Foreground = new SolidColorBrush(Colors.Yellow);
                    streamStatus.Text        = loader.GetString("CS_Text29");
                    streamStatus.Foreground  = new SolidColorBrush(Colors.Red);
                }
            }
            else // If Internet Is Not Available
            {
                networkStatus.Text       = loader.GetString("CS_Text30");
                networkStatus.Foreground = new SolidColorBrush(Colors.Red);
                streamStatus.Text        = loader.GetString("CS_Text31");
                streamStatus.Foreground  = new SolidColorBrush(Colors.Red);
            }
        }
Beispiel #32
0
        /// <summary>
        /// Coverts a DateTime to 'time ago' format
        /// </summary>
        /// <returns></returns>
        public static string ConvertDateToTimeAgoFormat(DateTime dt)
        {
            var    ts    = new TimeSpan(DateTime.Now.Ticks - dt.Ticks);
            double delta = Math.Abs(ts.TotalSeconds);

            var languageLoader = new Windows.ApplicationModel.Resources.ResourceLoader();

            if (delta < 60)
            {
                if (ts.Seconds == 1)
                {
                    return(languageLoader.GetString("aSecondAgo"));
                }
                else
                {
                    return(string.Format("{0} {1}",
                                         ts.Seconds,
                                         languageLoader.GetString("secondsAgo")));
                }
            }
            if (delta < 120)
            {
                return(languageLoader.GetString("aMinuteAgo"));
            }
            if (delta < 2700) // 45 * 60
            {
                return(string.Format("{0} {1}",
                                     ts.Minutes,
                                     languageLoader.GetString("minutesAgo")));
            }
            if (delta < 5400) // 90 * 60
            {
                return(languageLoader.GetString("anHourAgo"));
            }
            if (delta < 86400) // 24 * 60 * 60
            {
                return(string.Format("{0} {1}",
                                     ts.Hours,
                                     languageLoader.GetString("hoursAgo")));
            }
            if (delta < 172800) // 48 * 60 * 60
            {
                return(languageLoader.GetString("aDayAgo"));
            }
            if (delta < 2592000) // 30 * 24 * 60 * 60
            {
                return(string.Format("{0} {1}",
                                     ts.Days,
                                     languageLoader.GetString("daysAgo")));
            }
            if (delta < 31104000) // 12 * 30 * 24 * 60 * 60
            {
                int months = System.Convert.ToInt32(Math.Floor((double)ts.Days / 30));

                if (months <= 1)
                {
                    return(languageLoader.GetString("oneMonthAgo"));
                }
                else
                {
                    return(string.Format("{0} {1}",
                                         months,
                                         languageLoader.GetString("monthsAgo")));
                }
            }

            int years = System.Convert.ToInt32(Math.Floor((double)ts.Days / 365));

            if (years <= 1)
            {
                return(languageLoader.GetString("oneYearAgo"));
            }
            else
            {
                return(string.Format("{0} {1}",
                                     years,
                                     languageLoader.GetString("yearsAgo")));
            }
        }
        private void PrepareButtonContent()
        {
            var loader = new Windows.ApplicationModel.Resources.ResourceLoader();

            AutoSliderRB.Content = loader.GetString("SliderCheckButton");
        }
Beispiel #34
0
        /// <summary>
        /// Search for the Page Title with the given Menu type
        /// </summary>
        /// <param name="type">type of the Menu</param>
        /// <returns>string</returns>
        /// <exception cref="Exception">When the given type don't have a Page Title pair</exception>
        public string ChoosePageTitleByPageType(Type type)
        {
            var languageLoader = new Windows.ApplicationModel.Resources.ResourceLoader();

            if (type == typeof(CommentView))
            {
                return(languageLoader.GetString("pageTitle_CommentView"));
            }
            else if (type == typeof(DeveloperProfileView))
            {
                return(languageLoader.GetString("pageTitle_DeveloperProfileView"));
            }
            else if (type == typeof(FeedView))
            {
                return(languageLoader.GetString("pageTitle_FeedView"));
            }
            else if (type == typeof(IssueDetailView))
            {
                return(languageLoader.GetString("pageTitle_IssueDetailView"));
            }
            else if (type == typeof(IssuesView))
            {
                return(languageLoader.GetString("pageTitle_IssuesView"));
            }
            else if (type == typeof(MyOrganizationsView))
            {
                return(languageLoader.GetString("pageTitle_MyOrganizationsView"));
            }
            else if (type == typeof(MyReposView))
            {
                return(languageLoader.GetString("pageTitle_MyReposView"));
            }
            else if (type == typeof(NotificationsView))
            {
                return(languageLoader.GetString("pageTitle_NotificationsView"));
            }
            else if (type == typeof(PullRequestDetailView))
            {
                return(languageLoader.GetString("pageTitle_PullRequestDetailView"));
            }
            else if (type == typeof(PullRequestsView))
            {
                return(languageLoader.GetString("pageTitle_PullRequestsView"));
            }
            else if (type == typeof(RepoDetailView))
            {
                return(languageLoader.GetString("pageTitle_RepoDetailView"));
            }
            else if (type == typeof(SearchView))
            {
                return(languageLoader.GetString("pageTitle_SearchView"));
            }
            else if (type == typeof(SettingsView))
            {
                return(languageLoader.GetString("pageTitle_SettingsView"));
            }
            else if (type == typeof(TrendingView))
            {
                return(languageLoader.GetString("pageTitle_TrendingView"));
            }
            else if (type == typeof(AboutSettingsView))
            {
                return("About");
            }
            else if (type == typeof(AppearanceView))
            {
                return("Appearance");
            }
            else if (type == typeof(DonateView))
            {
                return("Donate");
            }
            else if (type == typeof(CreditSettingsView))
            {
                return("Credits");
            }
            else
            {
                return("");
            }

            //throw new Exception("Page Title not found for the given (Page) type: " + type);
        }
        public static string GetLocalizationString(string key)
        {
            var loader = new Windows.ApplicationModel.Resources.ResourceLoader();

            return(loader.GetString(key));
        }