Beispiel #1
0
        /// <summary>
        /// 初始化字典,内含键值对,键为page名的字符串,名为对应的page对象
        /// </summary>
        private void InitDictionary()
        {
            this._dicPage = new Dictionary <string, Page>();

            string strPagName = "PAGE_HOME";
            Page   objPage    = new HomePage();

            objPage.DataContext = this._viewViewModel;
            this._dicPage.Add(strPagName, objPage);

            strPagName          = "PAGE_CONNECT";
            objPage             = new ConnectPage();
            objPage.DataContext = this._viewViewModel;
            this._dicPage.Add(strPagName, objPage);

            strPagName          = "PAGE_CONTROL";
            objPage             = new ControlPage();
            objPage.DataContext = this._viewViewModel;
            this._dicPage.Add(strPagName, objPage);

            strPagName          = "PAGE_UPDATE";
            objPage             = new UpdatePage();
            objPage.DataContext = this._viewViewModel;
            this._dicPage.Add(strPagName, objPage);

            strPagName          = "PAGE_CALIBRATION";
            objPage             = new CalibrationPage();
            objPage.DataContext = this._viewViewModel;
            this._dicPage.Add(strPagName, objPage);

            strPagName          = "PAGE_SETUP";
            objPage             = new SetupPage();
            objPage.DataContext = this._viewViewModel;
            this._dicPage.Add(strPagName, objPage);
        }
Beispiel #2
0
 public PageManager(MainWindow window)
 {
     Window       = window;
     MainPage     = new MainPage(window);
     DefusalPage  = new DefusalPage(window);
     SetupPage    = new SetupPage(window);
     CreditsPage  = new CreditsPage(window);
     SettingsPage = new SettingsPage(window);
 }
Beispiel #3
0
        public App()
        {
            if (Settings.GetUsername == "")
            {
                MainPage = new SetupPage();
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("=====" + Settings.GetUsername);
                MainPage = new NavigationPage(new TasksPage.TasksPage());
            }

            InitializeComponent();
        }
Beispiel #4
0
        public void Navigate(string page)
        {
            switch (page)
            {
            case "homepage":
                homePage = new HomePage();
                ApplicationHelper.NavigationService.Navigate(homePage);
                break;

            case "setuppage":
                setupPage = new SetupPage();
                ApplicationHelper.NavigationService.Navigate(setupPage);
                break;

            case "gamepage":
                gamePage = new GamePage();
                ApplicationHelper.NavigationService.Navigate(gamePage);
                break;

            case "leaderboardpage":
                leaderboardPage = new LeaderboardPage();
                ApplicationHelper.NavigationService.Navigate(leaderboardPage);
                break;

            case "adminpage":
                adminPage = new AdminPage();
                ApplicationHelper.NavigationService.Navigate(adminPage);
                break;

            case "boardsadminpage":
                boardsAdminPage = new BoardsAdminPage();
                ApplicationHelper.NavigationService.Navigate(boardsAdminPage);
                break;

            case "playersadminpage":
                playersAdminPage = new PlayersAdminPage();
                ApplicationHelper.NavigationService.Navigate(playersAdminPage);
                break;

            case "sessionsadminpage":
                sessionsAdminPage = new SessionsAdminPage();
                ApplicationHelper.NavigationService.Navigate(sessionsAdminPage);
                break;

            default:
                break;
            }
        }
