//string ResolveMsiShortcut(string file) //{ // StringBuilder product = new StringBuilder(MaxGuidLength + 1); // StringBuilder feature = new StringBuilder(MaxFeatureLength + 1); // StringBuilder component = new StringBuilder(MaxGuidLength + 1); // MsiGetShortcutTarget(file, product, feature, component); // int pathLength = MaxPathLength; // StringBuilder path = new StringBuilder(pathLength); // InstallState installState = MsiGetComponentPath(product.ToString(), component.ToString(), path, ref pathLength); // if (installState == InstallState.Local) // { // return path.ToString(); // } // else // { // return null; // } //} new public void Show() { //Ststem.Drawing.Point var screen = System.Windows.Forms.Screen.FromPoint(System.Windows.Forms.Cursor.Position); Left = SystemScaling.RealPixelsToWpfUnits(screen.WorkingArea.Left); Top = SystemScaling.RealPixelsToWpfUnits(screen.WorkingArea.Top); Height = SystemScaling.RealPixelsToWpfUnits(screen.WorkingArea.Height); base.Show(); BeginStoryboard((Storyboard)Resources["ShowMenu"]); }
private static void ListBoxSelectionChanged(object sender, SelectionChangedEventArgs e) { //Debug.WriteLine("ListBoxSelectionChanged"); ListBox listBox = sender as ListBox; if (listBox != null) { double scrollTo = 0; bool confirmScroll = true; if (e.AddedItems.Count > 0) { Point listPoint = _listBoxScroller.PointToScreen(new Point(0, 0)); listPoint.X = SystemScaling.RealPixelsToWpfUnits(listPoint.X); listPoint.Y = SystemScaling.RealPixelsToWpfUnits(listPoint.Y); ListBoxItem tempItem = listBox.ItemContainerGenerator.ContainerFromItem(listBox.Items[listBox.Items.IndexOf(e.AddedItems[0])]) as ListBoxItem; Point itemPoint = tempItem.PointToScreen(new Point(0, 0)); itemPoint.X = SystemScaling.RealPixelsToWpfUnits(itemPoint.X); itemPoint.Y = SystemScaling.RealPixelsToWpfUnits(itemPoint.Y); //Debug.WriteLine("MEASURED VALUES: " + itemPoint.Y + ", " + listPoint.Y + ", " + tempItem.ActualHeight + ", " + _listBoxScroller.ActualHeight); if (itemPoint.Y < listPoint.Y) { //Debug.WriteLine("SCROLLING UP: " + itemPoint.Y + ", " + listPoint.Y); scrollTo = _listBoxScroller.VerticalOffset + (itemPoint.Y - listPoint.Y); //Debug.WriteLine("scrollTo: " + scrollTo); } else if ((itemPoint.Y + tempItem.ActualHeight) > (listPoint.Y + _listBoxScroller.ActualHeight + _listBoxScroller.Padding.Top + _listBoxScroller.Padding.Bottom)) { //Debug.WriteLine("SCROLLING DOWN: " + (itemPoint.Y + tempItem.ActualHeight) + ", " + (listPoint.Y + _listBoxScroller.ActualHeight + _listBoxScroller.Padding.Top + _listBoxScroller.Padding.Bottom)); scrollTo = (itemPoint.Y + tempItem.ActualHeight) - ((listPoint.Y + _listBoxScroller.ActualHeight) - _listBoxScroller.ContentVerticalOffset); } else { confirmScroll = false; } /*for (int i = 0; i < (listbox.Items.IndexOf(e.AddedItems[0])); i++) * { * ListBoxItem tempItem = listbox.ItemContainerGenerator.ContainerFromItem(listbox.Items[i]) as ListBoxItem; * * if (tempItem != null) * { * scrollTo += tempItem.ActualHeight; * } * }*/ } else if (e.RemovedItems.Count > 0) { for (int i = 0; i < (listBox.Items.IndexOf(e.RemovedItems[0])); i++) { ListBoxItem tempItem = listBox.ItemContainerGenerator.ContainerFromItem(listBox.Items[i]) as ListBoxItem; if (tempItem != null) { scrollTo += tempItem.ActualHeight; } } } else { for (int i = 0; i < (listBox.SelectedIndex); i++) { ListBoxItem tempItem = listBox.ItemContainerGenerator.ContainerFromItem(listBox.Items[i]) as ListBoxItem; if (tempItem != null) { scrollTo += tempItem.ActualHeight; } } } if (confirmScroll) { AnimateScroll(_listBoxScroller, scrollTo); } } }