private void Add() { var window = new SelectFolderWindow { Owner = this }; if (window.ShowDialog() != true) { return; } var newScanContext = new ScanContext { Root = new DirectoryInfo(window.SelectedFolder) }; var folderSizeControl = new FolderSizeControl { DataContext = newScanContext, RequestClose = Remove }; var tabItem = new TabItem { Content = folderSizeControl, Header = newScanContext.Root.Name, ToolTip = newScanContext.Root.FullName, DataContext = newScanContext }; _tabControl.Items.Insert(0, tabItem); _scanContexts.Add(newScanContext); _tabControl.SelectedItem = tabItem; }
public virtual IScanContext CreateContext() { var context = new ScanContext(this); var handler = ContextCreated; handler?.Invoke(context); return(context); }
public TokenTableEntry(ScanContext inputContext, ScanContext outputContext, string pattern, TokenColor color, TokenTriggers triggers) { this.inputContext = inputContext; this.outputContext = outputContext; this.regExpression = new Regex(/*"\\G" + */ pattern); // \G = "anchor to the current position" this.tokenColor = color; this.tokenTriggers = triggers; }
private void TakePicture() { //cameraParameters.pixelFormat = showPicture == true ? CapturePixelFormat.BGRA32 : CapturePixelFormat.JPEG; scanContext = new ScanContext(horizontalAngle, ratio, Camera.main.transform); // create a context with Camera position. placeScanner(scanContext.origin); ScannerScreen.GetComponent <MoveLine>().startScanAnimation(); StartCoroutine(TakePictureInternal()); }
//private Dictionary<System.Guid, ScanContext> scanContextMap = new Dictionary<System.Guid, ScanContext>(); // we may use a dictionary to store many scans waiting for results ... let's start with one for now // Use this for initialization void Start() { angleRadian = horizontalAngle * (Math.PI / 180); gaze = CoreServices.InputSystem.GazeProvider; cursor?.SetActive(false);//disable cursor shutterSound = GetComponent <AudioSource>() as AudioSource; labeler = GetComponent <ObjectLabeler>() as ObjectLabeler; mqttHelper = GetComponent <MqttHelper>() as MqttHelper; mqttHelper.Subscribe(ResultReceiver); // Debug.Log("File path " + Application.persistentDataPath); // take lower resolution available if ((PhotoCapture.SupportedResolutions != null) && (PhotoCapture.SupportedResolutions.Count() > 0)) { cameraResolution = PhotoCapture.SupportedResolutions.OrderByDescending((res) => res.width * res.height).Last(); ratio = (float)cameraResolution.height / (float)cameraResolution.width; Debug.Log("Resolution " + cameraResolution.height + " x " + cameraResolution.width); } else { ratio = 9f / 16f; } scanContext = new ScanContext(horizontalAngle, ratio, Camera.main.transform); // create a context with Camera position. ScannerScreen.SetActive(false); // remove the scanner Vector3 scale = ScannerScreen.transform.localScale; scale.x = 2f * scannerScreenDistance * (float)Math.Tan(angleRadian / 2f); scale.y = scale.x * ratio; // scale the entire photo on height ScannerScreen.transform.localScale = scale; Debug.Log("scanContext init " + scanContext.ToString()); // Create a PhotoCapture object PhotoCapture.CreateAsync(false, delegate(PhotoCapture captureObject) { photoCaptureObject = captureObject; CameraParameters cameraParameters = new CameraParameters(); cameraParameters.hologramOpacity = 0.0f; cameraParameters.cameraResolutionWidth = cameraResolution.width; cameraParameters.cameraResolutionHeight = cameraResolution.height; cameraParameters.pixelFormat = CapturePixelFormat.BGRA32; //cameraParameters.pixelFormat = showPicture == true ? CapturePixelFormat.BGRA32 : CapturePixelFormat.JPEG; photoCaptureObject.StartPhotoModeAsync(cameraParameters, delegate(PhotoCapture.PhotoCaptureResult result) { // Take a picture Debug.Log("camera ready to take picture"); }); }); PointerUtils.SetGazePointerBehavior(PointerBehavior.AlwaysOn); }
private List <CompetitorData> ParseBasicGameDetails(HtmlNode node, DateTime date) { List <CompetitorData> game = null; try { var home = new CompetitorData(); var away = new CompetitorData(); home.Name = ParseFunctions.ExtractValueFromNode(node, "//td[@class='team team-a ']/a/.", "title"); away.Name = ParseFunctions.ExtractValueFromNode(node, "//td[@class='team team-b ']/a/.", "title"); home.Link = ParseFunctions.ExtractValueFromNode(node, "//td[@class='team team-a ']/a/.", "href"); away.Link = ParseFunctions.ExtractValueFromNode(node, "//td[@class='team team-b ']/a/.", "href"); home.Id = ParseFunctions.ParsePositiveNumber(home.Link, "/(?<num>\\d{2,})"); away.Id = ParseFunctions.ParsePositiveNumber(away.Link, "/(?<num>\\d{2,})"); var rawGameStartTime = ParseFunctions.ExtractValueFromNode(node, "//td[@class='score-time status']"); var rawScore = ParseFunctions.ExtractValueFromNode(node, "//td[@class='score-time score']"); if (!string.IsNullOrEmpty(rawGameStartTime)) { var time = ParseFunctions.ParseTime(rawGameStartTime); var gameTime = date.Date.Add(time).Subtract(DataFetcher.TimeOffset); var scanContext = new ScanContext(gameTime); home.NextScan = scanContext; away.NextScan = scanContext; } else { var gameTime = date.Date.AddHours(16); var scanContext = new ScanContext(gameTime); home.NextScan = scanContext; away.NextScan = scanContext; } game = new List <CompetitorData>() { home, away }; } catch (Exception exception) { } return(game); }
private void Remove(ScanContext scanContext) { TabItem tabItemToRemove = null; foreach (TabItem tabItem in _tabControl.Items) { if (tabItem.DataContext == scanContext) { tabItemToRemove = tabItem; break; } } _tabControl.Items.Remove(tabItemToRemove); _scanContexts.Remove(scanContext); }
public void testPickupCash() { // The Sim wants a TV -- that's worth massive Room // The Sim has a lot of cash, but hates spending it -- and doesn't have enough for a TV // The Sim could sell her daughter's painting (which she doesn't particularly like) to generate some cash (but not enough for a TV) // Conclusion: the Sim will sell the painting to get cash TheSims sims = new TheSims(); List <Task> tasks = new List <Task> { sims.BuyFridgeAt(13, 14), sims.SellArtworkAt(13, 10) }; Dictionary <Resource, double> desires = new Dictionary <Resource, double> { { TheSims.cash, 10 }, // each Simolean is worth 10 happiness to me { TheSims.fridge, 100 }, // woah i am seriously hankering for that fridge { TheSims.artwork, 7 } // hmm don't really care about that painting so much }; List <Repositioner> repositioners = new List <Repositioner> { new PythagoreanRepositioner(1, new List <Resource> { TheSims.x, TheSims.z }) }; ScanContext context = new ScanContext(tasks, desires, repositioners); Dictionary <Resource, double> startingResources = new Dictionary <Resource, double> { { TheSims.x, 13 }, { TheSims.cash, 50 } }; ScanNode result = new Scanner().Scan(context, startingResources); result.ShouldNotBeNull(); result.task.name.ShouldBe("sell artwork"); double moveCost = 0 * 1.0; // since we never actually buy the fridge double cashWin = 4 * 10.0; // this is built in to "buy ingredients" task double artworkCost = 1 * 7.0; // so long, picture result.profit.ShouldBe(cashWin - artworkCost - moveCost); }
public void testDeep() { TheSims sims = new TheSims(); List <Task> tasks = new List <Task> { sims.BakeFood(3, 0), sims.ServeDinner(9, 0), sims.BuyIngredients(-4, 0), // here's the fridge! sims.ChopIngredients(0, 0), sims.BakeFood(-4, 0) // a second oven exists }; Dictionary <Resource, double> desires = new Dictionary <Resource, double> { { TheSims.cash, 8 }, // i hate spending cash 8 times as much as i hate walking { TheSims.social, 120 } // but OMG i love being social! }; List <Repositioner> repositioners = new List <Repositioner>() { new PythagoreanRepositioner(1, new List <Resource>() { TheSims.x, TheSims.z }) }; ScanContext context = new ScanContext(tasks, desires, repositioners); Dictionary <Resource, double> startingResources = new Dictionary <Resource, double> { { TheSims.x, 0 }, { TheSims.cash, 50 } }; ScanNode result = new Scanner().Scan(context, startingResources); result.ShouldNotBeNull(); result.task.name.ShouldBe("buy ingredients"); double moveCost = (4 + 4 + 3 + 6) * 1.0; // the dude starts at x position 0 then moves from there double cashCost = 1 * 8.0; // buy ingredients costs 1 cash double socialReward = 4 * 120.0; // huge social reward for this sim result.profit.ShouldBe(socialReward - moveCost - cashCost); }
public Scanner(ScanContext scanContext) { _scanContext = scanContext ?? throw new ArgumentNullException(nameof(scanContext)); }
public TokenTableEntry(ScanContext inputContext, ScanContext outputContext, string pattern, TokenColor color) : this(inputContext, outputContext, pattern, color, TokenTriggers.None) { }