Beispiel #5
0
        public MainForm(string[] arguments)
        {
            m_loading = true;
            Visible = false;
            m_prefences = new Preferences(getPreferencesPath);
            Localization.SetCulture(m_prefences.General.Culture);

            InitializeComponent();

            m_Port_ECU_Status = new MainForm.UltraStatusBarEx(m_statusPortECU);

            this.Icon = OCTech.OBD2.Applications.Properties.Resources.Application;
            this.Text = MainForm.ApplicationName;
            string titleBarCompany = Localization.GetTitleBarCompany(m_prefences.General.Culture);
            if (!string.IsNullOrEmpty(titleBarCompany))
                Text = string.Format("{0} - {1}", Text, titleBarCompany);
            m_statusErrorECU = Localization.GetStatusBarBanner(m_prefences.General.Culture);

            m_mainForm = (Form)this;
            processCommandOptions(arguments);

            this.Disposed += new EventHandler(mainForm_Disposed);

            Version version = m_scanTool.GetType().Assembly.GetName().Version;
            int unlock = version.Major ^ version.Minor ^ version.Build ^ version.Revision;
            m_scanTool.Unlock(unlock);

            FileUtility.PathResolverReplacements.Add("[ApplicationName]", MainForm.ApplicationName);

            LoggableItem.RegisterLoggableItem(
                typeof(PIDLoggableItem),
                new LoggableItemXmlReader(PIDLoggableItem.FromXml)
                );
            LoggableItem.RegisterLoggableItem(
                typeof(FuelLoggableItem),
                new LoggableItemXmlReader(FuelLoggableItem.FromXml)
                );
            LoggableItem.RegisterLoggableItem(
                typeof(UserPIDLoggableItem),
                new LoggableItemXmlReader(UserPIDLoggableItem.FromXml)
                );
            LoggableItem.RegisterLoggableItem(
                typeof(PIDPluginLoggableItem),
                new LoggableItemXmlReader(PIDPluginLoggableItem.FromXml)
                );

            if (m_prefences.Layout.TouchScreenSize)
            {
                customListView.ItemSpacing = ListViewItemSpacing.Small;
                toolStripContainer.TopToolStripPanelVisible = false;
            }

            customListView.Add(
                OCTech.OBD2.Applications.Properties.Resources.SetupPageName,
                "Setup",
                OCTech.OBD2.Applications.Properties.Resources.p000075
                );
            customListView.Add(
                OCTech.OBD2.Applications.Properties.Resources.DiagPageName,
                "Diagnostics",
                OCTech.OBD2.Applications.Properties.Resources.p000026
                );
            customListView.Add(
                OCTech.OBD2.Applications.Properties.Resources.MonitorsPageName,
                "Monitors",
                OCTech.OBD2.Applications.Properties.Resources.p000045
                );
            customListView.Add(
                OCTech.OBD2.Applications.Properties.Resources.DashboardPageName,
                "Dashboard",
                OCTech.OBD2.Applications.Properties.Resources.p000015
                );
            customListView.Add(
                OCTech.OBD2.Applications.Properties.Resources.LogsPageName,
                "Logs",
                OCTech.OBD2.Applications.Properties.Resources.p000043
                );
            customListView.Add(
                OCTech.OBD2.Applications.Properties.Resources.ExitText,
                "Exit",
                OCTech.OBD2.Applications.Properties.Resources.p000032,
                true
                );

            customListView.ItemSelected += new EventHandler<CustomListViewItemSelectedEventArgs>(customListView_ItemSelected);
            customListView.Font = this.Font;

            CurrentOperationStatus = OCTech.OBD2.Applications.Properties.Resources.SystemReadyText;
            ConnectedStatus = ConnectionStatus.NotConnected;

            if (m_prefences.Layout.SelectedPageKey == "Exit"
            || !m_prefences.Layout.RememberLastPageOnStartup
            || string.IsNullOrEmpty(m_prefences.Layout.SelectedPageKey)
                )
                m_prefences.Layout.SelectedPageKey = "Setup";

            m_scanTool.CommunicationErrorOccurred += new EventHandler<MessageEventArgs>(m_scanTool_CommunicationErrorOccurred);
            m_scanTool.SelectECU += new EventHandler<SelectedECUEventArgs>(m_scanTool_SelectECU);
            m_scanTool.ConnectionChanged += new EventHandler(m_scanTool_ConnectionChanged);
            m_scanTool.ConnectionStatusChanged += new EventHandler<ConnectionStatusChangedEventArgs>(m_scanTool_ConnectionStatusChanged);

            m_pidMonitor = new PIDMonitor(m_scanTool);
            m_pidMonitor.SetCulture(m_prefences.General.Culture);
            m_pidMonitor.ErrorOccurred += new EventHandler<OCTech.Utilities.ExceptionEventArgs>(utilities_ErrorOccurred);
            m_pidMonitor.NewPIDResponseArrived += new EventHandler<PIDResponseEventArgs>(m_pidMonitor_NewPIDResponseArrived);
            m_pidMonitor.NewPIDTimingAvailable += new EventHandler<PIDMonitorTimingEventArgs>(m_pidMonitor_NewPIDTimingAvailable);
            m_pidMonitor.Playback.RecordedPlaybackChanged += new EventHandler<RecordedDataPlayBackEventArgs>(m_pidMonitor_RecordedPlaybackChanged);

            FuelCalculator fuelCalculator = new FuelCalculator(m_pidMonitor, m_scanTool);
            fuelCalculator.ErrorOccurred += new EventHandler<OCTech.Utilities.ExceptionEventArgs>(utilities_ErrorOccurred);

            vehicleManagement = new VehicleManagement(this, m_scanTool, m_pidMonitor, fuelCalculator, this, MainForm.MyDocumentsPath);

            m_context = new AppContext(m_prefences, this, m_scanTool, m_pidMonitor, fuelCalculator, MainForm.MyDocumentsPath, MainForm.ApplicationDataDirectory, m_messageDispatcher, this, this, vehicleManagement);
            MainForm.m_StaticContext = m_context;

            TripManager.Initialize(m_context.ScanTool, m_context.PidMonitor, m_context.FuelCalculator, MainForm.ApplicationDataDirectory);
            TripManager.ErrorOccurred += new EventHandler<OCTech.Utilities.ExceptionEventArgs>(utilities_ErrorOccurred);

            pluginInitialize();

            sensorCalibration = new SensorCalibration();
            sensorCalibration.Initialize(m_context);

            DispatchPID.Initialize(m_context);

            m_setupPage = new SetupPage(m_context);
            m_setupPage.ColorModeChanged += new EventHandler<ColorModeChangedEventArgs>(m_setupPage_ColorModeChanged);

            m_diagnostic = new DiagnosticsPage(m_context);
            m_monitors = new MonitorsPage(m_context);
            m_dashboard = new CustomDashboard(m_context);
            m_logs = new LogsPage(m_context);

            m_TabPages.Add("Setup", m_setupPage);
            m_TabPages.Add("Diagnostics", m_diagnostic);
            m_TabPages.Add("Monitors", m_monitors);
            m_TabPages.Add("Dashboard", m_dashboard);
            m_TabPages.Add("Logs", m_logs);

            pagePanel.SuspendLayout();

            addPageToPanel(m_setupPage);
            addPageToPanel(m_diagnostic);
            addPageToPanel(m_monitors);
            addPageToPanel(m_dashboard);
            addPageToPanel(m_logs);

            pagePanel.ResumeLayout();

            m_StripMenus.Add("Setup", setupToolStripMenuItem);
            m_StripMenus.Add("Diagnostics", diagnosticsToolStripMenuItem);
            m_StripMenus.Add("Monitors", monitorsToolStripMenuItem);
            m_StripMenus.Add("Dashboard", dashboardToolStripMenuItem);
            m_StripMenus.Add("Logs", logsToolStripMenuItem);

            setControlsText();
            setConnectButtonState();

            loadOCTechPlugins();
            if (m_PluginsInfo.Plugins.Count == 0 && !PIDPluginController.AreAnyPIDPluginAssembliesLoaded)
                pluginManagerToolStripMenuItem.Visible = false;

            if (!m_TabPages.ContainsKey(m_prefences.Layout.SelectedPageKey))
                m_prefences.Layout.SelectedPageKey = "Setup";
            switchPageByName(m_prefences.Layout.SelectedPageKey);
            customListView.SelectItem(m_prefences.Layout.SelectedPageKey);
            loadDataDashboard(getDataPath);

            try
            {
                m_pidMonitor.LoadSettings(MainForm.ApplicationDataDirectory);
            }
            catch { }

            m_setupPage.m001d9a(m_PluginsInfo);

            setColorTheme(ActiveTheme);
            m_scanTool.DebugEnabled = true;

            Gauge.ErrorOccurred += new EventHandler<Controls.ExceptionEventArgs>(controls_ErrorOccurred);
            PowerBar.ErrorOccurred += new EventHandler<Controls.ExceptionEventArgs>(controls_ErrorOccurred);
            RoundedLabel.ErrorOccurred += new EventHandler<Controls.ExceptionEventArgs>(controls_ErrorOccurred);
            LinearGauge.ErrorOccurred += new EventHandler<Controls.ExceptionEventArgs>(controls_ErrorOccurred);
        }
Beispiel #6
0
        //static IWebDriver webDriver;
        static void Main(string[] args)
        {
            var    shouldShowHelp           = false;
            string uri                      = "https://localhost:44346";
            string siteName                 = "Service Taxonomy Editor";
            string recipeName               = "ServiceTaxonomyEditor";
            string databaseType             = "";
            string tablePrefix              = "";
            string sqlConnectionString      = "";
            string userName                 = "";
            string email                    = "";
            string password                 = "";
            bool   runPublishIfAlreadySetUp = false;
            bool   alreadySetup             = false;
            int    returnCode               = 0;

            var p = new OptionSet {
                { "u|uri=", "The base url of the orchard core instance.", u => uri = u },
                { "s|sitename=", "The name of the site", s => siteName = s },
                { "r|recipename=", "The name of the recipe to load during initialistation", r => recipeName = r },
                { "d|databasetype=", "The database type for the installation ( SqlConnection | Sqlite | MySql | Postgres )", d => databaseType = d },
                { "t|tableprefix=", "The table prefix (not required for Sqlite )", t => tablePrefix = t },
                { "c|connectionstring=", "The sql connection string (not required for Sqlite )", c => sqlConnectionString = c },
                { "n|username="******"The default user name", n => userName = n },
                { "e|email=", "The default email address", e => email = e },
                { "p|password="******"The default password", p => password = p },
                { "a|alwaysRunPublish=", "If Setup is already complete, publish anyway (y/n)", x => runPublishIfAlreadySetUp = (x.ToLower().Equals("y")) },
                { "h|help", "show this message and exit", h => shouldShowHelp = h != null },
            };



            List <string> extra;

            try
            {
                // parse the command line
                extra = p.Parse(args);
            }
            catch (OptionException e)
            {
                // output some error message
                Console.Write("greet: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `greet --help' for more information.");
                return;
            }

            bool   missingArgs  = false;
            string errorMessage = "The following mandatory arguments were not supplied:\n";

            if (userName == string.Empty)
            {
                missingArgs   = true;
                errorMessage += "\tuserName\n";
            }
            if (email == string.Empty)
            {
                missingArgs   = true;
                errorMessage += "\temail\n";
            }
            if (password == string.Empty)
            {
                missingArgs   = true;
                errorMessage += "\tpassword\n";
            }

            if (missingArgs && !shouldShowHelp)
            {
                Console.WriteLine(errorMessage + "\n");
                shouldShowHelp = true;
            }

            if (shouldShowHelp)
            {
                ShowHelp(p);
                return;
            }

            if (!uri.EndsWith("/"))
            {
                Console.WriteLine("Adding trailing slash to uri");
                uri += "/";
            }

            Console.WriteLine("uri = " + uri);
            Console.WriteLine("siteName = " + siteName);
            Console.WriteLine("recipeName = " + recipeName);
            Console.WriteLine("databaseType = " + databaseType);
            Console.WriteLine("tablePrefix = " + tablePrefix);
            Console.WriteLine("sqlConnectionString = " + new String('#', sqlConnectionString.Length));
            Console.WriteLine("userName = "******"email = " + email);
            Console.WriteLine("password = "******"runPublishIfAlreadySetUp = " + runPublishIfAlreadySetUp.ToString());

            IWebDriver webDriver = null;

            try
            {
                ChromeOptions options = new ChromeOptions();
                if (Environment.GetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI") == "https://sfa-gov-uk.visualstudio.com/")
                {
                    Console.WriteLine("Running on build server, using headless browser");
                    options.AddArgument("--headless");
                }

                webDriver = new ChromeDriver(Environment.CurrentDirectory, options);

                // setup page

                SetupPage setupPage = new SetupPage(webDriver);
                setupPage.openPage(uri);
                alreadySetup = !setupPage.verifyPageLoaded();

                if (!alreadySetup)
                {
                    Console.WriteLine("Initial configuration not completed, configuring site and checking database configuration");
                    setupPage.enterSiteName(siteName);
                    setupPage.selectRecipe(recipeName);
                    if (!databaseType.Equals(string.Empty))
                    {
                        Console.WriteLine(String.Format("Setting database type to {0}", databaseType));
                        setupPage.selectDatabase(databaseType);
                    }
                    if (!sqlConnectionString.Equals(string.Empty))
                    {
                        Console.WriteLine("Setting SQL Connection String");
                        setupPage.enterConnectionString(sqlConnectionString);
                    }
                    if (!tablePrefix.Equals(string.Empty))
                    {
                        setupPage.enterTablePrefix(tablePrefix);
                    }
                    setupPage.enterUsername(userName);
                    setupPage.enterPassword(password);
                    setupPage.enterEmail(email);

                    setupPage.submitForm();
                    if (!setupPage.checkSubmissionSuccess())
                    {
                        throw new Exception("Setup did not complete succesfully");
                    }
                    ;
                }
                else
                {
                    Console.WriteLine(string.Format("Initial configuration already completed, navigating to {0}", uri));
                    webDriver.Navigate().GoToUrl(uri);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("An error was encountered:\n" + e);
                if (webDriver != null)
                {
                    String filepath = String.Format("{0}/OrchardCoreSetupScreenshot-{1}.png", Environment.CurrentDirectory, DateTime.Now.ToString("yyyyMMdd-HHmm"));
                    Console.WriteLine(String.Format("saving screenshot to {0}", filepath));
                    Screenshot screenShot = ((ITakesScreenshot)webDriver).GetScreenshot();
                    screenShot.SaveAsFile(filepath);
                }
                returnCode = -1;
            }
            finally
            {
                webDriver?.Close();
                webDriver?.Quit();
            }
            Environment.Exit(returnCode);
        }