1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using CommonUI.Display;
- namespace CommonUI.Tool
- {
- public class AnchorTool
- {
- public static Anchor FromString(string text)
- {
- string[] ay = text.Split('_');
- string h = ay[0];
- string v = ay[ay.Length - 1];
- Anchor ih = Anchor.ANCHOR_HCENTER;
- if (h == "L")
- {
- ih = Anchor.ANCHOR_LEFT;
- }
- else if (h == "R")
- {
- ih = Anchor.ANCHOR_RIGHT;
- }
- Anchor iv = Anchor.ANCHOR_VCENTER;
- if (v == "T")
- {
- iv = Anchor.ANCHOR_TOP;
- }
- else if (v == "B")
- {
- iv = Anchor.ANCHOR_BOTTOM;
- }
- return ih | iv;
- }
- public static Anchor FromTextAnchor(Data.TextAnchor ta)
- {
- Anchor ih = Anchor.ANCHOR_HCENTER;
- Anchor iv = Anchor.ANCHOR_VCENTER;
- switch (ta)
- {
- case Data.TextAnchor.L_T:
- ih = Anchor.ANCHOR_LEFT;
- iv = Anchor.ANCHOR_TOP;
- break;
- case Data.TextAnchor.C_T:
- iv = Anchor.ANCHOR_TOP;
- break;
- case Data.TextAnchor.R_T:
- ih = Anchor.ANCHOR_TOP;
- iv = Anchor.ANCHOR_TOP;
- break;
- case Data.TextAnchor.L_C:
- ih = Anchor.ANCHOR_LEFT;
- break;
- case Data.TextAnchor.C_C:
- break;
- case Data.TextAnchor.R_C:
- ih = Anchor.ANCHOR_RIGHT;
- break;
- case Data.TextAnchor.L_B:
- ih = Anchor.ANCHOR_LEFT;
- iv = Anchor.ANCHOR_BOTTOM;
- break;
- case Data.TextAnchor.C_B:
- iv = Anchor.ANCHOR_BOTTOM;
- break;
- case Data.TextAnchor.R_B:
- ih = Anchor.ANCHOR_RIGHT;
- iv = Anchor.ANCHOR_BOTTOM;
- break;
- default: break;
- }
- return ih | iv;
- }
- }
- }
|