Esempio n. 1
0
        private DragHandle BeginDragHandle(ListDrawerConfigInfo info, int j, int i)
        {
            var child      = info.property.Children[j];
            var dragHandle = DragAndDropManager.BeginDragHandle(child, (TElement)child.ValueEntry.WeakSmartValue, info.IsReadOnly ? DragAndDropMethods.Reference : DragAndDropMethods.Move);

            dragHandle.Enabled = info.Draggable;

            if (dragHandle.OnDragStarted)
            {
                ListDrawerStaticInfo.CurrentDraggingPropertyInfo = info.property.Children[j];
                dragHandle.OnDragFinnished = dropEvent =>
                {
                    if (dropEvent == DropEvents.Moved)
                    {
                        // If it's a cross-window drag, the changes will for some reason be lost if we don't do this.
                        if (dragHandle.IsCrossWindowDrag)
                        {
                            GUIHelper.RequestRepaint();
                            EditorApplication.delayCall += () =>
                            {
                                info.ListValueChanger.RemoveListElementAt(j, CHANGE_ID);
                            };
                        }
                        else
                        {
                            info.ListValueChanger.RemoveListElementAt(j, CHANGE_ID);
                        }
                    }

                    ListDrawerStaticInfo.CurrentDraggingPropertyInfo = null;
                };
            }

            return(dragHandle);
        }
Esempio n. 2
0
        /// <summary> Creates a new root from the given <paramref name="guiSheet"/> and dependencies. </summary>
        /// <param name="guiSheet"> The XML layout document. </param>
        /// <param name="styleManager"> The styles. </param>
        /// <param name="templateManager"> The templates. </param>
        /// <param name="inputManager"> The object for handling user input. </param>
        /// <param name="dragAndDropManager"> The drag and drop manager. </param>
        /// <param name="elementManager"> The elements. </param>
        /// <param name="gameWindow"> The MonoGame <see cref="GameWindow"/>. </param>
        internal void InternalInitialise(XmlDocument guiSheet, StyleManager styleManager, TemplateManager templateManager, InputManager inputManager, DragAndDropManager dragAndDropManager, ElementManager elementManager, GameWindow gameWindow)
        {
            // Bind the window changing size.
            gameWindow.ClientSizeChanged += screenResized;

            // Set dependencies.
            InputManager       = inputManager;
            DragAndDropManager = dragAndDropManager;
            StyleManager       = styleManager;
            ElementManager     = elementManager;
            TemplateManager    = templateManager;

            // Call the created function.
            OnCreated();

            // Select the main node, if it does not exist, throw an exception.
            XmlNode mainNode = guiSheet.SelectSingleNode(mainNodeName) ?? throw new Exception($"Gui sheet's main node must be named {mainNodeName}.");

            // Set the attributes to the attributes loaded from the main node.
            Attributes = new AttributeCollection(mainNode);

            // Initialise the bounds to the size of the window and the parsed padding.
            Bounds = new Bounds(elementManager.ElementContainer, gameWindow.ClientBounds.Size, Attributes);

            // Load the built-in templates.
            templateManager.LoadDefault();

            // Load the UI's linked sheets.
            loadStyleSheets(styleManager, mainNode);
            loadTemplateSheets(templateManager, mainNode);

            // Set the default style.
            styleManager.LoadDefaultStyle(mainNode);

            // Pre-initialise first.
            PreInitialise();

            // Load the UI.
            elementManager.LoadFromNode(mainNode);

            // Initialise.
            Initialise();

            // Call the setup function on all root-level elements, cascading up, then do the same with the post setup function.
            foreach (Element child in elementManager)
            {
                child.internalOnFullSetup();
            }
            foreach (Element child in elementManager)
            {
                child.internalOnPostFullSetup();
            }
            HasSetUp = true;

            // Call the PostInitialise function.
            PostInitialise();
        }
        public MainPage()
        {
            InitializeComponent();

            gridControl1.ItemsSource = DemoUtils.GenerateScheduleTasks();

            DragAndDropManager.RegisterHandler(schedulerControl1, this);
            DragAndDropManager.RegisterHandler(gridControl1, this);
        }
