Example #1
0
        public override void onTap(int floorNum, int vertexId)
        {
            const int    GET_DIRECTION      = 0;
            const int    OPEN_URL           = 1;
            const String GET_DIRECTION_TEXT = "Get Directions";
            const String OPEN_URL_TEXT      = "Open URL";

            //HACK: Replace with graph
            Vertex           v      = LocationService.CurrentBuilding.Vertices.FirstOrDefault(v1 => v1.ID == vertexId);
            SymbolicLocation symLoc = v.SymbolicLocations.FirstOrDefault();

            //if (symLoc == null)

            String[] items;
            if (symLoc == null || (!isLocationUrlWellFormed(symLoc.url)))
            {
                items = new String[1];             //URL is not applicable
                items[GET_DIRECTION] = GET_DIRECTION_TEXT;
            }
            else           //url is well-formed
            {
                items = new String[2];
                items[GET_DIRECTION] = GET_DIRECTION_TEXT;
                items[OPEN_URL]      = OPEN_URL_TEXT;
            }

            //TODO: Create Dialog, i.curEdge., new Page in WP 7
            //Two choices: Get directions or browse symbolic location's url
        }
Example #2
0
        public static BitmapImage getCorrectMarker(Vertex vertex)
        {
            //First check for 'walking' properties
            if (vertex.isStairEndpoint())
            {
                return(getStaircaseMarker());
            }
            if (vertex.isElevatorEndpoint())
            {
                return(getElevatorMarker());
            }

            SymbolicLocation symLoc = vertex.SymbolicLocations.FirstOrDefault();

            if (symLoc == null)
            {
                return(getNoSymbolicLocationMarker());
            }

            //v has a symbolic location. Now, check for special properties
            //SymbolicLocation symLoc = v.getLocation().getSymbolicLocation();
            if (symLoc.is_entrance.HasValue && symLoc.is_entrance.Value == true)
            {
                return(getEntranceMarker());
            }

            //HACK: The enum is found in the 'wrong' class
            switch ((EditSymbolicLocation.InfoType)symLoc.info_type)
            {
            case EditSymbolicLocation.InfoType.NONE:
                return(getSymbolicLocationMarker());     //NONE

            case EditSymbolicLocation.InfoType.OFFICE:
                return(getOfficeMarker());                 //OFFICE

            case EditSymbolicLocation.InfoType.DEFIBRELLATOR:
                return(getDefibrellatorMarker());         //DEFIBRELLATOR

            case EditSymbolicLocation.InfoType.FIRST_AID_KIT:
                return(getFirstAidMarker());               //FIRST_AID_KIT

            case EditSymbolicLocation.InfoType.FIRE_EXTINGUISHER:
                return(getFireExtinguisherMarker());       //FIRE_EXTINGUISHER

            case EditSymbolicLocation.InfoType.TOILET:
                return(getToiletMarker());                 //TOILET

            case EditSymbolicLocation.InfoType.FOOD:
                return(getFoodMarker());                       //FOOD

            case EditSymbolicLocation.InfoType.LECTURE_ROOM:
                return(getLectureRoomMarker());                //LECTURE_ROOM

            case EditSymbolicLocation.InfoType.STJERNE_DAG:
                return(getStarMarker());

            default:
                return(getSymbolicLocationMarker());    //NONE
            }
        }
        private void Tapped_UpdateTitle()
        {
            String title = "? - ?";

            if (mEndPoints.Count == 1)
            {
                Vertex           v1   = mEndPoints[0];
                SymbolicLocation s1   = v1.SymbolicLocations.FirstOrDefault();
                String           end1 = (s1 != null && s1.title != null)
                                ? s1.title
                                : getCoordinatesTitle(v1);
                title = end1 + " - ?";
            }
            else if (mEndPoints.Count == 2)
            {
                Vertex           v1   = mEndPoints[0];
                SymbolicLocation s1   = v1.SymbolicLocations.FirstOrDefault();
                String           end1 = (s1 != null && s1.title != null)
                                ? s1.title
                                : getCoordinatesTitle(v1);

                Vertex           v2   = mEndPoints[1];
                SymbolicLocation s2   = v2.SymbolicLocations.FirstOrDefault();
                String           end2 = (s2 != null && s2.title != null)
                                ? s2.title
                                : getCoordinatesTitle(v2);
                title = end1 + " - " + end2;
            }

            this.ApplicationTitle.Text = title;
        }
