コード例 #1
0
 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType)
 {
     if (destinationType == null)
     {
         throw new ArgumentNullException("destinationType");
     }
     if ((destinationType == typeof(string)) && (value is LinkArea))
     {
         LinkArea area = (LinkArea)value;
         if (culture == null)
         {
             culture = CultureInfo.CurrentCulture;
         }
         string        separator = culture.TextInfo.ListSeparator + " ";
         TypeConverter converter = TypeDescriptor.GetConverter(typeof(int));
         string[]      strArray  = new string[2];
         int           num       = 0;
         strArray[num++] = converter.ConvertToString(context, culture, area.Start);
         strArray[num++] = converter.ConvertToString(context, culture, area.Length);
         return(string.Join(separator, strArray));
     }
     if ((destinationType == typeof(InstanceDescriptor)) && (value is LinkArea))
     {
         LinkArea        area2       = (LinkArea)value;
         ConstructorInfo constructor = typeof(LinkArea).GetConstructor(new System.Type[] { typeof(int), typeof(int) });
         if (constructor != null)
         {
             return(new InstanceDescriptor(constructor, new object[] { area2.Start, area2.Length }));
         }
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }
コード例 #2
0
ファイル: LinkLabel.cs プロジェクト: raj581/Marvin
        public LinkLabel()
        {
            LinkArea      = new LinkArea(0, -1);
            link_behavior = LinkBehavior.SystemDefault;
            link_visited  = false;
            pieces        = null;
            focused_index = -1;

            string_format.FormatFlags |= StringFormatFlags.NoClip;

            ActiveLinkColor   = Color.Red;
            DisabledLinkColor = ThemeEngine.Current.ColorGrayText;
            LinkColor         = Color.FromArgb(255, 0, 0, 255);
            VisitedLinkColor  = Color.FromArgb(255, 128, 0, 128);
            SetStyle(ControlStyles.Selectable, false);
            SetStyle(ControlStyles.ResizeRedraw |
                     ControlStyles.UserPaint |
                     ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.SupportsTransparentBackColor |
                     ControlStyles.Opaque
#if NET_2_0
                     | ControlStyles.OptimizedDoubleBuffer
#else
                     | ControlStyles.DoubleBuffer
#endif
                     , true);
            CreateLinkPieces();
        }
コード例 #3
0
        public override bool Equals(object o)
        {
            if (!(o is LinkArea))
            {
                return(false);
            }
            LinkArea area = (LinkArea)o;

            return(this == area);
        }
コード例 #4
0
ファイル: LinkAreaTest.cs プロジェクト: nlhepler/mono
		public void Inequality ()
		{
			LinkArea l1 = new LinkArea (2, 4);
			LinkArea l2 = new LinkArea (4, 6);
			LinkArea l3 = new LinkArea (2, 4);

			Assert.IsFalse (l1 != l3, "A1");
			Assert.IsTrue (l1 != l2, "A2");
			Assert.IsTrue (l2 != l3, "A3");
		}
コード例 #5
0
        public override bool Equals(object o)
        {
            if (!(o is LinkArea))
            {
                return(false);
            }

            LinkArea comp = (LinkArea)o;

            return(comp.Start == start && comp.Length == length);
        }
コード例 #6
0
ファイル: LinkAreaTest.cs プロジェクト: nlhepler/mono
		public void LinkAreaToString ()
		{
			LinkArea la = new LinkArea ();
			Assert.AreEqual ("{Start=0, Length=0}", la.ToString (), "A1");

			la = new LinkArea (0, 0);
			Assert.AreEqual ("{Start=0, Length=0}", la.ToString (), "A2");

			la = new LinkArea (4, 75);
			Assert.AreEqual ("{Start=4, Length=75}", la.ToString (), "A3");		
		}
コード例 #7
0
        /// <include file='doc\LinkArea.uex' path='docs/doc[@for="LinkArea.Equals"]/*' />
        public override bool Equals(object o)
        {
            if (!(o is LinkArea))
            {
                return(false);
            }

            LinkArea a = (LinkArea)o;

            return(start == a.start && length == a.length);
        }
コード例 #8
0
ファイル: LinkArea.cs プロジェクト: dox0/DotNet471RS3
            /// <include file='doc\LinkArea.uex' path='docs/doc[@for="LinkArea.LinkAreaConverter.ConvertTo"]/*' />
            /// <devdoc>
            ///      Converts the given object to another type.  The most common types to convert
            ///      are to and from a string object.  The default implementation will make a call
            ///      to ToString on the object if the object is valid and if the destination
            ///      type is string.  If this cannot convert to the desitnation type, this will
            ///      throw a NotSupportedException.
            /// </devdoc>
            public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
            {
                if (destinationType == null)
                {
                    throw new ArgumentNullException("destinationType");
                }

                if (destinationType == typeof(string) && value is LinkArea)
                {
                    LinkArea pt = (LinkArea)value;

                    if (culture == null)
                    {
                        culture = CultureInfo.CurrentCulture;
                    }
                    string        sep          = culture.TextInfo.ListSeparator + " ";
                    TypeConverter intConverter = TypeDescriptor.GetConverter(typeof(int));
                    string[]      args         = new string[2];
                    int           nArg         = 0;

                    args[nArg++] = intConverter.ConvertToString(context, culture, pt.Start);
                    args[nArg++] = intConverter.ConvertToString(context, culture, pt.Length);

                    return(string.Join(sep, args));
                }
                if (destinationType == typeof(InstanceDescriptor) && value is LinkArea)
                {
                    LinkArea pt = (LinkArea)value;

                    ConstructorInfo ctor = typeof(LinkArea).GetConstructor(new Type[] { typeof(int), typeof(int) });
                    if (ctor != null)
                    {
                        return(new InstanceDescriptor(ctor, new object[] { pt.Start, pt.Length }));
                    }
                }

                return(base.ConvertTo(context, culture, value, destinationType));
            }
コード例 #9
0
ファイル: OneResultControl.cs プロジェクト: sheeeng/Zydeo
 public override void DoMouseLeave()
 {
     if (Parent == null) return;
     Cursor = Cursors.Arrow;
     // Cursor hovered over a link, or a sense: request a repaint
     if (hoverLink != null || hoverSenseIx != -1)
     {
         hoverLink = null;
         hoverSenseIx = -1;
         // Cannot request paint for myself directly: entire results control must be repainted in one
         // - Cropping when I'm outside parent's rectangle
         // - Stuff in overlays on top of me
         parentPaint();
     }
 }
コード例 #10
0
ファイル: LinkLabel.cs プロジェクト: JianwenSun/cc
 private void ResetLinkArea() {
     LinkArea = new LinkArea(0, -1);
 }
コード例 #11
0
ファイル: LinkLabel.cs プロジェクト: carrie901/mono
		public LinkLabel ()
		{
			LinkArea = new LinkArea (0, -1);
			link_behavior = LinkBehavior.SystemDefault;
			link_visited = false;
			pieces = null;
			focused_index = -1;

			string_format.FormatFlags |= StringFormatFlags.NoClip;
			
			ActiveLinkColor = Color.Red;
			DisabledLinkColor = ThemeEngine.Current.ColorGrayText;
			LinkColor = Color.FromArgb (255, 0, 0, 255);
			VisitedLinkColor = Color.FromArgb (255, 128, 0, 128);
			SetStyle (ControlStyles.Selectable, false);
			SetStyle (ControlStyles.ResizeRedraw | 
				ControlStyles.UserPaint | 
				ControlStyles.AllPaintingInWmPaint |
				ControlStyles.SupportsTransparentBackColor | 
				ControlStyles.Opaque |
				ControlStyles.OptimizedDoubleBuffer
				, true);
			CreateLinkPieces ();
		}
コード例 #12
0
 public ToolTipLinkLabel()
 {
     LinkArea = new LinkArea(0, 0);
 }
コード例 #13
0
ファイル: linkLabelEx.cs プロジェクト: hbaes/updateSystem.NET
		public linkLabelEx() {
			_urlEx = new Regex(@"\[url=([^\]]+)\]([^\]]+)\[\/url\]");
			base.Text = "LinkLabelEx";
			LinkArea = new LinkArea(0, 0);
			autoOpenLinks = true;
		}
コード例 #14
0
        /// <summary>
        /// <para>Produces unmeasured display blocks from a single hybrid text. Marks highlights, if any.</para>
        /// <para>Does not fill in blocks' size, but fills in everything else.</para>
        /// </summary>
        /// <param name="htxt">Hybrid text to break down into blocks and measure.</param>
        /// <param name="isMeta">True if this is a domain or note (displayed in italics).</param>
        /// <param name="hl">Highlight to show in hybrid text, or null.</param>
        /// <param name="blocks">List of blocks to append to.</param>
        /// <param name="links">List to gather links (appending to list).</param>
        private void makeBlocks(HybridText htxt, bool isMeta, CedictTargetHighlight hl,
            List<Block> blocks, List<LinkArea> links)
        {
            byte fntIdxLatin = isMeta ? fntMetaLatin : fntSenseLatin;
            byte fntIdxZhoSimp = isMeta ? fntMetaHanziSimp : fntSenseHanziSimp;
            byte fntIdxZhoTrad = isMeta ? fntMetaHanziTrad : fntSenseHanziTrad;
            // Go run by run
            for (int runIX = 0; runIX != htxt.RunCount; ++runIX)
            {
                TextRun run = htxt.GetRunAt(runIX);
                // Latin run: split by spaces first
                if (run is TextRunLatin)
                {
                    string[] bySpaces = run.GetPlainText().Split(new char[] { ' ' });
                    // Each word: also by dash
                    int latnPos = 0;
                    foreach (string str in bySpaces)
                    {
                        string[] byDashes = splitByDash(str);
                        // Add block for each
                        int ofsPos = 0;
                        foreach (string blockStr in byDashes)
                        {
                            Block tb = new Block
                            {
                                TextPos = textPool.PoolString(blockStr),
                                FontIdx = fntIdxLatin,
                                SpaceAfter = false, // will set this true for last block in "byDashes"
                            };
                            // Does block's text intersect with highlight?
                            if (hl != null && hl.RunIx == runIX)
                            {
                                int blockStart = latnPos + ofsPos;
                                int blockEnd = blockStart + blockStr.Length;
                                if (blockStart >= hl.HiliteStart && blockStart < hl.HiliteStart + hl.HiliteLength)
                                    tb.Hilite = true;
                                else if (blockEnd > hl.HiliteStart && blockEnd <= hl.HiliteStart + hl.HiliteLength)
                                    tb.Hilite = true;
                                else if (blockStart < hl.HiliteStart && blockEnd >= hl.HiliteStart + hl.HiliteLength)
                                    tb.Hilite = true;
                            }
                            blocks.Add(tb);
                            // Keep track of position for highlight
                            ofsPos += blockStr.Length;
                        }
                        // Make sure last one is followed by space
                        Block xb = blocks[blocks.Count - 1];
                        xb.SpaceAfter = true;
                        blocks[blocks.Count - 1] = xb;
                        // Keep track of position in text - for highlights
                        latnPos += str.Length + 1;
                    }
                }
                // Chinese: depends on T/S/Both display mode, and on available info
                else
                {
                    TextRunZho zhoRun = run as TextRunZho;
                    // Chinese range is made up of:
                    // Simplified (empty string if only traditional requested)
                    // Separator (if both simplified and traditional are requested)
                    // Traditional (empty string if only simplified requested)
                    // Pinyin with accents as tone marks, in brackets (if present)
                    string strSimp = string.Empty;
                    if (analyzedScript != SearchScript.Traditional && zhoRun.Simp != null) strSimp = zhoRun.Simp;
                    string strTrad = string.Empty;
                    if (analyzedScript != SearchScript.Simplified && zhoRun.Trad != null) strTrad = zhoRun.Trad;
                    string strPy = string.Empty;
                    // Convert pinyin to display format (tone marks as diacritics; r5 glued)
                    if (zhoRun.Pinyin != null) strPy = "[" + zhoRun.GetPinyinInOne(true) + "]";

                    // Create link area, with query string
                    string strPyNumbers = string.Empty; // Pinyin with numbers as tone marks
                    if (zhoRun.Pinyin != null) strPyNumbers = zhoRun.GetPinyinRaw();
                    LinkArea linkArea = new LinkArea(strSimp, strTrad, strPyNumbers, analyzedScript);

                    // Block for simplified, if present
                    if (strSimp != string.Empty)
                    {
                        Block tb = new Block
                        {
                            TextPos = textPool.PoolString(strSimp),
                            FontIdx = fntIdxZhoSimp,
                            SpaceAfter = true,
                        };
                        blocks.Add(tb);
                        linkArea.BlockIds.Add(blocks.Count - 1);
                    }
                    // Separator if both simplified and traditional are there
                    // AND they are different...
                    if (strSimp != string.Empty && strTrad != string.Empty && strSimp != strTrad)
                    {
                        Block xb = blocks[blocks.Count - 1];
                        xb.StickRight = true;
                        blocks[blocks.Count - 1] = xb;
                        Block tb = new Block
                        {
                            TextPos = textPool.PoolString("•"),
                            FontIdx = fntIdxLatin,
                            SpaceAfter = true,
                        };
                        blocks.Add(tb);
                        linkArea.BlockIds.Add(blocks.Count - 1);
                    }
                    // Traditional, if present
                    if (strTrad != string.Empty && strTrad != strSimp)
                    {
                        Block tb = new Block
                        {
                            TextPos = textPool.PoolString(strTrad),
                            FontIdx = fntIdxZhoTrad,
                            SpaceAfter = true,
                        };
                        blocks.Add(tb);
                        linkArea.BlockIds.Add(blocks.Count - 1);
                    }
                    // Pinyin, if present
                    if (strPy != string.Empty)
                    {
                        // Split by spaces
                        string[] pyParts = strPy.Split(new char[] { ' ' });
                        foreach (string pyPart in pyParts)
                        {
                            Block tb = new Block
                            {
                                TextPos = textPool.PoolString(pyPart),
                                FontIdx = fntIdxLatin,
                                SpaceAfter = true,
                            };
                            blocks.Add(tb);
                            linkArea.BlockIds.Add(blocks.Count - 1);
                        }
                    }
                    // Last part will have requested a space after.
                    // Look ahead and if next text run is Latin and starts with punctuation, make it stick
                    TextRunLatin nextLatinRun = null;
                    if (runIX + 1 < htxt.RunCount) nextLatinRun = htxt.GetRunAt(runIX + 1) as TextRunLatin;
                    if (nextLatinRun != null && char.IsPunctuation(nextLatinRun.GetPlainText()[0]))
                    {
                        Block xb = blocks[blocks.Count - 1];
                        xb.SpaceAfter = false;
                        blocks[blocks.Count - 1] = xb;
                    }
                    // Collect link area
                    links.Add(linkArea);
                }
            }
        }
コード例 #15
0
ファイル: OneResultControl.cs プロジェクト: sheeeng/Zydeo
 /// <summary>
 /// Updates state for hover behavior above links.
 /// </summary>
 /// <param name="p">Mouse coordinate.</param>
 /// <returns>True if control must request a repaint.</returns>
 private bool doCheckLinkHover(Point p)
 {
     // Are we over a link area?
     LinkArea overWhat = null;
     foreach (LinkArea link in targetLinks)
     {
         foreach (Rectangle rect in link.ActiveAreas)
         {
             if (rect.Contains(p))
             {
                 overWhat = link;
                 break;
             }
         }
     }
     // We're over a link
     //if (overWhat != null) Cursor = Cursors.Hand;
     if (overWhat != null) Cursor = CustomCursor.GetHand(Scale);
     // Nop, not over a link
     else Cursor = Cursors.Arrow;
     // Hover state changed: request a repaint
     if (overWhat != hoverLink)
     {
         hoverLink = overWhat;
         return true;
     }
     return false;
 }
コード例 #16
0
        public void WithStruct()
        {
            LinkArea linkArea = new LinkArea();
            // lots of code in between
            FluidUtils.With(ref linkArea, (l) =>
            {
                l.Start = 56;
                l.Length = 112;
                return l;
            });

            Assert.AreEqual(56, linkArea.Start);
            Assert.AreEqual(112, linkArea.Length);
        }
コード例 #17
0
 private void ShowCompleted(string status, LinkArea linkArea)
 {
     statusLinkLabel.Text = status;
     statusLinkLabel.LinkArea = linkArea;
     statusPictureBox.Image = Resources.review_sharestatus_icon_success;
 }