public override TJSONValue Execute(TJSONValue value, int JSONType) { TJSONObject obj = TJSONObject.Parse(value.ToString()); Context.Send(new SendOrPostCallback(x => { if (obj.getString("cmd") == "vibrate") { Microsoft.Devices.VibrateController.Default.Start(TimeSpan.FromMilliseconds(50)); System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer(); timer.Interval = new TimeSpan(0, 0, 0, 0, 200); timer.Tick += (tsender, tevt) => { var t = tsender as System.Windows.Threading.DispatcherTimer; t.Stop(); Microsoft.Devices.VibrateController.Default.Stop(); }; timer.Start(); } if (obj.getString("cmd") == "ring") { SoundEffect.MasterVolume = 1.0f; SoundEffect sfx = SoundEffect.FromStream(TitleContainer.OpenStream("cmd.wav")); SoundEffectInstance sfxInstance = sfx.CreateInstance(); sfxInstance.Play(); } }), null); return(null); }
private void LoadUsersList() { CTConnection.getLoginUserInstance().GetUserList(users => { this.Dispatcher.BeginInvoke(() => { listBox1.Items.Clear(); UsersArray.Clear(); int i = 0; for (i = 0; i < users.size(); i++) { TJSONObject userItem = users.getJSONObject(i); UsersArray.Add(new UserRecord(userItem.getString("userid"), userItem.getString("username"))); listBox1.Items.Add(userItem.getString("username")); } //listBox1.DataContext = UsersArray; //listBox1.DisplayMemberPath = "UserName"; }); }, ManageExceptionCallback); }
private void LoadAccBookList() { CTConnection.getLoginUserInstance().GetAccListJSON(result => { this.Dispatcher.BeginInvoke(() => { lbAccBook.Items.Clear(); AccBookArray.Clear(); TJSONArray accbooks = result.getJSONArray("accbooks"); int i = 0; for (i = 0; i < accbooks.size(); i++) { TJSONObject AccItem = accbooks.getJSONObject(i); AccBookArray.Add(new AccBook(AccItem.getString("syaccbookcode"), AccItem.getString("syaccbookname"))); lbAccBook.Items.Add(AccItem.getString("syaccbookname")); } if (lbAccBook.Items.Count > 0) { lbAccBook.SelectedIndex = 0; } }); }, ManageExceptionCallback); }
public override TJSONValue Execute(TJSONValue value, int JSONType) { TJSONObject obj = TJSONObject.Parse(value.ToString()); Context.Send(new SendOrPostCallback(x => { PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame; PhoneApplicationPage mp = frame.Content as PhoneApplicationPage; if (mp is MainTweetPage) { ((MainTweetPage)mp).listBox1.Items.Add(obj.getString("username") + ": " + obj.getString("message")); SoundEffect.MasterVolume = 1.0f; SoundEffect sfx = SoundEffect.FromStream(TitleContainer.OpenStream("tweet.wav")); SoundEffectInstance sfxInstance = sfx.CreateInstance(); sfxInstance.Play(); } }), null); return(null); }
public override TJSONValue Execute(TJSONValue value, int JSONType) { TJSONObject obj = TJSONObject.Parse(value.ToString()); Context.Send(new SendOrPostCallback(x => { string notificationtype = obj.getString("notificationType"); if (notificationtype == "message") { PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame; PhoneApplicationPage mp = frame.Content as PhoneApplicationPage; if (mp is MainTweetPage) { System.Windows.Controls.ListBox listbox = ((MainTweetPage)mp).listBox1; listbox.Items.Add(obj.getString("fromusrname") + " " + obj.getString("datetime")); string msgText = obj.getString("message"); int txtPos = 0; int txtLen = 22; while (txtPos < msgText.Length) { string dipTxt = msgText.Substring(txtPos, txtLen); listbox.Items.Add(dipTxt); txtPos = txtPos + txtLen; if (txtPos + txtLen > msgText.Length) { txtLen = msgText.Length - txtPos; } } SoundEffect.MasterVolume = 1.0f; SoundEffect sfx = SoundEffect.FromStream(TitleContainer.OpenStream("tweet.wav")); SoundEffectInstance sfxInstance = sfx.CreateInstance(); sfxInstance.Play(); } } else if (notificationtype == "cmd") { if (obj.getString("cmd") == "vibrate") { /* SoundEffect.MasterVolume = 1.0f; * SoundEffect sfx = SoundEffect.FromStream(TitleContainer.OpenStream("cmd.wav")); * SoundEffectInstance sfxInstance = sfx.CreateInstance(); * sfxInstance.Play();*/ Microsoft.Devices.VibrateController.Default.Start(TimeSpan.FromMilliseconds(50)); System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer(); timer.Interval = new TimeSpan(0, 0, 0, 0, 200); timer.Tick += (tsender, tevt) => { var t = tsender as System.Windows.Threading.DispatcherTimer; t.Stop(); Microsoft.Devices.VibrateController.Default.Stop(); }; timer.Start(); } if (obj.getString("cmd") == "ring") { SoundEffect.MasterVolume = 1.0f; SoundEffect sfx = SoundEffect.FromStream(TitleContainer.OpenStream("cmd.wav")); SoundEffectInstance sfxInstance = sfx.CreateInstance(); sfxInstance.Play(); } } }), null); return(null); }