本文整理汇总了C#中Gtk.DrawingArea类的典型用法代码示例。如果您正苦于以下问题:C# DrawingArea类的具体用法?C# DrawingArea怎么用?C# DrawingArea使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DrawingArea类属于Gtk命名空间,在下文中一共展示了DrawingArea类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DemoColorSelection
public DemoColorSelection () : base ("Color Selection")
{
BorderWidth = 8;
VBox vbox = new VBox (false,8);
vbox.BorderWidth = 8;
Add (vbox);
// Create the color swatch area
Frame frame = new Frame ();
frame.ShadowType = ShadowType.In;
vbox.PackStart (frame, true, true, 0);
drawingArea = new DrawingArea ();
drawingArea.ExposeEvent += new ExposeEventHandler (ExposeEventCallback);
// set a minimum size
drawingArea.SetSizeRequest (200,200);
// set the color
color = new Gdk.Color (0, 0, 0xff);
drawingArea.ModifyBg (StateType.Normal, color);
frame.Add (drawingArea);
Alignment alignment = new Alignment (1.0f, 0.5f, 0.0f, 0.0f);
Button button = new Button ("_Change the above color");
button.Clicked += new EventHandler (ChangeColorCallback);
alignment.Add (button);
vbox.PackStart (alignment);
ShowAll ();
}
示例2: Render
public void Render(DrawingArea area, SettingsModel settings)
{
var width = area.Allocation.Width;
var height = area.Allocation.Height;
var kaleidoscope = _factory.Get (settings.Type);
var rootNode = kaleidoscope.Generate (
settings.GeometyWidth,
settings.ImageUri,
width, height);
ImageSurface surface = new ImageSurface(Format.Argb32, width, height);
using (var context = new Context (surface)) {
context.Translate(width / 2, height / 2);
rootNode.Render (context);
}
rootNode.Geometry.Dispose ();
using (Context context = Gdk.CairoHelper.Create (area.GdkWindow)) {
context.Rectangle(0, 0, width, height);
context.SetSource(surface);
context.Fill();
context.GetTarget ().Dispose ();
}
surface.Dispose ();
}
示例3: InteractivePlotSurface2D
private bool coordsActive_ = true; // Shows X,Y in Tooltip
#endregion Fields
#region Constructors
/// <summary>
/// Default Constructor
/// </summary>
public InteractivePlotSurface2D()
: base()
{
canvas = new DrawingArea (); // allocate local DrawingArea
canvas.CanFocus = true; // enable to receive the focus
// Link the event handlers into the DrawingArea events (default is none)
canvas.SizeAllocated += new SizeAllocatedHandler (SizeAllocated);
canvas.ExposeEvent += new ExposeEventHandler (ExposeEvent);
canvas.EnterNotifyEvent += new EnterNotifyEventHandler (EnterNotify);
canvas.LeaveNotifyEvent += new LeaveNotifyEventHandler (LeaveNotify);
canvas.ButtonPressEvent += new ButtonPressEventHandler (ButtonPress);
canvas.MotionNotifyEvent += new MotionNotifyEventHandler (MotionNotify);
canvas.ButtonReleaseEvent += new ButtonReleaseEventHandler (ButtonRelease);
canvas.ScrollEvent += new ScrollEventHandler (ScrollNotify);
canvas.KeyPressEvent += new KeyPressEventHandler (KeyPressed);
canvas.KeyReleaseEvent += new KeyReleaseEventHandler (KeyReleased);
// Subscribe to DrawingArea mouse movement and button press events.
// Enter and Leave notification is necessary to make ToolTips work.
// Specify PointerMotionHint to prevent being deluged with motion events.
canvas.AddEvents ((int)Gdk.EventMask.EnterNotifyMask);
canvas.AddEvents ((int)Gdk.EventMask.LeaveNotifyMask);
canvas.AddEvents ((int)Gdk.EventMask.ButtonPressMask);
canvas.AddEvents ((int)Gdk.EventMask.ButtonReleaseMask);
canvas.AddEvents ((int)Gdk.EventMask.PointerMotionMask);
canvas.AddEvents ((int)Gdk.EventMask.PointerMotionHintMask);
canvas.AddEvents ((int)Gdk.EventMask.ScrollMask);
canvas.SetSizeRequest (400, 300); // Set DrawingArea size
// Set up ToolTips to show coordinates. NB works via Enter/Leave events
// TODO: ToolTips do not work well yet - needs review of approach
this.Canvas.TooltipText = "Coordinates will display here";
}
示例4: DemoColorSelection
public DemoColorSelection () : base ("Color Selection")
{
BorderWidth = 8;
VBox vbox = new VBox (false,8);
vbox.BorderWidth = 8;
Add (vbox);
// Create the color swatch area
Frame frame = new Frame ();
frame.ShadowType = ShadowType.In;
vbox.PackStart (frame, true, true, 0);
drawingArea = new DrawingArea ();
// set a minimum size
drawingArea.SetSizeRequest (200,200);
// set the color
color.Red = 0;
color.Green = 0;
color.Blue = 1;
color.Alpha = 1;
drawingArea.OverrideBackgroundColor (StateFlags.Normal, color);
frame.Add (drawingArea);
Alignment alignment = new Alignment (1.0f, 0.5f, 0.0f, 0.0f);
Button button = new Button ("_Change the above color");
button.Clicked += new EventHandler (ChangeColorCallback);
alignment.Add (button);
vbox.PackStart (alignment, false, false, 0);
ShowAll ();
}
示例5: GetDisplayWidget
public override Gtk.Widget GetDisplayWidget()
{
DrawingArea colorPreview = new DrawingArea ();
colorPreview.ModifyBg(StateType.Normal, GetColor ());
colorPreview.WidthRequest = 15;
Alignment colorPreviewAlign = new Alignment (0, 0, 0, 1);
colorPreviewAlign.SetPadding (2, 2, 2, 2);
colorPreviewAlign.Add (colorPreview);
string labelText;
System.Drawing.Color color = (System.Drawing.Color) parentRow.PropertyValue;
//TODO: dropdown known color selector so this does something
if (color.IsKnownColor)
labelText = color.Name;
else if (color.IsEmpty)
labelText = "[empty]";
else
labelText = String.Format("#{0:x2}{1:x2}{2:x2}", color.R, color.G, color.B);
//we use StringValue as it auto-bolds the text for non-default values
Label theLabel = (Label) base.StringValue (labelText);
theLabel.Xalign = 0;
theLabel.Xpad = 3;
HBox hbox = new HBox ();
hbox.PackStart (colorPreviewAlign, false, false, 0);
hbox.PackStart (theLabel, true, true, 0);
return hbox;
}
示例6: OnMouseDown
protected override void OnMouseDown (DrawingArea canvas, ButtonPressEventArgs args, Cairo.PointD point)
{
// Ignore extra button clicks while drawing
if (is_drawing)
return;
Document doc = PintaCore.Workspace.ActiveDocument;
hist = new SelectionHistoryItem(Icon, Name);
hist.TakeSnapshot();
reset_origin = args.Event.GetPoint();
active_control = HandleResize (point);
if (!active_control.HasValue)
{
combine_mode = PintaCore.Workspace.SelectionHandler.DetermineCombineMode(args);
double x = Utility.Clamp(point.X, 0, doc.ImageSize.Width - 1);
double y = Utility.Clamp(point.Y, 0, doc.ImageSize.Height - 1);
shape_origin = new PointD(x, y);
doc.PreviousSelection.Dispose ();
doc.PreviousSelection = doc.Selection.Clone();
doc.Selection.SelectionPolygons.Clear();
// The bottom right corner should be selected.
active_control = 3;
}
is_drawing = true;
}
示例7: BuildInterface
private void BuildInterface()
{
VBox vbox = this.Child as VBox;
HButtonBox buttonBox = new HButtonBox ();
drawingArea = new DrawingArea ();
drawingArea.SetSizeRequest (640, 480);
captureButton = new Button ("Capture");
previewButton = new Button ("Preview");
previewButton.Sensitive = false;
saveButton = new Button ("Save");
saveButton.Sensitive = false;
cancelButton = new Button ("Cancel");
buttonBox.PackStart (captureButton);
buttonBox.PackStart (previewButton);
buttonBox.PackStart (saveButton);
buttonBox.PackStart (cancelButton);
buttonBox.LayoutStyle = ButtonBoxStyle.Center;
vbox.PackStart (drawingArea);
vbox.PackStart (buttonBox, false, true, 8);
this.ShowAll ();
this.DeleteEvent += new DeleteEventHandler(OnDelete);
captureButton.Clicked += new EventHandler (CaptureButtonClicked);
previewButton.Clicked += new EventHandler(PreviewButtonClicked);
saveButton.Clicked += new EventHandler (SaveButtonClicked);
cancelButton.Clicked += new EventHandler (CancelButtonClicked);
}
示例8: GlToggleButton
public GlToggleButton(GdkGL.Config config)
{
// VBox.
VBox vbox = new VBox (false, 0);
vbox.BorderWidth = 10;
// Drawing area for drawing OpenGL scene.
DrawingArea drawing_area = new DrawingArea ();
drawing_area.SetSizeRequest (200, 200);
// Set OpenGL-capability to the widget.
m_gl = new GlWidget (drawing_area, config);
drawing_area.Realized += new EventHandler (Realize);
drawing_area.ConfigureEvent += new ConfigureEventHandler (Configure);
drawing_area.ExposeEvent += new ExposeEventHandler (Expose);
drawing_area.Unrealized += new EventHandler (Unrealize);
drawing_area.VisibilityNotifyEvent += new VisibilityNotifyEventHandler (VisibilityNotify);
vbox.PackStart (drawing_area, true, true, 0);
drawing_area.Show ();
// Label.
Label label = new Label ("Toggle Animation");
vbox.PackStart (label, false, false, 10);
label.Show ();
Toggled += new EventHandler (ToggleAnimation);
// Add VBox.
vbox.Show ();
Add (vbox);
}
示例9: EditPlayer
public override void EditPlayer(Text text)
{
playerText = text;
if (playerDialog == null) {
Gtk.Dialog d = new Gtk.Dialog (Catalog.GetString ("Select player"),
this, DialogFlags.Modal | DialogFlags.DestroyWithParent,
Stock.Cancel, ResponseType.Cancel);
d.WidthRequest = 600;
d.HeightRequest = 400;
DrawingArea da = new DrawingArea ();
TeamTagger tagger = new TeamTagger (new WidgetWrapper (da));
tagger.ShowSubstitutionButtons = false;
tagger.LoadTeams ((ViewModel.Project as ProjectLongoMatch).LocalTeamTemplate, (ViewModel.Project as ProjectLongoMatch).VisitorTeamTemplate,
(ViewModel.Project as ProjectLongoMatch).Dashboard.FieldBackground);
tagger.PlayersSelectionChangedEvent += players => {
if (players.Count == 1) {
Player p = players [0];
playerText.Value = p.ToString ();
d.Respond (ResponseType.Ok);
}
tagger.ResetSelection ();
};
d.VBox.PackStart (da, true, true, 0);
d.ShowAll ();
playerDialog = d;
}
if (playerDialog.Run () != (int)ResponseType.Ok) {
text.Value = null;
}
playerDialog.Hide ();
}
示例10: PlainSurfaceItem
public PlainSurfaceItem(int maxWidth, int maxHeight, int widthRequest = 0, int heightRequest = 0, string label = null)
{
//Console.WriteLine ("PlainSurfaceItem");
_label = label;
this._evtBox = new EventBox ();
this._draw = new global::Gtk.DrawingArea ();
if(widthRequest > 0) {
_draw.WidthRequest = widthRequest;
}
if(heightRequest > 0) {
_draw.HeightRequest = heightRequest;
}
this._evtBox.Add (this._draw);
maxWidth = Math.Max (maxWidth, widthRequest);
maxHeight = Math.Max (maxHeight, heightRequest);
this._height = Math.Max(_draw.Allocation.Height, heightRequest);
this._width = Math.Max(_draw.Allocation.Width, widthRequest);
this._mode = DisplayMode.Snapshot;
this._surface = new ImageSurface(Format.Argb32, maxWidth, maxHeight);
this._button = MouseButton.None;
this._background = new Color (1.0, 1.0, 1.0);
_draw.ExposeEvent += DrawExpose;
_evtBox.ButtonPressEvent += DrawButtonPressEvent;
_evtBox.ButtonReleaseEvent += DrawButtonReleaseEvent;
_evtBox.MotionNotifyEvent += DrawMotionNotifyEvent;
}
示例11: Main15
//private static Gdk.Pixmap pixmap = null;
//private static Gtk.InputDialog inputDialog = null;
public static int Main15 (string[] args) {
Application.Init ();
win = new Gtk.Window ("Scribble XInput Demo");
win.DeleteEvent += new DeleteEventHandler (WindowDelete);
vBox = new VBox (false, 0);
win.Add (vBox);
darea = new Gtk.DrawingArea ();
darea.SetSizeRequest (200, 200);
// darea.ExtensionEvents=ExtensionMode.Cursor;
vBox.PackStart (darea, true, true, 0);
//darea.ExposeEvent += new ExposeEventHandler (ExposeEvent);
darea.ConfigureEvent += new ConfigureEventHandler (ConfigureEvent);
darea.MotionNotifyEvent += new MotionNotifyEventHandler (MotionNotifyEvent);
darea.ButtonPressEvent += new ButtonPressEventHandler (ButtonPressEvent);
darea.Events = EventMask.ExposureMask | EventMask.LeaveNotifyMask |
EventMask.ButtonPressMask | EventMask.PointerMotionMask;
inputButton = new Button("Input Dialog");
vBox.PackStart (inputButton, false, false, 0);
inputButton.Clicked += new EventHandler (InputButtonClicked);
quitButton = new Button("Quit");
vBox.PackStart (quitButton, false, false, 0);
quitButton.Clicked += new EventHandler (QuitButtonClicked);
win.ShowAll ();
Application.Run ();
return 0;
}
示例12: BoardRenderer
public BoardRenderer(Gtk.DrawingArea area, int width, int height, int fieldSize)
{
area.SetSizeRequest (width * fieldSize, height * fieldSize);
this.area = area;
this.width = width;
this.height = height;
this.fieldSize = fieldSize;
}
示例13: WorkspaceService
public WorkspaceService(Gtk.Bin mainWindow, DrawingArea designArea,DrawingArea previewArea, PropertyGrid.PropertyGrid propertyGrid,Gtk.Label statusLabel)
{
this.designArea = designArea;
this.previewArea = previewArea;
this.propertyGrid = propertyGrid;
this.mainControl = mainWindow;
this.StatusLabel = statusLabel;
}
示例14: OnMouseDown
protected override void OnMouseDown(DrawingArea canvas, ButtonPressEventArgs args, Cairo.PointD point)
{
shape_origin = point;
is_drawing = true;
hist = new SelectionHistoryItem (Icon, Name);
hist.TakeSnapshot ();
}
示例15: MainWindow_Widget2
public MainWindow_Widget2()
: base("Widget2")
{
SetDefaultSize(800, 600);
SetPosition(WindowPosition.Center);
BorderWidth = 7;
DeleteEvent += delegate
{
Application.Quit();
};
_label = new Label("...");
Entry entry = new Entry();
entry.Changed += OnChangedEntry;
// scale and image
HScale scale = new HScale(0, 100, 1);
{
scale.SetSizeRequest(160, 35);
scale.ValueChanged += OnChangeScale;
LoadImage();
_image = new Image(img1);
}
// Color
ToggleButton red = new ToggleButton("red");
{
red.SetSizeRequest(80, 35);
red.Clicked += OnRed;
_area = new DrawingArea();
_area.SetSizeRequest(150, 150);
}
Calendar calendar = new Calendar();
{
calendar.DaySelected += OnDaySelected;
}
Fixed fix = new Fixed();
fix.Put(entry, 60, 100);
fix.Put(_label, 60, 40);
fix.Put(scale, 60, 200);
fix.Put(_image, 10, 240);
fix.Put(red, 300, 250);
fix.Put(_area, 300, 500);
fix.Put(calendar, 500, 300);
Add(fix);
ShowAll();
}