Is there a way to get graphic text to scale in ArcMap? - gis

I'm using this code to create text in ArcMap. But I can't seem to get it to scale like annotation text when you zoom in.
Does anyone know how to do this?
//'First setup a color. We'll use RGB red
IRgbColor pRGBcolor = new RgbColor();
pRGBcolor.Blue = 0;
pRGBcolor.Red = 255;
pRGBcolor.Green = 0;
//'Next, cocreate a new TextElement
ITextElement pTextElement = new TextElementClass();
//'Query Interface (QI) to an IElement pointer and set
//'the geometry that was passed in
IElement pElement = pTextElement as IElement;
pElement.Geometry = Point;
//'Next, setup a font
stdole.IFontDisp pFontDisp = new stdole.StdFont() as stdole.IFontDisp;
pFontDisp.Name = "Arial";
pFontDisp.Bold = true;
//'Next, setup a TextSymbol that the TextElement will draw with
ITextSymbol pTextSymbol = new ESRI.ArcGIS.Display.TextSymbolClass();
pTextSymbol.Font = pFontDisp;
pTextSymbol.Color = pRGBcolor;
pTextSymbol.Size = Size;
pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;
pTextSymbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;
pTextSymbol.Angle = Angle;
pTextSymbol.Text = Text;
//'set the size of the text symbol here, rather than on the font
//'Next, Give the TextSymbol and text string to the TextElement
pTextElement.Symbol = pTextSymbol;
pTextElement.Text = pTextSymbol.Text;
pTextElement.ScaleText = true;
ESRI.ArcGIS.Carto.IElementProperties3 aoElementPro = pTextElement as ESRI.ArcGIS.Carto.IElementProperties3;
aoElementPro.ReferenceScale = cGISHelpers.MapDomain.Map.MapScale;

We can very well add text which changes it size according to the scale. for this, we need to use the IElementProperties3.ReferenceScale Property.
I do not have C# code, but am attaching some sample VBA code that you can modify.
'--------------------------------
Sub ChangeTextElemRefScale()
Dim pDoc As IMxDocument
Dim pContainer As IGraphicsContainer
Dim pElement As IElement
Dim pTextElement As ITextElement
Dim pActiveView As IActiveView
Set pDoc = ThisDocument
Set pActiveView = pDoc.ActiveView
Set pContainer = pActiveView
'Loop through the graphics container
pContainer.Reset
Set pElement = pContainer.Next
While not pElement Is Nothing
'Get the specific text element
If TypeOf pElement Is ITextElement Then
Set pTextElement = pElement
If pTextElement.Text = "oregon" Then 'change this to your text element's text
Dim pElemProp As IElementProperties3
Set pElemProp = pTextElement
pElemProp.ReferenceScale = 15000000
End If
End If
Set pElement = pContainer.Next
Wend
pDoc.ActiveView.PartialRefresh esriViewGraphics, Nothing, Nothing
End Sub
'--------------------------------

To my knowledge, you can't get a TextSymbol to scale along with the map. That's because the TextElement isn't changeable based upon the map's extent but, instead, uses the font size to determine how large it's going to appear on the screen.
The best way that I can think of to do it while still using a TextSymbol is to change the point size (and, if the extent is large enough, hide/show the element) as the extent changes. I don't know of a "text control that pays attention to the extent," which is what you would really need.
Alternately, couldn't you just use an annotation layer or label the layer where you want the text size to change?

The ITextElement has got a property ITextElement.ScaleText. Set this to true and the text size will adapt automatically.

Related

VBA - Filling input boxes in Internet Explorer not working

