Example #1
0
        //Warning event fires wherever you click on the page of a tab
        private void newWindow(object sender, MouseButtonEventArgs e)
        {
            TabItem currentClick = sender as TabItem;

            //This point stuff is so that the new window is only triggered near the ACTUAL tab
            GeneralTransform transform = currentClick.TransformToAncestor(this);
            Point rootPoint = transform.Transform(new Point(0, 0));
            Point tabClick = e.GetPosition(this);

            if (Math.Abs(rootPoint.X - tabClick.X) > 20)
                return;
            //Clean up dynamically assigned events, so they are not triggered for this window
            currentClick.MouseDoubleClick -= newWindow;
            foreach (UIElement elem in hasEvents)
            {
                if ( (string)((TextBox)elem).Tag == currentClick.Header.ToString().ToUpper())
                {
                    ((TextBox)elem).MouseDown -= price_MouseDown;
                }
            }
            this.StockSymbolTabs.Items.Remove(currentClick);
            Dictionary<Util.TimeType, StockInfo> storedInfo = stockInformation[currentClick.Header.ToString()];
            DataWindow newWin = new DataWindow();
            newWin.dealWithResults(currentClick.Header.ToString(), storedInfo);
            newWin.Owner = this.Owner;
            newWin.Show();
        }