Esempio n. 4
0
        private void panelDragFile_DragDrop(object sender, DragEventArgs e)
        {
            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
            string   file1 = files.FirstOrDefault();

            if (DragAndDropManager.IsFilenameAudio(file1))
            {
                SetFilename(file1);
            }
            panelDragFile.BackColor = Color.LightGray;
        }
Esempio n. 5
0
        private void EndDropZone()
        {
            if (info.OrderedCollectionResolver == null)
            {
                return;
            }

            if (info.DropZone.IsReadyToClaim)
            {
                CollectionDrawerStaticInfo.CurrentDraggingPropertyInfo = null;
                CollectionDrawerStaticInfo.CurrentDroppingPropertyInfo = info.Property;
                object droppedObject = info.DropZone.ClaimObject();

                object[] values = new object[info.Property.Tree.WeakTargets.Count];

                for (int i = 0; i < values.Length; i++)
                {
                    values[i] = droppedObject;
                }

                if (info.DropZone.IsCrossWindowDrag)
                {
                    // If it's a cross-window drag, the changes will for some reason be lost if we don't do this.
                    GUIHelper.RequestRepaint();
                    EditorApplication.delayCall += () =>
                    {
                        info.OrderedCollectionResolver.QueueInsertAt(Mathf.Clamp(info.InsertAt, 0, info.Property.Children.Count), values);
                    };
                }
                else
                {
                    info.OrderedCollectionResolver.QueueInsertAt(Mathf.Clamp(info.InsertAt, 0, info.Property.Children.Count), values);
                }
            }
            else
            {
                UnityEngine.Object[] droppedObjects = HandleUnityObjectsDrop(info);
                if (droppedObjects != null)
                {
                    foreach (var obj in droppedObjects)
                    {
                        object[] values = new object[info.Property.Tree.WeakTargets.Count];

                        for (int i = 0; i < values.Length; i++)
                        {
                            values[i] = obj;
                        }

                        info.OrderedCollectionResolver.QueueInsertAt(Mathf.Clamp(info.InsertAt, 0, info.Property.Children.Count), values);
                    }
                }
            }
            DragAndDropManager.EndDropZone();
        }
Esempio n. 6
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this.gameObject);
         Debug.LogError("Too many Drag and Drop Manager");
     }
 }
Esempio n. 7
0
 private void panelDragFile_DragEnter(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(DataFormats.FileDrop))
     {
         string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
         string   file1 = files.FirstOrDefault();
         if (DragAndDropManager.IsFilenameAudio(file1))
         {
             e.Effect = DragDropEffects.Copy;
             panelDragFile.BackColor = Color.Azure;
         }
     }
 }
 protected override void Awake()
 {
     base.Awake();
     table             = FindObjectOfType <Table>();
     handPlane         = FindObjectOfType <HandPlane>();
     root              = transform.parent.GetComponent <Transform>();
     rend              = GetComponent <Renderer>();
     dndm              = FindObjectOfType <DragAndDropManager>();
     animScr           = GetComponent <BaseObjectAnimation>();
     apprn             = GetComponent <BaseObjectAppearance>();
     handPlaneCollider = GameObject.Find("HandPlane").GetComponent <Collider>();
     coll              = GetComponent <Collider>();
 }
Esempio n. 9
0
        private DropZoneHandle BeginDropZone(ListDrawerConfigInfo info)
        {
            var dropZone = DragAndDropManager.BeginDropZone(info.property.Tree.GetHashCode() + "-" + info.property.Path, typeof(TElement), true);

            if (Event.current.type == EventType.Repaint && DragAndDropManager.IsDragInProgress)
            {
                var rect = dropZone.Rect;
                dropZone.Rect = rect;
            }

            dropZone.Enabled = info.IsReadOnly == false;
            info.DropZone    = dropZone;
            return(dropZone);
        }
Esempio n. 10
0
        private DropZoneHandle BeginDropZone(ListDrawerConfigInfo info)
        {
            var dropZone = DragAndDropManager.BeginDropZone(UniqueDrawerKey.Create(info.property, this), typeof(TElement), true);

            if (Event.current.type == EventType.Repaint && DragAndDropManager.IsDragInProgress)
            {
                var rect = dropZone.Rect;
                dropZone.Rect = rect;
            }

            dropZone.Enabled = info.IsReadOnly == false;
            info.DropZone    = dropZone;
            return(dropZone);
        }
