public override void LoadContent() { base.LoadContent(); dimension = this; state = STATE_BIRTH; Lights = new BlindList3D(); Lights.LoadContent(); ambientLight = new AmbientLight(); ambientLight.LoadContent(); AddLight(ambientLight); FinalImage = new RenderTarget2D(Global.device, Global.windowWidth, Global.windowHeight, false, SurfaceFormat.Color, DepthFormat.Depth24); OverlayImage = new RenderTarget2D(Global.device, Global.windowWidth, Global.windowHeight, false, SurfaceFormat.Color, DepthFormat.Depth24); TransImage = new RenderTarget2D(Global.device, Global.windowWidth, Global.windowHeight, false, SurfaceFormat.Color, DepthFormat.Depth24); Overlays = new BlindList3D(); Overlays.LoadContent(); Transparencies = new BlindList3D(); Transparencies.LoadContent(); skybox = new SkyBox(); skybox.LoadContent(); skybox.dimension = this; //OPTIONS wireFrame = false; mouseSensitivity = 0.001f; keySensitivity = 1f; gravity = -0.4f; _DebugMode = DebugModes.None; _ControlMode = ControlModes.None; _UpdateMode = UpdateModes.Normal; timeDilation = 1f; }
public void WillOnlyLogNotificationWhenAddingAnIronPythonNodeOnce() { DebugModes.LoadDebugModesStatusFromConfig(Path.Combine(GetTestDirectory(ExecutingDirectory), "DynamoCoreWpfTests", "python2ObsoleteMode.config")); // Arrange string pythonNodeName = "Python Script"; raisedEvents = new List <string>(); // Act // open file this.ViewModel.Model.Logger.NotificationLogged += Logger_NotificationLogged; var nodesCountBeforeNodeAdded = this.ViewModel.CurrentSpace.Nodes.Count(); this.ViewModel.ExecuteCommand(new DynamoModel. CreateNodeCommand(Guid.NewGuid().ToString(), pythonNodeName, 0, 0, false, false)); this.ViewModel.ExecuteCommand(new DynamoModel. CreateNodeCommand(Guid.NewGuid().ToString(), pythonNodeName, 0, 0, false, false)); DispatcherUtil.DoEvents(); var nodesCountAfterNodeAdded = this.ViewModel.CurrentSpace.Nodes.Count(); // Assert Assert.AreEqual(nodesCountBeforeNodeAdded + 2, nodesCountAfterNodeAdded); Assert.AreEqual(raisedEvents.Count, 1); Assert.IsTrue(raisedEvents.Any(x => x.Contains(nameof(PythonMigrationViewExtension)))); raisedEvents.Clear(); this.ViewModel.Model.Logger.NotificationLogged -= Logger_NotificationLogged; DispatcherUtil.DoEvents(); }
public void TestLoadNoDebugModes() { string configPath = Path.Combine(TestDirectory, "testDebugModes", "noDebugModes.config"); XmlDocument xml = new XmlDocument(); xml.Load(configPath); var debugItems = xml.DocumentElement.SelectNodes("DebugMode"); Assert.IsEmpty(debugItems); Type dbgModesType = typeof(DebugModes); var testDebugModeNames = new List <string>() { "test5", "test6" }; // Register the test debug modes. MethodInfo addDebugMode = dbgModesType.GetMethod("AddDebugMode", BindingFlags.Static | BindingFlags.NonPublic); foreach (var dbgModeName in testDebugModeNames) { addDebugMode.Invoke(null, new object[] { dbgModeName, dbgModeName }); } // Load the enabled/disabled status from the test config file. dbgModesType.GetMethod("LoadDebugModesStatusFromConfig", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, new object[] { configPath }); foreach (var dbgModeName in testDebugModeNames) { Assert.IsNotNull(DebugModes.GetDebugMode(dbgModeName)); Assert.AreEqual(DebugModes.IsEnabled(dbgModeName), false); } }
public void TestMissingConfig() { Type dbgModesType = typeof(DebugModes); var testDebugModeNames = new List <string>() { "test7", "test8" }; // Register the test debug modes. MethodInfo addDebugMode = dbgModesType.GetMethod("AddDebugMode", BindingFlags.Static | BindingFlags.NonPublic); foreach (var dbgModeName in testDebugModeNames) { addDebugMode.Invoke(null, new object[] { dbgModeName, dbgModeName }); } // Load the enabled/disabled status from the test config file. string configPath = Path.Combine(TestDirectory, "testDebugModes", "missing.config"); dbgModesType.GetMethod("LoadDebugModesStatusFromConfig", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, new object[] { configPath }); foreach (var dbgModeName in testDebugModeNames) { Assert.IsNotNull(DebugModes.GetDebugMode(dbgModeName)); Assert.AreEqual(DebugModes.IsEnabled(dbgModeName), false); } }
public void TestLoadNoDebugModes() { string configPath = Path.Combine(TestDirectory, "testDebugModes", "noDebugModes.config"); XmlDocument xml = new XmlDocument(); xml.Load(configPath); var debugItems = xml.DocumentElement.SelectNodes("DebugMode"); Assert.IsEmpty(debugItems); var testDebugModeNames = new List <string>() { "test5", "test6" }; // Register the test debug modes. foreach (var dbgModeName in testDebugModeNames) { DebugModes.AddDebugMode(dbgModeName, dbgModeName); } // Load the enabled/disabled status from the test config file. DebugModes.LoadDebugModesStatusFromConfig(configPath); foreach (var dbgModeName in testDebugModeNames) { Assert.IsNotNull(DebugModes.GetDebugMode(dbgModeName)); Assert.AreEqual(DebugModes.IsEnabled(dbgModeName), false); } }
public void TestMissingConfig() { Type dbgModesType = typeof(DebugModes); var testDebugModeNames = new List <string>() { "test7", "test8" }; // Register the test debug modes. foreach (var dbgModeName in testDebugModeNames) { DebugModes.AddDebugMode(dbgModeName, dbgModeName); } // Load the enabled/disabled status from the test config file. string configPath = Path.Combine(TestDirectory, "testDebugModes", "missing.config"); DebugModes.LoadDebugModesStatusFromConfig(configPath); foreach (var dbgModeName in testDebugModeNames) { Assert.IsNotNull(DebugModes.GetDebugMode(dbgModeName)); Assert.AreEqual(DebugModes.IsEnabled(dbgModeName), false); } }
public async Task <string> PushDebugData(DebugModes oDebugType) { try { string debugrmsg = string.Empty; using (var client = new HttpClient()) { client.BaseAddress = new Uri(baseURL); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); // HTTP POST HttpResponseMessage response = await client.PostAsJsonAsync("api/opendental/debuglog", oDebugType); if (response.IsSuccessStatusCode) { debugrmsg = await response.Content.ReadAsAsync <string>(); } else { debugrmsg = "Failed"; } } return(debugrmsg); } catch (Exception ex) { Library.WriteErrorLog("Error in Push Debug Data -- " + ex); return("Failed"); } }
public void CanOpenDocumentationBrowserWhenMoreInformationIsClicked() { DebugModes.LoadDebugModesStatusFromConfig(Path.Combine(GetTestDirectory(ExecutingDirectory), "DynamoCoreWpfTests", "python2ObsoleteMode.config")); DynamoModel.IsTestMode = false; // Act // open file var examplePath = Path.Combine(UnitTestBase.TestDirectory, @"core\python", "python.dyn"); Open(examplePath); DispatcherUtil.DoEvents(); var ironPythonDialog = this.View.GetChildrenWindowsOfType <IronPythonInfoDialog>().First(); var viewExtensionTabsBeforeBtnClick = this.View.ExtensionTabItems.Count; DispatcherUtil.DoEvents(); ironPythonDialog.MoreInformationBtn.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); var hasDocumentationBrowserTab = this.View.ExtensionTabItems .Any(x => x.Header.ToString() == "Documentation Browser"); DispatcherUtil.DoEvents(); // Assert Assert.AreEqual(viewExtensionTabsBeforeBtnClick + 1, this.View.ExtensionTabItems.Count); Assert.IsTrue(hasDocumentationBrowserTab); DynamoModel.IsTestMode = true; DispatcherUtil.DoEvents(); }
private void OnOkClick(object sender, RoutedEventArgs e) { foreach (DebugModeListItem item in CheckList.Items) { DebugModes.SetDebugModeEnabled(item.Name, item.Enabled); } Close(); }
internal void UnmarkForUninstall(IPreferences prefs) { MarkedForUninstall = false; if (DebugModes.IsEnabled("DynamoPackageStates")) { // Should this be a "Loaded state" or something else ? // Or maybe state should only be set when trying to Load the package...not here. PackageState = PackageStates.Loaded; } prefs.PackageDirectoriesToUninstall.RemoveAll(x => x.Equals(RootDirectory)); }
internal void MarkForUninstall(IPreferences prefs) { MarkedForUninstall = true; if (DebugModes.IsEnabled("DynamoPackageStates")) { PackageState = PackageStates.PendingUnload; } if (!prefs.PackageDirectoriesToUninstall.Contains(RootDirectory)) { prefs.PackageDirectoriesToUninstall.Add(RootDirectory); } }
public void TestLoadDebugModes() { string configPath = Path.Combine(TestDirectory, "testDebugModes", "debugModes.config"); XmlDocument xml = new XmlDocument(); xml.Load(configPath); var debugItems = xml.DocumentElement.SelectNodes("DebugMode"); var testDebugModes = new Dictionary <string, bool>(); foreach (XmlNode item in debugItems) { testDebugModes[item.Attributes["name"].Value] = bool.Parse(item.Attributes["enabled"].Value); } Type dbgModesType = typeof(DebugModes); // Register the test debug modes. MethodInfo addDebugMode = dbgModesType.GetMethod("AddDebugMode", BindingFlags.Static | BindingFlags.NonPublic); foreach (var dbgModeName in testDebugModes) { addDebugMode.Invoke(null, new object[] { dbgModeName.Key, dbgModeName.Key }); } // Load the enabled/disabled status from the test config file. dbgModesType.GetMethod("LoadDebugModesStatusFromConfig", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, new object[] { configPath }); foreach (var item in testDebugModes) { var dbgMode = DebugModes.GetDebugMode(item.Key); Assert.IsNotNull(dbgMode); Assert.AreEqual(dbgMode.IsEnabled, item.Value); } var forceEnabled = false; foreach (var item in testDebugModes) { DebugModes.SetDebugModeEnabled(item.Key, forceEnabled); } foreach (var item in testDebugModes) { Assert.AreEqual(DebugModes.IsEnabled(item.Key), forceEnabled); } }
/// <summary> /// Constructor /// </summary> public DebugModesWindow() { InitializeComponent(); var items = new List <DebugModeListItem>(); foreach (var entry in DebugModes.GetDebugModes()) { items.Add(new DebugModeListItem() { Name = entry.Value.Name, Enabled = entry.Value.IsEnabled }); } CheckList.ItemsSource = items; }
internal void MarkForUninstall(IPreferences prefs) { MarkedForUninstall = true; if (DebugModes.IsEnabled("DynamoPackageStates")) { PackageState = PackageStates.PendingUnload; } else { RaisePropertyChanged(nameof(EnableOldMarkedForUnistallState)); } if (!prefs.PackageDirectoriesToUninstall.Contains(RootDirectory)) { prefs.PackageDirectoriesToUninstall.Add(RootDirectory); } }
public void WillDisplayDialogWhenOpeningGraphWithIronPythonNodes() { DebugModes.LoadDebugModesStatusFromConfig(Path.Combine(GetTestDirectory(ExecutingDirectory), "DynamoCoreWpfTests", "python2ObsoleteMode.config")); DynamoModel.IsTestMode = false; // Act // open file Open(@"core\python\python.dyn"); var isIronPythonDialogOpen = this.View.OwnedWindows .Cast <Window>() .Any(x => x.GetType() == typeof(IronPythonInfoDialog)); // Assert Assert.IsTrue(isIronPythonDialogOpen); DynamoModel.IsTestMode = true; DispatcherUtil.DoEvents(); }
public void TestLoadDebugModes() { string configPath = Path.Combine(TestDirectory, "testDebugModes", "debugModes.config"); XmlDocument xml = new XmlDocument(); xml.Load(configPath); var debugItems = xml.DocumentElement.SelectNodes("DebugMode"); var testDebugModes = new Dictionary <string, bool>(); foreach (XmlNode item in debugItems) { testDebugModes[item.Attributes["name"].Value] = bool.Parse(item.Attributes["enabled"].Value); } // Register the test debug modes. foreach (var dbgModeName in testDebugModes) { DebugModes.AddDebugMode(dbgModeName.Key, dbgModeName.Key); } // Load the enabled/disabled status from the test config file. DebugModes.LoadDebugModesStatusFromConfig(configPath); foreach (var item in testDebugModes) { var dbgMode = DebugModes.GetDebugMode(item.Key); Assert.IsNotNull(dbgMode); Assert.AreEqual(dbgMode.IsEnabled, item.Value); } var forceEnabled = false; foreach (var item in testDebugModes) { DebugModes.SetDebugModeEnabled(item.Key, forceEnabled); } foreach (var item in testDebugModes) { Assert.AreEqual(DebugModes.IsEnabled(item.Key), forceEnabled); } }
public void DefaultConstructorInstanceTest() { var config = new AutoConfigFileConfiguration(); // gets .config file, AutoConfigFileConfiguration section config.Initialize(sectionName: "MyAdminConfiguration"); string appName = config.ApplicationName; DebugModes mode = config.DebugMode; int maxItems = config.MaxDisplayListItems; Assert.IsNotNull(config); Assert.IsFalse(string.IsNullOrEmpty(config.ApplicationName)); Assert.AreEqual(config.MaxDisplayListItems, 15); string text = File.ReadAllText(TestHelpers.GetTestConfigFilePath()); Console.WriteLine(text); }
public void WillNotLogNotificationWhenAddingNodeWhenPython2ObsoleteFlagIsOff() { var debugMode = DebugModes.GetDebugMode("Python2ObsoleteMode"); bool shouldReenable = false; if (debugMode != null && debugMode.IsEnabled) { debugMode.IsEnabled = false; shouldReenable = true; } // Arrange string pythonNodeName = "Python Script"; raisedEvents = new List <string>(); // Act // open file this.ViewModel.Model.Logger.NotificationLogged += Logger_NotificationLogged; var nodesCountBeforeNodeAdded = this.ViewModel.CurrentSpace.Nodes.Count(); this.ViewModel.ExecuteCommand(new DynamoModel. CreateNodeCommand(Guid.NewGuid().ToString(), pythonNodeName, 0, 0, false, false)); DispatcherUtil.DoEvents(); var nodesCountAfterNodeAdded = this.ViewModel.CurrentSpace.Nodes.Count(); // Assert Assert.AreEqual(nodesCountBeforeNodeAdded + 1, nodesCountAfterNodeAdded); Assert.AreEqual(raisedEvents.Count, 0); raisedEvents.Clear(); this.ViewModel.Model.Logger.NotificationLogged -= Logger_NotificationLogged; DispatcherUtil.DoEvents(); if (shouldReenable) { debugMode.IsEnabled = true; } }
public void WillDisplayDialogWhenCustomNodeInsideWorkspaceHasIronPythonNode() { DebugModes.LoadDebugModesStatusFromConfig(Path.Combine(GetTestDirectory(ExecutingDirectory), "DynamoCoreWpfTests", "python2ObsoleteMode.config")); DynamoModel.IsTestMode = false; // open file var examplePath = Path.Combine(UnitTestBase.TestDirectory, @"core\python", "PythonCustomNodeHomeWorkspace.dyn"); Open(examplePath); DispatcherUtil.DoEvents(); var ironPythonDialog = this.View.GetChildrenWindowsOfType <IronPythonInfoDialog>().First(); // Assert that the IronPython dialog is shown. Assert.IsNotNull(ironPythonDialog); Assert.IsTrue(ironPythonDialog.IsLoaded); DynamoModel.IsTestMode = true; DispatcherUtil.DoEvents(); }
private void OnDebugModeItemClick(object sender, RoutedEventArgs e) { var listItem = (System.Windows.Controls.ListBoxItem)sender; if (null == listItem) { throw new InvalidOperationException("Invalid Control type found. Expected ListBoxItem"); } var dataContext = (DebugModeListItem)listItem.DataContext; if (null == dataContext) { throw new InvalidOperationException("Invalid data context type found. Expected DebugModeItem"); } var debugMode = DebugModes.GetDebugMode(dataContext.Name); if (null == debugMode) { throw new InvalidOperationException("Invalid debug mode found"); } SelectedDbgMode.Text = debugMode.Description; }
public void WillNotDisplayIronPythonDialogAgainWhenDoNotShowAgainSettingIsChecked() { DebugModes.LoadDebugModesStatusFromConfig(Path.Combine(GetTestDirectory(ExecutingDirectory), "DynamoCoreWpfTests", "python2ObsoleteMode.config")); DynamoModel.IsTestMode = false; // Arrange var examplePathIronPython = Path.Combine(UnitTestBase.TestDirectory, @"core\python", "python.dyn"); //Disable iron python alerts ViewModel.IsIronPythonDialogDisabled = true; // Act // open file Open(examplePathIronPython); DispatcherUtil.DoEvents(); var ironPythonDialog = this.View.GetChildrenWindowsOfType <IronPythonInfoDialog>(); Assert.IsEmpty(ironPythonDialog); Assert.AreEqual(0, ironPythonDialog.Count()); DynamoModel.IsTestMode = true; DispatcherUtil.DoEvents(); }
public void WillNotDisplayDialogWhenOpeningGraphWithIronPythonNodesSecondTimeInSameSession() { DebugModes.LoadDebugModesStatusFromConfig(Path.Combine(GetTestDirectory(ExecutingDirectory), "DynamoCoreWpfTests", "python2ObsoleteMode.config")); DynamoModel.IsTestMode = false; // Arrange var examplePathIronPython = Path.Combine(UnitTestBase.TestDirectory, @"core\python", "python.dyn"); var examplePathEmptyFile = Path.Combine(UnitTestBase.TestDirectory, @"core\Home.dyn"); // Act // open file Open(examplePathIronPython); var ironPythonWorkspaceId = this.ViewModel.CurrentSpace.Guid; DispatcherUtil.DoEvents(); var ironPythonDialog = this.View.GetChildrenWindowsOfType <IronPythonInfoDialog>().First(); Assert.IsNotNull(ironPythonDialog); Assert.IsTrue(ironPythonDialog.IsLoaded); ironPythonDialog.OkBtn.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); DispatcherUtil.DoEvents(); // Open empty file before open the the IronPython file again Open(examplePathEmptyFile); Assert.AreNotEqual(ironPythonWorkspaceId, this.ViewModel.CurrentSpace.Guid); DispatcherUtil.DoEvents(); Open(examplePathIronPython); Assert.AreEqual(ironPythonWorkspaceId, this.ViewModel.CurrentSpace.Guid); var secondGraphIronPythonDialog = this.View.GetChildrenWindowsOfType <IronPythonInfoDialog>(); DispatcherUtil.DoEvents(); // Assert Assert.AreEqual(0, secondGraphIronPythonDialog.Count()); DynamoModel.IsTestMode = true; DispatcherUtil.DoEvents(); }
/// <summary> /// Check Dynamo package install state /// </summary> /// <param name="packageDownloadHandle">package download handle</param> /// <param name="downloadPath">package download path</param> internal void SetPackageState(PackageDownloadHandle packageDownloadHandle, string downloadPath) { Package dynPkg; if (packageDownloadHandle.Extract(DynamoViewModel.Model, downloadPath, out dynPkg)) { PackageManagerExtension.PackageLoader.LoadPackages(new List <Package> { dynPkg }); packageDownloadHandle.DownloadState = PackageDownloadHandle.State.Installed; if (DebugModes.IsEnabled("DynamoPackageStates")) { // Temporary location for setting the package state. // Should be moved somewhere with more visibility into possible errors. dynPkg.PackageState = Package.PackageStates.Loaded; } } else { packageDownloadHandle.DownloadState = PackageDownloadHandle.State.Error; packageDownloadHandle.Error(Resources.MessageInvalidPackage); } }
public void VerifyDynamoLoadingOnOpeningWorkspaceWithMissingCustomNodes() { List <string> dependenciesList = new List <string>() { "MeshToolkit", "Clockwork for Dynamo 1.x", "Clockwork for Dynamo 2.x", "Dynamo Samples" }; DebugModes.LoadDebugModesStatusFromConfig(Path.Combine(GetTestDirectory(ExecutingDirectory), "DynamoCoreWpfTests", "python2ObsoleteMode.config")); DynamoModel.IsTestMode = false; var examplePath = Path.Combine(@"core\packageDependencyTests\PackageDependencyStates.dyn"); Open(examplePath); Assert.AreEqual(1, View.ExtensionTabItems.Count); var workspaceViewExtension = (WorkspaceDependencyViewExtension)View.viewExtensionManager.ViewExtensions .Where(x => x.Name.Equals("Workspace References")).FirstOrDefault(); foreach (PackageDependencyRow packageDependencyRow in workspaceViewExtension.DependencyView.dataRows) { var dependencyInfo = packageDependencyRow.DependencyInfo; Assert.Contains(dependencyInfo.Name, dependenciesList); } }
/// <summary> /// Sets the debugger mode. /// </summary> public virtual void SetDebugMode(DebugModes mode) { this.DebugMode = mode; }
/// <summary> /// Sets the debugger mode. /// </summary> /// <param name="mode">Debugger mode to set.</param> public override void SetDebugMode(DebugModes mode) { _wrappedDebugger.SetDebugMode(mode); base.SetDebugMode(mode); }
/// <summary> /// SetDebugMode /// </summary> /// <param name="mode"></param> public override void SetDebugMode(DebugModes mode) { _wrappedDebugger.Value.SetDebugMode(mode); base.SetDebugMode(mode); }
/// <summary> /// SetDebugMode /// </summary> /// <param name="mode"></param> public override void SetDebugMode(DebugModes mode) { CheckForValidateState(); // Only set debug mode on server if no commands are currently // running on remote runspace. if ((_runspace.GetCurrentlyRunningPipeline() != null) || (_runspace.RemoteCommand != null)) { return; } using (PowerShell ps = GetNestedPowerShell()) { ps.SetIsNested(false); ps.AddCommand(DebuggerUtils.SetDebugModeFunctionName).AddParameter("Mode", mode); ps.Invoke(); } base.SetDebugMode(mode); SetIsActive(_breakpointCount); }
/// <summary> /// Sets client debug info state based on server info. /// </summary> /// <param name="debugMode">Debug mode</param> /// <param name="inBreakpoint">Currently in breakpoint</param> /// <param name="breakpointCount">Breakpoint count</param> /// <param name="breakAll">Break All setting</param> /// <param name="unhandledBreakpointMode">UnhandledBreakpointMode</param> /// <param name="serverPSVersion">Server PowerShell version</param> internal void SetClientDebugInfo( DebugModes? debugMode, bool inBreakpoint, int breakpointCount, bool breakAll, UnhandledBreakpointProcessingMode unhandledBreakpointMode, Version serverPSVersion) { if (debugMode != null) { _remoteDebugSupported = true; DebugMode = debugMode.Value; } else { _remoteDebugSupported = false; } if (inBreakpoint) { SetRemoteDebug(true, RunspaceAvailability.RemoteDebug); } _serverPSVersion = serverPSVersion; _breakpointCount = breakpointCount; _isDebuggerSteppingEnabled = breakAll; _unhandledBreakpointMode = unhandledBreakpointMode; SetIsActive(breakpointCount); }
/// <summary> /// Prevents a default instance of the <see cref="CLAutoThumbnailer"/> class from being created. /// </summary> /// <param name="args">Command line arguments.</param> /// <param name="baseDir">If created via command file the directory of the command file, /// otherwise <c>null</c>.</param> /// <exception cref="NDesk.Options.OptionException">Thrown when option error occurs.</exception> CLAutoThumbnailer(string[] args, string baseDir) { InitializeThumbnailSettings (); InitializeVideoRE (); System.Collections.Specialized.StringCollection fixedArgs = new System.Collections.Specialized.StringCollection (); foreach (string arg in args) { if (arg.EndsWith("\"")) { fixedArgs.Add(arg.Remove(arg.Length-1)); } else fixedArgs.Add(arg); } String[] fixedArgsArray = new String[fixedArgs.Count]; fixedArgs.CopyTo(fixedArgsArray, 0); double doubleInterval = -1; _oset = new NDesk.Options.OptionSet () { { "d|directory=", "{DIRECTORY} to process. Generate thumbnails for\n" + "files with the following extensions:\n" + _videoExtensions, v => _directoryArg = v }, { "exts=", "add/remove video {EXTENSIONS} " + "(\"[+]ext1, -ext2\")", v => { string[] exts = _commaRE.Split(v); foreach (string ext in exts) { string s = ext.Trim().ToLower(); bool addExt = true; if (s[0] == '-') { s = s.Substring(1); addExt = false; } else if (s[0] == '+') { s = s.Substring (1); } if (addExt) { if (_videoExts.Contains (s)) THelper.Error ("Error: '{0}' is already in valid video extensions list.", s); else { THelper.Information ("'{0}' added to valid video extensions list.", s); _videoExts.Add (s); _videoExtsChanged = true; } } else { if (!_videoExts.Contains (s)) THelper.Error ("Error: '{0}' isn't in valid video extensions list.", s); else { THelper.Information ("'{0}' removed from valid video extensions list.", s); _videoExts.Remove (s); _videoExtsChanged = true; } } } if (_videoExtsChanged) { System.Collections.ArrayList temp = System.Collections.ArrayList.Adapter(_videoExts); temp.Sort (); _videoExts = new System.Collections.Specialized.StringCollection (); _videoExts.AddRange ((String[]) temp.ToArray(typeof(string))); } } }, { "minsize=", String.Format("Minimum {{FILESIZE}} of video files (0 to disable) [{0} ({1})]", _minFileSize, ThumbnailCreator.GetFileSizeString(_minFileSize)), (long v) => { if (v < 0) v = 0; _minFileSize = v; } }, { "m|cmddir=", "create initial command file for {DIRECTORY}", v => _cmdDirectory = v }, { "s|start=", String.Format(@"start {{TIME}} in h:mm:ss [{0}]", _tnSettings.Start.ToString(@"h\:mm\:ss")), (TimeSpan v) => _tnSettings.Start = v }, { "e|end=", String.Format(@"end {{TIME}} in h:mm:ss [{0}{1}]", _tnSettings.End.TotalSeconds < 0 ? "-" : "", _tnSettings.End.ToString(@"h\:mm\:ss")), (TimeSpan v) => _tnSettings.End = v }, { "v|overview", String.Format("create Overview page (-v- disables) [{0}]", _createOverview), v => _createOverview = v != null }, { "n=", String.Format("Overview page desired # of {{ROWS or COLUMNS}} [{0}]", _tnSettings.OverviewThumbs), (int v) => { if (v < 1) v = 1; _tnSettings.OverviewThumbs = v; } }, { "c|columns=", String.Format("Overview page actual # of {{COLUMNS}} [{0}]", _tnSettings.OverviewColumns), (int v) => { if (v < 1) v = 1; _tnSettings.OverviewColumns = v; } }, { "r|rows=", String.Format("Overview page actual # of {{ROWS}} [{0}]", _tnSettings.OverviewRows), (int v) => { if (v < 1) v = 1; _tnSettings.OverviewRows = v; } }, { "i|interval=", String.Format("Detail page thumbnail interval {{SECONDS}} [{0:F2}]", _tnSettings.Interval.TotalSeconds), (double v) => { if (v != 0.0 && v < 1.0 / 30.0) v = 1.0 / 30.0; doubleInterval = v; } }, { "autointerval", String.Format("use automatic interval based on duration [{0}]", _autoInterval), v => _autoInterval = v != null }, { "autointervals=", String.Format("automatic interval {{SPECIFICATION}}\n" + "( <min1=secs1, <min2=secs2, <min3=secs3, secs4 )\n" + "[ {0} ]", _intervalsStr), v => { _intervalsStr = v; InitializeAutoIntervals (_intervalsStr); } }, { "N=", String.Format("Detail page desired # of {{ROWS or COLUMNS}} [{0}]", _tnSettings.DetailThumbs), (int v) => { if (v < 1) v = 1; _tnSettings.DetailThumbs = v; } }, { "C|Columns=", String.Format("Detail page actual # of {{COLUMNS}} [{0}]", _tnSettings.DetailColumns), (int v) => { if (v < 1) v = 1; _tnSettings.DetailColumns = v; } }, { "R|Rows=", String.Format("Detail page actual # of {{ROWS}} [{0}]", _tnSettings.DetailRows), (int v) => { if (v < 1) v = 1; _tnSettings.DetailRows = v; } }, { "dfts", String.Format("add Detail page filename timestamps\n" + "(--dfts- disables) [{0}]", _tnSettings.DetailFileTimestamps), v => _tnSettings.DetailFileTimestamps = v != null }, { "y|layout=", String.Format("layout {{MODE}}\n(0=Auto,1=Actual,2=Row Priority,3=Column Priority) [{0}]", _tnSettings.LayoutMode), (int v) => { if (v < 0 || v > 3) v = 0; _tnSettings.LayoutMode = (ThumbnailSettings.LayoutModes) v; } }, { "othres=", String.Format("video aspect ratio {{THRESHOLD}} for\n" + "Auto Layout of Overview Page [{0:F2}]", _tnSettings.OverviewThreshold), (double v) => { if (v != 0.0 && v < 0.2) v = 0.2; if (v > 4.0) v = 4.0; _tnSettings.OverviewThreshold = v; } }, { "dthres=", String.Format("video aspect ratio {{THRESHOLD}} for\n" + "Auto Layout of Detail Pages [{0:F2}]", _tnSettings.DetailThreshold), (double v) => { if (v != 0.0 && v < 0.2) if (v < 0.2) v = 0.2; if (v > 4.0) v = 4.0; _tnSettings.DetailThreshold = v; } }, { "rcopt", String.Format("do row/column optimizations\n" + "(--rcopt- disables) [{0}]", _tnSettings.RCOptimization), v => _tnSettings.RCOptimization = v != null }, { "maxoptsteps=", String.Format("max # of row/column optimization {{STEPS}}\n" + "(0=unlimited) [{0}]", _tnSettings.MaxOptimizationSteps), (int v) => { if (v < 0) v = 0; _tnSettings.MaxOptimizationSteps = v; } }, { "wthres=", String.Format("width {{THRESHOLD}} for adding columns (0.1 - 1.0) [{0:F2}]", _tnSettings.WidthThreshold), (double v) => { if (v < 0.1) v = 0.1; if (v > 1.0) v = 1.0; _tnSettings.WidthThreshold = v; } }, { "hthres=", String.Format("height {{THRESHOLD}} for adding rows (0.1 - 1.0)\n[{0:F2}]", _tnSettings.HeightThreshold), (double v) => { if (v < 0.1) v = 0.1; if (v > 1.0) v = 1.0; _tnSettings.HeightThreshold = v; } }, { "mincols=", String.Format("minimum # of {{COLUMNS}} [{0}]", _tnSettings.MinColumns), (int v) => { if (v < 1) v = 1; _tnSettings.MinColumns = v; } }, { "minrows=", String.Format("minimum # of {{ROWS}} [{0}]", _tnSettings.MinRows), (int v) => { if (v < 1) v = 1; _tnSettings.MinRows = v; } }, { "p|crop=", "crop {ASPECT RATIO}", (double v) => { if (v < 0.2) v = 0.2; if (v > 4.0) v = 4.0; _cropAspect = v; } }, { "rect=", "source {RECTANGLE} ( X,Y+WxH )", v => { System.Text.RegularExpressions.Match m = _rectRE.Match (v); if (!m.Success) throw new NDesk.Options.OptionException ( "Need to specify X,Y+WxH for --rect option.", "--rect"); _srcRect = new System.Drawing.Rectangle (Int32.Parse (m.Groups["x"].Value), Int32.Parse (m.Groups["y"].Value), Int32.Parse (m.Groups["w"].Value), Int32.Parse (m.Groups["h"].Value)); } }, { "t|stretch=", "stretch {ASPECT RATIO}", (double v) => { if (v < 0.2) v = 0.2; if (v > 4.0) v = 4.0; _stretchAspect = v; } }, { "aar", String.Format("do auto aspect ratio adjustment\n" + "(--aar- disables) [{0}]", _autoAspectRatio), v => _autoAspectRatio = v != null }, { "o|outdir=", "Output {DIRECTORY}", v => _outputDirectory = v }, { "subdir=", String.Format("Output sub-directory {{NAME}} [\"{0}\"]", _tnSettings.SubDirectory), v => { if (v=="" || !_subdirRE.IsMatch(v)) throw new NDesk.Options.OptionException ( "Subdirectory name can only contain alphanumerics, '_', and '-'.", "--subdir"); _tnSettings.SubDirectory = v; } }, { "name=", "Display {NAME}", v => _displayFilename = v }, { "l|label=", String.Format("timestamp label {{POSITION}}\n(0=Off,1=LR,2=LL,3=UR,4=UL) [{0}]", _tnSettings.LabelPosition), (int v) => { if (v < 0 || v > 4) v = 1; _tnSettings.LabelPosition = (ThumbnailSettings.LabelPositions) v; } }, { "ms", String.Format("show non-zero millisecond display in timestamps [{0}]", _tnSettings.AlwaysShowMilliseconds), v => _tnSettings.AlwaysShowMilliseconds = v != null }, { "f|scalefactor=", String.Format("page {{SCALE FACTOR}} [{0:F2}]", _tnSettings.ScaleFactor), (double v) => { if (v < 0.25) v = 0.25; if (v > 3.0) v = 3.0; _tnSettings.ScaleFactor = v; } }, { "w|width=", String.Format("page width {{PIXELS}} [{0}]", _tnSettings.Width), (int v) => { if (v < 100) v = 100; _tnSettings.Width = v; } }, { "h|height=", String.Format("page height {{PIXELS}} [{0}]", _tnSettings.Height), (int v) => { if (v < 100) v = 100; _tnSettings.Height = v; } }, { "margin=", String.Format("margin between thumbnails {{PIXELS}} [{0}]", _tnSettings.Margin), (int v) => { if (v < 0) v = 0; _tnSettings.Margin = v; } }, { "border=", String.Format("thumbnail border width {{PIXELS}} [{0}]", _tnSettings.Border), (int v) => { if (v < 0) v = 0; _tnSettings.Border = v; } }, { "save", "save current settings as defaults", v => _saveSettings = v != null }, { "reset", "reset settings to initial defaults", v => _resetSettings = v != null }, { "dumpcr:", "dump # columns/rows diagnostic plot to {FILE}", v => { _dumpCRs = true; if (v != null) { _dumpFilename = v; if (_dumpFilename.Contains ("|")) { string[] parts = _dumpFilename.Split (new char[] { '|' }, 2); _dumpFilename = parts[1]; string flag = parts[0].Trim ().ToLower (); if (flag.StartsWith ("nothr")) _dumpThresholds = false; } } } }, { "debug:", String.Format("show debugging information"), v => { if (v == null) _debug = DebugModes.ShowDebuggingMessages; else { int debug = Int32.Parse (v); if (debug < 0) { debug = -debug; THelper.SetLoggerLevel("mainlogger", System.Diagnostics.SourceLevels.Information); } else { THelper.SetConsoleLevel (System.Diagnostics.SourceLevels.Verbose); } _debug = (DebugModes) debug; } } }, { "?|help", "show this message and exit", v => _show_help = v != null }, { "version", "show version and exit", v => _show_version = v != null }, #if false { "x|maxmulti=", "max # of multi-page {ROWS}", (int v) => _tnSettings.MaxMultiRows = v }, { "n|minoverview=", "minimum # of overview {ROWS}", (int v) => _tnSettings.MinOverviewRows = v }, NDesk.Options.Option rectOption = _oset.Add( ); #endif }; List<string> extra; extra = _oset.Parse (fixedArgsArray); if (_show_help && baseDir != null) { ShowHelp (_oset); return; } if (_debug == DebugModes.ShowDebuggingMessages && baseDir != null) { THelper.Information ("Displaying debugging information."); } if (extra.Count > 0) { _filename = extra[0]; } if (_filename != null) { if (baseDir != null) { if (!System.IO.Path.IsPathRooted (_filename)) _filename = System.IO.Path.Combine (baseDir, _filename); } _fileList = CreateFileList (_filename); if (_fileList == null) { THelper.Critical ("\"" + _filename + "\" doesn't exist."); _filename = null; return; } if (_fileList.Count == 0) { THelper.Critical ("\"" + _filename + "\" doesn't match any files."); _filename = null; _fileList = null; return; } } if (_directoryArg != null) { if (baseDir != null) { if (!System.IO.Path.IsPathRooted(_directoryArg)) _directoryArg = System.IO.Path.Combine(baseDir, _directoryArg); } if (!System.IO.Directory.Exists(_directoryArg)) { _directoryArg = null; THelper.Critical ("\"" + _directoryArg + "\" doesn't exist."); return; } } if (doubleInterval != -1) { int intervalSeconds = (int) Math.Truncate (doubleInterval); int intervalMilliseconds = 0; double fractSeconds = Math.Abs (doubleInterval - (double) intervalSeconds); if (fractSeconds >= 0.001) intervalMilliseconds = (int) (1000 * fractSeconds); _tnSettings.Interval = new TimeSpan (0, 0, 0, intervalSeconds, intervalMilliseconds); } if (_tnSettings.OverviewThreshold == 0.0) _tnSettings.OverviewThreshold = _tnSettings.AspectRatio * _tnSettings.LayoutThresholdAdjustment; if (_tnSettings.DetailThreshold == 0.0) _tnSettings.DetailThreshold = _tnSettings.AspectRatio * _tnSettings.LayoutThresholdAdjustment; }
/// <summary> /// Set debug mode /// </summary> /// <param name="mode"></param> public override void SetDebugMode(DebugModes mode) { lock (_syncObject) { base.SetDebugMode(mode); if (!CanEnableDebugger) { SetInternalDebugMode(InternalDebugMode.Disabled); } else if ((_idToBreakpoint.Count > 0) && (_context._debuggingMode == 0)) { // Set internal debugger to active. SetInternalDebugMode(InternalDebugMode.Enabled); } } }