public static List <Listings> GetAll(string terms = "") { List <Listings> Listings = new List <Listings>(); string sql; int listingCode; int.TryParse(terms, out listingCode); if (terms == "") { sql = "SELECT * FROM Listings"; } else { sql = "SELECT * FROM Listings WHERE title like '%" + terms + "%' OR ListingCode = " + listingCode; } DataTable _categories = Db.getAll(sql); foreach (DataRow row in _categories.Rows) { Listings listing = new Listings(); var _id = row["id"].ToString(); int id; int.TryParse(_id, out id); listing.Id = id; listing.Get(); Listings.Add(listing); } return(Listings); }
/// <inheritdoc cref="SiteSearcher" /> private async Task ProcessURL(Uri url, CancellationToken ct) { var listings = await Fetcher.GetListingsAsync(url, ct); if (listings != null) { ListingBase tmpListing = null; try { foreach (var listing in listings) { tmpListing = listing; // get the description and the apply email await Fetcher.GetRemainingListingDataAsync(listing, ct); Listings.Add(listing); } } catch (Exception e) { var vm = new OkViewModel(e.Message + "\n" + url + "\n" + tmpListing, "Search Error"); DialogService.OpenDialog(vm, null); } } }
public void Delete_CommentId_OpenViewResult() { // Arrange var commentController = this.CreateCommentController(true); //create new listing for comment Listings listing = new Listings() { Name = "good Car", Description = "easy free car :(", Userid = fakeUser.Id }; mockadvert_siteContext.Listings.Add(listing); mockadvert_siteContext.SaveChanges(); var comment = new Comments() { Listingid = listing.Id, Text = "HAHA", }; mockadvert_siteContext.Comments.Add(comment); mockadvert_siteContext.SaveChanges(); var result = commentController.Delete(comment.Id); // Assert Assert.IsType <ViewResult>(result); }
public ActionResult Edit(string listingID, bool Internal = false) { var serialization = new Serialization(); var listingsBA = new Listings(); var HashCriteria = new Hashtable(); var listingsModel = new ListingModel(); var listing_ID = Convert.ToInt64(CipherTool.DecryptString(listingID)); listingsModel.loanInformation = new LoanInformation(); var dropdownValues = new LoanInformation(); HashCriteria.Add("UserID", userID); HashCriteria.Add("ID", listing_ID); HashCriteria.Add("CurrentTab", "LoanInformation"); var actualCriteria = serialization.SerializeBinary((object)HashCriteria); var result = listingsBA.EditCurrentListing(actualCriteria); var listingEditModel = (LoanInformation)(serialization.DeSerializeBinary(Convert.ToString(result))); var defaultValues = listingsBA.GetListingDefaultValuesForLoanInformation(); dropdownValues = (LoanInformation)(serialization.DeSerializeBinary(Convert.ToString(defaultValues))); listingEditModel.ListingType = GetListingLoanType(); listingEditModel.RateType = dropdownValues.RateType; listingEditModel.AmortizationType = dropdownValues.AmortizationType; listingEditModel.PaymentsFrequency = dropdownValues.PaymentsFrequency; listingEditModel.LienPositionType = dropdownValues.LienPositionType; listingEditModel.JuniorTrustDeedORMortgageList = dropdownValues.JuniorTrustDeedORMortgageList; listingsModel.loanInformation = listingEditModel; if (Internal) { return(PartialView("_LoanInformation", listingsModel.loanInformation)); } return(View("AddListing", listingsModel)); }
private void LoadRecentItems() { string html = ""; List <Listings> RecentItems = Listings.GetLastListing(8); foreach (var item in RecentItems) { html += @" <div class='col-md-3 gallery-grid '> <a href = 'single.aspx?id=" + item.Id + @"'> <img src = 'data/" + item.ImageUrl + @"' class='img-responsive'/> <div class='gallery-info'> <div class='quick'> <p><span class='glyphicon glyphicon-eye-open' aria-hidden='true'></span>view</p> </div> </div> </a> <div class='galy-info'> <p>" + item.Title + @"</p> <div class='galry'> <div class='prices'> <h5 class='item_price'>£ " + item.Price + @"</h5> </div> <div class='clearfix'></div> </div> </div> </div> "; } lblRecentListingContainer.Text = html; }
public Bids(Listings Listing, Users User, int Price) { this.Listing = Listing; this.User = User; this.Price = Price; this.DateTime = DateTime.Now; }
public List <ListingType> GetListingLoanType() { var listingsBA = new Listings(); var lstLoanType = listingsBA.GetListingLoanTypes(); return(lstLoanType); }
public void Get() { string sql = "SELECT * FROM Bids WHERE id = " + Id; DataRow row = Db.getOne(sql); if (!row.IsNull(0)) { var _listingId = row["listingid"].ToString(); int listingId; int.TryParse(_listingId, out listingId); Listing = new Listings(); Listing.Id = listingId; Listing.Get(); var _userId = row["userid"].ToString(); int userId; int.TryParse(_userId, out userId); User = new Users(); User.Id = userId; var _price = row["price"].ToString(); int price; int.TryParse(_price, out price); Price = price; var dateTime = row["datetime"].ToString(); DateTime = Convert.ToDateTime(dateTime); } }
// Code to execute when the application is launching (eg, from Start) // This code will not execute when the application is reactivated private void Application_Launching(object sender, LaunchingEventArgs e) { if (LatestShows == null) { LatestShows = new Listings(); } if (Torrents == null) { Torrents = new Torrents(); } if (Shows == null) { Shows = new Shows(); } if (db == null) { db = new DC(); } if (!db.DatabaseExists()) { db.CreateDatabase(); } //pre load shows //if (!App.Shows.IsDataLoaded) { // App.Shows.LoadData(false); //} }
private void FillTreeView(Listings TreeListing) { TreeNode nod; try { tvwBusiness.BeginUpdate(); foreach (Listing li in TreeListing.Listing) { nod = new TreeNode(li.CompanyName); nod.Nodes.Add(li.Address); nod.Nodes.Add(li.Phone); tvwBusiness.Nodes.Add(nod); } tvwBusiness.EndUpdate(); } catch (Exception ex) { MessageBox.Show("Could not parse results (" + ex.Message + ")!"); } finally { tvwBusiness.Nodes.Clear(); } }
public IActionResult getListingById(int listingId) { string StoredProcedureName = ListingsProcedures.getListingById; Dictionary <string, object> Parameters = new Dictionary <string, object>(); Parameters.Add("@ListingId", listingId); DataTable dt = dbMan.ExecuteReader(StoredProcedureName, Parameters); if (dt == null) { return(StatusCode(404)); } Listings listing = new Listings(); listing.id = Convert.ToInt32(dt.Rows[0]["id"]); listing.expirationDate = Convert.ToDateTime(dt.Rows[0]["expirationDate"]); listing.price = Convert.ToInt32(dt.Rows[0]["price"]); listing.shreets = Convert.ToInt32(dt.Rows[0]["shreets"]); listing.elbas = Convert.ToInt32(dt.Rows[0]["elbas"]); listing.userId = Convert.ToInt32(dt.Rows[0]["userId"]); listing.drugId = Convert.ToInt32(dt.Rows[0]["drugId"]); listing.drugName = Convert.ToString(dt.Rows[0]["drugName"]); listing.sellerName = Convert.ToString(dt.Rows[0]["sellerName"]); return(Json(listing)); }
public async Task CreateAsync_Comment_CreateNewComment() { // Arrange var commentController = this.CreateCommentController(true); Comments comment = new Comments() { Text = "TestComment" }; //create new listing for comment Listings listing = new Listings() { Name = "Test Nice Car", Description = "free car :)", Userid = fakeUser.Id }; mockadvert_siteContext.Listings.Add(listing); mockadvert_siteContext.SaveChanges(); //get id int id = listing.Id; // Act var result = (RedirectToActionResult)await commentController.CreateAsync(id, comment); var addedComment = await mockadvert_siteContext.Comments.FirstAsync(c => c.Userid == fakeUser.Id); // Assert Assert.Equal(addedComment.Text, comment.Text); Assert.Equal(addedComment.Userid, fakeUser.Id); }
public ActionResult SavePropertyInformation(PropertyInformation model) { var serialization = new Serialization(); var listingsBA = new Listings(); long listingID = 0; if (ModelState.IsValid) { var HashCriteria = SetHashCriteriaForPropertyInformation(model); var actualCriteria = serialization.SerializeBinary((object)HashCriteria); var result = listingsBA.SavePropertyInformation(actualCriteria); listingID = Convert.ToInt64(serialization.DeSerializeBinary(Convert.ToString(result))); } else { PropertyInformation propertyInformation = new PropertyInformation(); var result = listingsBA.GetListingDefaultValuesForPropertyInformation(); propertyInformation = (PropertyInformation)(serialization.DeSerializeBinary(Convert.ToString(result))); return(PartialView("_PropertyAndBorrowerInfo", propertyInformation)); } string ListingID = CipherTool.EncryptString(Convert.ToString(listingID), true); var jsonResult = new[] { new { ListingID = ListingID, ID = listingID }, }; return(Json(jsonResult, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Attempts to create a secured banner image URL /// </summary> /// <returns> Returns if able, a secured banner image url, or an empty string otherwise. </returns> public string GetHttpsSecuredHeaderImage() { if (HeaderImageURL != null && HeaderImageURL.ToLower().Contains("https")) { return(HeaderImageURL); } else if (AppID != 0) { if (Listings != null) { Listing listing = Listings.FirstOrDefault(); if (listing != null) { if (listing.IsComplex()) { return("https://steamcdn-a.akamaihd.net/steam/subs/" + AppID + "/capsule_sm_120.jpg"); } } } return("https://steamcdn-a.akamaihd.net/steam/apps/" + AppID + "/capsule_sm_120.jpg"); //"/header_292x136.jpg"; } return(string.Empty); }
public async Task <IActionResult> Edit(int id, [Bind("ListingsId,ListingNumber,SmlsNumber,TuNuevoEspacioNumber,IsSmlsPromoted,IsTuNuevoEspacioPromoted,ListingType,Address,City,Department,BloqueNumber,UnitNumber,UrbanizationName,Neighborhood,Estrato,SalesPrice,AdministrationFee,ParkingSpaces,HasOpenKitchen,HasElevator,IsClosedUrbanization,FkCompaniesId,HasBalcony,HasMaidRoom,IsStudio,HasPool,YearBuilt,FkContactsId,AreaSize,NumberOfRooms,NumberOfBathrooms")] Listings listings) { if (id != listings.ListingsId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(listings); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ListingsExists(listings.ListingsId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["FkCompaniesId"] = new SelectList(_context.Companies, "CompaniesId", "CompanyName", listings.FkCompaniesId); ViewData["FkContactsId"] = new SelectList(_context.Contacts, "ContactsId", "ContactLastNames", listings.FkContactsId); return(PartialView(listings)); }
/// <summary> /// Fires when the user is trying to send a new transaction to the database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void SubmitTransaction_Button_Click(object sender, RoutedEventArgs e) { try { if (SessionState.LoggedIn == false) { MessageDialog message = new MessageDialog("You are not signed in. Please proceed to the sign in page."); await message.ShowAsync(); } //Build the POST request to the server SimpleListing newListing = new SimpleListing(); newListing.Author = Author_TextBox.Text; newListing.ISBN = ISBN_TextBox.Text; newListing.Price = Convert.ToInt32(Price_TextBox.Text); newListing.Title = Title_TextBox.Text; newListing.Description = Description_TextBox.Text; string json = new Listings().GenerateRequestJson(newListing); dynamic desResponse = JsonConvert.DeserializeObject((string)JsonConvert.DeserializeObject(json)); var listingId = desResponse.NewListingId; MessageDialog successMessage = new MessageDialog("The transaction has been created."); await successMessage.ShowAsync(); } catch (Exception ex) { } }
public async Task Price(string ticker) { Listings = (Listings == null || DateTime.Now.AddHours(-24) > Listings.LastUpdatedFromApi) ? this.GetListings().Result : Listings; var coin = Listings.Currencies.FirstOrDefault(c => c.Symbol.Equals(ticker.ToUpperInvariant())); Currency prices = null; if (coin != null) { prices = await this.GetPrices(coin.Id); } var resultString = prices != null ? prices.CoinData.Id != 1 ? $"```Currency: {prices.CoinData.Name}\nTicker: {prices.CoinData.Symbol}\nPrice USD: {prices.CoinData.Quotes.PriceUSD.Price}\nPrice BTC: {prices.CoinData.Quotes.PriceBTC.Price}\nChange(24h): {prices.CoinData.Quotes.PriceUSD.PercentChange24h}%```" : $"```Currency: {prices.CoinData.Name}\nTicker: {prices.CoinData.Symbol}\nPrice USD: {prices.CoinData.Quotes.PriceUSD.Price}\nChange(24h): {prices.CoinData.Quotes.PriceUSD.PercentChange24h}%```" : $"Could not get the price."; var isBotChannel = this.Context.Channel.Id.Equals(DiscordDataConstants.BotChannel); await this.Context.Guild.GetTextChannel(DiscordDataConstants.BotChannel) .SendMessageAsync($"{(isBotChannel ? resultString : $"{this.Context.Message.Author.Mention} {resultString}")}");
public Response UpdateStatus(long id, Listings status) { Response response = new Response(); try { using (IDbConnection conn = GetConnection()) { var item = Read(id); if (item.listing == null) { response.Status = false; response.Description = "Invalid Property"; return(response); } var listing = item.listing; listing.status = status.status; conn.Update(listing); response.Status = true; response.Description = "Successful"; } } catch (Exception ex) { response.Status = false; response.Description = ex.Message; } return(response); }
public async Task <IActionResult> Edit(int id, [Bind("Id,ListingUrl,ScrapeId,LastScraped,Name,Summary,Space,Description,ExperiencesOffered,NeighborhoodOverview,Notes,Transit,Access,Interaction,HouseRules,ThumbnailUrl,MediumUrl,PictureUrl,XlPictureUrl,HostId,HostUrl,HostName,HostSince,HostLocation,HostAbout,HostResponseTime,HostResponseRate,HostAcceptanceRate,HostIsSuperhost,HostThumbnailUrl,HostPictureUrl,HostNeighbourhood,HostListingsCount,HostTotalListingsCount,HostVerifications,HostHasProfilePic,HostIdentityVerified,Street,Neighbourhood,NeighbourhoodCleansed,NeighbourhoodGroupCleansed,City,State,Zipcode,Market,SmartLocation,CountryCode,Country,Latitude,Longitude,IsLocationExact,PropertyType,RoomType,Accommodates,Bathrooms,Bedrooms,Beds,BedType,Amenities,SquareFeet,Price,WeeklyPrice,MonthlyPrice,SecurityDeposit,CleaningFee,GuestsIncluded,ExtraPeople,MinimumNights,MaximumNights,CalendarUpdated,HasAvailability,Availability30,Availability60,Availability90,Availability365,CalendarLastScraped,NumberOfReviews,FirstReview,LastReview,ReviewScoresRating,ReviewScoresAccuracy,ReviewScoresCleanliness,ReviewScoresCheckin,ReviewScoresCommunication,ReviewScoresLocation,ReviewScoresValue,RequiresLicense,License,JurisdictionNames,InstantBookable,IsBusinessTravelReady,CancellationPolicy,RequireGuestProfilePicture,RequireGuestPhoneVerification,CalculatedHostListingsCount,ReviewsPerMonth")] Listings listings) { if (id != listings.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(listings); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ListingsExists(listings.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Id"] = new SelectList(_context.Listings, "Id", "Access", listings.Id); return(View(listings)); }
public ActionResult SaveCommentsInformation(CommentsInformation model) { var serialization = new Serialization(); var listingsBA = new Listings(); long listingID = 0; if (ModelState.IsValid) { Hashtable HashCriteria = new Hashtable(); HashCriteria.Add("ListingID", model.ID); HashCriteria.Add("Comments", model.Comments); HashCriteria.Add("IsSellerOffering", model.IsSellerOffering); HashCriteria.Add("SellerOfferingPercentage", model.SellerOfferingPercentage); HashCriteria.Add("UserID", userID); var actualCriteria = serialization.SerializeBinary((object)HashCriteria); var result = listingsBA.SaveCommentsInformation(actualCriteria); listingID = Convert.ToInt64(serialization.DeSerializeBinary(Convert.ToString(result))); } else { return(PartialView("_Comments", model)); } var ListingID = CipherTool.EncryptString(Convert.ToString(listingID), true); var jsonResult = new[] { new { ListingID = ListingID, ID = listingID }, }; return(Json(jsonResult, JsonRequestBehavior.AllowGet)); }
public ActionResult SaveDocumentsInformation(DocumentsInformation model) { var serialization = new Serialization(); var listingsBA = new Listings(); long listingID = 0; if (ModelState.IsValid) { var HashCriteria = SetHashCriteriaForDocumentInformation(model); var actualCriteria = serialization.SerializeBinary((object)HashCriteria); var result = listingsBA.SaveDocumentsInformation(actualCriteria); listingID = Convert.ToInt64(serialization.DeSerializeBinary(Convert.ToString(result))); SaveListingDocuments(Convert.ToInt64(listingID)); SaveListingImages(Convert.ToInt64(listingID)); Session["ListingDocuments"] = null; Session["ListingImages"] = null; } else { return(PartialView("_Documents", model)); } string ListingID = Synoptek.SessionManagement.CipherTool.EncryptString(Convert.ToString(listingID), true); var jsonResult = new[] { new { ListingID = ListingID, ID = listingID }, }; return(Json(jsonResult, JsonRequestBehavior.AllowGet)); }
public long SaveListingDocuments(long listingID) { var serialization = new Serialization(); var listingsBA = new Listings(); var result = string.Empty; var resultlisting = 0; var lstDocuments = Session["ListingDocuments"] as List <ListingLoanDocuments>; if (lstDocuments != null && lstDocuments.Count > 0) { foreach (var tempfile in lstDocuments) { var TempDocumentPath = System.Configuration.ConfigurationManager.AppSettings["ListingTempDocumentPath"]; TempDocumentPath = TempDocumentPath + "/" + tempfile.DocumentType; var DocumentPath = System.Configuration.ConfigurationManager.AppSettings["ListingDocumentPath"] + "/" + listingID; DocumentPath = DocumentPath + "/" + tempfile.DocumentType; var folderExists = Directory.Exists(Server.MapPath(DocumentPath)); if (!folderExists) { Directory.CreateDirectory(Server.MapPath(DocumentPath)); } var TempserverPath = Server.MapPath(TempDocumentPath + "/" + tempfile.FileName); var ActualImagePath = Server.MapPath(DocumentPath + "/" + tempfile.FileName); var docpresent = System.IO.File.Exists(ActualImagePath); var tempPresent = System.IO.File.Exists(TempserverPath); if (!docpresent && tempPresent) { if (!tempfile.IsDeleted) { System.IO.File.Copy(TempserverPath, ActualImagePath); } } if (docpresent && tempfile.IsDeleted) { System.IO.File.Delete(Server.MapPath(DocumentPath + "/" + tempfile.FileName)); } //Save listing Documents in database Hashtable HashCriteria = new Hashtable(); HashCriteria.Add("FileName", tempfile.FileName); HashCriteria.Add("IsDeleted", tempfile.IsDeleted); HashCriteria.Add("ID", tempfile.id); HashCriteria.Add("DocumentTypeID", tempfile.DocumentTypeID); HashCriteria.Add("ListingID", listingID); HashCriteria.Add("UserID", userID); var actualCriteria = serialization.SerializeBinary((object)HashCriteria); result = Convert.ToString(listingsBA.SaveUploadedListingDocuments(actualCriteria)); resultlisting = Convert.ToInt32(serialization.DeSerializeBinary(Convert.ToString(result))); var res = System.IO.File.Exists(TempDocumentPath + "/" + tempfile.FileName); if (res) { System.IO.File.Delete(Server.MapPath(TempDocumentPath + "/" + tempfile.FileName)); } } } return(resultlisting); }
public ActionResult DeleteConfirmed(int id) { Listings listings = db.Listings.Find(id); db.Listings.Remove(listings); db.SaveChanges(); return(RedirectToAction("Index")); }
public override int GetHashCode() { unchecked { var hashCode = RecursiveCount; hashCode = (hashCode * 397) ^ Count; hashCode = (hashCode * 397) ^ (Listings != null ? Listings.GetHashCode() : 0); return(hashCode); } }
public Product GetProduct(string listingId, string productId) { Product product = Listings.Find(l => l.ID.Equals(listingId) || l.Name.Equals(listingId)).Products.Where(p => p.ProductID.Equals(productId)).First(); if (product == null) { Console.WriteLine("Product with listing identifier {0} and product id {1} does not exist.", listingId, productId); } return(product); }
public void RemoveListing(string listingId) { int index = Listings.FindIndex(li => li.ID.Equals(listingId)); if (index < 0) { return; } Listings.RemoveAt(index); }
public S_SHOW_PARTY_MATCH_INFO(TeraMessageReader reader) : base(reader) { var count = reader.ReadUInt16(); var offset = reader.ReadUInt16(); var page = reader.ReadInt16(); var pages = reader.ReadInt16(); if (page == 0) { Listings.Clear(); } if (count == 0) { Listings.Clear(); IsLast = true; return; } reader.BaseStream.Position = offset - 4; for (var i = 0; i < count; i++) { var l = new Listing(); var curr = reader.ReadUInt16(); var next = reader.ReadUInt16(); var msgOffset = reader.ReadUInt16(); var leaderNameOffset = reader.ReadUInt16(); var leaderId = reader.ReadUInt32(); var isRaid = reader.ReadBoolean(); var playerCount = reader.ReadInt16(); reader.BaseStream.Position = msgOffset - 4; var msg = reader.ReadTeraString(); reader.BaseStream.Position = leaderNameOffset - 4; var leaderName = reader.ReadTeraString(); l.LeaderName = leaderName; l.LeaderId = leaderId; l.IsRaid = isRaid; l.Message = msg; l.PlayerCount = playerCount; Listings.Add(l); if (next != 0) { reader.BaseStream.Position = next - 4; } } if (page < pages) { Proxy.RequestNextLfgPage(page + 1); } if (page == pages) { IsLast = true; } }
public static List <Listings> GetLastListing(int limit) { string sql = "SELECT TOP " + limit + " * FROM Listings ORDER BY Id DESC "; List <Listings> items = new List <Listings>(); DataTable dt = Db.getAll(sql); if (dt.Rows.Count == 0) { return(items); } foreach (DataRow row in dt.Rows) { if (!row.IsNull(0)) { Listings listing = new Listings(); var _id = row["Id"].ToString(); int id; int.TryParse(_id, out id); listing.Id = id; var _listingCode = row["ListingCode"].ToString(); int listCode; int.TryParse(_listingCode, out listCode); listing.ListingCode = listCode; listing.Title = row["Title"].ToString(); var _catId = row["CategoryId"].ToString(); int catId; int.TryParse(_catId, out catId); listing.Category.Id = catId; var _userId = row["SellerId"].ToString(); int userId; int.TryParse(_userId, out userId); listing.User.Id = userId; listing.Description = row["description"].ToString(); var _price = row["Price"].ToString(); int price; int.TryParse(_price, out price); listing.Price = price; var _addedDate = row["AddedDate"].ToString(); listing.AddedDate = Convert.ToDateTime(_addedDate); var _lastDate = row["lastDate"].ToString(); listing.LastDate = Convert.ToDateTime(_lastDate); listing.ImageUrl = row["ImageUrl"].ToString(); items.Add(listing); } } return(items); }
private void GetSearchTerms() { if (Request.QueryString["terms"] == null) { Response.Redirect("Default.aspx"); return; } terms = Request.QueryString["terms"].ToString(); SearchResult = Listings.GetAll(terms); }
public void Setup() { Car ford = new Car("Ford", "F350", 2019, "leather seats and all the bells and whistles", 50000.89, "New", "whatever", "truck", "gas"); Car honda = new Car("Honda", "Civic", 1989, "how dare you", 1000, "Sorta New", "whatever", "car", "gas"); Car toyota = new Car("Toyota", "Tacoma", 2011, "full of trash", 12000, "old", "whatever", "truck", "gas"); Car tracker = new Car("Darryl", "Frankenstein", 1989, "mostly a tracker", 1000000, "New Parts....", "whatever", "truck", "gas"); Furniture couch = new Furniture(2011, "its a brown leather couch", 100, "Its very cracked and warn", "n______n", "Couch"); Listings.AddRange(new Listing[] { ford, honda, toyota, tracker, couch }); }
void Setup(InteractDialogMsg msg) { // set visible Visible = true; if (msg.items != null) { // copy new items items = msg.items; // set game object interactObject = msg.baseobj; xmlData = msg.baseXML; // set position //area.x = x; //area.y = y; // Setup buttons List<string> entries = new List<string>(); listings = new Listings(); listings.subCategories.Clear(); listings.items.Clear(); // Build catagories foreach (InteractionMap item in items) { if (item.category != null) { foreach (string category in item.category) { ParseCategory(listings, category); } } } // Fill entries foreach (InteractionMap item in items) { if (item.category != null && item.category.Count > 0) { foreach (string category in item.category) { AddtoCategory(item, listings, category); } } else { listings.items.Add(item); } } //rmenu.Setup(entries); RightPanelInit(listings); current = listings; } else { interactObject = null; xmlData = ""; } }
/// <summary> /// Initializes a new instance of the <see cref="Listings.Enumerator"/> class. /// </summary> /// <param name='listings'> /// Listings. /// </param> public Enumerator(Listings listings) { this.listings = listings; if (this.listings.listings == null) { this.listings.listings = new Listing[0]; } i = -1; }
void AddtoCategory(InteractionMap item, Listings parent, string category) { string front; int start; // check if subcatagories listed in string if ((start = category.IndexOf("/")) >= 0) { front = category.Substring(0, start); AddtoCategory(item, parent.FindSubCatagory(front), category.Substring(start + 1, category.Length - (start+1))); } else { Listings subcat = parent.FindSubCatagory(category); subcat.items.Add(item); } }
public override void Initialize(ScreenInfo parent) { // Create the space to make the left and right side menus // and add the generated GUIMenu objects into it. List<GUIObject> find = FindObjectsOfType(typeof(GUIMenu)); if (find.Count > 0) lmenu = find[0] as GUIMenu; find = FindObjectsOfType(typeof(GUIScrollMenu)); if (find.Count > 0) rmenu = find[0] as GUIScrollMenu; find = FindObjectsOfType(typeof(GUILabel)); if (find.Count > 0) { title = find[0] as GUILabel; if (interactObject != null) title.text = interactObject.prettyname; } find.Clear(); Elements.Clear(); GUIVerticalCommand vert = new GUIVerticalCommand(); vert.Elements = new List<GUIObject>(); Elements.Add(vert); if (title != null ) vert.Elements.Add(title); GUISpace space = new GUISpace(); space.pixels = 5; vert.Elements.Add(space); if (lmenu != null && rmenu != null) { GUIHorizontalCommand hc = new GUIHorizontalCommand(); hc.Elements = new List<GUIObject>(); hc.Elements.Add(lmenu); hc.Elements.Add(rmenu); vert.Elements.Add(hc); } base.Initialize(parent); patient = Patient.FindObjectOfType(typeof(Patient)) as Patient; Object[] temp = ObjectInteraction.FindObjectsOfType(typeof(ObjectInteraction)); foreach (Object obj in temp) { if (obj == patient) continue; roomObjects.Add(obj as ObjectInteraction); } listings = new Listings(); listings.category = "root"; current = listings; }
public override void Execute() { if (!Visible) return; base.Execute(); int i; List<GUIMenu.MenuButton> buttons = lmenu.GetButtons(); GUIMenu.MenuButton mbutton = lmenu.GetOnButton(); if ( mbutton != null ) { // Check Target button, if active if ( mbutton.button.text == sHome ) // Patient button { interactObject = target; // change title if ( title != null ) title.text = interactObject.prettyname; InteractDialogMsg idmsg = new InteractDialogMsg(); xmlData = interactObject.originXML; ScriptedObject so = interactObject.GetComponent<ScriptedObject>(); if (so != null) idmsg.items = so.QualifiedInteractions(); else idmsg.items = interactObject.ItemResponse; //idmsg.LoadXML(xmlData); idmsg.baseXML = xmlData; idmsg.baseobj = interactObject; Setup(idmsg); pastXMLs.Clear(); rooming = false; } if ( mbutton.button.text == sPatient ) // Patient button { interactObject = patient; // change title if ( title != null ) title.text = interactObject.prettyname; InteractDialogMsg idmsg = new InteractDialogMsg(); xmlData = interactObject.originXML; ScriptedObject so = interactObject.GetComponent<ScriptedObject>(); if (so != null) idmsg.items = so.QualifiedInteractions(); else idmsg.items = interactObject.ItemResponse; //idmsg.LoadXML(xmlData); idmsg.baseXML = xmlData; idmsg.baseobj = interactObject; Setup(idmsg); pastXMLs.Clear(); rooming = false; } else if ( mbutton.button.text == sTeam ) // Team button { // change button[0] name to this object // Setup buttons List<string> entries = new List<string>(); foreach (ObjectInteraction obj in roomObjects) { if (obj.onTeamMenu) entries.Add(obj.prettyname); } rmenu.Setup(entries); rooming = true; } else if ( mbutton.button.text == sBack ) // GoBack button { if (current != listings) { //InteractDialogMsg idmsg = new InteractDialogMsg(); //xmlData = pastXMLs[pastXMLs.Count - 1]; //idmsg.LoadXML(xmlData); //idmsg.baseXML = xmlData; //idmsg.baseobj = interactObject; //Setup(idmsg); //pastXMLs.RemoveAt(pastXMLs.Count - 1); //rooming = false; current = current.parent; rooming = false; SetupRight(current); } else { Visible = false; } } // clear buttons for (i = 0; i < buttons.Count; i++) { buttons[i].on = false; } } buttons = rmenu.GetButtons(); for (i = 0; i < buttons.Count; i++) { if (rooming) { if (buttons[i].on) { interactObject = null; // Find matching Object by name (allows for onTeamMenu to work during runtime) foreach (ObjectInteraction oi in roomObjects) { if (buttons[i].button.text == oi.prettyname) { interactObject = oi; break; } } if (interactObject == null) break; // Safety measure InteractDialogMsg idmsg = new InteractDialogMsg(); xmlData = interactObject.originXML; ScriptedObject so = interactObject.GetComponent<ScriptedObject>(); if (so != null) idmsg.items = so.QualifiedInteractions(); else idmsg.items = interactObject.ItemResponse; idmsg.baseXML = xmlData; idmsg.baseobj = interactObject; // change the title bar (or first element of left column for now) to be // this button name title.text = buttons[i].button.text; Setup(idmsg); pastXMLs.Clear(); rooming = false; break; } } else { if (buttons[i].on) { if (i < current.subCategories.Count) { current = current.subCategories[i]; SetupRight(current); break; } else { InteractionMap im = current.items[i - current.subCategories.Count]; // Activate interaction! interactObject.PutMessage(new InteractMsg(interactObject.gameObject, im, im.log)); current=listings; // reset the menu for next time PAA Visible = false; break; } } } buttons[i].on = false; } }
void ParseCategory(Listings parent, string category) { string front; int start = 0; // check if subcatagories listed in string if ((start = category.IndexOf("/")) >= 0) front = category.Substring(0, start); else front = category; Listings subCategory = parent.FindSubCatagory(front); if (subCategory == null) { // Add subcategory to parent subCategory = new Listings(); subCategory.category = front; subCategory.parent = parent; SortIntoCategory(parent.subCategories, subCategory, front); //parent.subCategories.Add(subCategory); } // Put further sub-subcategories into this subcategory if (start >= 0) { string temp = category.Substring(start+1, category.Length - (start + 1)); ParseCategory(subCategory, temp); } }
void SortIntoCategory(List<Listings> list, Listings entry, string name) { int count = list.Count, insertPoint = 0; for(int i = 0; i < count; i++) { if (SortTest(0, list[i].category.ToLower(), name.ToLower())) { insertPoint = i; break; } insertPoint = i + 1; } list.Insert(insertPoint, entry); }
public override void ButtonCallback (GUIButton button) { // task if ( button.name == "TASK" ) { TaskButton task = button as TaskButton; if ( task != null ) { // get interaction name //string name = nameMap[button.text]; //InteractionMap im = InteractionMgr.GetInstance().Get(name); // Activate interaction! // add breadcrumbs to param list InteractionMap tmpMap = new InteractionMap(); // need a copy operator? tmpMap = task.map; tmpMap.objectName = interactObject.Name; tmpMap.param.Add(current.category+"=True"); Listings parent=current.parent; while (parent!=null && parent.category != null) { tmpMap.param.Add(parent.category+"=True"); parent=parent.parent; } //InteractionMgr.GetInstance().EvaluateInteractionSet(task.map.item); // go through the dispatcher. Dispatcher.GetInstance().ExecuteCommand(tmpMap); //Dispatcher.GetInstance().ExecuteCommand(task.map.item, interactObject.Name ); // interactObject.PutMessage(new InteractMsg(interactObject.gameObject, tmpMap, task.map.log)); current=listings; // reset the menu for next time PAA // close this bitch (optional) if ( CloseOnTask == true ) Close(); } } // patient if ( button.name == "PATIENT" ) { GUIToggle toggle = Find("PATIENT") as GUIToggle; if ( toggle.toggle == true ) // go to previous target object ObjUpdate(target); else { // save target for return target = interactObject; // go to patient ObjUpdate(patient); } // clear toggles toggle = Find("ROOM") as GUIToggle; toggle.toggle = false; toggle = Find("TEAM") as GUIToggle; toggle.toggle = false; } // room and items if ( button.name == "ROOM" ) { GUIToggle toggle = Find("ROOM") as GUIToggle; if ( toggle.toggle == true ) // go back to original object ObjUpdate(interactObject); else // go to room SetupRoom(); } if ( button.name == "ROOM_ITEM" ) { target = GetRoomObject(button.text); ObjUpdate(target); // reset TEAM toggle GUIToggle toggle = Find("ROOM") as GUIToggle; toggle.toggle = false; } // team and items if ( button.name == "TEAM" ) { GUIToggle toggle = Find("TEAM") as GUIToggle; if ( toggle.toggle == true ) // go back to original object ObjUpdate(interactObject); else // go to team SetupTeam(); } if ( button.name == "TEAM_ITEM" ) { target = GetRoomObject(button.text); ObjUpdate(target); // reset TEAM toggle GUIToggle toggle = Find("TEAM") as GUIToggle; toggle.toggle = false; } // category (right panel) if ( button.name == "CATEGORY" ) { // go to this category current = current.FindSubCatagory(button.text); if ( current != null ) RightPanelUpdate(current); } // back button (right panel category back) if ( button.name == "BACK" ) { // go back current = current.parent; if ( current != null ) RightPanelUpdate(current); } base.ButtonCallback (button); }
protected void RightPanelUpdate( Listings listing ) { updateListing = listing; }
protected void RightPanelInit( Listings listing ) { if ( view == null ) view = Find("secondaryMenuScrollArea") as GUIScrollView; if ( view != null ) { // get category button template if ( categoryToggleTemplate == null ) { categoryToggleTemplate = view.Find("button.category") as GUIToggle; } // get task button template if ( taskButtonTemplate == null ) { taskButtonTemplate = view.Find("button.task") as GUIButton; } // clear all elements view.Elements.Clear(); // set current listing current = listing; // put category title first (if there is one) if ( current.parent != null ) { // add element GUIToggle copy = categoryToggleTemplate.Clone() as GUIToggle; copy.name = "BACK"; copy.text = current.category; copy.UpdateContent(); copy.toggle = true; view.Elements.Add(copy); } // // do categories first foreach (Listings cat in listing.subCategories) { // add element GUIToggle copy = categoryToggleTemplate.Clone() as GUIToggle; copy.name = "CATEGORY"; copy.text = cat.category; copy.UpdateContent(); view.Elements.Add(copy); } // init dictionary if ( nameMap == null ) nameMap = new Dictionary<string, string>(); nameMap.Clear(); // now do items foreach( InteractionMap map in listing.items ) { // add element GUIButton temp = taskButtonTemplate.Clone() as GUIButton; TaskButton task = new TaskButton(temp); task.map = map; task.name = "TASK"; task.text = StringMgr.GetInstance().Get(map.item); task.UpdateContent(); view.Elements.Add(task); // add to name map nameMap[task.text] = map.item; } } BreadcrumbInit(); }
/// <summary> /// Creates a new ApplicationBarSetup and initializes _appBar. /// </summary> protected ApplicationBarSetup(Listings Page) { _appBar = new ApplicationBar(); _page = Page; }
void SetupRight(Listings category) { List<string> entries = new List<string>(); StringMgr sMgr = StringMgr.GetInstance(); // Add subcategories on top foreach (Listings subcat in category.subCategories) { entries.Add("|> " + subcat.category); } // Add entries in this category foreach (InteractionMap item in category.items) { entries.Add(sMgr.Get(item.item)); } rmenu.Setup(entries); }