当前位置: 首页>>代码示例>>C#>>正文


C# Gdk.GetSelectedAction方法代码示例

本文整理汇总了C#中Gdk.GetSelectedAction方法的典型用法代码示例。如果您正苦于以下问题:C# Gdk.GetSelectedAction方法的具体用法?C# Gdk.GetSelectedAction怎么用?C# Gdk.GetSelectedAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gdk的用法示例。


在下文中一共展示了Gdk.GetSelectedAction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoDragDrop

        internal bool DoDragDrop(Gdk.DragContext context, int x, int y, uint time)
        {
            DragDropInfo.LastDragPosition = new Point (x, y);
            var cda = ConvertDragAction (context.GetSelectedAction());

            DragDropResult res;
            if ((enabledEvents & WidgetEvent.DragDropCheck) == 0) {
                if ((enabledEvents & WidgetEvent.DragDrop) != 0)
                    res = DragDropResult.None;
                else
                    res = DragDropResult.Canceled;
            }
            else {
                DragCheckEventArgs da = new DragCheckEventArgs (new Point (x, y), Util.GetDragTypes (context.ListTargets ()), cda);
                ApplicationContext.InvokeUserCode (delegate {
                    EventSink.OnDragDropCheck (da);
                });
                res = da.Result;
                if ((enabledEvents & WidgetEvent.DragDrop) == 0 && res == DragDropResult.None)
                    res = DragDropResult.Canceled;
            }
            if (res == DragDropResult.Canceled) {
                Gtk.Drag.Finish (context, false, false, time);
                return true;
            }
            else if (res == DragDropResult.Success) {
                Gtk.Drag.Finish (context, true, cda == DragDropAction.Move, time);
                return true;
            }
            else {
                // Undefined, we need more data
                QueryDragData (context, time, false);
                return true;
            }
        }
开发者ID:mono,项目名称:xwt,代码行数:35,代码来源:WidgetBackend.cs

示例2: DoDragDataReceived

        internal bool DoDragDataReceived(Gdk.DragContext context, int x, int y, Gtk.SelectionData selectionData, uint info, uint time)
        {
            if (DragDropInfo.DragDataRequests == 0) {
                // Got the data without requesting it. Create the datastore here
                DragDropInfo.DragData = new TransferDataStore ();
                DragDropInfo.LastDragPosition = new Point (x, y);
                DragDropInfo.DragDataRequests = 1;
            }

            DragDropInfo.DragDataRequests--;

            // If multiple drag/drop data types are supported, we need to iterate through them all and
            // append the data. If one of the supported data types is not found, there's no need to
            // bail out. We must raise the event
            Util.GetSelectionData (ApplicationContext, selectionData, DragDropInfo.DragData);

            if (DragDropInfo.DragDataRequests == 0) {
                if (DragDropInfo.DragDataForMotion) {
                    // If no specific action is set, it means that no key has been pressed.
                    // In that case, use Move or Copy or Link as default (when allowed, in this order).
                    var cact = ConvertDragAction (context.Actions);
                    if (cact != DragDropAction.Copy && cact != DragDropAction.Move && cact != DragDropAction.Link) {
                        if (cact.HasFlag (DragDropAction.Move))
                            cact = DragDropAction.Move;
                        else if (cact.HasFlag (DragDropAction.Copy))
                            cact = DragDropAction.Copy;
                        else if (cact.HasFlag (DragDropAction.Link))
                            cact = DragDropAction.Link;
                        else
                            cact = DragDropAction.None;
                    }

                    DragOverEventArgs da = new DragOverEventArgs (DragDropInfo.LastDragPosition, DragDropInfo.DragData, cact);
                    ApplicationContext.InvokeUserCode (delegate {
                        EventSink.OnDragOver (da);
                    });
                    OnSetDragStatus (context, (int)DragDropInfo.LastDragPosition.X, (int)DragDropInfo.LastDragPosition.Y, time, ConvertDragAction (da.AllowedAction));
                    return true;
                }
                else {
                    // Use Context.Action here since that's the action selected in DragOver
                    var cda = ConvertDragAction (context.GetSelectedAction());
                    DragEventArgs da = new DragEventArgs (DragDropInfo.LastDragPosition, DragDropInfo.DragData, cda);
                    ApplicationContext.InvokeUserCode (delegate {
                        EventSink.OnDragDrop (da);
                    });
                    Gtk.Drag.Finish (context, da.Success, cda == DragDropAction.Move, time);
                    return true;
                }
            } else
                return false;
        }
开发者ID:mono,项目名称:xwt,代码行数:52,代码来源:WidgetBackend.cs


注:本文中的Gdk.GetSelectedAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。