示例#1
0
        private int intUpCount = 0;  // Counts "Mouse Up"

        /// <summary>
        /// Second "Up" Create Full Main Window and Delete Temporary Window
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void WinTemp_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            intUpCount += 1;
            if (intUpCount == 2) // only once for each TAB will be created FullWindow
            {
                if (CommonStaticLibrary.IntActiveWindow == -1)
                {
                    //Create fullWindow from Temporary (Attached/Detached logic )

                    Window fullWindow = new Window();
                    fullWindow.Title = "MainWindow";

                    TabUserControl tuc = new TabUserControl();
                    tuc.ParentWindow = fullWindow; // WE MUST SETUP/REMEMBER  NEW WINDOW INSIDE STATIC VALUE (in USER CONTROL)

                    Uri iconUri = new Uri("pack://application:,,,/MyUserControl;component/AP.ico");
                    fullWindow.Icon = BitmapFrame.Create(iconUri);
                    Grid       grdtc = WinTemp.Content as Grid;
                    TabItem    ti    = new TabItem();
                    TabControl tc    = grdtc.Children[0] as TabControl;
                    ti = tc.Items[0] as TabItem;
                    tc.Items.Remove(ti);
                    tuc.addTabItem(ti);
                    Grid grd = new Grid();
                    grd.Children.Add(tuc);
                    fullWindow.Content     = grd;
                    fullWindow.Left        = WinTemp.RestoreBounds.Left - 20;
                    fullWindow.Top         = WinTemp.RestoreBounds.Top;
                    fullWindow.Width       = WinTemp.ActualWidth;
                    fullWindow.Height      = WinTemp.ActualHeight;
                    fullWindow.Name        = "FullWindow" + (ti.Header as Label).Content.ToString();
                    fullWindow.WindowStyle = WindowStyle.SingleBorderWindow;

                    fullWindow.Show();
                    fullWindow.Focus();
                }
                else
                {
                    Window         w       = CommonStaticLibrary.WinList[CommonStaticLibrary.IntActiveWindow];
                    Grid           grd     = w.Content as Grid;
                    TabUserControl existUC = grd.Children[0] as TabUserControl;
                    Grid           grdTc   = WinTemp.Content as Grid;
                    TabControl     tc      = grdTc.Children[0] as TabControl;
                    TabItem        ti      = new TabItem();
                    ti = tc.Items[0] as TabItem;
                    tc.Items.Remove(ti);
                    existUC.addTabItem(ti);
                    existUC.Opacity = 1.0;
                    w.Focus();
                }
                aTimer.Enabled = false; // Stop Timer
                WinTemp.Close();
                CommonStaticLibrary.IntActiveWindow = -1;
                ChangeTitleAll();
            }
        }
示例#2
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.MW1 = ((WpfControlTabTest.MainWindow)(target));
                return;

            case 2:
                this.grdMain = ((System.Windows.Controls.Grid)(target));
                return;

            case 3:
                this.MyTabControl = ((MyUserControl.TabUserControl)(target));
                return;
            }
            this._contentLoaded = true;
        }
示例#3
0
        private void createFullWindow(string tabName)
        {
            Window fullWindow = new Window();

            fullWindow.Title = "MainWindow";

            TabUserControl tuc = new TabUserControl();

            tuc.ParentWindow = fullWindow; // WE MUST SETUP/REMEMBER  NEW WINDOW INSIDE STATIC VALUE (in USER CONTROL)

            Uri iconUri = new Uri("pack://application:,,,/MyUserControl;component/AP.ico");

            fullWindow.Icon = BitmapFrame.Create(iconUri);

            TabItem ti  = new TabItem();
            Label   lbl = new Label();

            lbl.Content = tabName;
            ti.Header   = lbl;

            Window firstWin = CommonStaticLibrary.WinList[0];

            tuc.addTabItem(ti);
            Grid tabGrid = new Grid();

            tabGrid.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, rnd(), rnd(), rnd()));
            ti.Content         = tabGrid;

            Grid grdtc = new Grid();

            grdtc.Children.Add(tuc);

            fullWindow.Content = grdtc;
            fullWindow.Left    = firstWin.RestoreBounds.Left + 44;
            fullWindow.Top     = firstWin.RestoreBounds.Top + 44;
            fullWindow.Width   = firstWin.ActualWidth;
            fullWindow.Height  = firstWin.ActualHeight;
            // fullWindow.Name = "FullWindow" + CommonStaticLibrary.WinList.Count.ToString();
            fullWindow.WindowStyle = WindowStyle.SingleBorderWindow;

            fullWindow.Show();
            fullWindow.Focus();
        }