public void SetItem( Items.ItemProperty[] properties, Items.Item item, TagVisualization tv) { // clear out any prior contents RowHost.Children.Clear(); RowHost.RowDefinitions.Clear(); // set up our row definitions for (int index = 0; index < properties.Length; ++index) { RowHost.RowDefinitions.Add(new RowDefinition()); } // add our rows for (int index = 0; index < properties.Length; ++index) { InformationPanelRow row = new InformationPanelRow(); Grid.SetRow(row, index); RowHost.Children.Add(row); row.HeadingLabel.Text = properties[index].Name; row.Cell.SetValue(item.Values[index], properties[index].PropertyType); } TagData tagValue = tv.VisualizedTag; BRed.Tag = tagValue; BWhite.Tag = tagValue; BYellow.Tag = tagValue; BBlue.Tag = tagValue; BGreen.Tag = tagValue; ItemNamePanel.Text = item.Name; }
protected override void OnMoved(RoutedEventArgs e) { TagVisualization tv = (TagVisualization)e.Source; double o = tv.Orientation; System.Diagnostics.Debug.WriteLine("ItemVi: Ahi van la orientacion"); System.Diagnostics.Debug.WriteLine(o); }
/// <summary> /// Constructor. /// </summary> /// <param name="visualization"></param> /// <param name="routedEvent"></param> internal TagVisualizationEnterLeaveEventArgs( TagVisualization visualization, bool isFirstOrLast, RoutedEvent routedEvent) : base(routedEvent) { Debug.Assert(visualization != null); this.visualization = visualization; this.isFirstOrLast = isFirstOrLast; }
/// <summary> /// Changes the position of Lynx Reciever screen on table upon lynx movement. This function is not used by software. /// </summary> /// <param name="sender">object sender</param> /// <param name="e">tag visualizer event arguements</param> private void onTagMoved(object sender, TagVisualizerEventArgs e) { TagVisualization tag = e.TagVisualization; lynx.heading = tag.Orientation; lynx.tagX = tag.Center.X; lynx.tagY = tag.Center.Y; lynx.xSendFirst = lynx.tagX - (((18 * 2.22) + 39) + 10) + ((18 * 2.22) + 39); //X is for border of read send ranger lynx.ySendFirst = lynx.tagY + ((40 * 2.22)); lynx.xRecFirst = lynx.tagX + (((18 * 2.22) + 39) - 40) - (18 * 2.22); lynx.yRecFirst = lynx.tagY + ((26 * 2.22)); }
protected override void OnLostTag(RoutedEventArgs e) { TagVisualization tv = (TagVisualization)e.Source; TagData tag = tv.VisualizedTag; long tagValue = tag.Value; if (InformationPanel.Visibility == Visibility.Visible) { Storyboard sb = (Storyboard)this.FindResource("HidePanelStoryboard"); sb.Begin(); } }
/// <summary> /// This function recognises tag, and gets relative x and y axis. It also gets orientation of the tag. This function is not used by software. /// </summary> /// <param name="sender">object sender</param> /// <param name="e">tag visualizer event arguements</param> private void onTagAdded(object sender, TagVisualizerEventArgs e) { TagVisualization tag = e.TagVisualization; // Console.WriteLine(tag.VisualizedTag.Value); lynx.heading = tag.Orientation; lynx.tagX = tag.Center.X; lynx.tagY = tag.Center.Y; lynx.xRecFirst = lynx.tagX + 32; lynx.yRecFirst = lynx.tagY + 99; lynx.xSendFirst = lynx.xRecFirst - (52 * 2.22); //X is for border of read send ranger lynx.ySendFirst = lynx.tagY + 99; LynxAvailable = true; }
/// <summary> /// Refresh the item visualization properties when a tag is received. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected override void OnGotTag(RoutedEventArgs e) { TagVisualization tv = (TagVisualization)e.Source; TagData tag = tv.VisualizedTag; long tagValue = tag.Value; // Has to be a valid tag if (IsTagValid(tag)) { // Look for a match in our item data Items.Item matchingItem = itemData.Find((byte)tag.Value); if (matchingItem != null) { SetItem(itemData.Properties, matchingItem, tv); } } if (MainWindow.shouldShowTable(tagValue)) { Storyboard sb = (Storyboard)this.FindResource("ShowPanelStoryboard"); sb.Begin(); } }
/// <summary> /// Raises an enter or leave event on the specified dependency object. /// </summary> /// <param name="element"></param> /// <param name="visualization"></param> /// <param name="isFirstOrLast"></param> /// <param name="routedEvent"></param> private static void RaiseEnterLeaveEvent( DependencyObject element, TagVisualization visualization, bool isFirstOrLast, RoutedEvent routedEvent) { UIElement uiElement = element as UIElement; if (uiElement != null) { uiElement.RaiseEvent(new TagVisualizationEnterLeaveEventArgs( visualization, isFirstOrLast, routedEvent)); } else { ContentElement contentElement = element as ContentElement; if (contentElement != null) { contentElement.RaiseEvent(new TagVisualizationEnterLeaveEventArgs( visualization, isFirstOrLast, routedEvent)); } } }
/// <summary> /// Here when a visualization leaves a list of elements. /// </summary> /// <param name="elements"></param> /// <param name="visualization"></param> private static void OnVisualizationsLeave(IEnumerable<DependencyObject> elements, TagVisualization visualization) { Debug.Assert(elements != null); Debug.Assert(visualization != null); // Update the "visualizations over" lists appropriately foreach (DependencyObject element in elements) { Debug.Assert(elementVisualizations.ContainsKey(element)); List<TagVisualization> visualizations = elementVisualizations[element]; Debug.Assert(visualizations.Contains(visualization)); visualizations.Remove(visualization); if (visualizations.Count == 0) { // This is the last remaining visualization over it elementVisualizations.Remove(element); } } // Set IsAnyVisualizationOver property and raise VisualizationLeave // event as appropriate foreach (DependencyObject element in elements) { bool isLast = !elementVisualizations.ContainsKey(element); if (isLast) { Debug.Assert(GetIsAnyVisualizationOver(element), "IsAnyVisualizationOver was already false"); SetIsAnyVisualizationOver(element, false); } RaiseEnterLeaveEvent(element, visualization, isLast, VisualizationLeaveEvent); } }
/// <summary> /// Here when a visualization enters a list of elements. /// </summary> /// <param name="elements"></param> /// <param name="visualization"></param> private static void OnVisualizationsEnter(IEnumerable<DependencyObject> elements, TagVisualization visualization) { Debug.Assert(elements != null); Debug.Assert(visualization != null); foreach (DependencyObject element in elements) { // Update the "visualizations over" lists appropriately List<TagVisualization> visualizations; if (elementVisualizations.TryGetValue(element, out visualizations)) { // Already had some visualizations, just add it Debug.Assert(visualizations != null); Debug.Assert(!visualizations.Contains(visualization)); visualizations.Add(visualization); } else { // This is the first visualization over it visualizations = new List<TagVisualization>(); visualizations.Add(visualization); elementVisualizations.Add(element, visualizations); } } // Set IsAnyVisualizationOver property and raise VisualizationEnter // event as appropriate foreach (DependencyObject element in elements) { List<TagVisualization> visualizations = elementVisualizations[element]; bool isFirst = visualizations.Count == 1; if (isFirst) { Debug.Assert(!GetIsAnyVisualizationOver(element), "IsAnyVisualizationOver was already true"); SetIsAnyVisualizationOver(element, true); } RaiseEnterLeaveEvent(element, visualization, isFirst, VisualizationEnterEvent); } }
/// <summary> /// Synchronizes the specified visualization. /// </summary> /// <param name="visualizer"></param> /// <param name="visualization"></param> private static void SynchronizeVisualization(TagVisualizer visualizer, TagVisualization visualization) { Debug.Assert(visualizer != null); Debug.Assert(visualization != null); Debug.Assert(visualizer.ActiveVisualizations.Contains(visualization)); // Find the element that the visualization is over DependencyObject elementHit = VisualizerHitTester.HitTest(visualizer, visualization.Center) ?? visualizer; // Get its current ancestry chain Predicate<DependencyObject> isVisualizer = delegate(DependencyObject obj) { return obj == visualizer; }; AncestryChain newChain = new AncestryChain(elementHit, isVisualizer); Debug.Assert(newChain.IsComplete, "Hit element's ancestry chain didn't reach visualizer"); // Get its old chain, if any AncestryChain oldChain; if (visualizationChains.TryGetValue(visualization, out oldChain)) { Debug.Assert(oldChain != null); // We have an old chain. Process any adds or removes. IEnumerable<DependencyObject> removes = newChain.FindDiff(oldChain); if (removes != null) { OnVisualizationsLeave(removes, visualization); } IEnumerable<DependencyObject> adds = oldChain.FindDiff(newChain); if (adds != null) { OnVisualizationsEnter(adds, visualization); } } else { // We don't have an old chain. Treat everything as an add. OnVisualizationsEnter(newChain, visualization); } visualizationChains[visualization] = newChain; }
/// <summary> /// Sets the visualization that controls axis /// endpoint #2. /// </summary> /// <param name="visualization"></param> public void SetVisualization2(TagVisualization visualization) { SetVisualization(visualization, ref visualization2); }
/// <summary> /// Unhook events from a visualization that we're no longer /// using as an endpoint. /// </summary> /// <param name="visualization"></param> private void Unregister(TagVisualization visualization) { visualization.GotTag -= OnVisualizationGotOrLostTag; visualization.LostTag -= OnVisualizationGotOrLostTag; visualization.Unloaded -= OnVisualizationUnloaded; visualization.Moved -= OnVisualizationMoved; }
/// <summary> /// Sets one of our endpoints to the specified visualization. /// </summary> /// <param name="newVisualization"></param> /// <param name="currentVisualization"></param> private void SetVisualization( TagVisualization newVisualization, ref TagVisualization currentVisualization) { // Unhook events from the previous visualization, // and hook up the new one. if (currentVisualization != null) { Unregister(currentVisualization); } currentVisualization = newVisualization; if (currentVisualization != null) { Register(currentVisualization); } UpdateVisibility(); }