コード例 #1
0
ファイル: AbilityItem.cs プロジェクト: khiemnd777/Bang
    void Start()
    {
        dragDropHandler = GetComponent <DragDropHandler>();
        rectTransform   = GetComponent <RectTransform>();
        minHeight       = titleContainer.GetHeight() + 10f;
        FitWithTacticContainer();

        dragDropHandler.onDragged += OnItemDragged;
    }
コード例 #2
0
 void Start()
 {
     // drag drop handler
     _dragDropHandler                     = GetComponent <DragDropHandler>();
     _dragDropHandler.onDragged          += OnItemDragged;
     _dragDropHandler.onBeginDragEvent   += OnItemBeginDrag;
     _dragDropHandler.onPointerDownEvent += OnPointerDownEvent;
     // drop zone handler
     _dropZoneHandler = GetComponent <DropZoneHandler>();
     _dropZoneHandler.onDropInZoneEvent += OnItemDroppedInZone;
 }
コード例 #3
0
        public ProjectExplorerWindow()
        {
            ApplicationConfig applicationConfig = new ApplicationConfig();

            applicationConfig.ConfigureApplication(this);
            this.commandExecutor = applicationConfig.GetInstance <CommandExecutor>();
            this.dragDropHandler = applicationConfig.GetInstance <DragDropHandler>();
            this.bootstrap       = applicationConfig.GetInstance <Bootstrap>();
            this.DataContext     = applicationConfig.GetInstance <MainViewModel>();
            InitializeComponent();
        }
コード例 #4
0
 public void RegisterDragDrop()
 {
     DragDropHandler.RegisterControl(labelControl, false, true);
     DragDropHandler.RegisterControl(frameControl, false, true);
     DragDropHandler.RegisterControl(textBoxControl, false, true);
     DragDropHandler.RegisterControl(buttonControl, false, true);
     DragDropHandler.RegisterControl(treeControl, false, true);
     DragDropHandler.RegisterControl(multiTabControl, false, true);
     DragDropHandler.RegisterControl(tableControl, false, true);
     DragDropHandler.RegisterControl(connectorControl, false, true);
 }
コード例 #5
0
        public TPFTools()
        {
            InitializeComponent();

            // Setup drag/drop handling
            var dropAction = new Action<TPFTexInfo, string[]>(async (tex, droppedFiles) => await Task.Run(() => vm.LoadFiles(droppedFiles))); // Don't need the TPFTexInfo - it'll be null anyway.
            Predicate<string[]> dropValidator = new Predicate<string[]>(files => files.All(file => TPFToolsViewModel.AcceptedExtensions.Contains(Path.GetExtension(file).ToLowerInvariant())));
            Func<TPFTexInfo, Dictionary<string, Func<byte[]>>> dataGetter = tex => new Dictionary<string, Func<byte[]>> { { tex.DefaultSaveName, () => tex.Extract() } };

            DropHelper = new DragDropHandler<TPFTexInfo>(this, dropAction, dropValidator, dataGetter);

            vm = new TPFToolsViewModel();
            DataContext = vm;
        }
    void OnDisable()
    {
        if (instance == this)
        {
            // set window message handler back to old handler
            SetWindowLongPtr(hMainWindow, -4, oldWndProcPtr);
            // release pointers
            hMainWindow   = IntPtr.Zero;
            oldWndProcPtr = IntPtr.Zero;
            newWndProcPtr = IntPtr.Zero;
            newWndProc    = null;

            instance = null;
        }
    }
コード例 #7
0
        private void Control_Drop(object sender, DragEventArgs e)
        {
            if (DragDropHandler == null || _currentDropLocation == null ||
                !e.TryGetDataContext <TDrop>(out var targetDataContext) ||
                !e.TryGetDragDropDataContext <TDrag>(DragDropFormat, out var sourceDataContext))
            {
                return;
            }

            e.Handled = true;

            DragDropHandler.Drop(sourceDataContext, targetDataContext, _currentDropLocation.Value);

            _currentDropLocation = null;
        }
