// Calls every method that needs to be called to setup the view correctly. private void SetupView() { dataControl = new DataControl(); visueelControl = new Connecion_to_files(dataControl.GetDataModel()); mapView = new MapView(visueelControl); indexPanel = new IndexPanel(); zoomInandOut = new ZoomInandOut(mapView); mapView.mapView = mapView; mapView.zoomInOut = zoomInandOut; this.Controls.Add(indexPanel); this.Controls.Add(zoomInandOut); this.Controls.Add(mapView); WindowState = FormWindowState.Maximized; ChangeBackIcon(false); ShowUserControl(inputPanel); HideshowBack(); FillTimeInput(); SetElement(); DataModel datamodel = dataControl.GetDataModel(); nodeList = datamodel.nodes; SizeChanged += new EventHandler(ScreenSizeChanged); departureInput.GotFocus += new EventHandler(this.RemoveText); departureInput.LostFocus += new EventHandler(this.AddText); destinationInput.GotFocus += new EventHandler(this.RemoveText); destinationInput.LostFocus += new EventHandler(this.AddText); detailsUserControl.Visible = false; departureInput.Text = "Departure"; departureInput.ForeColor = Color.LightGray; destinationInput.Text = "Destination"; destinationInput.ForeColor = Color.LightGray; timeInput.DropDownStyle = ComboBoxStyle.DropDownList; timeInput.DataSource = timeList; timeInput.DisplayMember = "departureTime"; }
/// <summary> /// method for reading from the disk /// </summary> /// <param name="c">Gives acces to the class Connectiom_to_files</param> /// <param name="path">Is the path where the files is saved</param> public static void Disk_read(Connecion_to_files c, string path) { try { using (Stream str = File.Open(path, FileMode.Open)) { var formater = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); c.access = (VisualModel)formater.Deserialize(str); } } catch { MessageBox.Show("File coudn't be opened", "Error", MessageBoxButtons.OK); } }
/// <summary> /// constructor method /// </summary> /// <param name="c"> sets connection to Visueel Model</param> public MapView(Connecion_to_files c) { _connecionToFiles = c; InitializeComponent(); picbox1 = new PictureBox(); Controls.Add(picbox1); this.MouseWheel += new MouseEventHandler(MoveMouseWheel);; picbox1.MouseDown += (object o, MouseEventArgs mea) => { if (mea.Button == MouseButtons.Left) { start = mea.Location; } }; picbox1.MouseMove += (object o, MouseEventArgs mea) => { if (mea.Button == MouseButtons.Left) { end = mea.Location; } if (end != newEnd) { mouseMoved = true; } Onclick(); start = end; }; picbox1.MouseUp += (object o, MouseEventArgs mea) => { end = mea.Location; mouseMoved = false; newEnd = end; }; }