private void HackMouseMove() { Point middle = new Point(DisplayBox.Width / 2, DisplayBox.Height / 2); // Force (invisible) cursor to middle of window Cursor.Position = DisplayBox.PointToScreen(middle); }
void InitObjects() { DrawingStyler.style = DrawingStyle.Default; currentArray = new SortingArray(defaultArraySize); graph = DisplayBox.CreateGraphics(); controller = new Controller(graph, currentArray, GetTrackbarDelay()); }
private void DisplayBox_MouseMove(object sender, MouseEventArgs e) { var result = DrawGraphics.DrawBitmap(e, this.DisplayBox, vectorPointsList, pivotX, pivotY); DrawGrids(); DrawAngleAxis(result); DisplayBox.Refresh(); }
private void UpdateDisplay() { String input = InputTextBox.Text; DisplayBox.Text = DisplayBox.Text + input + "\n\n"; DisplayBox.ScrollToEnd(); InputTextBox.Clear(); }
private void DrawGrids() { using (var g = System.Drawing.Graphics.FromImage(DisplayBox.Image)) { g.DrawLine(Pens.Gray, (float)pivotX, (float)pivotY, DisplayBox.Width, (float)pivotY); g.DrawLine(Pens.Gray, (float)pivotX, 0, (float)pivotX, DisplayBox.Height); DisplayBox.Refresh(); } }
public void WriteString_InvalidBoxNameExceptionThrown() { //Set up DisplayBox box = new DisplayBox("MyBox", 0, 0, 80, 30); DisplayScreen screen = new DisplayScreen(150, 50); screen.Add(box); //Action - assert Assert.Throws <ArgumentException>(() => screen.WriteString("BogusName", "SomeText", ConsoleColor.Black, ConsoleColor.White, 0, 0)); }
private void buttonCE_Click(object sender, EventArgs e) { _digit1 = 0; _digit2 = 0; _result = 0; _operationChoosed = false; _operationCompleted = false; _currentState.Clear(); DisplayBox.Clear(); CalcTextBox.Text = _zero; }
public void Add_NewBoxGetsAddedToNonEmptyList(int box1X, int box1Y, int box1Width, int box1Height, int box2X, int box2Y, int box2Width, int box2Height) { //Set up DisplayBox box1 = new DisplayBox("Box1", box1X, box1Y, box1Width, box1Height); DisplayBox box2 = new DisplayBox("Box2", box2X, box2Y, box2Width, box2Height); DisplayScreen screen = new DisplayScreen(150, 50); screen.Add(box1); screen.Add(box2); //No assert needed as test succeeds if no exception is thrown }
public void Add_OverlappingBoxesThrowsException(int box1X, int box1Y, int box1Width, int box1Height, int box2X, int box2Y, int box2Width, int box2Height) { //Set up DisplayBox box1 = new DisplayBox("Box1", box1X, box1Y, box1Width, box1Height); DisplayBox box2 = new DisplayBox("Box2", box2X, box2Y, box2Width, box2Height); DisplayScreen screen = new DisplayScreen(150, 50); screen.Add(box1); //Assertion Assert.Throws <DisplayBoxOverlapException>(() => screen.Add(box2)); }
public void Add_BoxNameAlreadyExistsThrowsException() { //Set up string boxName = "MyBox"; DisplayScreen screen = new DisplayScreen(150, 50); DisplayBox box1 = new DisplayBox(boxName, 0, 0, 80, 30); DisplayBox box2 = new DisplayBox(boxName, 0, 0, 80, 30); //Action screen.Add(box1); //Assert Assert.Throws <DisplayBoxExistsException>(() => screen.Add(box2)); }
private void button0_Click(object sender, EventArgs e) { if (CalcTextBox.Text != _zero) { if (_operationCompleted) { CalcTextBox.Text = _zero; DisplayBox.Clear(); _operationCompleted = false; } CalcTextBox.Text += ((Button)sender).Text; } }
//Button Click Events private void NumClick(object sender, EventArgs e) { Button btn = (Button)sender; if (DisplayBox.Text == "0") { DisplayBox.Clear(); } if (HasAns == true) { DisplayBox.Clear(); HasAns = false; } DisplayBox.Text = DisplayBox.Text + btn.Text; }
public void ShowHexString(bool tohex) { string text = new TextRange(DisplayBox.Document.ContentStart, DisplayBox.Document.ContentEnd).Text; string s; if (tohex) { s = StringTool.String2Hex(text); } else { s = StringTool.Hex2String(text); } DisplayBox.Document.Blocks.Clear(); DisplayBox.AppendText(s); }
public void UpdateReceivedMessage(object sender, EventArgs e) { UpdateEventArgs ue = (UpdateEventArgs)e; string s = ue.Id + " -> " + ue.Message + "\n\n"; DisplayBox.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new DispatcherOperationCallback(delegate { DisplayBox.Text += s; DisplayBox.ScrollToEnd(); return(null); }), null); //DisplayBox.Text = s; //DisplayBox.ScrollToEnd(); }
public void Add_NewBoxGetsAddedCorrectly(string name, int x, int y, int width, int height, int screenWidth, int screenHeight) { //Set up DisplayScreen screen = new DisplayScreen(screenWidth, screenHeight); DisplayBox box = new DisplayBox(name, x, y, width, height); //Action screen.Add(box); List <DisplayBox> boxList = screen.GetDisplayBoxes(); //Assert Assert.True(boxList.Count > 0); Assert.True(boxList[0].Name == name); Assert.True(boxList[0].DisplayX == x); Assert.True(boxList[0].DisplayY == y); Assert.True(boxList[0].DisplayWidth == width); Assert.True(boxList[0].DisplayHeight == height); }
/// <summary> /// Universal Button Handler. Handles Input for Every Button Aside from Clear and Equals /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ButtonHandler(object sender, EventArgs e) { Button currentButton = (Button)sender; string text = currentButton.Text; if (DisplayBox.Text == "ERROR") { displayString = ""; DisplayBox.Clear(); } if (!(displayString.Contains("+") || displayString.Contains("−") || displayString.Contains("/") || displayString.Contains("x")) && displayString.Length >= 1) { if (Tokens.IsFunction(text)) //Encase whatever is on the display with the function { displayString = text + " (" + displayString + ")"; infix = text.Contains(Tokens.LEFT_PAREN_OP) ? (text + " ( " + infix + " ) ") : (text + " ( " + infix + " )"); text = ""; } } //This block ensures proper infix formatting for parsing if (Tokens.IsOperator(text) && text != Tokens.FACT_OP) { infix += " " + text + " "; } else if (text == Tokens.LEFT_PAREN_OP || Tokens.IsFunction(text)) { infix += text + " "; } else if (text == Tokens.RIGHT_PAREN_OP || text == Tokens.FACT_OP) { infix += " " + text; } else { infix += text; } displayString = infix; DisplayBox.Text = displayString; Debug.WriteLine(infix); }
private void OnDisplayMouseMove(object sender, MouseEventArgs e) { // Short-circuit if a script is playing. if (ScriptManager.IsPlaying) { return; } if (!_mouseCaptured) { // We do nothing with mouse input unless we have capture. return; } if (_skipNextMouseMove) { _skipNextMouseMove = false; return; } // We implement a crude "mouse capture" behavior by forcing the mouse cursor to the // center of the display window and taking the delta of the last movement and using it // to move the Alto's mouse. // In this way the Windows cursor never leaves our window (important in order to prevent // other programs from getting clicked on while Missile Command is being played) and we // still get motion events. Point middle = new Point(DisplayBox.Width / 2, DisplayBox.Height / 2); int dx = e.X - middle.X; int dy = e.Y - middle.Y; if (dx != 0 || dy != 0) { _system.MouseAndKeyset.MouseMove(dx, dy); // Don't handle the very next Mouse Move event (which will just be the motion we caused in the // below line...) _skipNextMouseMove = true; Cursor.Position = DisplayBox.PointToScreen(middle); } }
private void DisplayBox_MouseMove(object sender, MouseEventArgs e) { if (isMouseDown && isDrawEnabled) { if (lastPoint != null) { if (DisplayBox.Image == null) { Bitmap bmp = new Bitmap(DisplayBox.Width, DisplayBox.Height); DisplayBox.Image = bmp; } using (Graphics g = Graphics.FromImage(DisplayBox.Image)) { g.DrawLine(new Pen(Color.Black, 2), lastPoint, e.Location); g.SmoothingMode = SmoothingMode.AntiAlias; } DisplayBox.Invalidate(); //refreshes the picturebox lastPoint = e.Location; //keep assigning the lastPoint } } }
public async Task StartCrawlerAsync() { DisplayBox.Text = "Loading..."; var url = ""; for (int i = 0; i < 6; i++) { int x = i + 1; url = "https://store.steampowered.com/search/?category1=998&specials=1&filter=topsellers&page=" + x; var httpClient = new HttpClient(); var html = await httpClient.GetStringAsync(url); var htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(html); var divs = htmlDocument.DocumentNode.Descendants("div").Where(node => node.GetAttributeValue("class", "").Equals("responsive_search_name_combined")).ToList(); Listen.Add($"side {x}"); foreach (var div in divs) { var name = div.Descendants("span").FirstOrDefault().InnerText; var Percent = div.Descendants("div").Where(node => node.GetAttributeValue("class", "").Equals("col search_discount responsive_secondrow")).FirstOrDefault().Descendants("span").FirstOrDefault().InnerText; var Price = div.Descendants("div").Where(node => node.GetAttributeValue("class", "").Equals("col search_price discounted responsive_secondrow")).FirstOrDefault().InnerText; var kage = Price.Split(new char[] { '\t', '€' }); Price = kage[9]; var BeforePrice = kage[8]; Listen.Add(name + ": " + Percent + " Før pris " + BeforePrice + "€ Tilbuds pris " + Price + "€"); } } DisplayBox.Clear(); foreach (var item in Listen) { DisplayBox.Text += item + "\n \n"; } }
private void ClearBtn_Click(object sender, EventArgs e) { DisplayBox.Clear(); }
public void ST(string text) { DisplayBox.AppendText(text + "\n"); }
private void button1_Click(object sender, EventArgs e) { DisplayBox.AppendText(XButton.Text); }
private void UpdateUI(string data) { DisplayBox.AppendText(data); DisplayScroll.ScrollToEnd(); }
public void NewBoxWithValidArgumentsValues(string name, int x, int y, int width, int height) { DisplayBox box = new DisplayBox(name, x, y, width, height); }
private void SearchButton_Click(object sender, EventArgs e) { //Is this a batch? True if yes //bool batchOrder = batchOrderCheck.Checked; //Used to store the added tickers string tickers = ""; //base string that represents the JSON and the input string input = ""; //Goes until 'end' is entered while (!input.ToUpper().Equals("END")) { ShowInputDialog(ref input); //only adds valid tickers if (!input.ToUpper().Equals("END")) { tickers = input.ToUpper(); } } //Networking section try { //Defines arrays to be used char[] textToSend = new char[0]; byte[] bytesToRead = new byte[0]; byte[] bytesToSend = new byte[0]; int bytesRead = 0; //Initializes NetworkStream and TCPClient textToSend = tickers.ToCharArray(); bytesToSend = ASCIIEncoding.ASCII.GetBytes(textToSend); MessageBox.Show("Sending : " + tickers); nwStream.Write(bytesToSend, 0, bytesToSend.Length); //---read back the text--- bytesToRead = new byte[client.ReceiveBufferSize]; bytesRead = nwStream.Read(bytesToRead, 0, client.ReceiveBufferSize); string returned = Encoding.ASCII.GetString(bytesToRead, 0, bytesRead); Console.WriteLine("Received : " + returned); DisplayBox.AppendText(returned); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } /*{ * // //use web as a webclient to allow API access * // using (var web = new WebClient()) * // { * // if (input.Equals("")) * // { * // input = "AAPL"; * // } * // var url = $""; * // //If batch, special URL used * // if (batchOrder) * // { * // url = $"https://api.iextrading.com/1.0/stock/market/batch?symbols={tickers}&types=quote"; * // } * // else * // { * // url = $"https://api.iextrading.com/1.0/stock/{tickers}/book/"; * // } * // //Download the returned API call as a string * // json = web.DownloadString(url); * // } * //}//Moved JSON * //json = json.Replace("//", ""); * { * //Parse the json string to a JSON object * var v = JToken.Parse(json); * //Display ticker and other info for each stock requested in batch. * foreach (var j in v) * { * JToken i = j.First.First.First; * Stock stockShow = crawl.FillStock(i); * var ticker = i.SelectToken("symbol"); * var price = i.SelectToken("latestPrice"); * var peRat = i.SelectToken("peRatio"); * * DisplayBox.AppendText($"{ticker} : {price} : {peRat}"); * DisplayBox.AppendText(Environment.NewLine); * DisplayBox.AppendText(stockShow.ToString()); * } * }//Old JSON Batch Code * { * var v = JToken.Parse(json); * var mainStuff = v.First.First; * Stock stockShow = crawl.FillStock(mainStuff); * var ticker = mainStuff.SelectToken("symbol"); * var price = mainStuff.SelectToken("close"); * var peRat = mainStuff.SelectToken("peRatio"); * var rating = stockShow.Rating; * * DisplayBox.Text += ($"{ticker} : {price} : {peRat} : {rating}"); * DisplayBox.AppendText(Environment.NewLine); * DisplayBox.AppendText(stockShow.ToString()); * }//Old JSON Solo Code*/ }
public void DisplayMessages(string message) { DisplayBox.AppendText(message); }
private void DisplayBox_KeyDown(object sender, KeyEventArgs e) { if (ShowingList == false) { MainForm_KeyDown(sender, e); return; } if (Locked) { return; } int SubKey = 0; if (((Win32.GetAsyncKeyState(Win32.EVirtualKey.VK_LSHIFT) & 0x8000) | (Win32.GetAsyncKeyState(Win32.EVirtualKey.VK_RSHIFT) & 0x8000)) != 0) { SubKey |= 1; } if (((Win32.GetAsyncKeyState(Win32.EVirtualKey.VK_LCONTROL) & 0x8000) | (Win32.GetAsyncKeyState(Win32.EVirtualKey.VK_RCONTROL) & 0x8000)) != 0) { SubKey |= 2; } if (((Win32.GetAsyncKeyState(Win32.EVirtualKey.VK_LMENU) & 0x8000) | (Win32.GetAsyncKeyState(Win32.EVirtualKey.VK_RMENU) & 0x8000)) != 0) { SubKey |= 4; } switch (e.KeyCode) { case Keys.Space: if (SubKey == 2) { MnToggleShow_Click(null, null); } break; case Keys.Return: ToggleShowList(EShowMode.PICTURE); break; case Keys.Delete: if (SubKey == 0) { DeleteFileLists(0); } else if (SubKey == 2) { DeleteFileLists(1); } else if (SubKey == 3) { DeleteFileLists(2); } break; case Keys.Down: if (SubKey == 4) { MoveSelectedList(1); } break; case Keys.Up: if (SubKey == 4) { MoveSelectedList(-1); } break; case Keys.O: MnOpenFile_Click(null, null); break; case Keys.N: if (SubKey == 2) { MnFileRename_Click(null, null); } break; case Keys.A: if (SubKey == 2) { for (int i = 0; i < DisplayBox.Items.Count; i++) { DisplayBox.SetSelected(i, true); } } break; case Keys.S: if (SubKey == 0) { MnInScreen_Click(null, null); } else if (SubKey == 2) { MnSave_Click(null, null); } break; case Keys.C: if (SubKey == 0) { MnCenter_Click(null, null); } else if (SubKey == 2) { MnFileCopy_Click(null, null); } else if (SubKey == 3) { MnCopyFilePath_Click(null, null); } break; case Keys.T: if (SubKey == 0) { MnAlwaysTop_Click(null, null); } else if (SubKey == 2) { SortFileLists(ESortType_NAME); } break; case Keys.F: MnFullScreen_Click(null, null); break; case Keys.X: if (SubKey == 2) { MnFileCut_Click(null, null); } break; case Keys.Back: MnCloseArchive_Click(null, null); break; case Keys.V: if (SubKey == 2) { MnFilePaste_Click(null, null); } break; case Keys.I: if (SubKey == 2) { for (int i = 0; i < DisplayBox.Items.Count; i++) { DisplayBox.SetSelected(i, !DisplayBox.GetSelected(i)); } } break; case Keys.D: if (SubKey == 2) { for (int i = 0; i < DisplayBox.Items.Count; i++) { DisplayBox.SetSelected(i, false); } } break; case Keys.P: if (SubKey == 2) { MnOpenExistsFolder_Click(null, null); } else { MnOpenFolder_Click(null, null); } break; case Keys.G: if (SubKey == 2) { SortFileLists(ESortType_TIMESTAMP); } break; case Keys.E: if (SubKey == 2) { SortFileLists(ESortType_EXT); } break; case Keys.Y: if (SubKey == 2) { SortFileLists(ESortType_FILESIZE); } break; case Keys.U: if (SubKey == 2) { SortFileLists(ESortType_REVERSE); } break; case Keys.R: if (SubKey == 2) { SortFileLists(ESortType_RANDOM); } break; case Keys.Escape: Close(); break; } }
public virtual bool ContainsPoint(double x, double y) { return(DisplayBox.Contains(x, y)); }
private void SubstractButton_Click(object sender, EventArgs e) { DisplayBox.AppendText(SubButton.Text); }
// initialization private void OnLoad(object sender, EventArgs e) { ViewStreamButton.Enabled = false; ViewContentsButton.Enabled = false; RotateRightButton.Enabled = false; RotateLeftButton.Enabled = false; TextDisplayButton.Enabled = false; HexDisplayButton.Enabled = false; switch (Mode) { case DisplayMode.PdfSummary: Text = string.Format("PDF File {0} Summary", SafeFileName); DisplayString = Reports.PdfFileSummary(Reader); DisplayBox.Text = DisplayString; HexDisplayButton.Enabled = ByteArray != null; break; case DisplayMode.ObjectSummary: Text = string.Format("Object No {0} Summary", ReaderObject.ObjectNumber); DisplayString = Reports.ObjectSummary(ReaderObject); DisplayBox.Text = DisplayString; HexDisplayButton.Enabled = ByteArray != null; if (ReaderObject.ObjectType == ObjectType.Stream || ReaderObject.PdfObjectType == "/Page") { ViewStreamButton.Enabled = true; ViewContentsButton.Enabled = true; } break; case DisplayMode.Stream: Text = string.Format("Object No. {0} Stream", ReaderObject.ObjectNumber); DisplayString = Reports.ByteArrayToString(ByteArray); DisplayBox.Text = DisplayString; HexDisplayButton.Enabled = true; break; case DisplayMode.Contents: Text = string.Format("Object No. {0} Contents", ReaderObject.ObjectNumber); DisplayString = Reports.ByteArrayToString(ByteArray); DisplayBox.Text = DisplayString; HexDisplayButton.Enabled = true; break; case DisplayMode.Image: Image = new Bitmap(new MemoryStream(ByteArray)); DisplayBox.Visible = false; ImageMode = true; OnResize(this, null); RotateRightButton.Enabled = true; RotateLeftButton.Enabled = true; HexDisplayButton.Enabled = true; TextDisplayButton.Text = "Image"; break; } // load to display box DisplayBox.Select(0, 0); DisplayBox.BackColor = Color.White; DisplayBox.ForeColor = Color.Black; DisplayBox.ReadOnly = true; OnResize(this, null); if (Mode == DisplayMode.Stream) { Rectangle Rect = Bounds; Rect.X += 16; Rect.Y += 32; Bounds = Rect; } return; }