コード例 #8
0
ファイル: DragDropHandler.cs プロジェクト: khiemnd777/Bang
    public void OnBeginDrag(PointerEventData eventData)
    {
        var position = eventData.position;

        canvas            = GetComponentInParent <Canvas>();
        startPosition     = transform.position;
        startDragTime     = Time.time;
        dragJourneyLength = Vector3.Distance(Vector3.one, Vector3.zero);

        if (useIcon)
        {
            if (icon.enabled)
            {
                if (draggableIcon != null)
                {
                    Destroy(draggableIcon.gameObject);
                }
                originalIconScale    = icon.transform.localScale;
                draggableIcon        = Instantiate <Image>(icon, position, Quaternion.identity);
                draggableIcon.sprite = icon.sprite;
                draggableIcon.transform.localScale = icon.transform.localScale;
                draggableIcon.transform.SetParent(canvas.transform, false);
            }
        }
        else
        {
            if (draggableObject != null)
            {
                Destroy(draggableObject.gameObject);
            }
            orginalSiblingIndex = transform.GetSiblingIndex();
            draggableObject     = Instantiate <DragDropHandler>(this, position, Quaternion.identity);
            draggableObject.transform.localScale = Vector3.one;
            draggableObject.transform.SetParent(canvas.transform, false);
        }

        isDrag    = true;
        isEndDrag = false;

        StartCoroutine(OnBeginDragging());

        if (onBeginDragEvent != null)
        {
            onBeginDragEvent.Invoke(eventData);
        }
    }
コード例 #9
0
        public void HandleDragOver_TreeNodeDraggedToDroppableNode_DragDropEffectSetForEvent(bool canDrop, DragDropEffects dropEffect)
        {
            // Setup
            const int targetHeight = 30;

            var draggingNode = new TreeNode("DraggingNode");

            var mocks = new MockRepository();

            var data = mocks.Stub <IDataObject>();

            data.Expect(d => d.GetData(d.GetType())).IgnoreArguments().Return(draggingNode);

            var treeNode = mocks.Stub <TreeNode>();

            treeNode.Stub(tn => tn.Parent).Return(null);
            treeNode.Stub(tn => tn.Bounds).Return(new Rectangle(0, 0, 50, targetHeight));

            var nodePoint = new Point(0, 10);
            var graphics  = mocks.Stub <Graphics>();

            var treeView = mocks.Stub <WinFormsTreeView>();

            treeView.Stub(tv => tv.PointToClient(Point.Empty)).IgnoreArguments().Return(nodePoint);
            treeView.Stub(tv => tv.GetNodeAt(nodePoint)).Return(treeNode);
            treeView.Stub(tv => tv.CreateGraphics()).Return(graphics);
            mocks.ReplayAll();

            var ddh = new DragDropHandler();

            var dragEvent = new DragEventArgs(data, 0, 10, 15, DragDropEffects.All, DragDropEffects.None);
            Func <object, TreeNodeInfo> action = o => new TreeNodeInfo
            {
                CanDrop = (oo, op) => canDrop
            };

            // Call
            ddh.HandleDragOver(treeView, dragEvent, action);

            // Assert
            Assert.AreEqual(dragEvent.Effect, dropEffect);
            mocks.VerifyAll();
        }
