示例#1
0
        private void drawTurnState(List <UIElement> geoList, List <UIElement> unrotatedList)
        {
            TurnState currentTurnState = mapperVicinity.turnState;

            bool   inTurn = currentTurnState != null && currentTurnState.inTurn;
            string ts     = inTurn ? currentTurnState.ToString() : "not in turn";

            double x0 = 20.0d;
            double y0 = 50.0d;

            Label lblTurn = new Label()
            {
                Content = ts, Margin = new Thickness(x0, y0, 0, 0), FontSize = 12, FontWeight = FontWeights.Normal
            };

            unrotatedList.Add(lblTurn);

            try
            {
                string controlName = "TurnStateViewControl1";

                double controlWidth  = 3.0d * relCellWidth / MapperSettings.elementSizeMeters;
                double controlHeight = 3.0d * relCellHeight / MapperSettings.elementSizeMeters;
                double controlX      = (turnPanel.ActualWidth - controlWidth) / 2.0d;
                double controlY      = (turnPanel.ActualHeight - controlHeight) / 2.0d;

                TurnStateViewControl tsvc = turnPanel.FindName(controlName) as TurnStateViewControl;
                if (tsvc == null)
                {
                    tsvc = new TurnStateViewControl()
                    {
                        Name      = controlName,
                        turnState = currentTurnState,
                        Width     = controlWidth,
                        Height    = controlHeight,
                        Margin    = new Thickness(controlX, controlY, 0, 0)
                    };
                    turnPanel.Children.Add(tsvc);
                    turnPanel.RegisterName(tsvc.Name, tsvc);
                }
                else
                {
                    if (tsvc.Width != controlWidth || tsvc.Height != controlHeight)
                    {
                        tsvc.Width  = controlWidth;
                        tsvc.Height = controlHeight;
                        tsvc.Margin = new Thickness(controlX, controlY, 0, 0);
                    }
                    tsvc.turnState = currentTurnState;
                    tsvc.redraw();
                    //Console.WriteLine(string.Format("draw() - using existing control - scale: power={0} speed={1}", rsvc.maxAbsPower, rsvc.maxAbsSpeed));
                }
            }
            catch { }
        }
        private void drawTurnState(List<UIElement> geoList, List<UIElement> unrotatedList)
        {
            TurnState currentTurnState = mapperVicinity.turnState;

            bool inTurn = currentTurnState != null && currentTurnState.inTurn;
            string ts = inTurn ? currentTurnState.ToString() : "not in turn";

            double x0 = 20.0d;
            double y0 = 50.0d;

            Label lblTurn = new Label() { Content = ts, Margin = new Thickness(x0, y0, 0, 0), FontSize = 12, FontWeight = FontWeights.Normal };

            unrotatedList.Add(lblTurn);

            try
            {
                string controlName = "TurnStateViewControl1";

                double controlWidth = 3.0d * relCellWidth / MapperSettings.elementSizeMeters;
                double controlHeight = 3.0d * relCellHeight / MapperSettings.elementSizeMeters;
                double controlX = (turnPanel.ActualWidth - controlWidth) / 2.0d;
                double controlY = (turnPanel.ActualHeight - controlHeight) / 2.0d;

                TurnStateViewControl tsvc = turnPanel.FindName(controlName) as TurnStateViewControl;
                if (tsvc == null)
                {
                    tsvc = new TurnStateViewControl()
                    {
                        Name = controlName,
                        turnState = currentTurnState,
                        Width = controlWidth,
                        Height = controlHeight,
                        Margin = new Thickness(controlX, controlY, 0, 0)
                    };
                    turnPanel.Children.Add(tsvc);
                    turnPanel.RegisterName(tsvc.Name, tsvc);
                }
                else
                {
                    if (tsvc.Width != controlWidth || tsvc.Height != controlHeight)
                    {
                        tsvc.Width = controlWidth;
                        tsvc.Height = controlHeight;
                        tsvc.Margin = new Thickness(controlX, controlY, 0, 0);
                    }
                    tsvc.turnState = currentTurnState;
                    tsvc.redraw();
                    //Console.WriteLine(string.Format("draw() - using existing control - scale: power={0} speed={1}", rsvc.maxAbsPower, rsvc.maxAbsSpeed));
                }
            }
            catch { }
        }