I'm having the following problem which is once I populate some inputbox on IE with information from Excel using VBA, these are populated correctly but when i change onto the second line with input boxes (they all are the same in format) the one I filled before does not get saved (even if I press save).. the only way I found for the information to remain is if I get into any of these boxes I'm filling and type something manually.
Anyone has an idea of why this might be?
Thanks!
For Each cell In wsbd.range(range("A6"), range("A6").End(xlDown))
additemsbtn.Click
Set aNodeList = ieDoc.querySelectorAll("[dojoinsertionindex]")
aNodeList.Item(0).Click
For i = 0 To 15
If ieDoc.getElementById("meetingResultsPlanningTable").getElementsByTagName("select")(0).Item(i).innerText = wsbd.range("A6").Value Then
ieDoc.getElementById("meetingResultsPlanningTable").getElementsByTagName("select")(0).Item(i).Selected = True
Exit For
End If
Next i
Set dropOptions = ieDoc.getElementById("meetingResultsPlanningTable").getElementsByTagName("select")(5)
dropOptions.Value = "Value"
Set itemName = ieDoc.getElementById("dynamicLineItems").getElementsByClassName("InputBox")(0)
itemName.Value = wsbd.range("F6").Value
Set itemName = ieDoc.getElementById("dynamicLineItems").getElementsByClassName("NumInputBox2")(0)
itemName.Value = wsbd.range("J6").Value
Set itemName = ieDoc.getElementById("dynamicLineItems").getElementsByClassName("NumInputBox")(0)
itemName.Value = wsbd.range("Q6").Value
Set itemName = ieDoc.getElementById("dynamicLineItems").getElementsByClassName("NumInputBox")(1)
itemName.Value = wsbd.range("T6").Value * 100
Set itemName = ieDoc.getElementById("dynamicLineItems").getElementsByClassName("NumInputBox")(1)
itemName.Value = itemName.Value + 0
'Set savebtn = ieDoc.getElementById("/images/buttons/save.gif")
' savebtn.Click
Next cell
The code is working and is reading properly all the inofrmation in Excel, finding the corresponding Input boxes and populating them but then nothing gets saved or recorded.. as you can see I tried saving after completing the boxes but it still doesn't work...
I came up with a solution! And pretty simple by the way.. I just added a fireevent ("onchange") for each input box and that records all changes!
Set itemName = ieDoc.getElementById("dynamicLineItems").getElementsByClassName("InputBox")(0)
itemName.Focus
itemName.FireEvent ("onchange")
itemName.Value = somevalue.Value

MS Access Toggle Button background

Is it possible to totally remove the background color and the border of a toggle button in Access? As shown in the Imgur picture, I'd like to remove the grey-ish background and the border of the button totally so I'd keep the white icon (that list icon) only. Would that even be possible?
I am sure this is related to your other question at MS Access ToggleButton Picture change.
Use an Image control with embedded image and this code (note declaration of public variable in header):
Option Compare Database
Option Explicit
Public booMenu
Sub timeout(duration_ms As Double)
Dim Start_Time As Double
Start_Time = Timer
Do
DoEvents
Loop Until (Timer - Start_Time) >= duration_ms
End Sub
Private Sub Image5_Click()
Dim x As Integer
booMenu = Not booMenu
Me.Menu.Visible = True
Do
DoEvents
Me.Menu.Width = Me.Menu.Width + IIf(booMenu, 200, -200)
Me.Menu.Left = Me.Menu.Left - IIf(booMenu, 200, -200)
Me.Image5.Left = Me.Image5.Left - IIf(booMenu, 200, -200)
timeout (0.01)
x = x + 1
Loop Until x = 10
Me.Menu.Visible = booMenu
End Sub
I managed to find (kind of) a solution to this. The solution was to change the following parameters:
Use Theme = No;
BackColor = Form Color;
Pressed Back Color = Form Color
Eventually, it provides an effect very similar to the one that I was trying to achieve.

as3 textfield wordwrap true causing textwidth to be weird

I'm trying to wordwrap a textfield inside a button, however after i set wordwrap to true some unexpected behavior happened.
Button.width = 390;
Button.textField.autoSize = TextFieldAutoSize.LEFT;
Button.textField.border = true;
Button.textField.wordwrap = true;
Button.textField.multiline = true;
Button.textField.width = textButton.width - 10;
Button.textField.x = 5;
Button.height = 60;
This is what happens:
When I'm outputting the Button.textField.textWidth, it seems shown a value that so much less than Button or Button.textField.width. I just want to make the word break after textwidth meets the textField.width maximum value. Is there anything that I can do to change this behavior? …since I can't change the value of Button.textField.textWidth (read-only).
Comment out the Button.textField.autoSize setting. This is probably what is throwing everything off.
You're setting the text field's width to match the size of the button when you set width = textButton.width - 10, but you're also telling it to automatically resize the textField to match the size of the actual text when you set the autoSize setting. So it's not going to fit the button the way you want it to.