コード例 #10
0
 public void RegisterDragDrop()
 {
     DragDropHandler.RegisterControl(labelControl, false, true);
     DragDropHandler.RegisterControl(frameControl, false, true);
     DragDropHandler.RegisterControl(jasperControl, false, true);
     DragDropHandler.RegisterControl(textBoxControl, false, true);
     DragDropHandler.RegisterControl(buttonControl, false, true);
     DragDropHandler.RegisterControl(browseControl, false, true);
     DragDropHandler.RegisterControl(datePickerControl, false, true);
     DragDropHandler.RegisterControl(treeControl, false, true);
     DragDropHandler.RegisterControl(treeNodeControl, false, true);
     DragDropHandler.RegisterControl(multiTabControl, false, true);
     DragDropHandler.RegisterControl(tabPageControl, false, true);
     DragDropHandler.RegisterControl(tableControl, false, true);
     DragDropHandler.RegisterControl(connectorControl, false, true);
     DragDropHandler.RegisterControl(pictureControl, false, true);
     DragDropHandler.RegisterControl(checkboxControl, false, true);
     DragDropHandler.RegisterControl(radioControl, false, true);
     DragDropHandler.RegisterControl(comboControl, false, true);
     //DragDropHandler.RegisterControl(menuBarControl, false, true);
     DragDropHandler.RegisterControl(menuControl, false, true);
     DragDropHandler.RegisterControl(menuItemControl, false, true);
     DragDropHandler.RegisterControl(relationControl, false, true);
     DragDropHandler.RegisterControl(nodeControl, false, true);
     DragDropHandler.RegisterControl(nodeConnectorControl, false, true);
     // DragDropHandler.RegisterControl(searchControl, false, true);
     DragDropHandler.RegisterControl(listControl, false, true);
     DragDropHandler.RegisterControl(gridControl, false, true);
     DragDropHandler.RegisterControl(scrollablerowControl, false, true);
     DragDropHandler.RegisterControl(columnControl, false, true);
     DragDropHandler.RegisterControl(radioGroupControl, false, true);
     DragDropHandler.RegisterControl(PlaceHolderControl, false, true);
     DragDropHandler.RegisterControl(timeControl, false, true);
     DragDropHandler.RegisterControl(pagingControl, false, true);
     DragDropHandler.RegisterControl(vMenuBarControl, false, true);
     DragDropHandler.RegisterControl(calenderControl, false, true);
     DragDropHandler.RegisterControl(imageBrowseControl, false, true);
     DragDropHandler.RegisterControl(schedularControl, false, true);
     DragDropHandler.RegisterControl(appletControl, false, true);
     DragDropHandler.RegisterControl(latticeControl, false, true);
 }
コード例 #11
0
        private void Control_DragOver(object sender, DragEventArgs e)
        {
            if (DragDropHandler == null || !e.TryGetDataContext <TDrop>(out var targetDataContext) ||
                !e.TryGetDragDropDataContext <TDrag>(DragDropFormat, out var sourceDataContext))
            {
                return;
            }

            e.Handled = true;

            UpdateDropLocation(e);

            if (_currentDropLocation != null && DragDropHandler.CanDrop(sourceDataContext, targetDataContext, _currentDropLocation.Value))
            {
                e.Effects = DragDropEffects.Move | DragDropEffects.Copy;
            }
            else
            {
                e.Effects = DragDropEffects.None;
            }
        }
コード例 #12
0
        public void HandleItemDrag_WithItemInTree_SelectsItem()
        {
            // Setup
            using (var treeView = new WinFormsTreeView())
            {
                var treeNode = new TreeNode();

                treeView.Nodes.Add(treeNode);
                treeView.SelectedNode = null;

                var ddh = new DragDropHandler();

                var dragEvent = new ItemDragEventArgs(MouseButtons.Left, treeNode);
                Func <object, TreeNodeInfo> action = o => new TreeNodeInfo();

                // Call
                ddh.HandleItemDrag(treeView, dragEvent, action);

                // Assert
                Assert.AreSame(treeNode, treeView.SelectedNode);
            }
        }
コード例 #13
0
    System.Collections.IEnumerator enable_drag_drop()
    {
        yield return(new WaitForSeconds(2));

        bool bEnableDragDrop = (FPlatform.InUnityEditor() == false && FPlatform.GetDeviceType() == FPlatform.fDeviceType.WindowsDesktop);

        bEnableDragDrop = true;
        if (bEnableDragDrop)
        {
            Context.RegisterNextFrameAction(() => {
                if (FPlatform.InUnityEditor())
                {
                    DragDropHandler.Initialize();
                }
                else
                {
                    DragDropHandler.Initialize(WinAPI.GetCurrentThreadId(), "UnityWndClass");   // is this necessary?
                }
                DragDropHandler.OnDroppedFilesEvent += CCActions.DoDragDropImport;
            });
        }
    }
