getRowsbyTitle() 공개 정적인 메소드

public static getRowsbyTitle ( String title ) : ObservableCollection
title String
리턴 ObservableCollection
예제 #1
0
        private void SaveLocation_DoubleTap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            user_feedback.VibrateOnItemSelected();
            String temp_Radius     = "0";
            String temp_Note       = "";
            String temp_RingTones  = "";
            String temp_icon_light = "";
            String temp_icon_dark  = "";
            String error           = "";

            if (Title.Text == "" && error == "")
            {
                error = "Title";
            }

            // check if radius contains more than one "."
            int count = 0;

            if (Radius.Visibility == Visibility.Visible && error == "")
            {
                for (int i = 0; i < Radius.Text.Count(); i++)
                {
                    if (Radius.Text.ElementAt(i).Equals('.'))
                    {
                        count++;
                    }
                }
                if (count > 1)
                {
                    error = "Radius";
                }
                else if (Radius.Text == "." || Radius.Text == "")
                {
                    error = "Radius";
                }
                else if (Convert.ToDouble(Radius.Text) > 0)
                {
                    // do nothing, radius is greater than 0
                }
                else
                {
                    error = "Radius";
                }
            }

            if (Radius.Visibility == Visibility.Visible && (Radius.Text == "" || Radius.Text == "0" || Radius.Text == "." || Radius.Text == "0.0" || Radius.Text == "0." || Radius.Text == ".0") && error == "")
            {
                error = "Radius";
            }
            if (Note.Visibility == Visibility.Visible && Note.Text == "" && error == "")
            {
                error = "Note";
            }
            if (Location.Visibility == Visibility.Visible)
            {
                if (Location.Text == "" && error == "")
                {
                    error = "Location";
                }
            }

            if (error != "")
            {
                if (error != "Radius")
                {
                    MessageBox.Show(error + " cannot be empty ", "", MessageBoxButton.OK);
                }
                else
                {
                    MessageBox.Show(error + " cannot be empty or 0", "", MessageBoxButton.OK);
                }
            }
            else
            {
                if (Radius.Visibility == Visibility.Visible)
                {
                    temp_Radius = Radius.Text;
                }
                if (Ring_Tones.Visibility == Visibility.Visible)
                {
                    temp_RingTones = (String)Ring_Tones.SelectedItem;
                }
                if (Note.Visibility == Visibility.Visible)
                {
                    temp_Note = Note.Text;
                }
                switch ((String)Type.SelectedItem)
                {
                case "Alarm":
                    temp_icon_dark  = "/Images/Mode.png/";
                    temp_icon_light = "/Images/Mode_Dark.png/";
                    break;

                case "Car Locator":
                    temp_icon_dark  = "/Images/PushpinCar.png/";
                    temp_icon_light = "/Images/PushpinCar_Dark.png/";
                    break;

                case "Ring Tones":
                    temp_icon_dark  = "/Images/Location.png/";
                    temp_icon_light = "/Images/Location_Dark.png/";
                    break;

                default:
                    temp_icon_dark  = "/Images/PushpinCar.png/";
                    temp_icon_light = "/Images/PushpinCar_Dark.png/";
                    break;
                }
                if (!new_page)//Edit Page
                {
                    if ((old_title != Title.Text) || (old_radius != temp_Radius) || (old_ringtones != temp_RingTones) || (old_type != (String)Type.SelectedItem) || (old_note != temp_Note))
                    {
                        Table.Remove(Edit_Query[0]);
                        DB_Helper.deleteRow(Edit_Query[0]);

                        // Create a new to-do item based on the text box.
                        Row newRow = new Row {
                            Title = Title.Text, longitude = longitude, latitude = latitude, Radius = Double.Parse(temp_Radius), Ring_Tones = temp_RingTones, Type = (String)Type.SelectedItem, Note = temp_Note, Icon_Source_Dark = temp_icon_dark, Icon_Source_Light = temp_icon_light
                        };

                        // Add a to-do item to the observable collection.
                        Table.Add(newRow);

                        DB_Helper.insertRow(newRow);
                        NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));
                    }
                    else
                    {
                        NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));
                    }
                }
                else// New Page
                {
                    if (DB_Helper.getRowsbyTitle(Title.Text).Count != 0)
                    {
                        MessageBox.Show("The title is already used ", "", MessageBoxButton.OK);
                    }
                    else
                    {
                        Row newRow = new Row {
                            Title = Title.Text, longitude = longitude, latitude = latitude, Radius = Double.Parse(temp_Radius), Ring_Tones = temp_RingTones, Type = (String)Type.SelectedItem, Note = temp_Note, Icon_Source_Dark = temp_icon_dark, Icon_Source_Light = temp_icon_light
                        };

                        Table.Add(newRow);
                        DB_Helper.insertRow(newRow);

                        NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));
                    }
                }
            }

            user_feedback.Speak("Location Saved");
            avoiddouble = true;
        }
예제 #2
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            #region Trial Mode Check
            //if (App.IsTrial == true)
            //{
            //    // enable ads
            //    adControl.Visibility = System.Windows.Visibility.Visible;
            //    //adControl.IsAutoRefreshEnabled = true;
            //    adControl.IsEnabled = true;
            //    adControl.IsAutoCollapseEnabled = false;
            //}
            //else
            //{
            //    // disables ads
            //    adControl.Visibility = System.Windows.Visibility.Collapsed;
            //    //adControl.IsAutoRefreshEnabled = false;
            //    adControl.IsEnabled = false;
            //    adControl.IsAutoCollapseEnabled = false;
            //}
            #endregion

            Table = DB_Helper.getAllRows();
            if (NavigationContext.QueryString["from"] == "map")
            {
                Location.Visibility      = Visibility.Collapsed;
                Location_Text.Visibility = Visibility.Collapsed;
                useMyLocation.Visibility = Visibility.Collapsed;
                if (NavigationContext.QueryString["page"] == "new")
                {
                    longitude            = Double.Parse(NavigationContext.QueryString["longitude"]);
                    latitude             = Double.Parse(NavigationContext.QueryString["latitude"]);
                    new_page             = true;
                    Title_New.Visibility = Visibility.Visible;
                }
                else
                {
                    Title_Edit.Visibility = Visibility.Visible;
                    String title = NavigationContext.QueryString["title"];
                    Edit_Query        = DB_Helper.getRowsbyTitle(title);
                    Title.Text        = title;
                    Radius.Text       = Edit_Query[0].Radius.ToString();
                    Type.SelectedItem = Edit_Query[0].Type;
                    if (Edit_Query[0].Ring_Tones != "")
                    {
                        Ring_Tones.SelectedItem = Edit_Query[0].Ring_Tones;
                    }
                    latitude  = Edit_Query[0].latitude;
                    longitude = Edit_Query[0].longitude;
                    Note.Text = Edit_Query[0].Note;

                    old_title     = title;
                    old_radius    = Edit_Query[0].Radius.ToString();
                    old_type      = Edit_Query[0].Type;
                    old_ringtones = Edit_Query[0].Ring_Tones;
                    old_note      = Edit_Query[0].Note;
                    change_UI(Edit_Query[0].Type);
                }
            }
            else
            {
                new_page             = true;
                Title_New.Visibility = Visibility.Visible;
                longitude            = Double.Parse(NavigationContext.QueryString["longitude"]);
                latitude             = Double.Parse(NavigationContext.QueryString["latitude"]);
            }
            if (new_page)
            {
                var b = (ApplicationBarIconButton)ApplicationBar.Buttons[2]; //indx based!
                b.IsEnabled = false;
            }
            // Call the base method.
            base.OnNavigatedTo(e);
        }