Modify TLF Text Field properties that is on stage

I have a TLF Text field on the stage. I am trying to test this out in simple flash document.
My code takes in some xml that I parse. The xml will vary and will not always change all the properties of the text field. For instance in one case I only want to change the size of the font. In another case I only want to change the alignment of the font.
I am using TLF Text fields because we will translating into Arabic and I already have gotten Right to Left text working with them.
These are some properties I will need to edit in code:
Font Size
Font
Alignment
Leading
Bold, Italic, Underline (weight)
Any coding help would be great. I have seen ideas out there for text flow and text layout but I am obviously not using it correctly because I can't get it to work.
Long ago before I give up and stop using TLF fields. I have a project that requests dynamic addind and removing tlf fileds from/to stage. This is a code from this project:
This will generate default format dynamically
var config:Configuration = new Configuration();
var defTextFormat: TextLayoutFormat = new TextLayoutFormat();
defTextFormat.textAlign = TextAlign.LEFT;
defTextFormat.fontFamily = m_strFontName;
defTextFormat.fontSize = m_nFontSize;
defTextFormat.fontWeight = FontWeight.BOLD
defTextFormat.paddingLeft = 3;
defTextFormat.paddingTop = 3;
defTextFormat.paragraphStartIndent = 3;
defTextFormat.paragraphSpaceBefore = 3;
config.defaultLinkActiveFormat = defTextFormat;
config.defaultLinkHoverFormat = defTextFormat;
config.defaultLinkNormalFormat = defTextFormat;
config.textFlowInitialFormat = ITextLayoutFormat( defTextFormat );
m_textFlow = new TextFlow( config );
member m_textFlow holds a ref to TLF field.
To add and remove elements use m_textFlow.addChild( p ); where p is paragraph element
see: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flashx/textLayout/elements/ParagraphElement.html
To change the FontSize and color an element for example :
var _p:ParagraphElement = ParagraphElement( m_textFlow.getChildAt( iChild ) );
for ( var iParChild: uint = 0; iParChild < _p.numChildren; ++iParChild )
{
_p.getChildAt( iParChild ).color = color;
_p.getChildAt( iParChild ).fontSize = nRatio;
...
Maybe this can help you.

textbox autoresizing in actionscript3

I need to realize textbox autoresizing in actionscript3(IDE - adobe flash pro cs3). For example my textarea is in width 100 px, user has been wrote in it something, that is bigger than 100 px, then my textbox should become increasingly. any ideas?
Also I can't realize multiline option: when the text goes beyond the textbox, it starts to scroll. In line type I've chosen 'multiline'.
thanks
try this:
textfield.autoSize = "left";
textfield.multiline = true;
textfield.wordWrap = true;
Hope it helps,
Rob
If you want to resize textfield automaticaly you can use textfield.autoSize property.
Wnen you are using multiline textfield, then setting
textfield.autoSize = TextFieldAutoSize.LEFT;
will align text to left and resize field vertically. If you use single line text field, it will resize to the right.
The TextField's .autosize property is great for sizing dynamic text fields when you already know the text string (but mind the .multiline and .wordwrap properties), but won't be helpful for input text fields.
For input text, I'd suggest listening for the Event.CHANGE event, then updating the width/height based on the number of lines, the .textWidth, or TextLineMetrics info (e.g. myTextField.getLineMetrics).
Here's a quick example:
var myField:TextField = new TextField();
myField.x = 10;
myField.y = 10;
myField.width = 100;
myField.height = 20;
myField.border = true;
myField.type = TextFieldType.INPUT;
myField.addEventListener(Event.CHANGE, textChangeHandler);
addChild(myField);
function textChangeHandler(evt:Event) {
var buffer:Number = 10;
myField.width = Math.max(100, (myField.textWidth + buffer));
myField.scrollH = 0;
}
Edit: Oh, and if you want that to work with .multiline, then just add:
myField.multiline = true;
and in the textChangeHandler function add:
myField.height = myField.textHeight + buffer;