コード例 #14
0
        public override void Initialize(System.ComponentModel.IComponent component)
        {
            base.Initialize(component);

            // #297589. Do not show the grids on table control.
            BindingFlags bindingAttrs = BindingFlags.Instance | BindingFlags.NonPublic;
            Type         classType    = typeof(ParentControlDesigner);

            MemberInfo[] memberinfos = classType.GetMember("DrawGrid", bindingAttrs);
            PropertyInfo propInfo    = memberinfos[0] as PropertyInfo;

            propInfo.SetValue(this, false, null);

            // Record instance of control we're designing
            tableControl = (TableControl)component;

            // Hook up events
            //ISelectionService s = (ISelectionService)GetService(typeof(ISelectionService));
            IComponentChangeService c = (IComponentChangeService)GetService(typeof(IComponentChangeService));

            canParentProvider = new CanParentProvider(this);

            dragDropHandler = new TableControlDragDropHandler((Control)component, this.BehaviorService, (IDesignerHost)this.GetService(typeof(IDesignerHost)));
        }
コード例 #15
0
ファイル: DragDropHandler.cs プロジェクト: khiemnd777/Bang
    IEnumerator OnSlotMatch(DragDropHandler matchItem, Image currentIcon)
    {
        var fracJourney = 0f;

        while (fracJourney < 1f)
        {
            var distCovered = (Time.time - startEndDragTime) * 5f;
            fracJourney = distCovered / endDragJourneyLength;
            if (useIcon)
            {
                if (currentIcon.enabled)
                {
                    currentIcon.transform.localScale = Vector3.Lerp(Vector3.zero, originalIconScale, fracJourney);
                }
                matchItem.icon.transform.localScale = Vector3.Lerp(Vector3.zero, originalIconScale, fracJourney);
            }
            else
            {
                transform.localScale = Vector3.Lerp(Vector3.one * 0.975f, Vector3.one, fracJourney);
            }

            yield return(null);
        }
    }
