Ejemplo n.º 1
0
        /// <summary>
        /// 双击联系人头像
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void OnItemDoubleClicked(object sender, MouseButtonEventArgs e)
        {
            Action           method = null;
            Buddy            buddy;
            DependencyObject originalSource = e.OriginalSource as DependencyObject;

            if (originalSource != null)
            {
                if (originalSource is Run)
                {
                    originalSource = (originalSource as Run).Parent;
                }
                if ((originalSource is Visual) && !MainWindow.IsQZoneFlag(originalSource))
                {
                    buddy = this.contactListPanel.buddyTree.SelectedItem as Buddy;
                    if ((buddy != null) && (buddy != Util_Buddy.GetCurrentBuddy()))
                    {
                        if (method == null)
                        {
                            method = delegate
                            {
                                Util_Buddy.OpenContactSessionWindow(buddy);
                            };
                        }
                        base.Dispatcher.BeginInvoke(method, new object[0]);
                        e.Handled = true;
                    }
                }
            }
        }
        protected void OnItemDoubleClicked(object sender, MouseButtonEventArgs e)
        {
            DependencyObject originalSource = e.OriginalSource as DependencyObject;

            if (originalSource != null)
            {
                if (originalSource is System.Windows.Documents.Run)
                {
                    originalSource = (originalSource as System.Windows.Documents.Run).Parent;
                }
                if ((originalSource is Visual) && !MainWindow.IsQZoneFlag(originalSource))
                {
                    ListBox     ancestorByType = VisualTree.GetAncestorByType(originalSource, typeof(ListBox)) as ListBox;
                    ListBoxItem container      = VisualTree.GetAncestorByType(originalSource, typeof(ListBoxItem)) as ListBoxItem;
                    if ((ancestorByType != null) && (container != null))
                    {
                        Buddy buddy = ancestorByType.ItemContainerGenerator.ItemFromContainer(container) as Buddy;
                        if (buddy != null)
                        {
                            Util_Buddy.OpenContactSessionWindow(buddy);
                        }
                        else
                        {
                            InstanceAnswerPro.Core.Community.Community community = ancestorByType.ItemContainerGenerator.ItemFromContainer(container) as InstanceAnswerPro.Core.Community.Community;
                            if (community != null)
                            {
                                Util_Buddy.OpenCommunitySessionWindow(community);
                            }
                        }
                        e.Handled = true;
                    }
                }
            }
        }