Example #4
0
        private static String createFoliaJsonLocation(Vertex v)
        {
            if (v == null)
            {
                return("null");
            }

            AbsoluteLocation absLoc = v.AbsoluteLocations[0];
            SymbolicLocation symLoc = null;

            foreach (SymbolicLocation s in v.SymbolicLocations)
            {
                symLoc = s;
                break;
            }

            //[
            // {id: , latitude: , longitude: , altitude: , title: , description: , url: , location_type: }
            // ]

            StringBuilder sb = new StringBuilder();

            sb.Append("{");
            sb.Append("id: ").Append(v.ID);
            sb.Append(", latitude: ").Append(absLoc.latitude);
            sb.Append(", longitude: ").Append(absLoc.longitude);
            sb.Append(", altitude: ").Append(absLoc.altitude);
            String title = symLoc != null ? symLoc.title : "null";

            sb.Append(", title: ").Append("'").Append(title).Append("'");
            String description = symLoc != null ? symLoc.description : "null";

            sb.Append(", description: ").Append("'").Append(description).Append("'");
            String url = symLoc != null ? symLoc.url : "null";

            sb.Append(", url: ").Append("'").Append(url).Append("'");
            sb.Append(", location_type: ").Append(symLoc != null ? symLoc.info_type : -1);
            //ToString capitalizes boolean, so necessary to call toLower
            string isStair = v.isStairEndpoint().ToString().ToLower();

            sb.Append(", isStairEndpoint: ").Append(isStair);
            string isElevator = v.isElevatorEndpoint().ToString().ToLower();

            sb.Append(", isElevatorEndpoint: ").Append(isElevator);
            string isEntrance = (symLoc != null && (symLoc.is_entrance ?? false)).ToString().ToLower();

            sb.Append(", isEntrance: ").Append(isEntrance);
            sb.Append("}");

            return(sb.ToString());
        }
        void saveButton_Click(object sender, EventArgs e)
        {
            //tmpSymLoc is used to pass data to UploadSymbolicLocationTask
            //Whether the operation is CREATE or UPDATE is determined in UploadSymbolicLocationTask
            SymbolicLocation tmpSymLoc = new SymbolicLocation();

            tmpSymLoc.title       = titleTextBox.Text;
            tmpSymLoc.description = descriptionTextBox.Text;
            tmpSymLoc.url         = urlTextBox.Text;
            tmpSymLoc.is_entrance = isEntranceCheckBox.IsChecked;
            int selectedInfoType = infoTypeListBox.SelectedIndex;

            tmpSymLoc.info_type = selectedInfoType < 0 ? 0 : selectedInfoType;

            UploadSymbolicLocationTask(tmpSymLoc);
        }
