本文整理汇总了C#中Gtk.DrawingArea.AddEvents方法的典型用法代码示例。如果您正苦于以下问题:C# DrawingArea.AddEvents方法的具体用法?C# DrawingArea.AddEvents怎么用?C# DrawingArea.AddEvents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.DrawingArea
的用法示例。
在下文中一共展示了DrawingArea.AddEvents方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WidgetWrapper
public WidgetWrapper(DrawingArea widget)
{
this.widget = widget;
MoveWaitMS = 200;
widget.AddEvents ((int)EventMask.PointerMotionMask);
widget.AddEvents ((int)EventMask.ButtonPressMask);
widget.AddEvents ((int)EventMask.ButtonReleaseMask);
widget.AddEvents ((int)EventMask.KeyPressMask);
widget.ExposeEvent += HandleExposeEvent;
widget.ButtonPressEvent += HandleButtonPressEvent;
widget.ButtonReleaseEvent += HandleButtonReleaseEvent;
widget.MotionNotifyEvent += HandleMotionNotifyEvent;
}
示例2: SharpApp
public SharpApp()
: base("Simple drawing")
{
SetDefaultSize(400, 400);
SetPosition(WindowPosition.Center);
DeleteEvent += delegate { Application.Quit(); };
DrawingArea darea = new DrawingArea();
darea.ExposeEvent += OnExpose;
darea.AddEvents ((int)Gdk.EventMask.ButtonPressMask);
//darea.ButtonPressEvent += onButtonPress;
ButtonPressEvent += onButtonPress;
System.Console.WriteLine ("ctor");
Add(darea);
ShowAll();
}
示例3: setupWindow
//.........这里部分代码省略.........
MenuItem Help = new MenuItem ("Help");
Help.Submenu = HelpMenu;
MenuItem AboutMenuItem = new MenuItem("About");
HelpMenu.Append (AboutMenuItem);
MainMenuBar.Append (File);
MainMenuBar.Append (Gesture);
MainMenuBar.Append (Points);
MainMenuBar.Append (Help);
/*********************End of menu bar components*********************/
//Drawing area which is the core component of the application
dArea = new DrawingArea ();
dArea.SetSizeRequest (500, 500);
//Horizontal box (4 sections) which contains all of the buttons along the
//bottom of the window
HBox ButtonHBox = new HBox (false, 6);
/*********************Start of Buttons*********************/
Button BtnCreateGesture = new Button ("Create");
Button BtnRecognizeGesture = new Button ("Recognize");
Button BtnClearScreen = new Button ("Clear");
Button BtnRecordPoints = new Button ("Record points");
Button BtnChangeColour = new Button ("Change colour");
//Button functions
BtnCreateGesture.Clicked += new EventHandler (createGesture);
BtnRecognizeGesture.Clicked += new EventHandler (recognizeGesture);
BtnClearScreen.Clicked += new EventHandler (clearScreen);
BtnRecordPoints.Clicked += new EventHandler (recordPoints);
BtnChangeColour.Clicked += changeColour;
//Adding buttons to the current horizontal box
ButtonHBox.PackStart (BtnCreateGesture, true, false, 0);
ButtonHBox.PackStart (BtnRecognizeGesture, true, false, 0);
ButtonHBox.PackStart (BtnClearScreen, true, false, 0);
ButtonHBox.PackStart (BtnRecordPoints, true, false, 0);
ButtonHBox.PackStart (BtnChangeColour, true, false, 0);
/*********************End of Buttons*********************/
//Status bar which shows the score and recognized gesture
sBar = new Statusbar ();
sBar.Push (1, "Ready");
//Entry box for batch function name to be used on the files
batchFunctionName = new Entry ("Recorded points function name");
batchFunctionName.AddEvents (
(int)Gdk.EventMask.ButtonPressMask
);
batchFunctionName.ButtonPressEvent += clearTextBox;
//Adding all components to the Vertical box
MainVBox.PackStart (MainMenuBar, false, false, 0);
MainVBox.PackStart (dArea, false, false, 0);
MainVBox.PackStart (ButtonHBox, false, false, 0);
MainVBox.PackStart (batchFunctionName, false, false, 0);
MainVBox.PackStart (sBar, false, false, 0);
Add (MainVBox);
ShowAll ();
//Surface 'pattern' for area to be covered
surface = new ImageSurface(Format.Argb32, 500, 500);
//Adding mouse events to the drawing area and assigning functions
dArea.AddEvents(
//Mouse Related Events
(int)Gdk.EventMask.PointerMotionMask
|(int)Gdk.EventMask.ButtonPressMask
|(int)Gdk.EventMask.ButtonReleaseMask
);
//Repaint the Canvas Internally.
dArea.ExposeEvent += OnDrawingAreaExposed;
//Do this on MousePress inside Area
dArea.ButtonPressEvent += OnMousePress;
//Do this on MouseReleased inside Area
dArea.ButtonReleaseEvent += OnMouseRelease;
//Do this if a Motion Occurs inside the Drawing Area
dArea.MotionNotifyEvent += OnMouseMotion2;
//Assigning close function to the window
DeleteEvent += delegate { Application.Quit(); };
//Checking to see if bool for using the dot function is true
//And assigning the required function as the delegate's operation
//Note: This will always be true, no current way to switch while
//application is running, has not been needed as of yet
if (isDot) {
Painter = new DrawShape (DrawDot);
myoPainter = new DrawShape (DrawDot);
} else {
Painter = new DrawShape (DrawLine);
}
}
示例4: 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";
}