/// <summary> /// Első eset: a két távolság által jelzett kör messze van egymástól: /// Megoldás: mindkettőt arányosan növeljük /// </summary> protected bool CheckFarDistances(TagDisplay tag1, TagDisplay tag2) { if (LocationCalculator.Distance(tag1.Origo, tag2.Origo) > tag1.Distance + tag2.Distance) { double deviance = LocationCalculator.Distance(tag1.Origo, tag2.Origo) - (tag1.Distance + tag2.Distance); deviance += BIAS; // Az eltérés torzítása, így biztosan lesz metszéspont double max = tag1.Distance + tag2.Distance; double rate1 = tag1.Distance / max; double rate2 = tag2.Distance / max; tag1.ChangeDistance(tag1.Distance + deviance * rate1); tag2.ChangeDistance(tag2.Distance + deviance * rate2); //TEST double dist = LocationCalculator.Distance(tag1.Origo, tag2.Origo) - (tag1.Distance + tag2.Distance); if (dist > 0.0) { dist = 0; /* throw new Exception("Calculation error: distance must be 0.0"); */ } //TEST return(true); } else { return(false); } }
private void Background_MouseRightButtonDown(object sender, MouseButtonEventArgs e) { Point mousepos = e.GetPosition(backgr); selectedTag = ClickedTag(mousepos); if (selectedTag != null) { tags.Remove(selectedTag); selectedTag.RemoveItselfFromView(); } CalculateIntersections(); }
private void Background_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Point mousepos = e.GetPosition(backgr); selectedTag = ClickedTag(mousepos); if (selectedTag == null) { selectedTag = new TagDisplay(mousepos, backgr); tags.Add(selectedTag); } CalculateIntersections(); }
/// <summary> /// Leellenőrzi azokat az eseteket, amikor nincs metszéspont, és beállítja a távolságokat úgy, hogy legyen /// </summary> /// <returns> /// true, ha módosítani kellett, mert nem volt metszéspont /// false, ha volt metszéspont /// </returns> protected bool IntersectionCheck(TagDisplay t0, TagDisplay t1) { // Első eset: a két távolság által jelzett kör messze van egymástól: // Megoldás: mindkettőt arányosan növeljük bool requiredModification = CheckFarDistances(t0, t1); // Második eset: az egyik kör a másikon belül helyezkedik el: // Megoldás: a nagyobb kört arányosan csökkentjük, a kisebb kört pedig arányosan növeljük if (!requiredModification) { requiredModification = CheckInclude(t0, t1); } return(requiredModification); }
//takes the location that the new container will be in public NewContainerPage(StorageLocation location) { this.location = location; InitializeComponent(); newContainerId = DatabaseHandler.GetDatabase().GenerateNewContainerId(); //get the id for the new container //set colors this.BackgroundColor = PageColors.secondaryColor; InitContent(); tagDisplay = new TagDisplay(); this.tagDisplayWrapper.Children.Add(tagDisplay); }
//initializes the content on the page private void InitContent() { this.locationName.TextColor = PageColors.textColor; this.nameInput.TextColor = PageColors.textColor; this.streetAddress.TextColor = PageColors.textColor; this.streetAddressInput.TextColor = PageColors.textColor; this.city.TextColor = PageColors.textColor; this.cityInput.TextColor = PageColors.textColor; this.country.TextColor = PageColors.textColor; this.countryInput.TextColor = PageColors.textColor; this.tags.TextColor = PageColors.textColor; this.tagsInput.TextColor = PageColors.textColor; this.notes.TextColor = PageColors.textColor; this.notesEditor.TextColor = PageColors.textColor; tagDisplay = new TagDisplay(new List <string>()); this.tagDisplayWrapper.Children.Add(tagDisplay); }
//for editing a preexisting item public NewItemPage(string name, string notes, List <string> tags, int id, Item prevItem, StorageContainer container) : base() { this.container = container; InitializeComponent(); InitContent(); newItemId = id; this.nameInput.Text = name; this.notesEditor.Text = notes; this.codeInput.Text = prevItem.barcode; this.previousItem = prevItem; this.isEditing = true; if (isEditing) { this.Title = "Editing"; } //set colors this.BackgroundColor = PageColors.secondaryColor; InitContent(); tagDisplay = new TagDisplay(); this.tagDisplayWrapper.Children.Add(tagDisplay); tagDisplay.AddTagBatch(tags); //set image if (ImageTools.HasImage(previousItem)) { if (ImageBaseHandler.current.isItemCached(previousItem.GetId())) { SetImageHolderContent(ImageBaseHandler.current.GetItemImageSource(previousItem.GetId())); } else { ImageSource imageLoadTask = ImageTools.LoadImage(System.IO.Path.Combine(Directories.itemImageDirectory, id.ToString() + ".jpg")); SetImageHolderContent(imageLoadTask); } } }
/// <summary> /// Második eset: az egyik kör a másikon belül helyezkedik el: /// Megoldás: a nagyobb kört arányosan csökkentjük, a kisebb kört pedig arányosan növeljük /// </summary> protected bool CheckInclude(TagDisplay tag1, TagDisplay tag2) { TagDisplay bigger, smaller; if (tag1.Includes(tag2)) { bigger = tag1; smaller = tag2; } else if (tag2.Includes(tag1)) { bigger = tag2; smaller = tag1; } else { return(false); } double deviance = bigger.Distance - (LocationCalculator.Distance(bigger.Origo, smaller.Origo) + smaller.Distance); deviance += BIAS; // Az eltérés torzítása, így biztosan lesz metszéspont double max = bigger.Distance + smaller.Distance; double brate = bigger.Distance / max; double srate = smaller.Distance / max; bigger.ChangeDistance(bigger.Distance - deviance * brate); smaller.ChangeDistance(smaller.Distance + deviance * srate); //TEST double dist = bigger.Distance - (LocationCalculator.Distance(bigger.Origo, smaller.Origo) + smaller.Distance); if (dist > 0.0) { dist = 0; /* throw new Exception("Calculation error: distance must be 0.0"); */ } //TEST return(true); }
public string ShowTags(string strTags) { try { string[] tags = new string[] { }; TagDisplay td = new TagDisplay(); tags = td.TagInput(strTags.Trim()); string result = string.Empty; foreach (string tag in tags) { result += tag + "\n"; } return result; } catch (myExceptionClass ex) { if (ex.InnerException != null) { //Custom message when inner exception occur return ex.Message + " Tag: " + ex.Tag + " is an exception(al) tag. Hence its not valid. " + ex.InnerException.Message; } else { return ex.Message + "myExceptionClass"; } } }