Exemple #1
0
            public static void SetTile(MessageItem item, string NavSource)
            {
                FlipTileData tileData = new FlipTileData()
                {
                    //Front square data
                    Title = item.Title + " by " + item.Author,
                    BackgroundImage = new Uri("/Assets/Tiles/FlipCycleTileMedium.png", UriKind.Relative),
                    SmallBackgroundImage = new Uri("/Assets/Tiles/IconicTileSmall.png", UriKind.Relative),

                    //Back square data
                    BackTitle = "On " + item.Date + " " + item.Time,
                    BackContent = item.Msg,
                    BackBackgroundImage = new Uri("/Assets/Tiles/FlipCycleTileMedium.png", UriKind.Relative),

                    //Wide tile data
                    WideBackgroundImage = new Uri("/Assets/Tiles/FlipCycleTileLarge.png", UriKind.Relative),
                    WideBackBackgroundImage = new Uri("/Assets/Tiles/FlipCycleTileLarge.png", UriKind.Relative),
                    WideBackContent = item.Msg
                };

                ShellTile.Create(new Uri(NavSource, UriKind.Relative), tileData, true);
            }
Exemple #2
0
        private void PostButton_Click(object sender, EventArgs e)
        {
            if (Message_Post_Box.Text.Length > 500)
            {
                MessageBox.Show("You have used over 500 characters, you must reduce the number of characters under 500 to proceed.");
                return;
            }

            MessageBoxResult postMsg = MessageBox.Show("Please click ok if you really want to post this message?", "Posting Message?", MessageBoxButton.OKCancel);
            if (postMsg == MessageBoxResult.OK)
            {
                String title = this.Message_Title_Box.Text;
                String message = this.Message_Post_Box.Text;
                int id = App.ReadMsgList.CurrentItemCount();
                int distance = (int)Distance_Slider.Value;
                int radiusMeters = App.distancesMeter[distance];
                bool showLocation = chkShowLocation.IsChecked.Value;

                MessageItem outgoingMsg = new MessageItem()
                         {
                             dbMsgID = id.ToString(),
                             Date = DateTime.Now.ToString("MM/dd/yyyy"),
                             Time = DateTime.Now.ToString("HH:mm:ss tt"),
                             Title = title,
                             Author = myId,
                             Msg = message
                         };

                /* progresss bar... */
                pi = new Microsoft.Phone.Shell.ProgressIndicator();
                pi.IsIndeterminate = true;
                pi.Text = "Posting message, please wait...";
                pi.IsVisible = true;
                Microsoft.Phone.Shell.SystemTray.SetIsVisible(this, true);
                Microsoft.Phone.Shell.SystemTray.SetProgressIndicator(this, pi);

                ThreadStart starter = delegate { Post_Button_Click_Work(title, message, id, radiusMeters, showLocation); };

                Thread work = new Thread(starter);
                work.Start();

                ///* wait for message back from post to the cloud.. */
                //dataSource ds = new dataSource(myId);
                //ds.write(radiusMeters, title, message);

                //App.ReadMsgList.Items.Add(outgoingMsg);

                // Navigate to the new page
                NavigationService.Navigate(new Uri("/ReadLongListPage.xaml", UriKind.Relative));
            }
        }
        private void getMsgComplete(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                // The user canceled the operation.
                MessageBox.Show("An error occurred, please try again");
                App.SaveDebugEntry("ReadDetailsPage.getMsgComplete: Canceld");
            }
            else if (e.Error != null)
            {
                // There was an error during the operation.
                MessageBox.Show("An error occurred, please try again");
                App.SaveDebugEntry("ReadDetailsPage.getMsgComplete: error occured");
            }
            else
            {
                readData msgOutput = (readData)e.Result;
                //Error Handling, need to provide feedback to the user
                if (msgOutput == null)
                {
                    //msg is null, reason unknown
                    MessageBox.Show("An error occurred, please try again");
                    App.SaveDebugEntry("ReadDetailsPage.getMsgComplete: null readMsg");
                }
                else
                {

                    msg curMsg = msgOutput.getMsg(0);

                    curReadMsg = new MessageItem()
                    {
                        dbMsgID = curMsg.msgID.ToString(),
                        Date = curMsg.createDate.Date.ToString("MM/dd/yyyy"),
                        Time = curMsg.createDate.TimeOfDay.ToString(),
                        Title = curMsg.title,
                        Author = curMsg.userName,
                        Msg = curMsg.msgBody,
                        ShowLocation = curMsg.showLocation
                    };

                    if (curMsg.showLocation)
                    {
                        postLoc = new GeoCoordinate(curMsg.lat, curMsg.lon);
                        msgBubble.Height = 400;

                        showMap = new Button();
                        showMap.Name = "btnShowMap";
                        showMap.Height = 75;
                        showMap.Width = 200;
                        showMap.Margin = new Thickness(226, 450, 0, 0);
                        showMap.Content = "Show Map";
                        showMap.Click += btnShowMap_Click;

                        ContentPanel.Children.Add(showMap);
                    }

                    DataContext = curReadMsg;
                }
            }
        }
