Esempio n. 1
0
        public bool Add(SiDComponent component)
        {
            if (component == null)
            return false;

              String compUIDStr = component.getUID().ToString();

              // check for duplicates
              if (mComponentsByUID.ContainsKey(compUIDStr))
              {
            return false;
              }

              mComponentsByUID.Add(compUIDStr, component);
              mComponents.Add(component);
              mComponentsByType.Add(component.GetType(), component);

              // ping event handler
              if (ComponentAdded != null)
            ComponentAdded(this, component);

              return true;
        }
Esempio n. 2
0
        void resourcePack_ComponentRemoved(ResourcePack sender, SiDComponent comp)
        {
            ImageListViewItem ilvi = TrackedComponents[comp];
              TrackedComponents.Remove(comp);

              if (comp is Tile)
              {
            ilvTiles.Items.Remove(ilvi);
              }
              else if (comp is Room)
              {
            ilvRooms.Items.Remove(ilvi);
              }
              else if (comp is Sprite)
              {
            ilvSprites.Items.Remove(ilvi);
              }
              else if (comp is StateObject)
              {
            ilvObjects.Items.Remove(ilvi);
              }
        }
Esempio n. 3
0
        void resourcePack_ComponentAdded(ResourcePack sender, SiDComponent comp)
        {
            String UIDstr = comp.getUID().ToString();

              if (comp is Tile)
              {
            Bitmap rep = ResizeBitmap(comp.RenderToBitmap(resourcePack), 4.0f);

            ilvTiles.Items.Add(UIDstr, comp.Name, rep);

            ImageListViewItem ilvi = ilvTiles.Items[ilvTiles.Items.Count - 1];
            ilvi.Tag = comp;

            TrackedComponents.Add(comp, ilvi);
              }
              else if (comp is Room)
              {
            Bitmap rep = comp.RenderToBitmap(resourcePack);

            ilvRooms.Items.Add(UIDstr, comp.Name, rep);

            ImageListViewItem ilvi = ilvRooms.Items[ilvRooms.Items.Count - 1];
            ilvi.Tag = comp;

            TrackedComponents.Add(comp, ilvi);
              }
              else if (comp is Sprite)
              {
            Bitmap rep = ResizeBitmap(comp.RenderToBitmap(resourcePack), 4.0f);

            ilvSprites.Items.Add(UIDstr, comp.Name, rep);

            ImageListViewItem ilvi = ilvSprites.Items[ilvSprites.Items.Count - 1];
            ilvi.Tag = comp;

            TrackedComponents.Add(comp, ilvi);
              }
              else if (comp is StateObject)
              {
            Bitmap rep = comp.RenderToBitmap(resourcePack);

            ilvObjects.Items.Add(UIDstr, comp.Name, rep);

            ImageListViewItem ilvi = ilvObjects.Items[ilvObjects.Items.Count - 1];
            ilvi.Tag = comp;

            TrackedComponents.Add(comp, ilvi);
              }
              else
              {
            byte [] stream = comp.SaveToByteStream();
            blobList.Items.Add(String.Format("{0} : {1}  ({2} bytes)", comp.ResourceTypeName, comp.Name, stream.Length));
              }
        }
Esempio n. 4
0
        public bool Remove(SiDComponent component)
        {
            if (component == null)
            return false;

              String compUIDStr = component.getUID().ToString();

              if (mComponentsByUID.ContainsKey(compUIDStr))
              {
            mComponents.Remove(component);
            mComponentsByUID.Remove(compUIDStr);
            mComponentsByType[component.GetType()].Remove(component);

            // ping event handler
            if (ComponentRemoved != null)
              ComponentRemoved(this, component);

            return true;
              }

              return false;
        }