Exemplo n.º 1
0
        private void getRenderButtons(MFW3D.Renderable.RenderableObject ro, System.Collections.ArrayList renderList, System.Collections.ArrayList roList)
        {
            if (ro.MetaData != null)
            {
                string toolbarImagePath = (string)ro.MetaData["ToolBarImagePath"];
                if (toolbarImagePath != null)
                {
                    ResourceCacheEntry cacheEntry = (ResourceCacheEntry)m_ResourceCache[toolbarImagePath];

                    if (cacheEntry == null)
                    {
                        if (System.IO.File.Exists(toolbarImagePath))
                        {
                            renderList.Add(toolbarImagePath);
                            roList.Add(ro);
                        }
                    }
                    else
                    {
                        renderList.Add(toolbarImagePath);
                        roList.Add(ro);
                    }
                }
            }

            if (ro is MFW3D.Renderable.RenderableObjectList)
            {
                MFW3D.Renderable.RenderableObjectList rol = (MFW3D.Renderable.RenderableObjectList)ro;
                for (int i = 0; i < rol.Count; i++)
                {
                    MFW3D.Renderable.RenderableObject childRo = (MFW3D.Renderable.RenderableObject)rol.ChildObjects[i];
                    getRenderButtons(childRo, renderList, roList);
                }
            }
        }
Exemplo n.º 2
0
        private void m_CleanupTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            try
            {
                System.Collections.ArrayList deletionKeys = new System.Collections.ArrayList();
                //lock(m_ImageTileHash.SyncRoot)
                {
                    foreach (string key in m_ResourceHash.Keys)
                    {
                        ResourceCacheEntry tile = (ResourceCacheEntry)m_ResourceHash[key];

                        if (System.DateTime.Now.Subtract(tile.LastAccessed) > System.TimeSpan.FromSeconds(30))
                        {
                            deletionKeys.Add(key);
                        }
                    }
                }

                foreach (string key in deletionKeys)
                {
                    ResourceCacheEntry tile = (ResourceCacheEntry)m_ResourceHash[key];
                    m_ResourceHash.Remove(key);
                }
            }
            catch
            {}
        }
Exemplo n.º 3
0
 public void Add(string key, ResourceCacheEntry newEntry)
 {
     if (!m_ResourceHash.Contains(key))
     {
         m_ResourceHash.Add(key, newEntry);
     }
 }
Exemplo n.º 4
0
        public ResourceCacheEntry this[string key]
        {
            get
            {
                ResourceCacheEntry tile = m_ResourceHash[key] as ResourceCacheEntry;

                if (tile != null)
                {
                    tile.LastAccessed = System.DateTime.Now;
                }
                return(tile);
            }
        }
Exemplo n.º 5
0
        private void RenderButton(string buttonKey, int x, int y, int width, int height, bool enabled)
        {
            try
            {
                ResourceCacheEntry cacheEntry = m_ResourceCache[buttonKey];
                if (cacheEntry == null)
                {
                    cacheEntry = new ResourceCacheEntry();

                    IconButton newIconButton = new IconButton();
                    newIconButton.ImagePath = buttonKey;

                    newIconButton.Texture = TextureLoader.FromFile(
                        m_Device3d, buttonKey);

                    newIconButton.SurfaceDescription = newIconButton.Texture.GetLevelDescription(0);

                    cacheEntry.Object = newIconButton;

                    m_ResourceCache.Add(buttonKey, cacheEntry);
                }

                IconButton iconButton = cacheEntry.Object as IconButton;

                if (iconButton.Texture != null && !iconButton.Texture.Disposed)
                {
                    if (m_sprite == null)
                    {
                        m_sprite = new Sprite(m_Device3d);
                    }

                    m_sprite.Begin(SpriteFlags.AlphaBlend);
                    float xscale = (float)width / iconButton.SurfaceDescription.Width;
                    float yscale = (float)height / iconButton.SurfaceDescription.Height;
                    m_sprite.Transform  = Matrix.Scaling(xscale, yscale, 0);
                    m_sprite.Transform *= Matrix.Translation(x, y, 0);                     //+ width / 2, y + height / 2, 0);

                    m_sprite.Draw(iconButton.Texture,
                                  new Vector3(iconButton.SurfaceDescription.Width / 2, iconButton.SurfaceDescription.Height / 2, 0.0f),              //Vector3.Empty,
                                  Vector3.Empty,
                                  System.Drawing.Color.White.ToArgb()
                                  );

                    // Reset transform to prepare for text rendering later
                    m_sprite.Transform = Matrix.Identity;
                    m_sprite.End();

                    if (enabled)
                    {
                        m_ChevronVerts[0].Color = System.Drawing.Color.White.ToArgb();
                        m_ChevronVerts[0].X     = x - 3;
                        m_ChevronVerts[0].Y     = y - height / 2 - 5;
                        m_ChevronVerts[0].Z     = 0.0f;

                        m_ChevronVerts[1].Color = System.Drawing.Color.White.ToArgb();
                        m_ChevronVerts[1].X     = x;
                        m_ChevronVerts[1].Y     = y - height / 2;
                        m_ChevronVerts[1].Z     = 0.0f;

                        m_ChevronVerts[2].Color = System.Drawing.Color.White.ToArgb();
                        m_ChevronVerts[2].X     = x + 3;
                        m_ChevronVerts[2].Y     = y - height / 2 - 5;
                        m_ChevronVerts[2].Z     = 0.0f;

                        m_Device3d.VertexFormat = CustomVertex.TransformedColored.Format;
                        m_Device3d.TextureState[0].ColorOperation = TextureOperation.SelectArg1;
                        m_Device3d.TextureState[0].ColorArgument1 = TextureArgument.Diffuse;
                        m_Device3d.TextureState[0].AlphaOperation = TextureOperation.Disable;

                        m_Device3d.DrawUserPrimitives(PrimitiveType.TriangleList, 1, m_ChevronVerts);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Write(ex);
            }
        }