Пример #1
0
        /// <summary>
        /// loads image and adds it to Images
        /// </summary>
        /// <param name="filename"></param>
        /// <exception cref="Exception"></exception>
        public void AddImageFromFile(string filename)
        {
            var tex = IO.LoadImageTexture(filename, out var originalFormat);

            try
            {
                Images.AddImage(tex, true, filename, originalFormat);
            }
            catch (Exception)
            {
                tex.Dispose();
                throw;
            }
        }
        public ObjectListEditor(List <object> objects, int selectedIndex, Image image)
        {
            InitializeComponent();

            if (image != null)
            {
                Images.AddImage(image);
            }

            using (new UsingProcessor(() => listControls.Items.BeginUpdate(), () => listControls.Items.EndUpdate()))
            {
                foreach (object obj in objects)
                {
                    listControls.Items.Add(obj, image != null ? 0 : -1);
                }
            }

            if (listControls.Items.Count > 0 && selectedIndex < listControls.Items.Count)
            {
                listControls.SelectedIndex = selectedIndex;
            }
        }
Пример #3
0
        // pass bool = false to get the width of the line to be drawn without actually drawing anything. Useful for aligning text.
        unsafe void writeTexture_Line(List <AAtom> atoms, uint *rPtr, ref int x, int y, int linewidth, int maxHeight, ref int lineheight, bool draw)
        {
            for (int i = 0; i < atoms.Count; i++)
            {
                AFont font = TextUni.GetFont((int)atoms[i].Font);
                if (lineheight < font.Height)
                {
                    lineheight = font.Height;
                }

                if (draw)
                {
                    if (atoms[i] is CharacterAtom)
                    {
                        CharacterAtom atom      = (CharacterAtom)atoms[i];
                        ACharacter    character = font.GetCharacter(atom.Character);
                        // HREF links should be colored white, because we will hue them at runtime.
                        uint color = atom.IsHREF ? 0xFFFFFFFF : Utility.UintFromColor(atom.Color);
                        character.WriteToBuffer(rPtr, x, y, linewidth, maxHeight, font.Baseline,
                                                atom.Style_IsBold, atom.Style_IsItalic, atom.Style_IsUnderlined, atom.Style_IsOutlined, color, 0xFF000008);
                    }
                    else if (atoms[i] is ImageAtom)
                    {
                        ImageAtom atom = (ImageAtom)atoms[i];
                        if (lineheight < atom.Height)
                        {
                            lineheight = atom.Height;
                        }
                        Images.AddImage(new Rectangle(x, y + (lineheight - atom.Height) / 2, atom.Width, atom.Height),
                                        atom.Texture, GumpData.GetGumpXNA(atom.ValueOver), GumpData.GetGumpXNA(atom.ValueDown));
                        atom.AssociatedImage = Images[Images.Count - 1];
                    }
                }
                x += atoms[i].Width;
            }
        }