private void UpdateDisconnectedUITheme(bool isPaused) { GuiConnectButtonImage.Image = Colors.IsDarkMode ? NSImage.ImageNamed("buttonConnectDark") : NSImage.ImageNamed("buttonConnect"); if (isPaused == false) { GuiConnectButtonText.AttributedStringValue = AttributedString.Create( LocalizedStrings.Instance.LocalizedString("Button_Connect"), Colors.ConnectButtonTextColor, NSTextAlignment.Center); GuiLabelToDoDescription.AttributedStringValue = AttributedString.Create( LocalizedStrings.Instance.LocalizedString("Label_ClickToConnect"), __ToDoDescriptionTextColor, NSTextAlignment.Center); } else { GuiConnectButtonText.AttributedStringValue = AttributedString.Create( LocalizedStrings.Instance.LocalizedString("Button_Resume"), Colors.ConnectButtonTextColor, NSTextAlignment.Center); GuiLabelToDoDescription.AttributedStringValue = AttributedString.Create( LocalizedStrings.Instance.LocalizedString("Label_ClickToResume"), __ToDoDescriptionTextColor, NSTextAlignment.Center); } }
public virtual AttributedCharacterIterator iterator() { AttributedString aString = new AttributedString(Convert.ToString(character)); aString.addAttribute(TextAttribute.FONT, font, 0, 1); return(aString.getIterator()); }
private void InitDefaultNetworkActionsButton() { NSMenuItem menuUntrusted = new NSMenuItem("", OnNetworksDefaultAction_Changed) { AttributedTitle = AttributedString.Create(LocalizedStrings.Instance.LocalizedString("NetworkConfig_Untrusted"), NSColor.SystemRedColor, NSTextAlignment.Left), Tag = (int)NetworkActionsConfig.WiFiActionTypeEnum.Untrusted }; NSMenuItem menuTrusted = new NSMenuItem("", OnNetworksDefaultAction_Changed) { AttributedTitle = AttributedString.Create(LocalizedStrings.Instance.LocalizedString("NetworkConfig_Trusted"), NSColor.SystemBlueColor, NSTextAlignment.Left), Tag = (int)NetworkActionsConfig.WiFiActionTypeEnum.Trusted }; NSMenuItem menuNoAction = new NSMenuItem("", OnNetworksDefaultAction_Changed) { AttributedTitle = AttributedString.Create(LocalizedStrings.Instance.LocalizedString("NetworkConfig_NoAction"), NSColor.SystemGrayColor, NSTextAlignment.Left), Tag = (int)NetworkActionsConfig.WiFiActionTypeEnum.None }; NetworksDefaultActionBtn.Menu.RemoveAllItems(); NetworksDefaultActionBtn.Menu.AddItem(menuUntrusted); NetworksDefaultActionBtn.Menu.AddItem(menuTrusted); NetworksDefaultActionBtn.Menu.AddItem(menuNoAction); if (NetworksDefaultActionBtn.Menu.Delegate == null) { NetworksDefaultActionBtn.Menu.Delegate = new MenuDelegateInvertHighlitedItem(); } NetworksDefaultActionBtn.SelectItemWithTag((int)__Settings.NetworkActions.DefaultActionType); }
/** * Convert the underlying Set of rich text Runs into java.text.AttributedString */ public AttributedString GetAttributedString(TextRun txRun){ String text = txRun.GetText(); //TODO: properly process tabs text = text.Replace('\t', ' '); text = text.Replace((char)160, ' '); AttributedString at = new AttributedString(text); RichTextRun[] rt = txRun.GetRichTextRuns(); for (int i = 0; i < rt.Length; i++) { int start = rt[i].GetStartIndex(); int end = rt[i].GetEndIndex(); if(start == end) { logger.log(POILogger.INFO, "Skipping RichTextRun with zero length"); continue; } at.AddAttribute(TextAttribute.FAMILY, rt[i].GetFontName(), start, end); at.AddAttribute(TextAttribute.SIZE, new Float(rt[i].GetFontSize()), start, end); at.AddAttribute(TextAttribute.FOREGROUND, rt[i].GetFontColor(), start, end); if(rt[i].IsBold()) at.AddAttribute(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD, start, end); if(rt[i].IsItalic()) at.AddAttribute(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE, start, end); if(rt[i].IsUnderlined()) { at.AddAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON, start, end); at.AddAttribute(TextAttribute.INPUT_METHOD_UNDERLINE, TextAttribute.UNDERLINE_LOW_TWO_PIXEL, start, end); } if(rt[i].IsStrikethrough()) at.AddAttribute(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON, start, end); int superScript = rt[i].GetSuperscript(); if(superScript != 0) at.AddAttribute(TextAttribute.SUPERSCRIPT, superScript > 0 ? TextAttribute.SUPERSCRIPT_SUPER : TextAttribute.SUPERSCRIPT_SUB, start, end); } return at; }
/// <summary> /// Creates an AttributedCharacterIterator with the contents of /// <code>iterator</code> and the additional attribute <code>key</code> /// <code>value</code>. /// </summary> /// <param name="iterator"> Initial AttributedCharacterIterator to add arg to </param> /// <param name="key"> Key for AttributedCharacterIterator </param> /// <param name="value"> Value associated with key in AttributedCharacterIterator </param> /// <returns> AttributedCharacterIterator wrapping args </returns> internal virtual AttributedCharacterIterator CreateAttributedCharacterIterator(AttributedCharacterIterator iterator, AttributedCharacterIterator_Attribute key, Object value) { AttributedString @as = new AttributedString(iterator); @as.AddAttribute(key, value); return(@as.Iterator); }
/// <summary> /// Create a Bidi object representing the bidi information on a line of text within /// the paragraph represented by the current Bidi. This call is not required if the /// entire paragraph fits on one line. /// </summary> /// <param name="lineStart"> the offset from the start of the paragraph to the start of the line. </param> /// <param name="lineLimit"> the offset from the start of the paragraph to the limit of the line. </param> /// <returns> a {@code Bidi} object </returns> public Bidi CreateLineBidi(int lineStart, int lineLimit) { AttributedString astr = new AttributedString(""); Bidi newBidi = new Bidi(astr.Iterator); return(BidiBase.setLine(this, BidiBase, newBidi, newBidi.BidiBase, lineStart, lineLimit)); }
public TextLineDisplay( AttributedString <TFont, TGlyph> text, Range range, TypesettingContext <TFont, TGlyph> context, IReadOnlyList <MathAtom> atoms, PointF position) : this( text.Runs.Select(run => new TextRunDisplay <TFont, TGlyph>(run, new Range(range.Location, run.Length), context) ).ToList(), atoms, position) { }
public override void WindowDidLoad() { base.WindowDidLoad(); GuiBtnLaunchAtLogin.IntValue = (__Settings.RunOnLogin) ? 1 : 0; // Add 'WARNING' text of red color to the WireGuard description text NSMutableAttributedString wgDescriptionText = new NSMutableAttributedString(); var warningStr = AttributedString.Create("WARNING: ", NSColor.Red, GuiWireGuardDescription.Alignment, GuiWireGuardDescription.Font); wgDescriptionText.Insert(GuiWireGuardDescription.AttributedStringValue, 0); wgDescriptionText.Insert(warningStr, 0); GuiWireGuardDescription.AttributedStringValue = wgDescriptionText; }
private void ShowConnectedAnimation() { View.IsVisibleCircles = false; GuiConnectButtonImage.Hidden = false; GuiConnectButtonText.Hidden = false; UpdateToDoLabelHiddenStatus(false); GuiConnectButtonImage.AlphaValue = 0f; GuiLabelToDoDescription.AlphaValue = 0f; GuiConnectButtonText.AttributedStringValue = AttributedString.Create( LocalizedStrings.Instance.LocalizedString("Button_Disconnect"), __ConnectedButtonTextColor, NSTextAlignment.Center); GuiConnectButtonText.AlphaValue = 1f; GuiLabelToDoDescription.AttributedStringValue = AttributedString.Create( LocalizedStrings.Instance.LocalizedString("Label_ClickToDisconnect"), __ToDoDescriptionTextColor, NSTextAlignment.Center); GuiConnectButtonImage.Image = NSImage.ImageNamed("buttonConnected"); var frame = GuiConnectButtonImage.Frame; CGRect oldBounds = new CGRect(0, 0, frame.Width, frame.Height); nfloat offset = frame.Width * 0.1f; CGRect newBounds = new CGRect(-offset, -offset, oldBounds.Width + offset * 2, oldBounds.Height + offset * 2); GuiConnectButtonImage.Bounds = newBounds; NSAnimationContext.RunAnimation((NSAnimationContext context) => { context.Duration = 0.5f; ((NSView)GuiConnectButtonImage.Animator).Bounds = oldBounds; ((NSView)GuiConnectButtonImage.Animator).AlphaValue = 1f; ((NSView)GuiLabelToDoDescription.Animator).AlphaValue = 1f; }, () => { GuiConnectButtonImage.Bounds = oldBounds; ShowConnectedStatusAtimation(); }); }
private void Initialize() { _timerHideWnd.Elapsed += OnTimerHideWindowEvent; this.Window.OnDoubleClick += () => { OnDoubleClick?.Invoke(); }; this.Window.OnClick += () => { OnClick?.Invoke(); }; Window.IsVisible = false; Window.AlphaValue = 0.9f; // set background colors Window.BackgroundColor = WindowBackgroundColor; FirewallStatusLabel.TextColor = TextStatusColor; VPNStatusLabel.TextColor = TextStatusColor; PauseTimeLeftLabel.TextColor = TextStatusColor; FirewallLabel.TextColor = TextLabelColor; VPNLabel.TextColor = TextLabelColor; ResumeInLabel.TextColor = TextLabelColor; NSImage resumeBtnImage = NSImage.ImageNamed("iconPlayWhite"); resumeBtnImage.Size = new CoreGraphics.CGSize(9, 12); ResumeBtn.Image = resumeBtnImage; ResumeBtn.TitleTextAttributedString = AttributedString.Create(" " + __appServices.LocalizedString("Button_Resume"), NSColor.White, null, UIUtils.GetSystemFontOfSize(12f, NSFontWeight.Semibold)); ResumeBtn.BackgroundColor = NSColor.Black; ResumeBtn.IconLocation = CustomButton.IconLocationEnum.Right; ResumeBtn.CornerRadius = 7; // locationg UI elements on right place // (some elements are located not on rihght places (in order to easiest view in Xcode designer during developing)) nfloat offset = FirewallLabel.Frame.Y - ResumeInLabel.Frame.Y; CoreGraphics.CGRect oldFrame = Window.Frame; Window.SetFrame(new CoreGraphics.CGRect(oldFrame.X, oldFrame.Y + offset, oldFrame.Width, oldFrame.Height - offset), false); // update data according to ViewModel (on property changed) __viewModel = new FloatingOverlayWindowViewModel(__AppState, __service, __appServices, __MainViewModel); __viewModel.PropertyChanged += _viewModel_PropertyChanged; __viewModel.Initialize(); __MainViewModel.PropertyChanged += MainViewModel_PropertyChanged; EnsureUIConsistent(); }
private void ShowDisconnectingAnimation(bool isPausing = false) { View.IsVisibleCircles = true; if (isPausing == false) { GuiConnectButtonText.AttributedStringValue = AttributedString.Create( LocalizedStrings.Instance.LocalizedString("Button_Disconnecting"), Colors.ConnectButtonTextColor, NSTextAlignment.Center); } else { GuiConnectButtonText.AttributedStringValue = AttributedString.Create( LocalizedStrings.Instance.LocalizedString("Button_Pausing"), Colors.ConnectButtonTextColor, NSTextAlignment.Center); } GuiConnectButtonText.AlphaValue = 1f; UpdateToDoLabelHiddenStatus(true); var frame = GuiConnectButtonImage.Frame; CGRect oldBounds = new CGRect(0, 0, frame.Width, frame.Height); nfloat offset = frame.Width * 0.4f; CGRect newBounds = new CGRect(-offset, -offset, oldBounds.Width + offset * 2, oldBounds.Height + offset * 2); GuiConnectButtonImage.Bounds = oldBounds; NSAnimationContext.RunAnimation((NSAnimationContext context) => { context.Duration = 0.5f; ((NSView)GuiConnectButtonImage.Animator).Bounds = newBounds; ((NSView)GuiConnectButtonImage.Animator).AlphaValue = 0f; }, () => { GuiConnectButtonImage.Bounds = oldBounds; }); AnimateButtonTextBlinking(); }
public bool IsPartialStringValid(ref NSString partialString, ref NSRange proposedSelectedRange, NSString originalString, NSRange originalSelectedRange, ref NSString errorDescription) { AttributedString.SetAttributes(DefaultAttributesDictionary, new NSRange(0, AttributedString.Length)); var newAttributes = new NSMutableDictionary(DefaultAttributesDictionary); #if __UNIFIED__ newAttributes[NSStringAttributeKey.ForegroundColor] = NSColor.Red; #else newAttributes[NSAttributedString.ForegroundColorAttributeName] = NSColor.Red; #endif // __UNIFIED__ var x = new NSMutableAttributedString(partialString, newAttributes); x.SetAttributes(newAttributes, new NSRange(0, partialString.Length)); AttributedString.SetString(x); ////AttributedString.AddAttribute((NSString)"NSForegroundColorAttributeName", NSColor.Red, new NSRange(0, theString.Length)); if (TextUpdateCallback != null) { TextUpdateCallback(partialString, INTV.Shared.Behavior.ValidEmailAddressBehavior.IsValidEmailAddress(partialString)); } return(true); }
private void RecreateNetworkActionsButtonItems() { NSMenuItem menuUntrusted = new NSMenuItem("", NetworkActionButton_Changed) { AttributedTitle = AttributedString.Create(GetActionName(WiFiActionTypeEnum.Untrusted), NSColor.SystemRedColor, NSTextAlignment.Center), Tag = (int)WiFiActionTypeEnum.Untrusted }; NSMenuItem menuTrusted = new NSMenuItem("", NetworkActionButton_Changed) { AttributedTitle = AttributedString.Create(GetActionName(WiFiActionTypeEnum.Trusted), NSColor.SystemBlueColor, NSTextAlignment.Center), Tag = (int)WiFiActionTypeEnum.Trusted }; NSMenuItem menuNoAction = new NSMenuItem("", NetworkActionButton_Changed) { AttributedTitle = AttributedString.Create(GetActionName(WiFiActionTypeEnum.None), NSColor.Black, NSTextAlignment.Center), Tag = (int)WiFiActionTypeEnum.None }; NSMenuItem menuDefaultAction = new NSMenuItem("", NetworkActionButton_Changed) { AttributedTitle = (__MainViewModel.WiFiActionType == WiFiActionTypeEnum.Default && __MainViewModel.Settings.NetworkActions.DefaultActionType == WiFiActionTypeEnum.None) ? AttributedString.Create(LocalizedStrings.Instance.LocalizedString("NetworkConfig_ActionNotSet"), NSColor.SystemGrayColor, NSTextAlignment.Center) : AttributedString.Create(GetActionName(WiFiActionTypeEnum.Default) + ": " + GetActionName(__MainViewModel.Settings.NetworkActions.DefaultActionType), NSColor.SystemGrayColor, NSTextAlignment.Center), Tag = (int)WiFiActionTypeEnum.Default }; GuiNetworkActionPopUpBtn.Menu.RemoveAllItems(); GuiNetworkActionPopUpBtn.Menu.AddItem(menuUntrusted); GuiNetworkActionPopUpBtn.Menu.AddItem(menuTrusted); //GuiNetworkActionPopUpBtn.Menu.AddItem(menuNoAction); // 'No action' available only for 'Default' action GuiNetworkActionPopUpBtn.Menu.AddItem(menuDefaultAction); GuiNetworkActionPopUpBtn.SelectItemWithTag((int)__MainViewModel.WiFiActionType); if (GuiNetworkActionPopUpBtn.Menu.Delegate == null) { GuiNetworkActionPopUpBtn.Menu.Delegate = new MenuDelegateInvertHighlitedItem(); } }
public virtual void Formatted(Format.Field attr, Object value, int start, int end, StringBuffer buffer) { if (start != end) { if (start < Size) { // Adjust attributes of existing runs int index = Size; int asIndex = AttributedStrings.Count - 1; while (start < index) { AttributedString @as = AttributedStrings[asIndex--]; int newIndex = index - @as.Length(); int aStart = System.Math.Max(0, start - newIndex); @as.AddAttribute(attr, value, aStart, System.Math.Min(end - start, @as.Length() - aStart) + aStart); index = newIndex; } } if (Size < start) { // Pad attributes AttributedStrings.Add(new AttributedString(buffer.Substring(Size, start - Size))); Size = start; } if (Size < end) { // Add new string int aStart = System.Math.Max(start, Size); AttributedString @string = new AttributedString(buffer.Substring(aStart, end - aStart)); @string.AddAttribute(attr, value); AttributedStrings.Add(@string); Size = end; } } }
public void TestCompatibility2() { // This test case does not work well on Java 1.4/1.4.1 environment, // because of insufficient Bidi implementation in these versions. /*String javaVersion = System.Environment.GetEnvironmentVariable("java.version"); * if (javaVersion.StartsWith("1.4.0") || javaVersion.StartsWith("1.4.1")) { * Logln("\nSkipping TestCompatibility. The test case is known to fail on Java " + javaVersion + "\n"); + return; + }*/ Logln("\nEntering TestCompatibility\n"); /* check constant field values */ int val; val = IBM.ICU.Text.Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT; val = IBM.ICU.Text.Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT; val = IBM.ICU.Text.Bidi.DIRECTION_LEFT_TO_RIGHT; val = IBM.ICU.Text.Bidi.DIRECTION_RIGHT_TO_LEFT; Logln("last val = " + val); String[] data = { "", /* * the following 2 cases are skipped, because java.text.Bidi has bugs * which cause discrepancies "abc", "ABC", */ "abc def", "ABC DEF", "abc 123 def", "ABC 123 DEF", "abc DEF ghi", "abc DEF 123 xyz","abc GHIJ 12345 def KLM" }; int dataCnt = data.Length; Bidi bidi; Bidi jbidi; for (int i = 0; i < dataCnt; i++) { String src = IBM.ICU.Charset.BidiTest.PseudoToU16(data[i]); bidi = new Bidi(src, IBM.ICU.Text.Bidi.DIRECTION_LEFT_TO_RIGHT); jbidi = new Bidi(src, Bidi.DIRECTION_LEFT_TO_RIGHT); CompareBidi(bidi, jbidi); bidi = new Bidi(src, IBM.ICU.Text.Bidi.DIRECTION_RIGHT_TO_LEFT); jbidi = new Bidi(src, Bidi.DIRECTION_RIGHT_TO_LEFT); CompareBidi(bidi, jbidi); char[] chars = src.ToCharArray(); bidi = new Bidi(chars, 0, null, 0, chars.Length, IBM.ICU.Text.Bidi.DIRECTION_LEFT_TO_RIGHT); jbidi = new Bidi(chars, 0, null, 0, chars.Length, Bidi.DIRECTION_LEFT_TO_RIGHT); CompareBidi(bidi, jbidi); } /* check bogus flags */ bidi = new Bidi("abc", 999); AssertEquals("\nDirection should be LTR", IBM.ICU.Text.Bidi.LTR, bidi.GetDirection()); /* check constructor with overriding embeddings */ bidi = new Bidi(new char[] { 's', 's', 's' }, 0, new sbyte[] { (sbyte)-7, (sbyte)-2, (sbyte)-3 }, 0, 3, IBM.ICU.Text.Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT); jbidi = new Bidi(new char[] { 's', 's', 's' }, 0, new sbyte[] { (sbyte)-7, (sbyte)-2, (sbyte)-3 }, 0, 3, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT); AttributedString al = new AttributedString( "HEBREW 123 english MOREHEB"); al.AddAttribute(TextAttribute.RUN_DIRECTION, TextAttribute.RUN_DIRECTION_RTL); al.AddAttribute(TextAttribute.NUMERIC_SHAPING, NumericShaper.GetShaper(NumericShaper.ARABIC)); al.AddAttribute(TextAttribute.BIDI_EMBEDDING, 1, 0, 26); al.AddAttribute(TextAttribute.BIDI_EMBEDDING, -1, 0, 6); al.AddAttribute(TextAttribute.BIDI_EMBEDDING, -1, 19, 26); AttributedCharacterIterator aci = al.GetIterator(); bidi = new Bidi(aci); jbidi = new Bidi(aci); CompareBidi(bidi, jbidi); String xout = bidi.WriteReordered(0); Logln("Output #1 of Bidi(AttributedCharacterIterator): " + xout); al = new AttributedString("HEBREW 123 english MOREHEB"); al.AddAttribute(TextAttribute.RUN_DIRECTION, TextAttribute.RUN_DIRECTION_RTL); al.AddAttribute(TextAttribute.BIDI_EMBEDDING, 0, 0, 26); aci = al.GetIterator(); bidi = new Bidi(aci); jbidi = new Bidi(aci); CompareBidi(bidi, jbidi); xout = bidi.WriteReordered(0); Logln("Output #2 of Bidi(AttributedCharacterIterator): " + xout); al = new AttributedString("HEBREW 123 english MOREHEB"); aci = al.GetIterator(); bidi = new Bidi(aci); jbidi = new Bidi(aci); CompareBidi(bidi, jbidi); xout = bidi.WriteReordered(0); Logln("Output #3 of Bidi(AttributedCharacterIterator): " + xout); char[] text = "abc==(123)==>def".ToCharArray(); bidi = new Bidi(text, 3, null, 0, 10, IBM.ICU.Text.Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT); jbidi = new Bidi(text, 3, null, 0, 10, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT); CompareBidi(bidi, jbidi); xout = bidi.WriteReordered(0); Logln("Output of Bidi(abc==(123)==>def,3,null,0,10, DEFAULT_LTR): " + xout); bidi = new Bidi(text, 3, null, 0, 10, IBM.ICU.Text.Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT); jbidi = new Bidi(text, 3, null, 0, 10, Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT); CompareBidi(bidi, jbidi); xout = bidi.WriteReordered(0); Logln("Output of Bidi(abc==(123)==>def,3,null,0,10, DEFAULT_RTL): " + xout); sbyte[] levels = new sbyte[] { 0, 0, 0, -1, -1, -1, 0, 0, 0, 0 }; bidi = new Bidi(text, 3, levels, 0, 10, IBM.ICU.Text.Bidi.DIRECTION_LEFT_TO_RIGHT); jbidi = new Bidi(text, 3, levels, 0, 10, Bidi.DIRECTION_LEFT_TO_RIGHT); CompareBidi(bidi, jbidi); xout = bidi.WriteReordered(0); Logln("Output of Bidi(abc==(123)==>def,3,levels,0,10, LTR): " + xout); bidi = new Bidi(text, 3, levels, 0, 10, IBM.ICU.Text.Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT); jbidi = new Bidi(text, 3, levels, 0, 10, Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT); CompareBidi(bidi, jbidi); xout = bidi.WriteReordered(0); Logln("Output of Bidi(abc==(123)==>def,3,levels,0,10, DEFAULT_RTL): " + xout); /* test reorderVisually */ sbyte[] myLevels = new sbyte[] { 1, 2, 0, 1, 2, 1, 2, 0, 1, 2 }; object[] objects = new object[10]; levels = new sbyte[objects.Length]; for (int i_0 = 0; i_0 < objects.Length; i_0++) { objects[i_0] = (char)((char)('a' + i_0)); levels[i_0] = myLevels[i_0]; } IBM.ICU.Text.Bidi.ReorderVisually(levels, 3, objects, 3, 7); String strbidi = ""; for (int i_1 = 0; i_1 < objects.Length; i_1++) { strbidi += objects[i_1].ToString(); } for (int i_2 = 0; i_2 < objects.Length; i_2++) { objects[i_2] = (char)((char)('a' + i_2)); levels[i_2] = myLevels[i_2]; } Bidi.ReorderVisually(levels, 3, objects, 3, 7); String strjbidi = ""; for (int i_3 = 0; i_3 < objects.Length; i_3++) { strjbidi += objects[i_3].ToString(); } if (!strjbidi.Equals(strbidi)) { Errln("Discrepancy in reorderVisually " + "\n bidi: " + strbidi + "\n jbidi: " + strjbidi); } else { Logln("Correct match in reorderVisually " + "\n bidi: " + strbidi + "\n jbidi: " + strjbidi); } Logln("\nExiting TestCompatibility\n"); }
public override void AwakeFromNib() { base.AwakeFromNib(); // Disable title-bar (but keep close/minimize/expand buttons on content-view) // IMPORTANT! 'FullSizeContentView' implemented since OS X 10.10 !!! Window.TitleVisibility = NSWindowTitleVisibility.Hidden; Window.TitlebarAppearsTransparent = true; Window.StyleMask |= NSWindowStyle.FullSizeContentView; // Progress indicator if (!__SessionStatus.IsActive) { __DaysLeft = 0; } // Normally we should show it days left <= 3 // if '__DaysLeft' > 3 - set max value to __DaysLeft+1 int maxValue = 3; if (__DaysLeft > 3) { maxValue = __DaysLeft + 1; } GuiProgressIndicator.MinValue = 0; GuiProgressIndicator.MaxValue = maxValue; GuiProgressIndicator.DoubleValue = maxValue - __DaysLeft; string cancelBtnText = LocalizedStrings.Instance.LocalizedString("Button_ContinueTrial"); string subscriptionBtnText; if (__SessionStatus.IsOnFreeTrial) { subscriptionBtnText = LocalizedStrings.Instance.LocalizedString("Button_GetSubscription"); } else { subscriptionBtnText = LocalizedStrings.Instance.LocalizedString("Button_RenewSubscription"); } // BUTTON Continue Trial GuiButtonCancel.Gradient = new NSGradient(NSColor.FromRgb(240, 244, 247), NSColor.FromRgb(240, 244, 247)); GuiButtonCancel.BorderColor = NSColor.SystemGrayColor; GuiButtonCancel.TitleForegroundColor = NSColor.Black; GuiButtonCancel.TitleFont = UIUtils.GetSystemFontOfSize(13f, NSFontWeight.Medium); GuiButtonCancel.TitleText = cancelBtnText; // BUTTON Get Subscription GuiButtonGoToAccount.Gradient = new NSGradient(NSColor.FromRgb(128, 187, 249), NSColor.FromRgb(17, 130, 254)); GuiButtonGoToAccount.BorderShadow = new NSShadow { ShadowOffset = new CoreGraphics.CGSize(0f, 1f), ShadowColor = NSColor.FromRgba(0, 0, 0, 0.18f) }; GuiButtonGoToAccount.TitleText = subscriptionBtnText; GuiButtonGoToAccount.TitleFont = UIUtils.GetSystemFontOfSize(13f, NSFontWeight.Medium); GuiButtonGoToAccount.TitleForegroundColor = NSColor.White; // TITLE if (!__SessionStatus.IsActive) { string title = LocalizedStrings.Instance.LocalizedString("Label_SubscriptionExpired"); if (__SessionStatus.IsOnFreeTrial) { title = LocalizedStrings.Instance.LocalizedString("Label_FreeTrialExpired"); } NSMutableAttributedString attrTitle = new NSMutableAttributedString(title); NSStringAttributes stringAttributes0 = new NSStringAttributes(); stringAttributes0.Font = UIUtils.GetSystemFontOfSize(20f, NSFontWeight.Medium); attrTitle.AddAttributes(stringAttributes0, new NSRange(0, title.Length)); GuiLabelTitleText.AttributedStringValue = attrTitle; // DESCRIPTION string description = LocalizedStrings.Instance.LocalizedString("Label_AccountDaysLeftDescription_Expired"); if (__SessionStatus.IsOnFreeTrial) { description = LocalizedStrings.Instance.LocalizedString("Label_TrialDaysLeftDescription_Expired"); } description = string.Format(description, __DaysLeft); GuiLabelDescriptionText.AttributedStringValue = AttributedString.Create(description, null, NSTextAlignment.Left); } else { string title; string daysStr = string.Format("{0}", __DaysLeft); if (__DaysLeft == 0) { title = LocalizedStrings.Instance.LocalizedString("Label_AccountDaysLeftTitle_LastDay_PARAMETRIZED"); if (__SessionStatus.IsOnFreeTrial) { title = LocalizedStrings.Instance.LocalizedString("Label_TrialDaysLeftTitle_LastDay_PARAMETRIZED"); } daysStr = ""; } else if (__DaysLeft == 1) { title = LocalizedStrings.Instance.LocalizedString("Label_AccountDaysLeftTitle_OneDay_PARAMETRIZED"); if (__SessionStatus.IsOnFreeTrial) { title = LocalizedStrings.Instance.LocalizedString("Label_TrialDaysLeftTitle_OneDay_PARAMETRIZED"); } } else { title = LocalizedStrings.Instance.LocalizedString("Label_AccountDaysLeftTitle_PARAMETRIZED"); if (__SessionStatus.IsOnFreeTrial) { title = LocalizedStrings.Instance.LocalizedString("Label_TrialDaysLeftTitle_PARAMETRIZED"); } } int numberSymbolPos = title.LastIndexOf("{0}", StringComparison.Ordinal); title = string.Format(title, daysStr); NSMutableAttributedString attrTitle = new NSMutableAttributedString(title); NSStringAttributes stringAttributes0 = new NSStringAttributes(); stringAttributes0.Font = UIUtils.GetSystemFontOfSize(20f, NSFontWeight.Medium); NSStringAttributes stringAttributes1 = new NSStringAttributes(); stringAttributes1.ForegroundColor = TitleDaysTextColor; attrTitle.AddAttributes(stringAttributes0, new NSRange(0, title.Length)); attrTitle.AddAttributes(stringAttributes1, new NSRange(numberSymbolPos, title.Length - numberSymbolPos)); GuiLabelTitleText.AttributedStringValue = attrTitle; // DESCRIPTION string description; if (__DaysLeft == 0) { description = LocalizedStrings.Instance.LocalizedString("Label_AccountDaysLeftDescription_LastDay"); if (__SessionStatus.IsOnFreeTrial) { description = LocalizedStrings.Instance.LocalizedString("Label_TrialDaysLeftDescription_LastDay"); } } else if (__DaysLeft == 1) { description = LocalizedStrings.Instance.LocalizedString("Label_AccountDaysLeftDescription_OneDay"); if (__SessionStatus.IsOnFreeTrial) { description = LocalizedStrings.Instance.LocalizedString("Label_TrialDaysLeftDescription_OneDay"); } } else { description = LocalizedStrings.Instance.LocalizedString("Label_AccountDaysLeftDescription_PARAMETRIZED"); if (__SessionStatus.IsOnFreeTrial) { description = LocalizedStrings.Instance.LocalizedString("Label_TrialDaysLeftDescription_PARAMETRIZED"); } } description = string.Format(description, __DaysLeft); GuiLabelDescriptionText.AttributedStringValue = AttributedString.Create(description, null, NSTextAlignment.Left); } }
public TextElement[] GetTextElements(float textWidth, FontRenderContext frc){ TextRun run = _shape.GetTextRun(); if (run == null) return null; String text = Run.GetText(); if (text == null || text.Equals("")) return null; AttributedString at = GetAttributedString(Run); AttributedCharacterIterator it = at.GetIterator(); int paragraphStart = it.GetBeginIndex(); int paragraphEnd = it.GetEndIndex(); List<TextElement> lines = new List<TextElement>(); LineBreakMeasurer measurer = new LineBreakMeasurer(it, frc); measurer.SetPosition(paragraphStart); while (measurer.GetPosition() < paragraphEnd) { int startIndex = measurer.GetPosition(); int nextBreak = text.IndexOf('\n', measurer.GetPosition() + 1); bool prStart = text[startIndex] == '\n'; if(prStart) measurer.SetPosition(startIndex++); RichTextRun rt = Run.GetRichTextRunAt(startIndex == text.Length ? (startIndex-1) : startIndex); if(rt == null) { logger.log(POILogger.WARN, "RichTextRun not found at pos" + startIndex + "; text.Length: " + text.Length); break; } float wrappingWidth = textWidth - _shape.GetMarginLeft() - _shape.GetMarginRight(); int bulletOffset = rt.GetBulletOffset(); int textOffset = rt.GetTextOffset(); int indent = rt.GetIndentLevel(); TextRulerAtom ruler = Run.GetTextRuler(); if(ruler != null) { int bullet_val = ruler.GetBulletOffsets()[indent]*Shape.POINT_DPI/Shape.MASTER_DPI; int text_val = ruler.GetTextOffsets()[indent]*Shape.POINT_DPI/Shape.MASTER_DPI; if(bullet_val > text_val){ int a = bullet_val; bullet_val = text_val; text_val = a; } if(bullet_val != 0 ) bulletOffset = bullet_val; if(text_val != 0) textOffset = text_val; } if(bulletOffset > 0 || prStart || startIndex == 0) wrappingWidth -= textOffset; if (_shape.GetWordWrap() == TextShape.WrapNone) { wrappingWidth = _shape.Sheet.GetSlideShow().GetPageSize().width; } TextLayout textLayout = measurer.nextLayout(wrappingWidth + 1, nextBreak == -1 ? paragraphEnd : nextBreak, true); if (textLayout == null) { textLayout = measurer.nextLayout(textWidth, nextBreak == -1 ? paragraphEnd : nextBreak, false); } if(textLayout == null){ logger.log(POILogger.WARN, "Failed to break text into lines: wrappingWidth: "+wrappingWidth+ "; text: " + rt.GetText()); measurer.SetPosition(rt.GetEndIndex()); continue; } int endIndex = measurer.GetPosition(); float lineHeight = (float)textLayout.GetBounds().Height; int linespacing = rt.GetLineSpacing(); if(linespacing == 0) linespacing = 100; TextElement el = new TextElement(); if(linespacing >= 0){ el.ascent = textLayout.GetAscent()*linespacing/100; } else { el.ascent = -linespacing*Shape.POINT_DPI/Shape.MASTER_DPI; } el._align = rt.GetAlignment(); el.advance = textLayout.GetAdvance(); el._textOffset = textOffset; el._text = new AttributedString(it, startIndex, endIndex); el.textStartIndex = startIndex; el.textEndIndex = endIndex; if (prStart){ int sp = rt.GetSpaceBefore(); float spaceBefore; if(sp >= 0){ spaceBefore = lineHeight * sp/100; } else { spaceBefore = -sp*Shape.POINT_DPI/Shape.MASTER_DPI; } el.ascent += spaceBefore; } float descent; if(linespacing >= 0){ descent = (textLayout.GetDescent() + textLayout.GetLeading())*linespacing/100; } else { descent = -linespacing*Shape.POINT_DPI/Shape.MASTER_DPI; } if (prStart){ int sp = rt.GetSpaceAfter(); float spaceAfter; if(sp >= 0){ spaceAfter = lineHeight * sp/100; } else { spaceAfter = -sp*Shape.POINT_DPI/Shape.MASTER_DPI; } el.ascent += spaceAfter; } el.descent = descent; if(rt.IsBullet() && (prStart || startIndex == 0)){ it.SetIndex(startIndex); AttributedString bat = new AttributedString(Character.ToString(rt.GetBulletChar())); Color clr = rt.GetBulletColor(); if (clr != null) bat.AddAttribute(TextAttribute.FOREGROUND, clr); else bat.AddAttribute(TextAttribute.FOREGROUND, it.GetAttribute(TextAttribute.FOREGROUND)); int fontIdx = rt.GetBulletFont(); if(fontIdx == -1) fontIdx = rt.GetFontIndex(); PPFont bulletFont = _shape.Sheet.GetSlideShow().GetFont(fontIdx); bat.AddAttribute(TextAttribute.FAMILY, bulletFont.GetFontName()); int bulletSize = rt.GetBulletSize(); int fontSize = rt.GetFontSize(); if(bulletSize != -1) fontSize = Math.round(fontSize*bulletSize*0.01f); bat.AddAttribute(TextAttribute.SIZE, new Float(fontSize)); if(!new Font(bulletFont.GetFontName(), Font.PLAIN, 1).canDisplay(rt.GetBulletChar())){ bat.AddAttribute(TextAttribute.FAMILY, "Arial"); bat = new AttributedString("" + DEFAULT_BULLET_CHAR, bat.GetIterator().GetAttributes()); } if(text.Substring(startIndex, endIndex).Length > 1){ el._bullet = bat; el._bulletOffset = bulletOffset; } } lines.Add(el); } //finally Draw the text fragments TextElement[] elems = new TextElement[lines.Count]; return lines.ToArray(elems); }
/// <summary> /// Creates an <code>AttributedCharacterIterator</code> containing the /// concatenated contents of the passed in /// <code>AttributedCharacterIterator</code>s. /// </summary> /// <param name="iterators"> AttributedCharacterIterators used to create resulting /// AttributedCharacterIterators </param> /// <returns> AttributedCharacterIterator wrapping passed in /// AttributedCharacterIterators </returns> internal virtual AttributedCharacterIterator CreateAttributedCharacterIterator(AttributedCharacterIterator[] iterators) { AttributedString @as = new AttributedString(iterators); return(@as.Iterator); }
private void ShowConnectingAnimation(bool isResuming = false) { if (!NSThread.IsMain) { InvokeOnMainThread(() => ShowConnectingAnimation(isResuming)); return; } // prepare GUI controls GuiConnectButtonImage.Hidden = false; GuiConnectButtonImage.Image = Colors.IsDarkMode ? NSImage.ImageNamed("buttonConnectDark") : NSImage.ImageNamed("buttonConnecting"); if (isResuming == false) { GuiConnectButtonText.AttributedStringValue = AttributedString.Create( LocalizedStrings.Instance.LocalizedString("Button_Connecting"), Colors.ConnectButtonTextColor, NSTextAlignment.Center); } else { GuiConnectButtonText.AttributedStringValue = AttributedString.Create( LocalizedStrings.Instance.LocalizedString("Button_Resuming"), Colors.ConnectButtonTextColor, NSTextAlignment.Center); } GuiConnectButtonText.AlphaValue = 1f; View.IsVisibleCircles = false; // initialize animation NSColor startCircleColor = Colors.ConnectiongAnimationCircleColor; UpdateToDoLabelHiddenStatus(true); __animationLayer.FillColor = NSColor.Clear.CGColor; __animationLayer.StrokeColor = startCircleColor.CGColor; var frame = GuiConnectButtonImage.Frame; var startCircle = CGPath.EllipseFromRect( new CGRect(frame.X + 6, frame.Y + 6, frame.Width - 12, frame.Height - 12) ); var endCircle = CGPath.EllipseFromRect( new CGRect(frame.X + 3, frame.Y + 3, frame.Width - 6, frame.Height - 6) ); CABasicAnimation circleRadiusAnimation = CABasicAnimation.FromKeyPath("path"); circleRadiusAnimation.From = FromObject(startCircle); circleRadiusAnimation.To = FromObject(endCircle); CABasicAnimation lineWidthAnimation = CABasicAnimation.FromKeyPath("lineWidth"); lineWidthAnimation.From = FromObject(1); lineWidthAnimation.To = FromObject(8); CAAnimationGroup animationGroup = new CAAnimationGroup(); animationGroup.Animations = new CAAnimation[] { circleRadiusAnimation, lineWidthAnimation }; animationGroup.Duration = 1f; animationGroup.RepeatCount = float.PositiveInfinity; animationGroup.AutoReverses = true; __animationLayer.AddAnimation(animationGroup, null); AnimateButtonTextBlinking(); }
private void UpdateWiFiInfoGuiData() { if (!NSThread.IsMain) { InvokeOnMainThread(() => UpdateWiFiInfoGuiData()); return; } try { UpdateToDoLabelHiddenStatus(); WifiState state = __MainViewModel.WiFiState; if (__MainViewModel.Settings.IsNetworkActionsEnabled == false) { GuiWiFiButton.Hidden = true; GuiNetworkActionPopUpBtn.Hidden = true; return; } NSFont wifiLabelFont = UIUtils.GetSystemFontOfSize(14, NSFontWeight.Thin); if (state == null || string.IsNullOrEmpty(state.Network.SSID)) { GuiWiFiButton.AttributedTitle = AttributedString.Create(LocalizedStrings.Instance.LocalizedString("Label_NoWiFiConnection"), NSColor.SystemGrayColor, NSTextAlignment.Center, wifiLabelFont); GuiWiFiButton.Image = null; GuiWiFiButton.Enabled = false; GuiWiFiButton.Hidden = false; GuiNetworkActionPopUpBtn.Hidden = true; } else { if (state.ConnectedToInsecureNetwork) { GuiWiFiButton.Image = NSImage.ImageNamed("iconWiFiSmallRed"); string networkName = " " + state.Network.SSID + " "; string fullText = networkName + "(" + LocalizedStrings.Instance.LocalizedString("Label_InsecureWiFiConnection") + ") "; NSMutableAttributedString attrTitle = new NSMutableAttributedString(fullText); NSStringAttributes stringAttributes0 = new NSStringAttributes(); stringAttributes0.ForegroundColor = __ToDoDescriptionTextColor; stringAttributes0.Font = wifiLabelFont; NSStringAttributes stringAttributes1 = new NSStringAttributes(); stringAttributes1.ForegroundColor = NSColor.SystemRedColor; stringAttributes1.Font = wifiLabelFont; attrTitle.AddAttributes(stringAttributes0, new NSRange(0, networkName.Length)); attrTitle.AddAttributes(stringAttributes1, new NSRange(networkName.Length, fullText.Length - networkName.Length)); attrTitle.SetAlignment(NSTextAlignment.Center, new NSRange(0, fullText.Length)); GuiWiFiButton.AttributedTitle = attrTitle; } else { GuiWiFiButton.Image = NSImage.ImageNamed("iconWiFiSmallBlue"); GuiWiFiButton.AttributedTitle = AttributedString.Create(" " + state.Network.SSID, __ToDoDescriptionTextColor, NSTextAlignment.Center, wifiLabelFont); } RecreateNetworkActionsButtonItems(); GuiWiFiButton.Enabled = true; GuiWiFiButton.Hidden = false; GuiNetworkActionPopUpBtn.Hidden = false; } } catch (Exception ex) { GuiWiFiButton.Hidden = true; GuiNetworkActionPopUpBtn.Hidden = true; Logging.Info($"{ex}"); } }