private ExpressionDrawer.Settings GetOptions()
        {
            // Empty color - use default
            ExpressionDrawer.Settings settings = new ExpressionDrawer.Settings();
            settings.showDir     = false;
            settings.showLabels  = false;
            settings.showDots    = false;
            settings.densify     = true;
            settings.imageWidth  = 100;
            settings.imageHeight = 100;
            settings.displayMultiPointsAsPlots = false;
            settings.image_maintainAspectRatio = false;
            GraphicalWatchOptionPage optionPage = Util.GetDialogPage <GraphicalWatchOptionPage>();

            if (optionPage != null)
            {
                if (optionPage.ValuePlot_EnableBars || optionPage.ValuePlot_EnableLines || optionPage.ValuePlot_EnablePoints)
                {
                    settings.valuePlot_enableBars   = optionPage.ValuePlot_EnableBars;
                    settings.valuePlot_enableLines  = optionPage.ValuePlot_EnableLines;
                    settings.valuePlot_enablePoints = optionPage.ValuePlot_EnablePoints;
                }
                if (optionPage.PointPlot_EnableLines || optionPage.PointPlot_EnablePoints)
                {
                    settings.pointPlot_enableLines  = optionPage.PointPlot_EnableLines;
                    settings.pointPlot_enablePoints = optionPage.PointPlot_EnablePoints;
                }
                settings.densify     = optionPage.Densify;
                settings.showDir     = optionPage.EnableDirections;
                settings.showLabels  = optionPage.EnableLabels;
                settings.showDots    = false;
                settings.imageHeight = Math.Max(optionPage.ImageHeight, 20);
                settings.imageWidth  = Math.Max(optionPage.ImageWidth, 20);
                settings.displayMultiPointsAsPlots = (optionPage.MultiPointDisplayMode == GraphicalWatchOptionPage.MultiPointDisplayModeValue.PointPlot);
                settings.image_maintainAspectRatio = optionPage.Image_MaintainAspectRatio;
            }
            return(settings);
        }
        private void UpdateItem(bool load, int index)
        {
            GraphicalItem variable = Variables[index];

            Bitmap bmp  = null;
            string type = null;

            if (ExpressionLoader.Debugger.CurrentMode == dbgDebugMode.dbgBreakMode)
            {
                // Empty color - use default
                ExpressionDrawer.Settings settings = new ExpressionDrawer.Settings();
                settings.densify    = true;
                settings.showDir    = false;
                settings.showLabels = false;
                settings.showDots   = false;
                // Other settings
                int  imageWidth  = 100;
                int  imageHeight = 100;
                bool displayMultiPointsAsPlots = false;
                // Load settings from option page
                GraphicalWatchOptionPage optionPage = Util.GetDialogPage <GraphicalWatchOptionPage>();
                if (optionPage != null)
                {
                    if (optionPage.ValuePlot_EnableBars || optionPage.ValuePlot_EnableLines || optionPage.ValuePlot_EnablePoints)
                    {
                        settings.valuePlot_enableBars   = optionPage.ValuePlot_EnableBars;
                        settings.valuePlot_enableLines  = optionPage.ValuePlot_EnableLines;
                        settings.valuePlot_enablePoints = optionPage.ValuePlot_EnablePoints;
                    }
                    if (optionPage.PointPlot_EnableLines || optionPage.PointPlot_EnablePoints)
                    {
                        settings.pointPlot_enableLines  = optionPage.PointPlot_EnableLines;
                        settings.pointPlot_enablePoints = optionPage.PointPlot_EnablePoints;
                    }
                    settings.densify          = optionPage.Densify;
                    settings.showDir          = optionPage.EnableDirections;
                    settings.showLabels       = optionPage.EnableLabels;
                    settings.showDots         = false;
                    imageHeight               = Math.Max(optionPage.ImageHeight, 20);
                    imageWidth                = Math.Max(optionPage.ImageWidth, 20);
                    displayMultiPointsAsPlots = optionPage.MultiPointDisplayMode == GraphicalWatchOptionPage.MultiPointDisplayModeValue.PointPlot;
                }

                (dataGrid.Columns[1] as DataGridTemplateColumn).Width = imageWidth + 1;
                dataGrid.RowHeight = imageHeight + 1;

                if (load)
                {
                    variable.Drawable = null;
                    variable.Traits   = null;
                }

                if (variable.Name != null && variable.Name != "")
                {
                    var expression = ExpressionLoader.Debugger.GetExpression(variable.Name);
                    if (expression.IsValidValue)
                    {
                        // create bitmap
                        bmp = new Bitmap(imageWidth, imageHeight);

                        Graphics graphics = Graphics.FromImage(bmp);
                        graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                        graphics.Clear(m_colors.ClearColor);

                        try
                        {
                            if (variable.Drawable == null)
                            {
                                Geometry.Traits            traits   = null;
                                ExpressionDrawer.IDrawable drawable = null;
                                ExpressionLoader.Load(variable.Name, out traits, out drawable);

                                if (drawable != null && displayMultiPointsAsPlots && drawable is ExpressionDrawer.MultiPoint)
                                {
                                    drawable = new ExpressionDrawer.PointsContainer(drawable as ExpressionDrawer.MultiPoint);
                                }

                                variable.Drawable = drawable;
                                variable.Traits   = traits;
                            }
                            else
                            {
                                if (displayMultiPointsAsPlots && variable.Drawable is ExpressionDrawer.MultiPoint)
                                {
                                    variable.Drawable = new ExpressionDrawer.PointsContainer(variable.Drawable as ExpressionDrawer.MultiPoint);
                                }
                                else if (!displayMultiPointsAsPlots && variable.Drawable is ExpressionDrawer.PointsContainer)
                                {
                                    variable.Drawable = (variable.Drawable as ExpressionDrawer.PointsContainer).MultiPoint;
                                }
                            }

                            if (!ExpressionDrawer.Draw(graphics, variable.Drawable, variable.Traits, settings, m_colors))
                            {
                                bmp = null;
                            }
                        }
                        catch (Exception)
                        {
                            bmp = null;
                        }

                        type = expression.Type;
                    }
                }
            }

            // set new row
            ResetAt(new GraphicalItem(variable.Drawable, variable.Traits, variable.Name, bmp, type), index);
        }