コード例 #16
0
ファイル: FormDesigner.cs プロジェクト: harpreetoxyent/pnl
        public BaseWindow initBaseWindow(string typeOfWindow, string windowName, bool isWindowSaved)
        {
            try
            {
                if (typeOfWindow == FormDesignerConstants.FormPattern)
                {
                    //Check for new Window
                    if (windowName == null)
                    {
                        windowName        = "";
                        currentBaseWindow = new BaseWindow(typeOfWindow, windowName, isWindowSaved);

                        windowName = currentBaseWindow.baseFrame.ControlName;
                        listFormBaseWindow.Add(currentBaseWindow.baseFrame.ControlName, currentBaseWindow);
                        listBaseWindow.Add(currentBaseWindow);
                        DragDropHandler.RegisterControl(currentBaseWindow.baseFrame, true, true);
                    }
                    //Check if we already create this object so no need to create new one
                    else if (!listFormBaseWindow.ContainsKey(windowName))
                    {
                        //currentBaseWindow.baseFrame.DataBindings.Add("ControlName",FormDesignerUtilities.dataSetList["datapattern0"]);
                        currentBaseWindow = new BaseWindow(typeOfWindow, windowName, isWindowSaved);
                        listFormBaseWindow.Add(currentBaseWindow.baseFrame.ControlName, currentBaseWindow);
                        listBaseWindow.Add(currentBaseWindow);
                        DragDropHandler.RegisterControl(currentBaseWindow.baseFrame, true, true);
                    }
                    else
                    {
                        currentBaseWindow = listFormBaseWindow[windowName];
                    }
                }
                if (typeOfWindow == FormDesignerConstants.DataPattern)
                {
                    if (windowName == null)
                    {
                        windowName = "";
                    }

                    if (!listDataBaseWindow.ContainsKey(windowName))
                    {
                        currentBaseWindow = new BaseWindow(typeOfWindow, windowName, isWindowSaved);
                        listDataBaseWindow.Add(currentBaseWindow.baseFrame.ControlName, currentBaseWindow);
                        listBaseWindow.Add(currentBaseWindow);
                        DragDropHandler.RegisterControl(currentBaseWindow.baseFrame, true, true);
                    }
                    else
                    {
                        currentBaseWindow = listDataBaseWindow[windowName];
                    }
                }
                if (typeOfWindow == FormDesignerConstants.WorkflowPattern)
                {
                    if (windowName == null)
                    {
                        windowName = "";
                    }
                    if (!listWorkBaseWindow.ContainsKey(windowName))
                    {
                        currentBaseWindow = new BaseWindow(typeOfWindow, windowName, isWindowSaved);
                        listWorkBaseWindow.Add(currentBaseWindow.baseFrame.ControlName, currentBaseWindow);
                        listBaseWindow.Add(currentBaseWindow);
                        DragDropHandler.RegisterControl(currentBaseWindow.baseFrame, true, true);
                    }
                    else
                    {
                        currentBaseWindow = listWorkBaseWindow[windowName];
                    }
                }

                currentBaseWindow.TypeOfWindow  = typeOfWindow;
                formulaEditor.CurrentBaseWindow = currentBaseWindow;
                currentBaseWindow.Click        += new EventHandler(currentBaseWindow_Click);
                currentBaseWindow.KeyPreview    = true;
                if (!currentBaseWindow.isKeyDown)
                {
                    currentBaseWindow.KeyDown  += new KeyEventHandler(eventManager.HandleCtrlDown);
                    currentBaseWindow.KeyUp    += new KeyEventHandler(eventManager.HandleCtrlUp);
                    currentBaseWindow.KeyPress += new KeyPressEventHandler(eventManager.HandleKeyPress);
                    currentBaseWindow.isKeyDown = true;
                }
                /*Register it only for one time*/
                //DragDropHandler.RegisterControl(currentBaseWindow.baseFrame, true, true);
                //baseWindowDefaultToolClick(null, null);
                currentBaseWindow.MouseClick += new MouseEventHandler(eventManager.handleControlClick);
                if (!currentBaseWindow.baseFrame.isMouseClick)
                {
                    currentBaseWindow.baseFrame.MouseClick  += new MouseEventHandler(eventManager.handleControlClick);
                    currentBaseWindow.baseFrame.isMouseClick = true;
                }
                //currentBaseWindow.SizeChanged += new EventHandler(currentBaseWindow_SizeChanged);
                currentBaseWindow.baseFrame.Scroll        += new ScrollEventHandler(baseFrame_Scroll);
                currentBaseWindow.baseFrame.MouseWheel    += new MouseEventHandler(baseFrame_MouseWheel);
                UIEventManager.form.currentBaseWindow      = currentBaseWindow;
                FormulaEditorWindow.form.currentBaseWindow = currentBaseWindow;
                //Added by HKU to set the first form pattern as default screen
                if (currentBaseWindow.TypeOfWindow == FormDesignerConstants.FormPattern)
                {
                    if (currentBaseWindow != null)
                    {
                        if (listFormBaseWindow.Count == 1 && FormDesignerUtilities.visibleTrueWindow.Count < 1)
                        {
                            currentBaseWindow.baseFrame.DefaultScreen = true;
                        }
                    }
                }
                //Adding by HKU done
                return(currentBaseWindow);
            }
            catch
            {
                return(null);
            }
        }
コード例 #17
0
 public virtual void DragLeave(EventArgs e)
 {
     DragDropHandler.DragLeave(e);
     // sometimes DragLeave is called before Drop
     DragLeft = true;
 }
