示例#1
0
        public override bool Equals(object obj)
        {
            if (!(obj is VisBitmapAnimation))
            {
                return(false);
            }
            // Do base-class equality comparison and the ReferenceEquals check.
            if (!base.Equals(obj))
            {
                return(false);
            }
            VisBitmapAnimation other = (VisBitmapAnimation)obj;

            if (other.mSerialNumbers.Count != mSerialNumbers.Count)
            {
                return(false);
            }
            for (int i = 0; i < mSerialNumbers.Count; i++)
            {
                if (other.mSerialNumbers[i] != mSerialNumbers[i])
                {
                    return(false);
                }
            }
            return(true);
        }
示例#2
0
        /// <summary>
        /// Strips serial numbers out of the list.
        /// </summary>
        /// <param name="visAnim">Object to strip serial numbers from.</param>
        /// <param name="removedSerials">List of serial numbers to remove.</param>
        /// <param name="newAnim">Object with changes, or null if nothing changed.</param>
        /// <returns>True if something was actually removed.</returns>
        public static bool StripEntries(VisBitmapAnimation visAnim, List <int> removedSerials,
                                        out VisBitmapAnimation newAnim)
        {
            bool somethingRemoved = false;

            // Both sets should be small, so not worried about O(m*n).
            List <int> newSerials = new List <int>(visAnim.mSerialNumbers.Count);

            foreach (int serial in visAnim.mSerialNumbers)
            {
                if (removedSerials.Contains(serial))
                {
                    Debug.WriteLine("Removing serial #" + serial + " from " + visAnim.Tag);
                    somethingRemoved = true;
                    continue;
                }
                newSerials.Add(serial);
            }

            if (somethingRemoved)
            {
                newAnim = new VisBitmapAnimation(visAnim.Tag, visAnim.VisGenIdent,
                                                 visAnim.VisGenParams, visAnim, newSerials);
            }
            else
            {
                newAnim = null;
            }
            return(somethingRemoved);
        }
示例#3
0
        /// <summary>
        /// Strips a set of Visualizations out of animations in the set.  The set is not
        /// modified; rather, a new set is generated with updated entries.
        /// </summary>
        /// <param name="visSet">Input set.</param>
        /// <param name="removedSerials">Serial numbers of removed items.</param>
        /// <param name="newSet">Updated set.</param>
        /// <returns>True if entries were removed.</returns>
        public static bool StripEntriesFromAnimations(VisualizationSet visSet,
                                                      List <int> removedSerials, out VisualizationSet newSet)
        {
            bool somethingRemoved = false;

            newSet = new VisualizationSet(visSet.Count);
            foreach (Visualization vis in visSet)
            {
                if (!(vis is VisBitmapAnimation))
                {
                    newSet.Add(vis);
                    continue;
                }

                if (VisBitmapAnimation.StripEntries((VisBitmapAnimation)vis,
                                                    removedSerials, out VisBitmapAnimation newAnim))
                {
                    somethingRemoved = true;
                    if (newAnim.Count != 0)
                    {
                        newSet.Add(newAnim);
                    }
                    else
                    {
                        Debug.WriteLine("Deleting empty animation " + vis.Tag);
                    }
                }
            }
            return(somethingRemoved);
        }
示例#4
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="tag">Unique identifier.</param>
        /// <param name="visGenIdent">Visualization generator identifier.</param>
        /// <param name="visGenParams">Parameters for visualization generator.</param>
        /// <param name="visSerialNumbers">Serial numbers of referenced Visualizations.</param>
        public VisBitmapAnimation(string tag, string visGenIdent,
                                  ReadOnlyDictionary <string, object> visGenParams, VisBitmapAnimation oldObj,
                                  List <int> visSerialNumbers)
            : base(tag, visGenIdent, visGenParams, oldObj)
        {
            Debug.Assert(visSerialNumbers != null);

            // Make a copy of the list.
            mSerialNumbers = new List <int>(visSerialNumbers.Count);
            foreach (int serial in visSerialNumbers)
            {
                mSerialNumbers.Add(serial);
            }

            CachedImage  = BLANK_IMAGE;
            OverlayImage = ANIM_OVERLAY_IMAGE;
        }
示例#5
0
        /// <summary>
        /// Attempts to refresh broken thumbnails across all visualization sets in the project.
        /// </summary>
        /// <param name="project">Project reference.</param>
        public static void RefreshAllThumbnails(DisasmProject project)
        {
            ScriptSupport iapp = null;
            Dictionary <string, IPlugin> plugins = null;

            SortedList <int, VisualizationSet> visSets = project.VisualizationSets;

            foreach (KeyValuePair <int, VisualizationSet> kvp in visSets)
            {
                VisualizationSet visSet = kvp.Value;
                foreach (Visualization vis in visSet)
                {
                    if (vis.HasImage)
                    {
                        continue;
                    }
                    //Debug.WriteLine("Vis needs refresh: " + vis.Tag);

                    if (vis is VisBitmapAnimation)
                    {
                        continue;
                    }

                    if (iapp == null)
                    {
                        // Prep the plugins on first need.
                        iapp = new ScriptSupport();
                        project.PrepareScripts(iapp);
                    }
                    iapp.MsgTag = vis.Tag;

                    if (plugins == null)
                    {
                        plugins = project.GetActivePlugins();
                    }
                    IPlugin_Visualizer vplug = FindPluginByVisGenIdent(plugins,
                                                                       vis.VisGenIdent, out VisDescr visDescr);
                    if (vplug == null)
                    {
                        Debug.WriteLine("Unable to refresh " + vis.Tag + ": plugin not found");
                        continue;
                    }

                    IVisualization2d                    vis2d   = null;
                    IVisualizationWireframe             visWire = null;
                    ReadOnlyDictionary <string, object> parms   =
                        new ReadOnlyDictionary <string, object>(vis.VisGenParams);
                    try {
                        if (visDescr.VisualizationType == VisDescr.VisType.Bitmap)
                        {
                            vis2d = vplug.Generate2d(visDescr, parms);
                            if (vis2d == null)
                            {
                                Debug.WriteLine("Vis2d generator returned null");
                            }
                        }
                        else if (visDescr.VisualizationType == VisDescr.VisType.Wireframe)
                        {
                            IPlugin_Visualizer_v2 plugin2 = (IPlugin_Visualizer_v2)vplug;
                            visWire = plugin2.GenerateWireframe(visDescr, parms);
                            if (visWire == null)
                            {
                                Debug.WriteLine("VisWire generator returned null");
                            }
                        }
                        else
                        {
                            Debug.Assert(false);
                        }
                    } catch (Exception ex) {
                        Debug.WriteLine("Vis generation failed: " + ex);
                    }
                    if (vis2d != null)
                    {
                        //Debug.WriteLine(" Rendered thumbnail: " + vis.Tag);
                        vis.SetThumbnail(vis2d);
                    }
                    else if (visWire != null)
                    {
                        vis.SetThumbnail(visWire, parms);
                    }
                }
            }

            if (iapp != null)
            {
                project.UnprepareScripts();
            }

            // Now that we've generated images for the Visualizations, update any
            // VisBitmapAnimation thumbnails that may have been affected.
            foreach (KeyValuePair <int, VisualizationSet> kvp in visSets)
            {
                VisualizationSet visSet = kvp.Value;
                foreach (Visualization vis in visSet)
                {
                    if (!(vis is VisBitmapAnimation))
                    {
                        continue;
                    }
                    VisBitmapAnimation visAnim = (VisBitmapAnimation)vis;
                    visAnim.GenerateImage(visSets);
                }
            }
        }