Exemple #4
0
        public bool msgInsert(MessageItem curMsg)
        {
            /* Check to see if the message is in our range.. */
            if (!isInRange(curMsg))
                return false;

            if (this.Items.Count == 0)   /* Just insert it.. */
            {
                this.Items.Add(curMsg);
                return true;
            }

            /* Now, try to insert the message in to our list in reverse chronological order */
            /* Assuming the message list is already sorted this way.. */
            for (int i = 0; i < this.Items.Count; i++)
            {
                int result = curMsg.CreateDate.CompareTo(this.Items[i].CreateDate) ;

                if (result > 0) /* Later than the current index one.. */
                {
                    this.Items.Insert(i, curMsg);
                    return true;
                }
                else if (result == 0)   /* Same time.. */
                {
                    /* Same message.. */
                    if (curMsg.dbMsgID.Equals(this.Items[i].dbMsgID))
                    {
                        return false;
                    }
                    else/* Different message but same time.. */
                    {
                        this.Items.Insert(i, curMsg);
                        return true;
                    }
                }
                else /* Earlier than the current index one.. */
                {
                    if (i == this.Items.Count - 1)
                    {
                        /*
                         * This message is even older than the last message
                         * we have in our list.  So, just add it..
                         */
                        this.Items.Add(curMsg);
                        return true;
                    }
                    else
                    {
                        //move on to the next one..
                    }
                }
            }

            return false;
        }
Exemple #5
0
        public bool isInRange(MessageItem curMsg)
        {
            if ((App.ReadSettings.latStart <= curMsg.Lat) && (curMsg.Lat <= App.ReadSettings.latEnd) &&
                (App.ReadSettings.lonStart <= curMsg.Lon) && (curMsg.Lon <= App.ReadSettings.lonEnd))
                return true;

            return false;
        }
        private void refreshCompleted(
            object sender,
            RunWorkerCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                // The user canceled the operation.
                MessageBox.Show("An error occurred, please try again");

               App.SaveDebugEntry("ReadLongListPage.refreshComplete: Canceld");
            }
            else if (e.Error != null)
            {
                // There was an error during the operation. 
                MessageBox.Show("An error occurred, please try again");

                App.SaveDebugEntry("ReadLongListPage.refreshComplete: error occured");
            }
            else
            {
                /*
                * Push all the msg from DB to MessageGroup so we can keep
                * a list of latest 50 message from DB
                */
                readMsg = (readData)e.Result;

                if (readMsg == null)
                {
                    MessageBox.Show("An error occurred, please try again");

                    App.SaveDebugEntry("ReadLongListPage.refreshComplete: null readMsg");
                }
                else
                {
                    //App.SaveDebugEntry("ReadLongListPage.refreshComplete: test...");

                    newMsgThisTime = 0;

                    //App.ReadMsgList = new MessageGroup();

                    int numMsg = readMsg.getLength();
                    for (int i = 0; i < numMsg; i++)
                    {
                        msg curDBMsg = readMsg.getMsg(i);

                        TimeSpan keepDays = new System.TimeSpan(App.ReadSettings.keepTime, 0, 0, 0);

                        /* Only add message if is newer than what we want to see */
                        if (DateTime.Now.Subtract(keepDays).CompareTo(curDBMsg.createDate) > 0)
                            continue;   // msg is too old..

                        MessageItem incomingMsg = new MessageItem()
                        {
                            dbMsgID = curDBMsg.msgID.ToString(),
                            Date = curDBMsg.createDate.Date.ToString("MM/dd/yyyy"),
                            Time = curDBMsg.createDate.TimeOfDay.ToString(),
                            Title = curDBMsg.title,
                            Lat = curDBMsg.lat,
                            Lon = curDBMsg.lon,
                            CreateDate = curDBMsg.createDate
                            //Author = curDBMsg.userName,
                            //Msg = curDBMsg.msgBody
                        };

                        if(App.ReadMsgList.msgInsert(incomingMsg))
                            newMsgThisTime++;
                    }

                    updateLiveTile(newMsgThisTime);
                }
                pi.IsVisible = false;
                Microsoft.Phone.Shell.SystemTray.SetIsVisible(this, false);
                doingRefresh = false;
                DataContext = App.ReadMsgList;
            }
        }