コード例 #18
0
        public Texplorer()
        {
            InitializeComponent();
            vm = new TexplorerViewModel();

            TaskBarUpdater = new Action<System.Windows.Shell.TaskbarItemProgressState>(state => TaskBarProgressMeter.Dispatcher.Invoke(new Action(() => TaskBarProgressMeter.ProgressState = state)));

            vm.PropertyChanged += (sender, args) =>
            {
                // Change toolbar progress state when required.
                if (args.PropertyName == nameof(vm.Progress))
                    TaskBarUpdater(vm.Progress == 0 || vm.Progress == vm.MaxProgress ? System.Windows.Shell.TaskbarItemProgressState.None : System.Windows.Shell.TaskbarItemProgressState.Normal);
                else if (args.PropertyName == nameof(vm.ProgressIndeterminate))
                    TaskBarUpdater(vm.ProgressIndeterminate ? System.Windows.Shell.TaskbarItemProgressState.Indeterminate : TaskBarProgressMeter.ProgressState);
            };

            vm.ProgressCloser = new Action(() =>
            {
                HiderButton.Dispatcher.Invoke(() =>   // Not sure if this is necessary, but things aren't working otherwise.
                {
                    Storyboard closer = (Storyboard)HiderButton.Resources["ProgressPanelCloser"];
                    closer.Begin();
                });
            });

            vm.ProgressOpener = new Action(() =>
            {
                TreeScanBackground.Dispatcher.Invoke(() =>   // Not sure if this is necessary, but things aren't working otherwise.
                {
                    Storyboard closer = (Storyboard)TreeScanBackground.Resources["ProgressPanelOpener"];
                    closer.Begin();
                });
            });

            vm.TreePanelCloser = new Action(() =>
            {
                Storyboard closer = (Storyboard)TreeScanBackground.Resources["TreeScanClosePanelAnimation"];
                closer.Begin();
            });

            vm.TreePanelOpener = new Action(() =>
            {
                Storyboard opener = (Storyboard)SettingsButton.Resources["TreeScanPanelOpener"];
                opener.Begin();
            });

            DataContext = vm;
            GetBackgroundMovie();
            BackgroundMovie.Play();


            Action<TreeTexInfo, string[]> textureDropper = new Action<TreeTexInfo, string[]>((tex, files) => Task.Run(() => vm.ChangeTexture(tex, files[0]))); // Can only be one due to validation in DragOver

            var FolderDataGetter = new Func<TexplorerTextureFolder, Dictionary<string, Func<byte[]>>>(context =>
            {
                var SaveInformation = new Dictionary<string, Func<byte[]>>();
                for (int i = 0; i < context.TexturesInclSubs.Count; i++)
                {
                    var tex = context.TexturesInclSubs[i];
                    Func<byte[]> data = () =>  ToolsetTextureEngine.ExtractTexture(tex);
                    SaveInformation.Add(tex.DefaultSaveName, data);
                }
                return SaveInformation;
            });

            var TextureDataGetter = new Func<TreeTexInfo, Dictionary<string, Func<byte[]>>>(context => new Dictionary<string, Func<byte[]>> { { context.DefaultSaveName,
                    () =>
                    {
                        // KFreon: Any conversion?
                        
                        return ToolsetTextureEngine.ExtractTexture(context);
                    }
                } });

            Predicate<string[]> DropValidator = new Predicate<string[]>(files => files.Length == 1 && !files.Any(file => ImageFormats.ParseExtension(Path.GetExtension(file)) == ImageFormats.SupportedExtensions.UNKNOWN));

            TextureDragDropper = new DragDropHandler<TreeTexInfo>(this, textureDropper, DropValidator, TextureDataGetter);
            FolderDragDropper = new DragDropHandler<TexplorerTextureFolder>(this, null, null, FolderDataGetter);  // DropAction and Validator not required as TreeView not droppable.



            // As VM should be created before this constructor is called, can do this check now.
            if (vm.CurrentTree.Valid)
                vm.TreePanelCloser();
        }
コード例 #19
0
ファイル: EnemyFieldSlot.cs プロジェクト: khiemnd777/Bang
 void Start()
 {
     dragDropHandler            = GetComponent <DragDropHandler>();
     dragDropHandler.onDragged += OnUpdateSlot;
 }
コード例 #20
0
 void Start()
 {
     handler                 = GetComponent <DragDropHandler>();
     handler.onDragEvent    += OnDrag;
     handler.onEndDragEvent += OnEndDrag;
 }
