コード例 #1
0
        private void gaugeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                GeoViewer.Models.Object obj = new Models.Object();
                obj.PictureViewID = _pictureView.PictureViewID;
                obj.Type = 4;
                obj.X = 50; obj.Y = 50;
                obj.Width = 100;
                obj.Height = 100;
                obj.Parameters = "0";
                obj.Z_Index = 1;
                if (entityConntext.Objects.
                    Where(ent => ent.PictureViewID == _pictureView.PictureViewID).OrderByDescending(ent => ent.Z_Index).Count() > 0)
                {
                    var topObject = entityConntext.Objects.
                        Where(ent => ent.PictureViewID == _pictureView.PictureViewID).OrderByDescending(ent => ent.Z_Index).First();
                    obj.Z_Index = topObject.Z_Index + 1;
                }
                obj.CreatedDate = DateTime.Now;
                obj.CreatedUser = AppContext.Current.LogedInUser.ToString();
                if (PictureViewBLL.Current.InsertObject(obj))
                {
                    Console.WriteLine("Insert Object Success, ID: " + obj.ObjectID);
                    PictureViewBLL.Current.Update(_pictureView);

                    Dundas.Gauges.WinControl.GaugeContainer gaugeContainer = new Dundas.Gauges.WinControl.GaugeContainer();
                    Dundas.Gauges.WinControl.CircularGauge circularGauge = new Dundas.Gauges.WinControl.CircularGauge();
                    Dundas.Gauges.WinControl.CircularPointer circularPointer = new Dundas.Gauges.WinControl.CircularPointer();
                    Dundas.Gauges.WinControl.CircularScale circularScale = new Dundas.Gauges.WinControl.CircularScale();
                    Dundas.Gauges.WinControl.GaugeLabel gaugeLabel = new Dundas.Gauges.WinControl.GaugeLabel();

                    gaugeContainer.BackFrame.BackColor = System.Drawing.Color.Transparent;
                    gaugeContainer.BackFrame.BackGradientEndColor = System.Drawing.Color.Transparent;
                    gaugeContainer.BackFrame.BackGradientType = Dundas.Gauges.WinControl.GradientType.None;
                    gaugeContainer.BackFrame.FrameColor = System.Drawing.Color.Transparent;
                    gaugeContainer.BackFrame.FrameGradientEndColor = System.Drawing.Color.Transparent;
                    gaugeContainer.BackFrame.FrameGradientType = Dundas.Gauges.WinControl.GradientType.None;
                    gaugeContainer.BackFrame.FrameShape = Dundas.Gauges.WinControl.BackFrameShape.AutoShape;
                    gaugeContainer.BackFrame.FrameStyle = Dundas.Gauges.WinControl.BackFrameStyle.Edged;
                    gaugeContainer.BackFrame.FrameWidth = 0F;
                    circularGauge.BackFrame.BackColor = System.Drawing.Color.White;
                    circularGauge.BackFrame.BackGradientEndColor = System.Drawing.Color.White;
                    circularGauge.BackFrame.BackGradientType = Dundas.Gauges.WinControl.GradientType.None;
                    circularGauge.BackFrame.BorderColor = System.Drawing.Color.Gray;
                    circularGauge.BackFrame.BorderWidth = 2;
                    circularGauge.BackFrame.FrameColor = System.Drawing.Color.Transparent;
                    circularGauge.BackFrame.FrameGradientEndColor = System.Drawing.Color.Transparent;
                    circularGauge.BackFrame.FrameGradientType = Dundas.Gauges.WinControl.GradientType.None;
                    circularGauge.BackFrame.FrameShape = Dundas.Gauges.WinControl.BackFrameShape.Rectangular;
                    circularGauge.BackFrame.FrameStyle = Dundas.Gauges.WinControl.BackFrameStyle.Simple;
                    circularGauge.BackFrame.FrameWidth = 0F;
                    circularGauge.Location.X = 0F;
                    circularGauge.Location.Y = 0F;
                    circularGauge.Name = "Default";
                    circularGauge.PivotPoint.X = 50F;
                    circularGauge.PivotPoint.Y = 45F;
                    circularPointer.BorderStyle = Dundas.Gauges.WinControl.GaugeDashStyle.Solid;
                    circularPointer.BorderWidth = 0;
                    circularPointer.CapFillColor = System.Drawing.Color.DimGray;
                    circularPointer.CapFillGradientType = Dundas.Gauges.WinControl.GradientType.None;
                    circularPointer.CapWidth = 24F;
                    circularPointer.FillColor = System.Drawing.Color.Lime;
                    circularPointer.FillGradientEndColor = System.Drawing.Color.LightGray;
                    circularPointer.FillGradientType = Dundas.Gauges.WinControl.GradientType.None;
                    circularPointer.Name = "Default";
                    circularPointer.NeedleStyle = Dundas.Gauges.WinControl.NeedleStyle.NeedleStyle11;
                    circularPointer.ShadowOffset = 0F;
                    circularPointer.Width = 10F;
                    circularPointer.Value = 0;
                    circularGauge.Pointers.Add(circularPointer);
                    circularScale.BorderColor = System.Drawing.Color.White;
                    circularScale.BorderWidth = 1;
                    circularScale.FillColor = System.Drawing.Color.Black;
                    circularScale.LabelStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 16.30189F);
                    circularScale.LabelStyle.RotateLabels = false;
                    circularScale.MajorTickMark.BorderWidth = 0;
                    circularScale.MajorTickMark.FillColor = System.Drawing.Color.Black;
                    circularScale.MajorTickMark.Shape = Dundas.Gauges.WinControl.MarkerStyle.Rectangle;
                    circularScale.MajorTickMark.Width = 2F;
                    circularScale.MinorTickMark.BorderWidth = 0;
                    circularScale.MinorTickMark.FillColor = System.Drawing.Color.Black;
                    circularScale.MinorTickMark.Width = 1.5F;
                    circularScale.Minimum = 0D;
                    circularScale.Maximum = 100D;
                    circularScale.Name = "Default";
                    circularScale.Radius = 44F;
                    circularScale.ShadowOffset = 0F;
                    circularScale.StartAngle = 30F;
                    circularScale.SweepAngle = 300F;
                    circularScale.Width = 0F;
                    circularGauge.Scales.Add(circularScale);
                    circularGauge.Size.Height = 100F;
                    circularGauge.Size.Width = 100F;
                    gaugeContainer.CircularGauges.Add(circularGauge);
                    gaugeContainer.InternalBackgroundPaint = false;
                    gaugeLabel.BackColor = System.Drawing.Color.Empty;
                    gaugeLabel.BackGradientEndColor = System.Drawing.Color.Empty;
                    gaugeLabel.Location.X = 19F;
                    gaugeLabel.Location.Y = 80F;
                    gaugeLabel.Name = "Default";
                    gaugeLabel.Parent = "CircularGauges.Default";
                    gaugeLabel.Size.Height = 18F;
                    gaugeLabel.Size.Width = 66F;
                    gaugeLabel.Text = "";
                    gaugeLabel.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
                    gaugeContainer.Labels.Add(gaugeLabel);
                    gaugeContainer.Location = new System.Drawing.Point(50, 50);
                    gaugeContainer.Name = obj.ObjectID.ToString();
                    gaugeContainer.Size = new System.Drawing.Size(100, 100);
                    gaugeContainer.TabIndex = 0;

                    gaugeContainer.Location = new System.Drawing.Point(50, 50);
                    gaugeContainer.Size = new Size(100, 100);
                    gaugeContainer.AccessibleName = obj.ObjectID.ToString();
                    gaugeContainer.AccessibleDescription = "4";

                    this.panel.Controls.Add(gaugeContainer);
                    gaugeContainer.BringToFront();
                    ControlMouseMoveEventRegister(gaugeContainer);
                    pb.WireControl(gaugeContainer);
                }
            }
            catch (Exception exception)
            {
                ShowErrorMessage(exception.Message);
            }
        }
