private void TreeFunctions_MouseMove(object sender, MouseEventArgs e) { if (e.LeftButton != MouseButtonState.Pressed) { return; } var tag = GetNodeTag(sender); if (tag == null) { return; } var mousePosition = e.GetPosition(TreeFunctions); if (!ShouldBeginDrag(mousePosition.X, mousePosition.Y)) { return; } var text = ((AdvancedKeywordInfo)tag).Template; if (string.IsNullOrEmpty(text)) { return; } TreeFunctions.DoDragDrop(text, CDragDropEffects.Copy | CDragDropEffects.Move); }
private void OnCollisionEnter2D(Collision2D col) //Checks what objects the AI collides with { if (col.gameObject.tag == "Tree") //If the collided object is a tree then continue code here { treeRef = col.gameObject.GetComponent <TreeFunctions>(); myState = AiStates.Chopping; //Sets AI state to chopping } }
private void TreeFunctions_KeyDown(object sender, KeyEventArgs e) { if (string.IsNullOrEmpty(TbFilterForFunctions.Text)) { return; } if (e.Key != Key.F3) { return; } var index = Keyboard.Modifiers != ModifierKeys.Shift ? TreeFunctions.SelectedIndex + 1 : TreeFunctions.SelectedIndex - 1; var source = ((IEnumerable <TreeViewItemData>)TreeFunctions.ItemsSource).ToList(); while (index < source.Count && index > 0) { if (string.IsNullOrEmpty(source[index].StringToUnderscore)) { if (Keyboard.Modifiers != ModifierKeys.Shift) { index++; } else { index--; } continue; } if (TreeFunctions.SelectedItem != source[index]) { TreeFunctions.SelectedItem = source[index]; TreeFunctions.ScrollIntoView(source[index]); var item = TreeFunctions.ItemContainerGenerator.ContainerFromItem(source[index]) as ListBoxItem; item?.Focus(); } break; } }
private void CheckTreeFilter([NotNull] ItemsControl tree, string filter) { var source = tree.ItemsSource as IEnumerable <TreeViewItemData>; if (source == null) { return; } var treeViewItemsData = source as TreeViewItemData[] ?? source.ToArray(); var firstmatch = treeViewItemsData.FirstOrDefault(x => x.Text.ToLowerInvariant().Contains(filter.ToLowerInvariant())); if (firstmatch != null) { TreeFunctions.ScrollIntoView(firstmatch); TreeFunctions.SelectedItem = firstmatch; } foreach (var treeViewItemData in treeViewItemsData) { treeViewItemData.StringToUnderscore = treeViewItemData.Text.ToLowerInvariant().Contains(filter.ToLowerInvariant()) ? filter : ""; } }