コード例 #21
0
        public virtual void SetDragTarget()
        {
            var targets = DragDropViz.DataManager.DataTypes.ToArray();

            DragDropHandler.SetDragTarget(DragDropAction.All, targets);
        }
コード例 #22
0
 void initializeDragDropHandler()
 {
     dragDropHandler = new DragDropHandler(this.TextArea);
 }
コード例 #23
0
ファイル: TacticItem.cs プロジェクト: khiemnd777/Bang
 void Start()
 {
     dragDropHandler            = GetComponent <DragDropHandler>();
     dragDropHandler.onDragged += OnItemDragged;
 }
コード例 #24
0
ファイル: EpiPlanViewModel.cs プロジェクト: nnqdev2/TestRepo
 public EpiPlanViewModel()
 {
     dropHandler = new DragDropHandler();
     DropHandler.AddHandler(typeof(ScheduleTasksPresenter), typeof(BookedOrder), AddOrder);
 }
コード例 #25
0
 public virtual void OnDrop(DragEventArgs e)
 {
     DragDropHandler.OnDrop(e);
     Dropping = false;
     InprocDragDrop.Dropping = false;
 }
コード例 #26
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public SetLocTargetDragDropHandler(VCItemContainer container, DragDropHandler next)
     : base(container, next)
 {
 }
コード例 #27
0
ファイル: ToolBox.cs プロジェクト: harpreetoxyent/pnl
        public static object CreateControl(string ctrlName, string partialName)
        {
            try
            {
                Control ctrl = null;
                //ToolStripMenuItem menu;
                //ToolStripButton menuItem;
                switch (ctrlName)
                {
                case "EIBButton":
                    ctrl = new EIBButton();
                    break;

                case "EIBApplet":
                    ctrl = new EIBApplet();
                    break;

                case "EIBLattice":
                    ctrl = new EIBLattice();
                    break;

                case "EIBSchedular":
                    ctrl = new EIBSchedular();
                    break;

                case "EIBDatePicker":
                    ctrl = new EIBDatePicker();
                    break;

                case "EIBTime":
                    ctrl = new EIBTime();
                    break;

                case "EIBCheckbox":
                    ctrl = new EIBCheckbox();
                    break;

                case "EIBCombobox":
                    ctrl = new EIBCombobox();
                    break;

                case "EIBLabel":
                    ctrl = new EIBLabel();
                    break;

                case "EIBLine":
                    ctrl = new EIBLine();
                    break;

                case "EIBPanel":
                    ctrl = new EIBPanel();
                    DragDropHandler.RegisterControl(ctrl, true, true);
                    break;

                case "EIBJasper":
                    ctrl = new EIBJasper();
                    break;

                case "EIBRadioGroup":
                    ctrl = new EIBRadioGroup();
                    DragDropHandler.RegisterControl(ctrl, true, true);
                    break;

                case "EIBPicture":
                    ctrl = new EIBPicture();
                    break;

                case "EIBRadioButton":
                    ctrl = new EIBRadioButton();
                    break;

                case "EIBTabControl":
                    ctrl = new EIBTabControl();
                    DragDropHandler.RegisterControl(ctrl, true, true);
                    break;

                case "EIBTabPage":
                    ctrl = new EIBTabPage();
                    DragDropHandler.RegisterControl(ctrl, true, true);
                    break;

                case "EIBSearch":
                    ctrl = new EIBSearch();
                    break;

                case "EIBListbox":
                    ctrl = new EIBListbox();
                    break;

                case "EIBGrid":
                    ctrl = new EIBGrid();
                    DragDropHandler.RegisterControl(ctrl, true, true);
                    break;

                case "EIBTable":
                    ctrl = new EIBTable();
                    break;

                case "EIBRelation":
                    ctrl = new EIBRelation();
                    break;

                case "EIBTextBox":
                    ctrl = new EIBTextBox();
                    break;

                case "EIBTreeView":
                    ctrl = new EIBTreeView();
                    break;

                case "EIBMenuBar":
                    ctrl = new EIBMenuBar(false);
                    DragDropHandler.RegisterControl(ctrl, true, true);
                    break;

                case "EIBNode":
                    ctrl = new EIBNode();
                    break;

                case "EIBNodeRelation":
                    ctrl = new EIBNodeRelation();
                    break;

                case "EIBColumn":
                    ctrl = new EIBColumn();
                    DragDropHandler.RegisterControl(ctrl, true, true);
                    break;

                case "EIBScrollableRow":
                    ctrl = new EIBScrollableRow();
                    DragDropHandler.RegisterControl(ctrl, true, true);
                    break;

                case "EIBBrowse":
                    ctrl = new EIBBrowse();
                    break;

                case "EIBVMenuBar":
                    ctrl = new EIBVMenuBar(false);
                    DragDropHandler.RegisterControl(ctrl, true, true);
                    break;

                case "EIBMenu":
                    return(new EIBMenu());

                case "EIBMenuItem":
                    return(new EIBMenuItem());

                /*
                 *                  case "EIBTreeNode":
                 *                      ctrl = new EIBTreeNode();
                 *                      break;
                 */
                default:
                    Assembly controlAsm  = Assembly.LoadWithPartialName(partialName);
                    Type     controlType = controlAsm.GetType(partialName + "." + ctrlName);
                    ctrl = (Control)Activator.CreateInstance(controlType);
                    break;
                }

                return(ctrl);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine("create control failed:" + ex.Message);
                return(new Control());
            }
        }
