Understand This Code
Understand This Code
Understand This Code
Understand This Code
Understand This Code
Understand This Code Understand This Code Understand This Code Understand This Code Understand This Code Understand This Code Understand This Code Understand This Code
Understand This Code Understand This Code
Understand This Code
Go Back  Xtreme Visual Basic Talk > > > Understand This Code


Reply
 
Thread Tools Display Modes
  #1  
Old 01-22-2014, 10:17 AM
JeremyBenson11 JeremyBenson11 is offline
Regular
 
Join Date: Dec 2013
Posts: 50
Default Understand This Code


hmm,

I'm still trying to learn how to create textranges and do searches but lack of knowledge on the following code is making it impossible to learn. Could anyone help me understand the following?

Code:
 if (position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text)
This is comparing value returned from GetPointerContext, but what exactly is that value? On msdn it says One of the TextPointerContext values that indicates the category for adjacent content in the specified logical direction.

I'm not sure what a textpointercontext is, and to me that sentence isn't even english, lol.

It's compared to TextPointerContext.Text which seems to be an undeclared class or value. What's that line of code refer to? I can't seem to find it...

Thanks in advanced for the help, sorry for tone here... getting stuck, and lack of learning making me a bit off, lol.
Reply With Quote
  #2  
Old 01-22-2014, 03:05 PM
passel's Avatar
passelUnderstand This Code passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,024
Default

May not look like english to you, but it doesn't look like Visual Basic to Me.

I don't do any XML, so have no idea, but it seems if you look up TextPointerContext it indicates it is an enumeration, which appears to indicated what type of element is next to the TextPointer in a document, i.e. is it Text, or an ElementEnd orElementStart, etc.

So, I would interpret that If statement to be saying,
If the characters in the forward direction from my current position are text Then ...
Text, as opposed to a Start tag, or End tag.

Again, I don't do XML so really don't know what I'm talking about.
The first TextPointerContext link I saw when doing a quick search was this one, perhaps you can gain more insight from it than I.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #3  
Old 01-23-2014, 09:29 AM
JeremyBenson11 JeremyBenson11 is offline
Regular
 
Join Date: Dec 2013
Posts: 50
Default

Hey,

sorry Passel. You're right. That was C#. The line I should have posted was

Code:
 If position.GetPointerContext(LogicalDirection.Forward) = TextPointerContext.Text Then
So that's saying if the text pointer is next to text do this...

That makes sense. So what does enumeration mean? I understand the data-type a bit from C+, but not sure what it means in this context.

TextPointerContext.Text looks strange to me is because it looks like an undeclared variable being used...

It must be some kind of global syntax?
Reply With Quote
  #4  
Old 01-23-2014, 10:43 AM
passel's Avatar
passelUnderstand This Code passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,024
Default

It is an Enumeration type, which basically means a list of names that equated to some number, which you may not need to know the actual number since you can referece it by name.
The TextPointerContext Enumeration Type is from the System.Windows.Documents namespace.

I was going to try to find other Enumerations you might be familiar with, like Colors.Red, etc. but Red unfortuantely is not an enumeration, but a structure and Colors and Color are classes. Looking at the mouse button values, those are Public constants, not an enumeration either.
<edit>
No, MouseButtons is an enumeration, the Public constants is just the way the numbers that make up the enumeration are implemented for enumeration types, so ...
MouseButtons.Left {= 1048576 }
MouseButtons.Right {= 2097152 }
MouseButtons.Middle { = 4194304 }
etc...
are values you can check to see which button was pressed
(imagine if you had to use those numbers instead of the names Left, Right, etc..)
just as
TextPointerContext.None {= 0 }
TextPointerContext.Text {= 1 }
TextPointerContext.Start {= 3 }
etc...
are values you can check against to identify the Context of a Document Element.
</edit>

So, I guess I'll just give you an MSDN Enum Class link to scroll down in to see examples of creating enumeration types, so maybe that will help you understand what an enumeration type is.

p.s. Those of us who deal with binary representations fairly regularly would probably recognize those hugh decimal numbers for the buttons just being individual high-order bits in a 32-bit word, so would be of the <Flags> Attribute type of enumeration, and in Hex wouldn't look quite so arbitrary, i.e.
Middle would be 0x4000000, Right = 0x2000000, Left = 0x1000000, which allows multiple buttons to be indicated as down at the same time by combining the bits. But using the name instead of having to use the numbers is still much more convenient.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.

Last edited by passel; 01-23-2014 at 11:15 AM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Understand This Code
Understand This Code
Understand This Code Understand This Code
Understand This Code
Understand This Code
Understand This Code Understand This Code Understand This Code Understand This Code Understand This Code Understand This Code Understand This Code
Understand This Code
Understand This Code
 
Understand This Code
Understand This Code
 
-->