Created
January 16, 2012 07:27
-
-
Save jeffwilcox/1619588 to your computer and use it in GitHub Desktop.
Just a fun way to show something different while things are loading.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Copyright (c) 2010-2011 Jeff Wilcox | |
// | |
// Licensed under the Apache License, Version 2.0 (the "License"); | |
// you may not use this file except in compliance with the License. | |
// You may obtain a copy of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
// | |
// Unless required by applicable law or agreed to in writing, software | |
// distributed under the License is distributed on an "AS IS" BASIS, | |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
// See the License for the specific language governing permissions and | |
// limitations under the License. | |
// | |
using System; | |
using System.Collections.Generic; | |
using AgFx; | |
namespace JeffWilcox.FourthAndMayor | |
{ | |
public class WittyBanter | |
{ | |
private static Random _rand = new Random(); | |
public WittyBanter() | |
{ | |
if (_banter == null) | |
{ | |
_banter = this; | |
PriorityQueue.AddWorkItem(Initialize); | |
} | |
} | |
public string WelcomeBanter | |
{ | |
get | |
{ | |
return _banter.GetBanterFrom(_welcome); | |
} | |
} | |
public string Banter | |
{ | |
get | |
{ | |
// Note that we don't fire property change notifications! | |
return _banter.GetBanterFrom(_other); | |
} | |
} | |
private void Initialize() | |
{ | |
_welcome.Add("Hi."); | |
_welcome.Add("Hi."); | |
_welcome.Add("Hello, world."); | |
_welcome.Add("Hello."); | |
_welcome.Add("Hey."); | |
_welcome.Add("Greetings."); | |
//_welcome.Add("bonjour"); | |
//_welcome.Add("Velkommen"); | |
//_welcome.Add("Welkom"); | |
//_welcome.Add("Bienvenue"); | |
//_welcome.Add("Willkommen"); | |
//_welcome.Add("Aloha"); | |
DateTime now = DateTime.Now; | |
string time = "Hello."; | |
if (now.Hour >= 4 && now.Hour < 6) | |
{ | |
time = "Early morning."; | |
} | |
else if (now.Hour >= 6 && now.Hour < 11) | |
{ | |
time = "Good morning."; | |
} | |
else if (now.Hour >= 11 && now.Hour < 13) | |
{ | |
time = "Lunch!"; | |
} | |
else if (now.Hour >= 13 && now.Hour < 17) | |
{ | |
time = "Good afternoon."; | |
} | |
else if (now.Hour >= 17 && now.Hour < 20) | |
{ | |
time = "Good evening."; | |
} | |
else if (now.Hour >= 20 && now.Hour < 23) | |
{ | |
time = "Having a good night?"; | |
} | |
_welcome.Add(time); | |
_welcome.Add(time); | |
_welcome.Add(time); | |
} | |
private string GetBanterFrom(List<string> list) | |
{ | |
int size = list.Count; | |
if (size > 0) | |
{ | |
int index = _rand.Next(0, size - 1); | |
return list[index]; | |
} | |
else return "Loading"; | |
} | |
private List<string> _welcome = new List<string>(); | |
private List<string> _other = new List<string>(); | |
private static WittyBanter _banter; | |
// homepage... | |
// hi | |
// hello | |
// bonjour | |
// hey | |
// TGIF! | |
// mondays :-( | |
// GPS ENABLED!!!! MEANS I WOULD LOVE TO OFFER GEOCODED BANTER... | |
// how's the weather in seattle? | |
// how's seattle today? | |
// these aren't the droids you're looking for | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment