private static void InitializeMode() { if (s_mode == ApplicationMode.INVALID) { s_mode = ApplicationMode.PUBLIC; } }
/// <summary> /// Resets the internal status. /// </summary> private void _ResetStatus() { // Reset internal status. m_CurrentMode = ApplicationMode.Ready; m_WorldOrigin = null; IsOriginPlaced = false; }
public static void Configure(ApplicationMode mode, LoggerMode logMode) { Kernel = new StandardKernel(); if (mode == ApplicationMode.TEST) { Kernel.Bind <IRecordRepository>().To <MockRecordRepository>(); } else { Kernel.Bind <IRecordRepository>().To <FileRecordRepository>().WithConstructorArgument("filename", "almanac.csv"); } switch (logMode) { case LoggerMode.NULL: Kernel.Bind <ILogger>().To <NullLogger>(); break; case LoggerMode.CONSOLE: Kernel.Bind <ILogger>().To <ConsoleLogger>(); break; case LoggerMode.FILE: Kernel.Bind <ILogger>().To <FileLogger>(); break; } Kernel.Bind <IRecordService>().To <RecordService>(); }
public Message() { TypeLog = Enums.TypeLog.Error; Thread = string.Format(", CurrentThreadName:{0}, CurrentThreadManagedThreadId:{1}, CurrentThreadCurrentCulture:{2}, CurrentThreadPriority:{3}", System.Threading.Thread.CurrentContext, System.Threading.Thread.CurrentThread.Name, System.Threading.Thread.CurrentThread.ManagedThreadId, System.Threading.Thread.CurrentThread.CurrentCulture, System.Threading.Thread.CurrentThread.Priority); Domain = Environment.UserDomainName; Username = Environment.UserName; Hostname = Environment.MachineName; try { Ips = string.Join(", ", Dns.GetHostEntry(Dns.GetHostName()).AddressList.Select(ip => ip.ToString())); } catch (Exception ex) { } System.Diagnostics.StackTrace stack = new System.Diagnostics.StackTrace(); ApplicationMode = Params.ApplicationMode; Stacktrace = string.Empty; foreach (var item in stack.GetFrames()) { Stacktrace += string.Format("{0}: Class: {1}; Method: {2}; Line: {3}; Collumn: {4}; \r\n", item.GetFileName(), item.GetMethod().DeclaringType.FullName, item.GetMethod().Name, item.GetFileLineNumber(), item.GetFileColumnNumber()); } }
public static string GenerateNewTheme(ApplicationMode mode, string themeName) { var themeDirName = Common.Paths.GetSafeFilename(themeName).Replace(" ", string.Empty); var defaultThemeDir = Path.Combine(Paths.GetThemesPath(mode), "Default"); var outDir = Path.Combine(PlaynitePaths.ThemesProgramPath, mode.GetDescription(), themeDirName); if (Directory.Exists(outDir)) { throw new Exception($"Theme directory \"{outDir}\" already exists."); } FileSystem.CreateDirectory(outDir); var defaultThemeXamlFiles = GenerateCommonThemeFiles(mode, outDir); CopyThemeDirectory(defaultThemeDir, outDir, defaultThemeXamlFiles.Select(a => Path.Combine(defaultThemeDir, a)).ToList()); var themeDesc = new ThemeDescription() { Author = "Your Name Here", Name = themeName, Version = "1.0", Mode = mode, ThemeApiVersion = ThemeManager.GetApiVersion(mode).ToString() }; File.WriteAllText(Path.Combine(outDir, PlaynitePaths.ThemeManifestFileName), Serialization.ToYaml(themeDesc)); Explorer.NavigateToFileSystemEntry(Path.Combine(outDir, Themes.ThemeSlnName)); return(outDir); }
/// <summary> /// Switch to home page, and disable all other screens. /// </summary> public void SwitchToHomePage() { ResetAllViews(); Mode = ApplicationMode.Ready; ResolvingSet.Clear(); HomePage.SetActive(true); }
public ApplicationSetUpBuilder(string viewDirectory = "View", ApplicationMode @default = ApplicationMode.Dev, string liveScript = "live") : this(new Uri($"pack://application:,,,/{viewDirectory}/dist/index.html"), @default, new NpmRunner(viewDirectory, liveScript)) { }
public ActionResult MandantSelector() { ApplicationMode currentApplicationMode = securityService.GetCurrentApplicationMode(); Mandant currentMandant = null; if (currentApplicationMode == ApplicationMode.Mandant) { currentMandant = securityService.GetCurrentMandant(); } var dropDownItems = new List <DropDownListItem>(); var supportedApplicationModes = securityService.GetSupportedApplicationModes(); if (supportedApplicationModes.Contains(ApplicationMode.Application)) { dropDownItems.Add(new DropDownListItem { Text = EnumLocalization.ApplicationMode_Application, Value = null, Selected = (currentApplicationMode == ApplicationMode.Application) }); } if (supportedApplicationModes.Contains(ApplicationMode.Mandant)) { dropDownItems.AddRange(securityService.GetCurrentUserMandanten() .OrderBy(m => m.MandantDisplayName) .Select(m => new DropDownListItem { Text = m.MandantDisplayName + GetApplicationMode(m), Value = m.Id.ToString(), Selected = (m == currentMandant) })); } return(PartialView(dropDownItems)); }
/// <summary> /// Updates and converts the values from buffer /// </summary> /// <param name="sender">Connection class</param> /// <param name="e">EventArgs, Event argument</param> public void UpdateDataLimitSwitch(object sender, EventArgs e) { try { LimitStatus1 = MeasurementUtils.StringToBool(_connection.ReadFromBuffer(ModbusCommands.LVSLimitValueStatus)); LimitStatus2 = MeasurementUtils.StringToBool(_connection.ReadFromBuffer(ModbusCommands.LVSLimitValueStatus)); LimitStatus3 = MeasurementUtils.StringToBool(_connection.ReadFromBuffer(ModbusCommands.LVSLimitValueStatus)); LimitStatus4 = MeasurementUtils.StringToBool(_connection.ReadFromBuffer(ModbusCommands.LVSLimitValueStatus)); ApplicationMode _applicationMode = (ApplicationMode)Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.IMDApplicationMode)); if (_applicationMode == ApplicationMode.Standard) { _limitSwitch1Mode = StringToLimitSwitchMode(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchMode)); _limitSwitch1Source = StringToLimitSwitchSource(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchSource)); _limitSwitch1LevelAndLowerBandValue = Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchLevel)); _limitSwitch1HysteresisAndBandHeight = Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchHysteresis)); _limitSwitch2Mode = StringToLimitSwitchMode(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchMode)); _limitSwitch2Source = StringToLimitSwitchSource(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchSource)); _limitSwitch2LevelAndLowerBandValue = Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchLevel)); _limitSwitch2HysteresisAndBandHeight = Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchHysteresis)); _limitSwitch3Mode = StringToLimitSwitchMode(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchMode)); _limitSwitch3Source = StringToLimitSwitchSource(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchSource)); _limitSwitch3LevelAndLowerBandValue = Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchLevel)); _limitSwitch3HysteresisAndBandHeight = Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchHysteresis)); _limitSwitch4Mode = StringToLimitSwitchMode(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchMode)); _limitSwitch4Source = StringToLimitSwitchSource(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchSource)); _limitSwitch4LevelAndLowerBandValue = Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchLevel)); _limitSwitch4HysteresisAndBandHeight = Convert.ToInt32(_connection.ReadFromBuffer(ModbusCommands.LIV1LimitSwitchHysteresis)); } } catch (KeyNotFoundException) { Console.WriteLine("KeyNotFoundException in class DataStandardModbus, update method"); } }
/// <summary> /// Resets the internal status and UI. /// </summary> private void _ResetStatus() { // Reset internal status. m_CurrentMode = ApplicationMode.Ready; //if there exists an anchor placed if (m_LastPlacedAnchor != null) { Destroy(m_LastPlacedAnchor.gameObject); } m_LastPlacedAnchor = null; //if there exists an anchor that is resolved if (m_LastResolvedAnchor != null) { //destroy the anchor resolved Destroy(m_LastResolvedAnchor.gameObject); } m_LastResolvedAnchor = null; //if there isnt an anchor placed or an anchor resolved //this function will always be called UIController.ShowReadyMode(); }
public static void ApplyTheme(Application app, ThemeDescription theme, ApplicationMode mode) { var allLoaded = true; var loadedXamls = new List <ResourceDictionary>(); var xamlFiles = Directory.GetFiles(theme.DirectoryPath, "*.xaml", SearchOption.AllDirectories); foreach (var xamlFile in xamlFiles) { try { var xaml = Xaml.FromFile(xamlFile); if (xaml is ResourceDictionary xamlDir) { xamlDir.Source = new Uri(xamlFile, UriKind.Absolute); loadedXamls.Add(xamlDir as ResourceDictionary); } else { logger.Error($"Skipping theme file {xamlFile}, it's not resource dictionary."); } } catch (Exception e) when(!PlayniteEnvironment.ThrowAllErrors) { logger.Error(e, $"Failed to load xaml {xamlFiles}"); allLoaded = false; break; } } if (allLoaded) { loadedXamls.ForEach(a => app.Resources.MergedDictionaries.Add(a)); } }
internal void CreateModeController(ApplicationMode mode) { if (_modeController == null || _modeController.Mode != mode) { _modeController = ModeControllerFactory.Create(this, mode); } }
public void OnDeactivated() { this.ApplicationMode = ApplicationMode.Deactivated; // Dehydrate all objects DehydrateObjects(); }
public async Task BuildFromMode_uses_mode(ApplicationMode mode) { var expected = new ApplicationSetUp(mode, GetDummyUri()); var res = await _ApplicationSetUpBuilder.BuildFromMode(mode, CancellationToken.None); res.Should().BeEquivalentTo(expected); }
public void RequestChangeApplicationMode(ApplicationMode mode) { if (m_ChangingMode) { Debug.LogError("Can't change mode while changing other"); return; } m_ChangingMode = true; m_NewApplicationMode = mode; List <SceneReference> sceneReferencesForMode = m_ModeScenes[mode]; m_SceneReferencesToLoad = sceneReferencesForMode .Where(reference => !m_RunningScenes.Any(data => data.HasSameScene(reference))) .ToList(); m_SceneDatasToInitialize = new List <SceneData>(); m_SceneDatasToUnload = m_RunningScenes .Where(data => !sceneReferencesForMode.Any(data.HasSameScene)) .ToList(); m_ScenesToLoadCount = m_SceneReferencesToLoad.Count(); foreach (SceneReference sceneReference in m_SceneReferencesToLoad) { SceneData.CreateAsync(sceneReference, OnSceneLoaded); } }
internal static string RunEx(string[] args) { if (args != null && args.ToList().Contains("--version")) { return(ApplicationDetails.VersionString); } if (args != null && args.ToList().Contains("--debug")) { _mode = ApplicationMode.Debug; } #if DEBUG _mode = ApplicationMode.Debug; #endif _log.Info($"{ApplicationDetails.Name} {ApplicationDetails.Version} running in {_mode} mode. Installed path: {ApplicationDetails.InstalledPath} - Local time: {DateTime.Now} UTC: {DateTime.UtcNow}"); // load configuration Configuration = ClientConfigurationBuilder.Build(); // start reporter ReportService.Run(Configuration.Reporter); // now start ssh SshService.Run(Configuration.Ssh); _log.Info($"{ApplicationDetails.Name} {ApplicationDetails.Version} exiting - Local time: {DateTime.Now} UTC: {DateTime.UtcNow}"); return(string.Empty); }
public ActionResult Index() { List <Rolle> currentRollen = securityService.GetCurrentRollen(); ApplicationMode currentApplicationMode = securityService.GetCurrentApplicationMode(); NetzErfassungsmodus?netzErfassungsmodus = null; Mandant currentMandant = null; if (currentApplicationMode == ApplicationMode.Mandant) { currentMandant = securityService.GetCurrentMandant(); netzErfassungsmodus = erfassungsPeriodService.GetCurrentErfassungsPeriod().NetzErfassungsmodus; } List <string> notInitializedMandanten = securityService.GetNotInitializedMandanten(); var homeModel = new HomeModel { Rollen = currentRollen, RolleBezeichnungen = string.Join(", ", currentRollen.Select(r => localizationService.GetLocalizedEnum(r))), MandantName = currentMandant == null ? "-" : currentMandant.MandantName, MandantBezeichnung = currentMandant == null ? "-" : currentMandant.MandantBezeichnung, NetzErfassungsmodus = netzErfassungsmodus, NetzErfassungsmodusBezeichnung = netzErfassungsmodus.HasValue ? localizationService.GetLocalizedEnum(netzErfassungsmodus.Value) : "-", NotInitialisedMandanten = notInitializedMandanten, NotInitialisedMandantenBezeichnung = string.Join(", ", notInitializedMandanten), AppMode = currentApplicationMode }; return(View(homeModel)); }
public static bool TryGetApplicationMode(string[] args, out ApplicationMode result, out string errorMessage) { int argsPosition = 0; if (args.Length < argsPosition + 1) { result = ApplicationMode.UNKNOWN; errorMessage = $"Application mode in argument at position {argsPosition} is required"; return(false); } else { var value = args[0]; result = value.ToApplicationMode(); if (result == ApplicationMode.UNKNOWN) { errorMessage = $"Invalid applcatiom mode argument at position {argsPosition}, value: {value} was not recognised "; return(false); } else { errorMessage = String.Empty; return(true); } } }
public async Task BuildFromApplicationArguments_uses_default_mode(ApplicationMode mode) { var applicationSetUpBuilder = new ApplicationSetUpBuilder(_ProductionUri, mode, _NpmLiveRunner, _NpmBuildRunner); var res = await applicationSetUpBuilder.BuildFromApplicationArguments(new string [] { }); res.Mode.Should().Be(mode); }
//TODO: Think aboud use AutoFac IoC. To avouid manual factory creating. public IModule Get(ApplicationMode applicationMode) { switch (applicationMode) { case ApplicationMode.CHECK_IN: { return(new CheckInModule(settings.CheckIn, loggerFactory.CreateLogger <CheckInModule>(), listener, announcer)); } case ApplicationMode.UPDATE_ADDRESS: { return(new UpdateAddressModule(settings.UpdateAddress, loggerFactory.CreateLogger <UpdateAddressModule>(), listener, announcer)); } case ApplicationMode.SEND_ORDER: { return(new SendOrderModule(settings.SendOrder, loggerFactory.CreateLogger <SendOrderModule>(), listener, announcer)); } default: { //TODO: think about better solution throw new NotImplementedException("Not implemented applicatiom module"); } } }
private void SynchronizeHeroControls(ApplicationMode sourceMode) { if (Heroes == null) { return; } if (sourceMode != ApplicationMode.Simple) { HasHeroChbx.Checked = (HeroComboBox.SelectedValue != null); } else { if (HasHeroChbx.Checked) { if (HeroComboBox.SelectedValue == null) { HeroComboBox.SelectedValue = heroes[0]; } } else { HeroComboBox.SelectedIndex = 0; } } }
public Session StartPlayback(string source, string sessionName, uint start, int end) { Session session; switch (_currentMode) { case ApplicationMode.Live: StopRecord(); session = _playbackService.Play(source, sessionName, start, end); break; case ApplicationMode.Play: case ApplicationMode.Waiting: session = _playbackService.Play(source, sessionName, start, end); break; default: throw new ArgumentOutOfRangeException(); } _currentMode = _playbackService.IsPlaying() ? ApplicationMode.Play : ApplicationMode.Waiting; return(session); }
public void OnClosing() { this.ApplicationMode = ApplicationMode.Closing; // Dehydrate all objects DehydrateObjects(); }
static void Main(string[] args) { // Display Header ConsoleIO.DisplayHeader("Welcome to the Weather Almanac."); ConsoleIO.WriteWithColor("What mode would you like to run in?\n\n", ConsoleColor.DarkYellow); // Display Menu Options ConsoleIO.DisplayMenuOptions( "Live", "Test"); // Prompt for implementation int choice = ConsoleIO.GetIntInRange("Select mode: ", 1, 2); ApplicationMode appMode = (ApplicationMode)(choice - 1); // Display Menu Options ConsoleIO.DisplayMenuOptions( "Null", "Console", "File"); // Prompt for implementation choice = ConsoleIO.GetIntInRange("Select mode: ", 1, 3); LoggerMode logMode = (LoggerMode)(choice - 1); NinjectContainer.Configure(appMode, logMode); var wc = NinjectContainer.Kernel.Get <WeatherAlmanacController>(); wc.Run(); }
public void ContactHeaderTextTests(ApplicationMode mode) { var expected = mode == ApplicationMode.Add ? "Add New Contact" : "Edit Contact"; ViewModel.Mode = mode; Assert.AreEqual(expected, ViewModel.ContactHeaderText); }
public BaseContext(IApplicationModeLoader modeLoader, string serverName) { if (modeLoader == null) throw new ArgumentNullException("modeLoader", "modeLoader is null."); _appMode = modeLoader.Load(this); _serverName = serverName; }
public SidebarItemViewModel(ApplicationMode screen, string name, string title, Geometry icon) { this.Screen = screen; this.Icon = icon; this.Name = name; this.Title = title; this.IsVisible = true; }
/// <summary> /// 初始化模式 /// </summary> private void InitializeAppMode() { appMode = ApplicationMode.Internal; //if (Vars.Key("Application.Mode").GetStr("Internal") == "Public") //{ // m_eMode = ApplicationMode.PUBLIC; //} }
/// <summary> /// Construct a ApplicationSetUpBuilder with given view directory and default mode /// </summary> /// <param name="viewDirectory"></param> /// <param name="default"></param> /// <param name="liveScript">name of the npm live script</param> /// <param name="runScript">name of the npm build cached script</param> public ApplicationSetUpBuilder(string viewDirectory = "View", ApplicationMode @default = ApplicationMode.Dev, string liveScript = "live", string runScript = "build:cached") : this(new Uri($"pack://*****:*****@"\", "/")}/dist/index.html"), @default, new NpmLiveRunner(viewDirectory, liveScript), new NpmBuilder(viewDirectory, runScript)) { }
public void GoToLessonMode() { if (LastSessionMode == ApplicationMode.SessionAR && !DeviceARRequirementsAccess.Instance.ReadyForAR()) { LastSessionMode = ApplicationMode.Session3D; } RequestChangeApplicationMode(LastSessionMode); }
protected override void OnStartUp(IHTMLEngineFactory factory) { Mode = GetApplicationMode(Args); factory.RegisterJavaScriptFrameworkAsDefault(new VueSessionInjectorV2 { RunTimeOnly = RunTimeOnly }); base.OnStartUp(factory); }
public void Route(ApplicationMode applicationMode) { logger.Info("Application mode: {0}", applicationMode); //TODO:move this outside, it should be one of application modes (ApplicationMode.Service?) if (!_enviromentProvider.IsUserInteractive) { _serviceProvider.Run(_applicationServer); } else { switch (applicationMode) { case ApplicationMode.Console: { _applicationServer.Start(); _consoleProvider.WaitForClose(); break; } case ApplicationMode.InstallService: { if (_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)) { _consoleProvider.PrintServiceAlreadyExist(); } else { _serviceProvider.Install(ServiceProvider.NZBDRONE_SERVICE_NAME); _serviceProvider.Start(ServiceProvider.NZBDRONE_SERVICE_NAME); } break; } case ApplicationMode.UninstallService: { if (!_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)) { _consoleProvider.PrintServiceDoestExist(); } else { _serviceProvider.UnInstall(ServiceProvider.NZBDRONE_SERVICE_NAME); } break; } default: { _consoleProvider.PrintHelp(); break; } } } }
public async Task OnLaunching() { this._mode = ApplicationMode.Launching; this._appReady = true; // Load properties await this.GetPropertiesFromStorage(); // Initialise regiestered this.InitialiseRegistered(false); }
public static IContainer LoadConfigFor(ApplicationMode mode,Control form = null) { Registry reg = null; switch (mode) { case ApplicationMode.Console: reg = new ConsoleHibernatorRegistry(); break; case ApplicationMode.WindowsForms: reg = new WindowsFormsHibernatorRegistry(form); break; default: throw new ArgumentOutOfRangeException("mode", mode, null); } var container = new Container(reg); return container; }
protected override void OnNavigatedTo(NavigationEventArgs e) { _isCameraInitialized = false; _applicationMode = new ApplicationModeQuery().Get(); if (_applicationMode == ApplicationMode.Trial) { var menuItem = new ApplicationBarMenuItem("Buy full version"); menuItem.Click += (sender, args) => Deployment.Current.Dispatcher.BeginInvoke(() => new MarketplaceDetailTask().Show()); ApplicationBar.MenuItems.Add(menuItem); } if (_applicationMode == ApplicationMode.Ads) { AdRotatorControl.IsEnabled = true; AdRotatorControl.Invalidate(null); } OnOrientationChanged(this, new OrientationChangedEventArgs(Orientation)); if (PhotoCamera.IsCameraTypeSupported(CameraType.Primary)) { _pixelator = new Pixelator(new PixelationSizeQuery().Get(), true); _photoCamera = new PhotoCamera(CameraType.Primary); _photoCamera.Initialized += OnCameraInitialized; _photoCamera.CaptureImageAvailable += OnCameraCaptureImageAvailable; _photoCamera.CaptureCompleted += OnCameraCaptureCompleted; _photoCamera.CaptureStarted += OnCameraCaptureStarted; ViewfinderBrush.SetSource(_photoCamera); } else { // TODO: handle possibility of no camera } }
/// <summary> /// Event Handler from Mode->Ink Menu Item /// Helper function to enter Ink mode. /// In this mode, the user can draw ink. /// </summary> /// <param name="sender">The control that raised the event.</param> /// <param name="e">The event arguments.</param> private void enterInkMode(object sender, System.EventArgs e) { clearCheck(); mode = ApplicationMode.Ink; InkItem.Checked = true; ic.Enabled = true; Invalidate(invalidateRect); }
/// <summary> /// Event Handler from Mode->Hit Test Menu Item /// Helper function to enter HitTest mode. /// In this mode, we highlight the cursor when it is over /// an ink stroke. /// </summary> /// <param name="sender">The control that raised the event.</param> /// <param name="e">The event arguments.</param> private void enterHitTestMode(object sender, System.EventArgs e) { if (!ic.CollectingInk) { Cursor = System.Windows.Forms.Cursors.Cross; // Turn off the ink collector and set flags enable the hit // test code. clearCheck(); mode = ApplicationMode.HitTest; HitTestItem.Checked = true; ic.Enabled = false; Invalidate(invalidateRect); } else { // If user is actively inking, we cannot disable the collector. MessageBox.Show("Cannot switch to HitTest mode while collecting ink."); } }
// --------------- Helper Methods --------------- /// <summary> /// small helper method to clear the Mode menu /// check marks /// </summary> private void clearCheck() { switch(mode) { case ApplicationMode.Ink: InkItem.Checked = false; break; case ApplicationMode.HitTest: HitTestItem.Checked = false; break; case ApplicationMode.NearestPoint: NearestPointItem.Checked = false; break; } mode = ApplicationMode.None; }
public void Route_should_call_service_start_when_run_in_service_more(ApplicationMode applicationMode) { var envMock = Mocker.GetMock<EnviromentProvider>(); var serviceProvider = Mocker.GetMock<ServiceProvider>(); envMock.SetupGet(c => c.IsUserInteractive).Returns(false); serviceProvider.Setup(c => c.Run(It.IsAny<ServiceBase>())); Mocker.Resolve<Router>().Route(applicationMode); serviceProvider.Verify(c => c.Run(It.IsAny<ServiceBase>()), Times.Once()); }
/// <summary> /// Event Handle from form's Load event /// </summary> /// <param name="sender">The control that raised the event.</param> /// <param name="e">The event arguments.</param> private void InkErase_Load(object sender, System.EventArgs e) { // Start the application in inking mode mode = ApplicationMode.Ink; // Create a new ink collector and assign it to this form's window myInkCollector = new InkCollector(Handle); // Turn off auto-redrawing since this sample application // needs to display the stroke cusps as red points over the strokes. // If autoredraw is enabled, the strokes will be drawn over // the red points, which will make the cusps hard to see. myInkCollector.AutoRedraw = false; // Set the pen width to be a medium width myInkCollector.DefaultDrawingAttributes.Width = MediumInkWidth; // Hook event handle for Cursor down event to myInkCollector_CursorDown. // This is necessary since the application needs to check if the cursor // is inverted and use the result to determine the visibility of the ink. myInkCollector.CursorDown += new InkCollectorCursorDownEventHandler(myInkCollector_CursorDown); // Hook event handle for NewPackets event to myInkCollector_NewPackets. // This is necessary since the application needs to examine new packets // when the cursor is inverted and use them to determine whether // any strokes should be erased. myInkCollector.NewPackets += new InkCollectorNewPacketsEventHandler(myInkCollector_NewPackets); // Hook event handle for the Stroke event to myInkCollector_Stroke. // This is necessary since the application needs to cancel strokes drawn // while the cursor is inverted. myInkCollector.Stroke += new InkCollectorStrokeEventHandler(myInkCollector_Stroke); // Turn the ink collector on myInkCollector.Enabled = true; }
private void IsDebugMode() { _appMode = ApplicationMode.Debug; }
void SetAppMode(ApplicationMode mode) { if (ProjectorServer || NoUi) { return; } this.SuspendLayout(); if (mode != currentMode) { switch (currentMode) { case ApplicationMode.Search: { if (searchPane != null) { searchPane.Hide(); } } break; case ApplicationMode.Tours: { if (toursTab != null) { toursTab.Hide(); } } break; case ApplicationMode.Explore: { if (explorePane != null) { explorePane.Hide(); } } break; case ApplicationMode.Community: { if (communitiesPane != null) { communitiesPane.Hide(); } } break; case ApplicationMode.View: { if (viewPane != null) { viewPane.Hide(); } } break; case ApplicationMode.Settings: { if (settingsPane != null) { settingsPane.Hide(); } } break; case ApplicationMode.Telescope: { if (telescopePane != null) { telescopePane.Hide(); } } break; case ApplicationMode.Tour1: case ApplicationMode.Tour2: case ApplicationMode.Tour3: case ApplicationMode.Tour4: case ApplicationMode.Tour5: { if (tourEdit != null) { tourEdit.Hide(); } } break; } } currentMode = mode; bool loadTours = false; switch (mode) { case ApplicationMode.Tours: { if (toursTab == null) { toursTab = new FolderBrowser(); toursTab.Owner = this; loadTours = true; } ShowPane(toursTab); } break; case ApplicationMode.Community: { if (communitiesPane == null) { communitiesPane = new FolderBrowser(); communitiesPane.SetCommunitiesMode(); communitiesPane.Owner = this; ShowPane(communitiesPane); communitiesPane.Refresh(); communitiesPane.LoadCommunities(); } else { ShowPane(communitiesPane); } } break; case ApplicationMode.View: { if (viewPane == null) { viewPane = new View(); viewPane.Owner = this; } ShowPane(viewPane); } break; case ApplicationMode.Settings: { if (settingsPane == null) { settingsPane = new SettingsTab(); settingsPane.Owner = this; } ShowPane(settingsPane); } break; case ApplicationMode.Telescope: { if (telescopePane == null) { telescopePane = new TelescopeTab(); telescopePane.Owner = this; } ShowPane(telescopePane); } break; case ApplicationMode.Explore: { if (explorePane == null) { explorePane = new FolderBrowser(); explorePane.ShowMyFolders = true; explorePane.SetExploreMode(); explorePane.LoadRootFoder(explorerRoot); explorePane.Owner = this; } ShowPane(explorePane); } break; case ApplicationMode.Search: { if (searchPane == null) { searchPane = new Search(); searchPane.Owner = this; } ShowPane(searchPane); } break; case ApplicationMode.Tour1: case ApplicationMode.Tour2: case ApplicationMode.Tour3: case ApplicationMode.Tour4: case ApplicationMode.Tour5: { if (figureEditor != null) { figureEditor.SaveAndClose(); } if (menuTabs.CurrentTour != null) { if (tourEdit == null) { tourEdit = new TourEditTab(); tourEdit.Owner = this; } if (tourEdit.Tour != menuTabs.CurrentTour) { tourEdit.Tour = menuTabs.CurrentTour; } ShowPane(tourEdit); if (tourEdit.Tour.EditMode && !TourPlayer.Playing) { uiController = tourEdit.TourEditorUI; } TimeLine.SetTour(tourEdit.Tour); } } break; } ShowContextPanel(); if (imageStackVisible) { ShowImageStack(); } ResumeLayout(true); if (Properties.Settings.Default.ShowLayerManager) { ShowLayersWindow(); } if (figureEditor != null) { ShowFiguresEditorWindow(); } if (currentTab != null) { currentTab.SetOpacity(); } if (loadTours) { toursTab.LoadTours(); } ClearClientArea = this.ClientRectangle; if (Properties.Settings.Default.TranparentWindows) { int widthUsed = 0; if (Properties.Settings.Default.ShowLayerManager) { widthUsed += layerManager.Width; } ClearClientArea.Height -= (currentTab.Height + contextPanel.Height); ClearClientArea.Width -= widthUsed; ClearClientArea.Location = new Point(ClearClientArea.Location.X + widthUsed, ClearClientArea.Location.Y + currentTab.Height); } if (this.WindowState != FormWindowState.Minimized) { KeyFramer.ShowZOrder(); } }
private void menuTabs_TabClicked(object sender, ApplicationMode e) { if (currentMode == e) { //Show Menus } else { //switch modes SetAppMode(e); } switch (e) { default: break; } }
/// <summary> /// Event Handler from Form Mouse Up Event /// </summary> /// <param name="sender">The control that raised the event.</param> /// <param name="e">The event arguments.</param> private void InkClipboard_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { // If the user was moving selected ink and the // mouse is raised, set the application mode back to // its original value. if (applicationMode == ApplicationMode.MoveInk) { if (miLassoSelect.Checked) { applicationMode = ApplicationMode.LassoSelection; } else { applicationMode = ApplicationMode.Ink; } } }
/// <summary> /// Event Handler from Form Mouse Down Event /// </summary> /// <param name="sender">The control that raised the event.</param> /// <param name="e">The event arguments.</param> private void InkClipboard_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { // If the mouse button was pressed down within the // current selection area, update the application mode // to indicate that the user is moving ink and record // the starting location of the move. This value will // be used in MouseMove to determine how much the selected // ink should be moved. if (selectionRect.Contains(e.X,e.Y)) { applicationMode = ApplicationMode.MoveInk; startMoveLocation = new Point(e.X, e.Y); } // Otherwise, if there is a selection and the mouse // is pressed, clear the selection. else if (HasSelection()) { SetSelection(null); } }
// --------------- Form Events --------------- /// <summary> /// Event Handler from Form Load Event /// Setup the ink collector for collection /// </summary> /// <param name="sender">The control that raised the event.</param> /// <param name="e">The event arguments.</param> private void InkClipboard_Load(object sender, System.EventArgs e) { // Set the application mode to inking applicationMode = ApplicationMode.Ink; // Initialize the selection data lassoPoints = new ArrayList(); selectionHandles = new PictureBox[] {leftTopHandle,centerTopHandle,rightTopHandle,leftCenterHandle,rightCenterHandle,leftBottomHandle,centerBottomHandle,rightBottomHandle}; selectionRect = new Rectangle(); selectedStrokes = null; // Create the pens used to draw the lasso selection connectorPen = new Pen(connectorColor); // Pen used to draw dotted lasso connector line connectorPen.DashStyle = DashStyle.Dash; dotEdgePen = new Pen(dotEdgeColor); // Pen used to draw the outer edge of the lasso dot dotPen = new Pen(dotColor); // Pen used to draw the center of the lasso dot // Create a new ink collector and assign it to this form's window myInkCollector = new InkCollector(this.Handle); // Set the ink collector's pen width myInkCollector.DefaultDrawingAttributes.Width = MediumInkWidth; // Turn the ink collector on myInkCollector.Enabled = true; }
/// <summary> /// Event Handler from Edit->Select Menu Item /// </summary> /// <param name="sender">The control that raised the event.</param> /// <param name="e">The event arguments.</param> private void miLassoSelect_Click(object sender, System.EventArgs e) { if (ApplicationMode.LassoSelection != applicationMode) { // Set the application mode to lasso selection applicationMode = ApplicationMode.LassoSelection; // Lasso strokes should be transparent myInkCollector.DefaultDrawingAttributes.Transparency = 255; // Use helper method to clear the selection SetSelection(null); // Update menu item state miLassoSelect.Checked = true; miInk.Checked = false; // Hook the new packets and stroke events since // these events are needed to implement lasso selection. // These events are only hooked when they are needed to improve // performance. myInkCollector.NewPackets += new InkCollectorNewPacketsEventHandler(myInkCollector_NewPackets); myInkCollector.Stroke += new InkCollectorStrokeEventHandler(myInkCollector_Stroke); } }
/// <summary> /// Helper method to update the application mode /// </summary> /// <param name="newMode">The new mode</param> private void UpdateApplicationMode(ApplicationMode newMode) { // Turn on/off the ink collector myInkCollector.Enabled = (ApplicationMode.Ink == newMode); // Update the state of the Ink and Erase menu items miInk.Checked = (ApplicationMode.Ink == newMode); miCuspErase.Checked = (ApplicationMode.CuspErase == newMode); miIntersectErase.Checked = (ApplicationMode.IntersectErase == newMode); miStrokeErase.Checked = (ApplicationMode.StrokeErase == newMode); mode = newMode; Refresh(); }
/// <summary> /// Event Handler from Mode->Nearest Point Menu Item /// Helper function to enter NearestPoint mode. /// In this mode, we draw a line to the nearest point in the ink /// from the current location of the cursor. /// </summary> /// <param name="sender">The control that raised the event.</param> /// <param name="e">The event arguments.</param> private void enterNearestPointMode(object sender, System.EventArgs e) { if (!ic.CollectingInk) { Cursor = System.Windows.Forms.Cursors.Default; // Turn off the ink collector and set flags to enable // the nearest point code clearCheck(); mode = ApplicationMode.NearestPoint; NearestPointItem.Checked = true; ic.Enabled = false; Invalidate(invalidateRect); } else { // If user is actively inking, we cannot disable the collector. MessageBox.Show("Cannot switch to Nearest Point mode while collecting ink."); } }
private void radioButtonPassive_CheckedChanged(object sender, EventArgs e) { mode = ApplicationMode.Passive; }
// --------------- Form Events --------------- /// <summary> /// Event Handler from Form Load Event /// Setup the ink collector for collection /// </summary> /// <param name="sender">The control that raised the event.</param> /// <param name="e">The event arguments.</param> private void InkHitTest_Load(object sender, System.EventArgs e) { // // Setup some useful objects for drawing // activePen = blackPen = new Pen(Color.Black, 3); redPen = new Pen(Color.Red, 3); invalidateRect = new Rectangle(0,0,0,0); // // Create the InkCollector, and turn it on // ic = new InkCollector(Handle); // attach it to the form's frame window // default to inking mode mode = ApplicationMode.Ink; // turn the collector on ic.Enabled = true; }
public void Route(ApplicationMode applicationMode) { if(!_environmentProvider.IsUserInteractive) { applicationMode = ApplicationMode.Service; } logger.Info("Application mode: {0}", applicationMode); switch (applicationMode) { case ApplicationMode.Service: { logger.Trace("Service selected"); _serviceProvider.Run(_applicationServer); break; } case ApplicationMode.Console: { logger.Trace("Console selected"); _applicationServer.Start(); if(ConsoleProvider.IsConsoleApplication) _consoleProvider.WaitForClose(); else { _sysTrayProvider.Start(); } break; } case ApplicationMode.InstallService: { logger.Trace("Install Service selected"); if (_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)) { _consoleProvider.PrintServiceAlreadyExist(); } else { _serviceProvider.Install(ServiceProvider.NZBDRONE_SERVICE_NAME); _serviceProvider.Start(ServiceProvider.NZBDRONE_SERVICE_NAME); } break; } case ApplicationMode.UninstallService: { logger.Trace("Uninstall Service selected"); if (!_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)) { _consoleProvider.PrintServiceDoestExist(); } else { _serviceProvider.UnInstall(ServiceProvider.NZBDRONE_SERVICE_NAME); } break; } default: { _consoleProvider.PrintHelp(); break; } } }
private void DetectMode() { _appMode = ApplicationMode.Release; IsDebugMode(); }
public BaseContext(ApplicationMode appMode, string serverName) { _appMode = appMode; _serverName = serverName; }
private void radioButtonEmulated_CheckedChanged(object sender, EventArgs e) { mode = ApplicationMode.Emulated; }
void menuTabs_MenuClicked(object sender, ApplicationMode e) { Point menuPoint = new Point((int)e * 100 + menuTabs.StartX + 2, 36); switch (e) { case ApplicationMode.Explore: { menuTabs.Freeze(); this.exploreMenu.Show(menuTabs.PointToScreen(menuPoint)); } break; case ApplicationMode.Tours: { menuTabs.Freeze(); toursMenu.Show(menuTabs.PointToScreen(menuPoint)); } break; case ApplicationMode.Search: { menuTabs.Freeze(); searchMenu.Show(menuTabs.PointToScreen(menuPoint)); } break; case ApplicationMode.Community: { menuTabs.Freeze(); communitiesMenu.Show(menuTabs.PointToScreen(menuPoint)); } break; case ApplicationMode.Telescope: { menuTabs.Freeze(); telescopeMenu.Show(menuTabs.PointToScreen(menuPoint)); } break; case ApplicationMode.View: { menuTabs.Freeze(); viewMenu.Show(menuTabs.PointToScreen(menuPoint)); } break; case ApplicationMode.Settings: { menuTabs.Freeze(); settingsMenu.Show(menuTabs.PointToScreen(menuPoint)); } break; case ApplicationMode.Tour1: case ApplicationMode.Tour2: case ApplicationMode.Tour3: case ApplicationMode.Tour4: case ApplicationMode.Tour5: default: break; } }
public void GetApplicationMode_single_arg(string arg, ApplicationMode mode) { Router.GetApplicationMode(new[] { arg }).Should().Be(mode); }
public void GetApplicationMode_two_args(string a, string b, ApplicationMode mode) { Router.GetApplicationMode(new[] { a, b }).Should().Be(mode); }
public void ShowTabMenu(ApplicationMode appMode) { hoverTabIndex = (int)appMode; Refresh(); MenuClicked.Invoke(this, appMode); }
private static int ToAppMode(ApplicationMode m) { return Convert.ToInt32(1 << Convert.ToInt32(m, CultureInfo.InvariantCulture), CultureInfo.InvariantCulture); }