static void Main(string[] args) { ISubject weatherSubject = new WeatherObject(); IDisplay display1 = new Display1(weatherSubject); display1.StartMonitoring(); }
public virtual bool Check() { if (this.VisualsDisplayHistory == null) { throw new CheckFailedException(this.GetType(), typeof(VisualsDisplayHistory)); } if (this.SceneManager == null) { throw new CheckFailedException(this.GetType(), typeof(ISceneManager)); } if (this.Display1 == null) { throw new CheckFailedException(this.GetType(), typeof(IGraphSceneDisplay <IVisual, IVisualEdge>)); } if (this.Display2 == null) { throw new CheckFailedException(this.GetType(), typeof(IGraphSceneDisplay <IVisual, IVisualEdge>)); } if (this.Backend == null) { throw new CheckFailedException(this.GetType() + "needs a Backend"); } Display1.Check(); Display2.Check(); return(true); }
private void Display1_TextChanged(object sender, EventArgs e) { if (autoscroll) { Display1.SelectionStart = Display1.Text.Length; Display1.ScrollToCaret(); } }
private void Display_Resize(object sender, EventArgs e) { if (this.WindowState == FormWindowState.Minimized) { this.Visible = false; } Display1.SetBounds(this.ClientRectangle.X, this.ClientRectangle.Y, this.ClientRectangle.Width, Display1.Font.Height * 7); Display2.SetBounds(this.ClientRectangle.X, this.ClientRectangle.Y + Display1.Height, this.ClientRectangle.Width, this.ClientRectangle.Height - Display1.Height); }
private void Clear() { VisualsDisplayHistory?.Clear(); SceneManager?.Clear(); ContentViewManager.Clear(); Display1.Clear(); Display2.Clear(); }
public void ClrTypeMappingValueAnnotationTryPopulateObjectInstance() { this.InitializeOperationDefinitions(); EdmToClrEvaluator ev = new EdmToClrEvaluator(this.operationDefinitions); var edmModel = this.GetParserResult(ClrTypeMappingTestModelBuilder.ValueAnnotationClassTypeBasicTest(), this.operationDeclarationModel); var value = ev.Evaluate(this.GetValueAnnotations(edmModel, edmModel.FindType("NS1.Person"), "TVDisplay").Single().Value); var isObjectPopulated = false; var isObjectInitialized = true; object createdObjectInstance = new Display1() { X = 0, Y = 1 }; TryCreateObjectInstance tryCreateObjectInstance = (IEdmStructuredValue edmValue, Type clrType, EdmToClrConverter converter, out object objectInstance, out bool objectInstanceInitialized) => { objectInstance = createdObjectInstance; objectInstanceInitialized = isObjectPopulated; return(isObjectInitialized); }; ev.EdmToClrConverter = new EdmToClrConverter(tryCreateObjectInstance); this.VerifyThrowsException(typeof(InvalidCastException), () => ev.EdmToClrConverter.AsClrValue(value, typeof(Display2))); isObjectPopulated = false; isObjectInitialized = false; createdObjectInstance = new Display1() { X = 0, Y = 1 }; ev.EdmToClrConverter = new EdmToClrConverter(tryCreateObjectInstance); Assert.IsTrue(CompareObjects((Display2)ev.EdmToClrConverter.AsClrValue(value, typeof(Display2)), new Display2() { X = 10, Y = 20, Origin = new Display1() { X = 10, Y = 20 } }), "The returned object has incorrect values."); isObjectPopulated = true; isObjectInitialized = true; createdObjectInstance = new Display1() { X = 0, Y = 1 }; ev.EdmToClrConverter = new EdmToClrConverter(tryCreateObjectInstance); this.VerifyThrowsException(typeof(InvalidCastException), () => ev.EdmToClrConverter.AsClrValue(value, typeof(Display2))); }
private void DisplayText(object sender, EventArgs e) { if (type1.SelectedIndex == 0) { Display1.AppendText(RxString); } else if (type1.SelectedIndex == 1) { Display1.AppendText(DecWrite()); } else { Display1.AppendText(HexWrite()); } }
public override void Dispose() { Clear(); if (_contentViewManager != null) { this.ContentViewManager.Dispose(); } Mesh.RemoveDisplay(Display1); Mesh.RemoveDisplay(Display2); Display1.Dispose(); Display1 = null; Display2.Dispose(); Display2 = null; }
public Display() { InitializeComponent(); this.Text = "Dictionary Server"; Display1.SetBounds(this.ClientRectangle.X, this.ClientRectangle.Y, this.ClientRectangle.Width, ClientRectangle.Height * 1 / 3); Display2.SetBounds(this.ClientRectangle.X, this.ClientRectangle.Y + Display1.Height, this.ClientRectangle.Width, this.ClientRectangle.Height - Display1.Height); UpdateTimer.Interval = 1000; UpdateTimer.Tick += new EventHandler(UpdateDisplay); UpdateTimer.Tag = 0; UpdateTimer.Start(); ThreadPool.QueueUserWorkItem(delegate { Program.Init(); }, null); ThreadPool.QueueUserWorkItem(delegate { Program.WaitForConnections(); }, null); Display1.SetBounds(this.ClientRectangle.X, this.ClientRectangle.Y, this.ClientRectangle.Width, Display1.Font.Height * 7); Display2.SetBounds(this.ClientRectangle.X, this.ClientRectangle.Y + Display1.Height, this.ClientRectangle.Width, this.ClientRectangle.Height - Display1.Height); }
private void initializeDeck() { List <List <int> > intDeck = FileReader.ReadFile(DeckAddress); //Creating Cards and setting them to the decks for (int i = 0; i < intDeck.Count; i++) { Card newCard = new Card(intDeck[i]); if (intDeck[i][1] == 1) { Deck1.Add(newCard); } else if (intDeck[i][1] == 2) { Deck2.Add(newCard); } else if (intDeck[i][1] == 3) { Deck3.Add(newCard); } } //Shuffling Decks ShuffleDecks(); //Turning 4 cards from each deck for (int i = 0; i < 4; i++) { Display1.Add(Deck1[0]); Deck1.RemoveAt(0); Display2.Add(Deck2[0]); Deck2.RemoveAt(0); Display3.Add(Deck3[0]); Deck3.RemoveAt(0); } }
private void clear1_Click(object sender, EventArgs e) { Display1.Clear(); }
private void button2_Click(object sender, EventArgs e) { Display1.Clear(); }
public void ClrTypeMappingValueAnnotationTryCreateObjectInstance() { this.InitializeOperationDefinitions(); EdmToClrEvaluator ev = new EdmToClrEvaluator(this.operationDefinitions); var edmModel = this.GetParserResult(ClrTypeMappingTestModelBuilder.ValueAnnotationClassTypeBasicTest(), this.operationDeclarationModel); var value = ev.Evaluate(this.GetValueAnnotations(edmModel, edmModel.FindType("NS1.Person"), "TVDisplay").Single().Value); var isObjectPopulated = true; var isObjectInitialized = true; object createdObjectInstance = null; TryCreateObjectInstance tryCreateObjectInstance = (IEdmStructuredValue edmValue, Type clrType, EdmToClrConverter converter, out object objectInstance, out bool objectInstanceInitialized) => { objectInstance = createdObjectInstance; objectInstanceInitialized = isObjectPopulated; return(isObjectInitialized); }; ev.EdmToClrConverter = new EdmToClrConverter(tryCreateObjectInstance); Assert.IsNull((Display2)ev.EdmToClrConverter.AsClrValue(value, typeof(Display2)), "The returned object should be null."); isObjectPopulated = false; isObjectInitialized = true; ev.EdmToClrConverter = new EdmToClrConverter(tryCreateObjectInstance); Assert.IsNull((Display2)ev.EdmToClrConverter.AsClrValue(value, typeof(Display2)), "The returned object should be null."); isObjectPopulated = true; isObjectInitialized = false; ev.EdmToClrConverter = new EdmToClrConverter(tryCreateObjectInstance); Assert.IsTrue(CompareObjects((Display2)ev.EdmToClrConverter.AsClrValue(value, typeof(Display2)), new Display2() { X = 10, Y = 20, Origin = new Display1() { X = 10, Y = 20 } }), "The returned object has incorrect values."); isObjectPopulated = false; isObjectInitialized = false; ev.EdmToClrConverter = new EdmToClrConverter(tryCreateObjectInstance); Assert.IsTrue(CompareObjects((Display2)ev.EdmToClrConverter.AsClrValue(value, typeof(Display2)), new Display2() { X = 10, Y = 20, Origin = new Display1() { X = 10, Y = 20 } }), "The returned object has incorrect values."); createdObjectInstance = new Display2() { X = 0, Y = 1, Origin = new Display1 { X = 3, Y = 4 } }; isObjectPopulated = true; isObjectInitialized = true; ev.EdmToClrConverter = new EdmToClrConverter(tryCreateObjectInstance); Assert.IsTrue(CompareObjects((Display2)ev.EdmToClrConverter.AsClrValue(value, typeof(Display2)), createdObjectInstance), "The returned object has incorrect values."); ev.EdmToClrConverter = new EdmToClrConverter((IEdmStructuredValue edmValue, Type clrType, EdmToClrConverter converter, out object objectInstance, out bool objectInstanceInitialized) => { if (clrType == typeof(Display2)) { objectInstance = new Display2() { X = 0, Y = 1, Origin = new Display1 { X = 3, Y = 4 } }; objectInstanceInitialized = false; return(true); } else if (clrType == typeof(Display1)) { objectInstance = new Display1 { X = 3, Y = 4 }; objectInstanceInitialized = false; return(true); } else { objectInstance = null; objectInstanceInitialized = false; return(false); } }); Assert.IsTrue(CompareObjects((Display2)ev.EdmToClrConverter.AsClrValue(value, typeof(Display2)), new Display2() { X = 10, Y = 20, Origin = new Display1() { X = 10, Y = 20 } }), "The returned object has incorrect values."); isObjectPopulated = false; isObjectInitialized = true; createdObjectInstance = new DisplayCoordination(); ev.EdmToClrConverter = new EdmToClrConverter(tryCreateObjectInstance); Coordination actual = (Coordination)ev.EdmToClrConverter.AsClrValue(value, typeof(Coordination)); Coordination expected = new Coordination() { X = 10, Y = 20 }; Assert.AreEqual(expected.X, actual.X, "The returned object has incorrect values. X"); Assert.AreEqual(expected.Y, actual.Y, "The returned object has incorrect values. X"); }
private void UpdateDisplay(object sender, EventArgs e) { UpdateTimer.Tag = int.Parse(UpdateTimer.Tag.ToString()) + 1; try { if (!Program.Loading) { if (!File.Exists(Program.userlog) || (!File.ReadAllText(Program.userlog).Contains(DateTime.Now.ToLongDateString()) && DateTime.Now.Hour == 7)) { Program.Init(); File.AppendAllText(Program.userlog, DateTime.Now.ToLongDateString() + Environment.NewLine + Environment.NewLine); while (!Program.IPlistfree) { Thread.Sleep(1); } Program.IPlistfree = false; Program.UserList.Clear(); Program.IPlistfree = true; } if (int.Parse(UpdateTimer.Tag.ToString()) >= 100) { UpdateTimer.Tag = 0; while (!Program.IPlistfree) { Thread.Sleep(1); } Program.IPlistfree = false; List <string> temp1 = Program.RecentIPList.ToList(); List <string> temp2 = Program.BanList.ToList(); Program.IPlistfree = true; foreach (string item in temp1) { if (!temp2.Contains(item) && temp1.Count(x => x == item) >= 100) { Program.BanList.Add(item); //Credentials stored separately on a local machine for obvious reasons. string email = File.ReadAllText(@"C:\Users\alexf\Google Drive\Computer\Documents\emailcredentials.txt").Split('\t')[0]; string password = File.ReadAllText(@"C:\Users\alexf\Google Drive\Computer\Documents\emailcredentials.txt").Split('\t')[1]; SmtpClient client = new SmtpClient("smtp.gmail.com", 587) { Credentials = new NetworkCredential(email, password), EnableSsl = true }; MailMessage message = new MailMessage(email, email); message.Subject = "Scraping Attempt Detected"; message.Body = "IP: " + item + Environment.NewLine + "Blocked"; client.SendAsync(message, null); } } while (!Program.IPlistfree) { Thread.Sleep(1); } Program.IPlistfree = false; Program.RecentIPList.Clear(); Program.IPlistfree = true; } Display1.Clear(); Display1.AppendText("Server Version: " + Program.version + Environment.NewLine); Display1.AppendText("Server URL: " + "http://" + Program.OwnIPAddress + ":" + Program.Port + "/" + Environment.NewLine); TimeSpan uptime = DateTime.Now.Subtract(Program.starttime); Display1.AppendText("Server Uptime: " + (uptime.Days == 1 ? uptime.Days + " day " : (uptime.Days > 1 ? uptime.Days + " days " : "")) + (uptime.Hours == 1 ? uptime.Hours + " hour " : (uptime.Hours > 1 ? uptime.Hours + " hours " : "")) + (uptime.Minutes == 1 ? uptime.Minutes + " minute " : (uptime.Minutes > 1 ? uptime.Minutes + " minutes " : "")) + (uptime.Seconds == 1 ? uptime.Seconds + " second " : (uptime.Seconds > 1 ? uptime.Seconds + " seconds " : "")) + Environment.NewLine); Display1.AppendText("Total Connections: " + Program.totalconnections + Environment.NewLine); Display1.AppendText("Unique Connections: " + Program.uniqueconnections + Environment.NewLine); Display1.AppendText("Waiting for connections..."); while (!Program.IPlistfree) { Thread.Sleep(1); } Program.IPlistfree = false; foreach (string line in Program.UserList.ToList()) { if (Display2.Lines.Contains(line)) { continue; } Display2.SelectionStart = 0; Display2.SelectionLength = 0; Display2.SelectedText = (line + '\n'); Display2.Update(); } Program.IPlistfree = true; } } catch { } }