//Creates filters and adds to filtersPanel
 private void populate_Filters(int a)
 {
     for (int i = 0; i < partsFilters[a].Length; i++)
     {
         SurfaceRadioButton filter;
         filter            = new SurfaceRadioButton();
         filter.Foreground = Brushes.Black;
         filter.Background = Brushes.LightGray;
         filter.Name       = "filter" + a + "_" + i;
         filter.Content    = partsFilters[a][i];
         filter.Checked   += new RoutedEventHandler(searchByFilter);
         filtersPanel.Children.Add(filter);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Called by the cancel_click function
        /// </summary>
        private void cancel()
        {
            foreach (SurfaceRadioButton rb in radioButtons)
            {
                imageCover.Children.Remove(rb);
            }

            dic = new Dictionary<SurfaceRadioButton, String>();

            radioButtons = new List<SurfaceRadioButton>();
            dicPos = new Dictionary<SurfaceRadioButton, String>();
            buttonChecked = null;
            hotImageNames = new List<String>();
            hotImagePaths = new List<String>();
            hotAudioNames = new List<String>();
            hotAudioPaths = new List<String>();
            hotVideoNames = new List<String>();
            hotVideoPaths = new List<String>();
            addHotspotsEnabled = false;
            Edit.IsEnabled = false;
            AddText.IsEnabled = false;
            AddAudio.IsEnabled = false;
            AddImage.IsEnabled = false;
            AddVideo.IsEnabled = false;
        }
Exemplo n.º 3
0
        //When a hotspot is checked, display the information and allow user to change the contents
        public void newButton_Checked(SurfaceRadioButton sender)
        {
            sender.IsChecked = true;
            AddText.IsEnabled = false;
            AddImage.IsEnabled = false;
            AddAudio.IsEnabled = false;
            AddVideo.IsEnabled = false;
            //AddTextAndImage.IsEnabled = false;
            Edit.IsEnabled = false;

            buttonChecked = (SurfaceRadioButton)sender;
            if (dic.ContainsKey((SurfaceRadioButton)sender))
            {
                String info = dic[buttonChecked];
                String[] infos = Regex.Split(info, "/");
                String type = infos[1];
                Edit.IsEnabled = true;
                if (type == "text")
                {
                    AddImage.IsEnabled = true;
                    AddAudio.IsEnabled = true;
                    AddVideo.IsEnabled = true;
                    //AddTextAndImage.IsEnabled = true;
                }
                else if (type == "image")
                {
                    AddText.IsEnabled = true;
                    AddAudio.IsEnabled = true;
                    AddVideo.IsEnabled = true;
                   // AddTextAndImage.IsEnabled = true;
                }
                else if (type == "audio")
                {
                    AddImage.IsEnabled = true;
                    AddText.IsEnabled = true;
                    AddVideo.IsEnabled = true;
                   // AddTextAndImage.IsEnabled = true;
                }
                else if (type == "video")
                {
                    AddImage.IsEnabled = true;
                    AddAudio.IsEnabled = true;
                    AddText.IsEnabled = true;
                   // AddTextAndImage.IsEnabled = true;
                }
                else
                {
                    AddImage.IsEnabled = true;
                    AddAudio.IsEnabled = true;
                    AddText.IsEnabled = true;
                    AddVideo.IsEnabled = true;
                }

            }
            else
            {
                AddText.IsEnabled = true;
                AddImage.IsEnabled = true;
                AddAudio.IsEnabled = true;
                AddVideo.IsEnabled = true;
                //AddTextAndImage.IsEnabled = true;
            }
        }
Exemplo n.º 4
0
        //This creates the points when the users click on the artwork to create new hotspots
        public void CreateNewPoints(Point newPoint, String str)
        {
            Double x = newPoint.X;// -20;
                Double y = newPoint.Y;// -40;
                Double[] size = this.findImageSize();
                Double imagecurWidth = size[0] * image1.GetZoomableCanvas.Scale;
                Double imagecurHeight = size[1] * image1.GetZoomableCanvas.Scale;

                Point newP = image1.GetZoomableCanvas.Offset;

                Double canvasLeft = (x + newP.X) / imagecurWidth;
                Double canvasTop = (y + newP.Y) / imagecurHeight;

                String lon = canvasLeft.ToString();
                String lat = canvasTop.ToString();

                SurfaceRadioButton newButton = new SurfaceRadioButton();

                if (str != null)
                {
                    dic.Add(newButton, str);
                }

                //Default the new button on the map as checked;
                newButton.IsChecked = true;
                buttonChecked = newButton;

                newButton.Width = 1;
                newButton.Height = 1;

                foreach (SurfaceRadioButton rb in radioButtons)
                {
                    rb.IsChecked = false;
                }

                radioButtons.Add(newButton);
                dicPos.Add(newButton, lon + "/" + lat);

                imageCover.Children.Add(newButton);

                Canvas.SetLeft(newButton, x -3.5);
                Canvas.SetTop(newButton, y -3);
                Canvas.SetZIndex(newButton, 20);
                newButton_Checked(newButton);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Remove a hotspot from the list
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RemoveOne_Click(object sender, RoutedEventArgs e)
        {
            if (buttonChecked != null)
            {

                imageCover.Children.Remove(buttonChecked);
                radioButtons.Remove(buttonChecked);
                if (dic.ContainsKey(buttonChecked))
                {
                    String info = dic[buttonChecked];

                    String[] infos = Regex.Split(info, "/");

                    if (infos[1] == "image")
                    {
                        hotImagePaths.Remove(infos[2]);
                    }
                    else if (infos[1] == "audio")
                    {
                        hotAudioPaths.Remove(infos[2]);
                    }
                    else if (infos[1] == "video")
                    {
                        hotVideoPaths.Remove(infos[2]);
                    }

                    dic.Remove(buttonChecked);

                }
                dicPos.Remove(buttonChecked);

                    AddText.IsEnabled = false;
                    AddImage.IsEnabled = false;
                    AddAudio.IsEnabled = false;
                    AddVideo.IsEnabled = false;
                    buttonChecked = null;
                    Edit.IsEnabled = false;
            }
            else
            {
                MessageBox.Show("Please select the hotspot you want to remove!");
            }
        }
Exemplo n.º 6
0
        //Creates the button and shows them up on the right place
        public void createButtons(String str)
        {
            String[] buttonsInfo = System.Text.RegularExpressions.Regex.Split(str, "///");
            String lon = buttonsInfo[1];
            String lat = buttonsInfo[2];

            double db1 = Convert.ToDouble(lon);
            double db2 = Convert.ToDouble(lat);

            Ellipse newEllipse = new Ellipse();
            Ellipse backEllipse = new Ellipse();
            SurfaceRadioButton newButton = new SurfaceRadioButton();

            SolidColorBrush mySolidColorBrush = new SolidColorBrush();

            if (buttonsInfo[0] == "yellow")//yellow
            {
                mySolidColorBrush.Color = Color.FromArgb(255, 255, 255, 0);
                locButtons.Add(newButton, str);
            }
            else if (buttonsInfo[0] == "blue")//blue
            {
                mySolidColorBrush.Color = Color.FromArgb(255, 0, 0, 255);
                locButtons.Add(newButton, str);

            }
            else if (buttonsInfo[0] == "red")//red
            {
                mySolidColorBrush.Color = Color.FromArgb(255, 255, 0, 0);
                locButtons.Add(newButton, str);
            }

            newEllipse.Width = 22;
            newEllipse.Height = 22;
            backEllipse.Width = 26;
            backEllipse.Height = 26;

            SolidColorBrush newBrush = new SolidColorBrush();
            newBrush.Color = Color.FromRgb(0, 255, 127);
            newEllipse.Fill = mySolidColorBrush;
            backEllipse.Fill = newBrush;

            Location.Children.Add(newEllipse);
            Location.Children.Add(newButton);
            Location.Children.Add(backEllipse);

            double mapActualWidth = mapWidth * mapImage.GetZoomableCanvas.Scale;
            double mapActualHeight = mapHeight * mapImage.GetZoomableCanvas.Scale;
            double long1 = db1 * mapActualWidth - mapImage.GetZoomableCanvas.Offset.X;
            double lat1 = db2 * mapActualHeight - mapImage.GetZoomableCanvas.Offset.Y;

            ellipses.Add(newButton, newEllipse);
            backEllipses.Add(newButton, backEllipse);
            Canvas.SetLeft(newButton, long1 - 5 - 1 / mapImage.GetZoomableCanvas.Scale);
            Canvas.SetTop(newButton, lat1 - 3 - 0.5 / mapImage.GetZoomableCanvas.Scale);
            Canvas.SetZIndex(newButton, 10);
            Canvas.SetLeft(newEllipse, long1 - 3 - 1 / mapImage.GetZoomableCanvas.Scale);
            Canvas.SetTop(newEllipse, lat1 - 1 - 0.5 / mapImage.GetZoomableCanvas.Scale);
            Canvas.SetZIndex(newEllipse, 10);
            Canvas.SetLeft(backEllipse, long1 - 5 - 1 / mapImage.GetZoomableCanvas.Scale);
            Canvas.SetTop(backEllipse, lat1 - 3 - 0.5 / mapImage.GetZoomableCanvas.Scale);
            Canvas.SetZIndex(backEllipse, 8);

            //Make sure the buttons are within the map image.
            if (long1 < 0 || long1 > Location.Width)
            {
                newButton.Visibility = Visibility.Collapsed;
                newEllipse.Visibility = Visibility.Collapsed;
                backEllipse.Visibility = Visibility.Collapsed;
            }
            if (lat1 < 0 || lat1 > Location.Height)
            {
                newButton.Visibility = Visibility.Collapsed;
                newEllipse.Visibility = Visibility.Collapsed;
                backEllipse.Visibility = Visibility.Collapsed;
            }
        }
Exemplo n.º 7
0
        //Displays the infomation of the mapButtons
        public void newButton_Click(SurfaceRadioButton sender)
        {
            String str = locButtons[(SurfaceRadioButton)sender];
            sender.IsChecked = true;
            String name = data.title;
            if (name.Length > 20)
            {
                name = name.Substring(0, 20);
                name = name + "...";
            }

            String labelText = name + " ";
            String[] displayInfo = Regex.Split(str, "///");
            String locCategory = displayInfo[0];
            String date = displayInfo[3];
            String city = displayInfo[4];

            if (locCategory == "yellow")
            {
                if (city == "")
                {
                    labelText += "is currently kept here";
                }
                else
                {
                    labelText += "is currently at" + " " + city;
                }
                if (date != "")
                {
                    String[] strings = Regex.Split(date, "/");
                    if (strings[0] != "null" && strings[1] != "null")
                    {
                        labelText += ", " + "from" + " " + strings[0] + " to " + strings[1];
                    }
                    else
                    {
                        if (strings[0] == "null")
                        {
                            labelText += ", " + strings[1];
                        }
                        else
                        {
                            labelText += ", " + strings[0];
                        }
                    }
                }

            }
            else if (locCategory == "blue")
            {
                if (city == "")
                {
                    labelText += " was displayed here";
                }
                else
                {
                    labelText += " was displayed in" + " " + city;
                }
                if (date != "")
                {
                    String[] strings = Regex.Split(date, "/");
                    if (strings[0] != "null" && strings[1] != "null")
                    {
                        labelText += ", " + "from" + " " + strings[0] + " to " + strings[1];
                    }
                    else
                    {
                        if (strings[0] == "null")
                        {
                            labelText += ", " + strings[1];
                        }
                        else
                        {
                            labelText += ", " + strings[0];
                        }
                    }
                }
            }
            else
            {
                if (city == "")
                {
                    labelText += " was created here";
                }
                else
                {
                    labelText += " was created in" + " " + city;
                }
                if (date != "")
                {
                    String[] strings = Regex.Split(date, "/");
                    if (strings[0] != "null" && strings[1] != "null")
                    {
                        labelText += ", " + "from" + " " + strings[0] + " to " + strings[1];
                    }
                    else
                    {
                        if (strings[0] == "null")
                        {
                            labelText += ", " + strings[1];
                        }
                        else
                        {
                            labelText += ", " + strings[0];
                        }
                    }
                }
            }
            infoLabel.Text = labelText;
            Canvas.SetZIndex(infoLabel, 20);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Remove a hotspot from the map
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RemoveOne_Click(object sender, RoutedEventArgs e)
        {
            Boolean isChecked = false;
            SurfaceRadioButton checkedButton = new SurfaceRadioButton();
            foreach (SurfaceRadioButton rb in radioButtons)
            {
                if (rb.IsChecked == true)
                {
                    isChecked = true;
                    checkedButton = rb;
                }

            }
            if (isChecked)
            {
                mapCover.Children.Remove(checkedButton);
                mapCover.Children.Remove(dicRb[checkedButton]);
                radioButtons.Remove(checkedButton);
                if (cityInfo.ContainsKey(checkedButton))
                {
                    cityInfo.Remove(checkedButton);
                }
                if (dateInfo.ContainsKey(checkedButton))
                {
                    dateInfo.Remove(checkedButton);
                }
                //need to find out which kind of location the spot is and remove from the list before saving
                String str = dic[checkedButton];
                String[] strings = Regex.Split(str, ",");
                if (strings[0] == "red")
                {

                    originX.Remove(strings[1]);
                    originExists = false;

                }
                else if (strings[0] == "blue")
                {

                }
                else if (strings[0] == "yellow")
                {
                    currentX.Remove(strings[1]);
                    currLocationExists = false;
                }
                date.IsReadOnly = true;
                city.IsReadOnly = true;
                date.Text = "";
                city.Text = "";
                dateTo.Text = "";
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Please select the location you want to remove!");
            }
        }
Exemplo n.º 9
0
        private void date_TextChanged(object sender, TextChangedEventArgs e)
        {
            Boolean isChecked = false;
            SurfaceRadioButton checkedButton = new SurfaceRadioButton();
            foreach (SurfaceRadioButton rb in radioButtons)
            {
                if (rb.IsChecked == true)
                {
                    isChecked = true;
                    checkedButton = rb;
                }

            }
            if (isChecked)
            {

                if (dateInfo.ContainsKey(checkedButton))
                {
                    if (dateTo.Text != "")
                    {
                        if (date.Text != "")
                        {
                            dateInfo[checkedButton] = date.Text + "/" + dateTo.Text;
                        }
                        else
                        {
                            dateInfo[checkedButton] = "null/" + dateTo.Text;
                        }
                    }
                    else
                    {
                        if (date.Text != null)
                        {
                            dateInfo[checkedButton] = date.Text + "/null";
                        }
                        else
                        {
                            dateInfo[checkedButton] = "";
                        }
                    }
                }
                else
                {
                    if (date.Text != "" || dateTo.Text!="")
                    {
                        if(dateTo.Text =="")
                        {

                            String newStr = date.Text+ "/null";
                            dateInfo.Add(checkedButton, newStr);
                        }
                        else
                        {
                            String newStr = date.Text + dateTo.Text;
                            dateInfo.Add(checkedButton,newStr);
                        }
                    }
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Create hotspot icons in correct positions and colors
        /// </summary>
        /// <param name="lon"></param>
        /// <param name="lat"></param>
        /// <param name="color"></param>
        private void createCircles(String lon, String lat, string marker, string date, string city)
        {
            double db1 = Convert.ToDouble(lon);
            double db2 = Convert.ToDouble(lat);

            Ellipse newEllipse = new Ellipse();
            ellipses.Add(newEllipse);

            SurfaceRadioButton newMarker = new SurfaceRadioButton();
            newMarker.IsChecked = true;

            foreach (SurfaceRadioButton rb in radioButtons)
            {
                rb.IsChecked = false;
            }

            dicRb.Add(newMarker, newEllipse);

            SolidColorBrush mySolidColorBrush = new SolidColorBrush();
            dateInfo.Add(newMarker, date);
            cityInfo.Add(newMarker, city);
            if (marker == "current")//yellow
            {
                mySolidColorBrush.Color = Color.FromArgb(255, 255, 255, 0);
                currentX.Add(lon);
                dic.Add(newMarker, "yellow" + "," + lon + "," + lat);

            }
            else if (marker == "exhibit")//blue
            {
                mySolidColorBrush.Color = Color.FromArgb(255, 0, 0, 255);
                dic.Add(newMarker, "blue" + "," + lon + "," + lat);

            }
            else if (marker == "origin")//red
            {
                mySolidColorBrush.Color = Color.FromArgb(255, 255, 0, 0);
                originX.Add(lon);
                dic.Add(newMarker, "red" + "," + lon + "," + lat);
            }
            radioButtons.Add(newMarker);
            newEllipse.Width = 13.5;
            newEllipse.Height = 13.5;
            newEllipse.Fill = mySolidColorBrush;

            newMarker.Height = 1;
            newMarker.Width = 1;

            mapCover.Children.Add(newEllipse);
            mapCover.Children.Add(newMarker);

            //Set the location of the circle on the map
            Point newP = map1.GetZoomableCanvas.Offset;
            this.findImageSize();
            Double mapcurWidth = mapWidth * map1.GetZoomableCanvas.Scale; //the size of the zoomed map
            Double mapcurHeight = mapHeight * map1.GetZoomableCanvas.Scale;

            Double screenPosX = (db1 * mapcurWidth) - map1.GetZoomableCanvas.Offset.X;
            Double screenPosY = (db2 * mapcurHeight) - map1.GetZoomableCanvas.Offset.Y;

            Canvas.SetLeft(newEllipse, screenPosX - 20.8);
            Canvas.SetTop(newEllipse, screenPosY - 5);

            Canvas.SetLeft(newMarker, screenPosX - 22.8);
            Canvas.SetTop(newMarker, screenPosY - 13);
            this.newMarker_Click(newMarker);
        }
Exemplo n.º 11
0
        private void city_TextChanged(object sender, TextChangedEventArgs e)
        {
            Boolean isChecked = false;
            SurfaceRadioButton checkedButton = new SurfaceRadioButton();
            foreach (SurfaceRadioButton rb in radioButtons)
            {
                if (rb.IsChecked == true)
                {
                    isChecked = true;
                    checkedButton = rb;
                }

            }
            if (isChecked)
            {

                if (cityInfo.ContainsKey(checkedButton))
                {
                    cityInfo[checkedButton] = city.Text;
                }
                else
                {
                    if (city.Text != "")
                    {
                        String newStr = city.Text;
                        cityInfo.Add(checkedButton, newStr);
                    }
                }
            }
        }
Exemplo n.º 12
0
        public void newMarker_Click(SurfaceRadioButton sender)
        {
            sender.IsChecked = true;
            date.IsReadOnly = false;
            city.IsReadOnly = false;
            dateTo.IsReadOnly = false;
            //Make sure that if it's the origin location, no date could be entered
            String str = dic[(SurfaceRadioButton)sender];
            String[] strs = Regex.Split(str, ",");
            if (strs[0] == "red")
            {
                date.IsReadOnly = true;
                dateTo.IsReadOnly = true;
            }

            if (dateInfo.ContainsKey((SurfaceRadioButton)sender))
            {

                if (dateInfo[(SurfaceRadioButton)sender].Contains("/"))
                {

                    String[] strings = Regex.Split(dateInfo[(SurfaceRadioButton)sender], "/");
                    if (strings[0] == "null")
                    {
                        date.Text = "";
                        dateTo.Text = strings[1];
                    }
                    else if (strings[1] == "null")
                    {
                        date.Text = strings[0];
                        dateTo.Text = "";
                    }

                    else if (strings[0] == "null" && strings[1] == "null")
                    {
                        date.Text = "";
                        dateTo.Text = "";
                    }
                    else
                    {
                        date.Text = strings[0];
                        dateTo.Text = strings[1];
                    }
                }
                else
                {
                    date.Text = "";
                    dateTo.Text = "";
                }
            }
            else
            {
                date.Text = "";
                dateTo.Text = "";
            }

            if (cityInfo.ContainsKey((SurfaceRadioButton)sender))
            {
                city.Text = cityInfo[(SurfaceRadioButton)sender];
            }
            else
            {
                city.Text = "";
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Create new hotspots on the map
        /// </summary>
        /// <param name="newPoint"></param>
        public void CreateNewPoints(Point newPoint)
        {
            if (currLocationExists && currentMarker == "current")
            {
                canAdd = false;
            }
            else if (originExists && currentMarker == "origin")
            {
                canAdd = false;
            }
            else
            {
                canAdd = true;
            }
            if (buttonChecked != null)
            {
                if (canAdd)
                {
                    if (RadioColor != 0)
                    {   //get the point clicked and calculate the longitute and latitude
                        LengthConverter myLengthConverter = new LengthConverter();
                        Double db1 = newPoint.X - 27;
                        Double db2 = newPoint.Y - 87;

                        //These operations are used to calculate the exact longitude and latitude before saving into the xml file.
                        this.findImageSize();
                        Double mapcurWidth = mapWidth * map1.GetZoomableCanvas.Scale;
                        Double mapcurHeight = mapHeight * map1.GetZoomableCanvas.Scale;

                        Point newP = map1.GetZoomableCanvas.Offset;
                        Double canvasLeft = (db1 + newP.X) / mapcurWidth;
                        Double canvasTop = (db2 + newP.Y) / mapcurHeight;
                        String lon = canvasLeft.ToString();
                        String lat = canvasTop.ToString();

                        Ellipse newEllipse = new Ellipse();
                        ellipses.Add(newEllipse);

                        SurfaceRadioButton newMarker = new SurfaceRadioButton();

                        SolidColorBrush mySolidColorBrush = new SolidColorBrush();
                        if (currentMarker == "current")//yellow
                        {
                            mySolidColorBrush.Color = Color.FromArgb(255, 255, 255, 0);
                            currentX.Add(lon);
                            dic.Add(newMarker, "yellow" + "," + lon + "," + lat);
                            currLocationExists = true;
                        }
                        else if (currentMarker == "exhibit")//blue
                        {
                            mySolidColorBrush.Color = Color.FromArgb(255, 0, 0, 255);
                            dic.Add(newMarker, "blue" + "," + lon + "," + lat);
                        }
                        else if (currentMarker == "origin")//red
                        {
                            mySolidColorBrush.Color = Color.FromArgb(255, 255, 0, 0);
                            originX.Add(lon);
                            dic.Add(newMarker, "red" + "," + lon + "," + lat);
                            originExists = true;
                            canAdd = true;
                            currentMarker = null;
                        }

                        mapCover.Children.Add(newEllipse);
                        mapCover.Children.Add(newMarker);

                        newEllipse.Width = 13.5;
                        newEllipse.Height = 13.5;
                        newEllipse.Fill = mySolidColorBrush;
                        foreach (SurfaceRadioButton rb in radioButtons)
                        {
                            rb.IsChecked = false;
                        }
                        newMarker.IsChecked = true;

                        radioButtons.Add(newMarker);
                        dicRb.Add(newMarker, newEllipse);

                        Double screenPosX = canvasLeft - map1.GetZoomableCanvas.Offset.X; //need to reset the location thing
                        Double screenPosY = (map1.GetZoomableCanvas.Scale / (1 / 15) * db2) - map1.GetZoomableCanvas.Offset.Y;
                        Canvas.SetLeft(newEllipse, db1 - 20.8);
                        Canvas.SetTop(newEllipse, db2 - 5);

                        Canvas.SetLeft(newMarker, db1 - 22.8);
                        Canvas.SetTop(newMarker, db2 - 13);
                        buttonChecked.IsChecked = false; //only enable to create one circle at a time
                        RadioColor = 0;
                        currentMarker = null;
                    }
                }
                else
                {
                    System.Windows.MessageBox.Show("There may only be one location of origin and one current location.");
                    if (buttonChecked != null)
                    {
                        buttonChecked.IsChecked = false;
                        buttonChecked = null;
                    }

                    buttonChecked = null;
                    currentMarker = null;
                    return;
                }
            }
        }
Exemplo n.º 14
0
 private void SurfaceRadioButton_Checked_2(object sender, RoutedEventArgs e)
 {
     RadioColor = 3;
     currentMarker = "current";
     buttonChecked = (SurfaceRadioButton)sender;
 }
Exemplo n.º 15
0
        //Resets results field to empty and original size; aborts old search
        //Calls populate_ResultsPage and sets searchType
        public void searchByFilter(object sender, RoutedEventArgs e)
        {
            //If filter is checked and it's not for restore (i.e. index is -1)
            if (storedFilterIndex == -1)
            {
                String loc = Directory.GetCurrentDirectory();
                L0_resultsSV.Items.Clear();
                L0_resultsSV.Height = 920;
                if (_currentSearch != null)
                {
                    _currentSearch.Abort();
                }
                ProgressIndicator.Visibility = Visibility.Collapsed;

                SurfaceRadioButton filter = (SurfaceRadioButton)sender;
                filter.Focus();
                filterText = (String)filter.Content;

                if (_partTypeSelected == "prom")
                {
                    loc = loc.Substring(0, loc.IndexOf("bin")) + @"promoters2.txt";
                }
                if (PartTypeSelected == "rbs")
                {
                    loc = loc.Substring(0, loc.IndexOf("bin")) + @"rbs2.txt";
                }
                if (PartTypeSelected == "cds")
                {
                    loc = loc.Substring(0, loc.IndexOf("bin")) + @"cds2.txt";
                }
                if (PartTypeSelected == "term")
                {
                    loc = loc.Substring(0, loc.IndexOf("bin")) + @"terminators2.txt";
                }

                populate_ResultsPage(loc);
            }

            #region if(sw1) else statement
            //int index = filtersPanel.Children.IndexOf(filter);

            //_currentSearch = _progressBarWrapper.execute<int, String>(searchByFilter_longOp, index, new Action<String> (searchByFilter_callback));
            //searchByFilter_longOp(index);
            //}
            //catch (Exception exc) { Console.WriteLine(exc); }

            //populate_ResultsPage(loc2);

            //int m = L0_resultsSV.Items.Count;

            /*for (int i = L0_resultsSV.Items.Count - 1; i >= 0; i--)
             * {
             *  Part p = L0_resultsSV.Items.GetItemAt(i) as Part;
             *  if (p.partCategory.Text != filterText)
             *  {
             *      L0_resultsSV.Items.Remove(p);
             *  }
             * }*/

            //else
            //{
            //    String loc2 = Directory.GetCurrentDirectory();
            //    L0_resultsSV.Items.Clear();
            //    if (_currentSearch != null) _currentSearch.Abort();
            //    ProgressIndicator.Visibility = Visibility.Collapsed;

            //    SurfaceRadioButton filter = (SurfaceRadioButton)sender;
            //    String filterText = (String)filter.Content;


            //    loc2 = loc2.Substring(0, loc2.IndexOf("bin")) + @"promoters.txt";
            //    populate_ResultsPage(loc2);


            //    Console.WriteLine("The Current Count is: " + L0_resultsSV.Items.Count);
            //    for (int i = L0_resultsSV.Items.Count - 1; i >= 0; i--)
            //    {
            //        Console.WriteLine(L0_resultsSV.Items.Count);
            //        Part p = L0_resultsSV.Items.GetItemAt(i) as Part;
            //        if (p.partCategory.Text != filterText)
            //        {
            //            L0_resultsSV.Items.Remove(p);
            //        }
            //    }

            //}
            #endregion

            #region Attempted threading for not so great search

            //Search search = null;
            #region Extra search code
            //BackgroundWorker searcher = new BackgroundWorker();
            //searcher.WorkerSupportsCancellation = true;

            //searcher.DoWork += delegate(object s, DoWorkEventArgs args)
            //{};

            //searcher.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args)
            //{};

            //searcher.RunWorkerAsync();

            /*Thread searchThread = new Thread(delegate()
             *  {
             *      search = new Search(convertType_MCPToPR(_partTypeSelected));
             *  });
             * searchThread.Start();
             * searchThread.Join();*/
            #endregion

            /*Func<String, Search> _searchByFilter =
             *  delegate(String query) { return new Search(query); };
             * Action<Search> callback = delegate(Search result)
             * {
             *  foreach (RegDataSheet regDS in result.RegDS)
             *  {
             *      if (convertType_RDSToMCP(regDS.Type) == _partTypeSelected)
             *      {
             *          if (_partTypeSelected == "prom")
             *          {
             *              if (regDS.Promoter.getReg().Contains(filterText))
             *              { partFromRegDS(regDS, regDS.Promoter.getReg()); }
             *          }
             *          else if (_partTypeSelected == "rbs")
             *          {
             *              if (regDS.Rbs.FamilyName.Contains(filterText))
             *              {  partFromRegDS(regDS, regDS.Rbs.FamilyName); }
             *          }
             *          else if (_partTypeSelected == "cds")
             *          { partFromRegDS(regDS, "CDS"); }
             *          else //term
             *          {
             *              if (regDS.Terminators.Direction == filterText)
             *              { partFromRegDS(regDS, regDS.Terminators.Direction); }
             *          }
             *      }
             *  }
             * }*/

            //_currentSearch = _progressBarWrapper.execute<String, Search>(_searchByFilter, convertType_MCPToPR(_partTypeSelected), callback);
            #endregion
        }
Exemplo n.º 16
0
        //Clears and repopulates old filters; sets first filter to checked
        private void nav_Checked(object sender, RoutedEventArgs e)
        {
            //If checked when searchInAll is checked, do what? unfocus?
            int a = 0;

            if (sender == all)
            {
                _partTypeSelected = "all";
                filtersPanel.Children.Clear();
                L0_resultsSV.Items.Clear();
                CategoryBrowse.Visibility = System.Windows.Visibility.Hidden;
            }

            else
            {
                CategoryBrowse.Visibility = System.Windows.Visibility.Visible;

                if (sender == prom)
                {
                    a = 0;
                    _partTypeSelected = "prom";
                    //loc = loc.Substring(0, loc.IndexOf("bin")) + @"promoters.txt";
                    //populate_ResultsPage(loc);3
                }
                else if (sender == rbs)
                {
                    a = 1;
                    _partTypeSelected = "rbs";
                    //loc = loc.Substring(0, loc.IndexOf("bin")) + @"rbs.txt";
                    //populate_ResultsPage(loc);
                }
                else if (sender == cds)
                {
                    a = 2;
                    _partTypeSelected = "cds";
                    //loc = loc.Substring(0, loc.IndexOf("bin")) + @"cds.txt";
                    //populate_ResultsPage(loc);
                }
                else if (sender == term)
                { //sender == term
                    a = 3;
                    _partTypeSelected = "term";
                    //loc = loc.Substring(0, loc.IndexOf("bin")) + @"terminators.txt";
                    //populate_ResultsPage(loc);
                }
                filtersPanel.Children.Clear();
                populate_Filters(a);
                SurfaceRadioButton firstfilter = VisualTreeHelper.GetChild(filtersPanel, 0) as SurfaceRadioButton;
                firstfilter.IsChecked = true;
            }

            /*else if (sender == all)
             * {
             *  _partTypeSelected = "all";
             *  filtersPanel.Children.Clear();
             * }*/

            //If nav is checked and it isn't for search (i.e. searchBar unfocused) and not for restore
            //if (!(Boolean)searchInType.IsChecked /*&& !isRestore*/)
            //{
            //((SurfaceRadioButton)sender).Focus();

            /*if (_partTypeSelected != "all");
             * {
             *  filtersPanel.Children.Clear();
             *  populate_Filters(a);
             *  SurfaceRadioButton firstfilter = VisualTreeHelper.GetChild(filtersPanel, 0) as SurfaceRadioButton;
             *  firstfilter.IsChecked = true;
             * }*/
            //}
        }