private static bool LiftItem(string command, Argument[] args, bool quiet, bool force) { if (args.Length < 1) { throw new RunTimeError(null, "Usage: lift (serial) [amount]"); } Serial serial = args[0].AsSerial(); if (!serial.IsValid) { throw new RunTimeError(null, $"{command} - Invalid serial"); } ushort amount = 1; if (args.Length == 2) { amount = Utility.ToUInt16(args[1].AsString(), 1); } if (_lastLiftId > 0) { if (DragDropManager.LastIDLifted == _lastLiftId) { _lastLiftId = 0; Interpreter.ClearTimeout(); return(true); } Interpreter.Timeout(30000, () => { _lastLiftId = 0; return(true); }); } else { Item item = World.FindItem(serial); if (item != null) { _lastLiftId = DragDropManager.Drag(item, amount <= item.Amount ? amount : item.Amount); } else { CommandHelper.SendWarning(command, "Item not found or out of range", quiet); return(true); } } return(false); }
public MainPage() { InitializeComponent(); this.Loaded += MainPage_Loaded; DragDropManager.AddDragInitializeHandler(this.ColumnsListBox, OnDragInitialize); DragDropManager.AddDropHandler(this.ColumnsListBox, OnDrop); DragDropManager.AddGiveFeedbackHandler(this.ColumnsListBox, OnGiveFeedback); this.clubsGrid.ColumnReordered += clubsGrid_ColumnReordered; }
/// <summary> /// Reads the favorites from the disk and displays the icons. /// </summary> /// <remarks>throws no exceptions</remarks> public void LoadFavorites() { if (pFavorites.InvokeRequired) { pFavorites.BeginInvoke(new Action(LoadFavorites)); return; } try { pFavorites.Controls.Clear(); pFavorites.Visible = false; if (FavoriteServer.ServerAddress == null) { return; } using (Client.ServerConfig serverConfig = new Client.ServerConfig(FavoriteServer.ServerAddress)) { ServerInfo serverInfo = serverConfig.GetServerInfo(); foreach (Favorites.FavoritesItem i in FavoriteServer.Items) { try { StreamSourceInfo sourceInfo = serverInfo.StreamSources.FindSource(i.SourceName); Thumbnail st = new Thumbnail(); st.ServerInfo = serverInfo; st.SourceInfo = sourceInfo; if (i.IconFilename != null) { st.IconFilename = i.IconFilename; } st.Cursor = Cursors.Hand; st.DragStarted += new MouseEventHandler(Thumbnail_DragStarted); DragDropManager.RegisterNonTarget(st); pFavorites.Controls.Add(st); } catch (Exception ex) { Debug.WriteLine("Couldn't load source: " + i.SourceName + " > " + ex.Message); } } } } catch (Exception ex) { ErrorLogger.DumpToDebug(ex); Debug.WriteLine("Can't contact favorite server (" + FavoriteServer.ServerAddress + "): " + ex.Message); } pFavorites.Visible = (pFavorites.Controls.Count > 0); }
private void Awake() { // singleton if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } }
public override void OnButtonPress(int num) { switch (num) { case 1: World.Player.SendMessage(MsgLevel.Force, LocString.TargItemAdd); Targeting.OneTimeTarget(new Targeting.TargetResponseCallback(OnTarget)); break; case 2: SetHotBag(); break; case 3: Organize(); break; case 4: if (m_SubList.SelectedIndex >= 0 && m_SubList.SelectedIndex < m_Items.Count) { m_Items.RemoveAt(m_SubList.SelectedIndex); m_SubList.Items.RemoveAt(m_SubList.SelectedIndex); } break; case 5: { if (MessageBox.Show(Language.GetString(LocString.Confirm), Language.GetString(LocString.ClearList), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Item bag = World.FindItem(m_Cont); if (bag != null) { bag.ObjPropList.Remove(Language.Format(LocString.OrganizerHBA1, Number)); bag.OPLChanged(); } m_SubList.Items.Clear(); m_Items.Clear(); m_Cont = 0; m_BagBTN.Text = Language.GetString(LocString.SetHB); } break; } case 6: DragDropManager.GracefulStop(); break; } }
public void OnDrop(PointerEventData eventData) { _dragDropManager = GameObject.FindGameObjectWithTag("DragDropManager").GetComponent <DragDropManager>(); _defausseCardManager = GameObject.FindGameObjectWithTag("DefausseCardManager").GetComponent <DefausseCardManager>(); if (eventData.pointerDrag != null && !eventData.pointerDrag.GetComponent <CardGame>().Defausse&& eventData.pointerDrag.GetComponent <CardGame>().CardPlayable&& !eventData.pointerDrag.GetComponent <CardGame>().ToDestroy) { _playerManager.Player.Argent += 2 + _playerManager.Player.NbCarteJaune; _playerManager.Player.SetText(); _dragDropManager.onDropCardAudio(); _defausseCardManager.DefausseCards.Add(eventData.pointerDrag); _defausseCardManager.NbCarteDefausseText(); _playerManager.Player.IsPlaying = false; _playerManager.Player.PlayerAdverse.IsPlaying = true; eventData.pointerDrag.GetComponent <CardGame>().SetCardPlayed(); GameObject.Find("DefausseAudio").GetComponent <AudioSource>().Play(); _zonePlayableManager.GetComponent <ZonePlayableManager>().HideShowZonePlayable(false); } if (eventData.pointerDrag != null && eventData.pointerDrag.GetComponent <CardGame>().ToDestroy) { if (_playerManager.Player.DestroyRessourcePrimaire) { _playerManager.Player.PlayerAdverse.Argile -= eventData.pointerDrag.GetComponent <CardGame>().GetCardEffect().BonusArgile; _playerManager.Player.PlayerAdverse.Bois -= eventData.pointerDrag.GetComponent <CardGame>().GetCardEffect().BonusBois; _playerManager.Player.PlayerAdverse.Pierre -= eventData.pointerDrag.GetComponent <CardGame>().GetCardEffect().BonusPierre; } if (_playerManager.Player.DestroyRessourceSecondaire) { _playerManager.Player.PlayerAdverse.Verre -= eventData.pointerDrag.GetComponent <CardGame>().GetCardEffect().BonusVerre; _playerManager.Player.PlayerAdverse.Papyrus -= eventData.pointerDrag.GetComponent <CardGame>().GetCardEffect().BonusPapyrus; } _defausseCardManager.DefausseCards.Add(eventData.pointerDrag); _dragDropManager.onDropCardAudio(); _defausseCardManager.NbCarteDefausseText(); _playerManager.Player.PlayerAdverse.SetText(); eventData.pointerDrag.GetComponent <CardGame>().SetCardPlayed(); if (CheckIfStartAge()) { GameObject.FindGameObjectWithTag("Manager").GetComponent <GameManager>().NextPlayerEndAge(); SceneManager.LoadScene("SelectionAvatar"); } } }
public WpfDragDropExtension(object owner) { _manager = (DragDropManager)owner; var host = WpfHost.Current; host.AllowDrop = true; host.DragEnter += OnHostDragEnter; host.DragOver += OnHostDragOver; host.DragLeave += OnHostDragLeave; host.Drop += OnHostDrop; }
public MainPage() { InitializeComponent(); MainViewModel viewModelData = new MainViewModel(); this.xLocalMachineTree.ItemsSource = viewModelData.LocalMachinePartitions; this.xApplicationTree.ItemsSource = viewModelData.Applications; DragDropManager.AddDragOverHandler(this.xLocalMachineTree, OnLocalMachineTreeDragOver, true); DragDropManager.AddDragOverHandler(this.xApplicationTree, OnApplicationTreeDragOver, true); DragDropManager.AddDropHandler(this.xApplicationTree, OnApplicationTreeDrop, true); }
public Example() { InitializeComponent(); this.SamplesList1.DataContext = this.SamplesList.DataContext = new SamplesViewModel(this.diagram); this.diagram.ItemsChanged += this.DiagramItemsChanged; this.fileManager = new FileManager(this.diagram); DragDropManager.AddDragInitializeHandler(this.panelBar, ToolboxDragService.OnDragInitialized); //// This is needed so that the code in SL and WPF is the same //// for the Undo/Redo list bindings in the SplitButton DropDownContent. this.DataContext = this.diagram.UndoRedoService; this.panelBar.ItemsSource = new HierarchicalGalleryItemsCollection(); }
private void InitializeDragAndDrop() { DragDropManager.RemoveDragInitializeHandler(this, new DragInitializeEventHandler(this.OnDragInitialized)); DragDropManager.RemoveDragOverHandler(this, new Telerik.Windows.DragDrop.DragEventHandler(this.OnDragOver)); DragDropManager.RemoveDragDropCompletedHandler(this, new Telerik.Windows.DragDrop.DragDropCompletedEventHandler(this.OnElementDragDropCompleted)); DragDropManager.RemoveDropHandler(this, new Telerik.Windows.DragDrop.DragEventHandler(this.OnDropCompleted)); DragDropManager.RemoveGiveFeedbackHandler(this, new Telerik.Windows.DragDrop.GiveFeedbackEventHandler(this.OnGiveFeedback)); DragDropManager.AddDragInitializeHandler(this, new DragInitializeEventHandler(this.OnDragInitialized)); DragDropManager.AddDragOverHandler(this, new Telerik.Windows.DragDrop.DragEventHandler(this.OnDragOver)); DragDropManager.AddDragDropCompletedHandler(this, new Telerik.Windows.DragDrop.DragDropCompletedEventHandler(this.OnElementDragDropCompleted)); DragDropManager.AddDropHandler(this, new Telerik.Windows.DragDrop.DragEventHandler(this.OnDropCompleted)); DragDropManager.AddGiveFeedbackHandler(this, new Telerik.Windows.DragDrop.GiveFeedbackEventHandler(this.OnGiveFeedback)); }
/// <summary> /// Handles the MouseMove of the drag source. Shows a visual notification if the asset can be dropped or not.. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The envet args instance containing event data.</param> private void DragSource_MouseMove(object sender, MouseEventArgs e) { if (this.IsDragging) { if (this.DragPopup != null && this.DragPopupChild != null && this.DragPopupChild.Children.Count > 0 && this.DragPopupChild.ActualHeight > 0 && this.DragPopupChild.ActualWidth > 0) { this.DragPopupChild.Opacity = 1; Point point = e.GetPosition(Application.Current.RootVisual); const double HeightOffset = 15; double currentVerticalPosition = point.Y - this.DragPopupChild.ActualHeight + HeightOffset; double currentHorizontalPosition = point.X - (this.DragPopupChild.ActualWidth / 2); this.DragPopup.VerticalOffset = currentVerticalPosition; this.DragPopup.HorizontalOffset = currentHorizontalPosition; FrameworkElement dropZone = this.GetDropZone(e); if (dropZone != null) { bool result = true; if (dropZone != null) { ICommand command = DragDropManager.GetDropCommand(dropZone); if (command != null) { DropPayload dropPayload = new DropPayload { DraggedItem = DragDropManager.GetDragData(this.dragSource), RelativePosition = e.GetPosition(dropZone), MouseEventArgs = e, DropData = DragDropManager.GetDropData(dropZone), CustomData = DragDropManager.GetCustomData(this.dragSource) }; result = command.CanExecute(dropPayload); } this.ShowDragDrop(result); } } else { this.ShowDragDrop(false); } } } }
private static bool DropItem(string command, Argument[] args, bool quiet, bool force) { if (args.Length < 2) { ScriptManager.Error("Usage: drop (serial) (x y z/layername)"); return(true); } Serial serial = args[0].AsSerial(); Point3D to = new Point3D(0, 0, 0); Layer layer = Layer.Invalid; switch (args.Length) { case 1: // drop at feet to = new Point3D(World.Player.Position.X, World.Player.Position.Y, World.Player.Position.Z); break; case 2: // dropping on a layer layer = (Layer)Enum.Parse(typeof(Layer), args[1].AsString(), true); break; default: // dropping at x/y/z to = new Point3D(Utility.ToInt32(args[1].AsString(), 0), Utility.ToInt32(args[2].AsString(), 0), Utility.ToInt32(args[3].AsString(), 0)); break; } if (DragDropManager.Holding != null) { if (layer > Layer.Invalid && layer <= Layer.LastUserValid) { Mobile m = World.FindMobile(serial); if (m != null) { DragDropManager.Drop(DragDropManager.Holding, m, layer); } } else { DragDropManager.Drop(DragDropManager.Holding, serial, to); } } else { World.Player.SendMessage(MsgLevel.Warning, LocString.MacroNoHold); } return(true); }
private static void OnGrabItem(bool loc, Serial serial, Point3D pt, ushort itemId) { Item item = World.FindItem(serial); if (item != null && item.Serial.IsItem && item.Movable && item.Visible) { Item hotbag = World.FindItem(_grabHotBag) ?? World.Player.Backpack; DragDropManager.DragDrop(item, item.Amount, hotbag); } else { World.Player.SendMessage(MsgLevel.Error, "Invalid or inaccessible item.", false); } }
private void ResetDragDropAdvisors() { if (this.SelectedItem != null) { FabTabItem lastTabItem = this.ItemContainerGenerator.ContainerFromIndex(this.Items.Count - 1) as FabTabItem; if (lastTabItem != null) { //when a tab closes that happens be the source or target on either of the advisors //it will disallow further drag and drop operations. therefore whenever a tab closes //reset this to something valid, in this case, the last item in the collection. DragDropManager.GetDragSourceAdvisor(lastTabItem).SourceUI = lastTabItem; DragDropManager.GetDropTargetAdvisor(lastTabItem).TargetUI = lastTabItem; } } }
private static void OnShowArrowDragCueChanged(DependencyObject target, DependencyPropertyChangedEventArgs args) { var element = (FrameworkElement)target; if ((bool)args.NewValue) { DragDropManager.AddDragInitializeHandler(element, OnElementDragInitialize, true); DragDropManager.AddDragDropCompletedHandler(element, OnElementDragDropCompleted, true); element.Unloaded += OnElementUnloaded; } else { UnsubscribeFromEvents(element); } }
public WpfDragDropExtension(object owner) { _manager = (DragDropManager)owner; var host = WpfHost.Current; if (host is not null) // TODO: Add support for multiple XamlRoots { host.AllowDrop = true; host.DragEnter += OnHostDragEnter; host.DragOver += OnHostDragOver; host.DragLeave += OnHostDragLeave; host.Drop += OnHostDrop; } }
protected override void OnAttached() { base.OnAttached(); dataPresenter = this.AssociatedObject; EventManager.RegisterClassHandler(typeof(XamDataGrid), UIElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(XamDataGrid_MouseLeftButtonDown)); var dataPresenterStyle = new Style(typeof(DataRecordPresenter)); dataPresenterStyle.Setters.Add(new EventSetter(FrameworkElement.LoadedEvent, new RoutedEventHandler(OnRecordPresenterLoaded))); dataPresenter.Resources.Add(typeof(DataRecordPresenter), dataPresenterStyle); DropTarget dropTarget = new DropTarget() { IsDropTarget = true }; DragDropManager.SetDropTarget(dataPresenter, dropTarget); }
public CollapsedDeviceViewer(Device device) { TitleText.Text = device.Name; _device = device; _device.Viewer = this; Deselect(); DeviceContextMenu = (ApolloContextMenu)this.Resources["DeviceContextMenu"]; GroupContextMenu = (ApolloContextMenu)this.Resources["GroupContextMenu"]; ChokeContextMenu = (ApolloContextMenu)this.Resources["ChokeContextMenu"]; DragDrop = new DragDropManager(this); SetEnabled(); }
public static bool Equip(Item item, Layer layer) { if (layer == Layer.Invalid || layer > Layer.LastUserValid || item == null || item.Layer == Layer.Invalid || item.Layer > Layer.LastUserValid) { return(false); } if (item != null && World.Player != null && item.IsChildOf(World.Player.Backpack)) { DragDropManager.DragDrop(item, World.Player, layer); return(true); } return(false); }
public ChainInfo(Chain chain) { InitializeComponent(); _chain = chain; Deselect(); Rename = new RenameManager(this); Rename.UpdateText(); _chain.ParentIndexChanged += Rename.UpdateText; DragDrop = new DragDropManager(this); SetEnabled(); }
private void AdminScreen_Loaded(object sender, RoutedEventArgs e) { PopupManager.Init(this.LayoutRoot); ServerManager.Instance.Reset(); ServerManager.Instance.Response += new ServerResponseEventHandler(OnServerResponse); _dragDropManager = new DragDropManager(LayoutRoot); lstActors.DragDropManager = _dragDropManager; lstTemplates.DragDropManager = _dragDropManager; // Event Hanlders ctlMap.CanAlwaysMove = true; ctlMap.DirectionClick += new Perenthia.Controls.DirectionEventHandler(ctlMap_DirectionClick); ServerManager.Instance.SendUserCommand("PLAY", this.OnPlayCommandResponse, _playerId); }
public ProjectWindow() { InitializeComponent(); #if DEBUG this.AttachDevTools(); #endif UpdateTopmost(Preferences.AlwaysOnTop); Preferences.AlwaysOnTopChanged += UpdateTopmost; DragDrop = new DragDropManager(this); for (int i = 0; i < Program.Project.Count; i++) { Contents_Insert(i, Program.Project[i]); } Selection = new SelectionManager(() => Program.Project.Tracks.FirstOrDefault()); BPM.Text = Program.Project.BPM.ToString(); observables.Add(BPM.GetObservable(TextBox.TextProperty).Subscribe(BPM_Changed)); for (int i = 0; i < 4; i++) { ((Dial)MacroDials.Children[i]).RawValue = Program.Project.GetMacro(i + 1); } Author.Text = Program.Project.Author.ToString(); observables.Add(Author.GetObservable(TextBox.TextProperty).Subscribe(Author_Changed)); UpdateTime(null, EventArgs.Empty); Timer = new DispatcherTimer() { Interval = new TimeSpan(0, 0, 1) }; Timer.Tick += UpdateTime; Timer.Start(); Started.Text = $"Started {Program.Project.Started.LocalDateTime.ToString("MM/dd/yyyy HH:mm")}"; observables.Add(this.GetObservable(Visual.BoundsProperty).Subscribe(Bounds_Updated)); observables.Add(TitleText.GetObservable(Visual.BoundsProperty).Subscribe(Bounds_Updated)); observables.Add(TitleCenter.GetObservable(Visual.BoundsProperty).Subscribe(Bounds_Updated)); observables.Add(CenteringLeft.GetObservable(Visual.BoundsProperty).Subscribe(Bounds_Updated)); observables.Add(CenteringRight.GetObservable(Visual.BoundsProperty).Subscribe(Bounds_Updated)); }
private static bool LiftType(string command, Argument[] args, bool quiet, bool force) { if (args.Length < 1) { ScriptManager.Error("Usage: lifttype (gfx/'name of item') [amount]"); return(true); } string gfxStr = args[0].AsString(); ushort gfx = Utility.ToUInt16(gfxStr, 0); ushort amount = Utility.ToUInt16(args[1].AsString(), 1); Item item; // No graphic id, maybe searching by name? if (gfx == 0) { item = World.Player.Backpack != null?World.Player.Backpack.FindItemByName(gfxStr, true) : null; if (item == null) { ScriptManager.Error($"Script Error: Couldn't find '{gfxStr}'"); return(true); } } else { item = World.Player.Backpack != null?World.Player.Backpack.FindItemByID(gfx) : null; } if (item != null) { if (item.Amount < amount) { amount = item.Amount; } DragDropManager.Drag(item, amount); } else { World.Player.SendMessage(MsgLevel.Warning, LocString.NoItemOfType, (ItemID)gfx); } return(true); }
public static void ToggleRight() { if (World.Player == null) { return; } Item item = World.Player.GetItemOnLayer(Layer.RightHand); if (item == null) { if (m_Right != null) { m_Right = World.FindItem(m_Right.Serial); } if (m_Right != null && m_Right.IsChildOf(World.Player.Backpack)) { // try to also undress conflicting hand(s) Item conflict = World.Player.GetItemOnLayer(Layer.LeftHand); if (conflict != null && (conflict.IsTwoHanded || m_Right.IsTwoHanded)) { Item ub = DressList.FindUndressBag(conflict); if (ub != null) { DragDropManager.DragDrop(conflict, ub); } } DragDropManager.DragDrop(m_Right, World.Player, DressList.GetLayerFor(m_Right)); } else { World.Player.SendMessage(MsgLevel.Force, LocString.MustDisarm); } } else { Item ub = DressList.FindUndressBag(item); if (ub != null) { DragDropManager.DragDrop(item, ub); } m_Right = item; } }
public static void OnUndressAll() { for (int i = 0; i < World.Player.Contains.Count; i++) { Item item = (Item)World.Player.Contains[i]; if (item.Layer <= Layer.LastUserValid && item.Layer != Layer.Backpack && item.Layer != Layer.Hair && item.Layer != Layer.FacialHair) { Item pack = DressList.FindUndressBag(item); if (pack != null) { DragDropManager.DragDrop(item, pack); } } } //if ( Macros.MacroManager.AcceptActions ) // MacroManager.Action( new Macros.UnDressAction( (byte)0 ) ); }
public MainWindow() { InitializeComponent(); // Set the items source of the controls: //allProductsView.ItemsSource = null; //allProductsView.ItemsSource = CategoryViewModel.Generate(); //var Background = new BackgroundWorkerTest(); IList wishlistSource = new ObservableCollection <ProductViewModel>(); wishlistView.ItemsSource = wishlistSource; DragDropManager.AddDragOverHandler(allProductsView, OnItemDragOver); DragDropManager.AddDropHandler(allProductsView, OnDrop); }
public override bool Perform() { Item barrel = WorldEx.FindItemG(0x0E77, 0x0847, i => i.DistanceTo(World.Player) < 3); if (barrel == null) { WorldEx.SendMessage("Sud nenalezen."); Parent.Stop(); } foreach (Item item in World.Player.Backpack.FindItems(i => IsFish(i.ItemID))) { if (!DragDropManager.HasDragFor(item.Serial)) { DragDrop.Move(item, barrel); } } return(true); }
public MainWindow() { InitializeComponent(); // Set the items source of the controls: allProductsView.ItemsSource = CategoryViewModel.Generate(); IList wishlistSource = new ObservableCollection <ProductViewModel>(); foreach (ProductViewModel product in ProductViewModel.Generate(6)) { wishlistSource.Add(product); } wishlistView.ItemsSource = wishlistSource; DragDropManager.AddDragOverHandler(allProductsView, OnItemDragOver); DragDropManager.AddDropHandler(allProductsView, OnDrop); }
private static void ToolBarDragDropCompleted(object sender, DragDropCompletedEventArgs e) { RadToolBar toolBar = e.Source as RadToolBar; DragDropInfo info = GetDragDropInfo(e.Data); if (toolBar == null || info == null) { return; } DragDropManager.RemoveDragDropCompletedHandler(info.ToolBar, ToolBarDragDropCompleted); ClearActiveToolBarStyle(info.ToolBar); ClearHitTesting(info.Tray.Items); HideNewBandIndicator(info.Tray); e.Handled = true; }
/// <summary> /// Check if there are drop zones an specific position. /// </summary> /// <param name="e">The mouse event args.</param> /// <returns>A list of possible drop zones.</returns> private IList <FrameworkElement> CheckDropZones(MouseEventArgs e) { IList <FrameworkElement> dropZonesAtCurrentCord = new List <FrameworkElement>(); if (this.DragPopup != null && this.DragPopupChild != null && this.DragPopupChild.Children.Count > 0) { DragDropControl dragDropControl = this.DragPopupChild.Children[0] as DragDropControl; if (dragDropControl != null) { IList <FrameworkElement> invalidDropZones = new List <FrameworkElement>(); foreach (FrameworkElement frameworkElement in DragDropManager.DropZones) { IDropInfo dropInfo = DragDropManager.GetDropInfo(frameworkElement); Type dragSourceType = dragDropControl.DragContent.GetType(); try { Point dropPoint = e.GetPosition(frameworkElement); if ((dropPoint.X >= 0 && dropPoint.X <= frameworkElement.ActualWidth) && (dropPoint.Y >= 0 && dropPoint.Y <= frameworkElement.ActualHeight) && dropInfo.AllowedDragTypes.Contains(dragSourceType)) { dropZonesAtCurrentCord.Add(frameworkElement); } } catch (Exception) { invalidDropZones.Add(frameworkElement); } } foreach (FrameworkElement element in invalidDropZones) { DragDropManager.DropZones.Remove(element); } invalidDropZones.Clear(); } } return(dropZonesAtCurrentCord); }
void Awake() { instance = this; }