VCSJones.FiddlerCert.DoubleClickCopyBehavior.UIElement_MouseLeftButtonUp C# (CSharp) Method

UIElement_MouseLeftButtonUp() private static method

private static UIElement_MouseLeftButtonUp ( object sender, System e ) : void
sender object
e System
return void
        private static void UIElement_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            var element = sender as UIElement;
            if (element == null)
            {
                return;
            }
            var lastClickLocation = element.GetValue(LastClickLocationProperty) as Point?;
            var lastClickTime = element.GetValue(LastClickTimeProperty) as int?;
            var copyText = element.GetValue(CopyToClipBoardOnDoubleClickTextProperty) as string;
            if (lastClickLocation.HasValue && lastClickTime.HasValue)
            {
                if (e.Timestamp - lastClickTime.Value > SystemInformation.DoubleClickTime)
                {
                    element.SetValue(LastClickLocationProperty, e.GetPosition(element));
                    element.SetValue(LastClickTimeProperty, e.Timestamp);
                    return;
                }
                var size = SystemInformation.DoubleClickSize;
                var rect = new Rect(lastClickLocation.Value, lastClickLocation.Value);
                rect.Inflate(size.Width / 2, size.Height / 2);
                if (rect.Contains(e.GetPosition(element)))
                {
                    if (string.IsNullOrEmpty(copyText))
                    {
                        var contentControl = element as ContentControl;
                        if (contentControl != null)
                        {
                            Debug.WriteLine($"Clipboard set to: \"{contentControl.Content.ToString()}\"");
                            System.Windows.Clipboard.SetText(contentControl.Content.ToString());
                        }
                        var textBlock = element as TextBlock;
                        if (textBlock != null)
                        {
                            Debug.WriteLine($"Clipboard set to: \"{textBlock.Text}\"");
                            System.Windows.Clipboard.SetText(textBlock.Text);
                        }
                    }
                    else
                    {
                        Debug.WriteLine($"Clipboard set to: \"{copyText}\"");
                        System.Windows.Clipboard.SetText(copyText);
                    }
                    ClearDoubleClickProperties(element);
                    return;

                }
            }
            element.SetValue(LastClickLocationProperty, e.GetPosition(element));
            element.SetValue(LastClickTimeProperty, e.Timestamp);
        }