private void UpdateItem(int index)
        {
            VariableItem variable = Variables[index];

            Bitmap bmp  = null;
            string type = null;

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

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

                    if (!ExpressionDrawer.Draw(graphics, m_debugger, variable.Name, m_colors))
                    {
                        bmp = null;
                    }

                    type = expression.Type;
                }
            }

            // set new row
            ResetAt(new VariableItem(variable.Name, bmp, type), index);
        }
        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);
        }
        private void UpdateItem(bool load, int index)
        {
            GraphicalItem variable = Variables[index];

            if (ExpressionLoader.IsBreakMode)
            {
                if (load)
                {
                    ExpressionLoader.ReloadUserTypes(Util.GetDialogPage <GeneralOptionPage>());
                }

                // Load settings from option page
                ExpressionDrawer.Settings settings = GetOptions();

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

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

                if (variable.Name != null && variable.Name != "")
                {
                    var expressions = ExpressionLoader.GetExpressions(variable.Name);
                    if (ExpressionLoader.AllValidValues(expressions))
                    {
                        // create bitmap
                        variable.Bmp = new Bitmap(settings.imageWidth, settings.imageHeight);

                        Graphics graphics = Graphics.FromImage(variable.Bmp);
                        graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                        graphics.Clear(Util.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 &&
                                    settings.displayMultiPointsAsPlots &&
                                    drawable is ExpressionDrawer.MultiPoint)
                                {
                                    drawable = new ExpressionDrawer.PointsContainer(drawable as ExpressionDrawer.MultiPoint);
                                }

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

                            if (!ExpressionDrawer.Draw(graphics, variable.Drawable, variable.Traits, settings, Util.Colors))
                            {
                                variable.Bmp = null;
                            }

                            variable.Error = null;
                        }
                        catch (Exception e)
                        {
                            variable.Bmp = null;

                            variable.Error = e.Message;
                        }

                        variable.Type = ExpressionLoader.TypeFromExpressions(expressions);
                    }
                }
            }

            // set new row
            ResetAt(variable.ShallowCopy(), index);
        }