protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (mousePosition.HasValue) { var position = e.GetPosition(ParentMap); MovedLocation ml = this.DataContext as MovedLocation; if (ml != null) { Location CurrentLocation = ParentMap.ViewportPointToLocation(position); TemplatedParent.SetValue(MapPanel.LocationProperty, CurrentLocation); ml.Latitude = CurrentLocation.Latitude; ml.Longitude = CurrentLocation.Longitude; ml.Update(); } else { if (ParentMap != null) { ParentMap.TranslateMap((Point)(position - mousePosition)); } } mousePosition = position; } }
/// <summary> /// Finds all of the compiled binding expressions on the current data /// source and adds them to the context's registry. /// </summary> private void FindCompiledBindingExpressions() { var wrapperName = default(String); var wrapperType = DataSource is PresentationFoundationView ? DataSourceType : null; if (wrapperType == null) { for (var templateType = TemplatedParent.GetType(); templateType != null; templateType = templateType.BaseType) { wrapperName = PresentationFoundationView.GetDataSourceWrapperNameForComponentTemplate(templateType); wrapperType = Ultraviolet.GetUI().GetPresentationFoundation().GetDataSourceWrapperTypeByName(wrapperName); if (wrapperType != null) { break; } } if (wrapperType == null) { wrapperName = PresentationFoundationView.GetDataSourceWrapperNameForComponentTemplate(TemplatedParent.GetType()); throw new UvmlException(PresentationStrings.CannotFindViewModelWrapper.Format(wrapperName)); } } var properties = wrapperType.GetProperties().Where(x => x.Name.StartsWith("__UPF_Expression")).ToList(); var propertiesWithExpressions = from prop in properties let attr = (CompiledBindingExpressionAttribute)prop.GetCustomAttributes(typeof(CompiledBindingExpressionAttribute), false).Single() let expr = attr.Expression select new { Property = prop, Expression = expr, }; foreach (var prop in propertiesWithExpressions) { var key = new CompiledBindingExpressionKey(prop.Property.PropertyType, prop.Expression); compiledBindingExpressions.Add(key, prop.Property); } var uniques = compiledBindingExpressions.GroupBy(x => x.Key).Where(x => x.Count() == 1).ToList(); foreach (var unique in uniques) { var key = new CompiledBindingExpressionKey(null, unique.Key.Expression); compiledBindingExpressions[key] = unique.Single().Value; } }
void Refresh() { List <string> entries = new List <string>(); if (DataContext is KeyValuePair <string, IOItem> ) { KeyValuePair <string, IOItem> keyValuePair = (KeyValuePair <string, IOItem>)DataContext; IOItem currentItem = keyValuePair.Value; var infoControl = TemplatedParent.GetParent <NodeInfoContainer>(null); var control = infoControl != null ? infoControl.OriginElement : null; if (control != null) { // We'll need to query the canvas for links //NodeGraphLayout canvas = control.RootCanvas as NodeGraphLayout; TraceLab.UI.WPF.Views.DockableGraph topGraph = control.GetParent <TraceLab.UI.WPF.Views.DockableGraph>(null); NodeGraphLayout canvas = topGraph.graphLayout; // Add the current mapping entries.Add(currentItem.MappedTo); // Get the current item's type so that we can limit the selection to only this type string currentType = currentItem.IOItemDefinition.Type; var availableInputMappingsPerNode = new TraceLab.Core.Utilities.InputMappings(canvas.Graph); ExperimentNode currentNode = control.Vertex as ExperimentNode; //if currentNode is a ExperimentNode, and is ioValidator has incoming outputs for this node (otherwise, it has not been connected to start node) if (currentNode != null && availableInputMappingsPerNode.ContainsMappingsForNode(currentNode)) { foreach (string incomingOutput in availableInputMappingsPerNode[currentNode].Keys) { if (string.Equals(currentType, availableInputMappingsPerNode[currentNode][incomingOutput])) { entries.Add(incomingOutput); } } } } } this.ItemsSource = entries.Distinct(); }