Coder Social home page Coder Social logo

Comments (6)

Kagamia avatar Kagamia commented on July 3, 2024 1

Yes, we can use 'StringTrimming.EllipsisCharacter' to control the layout of texts. Seemsdn
Here's some pseudo codes:

var fmtItemName = new StringFormat(){Trimming=StringTrimming.EllipsisCharacter};
var fmtItemType = new StringFormat(){Alignment = StringAlignment.Far};

//measure itemType's text width
var layoutSize = g.MeasureString(itemType, font, MAX_WIDTH, fmtItemType);

//draw texts
g.DrawString(itemName, font, brush, new RectangleF(LEFT, y, MAX_WIDTH-laytouSize.Width, lineHeight), fmtItemName);
g.DrawString(itemType, font, brush, RIGHT, y, fmtItemType);
y+=lineHeight;

from wzcomparerr2.

Kagamia avatar Kagamia commented on July 3, 2024

Simply change the x position of every draw call.
like this:

{
    int value;
    string numValue;
    //Defense tooltip icon
    x += 62;
    g.DrawImage(Resource.UIToolTip_img_Item_Equip_Summary_icon_pdd, x, y);
    DrawReqNum(g, "0", NumberType.LookAhead, x - 5, y + 6, StringAlignment.Far);

    //Boss DMG tooltip icon
    x += 62;
    g.DrawImage(Resource.UIToolTip_img_Item_Equip_Summary_icon_bdr, x, y);
    this.Gear.Props.TryGetValue(GearPropType.bdR, out value);
    numValue = (value > 0 ? "+ " : null) + value + " % ";
    DrawReqNum(g, numValue, NumberType.LookAhead, x - 5, y + 6, StringAlignment.Far);

    //Ignored Monster DEF tooltip icon
    x += 62;
    g.DrawImage(Resource.UIToolTip_img_Item_Equip_Summary_icon_igpddr, x, y);
    this.Gear.Props.TryGetValue(GearPropType.imdR, out value);
    numValue = (value > 0 ? "+ " : null) + value + " % ";
    DrawReqNum(g, numValue, NumberType.LookAhead, x - 5, y + 6, StringAlignment.Far);
}

from wzcomparerr2.

Sunaries avatar Sunaries commented on July 3, 2024

Thank you @Kagamia!

I have one more question.

Simulated version

Is there a way to change the overlap of the text? For example, if the item name has X characters, it will automatically add an ellipsis?

from wzcomparerr2.

Sunaries avatar Sunaries commented on July 3, 2024

@Kagamia

Code thanks to a friend of mine: http://pastebin.com/pUyzFDfL
Result:

Simulated version

Can GearGraphics.DrawString do convenient word wrapping?

from wzcomparerr2.

Kagamia avatar Kagamia commented on July 3, 2024

Currently GearGraphics can only used for monospaced font formatting.
I'm still trying to support all possible fonts and word wrap, maybe it will appear in next version XD

from wzcomparerr2.

Sunaries avatar Sunaries commented on July 3, 2024

Thank you for your hard work and dedication on this program. It's amazing.
I will close this thread since my questions have been answered. :)

from wzcomparerr2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.