protected override void OnDraw(Xwt.Drawing.Context ctx, Xwt.Rectangle dirtyRect) { base.OnDraw(ctx, dirtyRect); if (pages == null) { return; } ctx.Font = this.Font; ctx.Save(); int width = (int)(report.PageWidthPoints * Scale); int height = (int)(report.PageHeightPoints * Scale); //Xwt.Rectangle rep_r = new Xwt.Rectangle(1, 1, width - 1, height - 1); //RenderXwt render = new RenderXwt(ctx, Scale); //render.RunPage(pages); //ctx.Stroke(); // Page Drawing using System.Drawing converted to Xwt Context PageDrawing render = new PageDrawing(ctx, 1f); render.RunPage(pages); ctx.Stroke(); ctx.Save(); }
public DragEventArgs (Point position, Xwt.Backends.TransferDataStore dataStore, DragDropAction action) { Data = dataStore; Position = position; Action = action; Success = false; }
protected override void OnSetBackgroundColor (Xwt.Drawing.Color color) { base.OnSetBackgroundColor (color); Widget.SetBackgroundColor (color); Widget.SetChildBackgroundColor (color); EventsRootWidget.SetBackgroundColor (color); }
internal async void RequestPopup (Xwt.Rectangle rect) { var token = popupSrc.Token; diff = await Task.Run (async delegate { try { foreach (var op in await codeAction.GetPreviewOperationsAsync (token)) { var ac = op as ApplyChangesOperation; if (ac == null) { continue; } var changedDocument = ac.ChangedSolution.GetDocument (documentContext.AnalysisDocument.Id); changedTextDocument = TextEditorFactory.CreateNewDocument (new StringTextSource ((await changedDocument.GetTextAsync (token)).ToString ()), editor.FileName); try { var list = new List<DiffHunk> (editor.GetDiff (changedTextDocument, new DiffOptions (false, true))); if (list.Count > 0) return list; } catch (Exception e) { LoggingService.LogError ("Error while getting preview list diff.", e); } } } catch (OperationCanceledException) {} return new List<DiffHunk> (); }); if (diff.Count > 0 && !token.IsCancellationRequested) ShowPopup (rect, PopupPosition.Left); }
/// <summary>Shows dialog</summary> /// <returns><value>True</value> if user want to proceed current operation, and <value>False</value> if user don't.</returns> public bool ShowDialog(Xwt.WindowFrame parent = null) { Build(); Xwt.Command DialogResult = null; if (parent == null){ DialogResult = this.Run(); } else{ DialogResult = this.Run(parent); } //4beginners: xwtdialog.Run() == winform.ShowDialog() == vb6form.Show(vbModal); if (DialogResult == null) return false; switch (DialogResult.Id) //hack due to C# limitation (it's unable to do switch(){} on custon types) { case "Add": case "Apply": case "Clear": case "Copy": case "Cut": case "Delete": case "Ok": case "Paste": case "Remove": case "Save": case "SaveAs": case "Yes": return true; } return false; }
bool SendKeyPressed (Xwt.KeyEventArgs kargs) { if (KeyPressed != null) KeyPressed (this, kargs); return kargs.Handled; }
public static NSPopover MakePopover(Xwt.Widget child, Color backgroundColor) { return new NSPopover { Behavior = NSPopoverBehavior.Transient, ContentViewController = new FactoryViewController (child) { BackgroundColor = backgroundColor.ToCGColor () } }; }
public InputBox(string AskText, string DefaultValue, Xwt.Command[] Buttons) { lblQuestion.Text = AskText; txtAnwser.Text = DefaultValue; this.Buttons.Add(Buttons); }
internal void NotifyClicked (Xwt.PointerButton button) { if (Clicked != null) Clicked (this, new StatusBarIconClickedEventArgs { Button = button, }); }
public static NSPopover MakePopover(Xwt.Widget child) { return new NSPopover { Behavior = NSPopoverBehavior.Transient, ContentViewController = new FactoryViewController (child) }; }
public override Control CreateTooltipWindow (TextEditor editor, DocumentContext ctx, TooltipItem item, int offset, Xwt.ModifierKeys modifierState) { var result = new LanguageItemWindow (GetExtensibleTextEditor (editor), modifierState, null, (string)item.Item, null); if (result.IsEmpty) return null; return result; }
protected override void OnDraw(Xwt.Drawing.Context ctx, Rectangle dirtyRect) { if (!Sensitive) { ctx.GlobalAlpha = .5d; } if (image == null) { ctx.SetColor(bg); ctx.Rectangle(dirtyRect); ctx.Fill(); } else ctx.DrawImage(image, new Rectangle(0, 0, WidthRequest, HeightRequest)); if (mOver && Sensitive) { ctx.SetColor(mOverColor); ctx.Rectangle(dirtyRect); ctx.Fill(); } if (mDown) { ctx.SetColor(mOverColor); ctx.Rectangle(dirtyRect); ctx.Fill(); } //ctx.SetColor(Colors.Red); //ctx.Rectangle(0, 0, WidthRequest, HeightRequest); //ctx.Stroke(); }
protected override void OnDraw(Xwt.Drawing.Context ctx, Xwt.Rectangle dirtyRect) { ctx.Rectangle(dirtyRect); ctx.SetColor(Colors.White); ctx.Fill(); this.Buttons.ForEach(X => DrawGradientButton(ctx, X)); }
protected override void OnDraw(Xwt.Drawing.Context ctx, Xwt.Rectangle dirtyRect) { base.OnDraw(ctx, dirtyRect); if (pages == null) { return; } ctx.Save(); //Xwt.Rectangle rep_r = new Xwt.Rectangle(1, 1, width - 1, height - 1); //RenderXwt render = new RenderXwt(ctx, Scale); //render.RunPage(pages); //ctx.Stroke(); if (_defaultBackend == Backend.PureXwt) { RenderXwt render = new RenderXwt(ctx, this, 1f); render.RunPage(pages); } else { // Page Drawing using System.Drawing converted to Xwt Context PageDrawing render = new PageDrawing(ctx, 1f, Convert.ToInt32(this.MinWidth), Convert.ToInt32(this.MinHeight)); render.RunPage(pages); } ctx.Stroke(); ctx.Save(); }
public void Show(Xwt.Popover.Position orientation, Xwt.Widget reference, Xwt.Rectangle positionRect, Widget child) { var parent = reference.ParentWindow; popover = new PopoverWindow ((Gtk.Widget)((WidgetBackend)Toolkit.GetBackend (child)).NativeWidget, orientation); popover.SetPadding (frontend.Padding); popover.TransientFor = ((WindowFrameBackend)Toolkit.GetBackend (parent)).Window; popover.DestroyWithParent = true; popover.Hidden += (o, args) => { popover.ReleaseInnerWidget (); sink.OnClosed (); popover.Destroy (); }; var screenBounds = reference.ScreenBounds; if (positionRect == Rectangle.Zero) positionRect = new Rectangle (Point.Zero, screenBounds.Size); positionRect = positionRect.Offset (screenBounds.Location); var position = new Point (positionRect.Center.X, popover.ArrowPosition == Popover.Position.Top ? positionRect.Bottom : positionRect.Top); popover.ShowAll (); popover.GrabFocus (); int w, h; popover.GetSize (out w, out h); popover.Move ((int)position.X - w / 2, (int)position.Y); popover.SizeAllocated += (o, args) => { popover.Move ((int)position.X - args.Allocation.Width / 2, (int)position.Y); popover.GrabFocus (); }; }
protected override void OnSetBackgroundColor (Xwt.Drawing.Color color) { // Gtk3 workaround (by rpc-scandinavia, see https://github.com/mono/xwt/pull/411) var selectedColor = Widget.GetBackgroundColor(StateType.Selected); Widget.SetBackgroundColor (StateType.Normal, Xwt.Drawing.Colors.Transparent); Widget.SetBackgroundColor (StateType.Selected, selectedColor); base.OnSetBackgroundColor (color); }
bool SendKeyPressed (Xwt.KeyEventArgs kargs) { if (KeyPressed != null) KeyPressed (this, kargs); LogMessage ($"KeyPressed with Handled {kargs.Handled}"); return kargs.Handled; }
public RenderXwt(Xwt.Drawing.Context g, float scale) { this.g = g; this.layout = new Xwt.Drawing.TextLayout(this.g ); dpiX *= scale; dpiY *= scale; }
protected internal override void DrawBackground(Context cr, Xwt.Rectangle area, DocumentLine line, int lineNumber, double x, double y, double height) { cr.Save(); cr.SetColor(Colors.LightGray); cr.Rectangle(x, y, Width, height + 1); cr.Fill(); cr.Restore(); }
public MarginMouseEventArgs(TextEditor textEditor, Xwt.PointerButton button, double x, double y, int multipleClicks) { TextEditor = textEditor; Button = button; X = x; Y = y; MultipleClicks = multipleClicks; }
protected internal override void Draw(Context cr, Xwt.Rectangle area, DocumentLine line, int lineNumber, double x, double y, double height) { if (line != null) { TextLayout layout; if (!layoutDict.TryGetValue(line, out layout)) { var mode = editor.Document.SyntaxMode; var style = SyntaxModeService.DefaultColorStyle; var chunks = GetCachedChunks(mode, editor.Document, style, line, line.Offset, line.Length); layout = new TextLayout(); layout.Font = editor.Options.EditorFont; string lineText = editor.Document.GetLineText(lineNumber); var stringBuilder = new StringBuilder(lineText.Length); int currentVisualColumn = 1; for (int i = 0; i < lineText.Length; ++i) { char chr = lineText[i]; if (chr == '\t') { int length = GetNextTabstop(editor, currentVisualColumn) - currentVisualColumn; stringBuilder.Append(' ', length); currentVisualColumn += length; } else { stringBuilder.Append(chr); if (!char.IsLowSurrogate(chr)) { ++currentVisualColumn; } } } layout.Text = stringBuilder.ToString(); int visualOffset = 1; foreach (var chunk in chunks) { var chunkStyle = style.GetChunkStyle(chunk); visualOffset = DrawLinePortion(cr, chunkStyle, layout, line, visualOffset, chunk.Length); } //layoutDict[line] = layout; } cr.DrawTextLayout(layout, x, y); if (editor.CaretVisible && editor.Caret.Line == lineNumber) { cr.SetColor(Colors.Black); cr.Rectangle(x + ColumnToX(line, editor.Caret.Column), y, caretWidth, LineHeight); cr.Fill(); } } }
internal static void SetImage (this CALayer layer, Xwt.Drawing.Image xwtImage, nfloat scale) { var image = xwtImage.ToNSImage (); layer.ContentsScale = scale; var layerContents = image.GetLayerContentsForContentsScale (layer.ContentsScale); void_objc_msgSend_IntPtr (layer.Handle, setContentsSelector, layerContents.Handle); layer.Bounds = new CGRect (0, 0, image.Size.Width, image.Size.Height); }
public override Control CreateTooltipWindow (TextEditor editor, DocumentContext ctx, TooltipItem item, int offset, Xwt.ModifierKeys modifierState) { foreach (var pseg in projection.ProjectedSegments) { if (pseg.ContainsOriginal (offset)) { return projectedTooltipProvider.CreateTooltipWindow (projection.ProjectedEditor, projection.ProjectedContext, item, pseg.FromOriginalToProjected (offset), modifierState); } } return null; }
public override Control CreateTooltipWindow (TextEditor editor, DocumentContext ctx, TooltipItem item, int offset, Xwt.ModifierKeys modifierState) { var result = item.Item as Result; var window = new LanguageItemWindow (CompileErrorTooltipProvider.GetExtensibleTextEditor (editor), modifierState, null, result.Message, null); if (window.IsEmpty) return null; return window; }
/// <summary>Converts Xwt.CheckBox selection status into boolean value</summary> private bool BoolFromCBX(Xwt.CheckBox CBX) { switch (CBX.State) { case Xwt.CheckBoxState.On: return true; case Xwt.CheckBoxState.Off: return false; } return false; //fallback }
public RenderXwt(Xwt.Drawing.Context g, Xwt.Canvas c, float scale) { this.cxt = g; this.cvs = c; this.layout = new Xwt.Drawing.TextLayout(this.cvs); dpiX *= scale; dpiY *= scale; }
public static void DrawImage(this Xwt.Drawing.Context ctx, System.Drawing.Bitmap image, Xwt.Point where, double Scaling = 1, bool IncludeAlpha = false) { using (System.IO.MemoryStream M = new System.IO.MemoryStream()) { image.Save(M, IncludeAlpha?System.Drawing.Imaging.ImageFormat.Png:System.Drawing.Imaging.ImageFormat.Bmp); M.Position = 0; ctx.DrawImage(Xwt.Drawing.Image.FromStream(M), new Xwt.Rectangle(where, new Xwt.Size(image.Width/Scaling, image.Height/Scaling))); } }
public void CheckWidgetRender (string refImageName, Xwt.Widget widget, int winWidth = 300, int winHeight = 100) { using (var win = new Window { Width = winWidth, Height = winHeight }) { win.Content = widget; ShowWindow (win); var img = Toolkit.CurrentEngine.RenderWidget (widget); ReferenceImageManager.CheckImage (refImageName, img); } }
protected override void OnDraw(Xwt.Drawing.Context ctx, Rectangle dirtyRect) { base.OnDraw(ctx, dirtyRect); //ctx.SetColor(PluginType.GetColor()); ctx.SetLineDash(0, 4d, 4d); ctx.Rectangle(0, 0, PluginWidget.Size.Width, PluginWidget.Size.Height); ctx.Stroke(); }
public CrossfadeIcon (Xwt.Drawing.Image primary, Xwt.Drawing.Image secondary) { if (primary == null) throw new ArgumentNullException ("primary"); if (secondary == null) throw new ArgumentNullException ("secondary"); this.primary = primary; this.secondary = secondary; }