Example #6
0
        private static String createFoliaJsonLocationJava(Vertex v)
        {
            if (v == null)
            {
                return("null");
            }

            AbsoluteLocation absLoc = v.AbsoluteLocations[0];
            SymbolicLocation symLoc = null;

            foreach (SymbolicLocation s in v.SymbolicLocations)
            {
                symLoc = s;
                break;
            }

            StringBuilder sb = new StringBuilder();

            sb.Append("{");
            sb.Append("id: ").Append(v.ID);
            sb.Append(", latitude: ").Append(absLoc.latitude);
            sb.Append(", longitude: ").Append(absLoc.longitude);
            sb.Append(", altitude: ").Append(absLoc.altitude);
            String title = symLoc != null ? symLoc.title : "null";

            sb.Append(", title: ").Append("\"").Append(title).Append("\"");
            String description = symLoc != null ? symLoc.description : "null";

            sb.Append(", description: ").Append("\"").Append(description).Append("\"");
            String url = symLoc != null ? symLoc.url : "null";

            sb.Append(", url: ").Append("\"").Append(url).Append("\"");
            //sb.append(", location_type: ").append(symLoc != null ? symLoc.getType().toString() : "N/A");
            sb.Append(", location_type: ").Append(symLoc != null ? symLoc.info_type ?? -1 : -1);
            string isStairEndpoint = v.isStairEndpoint().ToString().ToLower();

            sb.Append(", isStairEndpoint: ").Append(isStairEndpoint);
            string isElevatorEndpoint = v.isElevatorEndpoint().ToString().ToLower();

            sb.Append(", isElevatorEndpoint: ").Append(isElevatorEndpoint);
            string isEntrance = (symLoc != null ? symLoc.is_entrance : false).ToString().ToLower();

            sb.Append(", isEntrance: ").Append(isEntrance);
            sb.Append("}");

            return(sb.ToString());
        }
        private void initializeInputBoxes()
        {
            SymbolicLocation tmpSymLoc = Map2DOffline.SelectedOfflineVertex.SymbolicLocations.FirstOrDefault();

            if (tmpSymLoc == null)
            {
                tmpSymLoc = new SymbolicLocation();
            }
            else //populate the input boxes
            {
                //Binding is not worth the hassle, but goes like this:
                //Binding titleBinding = new Binding("title");
                //titleBinding.Source = tmpSymLoc;
                //titleTextBox.SetBinding(TextBlock.TextProperty, titleBinding);
                titleTextBox.Text            = tmpSymLoc.title ?? "";
                descriptionTextBox.Text      = tmpSymLoc.description ?? "";
                urlTextBox.Text              = tmpSymLoc.url ?? "";
                isEntranceCheckBox.IsChecked = tmpSymLoc.is_entrance;
            }
        }
        //Upload a symbolicLocation in the background (update or create)
        //Form: AsyncTask<[Input Parameter Type], [Progress Report Type], [Result Type]>
        private void UploadSymbolicLocationTask(SymbolicLocation tmpSymLoc)
        {
            isUploading = true;
            mContext    = LocationService.radiomapContext;

            Vertex           currentVertex = Map2DOffline.SelectedOfflineVertex;
            SymbolicLocation currentSymLoc = currentVertex.SymbolicLocations.FirstOrDefault();

            //1) upload NEW symbolic location
            if (currentSymLoc == null)
            {
                mContext.AddRelatedObject(currentVertex, "SymbolicLocations", tmpSymLoc);
                currentVertex.SymbolicLocations.Add(tmpSymLoc);
            }
            //2) or UPDATE existing
            else
            {
                //copy updated values
                currentSymLoc.title       = tmpSymLoc.title;
                currentSymLoc.description = tmpSymLoc.description;
                currentSymLoc.url         = tmpSymLoc.url;
                currentSymLoc.is_entrance = tmpSymLoc.is_entrance;

                mContext.UpdateObject(currentSymLoc);
            }
            try
            {
                mContext.BeginSaveChanges(OnChangesSaved, mContext);

                //uploadProgressBar.Visibility = System.Windows.Visibility.Visible;
                uploadProgressIndicator.IsVisible = isUploading;
            }
            catch (Exception ex)
            {
                isUploading = false;
                uploadProgressIndicator.IsVisible = isUploading;

                MessageBox.Show(string.Format("The changes could not be saved.\n"
                                              + "The following error occurred: {0}", ex.Message));
            }
        }
Example #9
0
        private void AddVertexPin(Vertex v)
        {
            //Pushpin pushpin = new Pushpin();
            //pushpin.Style = (Style)(Application.Current.Resources["PushpinStyle"]);
            Image pushpin = MarkerConfig.CreateImage(v);

            //pushpin.Tap += new EventHandler<GestureEventArgs>(pushpin_Tap);
            pushpin.Tap += (object sender, GestureEventArgs args) =>
            {
                SymbolicLocation symLoc = v.SymbolicLocations.FirstOrDefault();
                if (symLoc != null)
                {
                    string title       = symLoc.title ?? "";
                    string description = symLoc.description ?? "";
                    string url         = symLoc.url ?? "";
                    MessageBox.Show(string.Format("{0}\n{1}\n{2}", title, description, url));
                }
            };

            AbsoluteLocation pos = v.AbsoluteLocations.First();

            mapLayerVertices.AddChild(pushpin, new GeoCoordinate((double)pos.latitude, (double)pos.longitude), PositionOrigin.BottomCenter);
        }
Example #10
0
 public void AddToSymbolicLocations(SymbolicLocation symbolicLocation)
 {
     base.AddObject("SymbolicLocations", symbolicLocation);
 }
Example #11
0
 public static SymbolicLocation CreateSymbolicLocation(int ID, int vertex_ID)
 {
     SymbolicLocation symbolicLocation = new SymbolicLocation();
     symbolicLocation.ID = ID;
     symbolicLocation.Vertex_ID = vertex_ID;
     return symbolicLocation;
 }