コード例 #2
0
        private void LoadPicture(Models.PictureView pictureView)
        {
            try
            {
                panel.Controls.Clear();
                this.Text = pictureView.Name;
                // Linq to entities
                var objectlist = entityConntext.Objects.Where(ent => ent.PictureViewID == pictureView.PictureViewID).OrderBy(ent => ent.Z_Index);
                foreach (GeoViewer.Models.Object obj in objectlist)
                {
                    switch (obj.Type)
                    {
                        case 1: // Indicator
                            // Indicator Intitialization
                            indicator ind = new indicator();
                            ind.Location = new System.Drawing.Point(obj.X, obj.Y);
                            ind.Size = new System.Drawing.Size(obj.Width, obj.Height);
                            ind.FillColor = System.Drawing.Color.Lime;
                            ind.AccessibleName = obj.ObjectID.ToString();
                            ind.AccessibleDescription = "1";
                            // Get sensor name + unit + value
                            int sensorId = Convert.ToInt32(obj.Parameters);
                            var sensor = SensorBLL.Current.GetByID(sensorId);
                            Models.SensorValue sensorValue = new SensorValue();
                            if (sensor != null)
                            {
                                // Associate with sensor
                                // Add tooltip display description - binhpro 27/02/2013
                                if (!string.IsNullOrEmpty(sensor.Description))
                                {
                                    toolTip1.SetToolTip(ind, "Công thức: " + sensor.FormulaFunction + "\n" + sensor.Description);
                                }

                                ind.VarName = sensor.Name;
                                ind.UnitName = sensor.Unit;
                                if (entityConntext.SensorValues.
                                    Where(ent => ent.SensorID == sensorId).OrderByDescending(ent => ent.MeaTime).Count() > 0)
                                {
                                    sensorValue = entityConntext.SensorValues.
                                        Where(ent => ent.SensorID == sensorId).OrderByDescending(ent => ent.MeaTime).First();
                                    ind.Value = getDisplayValue(sensorValue);
                                    // Check if value is in alarm level
                                    if (PictureViewBLL.Current.CheckAlarmRunning(obj)) ind.FillColor = System.Drawing.Color.Red;
                                }
                            }
                            // Add to picture
                            this.panel.Controls.Add(ind);
                            ind.BringToFront();
                            break;
                        case 2: // Group Indicator
                            // Group Indicator Initialization
                            groupIndicator i = new groupIndicator();
                            i.Location = new System.Drawing.Point(obj.X, obj.Y);
                            i.Size = new System.Drawing.Size(obj.Width, obj.Height);
                            i.FillColor = System.Drawing.Color.Lime;
                            i.BackColor = System.Drawing.Color.Transparent;
                            i.AccessibleName = obj.ObjectID.ToString();
                            i.AccessibleDescription = "2";
                            // Check if value is in alarm level
                            //int idPicture = Convert.ToInt32(obj.Parameters);
                            //var subObjectList = entityConntext.Objects.
                            //    Where(ent => ent.PictureViewID == idPicture);
                            //foreach (GeoViewer.Models.Object subObject in subObjectList)
                            //{
                            //    if (PictureViewBLL.Current.CheckAlarmRunning(subObject))
                            //    {
                            //        i.FillColor = Color.Red;
                            //        break;
                            //    }
                            //}

                            //Edited By binhpro 18/10/2012
                            if (PictureViewBLL.Current.CheckAlarmRunning(obj))
                            {
                                i.FillColor = Color.Red;
                            }

                            // Add to picture
                            this.panel.Controls.Add(i);
                            i.BringToFront();
                            break;
                        case 3: // Image
                            // Image Initialization
                            System.Windows.Forms.PictureBox newpicture = new System.Windows.Forms.PictureBox();
                            newpicture.Location = new System.Drawing.Point(obj.X, obj.Y);
                            newpicture.ImageLocation = obj.Parameters;
                            newpicture.Size = new System.Drawing.Size(obj.Width, obj.Height);
                            newpicture.SizeMode = PictureBoxSizeMode.StretchImage;
                            newpicture.AccessibleName = obj.ObjectID.ToString();
                            newpicture.AccessibleDescription = "3";
                            // Add to picture
                            this.panel.Controls.Add(newpicture);
                            newpicture.BringToFront();
                            break;
                        case 4: // Gauge
                            // Gauge Initilization
                            Dundas.Gauges.WinControl.GaugeContainer gaugeContainer = new Dundas.Gauges.WinControl.GaugeContainer();
                            Dundas.Gauges.WinControl.CircularGauge circularGauge = new Dundas.Gauges.WinControl.CircularGauge();
                            Dundas.Gauges.WinControl.CircularPointer circularPointer = new Dundas.Gauges.WinControl.CircularPointer();
                            Dundas.Gauges.WinControl.CircularScale circularScale = new Dundas.Gauges.WinControl.CircularScale();
                            Dundas.Gauges.WinControl.GaugeLabel gaugeLabel = new Dundas.Gauges.WinControl.GaugeLabel();
                            gaugeContainer.BackFrame.BackColor = System.Drawing.Color.Transparent;
                            gaugeContainer.BackFrame.BackGradientEndColor = System.Drawing.Color.Transparent;
                            gaugeContainer.BackFrame.BackGradientType = Dundas.Gauges.WinControl.GradientType.None;
                            gaugeContainer.BackFrame.FrameColor = System.Drawing.Color.Transparent;
                            gaugeContainer.BackFrame.FrameGradientEndColor = System.Drawing.Color.Transparent;
                            gaugeContainer.BackFrame.FrameGradientType = Dundas.Gauges.WinControl.GradientType.None;
                            gaugeContainer.BackFrame.FrameShape = Dundas.Gauges.WinControl.BackFrameShape.AutoShape;
                            gaugeContainer.BackFrame.FrameStyle = Dundas.Gauges.WinControl.BackFrameStyle.Edged;
                            gaugeContainer.BackFrame.FrameWidth = 0F;
                            circularGauge.BackFrame.BackColor = System.Drawing.Color.White;
                            circularGauge.BackFrame.BackGradientEndColor = System.Drawing.Color.White;
                            circularGauge.BackFrame.BackGradientType = Dundas.Gauges.WinControl.GradientType.None;
                            circularGauge.BackFrame.BorderColor = System.Drawing.Color.Gray;
                            circularGauge.BackFrame.BorderWidth = 2;
                            circularGauge.BackFrame.FrameColor = System.Drawing.Color.Transparent;
                            circularGauge.BackFrame.FrameGradientEndColor = System.Drawing.Color.Transparent;
                            circularGauge.BackFrame.FrameGradientType = Dundas.Gauges.WinControl.GradientType.None;
                            circularGauge.BackFrame.FrameShape = Dundas.Gauges.WinControl.BackFrameShape.Rectangular;
                            circularGauge.BackFrame.FrameStyle = Dundas.Gauges.WinControl.BackFrameStyle.Simple;
                            circularGauge.BackFrame.FrameWidth = 0F;
                            circularGauge.Location.X = 0F;
                            circularGauge.Location.Y = 0F;
                            circularGauge.Name = "Default";
                            circularGauge.PivotPoint.X = 50F;
                            circularGauge.PivotPoint.Y = 45F;
                            circularPointer.BorderStyle = Dundas.Gauges.WinControl.GaugeDashStyle.Solid;
                            circularPointer.BorderWidth = 0;
                            circularPointer.CapFillColor = System.Drawing.Color.DimGray;
                            circularPointer.CapFillGradientType = Dundas.Gauges.WinControl.GradientType.None;
                            circularPointer.CapWidth = 24F;
                            circularPointer.FillColor = System.Drawing.Color.Lime;
                            circularPointer.FillGradientEndColor = System.Drawing.Color.LightGray;
                            circularPointer.FillGradientType = Dundas.Gauges.WinControl.GradientType.None;
                            circularPointer.Name = "Default";
                            circularPointer.NeedleStyle = Dundas.Gauges.WinControl.NeedleStyle.NeedleStyle11;
                            circularPointer.ShadowOffset = 0F;
                            circularPointer.Width = 10F;
                            circularGauge.Pointers.Add(circularPointer);
                            circularScale.BorderColor = System.Drawing.Color.White;
                            circularScale.BorderWidth = 1;
                            circularScale.FillColor = System.Drawing.Color.Black;
                            circularScale.LabelStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 16.30189F);
                            circularScale.LabelStyle.RotateLabels = false;
                            circularScale.MajorTickMark.BorderWidth = 0;
                            circularScale.MajorTickMark.FillColor = System.Drawing.Color.Black;
                            circularScale.MajorTickMark.Shape = Dundas.Gauges.WinControl.MarkerStyle.Rectangle;
                            circularScale.MajorTickMark.Width = 2F;
                            circularScale.MinorTickMark.BorderWidth = 0;
                            circularScale.MinorTickMark.FillColor = System.Drawing.Color.Black;
                            circularScale.MinorTickMark.Width = 1.5F;
                            circularScale.Name = "Default";
                            circularScale.Radius = 44F;
                            circularScale.ShadowOffset = 0F;
                            circularScale.StartAngle = 30F;
                            circularScale.SweepAngle = 300F;
                            circularScale.Width = 0F;
                            circularScale.Minimum = 0D;
                            circularScale.Maximum = 100D;
                            circularGauge.Scales.Add(circularScale);
                            circularGauge.Size.Height = 100F;
                            circularGauge.Size.Width = 100F;
                            circularGauge.Pointers["Default"].Value = 0;
                            gaugeContainer.CircularGauges.Add(circularGauge);
                            gaugeContainer.InternalBackgroundPaint = false;
                            gaugeLabel.BackColor = System.Drawing.Color.Empty;
                            gaugeLabel.BackGradientEndColor = System.Drawing.Color.Empty;
                            gaugeLabel.Location.X = 19F;
                            gaugeLabel.Location.Y = 80F;
                            gaugeLabel.Name = "Default";
                            gaugeLabel.Parent = "CircularGauges.Default";
                            gaugeLabel.Size.Height = 18F;
                            gaugeLabel.Size.Width = 66F;
                            gaugeLabel.Text = "";
                            gaugeLabel.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
                            gaugeContainer.Labels.Add(gaugeLabel);

                            gaugeContainer.Location = new Point(obj.X, obj.Y);
                            gaugeContainer.Size = new System.Drawing.Size(obj.Width, obj.Height);
                            gaugeContainer.AccessibleName = obj.ObjectID.ToString();
                            gaugeContainer.AccessibleDescription = "4";
                            // Get sensor name + unit + value
                            sensorId = Convert.ToInt32(obj.Parameters);
                            sensor = SensorBLL.Current.GetByID(sensorId);
                            if (sensor != null)
                            {
                                // Associate with sensor
                                // Add tooltip display description - binhpro 27/02/2013
                                if (!string.IsNullOrEmpty(sensor.Description))
                                {
                                    toolTip1.SetToolTip(gaugeContainer, "Công thức: " + sensor.FormulaFunction + "\n" + sensor.Description);
                                }
                                gaugeLabel.Text = sensor.Name + "\n" + sensor.Unit;
                                if (sensor.MaxValue != null) circularScale.Maximum = System.Convert.ToDouble(sensor.MaxValue);
                                if (sensor.MinValue != null) circularScale.Minimum = System.Convert.ToDouble(sensor.MinValue);
                                // Read latest value (if exists)
                                if (entityConntext.SensorValues.
                                    Where(ent => ent.SensorID == sensorId).OrderByDescending(ent => ent.MeaTime).Count() != 0)
                                {
                                    sensorValue = entityConntext.SensorValues.
                                        Where(ent => ent.SensorID == sensorId).OrderByDescending(ent => ent.MeaTime).First();
                                    if (sensor.MaxValue == null)
                                        circularScale.Maximum = Math.Round(System.Convert.ToDouble(getSensorValue(sensorValue)) + 1D, 0);
                                    if (sensor.MinValue == null)
                                        circularScale.Minimum = Math.Round(System.Convert.ToDouble(getSensorValue(sensorValue)) - 1D, 0);
                                    gaugeContainer.CircularGauges["Default"].Pointers["Default"].Value = System.Convert.ToDouble(getSensorValue(sensorValue));
                                    gaugeLabel.Text = sensor.Name + "\n" + getDisplayValue(sensorValue) + " " + sensor.Unit;
                                    // Check if value is in alarm level
                                    if (PictureViewBLL.Current.CheckAlarmRunning(obj))
                                        circularPointer.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(188)))), ((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
                                }
                            }
                            // Add to picture
                            this.panel.Controls.Add(gaugeContainer);
                            gaugeContainer.BringToFront();
                            break;
                        case 5: // Vertical Bar
                            // Vertical Bar Initilization
                            Dundas.Gauges.WinControl.LinearGauge linearGauge1 = new Dundas.Gauges.WinControl.LinearGauge();
                            Dundas.Gauges.WinControl.LinearPointer linearPointer1 = new Dundas.Gauges.WinControl.LinearPointer();
                            Dundas.Gauges.WinControl.LinearScale linearScale1 = new Dundas.Gauges.WinControl.LinearScale();
                            Dundas.Gauges.WinControl.GaugeContainer gaugeContainer1 = new Dundas.Gauges.WinControl.GaugeContainer();
                            Dundas.Gauges.WinControl.GaugeLabel gaugeLabel1 = new Dundas.Gauges.WinControl.GaugeLabel();
                            gaugeContainer1.BackFrame.BackColor = System.Drawing.Color.White;
                            gaugeContainer1.BackFrame.BackGradientEndColor = System.Drawing.Color.FromArgb(((int)(((byte)(26)))), ((int)(((byte)(59)))), ((int)(((byte)(105)))));
                            gaugeContainer1.BackFrame.BackGradientType = Dundas.Gauges.WinControl.GradientType.None;
                            gaugeContainer1.BackFrame.FrameGradientEndColor = System.Drawing.Color.DimGray;
                            gaugeContainer1.BackFrame.FrameGradientType = Dundas.Gauges.WinControl.GradientType.None;
                            gaugeContainer1.BackFrame.FrameShape = Dundas.Gauges.WinControl.BackFrameShape.Rectangular;
                            gaugeContainer1.BackFrame.FrameStyle = Dundas.Gauges.WinControl.BackFrameStyle.None;
                            gaugeContainer1.BackFrame.FrameWidth = 2F;
                            gaugeContainer1.InternalBackgroundPaint = false;
                            gaugeContainer1.LinearGauges.Add(linearGauge1);
                            gaugeLabel1.BackColor = System.Drawing.Color.Empty;
                            gaugeLabel1.BackGradientEndColor = System.Drawing.Color.Empty;
                            gaugeLabel1.Location.X = 14.27777F;
                            gaugeLabel1.Location.Y = 87.39495F;
                            gaugeLabel1.Name = "Default";
                            gaugeLabel1.Parent = "LinearGauges.Default";
                            gaugeLabel1.Size.Height = 14F;
                            gaugeLabel1.Size.Width = 72F;
                            gaugeLabel1.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
                            gaugeLabel1.Text = "";
                            gaugeContainer1.Labels.Add(gaugeLabel1);
                            linearGauge1.BackFrame.BackColor = System.Drawing.Color.White;
                            linearGauge1.BackFrame.BackGradientEndColor = System.Drawing.Color.DimGray;
                            linearGauge1.BackFrame.BackGradientType = Dundas.Gauges.WinControl.GradientType.None;
                            linearGauge1.BackFrame.FrameColor = System.Drawing.Color.Silver;
                            linearGauge1.BackFrame.FrameShape = Dundas.Gauges.WinControl.BackFrameShape.Rectangular;
                            linearGauge1.BackFrame.FrameStyle = Dundas.Gauges.WinControl.BackFrameStyle.Edged;
                            linearGauge1.BackFrame.FrameWidth = 1F;
                            linearGauge1.Location.X = 0F;
                            linearGauge1.Location.Y = 0F;
                            linearGauge1.Name = "Default";
                            linearGauge1.Orientation = Dundas.Gauges.WinControl.GaugeOrientation.Vertical;
                            linearPointer1.BorderWidth = 0;
                            linearPointer1.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(188)))), ((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0)))));
                            linearPointer1.FillGradientEndColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0)))));
                            linearPointer1.FillGradientType = Dundas.Gauges.WinControl.GradientType.None;
                            linearPointer1.Name = "Default";
                            linearPointer1.Placement = Dundas.Gauges.WinControl.Placement.Cross;
                            linearPointer1.ShadowOffset = 0F;
                            linearPointer1.ThermometerBackColor = System.Drawing.Color.Empty;
                            linearPointer1.ThermometerBackGradientEndColor = System.Drawing.Color.Empty;
                            linearPointer1.Type = Dundas.Gauges.WinControl.LinearPointerType.Bar;
                            linearPointer1.Width = 15F;
                            linearGauge1.Pointers.Add(linearPointer1);
                            linearScale1.Minimum = 0D;
                            linearScale1.Maximum = 100D;
                            linearScale1.EndMargin = 6F;
                            linearScale1.FillColor = System.Drawing.Color.Black;
                            linearScale1.LabelStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.18868F);
                            linearScale1.LabelStyle.FontUnit = Dundas.Gauges.WinControl.FontUnit.Default;
                            linearScale1.MajorTickMark.BorderWidth = 0;
                            linearScale1.MajorTickMark.FillColor = System.Drawing.Color.Black;
                            linearScale1.MajorTickMark.Length = 19F;
                            linearScale1.MajorTickMark.Width = 2F;
                            linearScale1.MinorTickMark.BorderWidth = 0;
                            linearScale1.MinorTickMark.FillColor = System.Drawing.Color.Black;
                            linearScale1.MinorTickMark.Length = 10F;
                            linearScale1.MinorTickMark.Width = 1.5F;
                            linearScale1.Name = "Default";
                            linearScale1.Position = 65F;
                            linearScale1.ShadowOffset = 0F;
                            linearScale1.StartMargin = 15F;
                            linearScale1.Width = 0F;
                            linearScale1.Maximum = 100D;
                            linearScale1.Minimum = 0D;
                            linearGauge1.Scales.Add(linearScale1);
                            linearGauge1.Size.Height = 100F;
                            linearGauge1.Size.Width = 100F;
                            gaugeContainer1.LinearGauges["Default"].Pointers["Default"].Value = 0;

                            gaugeContainer1.Location = new Point(obj.X, obj.Y);
                            gaugeContainer1.Size = new System.Drawing.Size(obj.Width, obj.Height);
                            gaugeContainer1.AccessibleName = obj.ObjectID.ToString();
                            gaugeContainer1.AccessibleDescription = "5";
                            // Get sensor name + unit + value
                            sensorId = Convert.ToInt32(obj.Parameters);
                            sensor = SensorBLL.Current.GetByID(sensorId);
                            if (sensor != null)
                            {
                                // Associate with sensor
                                // Add tooltip display description - binhpro 27/02/2013
                                if (!string.IsNullOrEmpty(sensor.Description))
                                {
                                    toolTip1.SetToolTip(gaugeContainer1, "Công thức: " + sensor.FormulaFunction + "\n" + sensor.Description);
                                }
                                gaugeLabel1.Text = sensor.Name + "\n" + sensor.Unit;
                                if (sensor.MaxValue != null) linearScale1.Maximum = System.Convert.ToDouble(sensor.MaxValue);
                                if (sensor.MinValue != null) linearScale1.Minimum = System.Convert.ToDouble(sensor.MinValue);
                                // Read latest value (if exists)
                                if (entityConntext.SensorValues.
                                    Where(ent => ent.SensorID == sensorId).OrderByDescending(ent => ent.MeaTime).Count() != 0)
                                {
                                    sensorValue = entityConntext.SensorValues.
                                        Where(ent => ent.SensorID == sensorId).OrderByDescending(ent => ent.MeaTime).First();
                                    if (sensor.MaxValue == null)
                                        linearScale1.Maximum = Math.Round(System.Convert.ToDouble(getSensorValue(sensorValue)) + 1D, 0);
                                    if (sensor.MinValue == null)
                                        linearScale1.Minimum = Math.Round(System.Convert.ToDouble(getSensorValue(sensorValue)) - 1D, 0);
                                    gaugeContainer1.LinearGauges["Default"].Pointers["Default"].Value = System.Convert.ToDouble(getSensorValue(sensorValue));
                                    gaugeLabel1.Text = sensor.Name + "\n" + getSensorValue(sensorValue).ToString() + " " + sensor.Unit;
                                    // Check if value is in alarm level
                                    if (PictureViewBLL.Current.CheckAlarmRunning(obj))
                                        linearPointer1.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(188)))), ((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
                                }
                            }
                            // Add to picture
                            this.panel.Controls.Add(gaugeContainer1);
                            gaugeContainer1.BringToFront();
                            break;
                        case 6: // Horizontal Bar
                            // Horizontal Bar Initilization
                            linearGauge1 = new Dundas.Gauges.WinControl.LinearGauge();
                            linearPointer1 = new Dundas.Gauges.WinControl.LinearPointer();
                            linearScale1 = new Dundas.Gauges.WinControl.LinearScale();
                            gaugeContainer1 = new Dundas.Gauges.WinControl.GaugeContainer();
                            gaugeLabel1 = new Dundas.Gauges.WinControl.GaugeLabel();
                            gaugeContainer1.BackFrame.BackColor = System.Drawing.Color.White;
                            gaugeContainer1.BackFrame.BackGradientEndColor = System.Drawing.Color.FromArgb(((int)(((byte)(26)))), ((int)(((byte)(59)))), ((int)(((byte)(105)))));
                            gaugeContainer1.BackFrame.BackGradientType = Dundas.Gauges.WinControl.GradientType.None;
                            gaugeContainer1.BackFrame.FrameGradientEndColor = System.Drawing.Color.DimGray;
                            gaugeContainer1.BackFrame.FrameGradientType = Dundas.Gauges.WinControl.GradientType.None;
                            gaugeContainer1.BackFrame.FrameShape = Dundas.Gauges.WinControl.BackFrameShape.Rectangular;
                            gaugeContainer1.BackFrame.FrameStyle = Dundas.Gauges.WinControl.BackFrameStyle.None;
                            gaugeContainer1.BackFrame.FrameWidth = 2F;
                            gaugeContainer1.InternalBackgroundPaint = false;
                            gaugeContainer1.LinearGauges.Add(linearGauge1);
                            gaugeLabel1.BackColor = System.Drawing.Color.Empty;
                            gaugeLabel1.BackGradientEndColor = System.Drawing.Color.Empty;
                            gaugeLabel1.Location.X = 32F;
                            gaugeLabel1.Location.Y = 62F;
                            gaugeLabel1.Name = "Default";
                            gaugeLabel1.Parent = "LinearGauges.Default";
                            gaugeLabel1.Size.Height = 34F;
                            gaugeLabel1.Size.Width = 39F;
                            gaugeLabel1.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
                            gaugeLabel1.Text = "";
                            gaugeContainer1.Labels.Add(gaugeLabel1);
                            linearGauge1.BackFrame.BackColor = System.Drawing.Color.White;
                            linearGauge1.BackFrame.BackGradientEndColor = System.Drawing.Color.DimGray;
                            linearGauge1.BackFrame.BackGradientType = Dundas.Gauges.WinControl.GradientType.None;
                            linearGauge1.BackFrame.FrameColor = System.Drawing.Color.Silver;
                            linearGauge1.BackFrame.FrameShape = Dundas.Gauges.WinControl.BackFrameShape.Rectangular;
                            linearGauge1.BackFrame.FrameStyle = Dundas.Gauges.WinControl.BackFrameStyle.Edged;
                            linearGauge1.BackFrame.FrameWidth = 2F;
                            linearGauge1.Location.X = 0F;
                            linearGauge1.Location.Y = 0F;
                            linearGauge1.Name = "Default";
                            linearGauge1.Orientation = Dundas.Gauges.WinControl.GaugeOrientation.Horizontal;
                            linearPointer1.BorderWidth = 0;
                            linearPointer1.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(188)))), ((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0)))));
                            linearPointer1.FillGradientEndColor = System.Drawing.Color.FromArgb(((int)(((byte)(182)))), ((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0)))));
                            linearPointer1.FillGradientType = Dundas.Gauges.WinControl.GradientType.None;
                            linearPointer1.Name = "Default";
                            linearPointer1.ShadowOffset = 0F;
                            linearPointer1.ThermometerBackColor = System.Drawing.Color.Empty;
                            linearPointer1.ThermometerBackGradientEndColor = System.Drawing.Color.Empty;
                            linearPointer1.Type = Dundas.Gauges.WinControl.LinearPointerType.Bar;
                            linearPointer1.Placement = Dundas.Gauges.WinControl.Placement.Cross;
                            linearPointer1.Width = 15F;
                            linearGauge1.Pointers.Add(linearPointer1);
                            linearScale1.Minimum = 0D;
                            linearScale1.Maximum = 100D;
                            linearScale1.EndMargin = 5F;
                            linearScale1.FillColor = System.Drawing.Color.Black;
                            linearScale1.LabelStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 16.30189F);
                            linearScale1.MajorTickMark.BorderWidth = 0;
                            linearScale1.MajorTickMark.FillColor = System.Drawing.Color.Black;
                            linearScale1.MajorTickMark.Length = 20F;
                            linearScale1.MajorTickMark.Width = 2F;
                            linearScale1.MinorTickMark.BorderWidth = 0;
                            linearScale1.MinorTickMark.FillColor = System.Drawing.Color.Black;
                            linearScale1.MinorTickMark.Length = 12F;
                            linearScale1.MinorTickMark.Width = 1.5F;
                            linearScale1.Name = "Default";
                            linearScale1.Position = 45F;
                            linearScale1.ShadowOffset = 0F;
                            linearScale1.StartMargin = 5F;
                            linearScale1.Width = 0F;
                            linearScale1.Maximum = 100D;
                            linearScale1.Minimum = 0D;
                            linearGauge1.Scales.Add(linearScale1);
                            linearGauge1.Size.Height = 100F;
                            linearGauge1.Size.Width = 100F;
                            gaugeContainer1.LinearGauges["Default"].Pointers["Default"].Value = 0;

                            gaugeContainer1.Location = new Point(obj.X, obj.Y);
                            gaugeContainer1.Size = new System.Drawing.Size(obj.Width, obj.Height);
                            gaugeContainer1.AccessibleName = obj.ObjectID.ToString();
                            gaugeContainer1.AccessibleDescription = "6";
                            // Get sensor name + unit + value
                            sensorId = Convert.ToInt32(obj.Parameters);
                            sensor = SensorBLL.Current.GetByID(sensorId);
                            if (sensor != null)
                            {
                                // Associate with sensor
                                // Add tooltip display description - binhpro 27/02/2013
                                if (!string.IsNullOrEmpty(sensor.Description))
                                {
                                    toolTip1.SetToolTip(gaugeContainer1, "Công thức: " + sensor.FormulaFunction + "\n" + sensor.Description);
                                }
                                gaugeLabel1.Text = sensor.Name + "\n" + sensor.Unit;
                                if (sensor.MaxValue != null) linearScale1.Maximum = System.Convert.ToDouble(sensor.MaxValue);
                                if (sensor.MinValue != null) linearScale1.Minimum = System.Convert.ToDouble(sensor.MinValue);
                                // Read latest value (if exists)
                                if (entityConntext.SensorValues.
                                    Where(ent => ent.SensorID == sensorId).OrderByDescending(ent => ent.MeaTime).Count() != 0)
                                {
                                    sensorValue = entityConntext.SensorValues.
                                        Where(ent => ent.SensorID == sensorId).OrderByDescending(ent => ent.MeaTime).First();
                                    if (sensor.MaxValue == null)
                                        linearScale1.Maximum = Math.Round(System.Convert.ToDouble(getSensorValue(sensorValue)) + 1D, 0);
                                    if (sensor.MinValue == null)
                                        linearScale1.Minimum = Math.Round(System.Convert.ToDouble(getSensorValue(sensorValue)) - 1D, 0);
                                    gaugeContainer1.LinearGauges["Default"].Pointers["Default"].Value = System.Convert.ToDouble(getSensorValue(sensorValue));
                                    gaugeLabel1.Text = sensor.Name + "\n" + getSensorValue(sensorValue).ToString() + " " + sensor.Unit;
                                    // Check if value is in alarm level
                                    if (PictureViewBLL.Current.CheckAlarmRunning(obj))
                                        linearPointer1.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(188)))), ((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
                                }
                            }
                            // Add to picture
                            this.panel.Controls.Add(gaugeContainer1);
                            gaugeContainer1.BringToFront();
                            break;
                        case 7: // Meter
                            // Meter Initilization
                            gaugeContainer = new Dundas.Gauges.WinControl.GaugeContainer();
                            circularGauge = new Dundas.Gauges.WinControl.CircularGauge();
                            circularPointer = new Dundas.Gauges.WinControl.CircularPointer();
                            circularScale = new Dundas.Gauges.WinControl.CircularScale();
                            gaugeLabel = new Dundas.Gauges.WinControl.GaugeLabel();

                            gaugeContainer.BackFrame.BackColor = System.Drawing.Color.White;
                            gaugeContainer.BackFrame.BackGradientEndColor = System.Drawing.Color.FromArgb(((int)(((byte)(26)))), ((int)(((byte)(59)))), ((int)(((byte)(105)))));
                            gaugeContainer.BackFrame.BackGradientType = Dundas.Gauges.WinControl.GradientType.None;
                            gaugeContainer.BackFrame.FrameGradientEndColor = System.Drawing.Color.DimGray;
                            gaugeContainer.BackFrame.FrameGradientType = Dundas.Gauges.WinControl.GradientType.None;
                            gaugeContainer.BackFrame.FrameShape = Dundas.Gauges.WinControl.BackFrameShape.Rectangular;
                            gaugeContainer.BackFrame.FrameStyle = Dundas.Gauges.WinControl.BackFrameStyle.None;
                            gaugeContainer.BackFrame.FrameWidth = 0F;
                            circularGauge.BackFrame.BackColor = System.Drawing.Color.White;
                            circularGauge.BackFrame.BackGradientEndColor = System.Drawing.Color.FromArgb(((int)(((byte)(26)))), ((int)(((byte)(59)))), ((int)(((byte)(105)))));
                            circularGauge.BackFrame.BackGradientType = Dundas.Gauges.WinControl.GradientType.None;
                            circularGauge.BackFrame.BorderColor = System.Drawing.Color.Gray;
                            circularGauge.BackFrame.BorderWidth = 2;
                            circularGauge.BackFrame.FrameGradientEndColor = System.Drawing.Color.DimGray;
                            circularGauge.BackFrame.FrameGradientType = Dundas.Gauges.WinControl.GradientType.None;
                            circularGauge.BackFrame.FrameShape = Dundas.Gauges.WinControl.BackFrameShape.Rectangular;
                            circularGauge.BackFrame.FrameStyle = Dundas.Gauges.WinControl.BackFrameStyle.Edged;
                            circularGauge.BackFrame.FrameWidth = 0F;
                            circularGauge.Location.X = 0F;
                            circularGauge.Location.Y = 0F;
                            circularGauge.Name = "Default";
                            circularGauge.PivotPoint.X = 50F;
                            circularGauge.PivotPoint.Y = 263F;
                            circularPointer.BorderWidth = 0;
                            circularPointer.CapFillColor = System.Drawing.Color.Silver;
                            circularPointer.CapFillGradientType = Dundas.Gauges.WinControl.GradientType.None;
                            circularPointer.CapVisible = false;
                            circularPointer.CapWidth = 30F;
                            circularPointer.FillColor = System.Drawing.Color.Lime;
                            circularPointer.FillGradientType = Dundas.Gauges.WinControl.GradientType.None;
                            circularPointer.Name = "Default";
                            circularPointer.ShadowOffset = 0F;
                            circularPointer.Width = 6.1F;
                            circularGauge.Pointers.Add(circularPointer);
                            circularScale.BorderColor = System.Drawing.Color.White;
                            circularScale.BorderWidth = 1;
                            circularScale.FillColor = System.Drawing.Color.Black;
                            circularScale.LabelStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 5F);
                            circularScale.MajorTickMark.BorderWidth = 0;
                            circularScale.MajorTickMark.FillColor = System.Drawing.Color.Black;
                            circularScale.MajorTickMark.Length = 6F;
                            circularScale.MajorTickMark.Shape = Dundas.Gauges.WinControl.MarkerStyle.Rectangle;
                            circularScale.MajorTickMark.Width = 2F;
                            circularScale.MinorTickMark.BorderWidth = 0;
                            circularScale.MinorTickMark.FillColor = System.Drawing.Color.Black;
                            circularScale.MinorTickMark.Length = 4F;
                            circularScale.MinorTickMark.Width = 1F;
                            circularScale.Name = "Default";
                            circularScale.Radius = 249F;
                            circularScale.ShadowOffset = 0F;
                            circularScale.StartAngle = 150F;
                            circularScale.SweepAngle = 60F;
                            circularScale.Width = 0F;
                            circularScale.Minimum = 0D;
                            circularScale.Maximum = 100D;
                            circularGauge.Scales.Add(circularScale);
                            circularGauge.Size.Height = 100F;
                            circularGauge.Size.Width = 100F;
                            circularPointer.Value = 0;
                            gaugeContainer.CircularGauges.Add(circularGauge);
                            gaugeContainer.InternalBackgroundPaint = false;
                            gaugeLabel.BackColor = System.Drawing.Color.Empty;
                            gaugeLabel.BackGradientEndColor = System.Drawing.Color.Empty;
                            gaugeLabel.Location.X = 25F;
                            gaugeLabel.Location.Y = 68F;
                            gaugeLabel.Name = "Default";
                            gaugeLabel.Parent = "CircularGauges.Default";
                            gaugeLabel.Size.Height = 33F;
                            gaugeLabel.Size.Width = 56F;
                            gaugeLabel.Text = "";
                            gaugeLabel.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
                            gaugeContainer.Labels.Add(gaugeLabel);

                            gaugeContainer.Location = new Point(obj.X, obj.Y);
                            gaugeContainer.Size = new System.Drawing.Size(obj.Width, obj.Height);
                            gaugeContainer.AccessibleName = obj.ObjectID.ToString();
                            gaugeContainer.AccessibleDescription = "7";
                            // Get sensor name + unit + value
                            sensorId = Convert.ToInt32(obj.Parameters);
                            sensor = SensorBLL.Current.GetByID(sensorId);
                            if (sensor != null)
                            {
                                // Associate with sensor
                                // Add tooltip display description - binhpro 27/02/2013
                                if (!string.IsNullOrEmpty(sensor.Description))
                                {
                                    toolTip1.SetToolTip(gaugeContainer, "Công thức: " + sensor.FormulaFunction + "\n" + sensor.Description);
                                }
                                gaugeLabel.Text = sensor.Name + "\n" + sensor.Unit;
                                if (sensor.MaxValue != null) circularScale.Maximum = System.Convert.ToDouble(sensor.MaxValue);
                                if (sensor.MinValue != null) circularScale.Minimum = System.Convert.ToDouble(sensor.MinValue);
                                // Read latest value (if exists)
                                if (entityConntext.SensorValues.
                                    Where(ent => ent.SensorID == sensorId).OrderByDescending(ent => ent.MeaTime).Count() != 0)
                                {
                                    sensorValue = entityConntext.SensorValues.
                                        Where(ent => ent.SensorID == sensorId).OrderByDescending(ent => ent.MeaTime).First();
                                    if (sensor.MaxValue == null)
                                        circularScale.Maximum = Math.Round(System.Convert.ToDouble(getSensorValue(sensorValue)) + 1D, 0);
                                    if (sensor.MinValue == null)
                                        circularScale.Minimum = Math.Round(System.Convert.ToDouble(getSensorValue(sensorValue)) - 1D, 0);
                                    gaugeContainer.CircularGauges["Default"].Pointers["Default"].Value = System.Convert.ToDouble(getSensorValue(sensorValue));
                                    gaugeLabel.Text = sensor.Name + "\n" + getDisplayValue(sensorValue) + " " + sensor.Unit;
                                    // Check if value is in alarm level
                                    if (PictureViewBLL.Current.CheckAlarmRunning(obj))
                                        circularPointer.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(188)))), ((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
                                }
                            }
                            // Add to picture
                            this.panel.Controls.Add(gaugeContainer);
                            gaugeContainer.BringToFront();
                            break;
                        case 8: // Numeric Indicator
                            // Numeric Indicator Initilization
                            Dundas.Gauges.WinControl.GaugeContainer gaugeContainer2 = new Dundas.Gauges.WinControl.GaugeContainer();
                            Dundas.Gauges.WinControl.GaugeLabel gaugeLabel2 = new Dundas.Gauges.WinControl.GaugeLabel();
                            Dundas.Gauges.WinControl.NumericIndicator numericIndicator = new Dundas.Gauges.WinControl.NumericIndicator();
                            gaugeContainer2.BackFrame.BackColor = System.Drawing.Color.White;
                            gaugeContainer2.BackFrame.BackGradientEndColor = System.Drawing.Color.White;
                            gaugeContainer2.BackFrame.BackGradientType = Dundas.Gauges.WinControl.GradientType.None;
                            gaugeContainer2.BackFrame.BorderWidth = 2;
                            gaugeContainer2.BackFrame.FrameGradientEndColor = System.Drawing.Color.DimGray;
                            gaugeContainer2.BackFrame.FrameGradientType = Dundas.Gauges.WinControl.GradientType.None;
                            gaugeContainer2.BackFrame.FrameShape = Dundas.Gauges.WinControl.BackFrameShape.Rectangular;
                            gaugeContainer2.BackFrame.FrameStyle = Dundas.Gauges.WinControl.BackFrameStyle.Simple;
                            gaugeContainer2.BackFrame.FrameWidth = 0F;
                            gaugeContainer2.InternalBackgroundPaint = false;
                            gaugeContainer2.NumericIndicators.Add(numericIndicator);
                            numericIndicator.BackColor = System.Drawing.Color.Transparent;
                            numericIndicator.BackGradientType = Dundas.Gauges.WinControl.GradientType.None;
                            numericIndicator.BorderColor = System.Drawing.Color.Black;
                            numericIndicator.BorderWidth = 0;
                            numericIndicator.DecimalColor = System.Drawing.Color.Black;
                            numericIndicator.Decimals = 2;
                            numericIndicator.DigitColor = System.Drawing.Color.Black;
                            numericIndicator.IndicatorStyle = Dundas.Gauges.WinControl.NumericIndicatorStyle.Digital7Segment;
                            numericIndicator.LedDimColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
                            numericIndicator.Location.X = 0F;
                            numericIndicator.Location.Y = -20F;
                            numericIndicator.Name = "Default";
                            numericIndicator.Parent = "";
                            numericIndicator.ShowDecimalPoint = true;
                            numericIndicator.Size.Height = 99F;
                            numericIndicator.Size.Width = 99F;
                            numericIndicator.Value = 0;
                            numericIndicator.Digits = 6;
                            gaugeLabel2.BackColor = System.Drawing.Color.Empty;
                            gaugeLabel2.BackGradientEndColor = System.Drawing.Color.Empty;
                            gaugeLabel2.Location.X = 26F;
                            gaugeLabel2.Location.Y = 75F;
                            gaugeLabel2.Name = "Default";
                            gaugeLabel2.Parent = "NumericIndicators.Default";
                            gaugeLabel2.Size.Height = 50F;
                            gaugeLabel2.Size.Width = 51F;
                            gaugeLabel2.Text = "";
                            gaugeLabel2.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
                            gaugeContainer2.Labels.Add(gaugeLabel2);

                            gaugeContainer2.Location = new Point(obj.X, obj.Y);
                            gaugeContainer2.Size = new System.Drawing.Size(obj.Width, obj.Height);
                            gaugeContainer2.AccessibleName = obj.ObjectID.ToString();
                            gaugeContainer2.AccessibleDescription = "8";
                            // Get sensor name + unit + value
                            sensorId = Convert.ToInt32(obj.Parameters);
                            sensor = SensorBLL.Current.GetByID(sensorId);
                            if (sensor != null)
                            {
                                // Associate with sensor
                                // Add tooltip display description - binhpro 27/02/2013
                                if (!string.IsNullOrEmpty(sensor.Description))
                                {
                                    toolTip1.SetToolTip(gaugeContainer2, "Công thức: " + sensor.FormulaFunction + "\n" + sensor.Description);
                                }
                                gaugeLabel2.Text = sensor.Name + "\n" + sensor.Unit;
                                if (sensor.MaxValue != null)
                                    gaugeContainer2.NumericIndicators["Default"].Digits = System.Convert.ToInt32(System.Math.Log10(System.Convert.ToInt32(sensor.MaxValue) + 1)) + 1 + 2 + 1;
                                // Read latest value (if exists)
                                if (entityConntext.SensorValues.
                                    Where(ent => ent.SensorID == sensorId).OrderByDescending(ent => ent.MeaTime).Count() != 0)
                                {
                                    sensorValue = entityConntext.SensorValues.
                                        Where(ent => ent.SensorID == sensorId).OrderByDescending(ent => ent.MeaTime).First();
                                    if (sensor.MaxValue == null)
                                        gaugeContainer2.NumericIndicators["Default"].Digits = System.Convert.ToInt32(System.Math.Log10(System.Convert.ToInt32(getSensorValue(sensorValue)) + 1)) + 1 + 2 + 1;
                                    gaugeContainer2.NumericIndicators["Default"].Value = System.Convert.ToDouble(getSensorValue(sensorValue));
                                    gaugeLabel2.Text = sensor.Name + "\n" + getDisplayValue(sensorValue) + " " + sensor.Unit;
                                    // Check if value is in alarm level
                                    if (PictureViewBLL.Current.CheckAlarmRunning(obj))
                                    {
                                        gaugeContainer2.NumericIndicators["Default"].DigitColor = System.Drawing.Color.FromArgb(((int)(((byte)(188)))), ((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
                                        gaugeContainer2.NumericIndicators["Default"].DecimalColor = System.Drawing.Color.FromArgb(((int)(((byte)(188)))), ((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
                                        gaugeContainer2.NumericIndicators["Default"].SeparatorColor = System.Drawing.Color.FromArgb(((int)(((byte)(188)))), ((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
                                    }
                                }
                            }
                            // Add to picture
                            this.panel.Controls.Add(gaugeContainer2);
                            gaugeContainer2.BringToFront();
                            break;
                        default:
                            break;
                    }
                }
                //mainMenuStrip.BringToFront();
                MouseMoveEventRegister(this.panel.Controls);
                foreach (Control control in this.panel.Controls)
                {
                    if (control.GetType() != typeof(MenuStrip))
                        pb.WireControl(control);
                }
                pb.EditModeEnabled = false;
                if (!SecurityBLL.Current.IsUserInRoles(new string[] { SecurityBLL.ROLE_VIEWS_EDIT, SecurityBLL.ROLE_VIEWS_MANAGE, SecurityBLL.ROLE_VIEWS_VIEW }))
                {
                    this.viewModeToolStripMenuItem.Enabled = false;
                    this.editToolStripMenuItem.Enabled = false;
                }
                this.addToolStripMenuItem.Enabled = false;
                //
            }
            catch (Exception exception)
            {
                ShowErrorMessage(exception.Message);
            }
        }