public MainView()
    {
        this.SuspendLayout();

        this.DoubleBuffered = true;

        this.Height = 600;
        this.Width = 600;

        this.Text = "PartsDB";

        tabControl = new TabControl();
        tabControl.Dock = DockStyle.Fill;
        tabControl.Selected += new TabControlEventHandler(delegate (object sender, TabControlEventArgs e) {
            if (e.TabPage == rsvTab) {
                activeTab = Tabs.RawSql;
            } else if (e.TabPage == rsvTab) {
                activeTab = Tabs.Prefs;
            } else if (e.TabPage == rsvTab) {
                activeTab = Tabs.Parts;
            } else if (e.TabPage == rsvTab) {
                activeTab = Tabs.Edit;
            }
        });
        Controls.Add(tabControl);

        partsTab = new TabPage("Parts");
        parts = new PartsView();
        parts.Dock = DockStyle.Fill;
        partsTab.Controls.Add(parts);
        tabControl.TabPages.Add(partsTab);

        partEditTab = new TabPage("Edit Part");
        partEdit = new PartEditView();
        partEdit.Dock = DockStyle.Fill;
        partEditTab.Controls.Add(partEdit);
        tabControl.TabPages.Add(partEditTab);

        pvTab = new TabPage("Preferences");
        pv = new PreferencesView();
        pv.Dock = DockStyle.Fill;
        pvTab.Controls.Add(pv);
        tabControl.TabPages.Add(pvTab);

        rsvTab = new TabPage("Raw SQL");
        rsv = new RawSqlView();
        rsv.Dock = DockStyle.Fill;
        rsvTab.Controls.Add(rsv);
        tabControl.TabPages.Add(rsvTab);

        this.ResumeLayout();
    }