Esempio n. 11
0
        private void EndDragHandle(int i)
        {
            var handle = DragAndDropManager.EndDragHandle();

            if (handle.IsDragging)
            {
                info.Property.Tree.DelayAction(() =>
                {
                    if (DragAndDropManager.CurrentDraggingHandle != null)
                    {
                        CollectionDrawerStaticInfo.DelayedGUIDrawer.Draw(Event.current.mousePosition - DragAndDropManager.CurrentDraggingHandle.MouseDownPostionOffset);
                    }
                });
            }
        }
Esempio n. 12
0
        private void EndDropZone(ListDrawerConfigInfo info)
        {
            if (info.DropZone.IsReadyToClaim)
            {
                ListDrawerStaticInfo.CurrentDraggingPropertyInfo = null;
                object droppedObject = info.DropZone.ClaimObject();

                object[] values = new object[info.ListValueChanger.ValueCount];

                for (int i = 0; i < values.Length; i++)
                {
                    values[i] = droppedObject;
                }

                if (info.DropZone.IsCrossWindowDrag)
                {
                    // If it's a cross-window drag, the changes will for some reason be lost if we don't do this.
                    GUIHelper.RequestRepaint();
                    EditorApplication.delayCall += () =>
                    {
                        info.ListValueChanger.InsertListElementAt(Mathf.Clamp(info.InsertAt, 0, info.property.Children.Count), values, CHANGE_ID);
                    };
                }
                else
                {
                    info.ListValueChanger.InsertListElementAt(Mathf.Clamp(info.InsertAt, 0, info.property.Children.Count), values, CHANGE_ID);
                }
            }
            else
            {
                UnityEngine.Object[] droppedObjects = HandleUnityObjectsDrop(info);
                if (droppedObjects != null)
                {
                    foreach (var obj in droppedObjects)
                    {
                        object[] values = new object[info.ListValueChanger.ValueCount];

                        for (int i = 0; i < values.Length; i++)
                        {
                            values[i] = obj;
                        }

                        info.ListValueChanger.InsertListElementAt(Mathf.Clamp(info.InsertAt, 0, info.property.Children.Count), values, CHANGE_ID);
                    }
                }
            }
            DragAndDropManager.EndDropZone();
        }
Esempio n. 13
0
        private DragHandle BeginDragHandle(ListDrawerConfigInfo info, int j, int i)
        {
            var child      = info.property.Children[j];
            var dragHandle = DragAndDropManager.BeginDragHandle(child, (TElement)child.ValueEntry.WeakSmartValue, info.IsReadOnly ? DragAndDropMethods.Reference : DragAndDropMethods.Move);

            dragHandle.Enabled = info.Draggable;

            if (dragHandle.OnDragStarted)
            {
                ListDrawerStaticInfo.CurrentDroppingPropertyInfo = null;
                ListDrawerStaticInfo.CurrentDraggingPropertyInfo = info.property.Children[j];
                dragHandle.OnDragFinnished = dropEvent =>
                {
                    if (dropEvent == DropEvents.Moved)
                    {
                        if (dragHandle.IsCrossWindowDrag || (ListDrawerStaticInfo.CurrentDroppingPropertyInfo != null && ListDrawerStaticInfo.CurrentDroppingPropertyInfo.Tree != info.property.Tree))
                        {
                            // Make sure drop happens a bit later, as deseiralization and other things sometimes
                            // overrides the cahnge.
                            GUIHelper.RequestRepaint();
                            UnityEditorEventUtility.DelayAction(() =>
                            {
                                GUIHelper.RequestRepaint();
                                UnityEditorEventUtility.DelayAction(() =>
                                {
                                    GUIHelper.RequestRepaint();
                                    UnityEditorEventUtility.DelayAction(() =>
                                    {
                                        info.ListValueChanger.RemoveListElementAt(j, CHANGE_ID);
                                    });
                                });
                            });
                        }
                        else
                        {
                            info.ListValueChanger.RemoveListElementAt(j, CHANGE_ID);
                        }
                    }

                    ListDrawerStaticInfo.CurrentDraggingPropertyInfo = null;
                };
            }

            return(dragHandle);
        }
