diff --git a/PROMS/Volian.Controls.Library/DisplayTransition.cs b/PROMS/Volian.Controls.Library/DisplayTransition.cs index f3cc64dc..c6007739 100644 --- a/PROMS/Volian.Controls.Library/DisplayTransition.cs +++ b/PROMS/Volian.Controls.Library/DisplayTransition.cs @@ -84,7 +84,7 @@ namespace Volian.Controls.Library //else //{ // StepPanelLinkEventArgs tmp = new StepPanelLinkEventArgs(null, e); - CurTrans = args.MyTransitionInfo; + CurTrans = args.MyLinkText.MyTransitionInfo; //} } private ItemInfo _CurrentItemProcedure; // the selected item's procedure diff --git a/PROMS/Volian.Controls.Library/RTBAPI.cs b/PROMS/Volian.Controls.Library/RTBAPI.cs index be1db9ad..2aed468c 100644 --- a/PROMS/Volian.Controls.Library/RTBAPI.cs +++ b/PROMS/Volian.Controls.Library/RTBAPI.cs @@ -802,9 +802,17 @@ namespace Volian.Controls.Library } public static void SetCharFormat(RichTextBox richTextBox, RTBSelection selection, CharFormatTwo cft) { - CharFormat2 cf2 = cft.CharFormat2; - if (SendMessage(new HandleRef(richTextBox, richTextBox.Handle), Messages.EM_SETCHARFORMAT, selection, ref cf2) == 0) - throw new Win32Exception(); + try + { + CharFormat2 cf2 = cft.CharFormat2; + if (SendMessage(new HandleRef(richTextBox, richTextBox.Handle), Messages.EM_SETCHARFORMAT, selection, ref cf2) == 0) + throw new Win32Exception(); + } + catch (Exception ex) + { + Console.WriteLine("Error on SetCharFormat {0}", ex.Message); + } + } public static void SetHighlightColor(RichTextBox richTextBox, RTBSelection selection, Color color) { @@ -874,6 +882,63 @@ namespace Volian.Controls.Library } SetCharFormat(richTextBox, selection, cft); } + public static bool IsBold(RichTextBox richTextBox) + { + CharFormatTwo cft = GetCharFormat(richTextBox, RTBSelection.SCF_SELECTION); + return ((cft.dwEffects & CharFormatEffects.CFE_BOLD) == CharFormatEffects.CFE_BOLD); + } + public static void ToggleBold(bool bSet, RichTextBox richTextBox, RTBSelection selection) + { + CharFormatTwo cft = GetCharFormat(richTextBox, selection); + if (bSet) + { + cft.dwEffects |= CharFormatEffects.CFE_BOLD; + cft.dwMask |= CharFormatMasks.CFM_BOLD; + } + else + { + cft.dwEffects &= ~RTBAPI.CharFormatEffects.CFE_BOLD; + } + SetCharFormat(richTextBox, selection, cft); + } + public static bool IsUnderline(RichTextBox richTextBox) + { + CharFormatTwo cft = GetCharFormat(richTextBox, RTBSelection.SCF_SELECTION); + return ((cft.dwEffects & CharFormatEffects.CFE_UNDERLINE) == CharFormatEffects.CFE_UNDERLINE); + } + public static void ToggleUnderline(bool bSet, RichTextBox richTextBox, RTBSelection selection) + { + CharFormatTwo cft = GetCharFormat(richTextBox, selection); + if (bSet) + { + cft.dwEffects |= CharFormatEffects.CFE_UNDERLINE; + cft.dwMask |= CharFormatMasks.CFM_UNDERLINE; + } + else + { + cft.dwEffects &= ~RTBAPI.CharFormatEffects.CFE_UNDERLINE; + } + SetCharFormat(richTextBox, selection, cft); + } + public static bool IsItalic(RichTextBox richTextBox) + { + CharFormatTwo cft = GetCharFormat(richTextBox, RTBSelection.SCF_SELECTION); + return ((cft.dwEffects & CharFormatEffects.CFE_ITALIC) == CharFormatEffects.CFE_ITALIC); + } + public static void ToggleItalic(bool bSet, RichTextBox richTextBox, RTBSelection selection) + { + CharFormatTwo cft = GetCharFormat(richTextBox, selection); + if (bSet) + { + cft.dwEffects |= CharFormatEffects.CFE_ITALIC; + cft.dwMask |= CharFormatMasks.CFM_ITALIC; + } + else + { + cft.dwEffects &= ~RTBAPI.CharFormatEffects.CFE_UNDERLINE; + } + SetCharFormat(richTextBox, selection, cft); + } public static bool IsLink(RichTextBox richTextBox) { CharFormatTwo cft = GetCharFormat(richTextBox, RTBSelection.SCF_SELECTION);