public override void LoadResources()
        {
            // load icons
            iconsTexture = (TextureResource)devIf.GetSharedResource("file://Media/UI/InViewIconsX16.png", ref checkedOutResources, devIf);
            // ^need??
            xAxisIcon = (TextureResource.Icon)devIf.GetSharedResource("file://Media/UI/InViewIconsX16.png:areas:icon:xAxis", ref checkedOutResources, devIf);
            yAxisIcon = (TextureResource.Icon)devIf.GetSharedResource("file://Media/UI/InViewIconsX16.png:areas:icon:yAxis", ref checkedOutResources, devIf);
            zAxisIcon = (TextureResource.Icon)devIf.GetSharedResource("file://Media/UI/InViewIconsX16.png:areas:icon:zAxis", ref checkedOutResources, devIf);
            tickIcon = (TextureResource.Icon)devIf.GetSharedResource("file://Media/UI/InViewIconsX16.png:areas:icon:tick", ref checkedOutResources, devIf);
            crossIcon = (TextureResource.Icon)devIf.GetSharedResource("file://Media/UI/InViewIconsX16.png:areas:icon:cross", ref checkedOutResources, devIf);

            // create GUI items
            // TODO: Needs layout manager support
            AddItem(new GUIIcon(new Point(10, 10), new Size(16, 16), xAxisIcon, true, true));
            AddItem(new GUIIcon(new Point(32, 10), new Size(16, 16), yAxisIcon, true, true));
            AddItem(new GUIIcon(new Point(54, 10), new Size(16, 16), zAxisIcon, true, true));

            AddItem(LayoutManager.AlignItem(new GUIIcon(new Point(-48, -50),
                                                        new Size(16, 16), tickIcon, true, false),
                                            LayoutRules.Positioning.Far,
                                            LayoutRules.Positioning.Far),
                    null, null, OnTickClick);
            AddItem(LayoutManager.AlignItem(new GUIIcon(new Point(-32, -50),
                                                        new Size(16, 16), crossIcon, true, false),
                                            LayoutRules.Positioning.Far,
                                            LayoutRules.Positioning.Far));
        }
示例#2
0
        private void ProcessSubAreas(XmlElement areas, TextureResource texRz, out TextureResource.Icon[] icons,
                                     string preamble)
        {
            XmlNodeList iconAreas = areas.SelectNodes("icon");

            if (iconAreas != null && iconAreas.Count > 0)
            {
                icons = new TextureResource.Icon[iconAreas.Count];
                int iconIdx = 0;
                foreach (XmlElement icon in iconAreas)
                {
                    string id = icon.Attributes["id"].InnerText;
                    // parse coords
                    XmlNodeList coords = icon.SelectNodes("coords");
                    if (coords == null || coords.Count == 0)
                    {
                        throw new Exception("Icon found with no coords");
                    }
                    icons[iconIdx] = new TextureResource.Icon(preamble + id, texRz, Rectangle.Empty,
                                                              RectangleF.Empty);

                    foreach (XmlElement coord in coords)
                    {
                        string     coordId = coord.Attributes["id"].InnerText;
                        int        u       = int.Parse(coord.Attributes["u"].InnerText);
                        int        v       = int.Parse(coord.Attributes["v"].InnerText);
                        int        w       = int.Parse(coord.Attributes["w"].InnerText);
                        int        h       = int.Parse(coord.Attributes["h"].InnerText);
                        Rectangle  pixels  = new Rectangle(u, v, w, h);
                        RectangleF coordsR = new RectangleF((float)u / (float)texRz.Width,
                                                            (float)v / (float)texRz.Height,
                                                            (float)w / (float)texRz.Width,
                                                            (float)h / (float)texRz.Height);
                        if (coordId == "face")
                        {
                            icons[iconIdx].FacePixels = pixels;
                            icons[iconIdx].FaceCoords = coordsR;
                        }
                        else if (coordId == "disabled")
                        {
                            icons[iconIdx].DisabledPixels = pixels;
                            icons[iconIdx].DisabledCoords = coordsR;
                        }
                        else if (coordId == "highlight")
                        {
                            icons[iconIdx].HighlightPixels = pixels;
                            icons[iconIdx].HighlightCoords = coordsR;
                        }
                    }
                    iconIdx++;
                }
            }
            else
            {
                icons = null;
            }
        }
        private void ProcessSubAreas(XmlElement areas, TextureResource texRz, out TextureResource.Icon[] icons,
                                     string preamble)
        {
            XmlNodeList iconAreas = areas.SelectNodes("icon");
            if (iconAreas != null && iconAreas.Count > 0)
            {
                icons = new TextureResource.Icon[iconAreas.Count];
                int iconIdx = 0;
                foreach (XmlElement icon in iconAreas)
                {
                    string id = icon.Attributes["id"].InnerText;
                    // parse coords
                    XmlNodeList coords = icon.SelectNodes("coords");
                    if (coords == null || coords.Count == 0)
                        throw new Exception("Icon found with no coords");
                    icons[iconIdx] = new TextureResource.Icon(preamble + id, texRz, Rectangle.Empty,
                                                              RectangleF.Empty);

                    foreach (XmlElement coord in coords)
                    {
                        string coordId = coord.Attributes["id"].InnerText;
                        int u = int.Parse(coord.Attributes["u"].InnerText);
                        int v = int.Parse(coord.Attributes["v"].InnerText);
                        int w = int.Parse(coord.Attributes["w"].InnerText);
                        int h = int.Parse(coord.Attributes["h"].InnerText);
                        Rectangle pixels = new Rectangle(u, v, w, h);
                        RectangleF coordsR = new RectangleF((float)u / (float)texRz.Width,
                                                            (float)v / (float)texRz.Height,
                                                            (float)w / (float)texRz.Width,
                                                            (float)h / (float)texRz.Height);
                        if (coordId == "face")
                        {
                            icons[iconIdx].FacePixels = pixels;
                            icons[iconIdx].FaceCoords = coordsR;
                        }
                        else if (coordId == "disabled")
                        {
                            icons[iconIdx].DisabledPixels = pixels;
                            icons[iconIdx].DisabledCoords = coordsR;
                        }
                        else if (coordId == "highlight")
                        {
                            icons[iconIdx].HighlightPixels = pixels;
                            icons[iconIdx].HighlightCoords = coordsR;
                        }
                    }
                    iconIdx++;
                }
            }
            else
                icons = null;
        }
示例#4
0
 public GUIIcon(Point origin, Size dimensions, TextureResource.Icon icon,
                bool highlight, bool enabled)
     : base(origin, dimensions, icon.Texture)
 {
     this.icon = icon;
     this.highlight = highlight;
     wantMouseOver = true;
     this.enabled = enabled;
 }