Esempio n. 14
0
        public void ProcessVidkaDataFolder(string folder)
        {
            var parentFolder = Path.GetDirectoryName(folder);

            foreach (var filename in Directory.GetFiles(parentFolder))
            {
                if (String.Equals(Path.GetFileName(filename), "Thumbs.db", StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }
                if (DragAndDropManager.IsFilenameVideo(filename) ||
                    DragAndDropManager.IsFilenameImage(filename) ||
                    DragAndDropManager.IsFilenameAudio(filename)) //TODO: audio
                {
                    var old_filenameMeta    = fileMappingOld.AddGetMetaFilename(filename);
                    var old_filenameThumb   = fileMappingOld.AddGetThumbnailFilename(filename);
                    var old_filenameWave    = fileMappingOld.AddGetWaveFilenameDat(filename);
                    var old_filenameWaveJpg = fileMappingOld.AddGetWaveFilenameJpg(filename);

                    var filenameMeta    = fileMapping.AddGetMetaFilename(filename);
                    var filenameThumb   = fileMapping.AddGetThumbnailFilename(filename);
                    var filenameWave    = fileMapping.AddGetWaveFilenameDat(filename);
                    var filenameWaveJpg = fileMapping.AddGetWaveFilenameJpg(filename);

                    if (DragAndDropManager.IsFilenameVideo(filename))
                    {
                        UpdateMetadataFilename(old_filenameMeta, filenameMeta, filename, MetaDataType.MetaXml);
                        UpdateMetadataFilename(old_filenameThumb, filenameThumb, filename, MetaDataType.Thumbs);
                        //UpdateMetadataFilename(old_filenameWave, filenameWave, filename, MetaDataType.WaveDat);
                        UpdateMetadataFilename(old_filenameWaveJpg, filenameWaveJpg, filename, MetaDataType.WaveJpg);
                    }
                    else if (DragAndDropManager.IsFilenameImage(filename))
                    {
                        UpdateMetadataFilename(old_filenameThumb, filenameThumb, filename, MetaDataType.Thumbs);
                    }
                    else if (DragAndDropManager.IsFilenameAudio(filename))
                    {
                        UpdateMetadataFilename(old_filenameMeta, filenameMeta, filename, MetaDataType.MetaXml);
                        //UpdateMetadataFilename(old_filenameWave, filenameWave, filename, MetaDataType.WaveDat);
                        UpdateMetadataFilename(old_filenameWaveJpg, filenameWaveJpg, filename, MetaDataType.WaveJpg);
                    }
                }
            }
        }
Esempio n. 15
0
        private DropZoneHandle BeginDropZone()
        {
            if (info.OrderedCollectionResolver == null)
            {
                return(null);
            }

            var dropZone = DragAndDropManager.BeginDropZone(info.Property.Tree.GetHashCode() + "-" + info.Property.Path, info.CollectionResolver.ElementType, true);

            if (Event.current.type == EventType.Repaint && DragAndDropManager.IsDragInProgress)
            {
                var rect = dropZone.Rect;
                dropZone.Rect = rect;
            }

            dropZone.Enabled = info.IsReadOnly == false;
            info.DropZone    = dropZone;
            return(dropZone);
        }
Esempio n. 16
0
        public MainWindow()
        {
            InitializeComponent();

            AllowDrop = true;
            DDManager = new DragAndDropManager(this);

            DataContextChanged += OnDataContextChanged;

            AddHandler(LoadedEvent, new RoutedEventHandler(OnLoaded));
            AddHandler(UIElement.PreviewMouseMoveEvent, new MouseEventHandler(OnPreviewMouseMove));

            CommandManager.AddPreviewCanExecuteHandler(this, new CanExecuteRoutedEventHandler(OnPreviewCanExecuteHandler));
            CommandManager.AddPreviewExecutedHandler(this, new ExecutedRoutedEventHandler(OnPreviewExecutedEvent));

            HelpManager.Instance.HelpRequested += OnInfoText;

            listviewFiles.ItemDoubleClicked += OnFileListItemDoubleClicked;
            libraryView.ItemDoubleClicked   += OnLibraryViewDoubleClicked;

            DataContext = (App.Current as App).Doc;
        }
Esempio n. 17
0
        private DragHandle BeginDragHandle(int j, int i)
        {
            var child      = info.Property.Children[j];
            var dragHandle = DragAndDropManager.BeginDragHandle(child, child.ValueEntry.WeakSmartValue, info.IsReadOnly ? DragAndDropMethods.Reference : DragAndDropMethods.Move);

            dragHandle.Enabled = info.Draggable;

            if (dragHandle.OnDragStarted)
            {
                CollectionDrawerStaticInfo.CurrentDroppingPropertyInfo = null;
                CollectionDrawerStaticInfo.CurrentDraggingPropertyInfo = info.Property.Children[j];
                dragHandle.OnDragFinnished = dropEvent =>
                {
                    if (dropEvent == DropEvents.Moved)
                    {
                        if (dragHandle.IsCrossWindowDrag || (CollectionDrawerStaticInfo.CurrentDroppingPropertyInfo != null && CollectionDrawerStaticInfo.CurrentDroppingPropertyInfo.Tree != info.Property.Tree))
                        {
                            // Make sure drop happens a bit later, as deserialization and other things sometimes
                            // can override the change.
                            GUIHelper.RequestRepaint();
                            EditorApplication.delayCall += () =>
                            {
                                info.OrderedCollectionResolver.QueueRemoveAt(j);
                            };
                        }
                        else
                        {
                            info.OrderedCollectionResolver.QueueRemoveAt(j);
                        }
                    }

                    CollectionDrawerStaticInfo.CurrentDraggingPropertyInfo = null;
                };
            }

            return(dragHandle);
        }
 private void Start()
 {
     dragAndDropManager = GameObject.FindGameObjectWithTag("DragAndDropManager").GetComponent <DragAndDropManager>();
 }
Esempio n. 19
0
        /// <summary> Creates a new <see cref="Root"/> with the given type <typeparamref name="T"/>, loaded from the sheet found at <paramref name="sheetPath"/>, and passing along any <paramref name="parameters"/> to the root's constructor. </summary>
        /// <typeparam name="T"> The type of <see cref="Root"/> to create. </typeparam>
        /// <param name="sheetPath"> The file path of the xml file to load. </param>
        /// <param name="parameters"> Any parameters to pass to the constructor of the <see cref="Root"/> object. </param>
        /// <returns> A <see cref="Root"/> object with the given type, constructed with the given parameters. </returns>
        public T CreateUIRoot <T>(string sheetPath, params object[] parameters) where T : Root
        {
            // Ensure the file path exists.
            if (string.IsNullOrWhiteSpace(sheetPath))
            {
                throw new ArgumentException($"'{nameof(sheetPath)}' cannot be null or whitespace.", nameof(sheetPath));
            }

            // Create the service provider with the given parameters.
            GameServiceContainer serviceProvider = new GameServiceContainer();

            foreach (object service in parameters)
            {
                serviceProvider.AddService(service.GetType(), service);
            }

            // Add dependencies.
            serviceProvider.AddService(graphicsDevice);
            serviceProvider.AddService(contentManager);
            serviceProvider.AddService(gameWindow);

            // Try create the root.
            T root;

            try { root = Dependencies.CreateObjectWithDependencies <T>(serviceProvider); }
            catch (Exception exception) { throw new Exception("Root creation failed.", exception); }

            // Create the managers, adding each one to the service provider.
            InputManager inputManager = new InputManager(gameWindow);

            serviceProvider.AddService(inputManager);

            DragAndDropManager dragAndDropManager = new DragAndDropManager(inputManager);

            serviceProvider.AddService(dragAndDropManager);

            TemplateManager templateManager = new TemplateManager();

            serviceProvider.AddService(templateManager);

            ResourceManager resourceManager = new ResourceManager(contentManager);

            serviceProvider.AddService(resourceManager);

            StyleManager styleManager = new StyleManager(resourceManager, graphicsDevice);

            serviceProvider.AddService(styleManager);

            ComponentManager componentManager = new ComponentManager(componentCache, serviceProvider);

            serviceProvider.AddService(componentManager);

            ElementManager elementManager = new ElementManager(root, componentManager, templateManager, styleManager, elementCache, serviceProvider);

            serviceProvider.AddService(elementManager);

            // Add an extension to the path if it is missing.
            if (!Path.HasExtension(sheetPath))
            {
                sheetPath = Path.ChangeExtension(sheetPath, ".xml");
            }

            // Convert the path to be relative to the content.
            sheetPath = Path.Combine(contentManager.RootDirectory, sheetPath);

            // If the file does not exist, throw an exception.
            if (!File.Exists(sheetPath))
            {
                throw new FileNotFoundException("The given gui sheet file path does not exist.", sheetPath);
            }

            // Load the sheet.
            XmlDocument guiSheet = new XmlDocument();

            guiSheet.Load(sheetPath);

            // Initialise the root.
            root.InternalInitialise(guiSheet, styleManager, templateManager, inputManager, dragAndDropManager, elementManager, gameWindow);

            // Return the root.
            return(root);
        }
Esempio n. 20
0
 protected void BtnClose_Click(object sender, EventArgs e)
 {
     ScriptManager.RegisterStartupScript(this, this.GetType(), "reallowOp", "reallowOp();", true);
     this.CloseMask();
     DragAndDropManager.ClearReport();
 }
Esempio n. 21
0
        public void ProcessRequest(HttpContext context)
        {
            if (!string.IsNullOrEmpty(NttDataWA.Utils.InitConfigurationKeys.GetValue("0", NttDataWA.Utils.DBKeys.FE_ENABLE_DRAG_AND_DROP.ToString())) && NttDataWA.Utils.InitConfigurationKeys.GetValue("0", NttDataWA.Utils.DBKeys.FE_ENABLE_DRAG_AND_DROP.ToString()).Equals("1"))
            {
                DragAndDropResult  response = null;
                HttpPostedFile     file     = null;
                HttpFileCollection files    = null;
                HttpRequest        request  = null;
                bool       first            = true;
                CallerPage callerPage;

                try
                {
                    if (context != null && context.Request != null && context.Request.Files != null && context.Request.Files.Count > 0)
                    {
                        request    = context.Request;
                        files      = request.Files;
                        first      = Boolean.Parse(request["First"]);
                        callerPage = (CallerPage)Enum.Parse(typeof(CallerPage), request["CallerPage"]);
                        if (first)
                        {
                            DragAndDropManager.ClearReport();
                        }

                        for (int i = 0; i < files.Count; i++)
                        {
                            file = files[i];

                            switch (callerPage)
                            {
                            case (CallerPage.ADLDOCUMENT):
                                response = AddWorkArea(file, context.Session);
                                break;

                            case (CallerPage.PROJECT):
                                response = AddInProject(file, first);
                                break;

                            case (CallerPage.DOCUMENT):
                            case (CallerPage.ATTACHMENTS):
                                response = AddNewDocument(file, context.Session);
                                break;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    response         = new DragAndDropResult();
                    response.Success = false;
                    if (file != null)
                    {
                        response.FileName      = file.FileName;
                        response.ContentLength = file.ContentLength;
                    }
                    response.Error = ex.Message;

                    MassiveOperationReport.MassiveOperationResultEnum result = MassiveOperationReport.MassiveOperationResultEnum.KO;
                    if (DragAndDropManager.Report == null)
                    {
                        DragAndDropManager.Report = new MassiveOperationReport();
                    }
                    DragAndDropManager.Report.AddReportRow(response.FileName + " " + response.DocNumber, result, response.Error);
                }

                context.Response.Write(JsonConvert.SerializeObject(response));
            }
        }
Esempio n. 22
0
 public Draggable(DragAndDropManager dragAndDropManager)
 {
     this.dragAndDropManager = dragAndDropManager ?? throw new System.ArgumentNullException(nameof(dragAndDropManager));
 }