private void OnPhotoButtonClick(object sender, RoutedEventArgs e) { if (this.DisplayMode == StatusDisplayMode.Base) { System.Windows.Forms.OpenFileDialog fileDialog = new System.Windows.Forms.OpenFileDialog(); fileDialog.Filter = "Image Files (*.jpg;*.jpeg;*.gif;*.png)|*.jpg;*.jpeg;*.gif;*.png"; if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.imageFile = DragContainer.ConstrainImage(fileDialog.FileName, FacebookImage.GetDimensionSize(FacebookImageDimensions.Big)); BitmapImage image = new BitmapImage(new Uri(this.imageFile)); image.Freeze(); this.photoImage.Source = image; this.imageFile = fileDialog.FileName; SwitchDisplayMode(StatusDisplayMode.Photo); } } else { this.photoImage.Source = null; SwitchDisplayMode(StatusDisplayMode.Base); } }
public void UpdateDrag() { if (DragContainer == null) { return; } float delta_time = Time.deltaTime; Vector3 pos = UICamera.lastWorldPosition; Vector3 move = pos - DragContainer.transform.position; pos.z = DragContainer.transform.parent.position.z - 2f; DragContainer.transform.position = pos; IsDragOut = CheckDragIndex(); DragContainer.SetRotation(move.x / delta_time * 10f); //if (Mathf.Abs(move.y) > Mathf.Abs(move.x)) //{ // float speed = move.y / delta_time; // if (speed > 2f) // IsDragOut = true; //} if (IsBatching == false) { UpdateBatch(); } }
public DragFabricButtonState(GameObject dragArea, Camera mainCamera, Camera guiCamera, DragContainer dragContainer) { this.dragArea = dragArea; this.mainCamera = mainCamera; this.guiCamera = guiCamera; this.dragContainer = dragContainer; }
public void SetDragReferences(ScrollRect scrollRect, int index, float dragHeight, DragContainer dragContainer = null) { this.scrollRect = scrollRect; this.index = index; this.dragHeight = dragHeight; this.dragContainer = dragContainer; }
private void OnPhotoButtonClick(object sender, RoutedEventArgs e) { if (this.DisplayMode == StatusDisplayMode.Base) { System.Windows.Forms.OpenFileDialog fileDialog = new System.Windows.Forms.OpenFileDialog(); fileDialog.Filter = "Image Files (*.jpg;*.jpeg;*.gif;*.png)|*.jpg;*.jpeg;*.gif;*.png"; if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.imageFile = DragContainer.ConstrainImage(fileDialog.FileName, FacebookImage.GetDimensionSize(FacebookImageDimensions.Big)); BitmapImage image = new BitmapImage(new Uri(this.imageFile)); image.Freeze(); this.photoImage.Source = image; this.imageFile = fileDialog.FileName; SwitchDisplayMode(StatusDisplayMode.Photo); // make sure we're still active (if in a popup, the OFD will close us) Action a = () => this.IsActive = true; Dispatcher.BeginInvoke(a, System.Windows.Threading.DispatcherPriority.Background, null); } } else { this.photoImage.Source = null; SwitchDisplayMode(StatusDisplayMode.Base); } }
public void MouseUp() { if (units > 0) { DragContainer.Enable(icon, InstantiateDisease); } }
public void OnDrop(PointerEventData eventData) { GameObject Inventory = GameObject.Find("Inventory"); if (Inventory) { InventorySystem InvenSystem = Inventory.GetComponent <InventorySystem>(); Transform Container = Inventory.transform.Find("DragContainer"); DragContainer dragContainer = Container.GetComponent <DragContainer>(); if (dragContainer.DragItem == null) { return; } float price; if (dragContainer.DragItem.itemTag == Scriptable_Item.tag_item.Expendables) { price = dragContainer.DragItem.Gold * dragContainer.count * 0.4f; } else { price = dragContainer.DragItem.Gold * 0.7f; } dragContainer.DragItem = null; dragContainer.count = 0; dragContainer.image.sprite = null; InvenSystem.SaleItem(price); } }
private void EndDrag() { if (selectedItem == null) { return; } GameObject container = RaycastUI("UI_Slot"); DropContainer dropContainer = (container == null) ? null : container.GetComponent <DropContainer>(); // could not find valid drop location if (container == null || container == selectedItemSlot.gameObject) { selectedItem.transform.localPosition = Vector3.zero; } // delete item else if (container.name == "Trash") { selectedItem.transform.SetParent(container.transform); loadout.TrashItem(selectedItem.Item); if (selectedItemSlot.transform.parent.name == "PendingItems") { Destroy(selectedItemSlot.gameObject); } Destroy(selectedItem.gameObject); } // only slot items of the same type else if (dropContainer.Type == selectedItem.Item.Type || dropContainer.Type == SlotType.None) { // swap items if (container.transform.childCount > 0) { loadout.SlotItem(selectedItem.Item); container.transform.GetChild(0).SetParent(selectedItemSlot.transform); selectedItem.transform.SetParent(container.transform); } // fill empty slot else { loadout.SlotItem(selectedItem.Item); selectedItem.transform.SetParent(container.transform); if (selectedItemSlot.name == "Slot") { Destroy(selectedItemSlot.gameObject); } } } selectedItem.transform.localPosition = Vector3.zero; Trash.SetActive(false); selectedItem = null; selectedItemSlot = null; }
public DragContainer CreateDragContainer(string type, string name) { IntPtr cPtr = CeguiBindingsPINVOKE.WindowManager_CreateDragContainer(swigCPtr, new CeguiDotNet.String(type).HandleRef, new CeguiDotNet.String(name).HandleRef); DragContainer ret = (cPtr == IntPtr.Zero) ? null : new DragContainer(cPtr, false); if (CeguiBindingsPINVOKE.SWIGPendingException.Pending) { throw CeguiBindingsPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
private void BeginDrag() { GameObject item = RaycastUI("UI_Item"); GameObject slot = RaycastUI("UI_Slot"); if (item != null && slot != null) { selectedItem = item.GetComponent <DragContainer>(); selectedItemSlot = slot.GetComponent <DropContainer>(); } Trash.SetActive(true); }
/// <summary> /// Initiates a drag-and-drop operation. /// </summary> /// <param name="items">The items being dragged.</param> /// <returns>A value from the <see cref="DragDropEffects"/> enumeration that represents the final effect that was performed during the drag-and-drop operation.</returns> protected internal DragDropEffects DoDragDrop(params object[] items) { var data = new DragContainer(items); try { return(GameForm.DoDragDrop(new DataObject(DragContainer.Format, data), DragDropEffects.All)); } catch (COMException) { return(DragDropEffects.None); } }
protected void onDragContainerLoaded(string path, GameObject asset) { if (!isDestroyed) { GameObject gameObject = UnityEngine.Object.Instantiate(asset, base.transform); dragContainerInstance = gameObject.GetComponent <DragContainer>(); dragContainerInstance.gameObject.AddComponent <LayoutElement>().ignoreLayout = true; gameObject.SetActive(value: false); if (isAllContentLoaded()) { setPoolOverride(); } } }
private IEnumerator loadDragFabricContainer() { AssetRequest <GameObject> assetRequest = Content.LoadAsync(dragFabricPrefabKey); yield return(assetRequest); GameObject dragFabricContainerInstance = Object.Instantiate(assetRequest.Asset); dragFabricContainerInstance.transform.SetParent(base.gameObject.transform, worldPositionStays: false); dragFabricContainerInstance.name = "DragFabricIcon"; dragFabricContainerInstance.SetActive(value: false); dragFabricContainer = dragFabricContainerInstance.GetComponent <DragContainer>(); dragFabricContainer.ImageOffset = FabricDragIconOffset; isFabricDragContainerLoaded = true; setupStates(); }
public Control CreateDragRepresentation(Type t) { //Default behavior: DragContainer dc = new DragContainer(); Control c = (Control)Activator.CreateInstance(t); //Thanks to http://www.jeffblankenburg.com/2008/04/how-about-some-code-simple-resizing-in.html for scaling code double uniformScaleAmount = c.UniformScaleAmount(MAX_DIMENSION); if (double.IsNaN(uniformScaleAmount)) { dc.LayoutRoot.Children.Add(c); c.Measure(new Size(MAX_DIMENSION, MAX_DIMENSION)); } TransformGroup tg = new TransformGroup(); ScaleTransform st = new ScaleTransform(); st.ScaleX = uniformScaleAmount; st.ScaleY = uniformScaleAmount; tg.Children.Add(st); c.RenderTransform = tg; c.InvalidateMeasure(); c.UpdateLayout(); double estimatedNewWidth = c.Width * uniformScaleAmount; double estimatedNewHeight = c.Height * uniformScaleAmount; double left = (dc.Width / 2.0D) - (estimatedNewWidth / 2.0D); double top = (dc.Height / 2.0D) - (estimatedNewHeight / 2.0D); c.SetValue(Canvas.LeftProperty, left); c.SetValue(Canvas.TopProperty, top); dc.LayoutRoot.Children.Add(c); dc.Opacity = DRAG_OPACITY; dc.LayoutRoot.Opacity = DRAG_OPACITY; return(dc); }
void OnTriggerEnter(Collider other) { if (other.tag == "Player") { gg = other; go = BaseRoller.InstantiateItem(roll, other.transform.position, other.transform.rotation, other.transform.GetChild(0)).GetComponent <Item>(); go.gameObject.SetActive(false); GameObject dg = Instantiate(slot, pending.position, pending.rotation, pending); dg.name = "Slot"; GameObject item = Instantiate(PrefabHolder.staticIconArray[roll.prefabID].icon, dg.transform.position, dg.transform.rotation, dg.transform); item.tag = Constants.Tag_UI_Item; Instantiate(PrefabHolder.staticTierArray[(int)go.Rarity], item.transform.position, item.transform.rotation).transform.SetParent(item.transform); DragContainer dragContainer = dg.GetComponentInChildren <DragContainer>(); dragContainer.Item = go; Destroy(gameObject); } }
public DragTemplateState(Camera mainCamera, Camera guiCamera, DragContainer dragContainer) { this.mainCamera = mainCamera; this.guiCamera = guiCamera; this.dragContainer = dragContainer; }
void Awake() { instance = this; }
public DragInventoryButtonState(DragContainer dragContainer, Camera mainCamera, Camera guiCamera) { this.dragContainer = dragContainer; this.mainCamera = mainCamera; this.guiCamera = guiCamera; }
private void OnUploadExecuted(object sender, ExecutedRoutedEventArgs e) { Assert.IsNull(_workerThread); string albumName = _albumName.Text; string albumDescription = _albumDescription.Text; string albumLocation = _albumLocation.Text; FacebookPhotoAlbum album = _albumsComboBox.SelectedItem as FacebookPhotoAlbum; Page = PhotoUploaderPage.Upload; UploadAlbumName = album != null ? album.Title : albumName; _closeCancelButton.Content = "Cancel"; UploadCount = 0; FileCount = Files.Count; FacebookClientApplication.Current2.MainWindow.SetTaskbarProgress(0); _uploadStatus.Text = ""; // This is terrible, but for some reason I can't get StringFormat to work correctly with the MultiBinding in this case. // This needs to be looked into next time there's any investment made into the PhotoUploadWizard. // (There are other things here that are also terrible (i.e. not localizable, not designable) so this isn't making anything worse...) _uploadPhotoStatusTextBlock.Text = "Uploading photo " + (UploadCount + 1) + " of " + FileCount + " to album " + UploadAlbumName; _workerThread = new Thread(new ThreadStart(() => { try { if (album == null) { album = ServiceProvider.ViewManager.CreatePhotoAlbum(albumName, albumDescription, albumLocation); } int count = 0; foreach (var file in Files) { Dispatcher.BeginInvoke(new Action(() => { BitmapImage image = new BitmapImage(new Uri(file.Path)); image.Freeze(); _nextPhotoImage.Source = image; })); string path = DragContainer.ConstrainImage(file.Path, FacebookImage.GetDimensionSize(FacebookImageDimensions.Big)); ServiceProvider.ViewManager.AddPhotoToAlbum(album, file.Description, path); count++; Dispatcher.BeginInvoke(new Action(() => { UploadCount = count; _uploadPhotoStatusTextBlock.Text = "Uploading photo " + (UploadCount + 1) + " of " + FileCount + " to album " + UploadAlbumName; FacebookClientApplication.Current2.MainWindow.SetTaskbarProgress((float)UploadCount / Files.Count); })); } Dispatcher.BeginInvoke(new Action(() => { ServiceProvider.ViewManager.NavigationCommands.NavigateToContentCommand.Execute(album); FacebookClientApplication.Current2.MainWindow.ClearTaskbarProgress(); Hide(); })); } catch (ThreadAbortException) { } catch (Exception) { Dispatcher.BeginInvoke(new Action(() => { _nextPhotoImage.Source = null; _uploadStatus.Text = "Upload failed."; _closeCancelButton.Content = "Close"; })); } })); _workerThread.Start(); }
void Awake() { singleton = this; view = GetComponent <SpriteRenderer>(); }
public DragDecalState(GameObject dragArea, Camera mainCamera, Camera guiCamera, DragContainer dragContainer) : base(dragArea, mainCamera, guiCamera, dragContainer) { }