示例#2
0
        /// <summary>
        /// Creates as base window for additional Views.
        /// Method builds windows according to the button's command parameter
        /// </summary>
        /// <param name="choice"></param>
        /// <returns>
        /// Basewindow Type Window
        /// </returns>
        public Window CreateBaseWindow(string choice)
        {
            try
            {
                switch (choice)
                {
                case "loginView":
                    var loginView = new LogInView();
                    loginView.DataContext = this.MainVm.LogInVm;
                    _windowTitle          = "Log in";
                    CurrentView           = loginView;
                    _windowHeight         = 800;
                    _windowWidth          = 650;
                    _windowState          = WindowState.Normal;
                    break;

                case "registerView":
                    var registerView = new RegisterUserView();
                    registerView.DataContext = this.MainVm.RegisterVm;
                    _windowTitle             = "Log in";
                    CurrentView   = registerView;
                    _windowHeight = 1040;
                    _windowWidth  = 650;
                    _windowState  = WindowState.Normal;
                    break;

                case "mechanicLoginView":
                    var mechanicLoginView = new MechanicLoginView();
                    mechanicLoginView.DataContext = this.MainVm.MechanicLoginVm;
                    _windowTitle  = "Login";
                    CurrentView   = mechanicLoginView;
                    _windowHeight = 450;
                    _windowWidth  = 650;
                    _windowState  = WindowState.Normal;
                    break;

                case "orderView":
                    var orderView = new OrderView();
                    orderView.DataContext = this.MainVm.OrderVm;
                    _windowTitle          = " Order Material";
                    CurrentView           = orderView;
                    _windowHeight         = 450;
                    _windowWidth          = 650;
                    _windowState          = WindowState.Maximized;
                    break;

                case "partsView":
                    var partsView = new PartsView();
                    partsView.DataContext = this.MainVm.PartsVm;
                    _windowTitle          = " Add new Part";
                    CurrentView           = partsView;
                    _windowHeight         = 450;
                    _windowWidth          = 650;
                    _windowState          = WindowState.Maximized;
                    break;

                    //case "billView":
                    //    var billView = new BillView();
                    //    billView.DataContext = this.MainVm.BillVm;
                    //    _windowTitle = "Bill";
                    //    CurrentView = billView;
                    //    _windowHeight = 450;
                    //    _windowWidth = 650;
                    //    _windowState = WindowState.Normal;
                    //    break;
                    //case "cartView":
                    //    var cartView = new CartView();
                    //    cartView.DataContext = this.MainVm.CartVm;
                    //    _windowTitle = "Shopping Cart";
                    //    CurrentView = cartView;
                    //    _windowHeight = 450;
                    //    _windowWidth = 650;
                    //    _windowState = WindowState.Normal;
                    //    break;
                    //case "checkOutView":
                    //    var checkoutView = new CheckOutView();
                    //    checkoutView.DataContext = this.MainVm.ChOutVm;
                    //    _windowTitle = "Check out";
                    //    CurrentView = checkoutView;
                    //    _windowHeight = 300;
                    //    _windowWidth = 600;
                    //    _windowState = WindowState.Normal;
                    //    break;
                    //case "storeVm":
                    //    var storeFrontView = new StoreFrontView();
                    //    storeFrontView.DataContext = this.MainVm.SfVm;
                    //    _windowTitle = "Flowers";
                    //    CurrentView = storeFrontView;
                    //    _windowHeight = 200;
                    //    _windowWidth = 250;
                    //    _windowState = WindowState.Normal;
                    //    break;
                    //case "resultView":
                    //    var resultView = new ResultView();
                    //    resultView.DataContext = this.MainVm.ResultVm;
                    //    _windowTitle = "Question Progress";
                    //    CurrentView = resultView;
                    //    _windowHeight = 800;
                    //    _windowWidth = 850;
                    //    _windowState = WindowState.Maximized;
                    //    break;
                    //case "examView":
                    //    var examView = new ExamView();
                    //    examView.DataContext = this.MainVm.ExamVm;
                    //    _windowTitle = "Exam";
                    //    CurrentView = examView;
                    //    _windowHeight = 200;
                    //    _windowWidth = 250;
                    //    _windowState = WindowState.Maximized;
                    //    break;
                    //case "aboutView":
                    //    var aboutView = new AboutView();
                    //    aboutView.DataContext = this.MainVm.AboutVm;
                    //    _windowTitle = "About Us";
                    //    CurrentView = aboutView;
                    //    _windowHeight = 580;
                    //    _windowWidth = 900;
                    //    _windowState = WindowState.Normal;
                    //    break;
                    //case "accountView":
                    //    var accountView = new AccountView();
                    //    accountView.DataContext = this.MainVm.AccountVm;
                    //    _windowTitle = "Account";
                    //    CurrentView = accountView;
                    //    _windowHeight = 800;
                    //    _windowWidth = 800;
                    //    _windowState = WindowState.Normal;
                    //    break;
                    //case "fileImportView":
                    //    var fileimportView = new FileImportView();
                    //    fileimportView.DataContext = this.MainVm.FileImportVm;
                    //    _windowTitle = "File Import";
                    //    CurrentView = fileimportView;
                    //    _windowHeight = 600;
                    //    _windowWidth = 600;
                    //    _windowState = WindowState.Maximized;
                    //    break;
                    //case "eulaView":
                    //    var eulaView = new EulaView();
                    //    eulaView.DataContext = this.MainVm.EulaVm;
                    //    _windowTitle = "Eula";
                    //    CurrentView = eulaView;
                    //    _windowHeight = 580;
                    //    _windowWidth = 900;
                    //    _windowState = WindowState.Maximized;
                    //    break;
                }
                ;
                if (CurrentView != null && _windowTitle != "")
                {
                    BaseWindow = new Window
                    {
                        Title                 = _windowTitle,
                        Content               = CurrentView,
                        Height                = _windowHeight,
                        Width                 = _windowWidth,
                        WindowStyle           = WindowStyle.None,
                        ResizeMode            = ResizeMode.NoResize,
                        WindowStartupLocation = WindowStartupLocation.CenterScreen,
                        WindowState           = _windowState,
                    };
                }
            }
            catch (Exception ex)
            {
                Protocol.WriteToProtocol(0, "CreateBaseWindow() :" + ex.Message + ex.StackTrace, "Window Creation Error");
            }
            return(BaseWindow);
        }