void PreloadNextVideos(int position) { for (int a = 0; a < areas.Count; a++) { DisplayArea thisArea = areas[a]; //print(thisArea.video.url); for (int c = position; c < items.Count; c++) { //print(items[c].displayArea); for (int ch = 0; ch < items[c].changes.Count; ch++) { AreaChange change = items[c].changes[ch]; if (change.displayArea == thisArea.name || (a == 0 && change.displayArea == null)) { if (change.movieName != null) { if (thisArea.preparedVid == true && change.movieName == thisArea.video.url) { break; } print("Prepare video:" + change.movieName); thisArea.video.playOnAwake = false; thisArea.video.url = change.movieName; thisArea.video.Prepare(); thisArea.preparedVid = true; break; } } } } } }
/// <summary> /// Get the 3D gaze point representation based on the normalized 2D point and the <see cref="DisplayArea"/> information. /// </summary> /// <param name="displayArea">The <see cref="DisplayArea"/> object.</param> /// <param name="point2D">The <see cref="NormalizedPoint2D"/> point.</param> /// <returns>The <see cref="Point3D"/> gaze point.</returns> public static Point3D NormalizedPoint2DToPoint3D(this DisplayArea displayArea, NormalizedPoint2D point2D) { var dx = displayArea.TopRight.Sub(displayArea.TopLeft).Mul(point2D.X); var dy = displayArea.BottomLeft.Sub(displayArea.TopLeft).Mul(point2D.Y); return(displayArea.TopLeft.Add(dx.Add(dy))); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { DisplayArea displayArea = DisplayArea.None; DisplayArea region = DisplayArea.None; if (value != null && Enum.TryParse(value.ToString(), out displayArea) && Enum.TryParse(parameter.ToString(), out region)) { switch (region) { case DisplayArea.PrimaryLeft: return(displayArea == DisplayArea.PrimaryLeft); case DisplayArea.PrimaryCenter: return(displayArea == DisplayArea.PrimaryCenter); case DisplayArea.PrimaryRight: return(displayArea == DisplayArea.PrimaryRight); case DisplayArea.SecondaryLeft: return(displayArea == DisplayArea.SecondaryLeft); case DisplayArea.SecondaryCenter: return(displayArea == DisplayArea.SecondaryCenter); case DisplayArea.SecondaryRight: return(displayArea == DisplayArea.SecondaryRight); default: return(false); } } return(false); }
public UC_CONTROLE_Documents() { InitializeComponent(); myDisplayArea = new DisplayArea(this); myMenu = new Menu(this); myMenu.changeMenuItems(); }
public async Task DisplayAsync(StorageFile file) { await DisplayArea.DisplayAsync(file); FrontEmptyArea.Visibility = Visibility.Collapsed; DisplayArea.Visibility = Visibility.Visible; }
private static void Main() { Thread.CurrentThread.Name = nameof(SimpleExampleConsoleWindow); _flairs = BuildFlairLibrary(); var header = new DisplayArea("Header", 0, 0, 5, Console.WindowWidth); var scrollingMessages = new DisplayArea("Messages", header.Bottom + 1, 0, Console.WindowHeight - (header.Bottom + 1), Console.WindowWidth) { Cycle = true }; _consoleWindow = new ConsoleWindow(new[] { header, scrollingMessages }); WriteHeader($"This is the head"); Task.Run(() => { for (var i = 0; i < 1000; i++) { WriteMessage($"Detail record {i} at {DateTime.Now.TimeOfDay}"); Thread.Sleep(100); } }); //WriteMessage($"This is any kind of message {DateTime.Now.TimeOfDay}"); WriteHeader($"Press ESC to close"); _consoleWindow.WaitForKey(ConsoleKey.Escape); _consoleWindow.Close(); }
public void Display(DataSet ds) { DisplayArea.Display(ds); FrontEmptyArea.Visibility = Visibility.Collapsed; DisplayArea.Visibility = Visibility.Visible; }
private void HandleEvent() { var isContext = Event.current.type == EventType.MouseDown && Event.current.button == 1; if (!isContext) { return; } var contextMenu = new GenericMenu(); if (DisplayArea.Contains(Event.current.mousePosition)) { var baseAdd = "Add State/{0}"; var allStates = MecanimAnimationUtility.GetAllStateNames(AnimationTimeline.AffectedObject.gameObject, AnimationTrack.Layer); var newTime = (((Event.current.mousePosition.x + XScroll - DisplayArea.x) / DisplayArea.width) * AnimationTimeline.Sequence.Duration) / XScale; foreach (var state in allStates) { contextMenu.AddItem( new GUIContent(string.Format(baseAdd, state)), false, (obj) => AddNewState(((float)((object[])obj)[0]), ((string)((object[])obj)[1])), new object[] { newTime, state } // This object is passed through to the annonymous function that is passed through as the previous argument. ); } } if (DisplayArea.Contains(Event.current.mousePosition)) { Event.current.Use(); contextMenu.ShowAsContext(); } }
private void OnMouseDragStart(object?sender, MouseEventArgs e) { if (DisplayArea.Contains(e.Position.ToVector2())) { var element = new DragAndDrop(_ability); element.Show(Root.System); } }
private void OnMouseDragStart(object?sender, MouseEventArgs e) { if (DisplayArea.Contains(e.Position.ToVector2())) { var element = new DragAndDrop(_pack.Item); element.OnSuccesfullyDrop += () => { _pack.Remove(); }; element.Show(Root.System); } }
private void WindowTextList_SelectedIndexChanged(object sender, EventArgs e) { var title = WindowTextList.SelectedItem as string; var hWnd = windows[title]; if (BmpHelper.TryGetWindow(hWnd, out Bitmap windowBmp)) { DisplayArea.PaintPicture(windowBmp); } }
private void AddLine(string s) { ColorAnimation animation = new ColorAnimation(Colors.Red, Colors.Black, new Duration(TimeSpan.FromSeconds(5))); var run = new Run(s); var paragraph = new Paragraph(run); paragraph.Foreground = new SolidColorBrush(Colors.Black); DisplayArea.Document.Blocks.Add(paragraph); paragraph.Foreground.ApplyAnimationClock(SolidColorBrush.ColorProperty, animation.CreateClock()); DisplayArea.ScrollToEnd(); }
private void DropItem(DragAndDrop element) { if (DisplayArea.Contains(element.PositionOffset) && element.Icon != _slot.Item) { try { _slot.PutOn(element.Icon as IItem); element.SuccesfullyDrop(); } catch (ArgumentException e) { } } }
private void OpenSerial() { try { serial.Open(); PortControlBtn.Text = "关闭"; Text = "串口通讯器 - " + PortSelect.Text; } catch { PortControlBtn.Text = "开启"; DisplayArea.AppendText("串口打开未成功!" + Environment.NewLine); Text = "串口通讯器 - 已关闭"; } }
private void SendBtn_Click(object sender, EventArgs e)//发送按钮 { if (serial.IsOpen) { if (MessageInput.Text.Length != 0) { serial.Write(MessageInput.Text); DisplayArea.AppendText("[" + TimeStamp + " SEND]" + MessageInput.Text + Environment.NewLine); MessageInput.Clear(); } } else { MessageBox.Show("请先打开串口!"); } }
private void HandleEvent() { var isContext = Event.current.type == EventType.MouseDown && Event.current.button == 1; if (!isContext) { return; } var contextMenu = new GenericMenu(); foreach (var data in cachedEventRenderData) { if (data.RenderRect.Contains(Event.current.mousePosition)) { contextMenu.AddItem(new GUIContent("Remove Event"), false, () => { RemoveEvent(data.Event); }); contextMenu.AddSeparator(""); break; } } if (DisplayArea.Contains(Event.current.mousePosition)) { var baseAdd = "Add Event/"; var newTime = (((Event.current.mousePosition.x + XScroll - DisplayArea.x) / DisplayArea.width) * Duration) / XScale; var baseType = typeof(USEventBase); var types = USEditorUtility.GetAllSubTypes(baseType).Where(type => type.IsSubclassOf(baseType)); foreach (var type in types) { var fullAdd = baseAdd; var customAttributes = type.GetCustomAttributes(true).Where(attr => attr is USequencerEventAttribute).Cast <USequencerEventAttribute>(); foreach (var customAttribute in customAttributes) { fullAdd += customAttribute.EventPath; } contextMenu.AddItem(new GUIContent(fullAdd), false, (obj) => AddEvent(newTime, (Type)obj), (object)type); } } if (DisplayArea.Contains(Event.current.mousePosition)) { Event.current.Use(); contextMenu.ShowAsContext(); } }
public void Connect() { try { AttachEventHandlers(_tracker); Framerate = _tracker.GetGazeOutputFrequency(); TrackBox = _tracker.GetTrackBox()?.ToTrackBoxCoords(); DisplayArea = _tracker.GetDisplayArea()?.ToDisplayArea(); } catch (Tobii.Research.InsufficientLicenseException) { } catch (Tobii.Research.ConnectionFailedException) { } catch (Tobii.Research.EyeTrackerUnavailableException) { } }
private void MessageInput_KeyDown(object sender, KeyEventArgs e)//输入框回车事件 { if (e.KeyCode == Keys.Enter) { if (serial.IsOpen) { if (MessageInput.Text.Length != 0) { serial.Write(MessageInput.Text); DisplayArea.AppendText("[" + TimeStamp + " SEND]" + MessageInput.Text + Environment.NewLine); MessageInput.Clear(); } } else { MessageBox.Show("请先打开串口!"); } } }
private double GetScaleAdjustment() { IntPtr hWnd = WindowNative.GetWindowHandle(this); WindowId wndId = Win32Interop.GetWindowIdFromWindow(hWnd); DisplayArea displayArea = DisplayArea.GetFromWindowId(wndId, DisplayAreaFallback.Primary); IntPtr hMonitor = Win32Interop.GetMonitorFromDisplayId(displayArea.DisplayId); // Get DPI. int result = GetDpiForMonitor(hMonitor, Monitor_DPI_Type.MDT_Default, out uint dpiX, out uint _); if (result != 0) { throw new Exception("Could not get DPI for monitor."); } uint scaleFactorPercent = (uint)(((long)dpiX * 100 + (96 >> 1)) / 96); return(scaleFactorPercent / 100.0); }
//事件 //自定义事件 private void Serial_DataReceived(object sender, SerialDataReceivedEventArgs e)//串口数据接收事件 { string data = string.Empty; while (serial.BytesToRead > 0) { data += serial.ReadExisting(); } if (HexModeCheck.Checked) { string HEXdata = string.Empty; for (int i = 0; i < data.Length; i++) { HEXdata += (Convert.ToString((char)data[i], 16) + " "); } data = HEXdata; } Invoke((EventHandler) delegate { DisplayArea.AppendText("[" + TimeStamp + " RECV]" + data + Environment.NewLine); }); }
private static void Main() { Thread.CurrentThread.Name = nameof(ExampleServer); var headerArea = new DisplayArea(HEADER_AREA, 0, 0, HEADER_LINES - 1, Console.WindowWidth); var totalConnectionArea = new DisplayArea(STATS_TOTAL_CONNECTION_AREA, headerArea.Bottom + 1, 0, headerArea.Bottom + 1, Console.WindowWidth) { Cycle = true }; var activeConnectionArea = new DisplayArea(STATS_ACTIVE_CONNECTION_AREA, totalConnectionArea.Bottom + 1, 0, totalConnectionArea.Bottom + 1, Console.WindowWidth) { Cycle = true }; var logAreaDemarcation = new DisplayArea(LOG_AREA_DEMARCATION, activeConnectionArea.Bottom + 1, 0, activeConnectionArea.Bottom + 1, Console.WindowWidth) { Cycle = true }; var logArea = new DisplayArea(LOG_AREA, logAreaDemarcation.Bottom + 1, 0, Console.WindowHeight - logAreaDemarcation.Bottom, Console.WindowWidth) { Cycle = true }; _consoleWindow = new ConsoleWindow(new[] { headerArea, totalConnectionArea, activeConnectionArea, logAreaDemarcation, logArea }); _consoleWindow.Clear(); _consoleWindow.WriteLine($"Locating hosting information...", Flair.Log, HEADER_AREA); _consoleWindow.WriteLine($"-----------------------LOG-------------------------", Flair.Log, LOG_AREA_DEMARCATION); var service = new AsyncTcpListener("Listener Simulator", 20000); Task.Run(() => { service.DebugMessageEventHandler += (sender, e) => { _consoleWindow.WriteLine($"{e.Timestamp.TimeOfDay} - {e.SourceName} - {e.Message}", Flair.Log, LOG_AREA); }; service.InfoMessageEventHandler += (sender, e) => { _consoleWindow.WriteLine($"{e.Timestamp.TimeOfDay} - {e.SourceName} - {e.Message}", Flair.Log, LOG_AREA); }; service.ConnectionInfoMessageEventHandler += (sender, e) => { _consoleWindow.WriteLine($"{e.Timestamp.TimeOfDay} - Client Connections {e.Stats.ClientConnectionsCount}", Flair.Log, STATS_TOTAL_CONNECTION_AREA); _consoleWindow.WriteLine($"{e.Timestamp.TimeOfDay} - Active Connections {e.Stats.ActiveClientCount}", Flair.Log, STATS_ACTIVE_CONNECTION_AREA); }; service.ErrorMessageEventHandler += (sender, e) => { _consoleWindow.WriteLine($"{e.Timestamp.TimeOfDay} - {e.SourceName} - {e.Message} - {e.Exception}", Flair.Error, LOG_AREA); }; service.ResponseEventHandler += (sender, eventArgs) => { if (eventArgs == null) { throw new ArgumentNullException(nameof(eventArgs)); } _consoleWindow.WriteLine($"Got {eventArgs.RequestMessage}", Flair.Log, LOG_AREA); if (string.IsNullOrWhiteSpace(eventArgs.RequestMessage)) { eventArgs.ResponseMessage = "¿Huh?"; } else if (eventArgs.RequestMessage.StartsWith(TRIGGER_TEXT, StringComparison.OrdinalIgnoreCase)) { eventArgs.ResponseMessage = $"REPLYING FROM Serverside for {eventArgs.RequestMessage.Replace(TRIGGER_TEXT, string.Empty)}"; } else { eventArgs.ResponseMessage = "W/E"; } }; service.Run(); return(Task.CompletedTask); }); _consoleWindow.WriteLine("Press ESC to stop listening", Flair.Success, HEADER_AREA); _consoleWindow.WaitForKey(ConsoleKey.Escape); service.Stop(); _consoleWindow.Close(); }
private void Tracker_DisplayAreaChanged(object sender, Tobii.Research.DisplayAreaEventArgs e) { DisplayArea = e.DisplayArea?.ToDisplayArea(); }
/// <summary> /// Restarts the zmachine. /// </summary> protected override void Restart() { // todo: reset custom colours. this.nextCustomColourNumber = 16; this.MouseWindow = new DisplayArea(); base.Restart(); }
private void OnTouchlessControllerUXEvent(PXCMTouchlessController.UXEventData data) { if (this.Dispatcher.CheckAccess()) { switch (data.type) { case PXCMTouchlessController.UXEventData.UXEventType.UXEvent_CursorVisible: { LabelStatus.Content = "Cursor Visible"; DisplayArea.Cursor = Cursors.Hand; } break; case PXCMTouchlessController.UXEventData.UXEventType.UXEvent_CursorNotVisible: { LabelStatus.Content = "Cursor Not Visible"; DisplayArea.Cursor = null; } break; case PXCMTouchlessController.UXEventData.UXEventType.UXEvent_Select: { LabelStatus.Content = "Select"; MouseInjection.ClickLeftMouseButton(); } break; //case PXCMTouchlessController.UXEventData.UXEventType.UXEvent_StartScroll: // { // Console.WriteLine("Start Scroll"); // initialScrollPoint = data.position.y; // initialScrollOffest = myListscrollViwer.VerticalOffset; // } // break; case PXCMTouchlessController.UXEventData.UXEventType.UXEvent_CursorMove: { Point point = new Point(); point.X = Math.Max(Math.Min(1.0F, data.position.x), 0.0F); point.Y = Math.Max(Math.Min(1.0F, data.position.y), 0.0F); if (Math.Abs(oldXpos - data.position.x) < 0.005F && Math.Abs(oldYpos - data.position.y) < 0.005F) { return; } Label11.Content = "data.position.x" + data.position.x; Label2.Content = "data.position.y" + data.position.y; oldXpos = data.position.x; oldYpos = data.position.y; Point myListBoxPosition = DisplayArea.PointToScreen(new Point(0.0, 0.0)); Point myListBoxPosition2 = DisplayArea.PointToScreen(new Point(DisplayArea.ActualWidth, DisplayArea.ActualHeight)); var d1 = myListBoxPosition2.X - myListBoxPosition.X; var d2 = myListBoxPosition2.Y - myListBoxPosition.Y; int mouseX = (int)(myListBoxPosition.X + point.X * d1); int mouseY = (int)(myListBoxPosition.Y + point.Y * d2); Label3.Content = "mouseX" + mouseX; Label4.Content = "mouseY" + mouseY; MouseInjection.SetCursorPos(mouseX, mouseY); } break; //case PXCMTouchlessController.UXEventData.UXEventType.UXEvent_Scroll: // { // Console.WriteLine("Scrolling"); // myListscrollViwer.ScrollToVerticalOffset(initialScrollOffest + (data.position.y - initialScrollPoint) * scrollSensitivity); // } // break; } } else { this.Dispatcher.Invoke(new Action(() => OnTouchlessControllerUXEvent(data))); } }
/// <summary> /// Determines whether two display areas are equal. /// </summary> /// <param name="displayArea"> /// The display area to compare. /// </param> /// <returns> /// A value indicating whether two display areas are equal. /// </returns> internal bool Equals(DisplayArea displayArea) { return this.size == displayArea.size && this.topLeftCornerPosition == displayArea.topLeftCornerPosition; }
// Use this for initialization void Start() { osc = GetComponent <OSC>(); osc.SetAllMessageHandler(OnOSCMessage); string allScript = GetScriptItems(); string[] lines = allScript.Split('\n'); ScriptItem curItem = null; AreaChange newAreaChange = null; foreach (string lineRaw in lines) { string line = lineRaw.Trim(); if (line.StartsWith("AREA:")) { DisplayArea newArea = new DisplayArea(); string [] values = line.Substring(5).Split(','); for (int c = 0; c < values.Length; c++) { switch (c) { case 0: newArea.name = values[c]; break; case 1: newArea.fontName = values[c]; break; case 2: int.TryParse(values[c], out newArea.fontSize); break; case 3: int.TryParse(values[c], out newArea.r); break; case 4: int.TryParse(values[c], out newArea.g); break; case 5: int.TryParse(values[c], out newArea.b); break; case 6: float.TryParse(values[c], out newArea.x0); break; case 7: float.TryParse(values[c], out newArea.y0); break; case 8: float.TryParse(values[c], out newArea.x1); break; case 9: float.TryParse(values[c], out newArea.y1); break; } } GameObject imgChild = new GameObject("img " + newArea.name); imgChild.transform.SetParent(canvas.transform, false); RawImage image = imgChild.AddComponent <RawImage>(); RectTransform tf2 = imgChild.GetComponent <RectTransform>(); tf2.anchorMin = new Vector2(newArea.x0, newArea.y0); tf2.anchorMax = new Vector2(newArea.x1, newArea.y1); tf2.offsetMin = new Vector2(0, 0); tf2.offsetMax = new Vector2(0, 0); newArea.image = image; newArea.image.enabled = false; RenderTexture vidTex = new RenderTexture(1024, 1024, 0); vidTex.Create(); GameObject vidChild = new GameObject("vid " + newArea.name); vidChild.transform.SetParent(canvas.transform, false); RawImage vImage = vidChild.AddComponent <RawImage>(); vImage.texture = vidTex; RectTransform tf3 = vidChild.GetComponent <RectTransform>(); tf3.anchorMin = new Vector2(newArea.x0, newArea.y0); tf3.anchorMax = new Vector2(newArea.x1, newArea.y1); tf3.offsetMin = new Vector2(0, 0); tf3.offsetMax = new Vector2(0, 0); VideoPlayer vidPlayer = vidChild.AddComponent <VideoPlayer>(); vidPlayer.renderMode = VideoRenderMode.RenderTexture; vidPlayer.targetTexture = vidTex; newArea.video = vidPlayer; newArea.vidTex = vidTex; newArea.videoImage = vImage; GameObject textChild = new GameObject("txt " + newArea.name); textChild.transform.SetParent(canvas.transform, false); Text txt = textChild.AddComponent <Text>(); txt.text = ""; txt.color = new Color(((float)newArea.r) / 255.0f, ((float)newArea.g) / 255.0f, ((float)newArea.b) / 255.0f); txt.alignment = TextAnchor.MiddleLeft; txt.font = Font.CreateDynamicFontFromOSFont(newArea.fontName, 36); txt.fontSize = newArea.fontSize; RectTransform tf = textChild.GetComponent <RectTransform>(); tf.anchorMin = new Vector2(newArea.x0, newArea.y0); tf.anchorMax = new Vector2(newArea.x1, newArea.y1); tf.offsetMin = new Vector2(0, 0); tf.offsetMax = new Vector2(0, 0); newArea.text = txt; areas.Add(newArea); } else { print(line); bool firstLine = (line.Length > 0 && line[0] == '#'); if (firstLine) { // print(line); if (newAreaChange != null) { newAreaChange.text = newAreaChange.text.Trim(); curItem.changes.Add(newAreaChange); } newAreaChange = new AreaChange(); string [] cueData = line.Substring(1).Split(','); if (cueData.Length > 1) { newAreaChange.displayArea = cueData[1]; } curItem = null; for (int c = 0; c < items.Count; c++) { if (items[c].cueID == cueData[0]) { curItem = items[c]; break; } } if (curItem == null) { curItem = new ScriptItem(); curItem.cueID = cueData[0]; items.Add(curItem); print(items.Count + "!"); } } else { if (newAreaChange != null) { if (line.StartsWith("[") && line.IndexOf("]") > 0) { newAreaChange.image = LoadScriptImage(line.Substring(1, line.IndexOf("]") - 1)); } else if (line.StartsWith("{") && line.IndexOf("}") > 0) { newAreaChange.movieName = LoadScriptVideo(line.Substring(1, line.IndexOf("}") - 1)); } else { newAreaChange.text += line + "\n"; } } } } } if (newAreaChange != null) { newAreaChange.text = newAreaChange.text.Trim(); curItem.changes.Add(newAreaChange); } }
void ChangeDisplay(int position) { if (!inFade) { inFade = true; fadeTime = 0; } // fade out any areas in the current position, ready to blink in the new one fadeTime += Time.deltaTime; if (fadeTime < fadeTotal) { float fadeAlpha = (fadeTotal - fadeTime) / fadeTotal; for (int ch = 0; ch < items[position].changes.Count; ch++) { AreaChange change = items[position].changes[ch]; DisplayArea area = GetDisplayArea(change.displayArea); area.videoImage.color = new Color(1, 1, 1, fadeAlpha); area.image.color = new Color(1, 1, 1, fadeAlpha); area.text.color = new Color(area.text.color.r, area.text.color.g, area.text.color.b, fadeAlpha); } return; } for (int ch = 0; ch < items[position].changes.Count; ch++) { AreaChange change = items[position].changes[ch]; DisplayArea area = GetDisplayArea(change.displayArea); if (change.movieName != null) { if (area.video.url != change.movieName || !area.preparedVid) { area.video.url = change.movieName; area.video.Prepare(); area.video.playOnAwake = false; area.preparedVid = true; } if (!area.video.isPrepared) { print("Not prepared"); return; } print("Play video:" + change.movieName + ":" + area.video.texture.width + "," + area.video.texture.height); // change image limits to fit video in the frame right float vw = area.video.texture.width; float vh = area.video.texture.height; Rect newUVRect; // first make texture uv rect exactly video size if (vw < vh) { // sides of texture need to go float scaling = vw / vh; newUVRect = new Rect((1f - scaling) / 2f, 0, scaling, 1); area.videoImage.uvRect = newUVRect; } else { // top of texture needs to go // size it so that pixels are square float scaling = vh / vw; newUVRect = new Rect(0, (1f - scaling) / 2f, 1, scaling); area.videoImage.uvRect = newUVRect; } AlterOffsetForRatio(area.videoImage.GetComponent <RectTransform>(), vw, vh); RenderTexture rt = UnityEngine.RenderTexture.active; UnityEngine.RenderTexture.active = area.vidTex; GL.Clear(true, true, Color.clear); UnityEngine.RenderTexture.active = rt; area.video.Play(); area.playedVid = true; area.videoImage.enabled = true; area.videoImage.texture = area.vidTex; area.image.enabled = false; } else { // stop any video in this area if (area.playedVid) { area.video.Stop(); area.playedVid = false; area.preparedVid = false; } area.videoImage.enabled = false; if (change.image != null) { // an image, load it area.image.enabled = true; area.image.texture = change.image; AlterOffsetForRatio(area.image.GetComponent <RectTransform>(), change.image.width, change.image.height); } else { area.image.enabled = false; } } area.text.text = change.text; // make sure any future videos are loaded } PreloadNextVideos(position); curPosition = position; if (inFade) { inFade = false; for (int ch = 0; ch < items[position].changes.Count; ch++) { AreaChange change = items[position].changes[ch]; DisplayArea area = GetDisplayArea(change.displayArea); area.videoImage.color = new Color(1, 1, 1, 1); area.image.color = new Color(1, 1, 1, 1); area.text.color = new Color(area.text.color.r, area.text.color.g, area.text.color.b, 1); } } }
public static void Run() { Thread.CurrentThread.Name = nameof(ExampleAsyncTcpClient); // Pausing this so server can start first when debugging this and server at the same time. Thread.Sleep(1 * 1000); var headerArea = new DisplayArea(HEADER_AREA, 0, 0, 7, Console.WindowWidth); var logAreaDemarcation = new DisplayArea(LOG_AREA_DEMARCATION, headerArea.Bottom + 1, 0, headerArea.Bottom + 1, Console.WindowWidth) { Cycle = true }; var logArea = new DisplayArea(LOG_AREA, logAreaDemarcation.Bottom + 1, 0, Console.WindowHeight - (logAreaDemarcation.Bottom + 1), Console.WindowWidth) { Cycle = true }; _consoleWindow = new ConsoleWindow(new[] { headerArea, logAreaDemarcation, logArea }); _consoleWindow.Clear(); // ~16k is where the amount of completed connections in TIME_WAIT // that are delaying completion and the number of open connections // exceeds the allowed sockets per port on this win10 machine. // More can probably be done with either better connection management, shorter timeouts, or // some registry tweaking. const int RUN_COUNT = 1 * 100; const int MAXDOP = 5; _consoleWindow.WriteLine("Starting client nag. Press ESC to stop nagging", Flair.Warning, HEADER_AREA); _consoleWindow.WriteLine($"-----------------------LOG-------------------------", Flair.Log, LOG_AREA_DEMARCATION); var overallSw = Stopwatch.StartNew(); Parallel.For(0, RUN_COUNT, new ParallelOptions { MaxDegreeOfParallelism = MAXDOP }, async i => { _clientTasks.Add(ExecuteDataExchange(i)); var result = await ExecuteDataExchange(i); _results.Add(result); }); overallSw.Stop(); Task.WaitAll(_clientTasks.ToArray()); //let any further console updates post before adding summary _consoleWindow.WriteLine($"Ran {RUN_COUNT} records in {overallSw.ElapsedMilliseconds}ms with MAXDOP of {MAXDOP}", Flair.Success, HEADER_AREA); var errors = _results.Where(r => r.Ex != null || r.DataExchangeResult?.Errors.Count > 0).ToArray(); if (errors.Any()) { _consoleWindow.WriteLine($"There were {errors.Length} errors", Flair.Error, HEADER_AREA); var firstFew = errors.Take(Math.Min(5, errors.Length)); foreach (var err in firstFew) { _consoleWindow.WriteLine($"{err.WithErrors()}", Flair.Error, LOG_AREA); } } var rate = overallSw.ElapsedMilliseconds / (decimal)RUN_COUNT; _consoleWindow.WriteLine($"Overall rate of {rate}ms per record", Flair.Success, HEADER_AREA); var sumResultTimes = _results.Sum(r => r.ElapsedMs); _consoleWindow.WriteLine($"Per item total time of {sumResultTimes}ms", Flair.Success, HEADER_AREA); //inner item rate should be larger than overall rate, as there are many items running at once. var innerItemRate = sumResultTimes / (decimal)RUN_COUNT; _consoleWindow.WriteLine($"Per item rate of {innerItemRate}ms per record", Flair.Success, HEADER_AREA); if (_results.Count != RUN_COUNT) { _consoleWindow.WriteLine($"Results count {_results.Count} doesnt match expected run count {RUN_COUNT}", Flair.Error, HEADER_AREA); } var noResponse = _results.Where(r => string.IsNullOrWhiteSpace(r.DataExchangeResult.ResponseMessage)).ToArray(); if (noResponse.Length > 0) { _consoleWindow.WriteLine($"Results {string.Join(",", noResponse.Select(r => r.ClientId))} had empty responses", Flair.Error, HEADER_AREA); } else { var correctResponses = _results .Where(r => r.DataExchangeResult.ResponseMessage.Equals($"REPLYING FROM Serverside for {r.RequestMessage.Replace(TRIGGER_TEXT, string.Empty)}", StringComparison.OrdinalIgnoreCase)) .ToArray(); if (correctResponses.Length == RUN_COUNT) { _consoleWindow.WriteLine($"All results had correct responses", Flair.Success, HEADER_AREA); } else { _consoleWindow.WriteLine($"All results did not have correct responses", Flair.Error, HEADER_AREA); } } Console.ReadLine(); }
private void HandleEvent() { var isContext = Event.current.type == EventType.MouseDown && Event.current.button == 1; if (!isContext) { return; } var contextMenu = new GenericMenu(); var newTime = (((Event.current.mousePosition.x + XScroll - DisplayArea.x) / DisplayArea.width) * Duration) / XScale; USObserverKeyframe overKeyframe = null; foreach (var data in cachedObserverRenderData) { if (data.RenderRect.Contains(Event.current.mousePosition)) { contextMenu.AddItem(new GUIContent("Remove Observer Keyframe"), false, () => { RemoveKeyframe(data.Keyframe); }); contextMenu.AddSeparator(""); overKeyframe = data.Keyframe; break; } } var cameras = Resources.FindObjectsOfTypeAll(typeof(Camera)) as Camera[]; cameras = cameras.OrderBy(camera => camera.name).ToArray(); foreach (var camera in cameras) { if (!ObserverTimeline.IsValidCamera(camera)) { continue; } var assetPath = AssetDatabase.GetAssetPath(camera.gameObject.transform.root.gameObject); if (!string.IsNullOrEmpty(assetPath)) { continue; } var cutTransition = Shared.TypeOfTransition.Cut; var cutDuration = Shared.TransitionHelper.DefaultTransitionTimeFor(cutTransition); contextMenu.AddItem(new GUIContent(String.Format("Set Camera/Cut/{0}", camera.name)), false, (settingCamera) => SetCamera(overKeyframe, newTime, cutTransition, cutDuration, (Camera)settingCamera), camera); var transitions = Enum.GetValues(typeof(Shared.TypeOfTransition)).Cast <Shared.TypeOfTransition>(); foreach (var transition in transitions) { if (transition == Shared.TypeOfTransition.Cut) { continue; } var transitionType = transition; // Keep a local copy of this, so it's safed for our delegate. var transitionDuration = Shared.TransitionHelper.DefaultTransitionTimeFor(transitionType); contextMenu.AddItem(new GUIContent(String.Format("Set Camera/Transition/{0}/{1}", camera.name, transitionType)), false, (settingCamera) => SetCamera(overKeyframe, newTime, transitionType, transitionDuration, (Camera)settingCamera), camera); } } if (DisplayArea.Contains(Event.current.mousePosition)) { Event.current.Use(); contextMenu.ShowAsContext(); } }
public AngularValidationEvaluationStrategy(DisplayArea displayArea) { DisplayArea = displayArea; }