private BaseGauge BuildLeftArcGauge(IGaugeItem gaugeItem)
        {
            LeftArcGauge leftArcGauge = new LeftArcGauge();

            leftArcGauge.GaugeItem = gaugeItem;

            BuildGauge(gaugeItem, (sensor) =>
            {
                leftArcGauge.SensorItem = sensor;
            });

            // Add it to the page
            this.CanvasGrid.Children.Add(leftArcGauge);
            return(leftArcGauge);
        }
        public BasePageView()
        {
            this.InitializeComponent();

            // Set the actual size of the page based on the resolution of the phyical device we are on.
            this.MainGrid.Height = Globals.ScreenSize.Height;
            this.MainGrid.Width  = Globals.ScreenSize.Width;

            this.Loaded         += BasePageView_Loaded;
            this.PointerPressed += BasePageView_PointerPressed;
            this.KeyDown        += MainCanvas_KeyDown;
            this.EditRibbon.ViewModel.SelectedGaugeItemList = _gaugeItemSelectedList;

            Messenger.Default.Register <List <IGaugeItem> >(this, "AddGaugeItemList", (gaugeItemList) =>
            {
                if (null == gaugeItemList)
                {
                    return;
                }
                if (gaugeItemList[0].PageId != this.ViewModel.GaugePageItem.PageId)
                {
                    return;
                }

                foreach (IGaugeItem gaugeItem in gaugeItemList)
                {
                    BaseGauge gauge = null;
                    switch (gaugeItem.GaugeType)
                    {
                    case GaugeTypeEnum.CircularGauge:
                        gauge = new CircularGauge();
                        break;

                    case GaugeTypeEnum.CompassRoseGauge:
                        gauge = new CompassRoseGauge();
                        break;

                    case GaugeTypeEnum.DonutGauge:
                        gauge = new DonutGauge();
                        break;

                    case GaugeTypeEnum.HorizontalBarGauge:
                        gauge = new HorizontalBarGauge();
                        break;

                    case GaugeTypeEnum.LeftArcGauge:
                        gauge = new LeftArcGauge();
                        break;

                    case GaugeTypeEnum.LeftTankGauge:
                        gauge = new TankGaugeLeft();
                        break;

                    case GaugeTypeEnum.PieChartGauge:
                        gauge = new PieChartGauge();
                        ((PieChartGauge)gauge).SensorCollection.Add(App.SensorCollection[0]);
                        ((PieChartGauge)gauge).SensorCollection.Add(App.SensorCollection[1]);
                        ((PieChartGauge)gauge).SensorCollection.Add(App.SensorCollection[2]);
                        break;

                    case GaugeTypeEnum.RightArcGauge: break;

                    case GaugeTypeEnum.RightTankGauge:
                        gauge = new TankGaugeRight();
                        break;

                    case GaugeTypeEnum.TextControl:
                        gauge = new TextControl();
                        break;

                    case GaugeTypeEnum.TextGauge:
                        gauge = new TextGauge();
                        break;

                    case GaugeTypeEnum.VerticalBarGauge:
                        gauge = new VerticalBarGauge();
                        break;
                    }

                    gauge.GaugeItem  = gaugeItem;
                    gauge.SensorItem = App.SensorCollection.FindBySensorId(gaugeItem.SensorId);

                    // Calculate the row/col position of this gauge
                    this.CanvasGrid.AddChildBaseGauge(gauge as BaseGauge, _nextRow, _nextCol);

                    _nextCol++;
                    if (_nextCol >= this.ViewModel.Cols)
                    {
                        _nextRow++;
                        _nextCol = 0;
                    }

                    // Persist the calculated (X,Y) location of the gauge
                    Task.Run(async() => { await gaugeItem.BeginCommit(); }).Wait();
                }
            });

            // Register to receive lists of gauges to display on the screen. Each item in this list
            // already has an (X,Y) location specified,
            Messenger.Default.Register <List <IGaugeItem> >(this, "BuildGaugeItemList", (gaugeItemList) =>
            {
                if (null == gaugeItemList)
                {
                    return;
                }
                if (gaugeItemList[0].PageId != this.ViewModel.GaugePageItem.PageId)
                {
                    return;
                }

                this.CanvasGrid.Children.Clear();
                BaseGauge gauge = null;

                foreach (IGaugeItem item in gaugeItemList)
                {
                    switch (item.GaugeType)
                    {
                    case GaugeTypeEnum.CircularGauge:
                        gauge = BuildCircularGauge(item);
                        break;

                    case GaugeTypeEnum.DonutGauge:
                        gauge = this.BuildDonutGauge(item);
                        break;

                    case GaugeTypeEnum.HorizontalBarGauge:
                        gauge = this.BuildHorizontalBarGauge(item);
                        break;

                    case GaugeTypeEnum.LeftArcGauge:
                        gauge = this.BuildLeftArcGauge(item);
                        break;

                    case GaugeTypeEnum.LeftTankGauge:
                        gauge = this.BuildLeftTankGauge(item);
                        break;

                    case GaugeTypeEnum.PieChartGauge:
                        gauge = this.BuildPieChartGauge(item);
                        break;

                    case GaugeTypeEnum.RightArcGauge: break;

                    case GaugeTypeEnum.RightTankGauge:
                        gauge = this.BuildRightTankGauge(item);
                        break;

                    case GaugeTypeEnum.TextControl:
                        gauge = this.BuildTextControl(item);
                        break;

                    case GaugeTypeEnum.TextGauge:
                        gauge = this.BuildTextGauge(item);
                        break;

                    case GaugeTypeEnum.VerticalBarGauge:
                        gauge = this.BuildVerticalBarGauge(item);
                        break;
                    }
                }
            });
        }