private void LoadForm(int idObject) { try { // Load datagrid List <GeoViewer.Models.PictureView> picturelist = entityConntext.PictureViews.Where(ent => ent.ProjectID == AppContext.Current.OpenProject.ProjectID).ToList(); var list = (from ent in picturelist select new { ent.PictureViewID, ent.Name, ent.Description }); dataGridView1.DataSource = list.ToList(); // Load current object var obj = PictureViewBLL.Current.GetObjectByID(idObject); if (obj != null) { this.widthNumericUpDown.Value = obj.Width; this.heightNumericUpDown.Value = obj.Height; this.topNumericUpDown.Value = obj.Y; this.leftNumericUpDown.Value = obj.X; // Find current picture int pictureId = Convert.ToInt32(obj.Parameters); GeoViewer.Models.PictureView picture = PictureViewBLL.Current.GetByID(pictureId); if (picture != null) { this.idPicture = picture.PictureViewID; this.valueTextBox.Text = "Current Picture: " + picture.Name; } } } catch (Exception exception) { ShowErrorMessage(exception.Message); } }
public ChartMainForm(Sensor sensor = null, Group group = null, PictureView pictureView = null, DateTime? startDate = null, DateTime? endDate = null) { _sensor = sensor; _group = group; _pictureView = pictureView; _startDate = startDate; _endDate = endDate; InitializeComponent(); }
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex >= 0) { int pictureId = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["PictureViewID"].Value); GeoViewer.Models.PictureView picture = PictureViewBLL.Current.GetByID(pictureId); this.valueTextBox.Text = "Current Picture: " + picture.Name; this.idPicture = picture.PictureViewID; } } catch (Exception exception) { ShowErrorMessage(exception.Message); } }
/// <summary> /// Pass params to display text view data on start up, set null (is default) for nothing display /// </summary> /// <param name="sensors">List sensors will be displayed</param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <param name="showCalcValue"></param> public TextViewForm(List<Sensor> sensors = null, PictureView pictureView = null, Group group = null, DateTime? startDate = null, DateTime? endDate = null, bool showCalcValue = true) { // set value to private field _sensors = sensors; _pictureView = pictureView; _group = group; _startDate = startDate; _endDate = endDate; _showCalcValue = showCalcValue; InitializeComponent(); //BindingData(); if (_group != null) _sensors = _group.Sensors.ToList(); if (_pictureView != null) _sensors = PictureViewBLL.Current.GetSensorsInPictureView(_pictureView); dataGridView.DataSource = TextViewBLL.Current.BindToDataTable(_sensors, !_showCalcValue, _startDate, _endDate); }
/// <summary> /// Pass params to build the chart on start up, set null (is default) for nothing display /// </summary> /// <param name="sensor"></param> /// <param name="group"></param> /// <param name="pictureView"></param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <param name="chartName"></param> /// <param name="xLabel"></param> /// <param name="yLabel"></param> /// <param name="showCalcValue"></param> public ChartViewForm(Sensor sensor = null, Group group = null, PictureView pictureView = null, DateTime? startDate = null, DateTime? endDate = null, string chartName = "Chart View", string xLabel = "Value", string yLabel = "Datetime", bool showCalcValue = true) { // set value to private field _sensor = sensor; _group = group; // ... // continue here InitializeComponent(); GraphPane myPane; LineItem mycurve; Random randomGen = new Random(); myPane = zedChartMain.GraphPane; myPane.XAxis.Type = AxisType.Date; myPane.XAxis.Scale.Format = "HH:mm:ss\ndd-MM-yyyy"; myPane.Title.Text = chartName; myPane.XAxis.Title.Text = xLabel; myPane.YAxis.Title.Text = yLabel; myPane.XAxis.MajorGrid.IsVisible = true; myPane.YAxis.MajorGrid.IsVisible = true; if (sensor != null) { List<SensorValue> listvalue = entityConntext.SensorValues.Where(ent => ent.SensorID == sensor.SensorID).ToList(); DataSourcePointList dsp = new DataSourcePointList(); dsp.DataSource = listvalue; if (!showCalcValue) { dsp.YDataMember = "RawValue"; } if (showCalcValue) { dsp.YDataMember = "CalcValue"; } dsp.XDataMember = "MeaTime"; mycurve = myPane.AddCurve(sensor.Name, dsp, Color.FromArgb(randomGen.Next(255), randomGen.Next(255), randomGen.Next(255))); mycurve.Line.Width = 1; } if (group != null) { List<Sensor> sensorsInGroup = group.Sensors.ToList(); for (int i = 0; i < sensorsInGroup.Count; i++) { int idsen = Convert.ToInt16(sensorsInGroup[i].SensorID); List<SensorValue> listvalue = entityConntext.SensorValues.Where(ent => ent.SensorID == idsen).ToList(); DataSourcePointList dsp = new DataSourcePointList(); dsp.DataSource = listvalue; if (!showCalcValue) { dsp.YDataMember = "RawValue"; } if (showCalcValue) { dsp.YDataMember = "CalcValue"; } dsp.XDataMember = "MeaTime"; mycurve = myPane.AddCurve(sensorsInGroup[i].Name, dsp, Color.FromArgb(randomGen.Next(255), randomGen.Next(255), randomGen.Next(255))); mycurve.Line.Width = 1; } } //lenh hien thi chart zedChartMain.IsShowPointValues = true; zedChartMain.AxisChange(); zedChartMain.Invalidate(); zedChartMain.Refresh(); }
public void Validate(PictureView obj) { if (!obj.Name.IsValidLength(1, 200)) throw new Exception(Resources.Error_PictureNameInvalid); if (!obj.Description.IsValidLength(-1, 500)) throw new Exception(Resources.Error_PictureDescriptionInvalid); }
public bool Update(PictureView obj) { using (var entityConntext = new GeoViewerEntities()) { SecurityBLL.Current.CheckPermissionThrowException(new string[] { SecurityBLL.ROLE_VIEWS_EDIT, SecurityBLL.ROLE_VIEWS_MANAGE }); Validate(obj); obj.LastEditedDate = DateTime.Now; obj.LastEditedUser = AppContext.Current.LogedInUser.Username; entityConntext.AttachUpdatedObject(obj); return entityConntext.SaveChanges() > 0; } }
public bool Insert(PictureView obj) { using (var entityConntext = new GeoViewerEntities()) { SecurityBLL.Current.CheckPermissionThrowException(SecurityBLL.ROLE_VIEWS_MANAGE); Validate(obj); obj.ProjectID = AppContext.Current.OpenProject.ProjectID; obj.CreatedDate = obj.LastEditedDate = DateTime.Now; obj.CreatedUser = obj.LastEditedUser = AppContext.Current.LogedInUser.Username; entityConntext.PictureViews.AddObject(obj); return entityConntext.SaveChanges() > 0; } }
/// <summary> /// Get list of sensors which displayed in this picture view /// </summary> /// <param name="pictureView"></param> /// <returns></returns> public List<Sensor> GetSensorsInPictureView(PictureView pictureView) { using (var entityContext = new GeoViewerEntities()) { var sensors = new List<Sensor>(); foreach (var obj in entityContext.Objects.Where(ent => ent.PictureViewID == pictureView.PictureViewID && ent.Type != OBJECT_TYPE_GROUP_INDICATOR && ent.Type != OBJECT_TYPE_IMAGE)) { var sensor = SensorBLL.Current.GetByID(obj.Parameters.ToInt32TryParse()); if (sensor != null && !sensors.Contains(sensor)) sensors.Add(sensor); } return sensors; } }
public List<int> GetParentPictureIDs(PictureView pictureView) { var parentIDs = new List<int>(); return parentIDs; }
private void ChartGridView_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) return; // Modify by binhpro 19/10/2012 int id = ChartGridView.Rows[e.RowIndex].Cells[0].Value.ToInt32TryParse(); if (combochart.SelectedIndex == 0) { _sensor = SensorBLL.Current.GetByID(id); _group = null; _pictureView = null; } else if (combochart.SelectedIndex == 1) { _group = ChartViewBLL.Current.GetGroupByID(id); _sensor = null; _pictureView = null; } else if (combochart.SelectedIndex == 2) { _pictureView = PictureViewBLL.Current.GetByID(id); _sensor = null; _group = null; } BindingData(); }
/// <summary> /// Deprecated Method for adding a new object to the PictureViews EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToPictureViews(PictureView pictureView) { base.AddObject("PictureViews", pictureView); }
/// <summary> /// Create a new PictureView object. /// </summary> /// <param name="pictureViewID">Initial value of the PictureViewID property.</param> public static PictureView CreatePictureView(global::System.Int32 pictureViewID) { PictureView pictureView = new PictureView(); pictureView.PictureViewID = pictureViewID; return pictureView; }
private void BindingGrid() { try { _startDate = fromdateTextBox.Text.ToDateTimeTryParse(null); _endDate = todateTextBox.Text.ToDateTimeTryParse(null); _showCalcValue = calcRadio.Checked; if (choiseTab.SelectedTab == sensorTab && sensorGridView.SelectedRows.Count > 0) { _sensors = new List<Sensor>(); _group = null; _pictureView = null; for (int i = 0; i < sensorGridView.SelectedRows.Count; i++) { _sensors.Add(SensorBLL.Current.GetByID(sensorGridView.SelectedRows[sensorGridView.SelectedRows.Count - 1 - i].Cells["SensorID"].Value.ToInt32TryParse())); } } else if (choiseTab.SelectedTab == groupTab) { if (groupGridView.SelectedRows.Count > 0) { _group = ChartViewBLL.Current.GetGroupByID(groupGridView.SelectedRows[0].Cells["GroupID"].Value.ToInt32TryParse()); _pictureView = null; } } else if (choiseTab.SelectedTab == pictureTab) { if (pictureGridView.SelectedRows.Count > 0) { _pictureView = PictureViewBLL.Current.GetByID(pictureGridView.SelectedRows[0].Cells["PictureViewID"].Value.ToInt32TryParse()); _group = null; } } if (_group != null) { _sensors = entityConntext.Groups.SingleOrDefault(ent => ent.GroupID == _group.GroupID).Sensors.ToList(); } if (_pictureView != null) { _sensors = PictureViewBLL.Current.GetSensorsInPictureView(_pictureView); } if(_sensors !=null && _sensors.Count > 0) { _sensors = _sensors.OrderBy(ent => ent.ColumnIndex).ToList(); dataGridView.DataSource = TextViewBLL.Current.BindToDataTable(_sensors, !_showCalcValue, _startDate, _endDate); } } catch (Exception exception) { //ShowErrorMessage(exception.Message); Console.WriteLine(exception.ToString()); } }