Exemplo n.º 1
0
        public App()
        {
            var mainStyles = new MainStyles();

            mainStyles.Load();

            var labelStyles = new LabelStyles();

            labelStyles.Load();

            On <Xamarin.Forms.PlatformConfiguration.Android>().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize);

            MainPage = new NavigationPage(new SplashPage())
            {
                BackgroundColor = (Color)Current.Resources[MainStyles.MainBackgroundColor]
            };
        }
Exemplo n.º 2
0
        private void DrawRoom(Graph.Node room)
        {
            if (room?.value == null)
            {
                Debug.LogError("Room node cannot be null");
                return;
            }
            Vector2 p = ScreenPos(room.pos), s = ScreenSize(room.size);

            if (t.IdAvailable(room.value))
            {
                throw new ArgumentException("The room " + room.value + " has no corresponding block container");
            }
            #region Draw Node (with menu)
            DrawImage(new Rect(p, s), t.GetMapById(room.value).Texture);
            DrawOutline(p, s, 2, Rooms.IsSelected(room) ? SelectColor : Color.black, default);

            // Only draw node menu if it is selected
            if (Rooms.AnySelected(room))
            {
                if (!Rooms.IsRoot(room) && GUI.Button(new Rect(p + ROOT_POS, new Vector2(50, 14)), "Root"))
                {
                    Rooms.Root = room;
                }
            }
            #endregion

            Handles.Label(p, room.value, LabelStyles.Colored(Color.white, FontStyle.Bold));
            if (showDebugInfo)
            {
                Handles.Label(p + Vector2.right * s + Vector2.down * 16, Rooms.IndexOf(room).ToString(), LabelStyles.Colored(Color.white, FontStyle.Normal));
            }

            if (Rooms.IsRoot(room))
            {
                Handles.Label(p + ROOT_POS + Vector2.up * 4, "Root", LabelStyles.Colored(HighlightColor, FontStyle.Bold));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Calculate font color of DataPoint labels depending upon chart background
        /// </summary>
        /// <param name="chart">Chart</param>
        /// <param name="dataPoint">DataPoint</param>
        /// <param name="labelFontColor">labelFontColor</param>
        /// <param name="labelStyle">labelStyle</param>
        /// <returns>Brush</returns>
        internal static Brush CalculateDataPointLabelFontColor(Chart chart, DataPoint dataPoint, Brush labelFontColor, LabelStyles labelStyle)
        {
            Brush returnBrush = dataPoint.LabelFontColor;

            if (labelFontColor == null)
            {
                Double intensity;

                if (labelStyle == LabelStyles.Inside && dataPoint.Parent.RenderAs != RenderAs.Line)
                {
                    intensity = Graphics.GetBrushIntensity(dataPoint.Color);
                    returnBrush = Graphics.GetDefaultFontColor(intensity);
                }
                else
                {
                    if (chart.PlotArea.InternalBackground == null)
                    {
                        if (chart.Background == null)
                        {
                            // returnBrush = Graphics.BLACK_BRUSH;
                            returnBrush = Graphics.AUTO_BLACK_FONT_BRUSH;
                        }
                        else
                        {
                            intensity = Graphics.GetBrushIntensity(chart.Background);
                            returnBrush = Graphics.GetDefaultFontColor(intensity);
                        }
                    }
                    else
                    {
                        intensity = Graphics.GetBrushIntensity(chart.PlotArea.InternalBackground);
                        returnBrush = Graphics.GetDefaultFontColor(intensity);
                    }
                }
            }

            return returnBrush;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Calculate auto placement for DataPoint label
 /// </summary>
 /// <param name="isView3D"></param>
 /// <param name="dataPoint"></param>
 /// <param name="barParams"></param>
 /// <param name="labelStyle"></param>
 /// <param name="labelLeft"></param>
 /// <param name="labelTop"></param>
 /// <param name="angle"></param>
 /// <param name="canvasLeft"></param>
 /// <param name="canvasTop"></param>
 /// <param name="canvasRight"></param>
 /// <param name="isVertical"></param>
 /// <param name="insideGap"></param>
 /// <param name="outsideGap"></param>
 /// <param name="tb"></param>
 private static void CalculateAutoPlacement(Boolean isView3D, DataPoint dataPoint, Size barVisualSize, Boolean isPositive,
     LabelStyles labelStyle, ref Double labelLeft, ref Double labelTop, ref Double angle, Double canvasLeft,
     Double canvasTop, Double canvasRight, Boolean isVertical, Double insideGap, Double outsideGap, Title tb)
 {
     if (isPositive)
     {
         if (labelStyle == LabelStyles.Inside)
         {
             if (barVisualSize.Width - insideGap - (dataPoint.MarkerSize / 2 * dataPoint.MarkerScale) >= tb.TextBlockDesiredSize.Width)
             {
                 labelLeft = canvasRight - tb.TextBlockDesiredSize.Width - (Double)(dataPoint.MarkerSize / 2 * dataPoint.MarkerScale) - insideGap;
                 labelTop = canvasTop + (barVisualSize.Height - tb.TextBlockDesiredSize.Height) / 2 + 6;
             }
             else
             {
                 labelLeft = canvasLeft + insideGap;
                 labelTop = canvasTop + (barVisualSize.Height - tb.TextBlockDesiredSize.Height) / 2 + 6;
             }
         }
         else
         {
             labelLeft = canvasRight + (Double)(dataPoint.MarkerSize / 2 * dataPoint.MarkerScale) + outsideGap;
             labelTop = canvasTop + (barVisualSize.Height - tb.TextBlockDesiredSize.Height) / 2 + 6;
         }
     }
     else
     {
         if (labelStyle == LabelStyles.Inside)
         {
             if (barVisualSize.Width - insideGap - (dataPoint.MarkerSize / 2 * dataPoint.MarkerScale) >= tb.TextBlockDesiredSize.Width)
             {
                 labelLeft = canvasLeft + (Double)(dataPoint.MarkerSize / 2 * dataPoint.MarkerScale + insideGap);
                 labelTop = canvasTop + (barVisualSize.Height - tb.TextBlockDesiredSize.Height) / 2 + 6;
             }
             else
             {
                 labelLeft = canvasRight - tb.TextBlockDesiredSize.Width - insideGap;
                 labelTop = canvasTop + (barVisualSize.Height - tb.TextBlockDesiredSize.Height) / 2 + 6;
             }
         }
         else
         {
             labelLeft = canvasLeft - tb.TextBlockDesiredSize.Width - (Double)(dataPoint.MarkerSize / 2 * dataPoint.MarkerScale + outsideGap);
             labelTop = canvasTop + (barVisualSize.Height - tb.TextBlockDesiredSize.Height) / 2 + 6;
         }
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Calculate auto placement for DataPoint label
        /// </summary>
        /// <param name="isView3D"></param>
        /// <param name="dataPoint"></param>
        /// <param name="columnParams"></param>
        /// <param name="labelStyle"></param>
        /// <param name="labelLeft"></param>
        /// <param name="labelTop"></param>
        /// <param name="angle"></param>
        /// <param name="canvasLeft"></param>
        /// <param name="canvasTop"></param>
        /// <param name="isVertical"></param>
        /// <param name="insideGap"></param>
        /// <param name="outsideGap"></param>
        /// <param name="tb"></param>
        private static void CalculateAutoPlacement(Boolean isView3D, DataPoint dataPoint, Size columnVisualSize, Boolean isPositive, LabelStyles labelStyle, ref Double labelLeft, ref Double labelTop, ref Double angle, Double canvasLeft, Double canvasTop, Boolean isVertical, Double insideGap, Double outsideGap, Title tb, Boolean isTopOfStack)
        {
            Double radius = 0;
            Double angleInRadian = 0;
            Point centerOfRotation;

            if (isPositive)
            {
                if (labelStyle == LabelStyles.Inside)
                {
                    if (isVertical)
                    {
                        if (columnVisualSize.Height - insideGap - (dataPoint.MarkerSize / 2 * dataPoint.MarkerScale) < tb.TextBlockDesiredSize.Width)
                        {
                            labelLeft = canvasLeft + columnVisualSize.Width / 2;
                            labelTop = canvasTop - tb.TextBlockDesiredSize.Height + columnVisualSize.Height + insideGap;
                            angle = -90;
                        }
                        else
                        {
                            centerOfRotation = new Point(canvasLeft + columnVisualSize.Width / 2, canvasTop + (((Double)dataPoint.MarkerSize / 2) * (Double)dataPoint.MarkerScale + insideGap));
                            angle = -90 + 180;
                            angleInRadian = (Math.PI / 180) * angle;
                            radius += tb.Width;
                            angle = (angleInRadian - Math.PI) * (180 / Math.PI);

                            labelLeft = centerOfRotation.X + radius * Math.Cos(angleInRadian);
                            labelTop = centerOfRotation.Y + radius * Math.Sin(angleInRadian);
                        }
                    }
                    else
                    {
                        if (columnVisualSize.Height - insideGap - (dataPoint.MarkerSize / 2 * dataPoint.MarkerScale) < tb.TextBlockDesiredSize.Height)
                        {
                            labelLeft = canvasLeft + columnVisualSize.Width / 2 - tb.TextBlockDesiredSize.Width / 2;
                            labelTop = canvasTop - tb.TextBlockDesiredSize.Height + columnVisualSize.Height + insideGap;

                            if (labelTop < 0)
                                labelTop = 0;
                        }
                        else
                        {
                            labelLeft = canvasLeft + columnVisualSize.Width / 2 - tb.TextBlockDesiredSize.Width / 2;
                            labelTop = canvasTop + (((Double)dataPoint.MarkerSize / 2) * (Double)dataPoint.MarkerScale) + insideGap;
                        }
                    }
                }
                else
                {   
                    if (isVertical)
                    {
                        labelTop = canvasTop - tb.TextBlockDesiredSize.Height - (((Double)dataPoint.MarkerSize / 2) * (Double)dataPoint.MarkerScale - (isView3D ? outsideGap : outsideGap + 3));
                        labelLeft = canvasLeft + columnVisualSize.Width / 2;
                        angle = -90;
                    }
                    else
                    {
                        if (dataPoint.Parent.RenderAs == RenderAs.StackedColumn100 && isView3D
                        && isTopOfStack)
                        {
                            if (!dataPoint.IsLabelStyleSet && !dataPoint.Parent.IsLabelStyleSet && !isVertical && tb.TextBlockDesiredSize.Height >= columnVisualSize.Height)
                            {
                                labelLeft = canvasLeft + columnVisualSize.Width / 2 - tb.TextBlockDesiredSize.Width / 2;
                                labelTop = canvasTop - outsideGap;// - tb.TextBlockDesiredSize.Height - (((Double)dataPoint.MarkerSize / 2) * (Double)dataPoint.MarkerScale - (isView3D ? -outsideGap : outsideGap));
                            }
                            else
                            {
                                labelLeft = canvasLeft + columnVisualSize.Width / 2 - tb.TextBlockDesiredSize.Width / 2;
                                labelTop = canvasTop - tb.TextBlockDesiredSize.Height - (((Double)dataPoint.MarkerSize / 2) * (Double)dataPoint.MarkerScale - (isView3D ? -outsideGap : outsideGap));
                            }
                        }
                        else
                        {   
                            labelLeft = canvasLeft + columnVisualSize.Width / 2 - tb.TextBlockDesiredSize.Width / 2;
                            labelTop = canvasTop - tb.TextBlockDesiredSize.Height - (((Double)dataPoint.MarkerSize / 2) * (Double)dataPoint.MarkerScale - (isView3D ? -outsideGap : outsideGap));
                        }
                    }
                }
            }
            else
            {
                if (labelStyle == LabelStyles.Inside)
                {
                    if (isVertical)
                    {
                        if (columnVisualSize.Height - insideGap - (dataPoint.MarkerSize / 2 * dataPoint.MarkerScale) < tb.TextBlockDesiredSize.Width)
                        {
                            centerOfRotation = new Point(canvasLeft + columnVisualSize.Width / 2, canvasTop - columnVisualSize.Height + insideGap);
                            angle = -90 - 180;
                            angleInRadian = (Math.PI / 180) * angle;
                            radius += tb.Width;
                            angle = (angleInRadian - Math.PI) * (180 / Math.PI);

                            labelLeft = centerOfRotation.X + radius * Math.Cos(angleInRadian);
                            labelTop = centerOfRotation.Y + radius * Math.Sin(angleInRadian);
                        }
                        else
                        {
                            labelLeft = canvasLeft + columnVisualSize.Width / 2;
                            labelTop = canvasTop - (((Double)dataPoint.MarkerSize / 2) * (Double)dataPoint.MarkerScale + insideGap);
                            angle = -90;
                        }
                    }
                    else
                    {
                        if (columnVisualSize.Height + insideGap - (dataPoint.MarkerSize / 2 * dataPoint.MarkerScale) < tb.TextBlockDesiredSize.Height)
                        {
                            labelLeft = canvasLeft + columnVisualSize.Width / 2 - tb.TextBlockDesiredSize.Width / 2;
                            labelTop = canvasTop - columnVisualSize.Height + insideGap;

                            if (labelTop + tb.TextBlockDesiredSize.Height > (dataPoint.Chart as Chart).ChartArea.ChartVisualCanvas.Height - (dataPoint.Chart as Chart).ChartArea.PLANK_THICKNESS)
                                labelTop = (dataPoint.Chart as Chart).ChartArea.ChartVisualCanvas.Height - (dataPoint.Chart as Chart).ChartArea.PLANK_THICKNESS - tb.TextBlockDesiredSize.Height;

                            angle = 0;
                        }
                        else
                        {
                            labelLeft = canvasLeft + columnVisualSize.Width / 2 - tb.TextBlockDesiredSize.Width / 2;
                            labelTop = canvasTop - tb.TextBlockDesiredSize.Height - (((Double)dataPoint.MarkerSize / 2) * (Double)dataPoint.MarkerScale - insideGap);
                            angle = 0;
                        }
                    }
                }
                else
                {
                    if (isVertical)
                    {
                        centerOfRotation = new Point(canvasLeft + columnVisualSize.Width / 2, canvasTop + (((Double)dataPoint.MarkerSize / 2) * (Double)dataPoint.MarkerScale + outsideGap + 2));
                        angle = -90 + 180;
                        angleInRadian = (Math.PI / 180) * angle;
                        radius += tb.Width;
                        angle = (angleInRadian - Math.PI) * (180 / Math.PI);

                        labelLeft = centerOfRotation.X + radius * Math.Cos(angleInRadian);
                        labelTop = centerOfRotation.Y + radius * Math.Sin(angleInRadian);
                    }
                    else
                    {
                        if (dataPoint.Parent.RenderAs == RenderAs.StackedColumn100 && isView3D
                        && isTopOfStack)
                        {
                            if (!dataPoint.IsLabelStyleSet && !dataPoint.Parent.IsLabelStyleSet && !isVertical && tb.TextBlockDesiredSize.Height >= columnVisualSize.Height)
                            {
                                labelLeft = canvasLeft + columnVisualSize.Width / 2 - tb.TextBlockDesiredSize.Width / 2;
                                labelTop = canvasTop - outsideGap;
                            }
                            else
                            {
                                labelLeft = canvasLeft + columnVisualSize.Width / 2 - tb.TextBlockDesiredSize.Width / 2;
                                labelTop = canvasTop + (((Double)dataPoint.MarkerSize / 2) * (Double)dataPoint.MarkerScale + outsideGap + 3);
                            }
                        }
                        else
                        {
                            labelLeft = canvasLeft + columnVisualSize.Width / 2 - tb.TextBlockDesiredSize.Width / 2;
                            labelTop = canvasTop + (((Double)dataPoint.MarkerSize / 2) * (Double)dataPoint.MarkerScale + outsideGap + 3);
                        }
                    }
                }
            }
        }