コード例 #28
0
ファイル: DragDropHandler.cs プロジェクト: khiemnd777/Bang
    public void OnEndDrag(PointerEventData eventData)
    {
        if (onEndDragEvent != null)
        {
            onEndDragEvent.Invoke(eventData);
        }
        if (!arrangeable)
        {
            return;
        }
        var position = eventData.position;

        isDrag            = false;
        isEndDrag         = true;
        dragJourneyLength = 0f;

        startEndDragTime     = Time.time;
        endDragJourneyLength = Vector3.Distance(Vector3.one * 1.5f, Vector3.one);

        if (useIcon)
        {
            if (draggableIcon != null)
            {
                lastDraggableIconPosition = draggableIcon.transform.position;
                DragDropHandler matchItem     = null;
                var             isAlternative = false;
                var             matchIndex    = 0;
                var             index         = 0;
                foreach (var item in items)
                {
                    if (RectTransformUtility.RectangleContainsScreenPoint(item.GetComponent <RectTransform>(), position))
                    {
                        if (item != this)
                        {
                            if (item.icon.enabled)
                            {
                                var itemIconSprite = item.icon.sprite;
                                item.icon.sprite = icon.sprite;

                                icon.sprite   = itemIconSprite;
                                icon.enabled  = true;
                                isAlternative = true;
                            }
                            else
                            {
                                item.icon.sprite = icon.sprite;
                                icon.enabled     = false;
                            }
                            item.icon.enabled = true;
                            matchItem         = item;
                            matchIndex        = index;
                        }
                    }
                    ++index;
                    item.transform.localScale         = Vector3.one;
                    item.GetComponent <Image>().color = originalColor;
                }
                if (matchItem != null)
                {
                    Destroy(draggableIcon.gameObject);
                    StartCoroutine(OnSlotMatch(matchItem, icon));
                    if (matchItem.onDragged != null)
                    {
                        matchItem.onDragged.Invoke(this.gameObject, matchIndex, isAlternative);
                    }
                }
                else
                {
                    StartCoroutine(OnSlotMiss());
                }
            }
        }
        else
        {
            if (draggableObject != null)
            {
                lastDraggableObjectPosition = draggableObject.transform.position;
                if (orginalSiblingIndex != transform.GetSiblingIndex())
                {
                    Destroy(draggableObject.gameObject);
                    StartCoroutine(OnSlotMatch(this, null));
                    if (onDragged != null)
                    {
                        onDragged.Invoke(gameObject, orginalSiblingIndex, false);
                    }
                }
                else
                {
                    StartCoroutine(OnSlotMiss());
                }
            }
        }
    }