Esempio n. 1
0
        private async void HandlePreviewDrop(object dropedFile)
        {
            var file = dropedFile as IDataObject;

            if (null == file)
            {
                return;
            }
            var documentsPath = (string[])file.GetData(DataFormats.FileDrop);

            if (documentsPath != null)
            {
                foreach (var path in documentsPath)
                {
                    if (ProcessScript.IsGeneratedByAhkPlugin(path))
                    {
                        MessageVisibility = "Collapsed";
                        var pathAlreadyAdded = FilesNameCollection.Any(p => p.FilePath.Equals(path));
                        if (!pathAlreadyAdded)
                        {
                            var scripts = ProcessScript.ReadImportedScript(path);
                            foreach (var script in scripts)
                            {
                                var exist = await ProcessScript.ScriptContentAlreadyExist(script.Value);

                                if (!exist)
                                {
                                    script.Value.ScriptStateAction = script.Value.Active ? "Disable" : "Enable";
                                    script.Value.RowColor          = script.Value.Active ? "Black" : "DarkGray";
                                    ScriptsCollection.Add(script);
                                }
                            }
                            var newFile = new ImportScriptItemTemplate
                            {
                                Content           = Path.GetFileNameWithoutExtension(path),
                                RemoveFileCommand = new RelayCommand(RemoveFile),
                                FilePath          = path
                            };
                            FilesNameCollection.Add(newFile);
                            if (ScriptsCollection.Count.Equals(0))
                            {
                                MessageVisibility = "Visible";
                                Message           = "Imported scripts are already in the master script.";
                            }
                        }
                    }
                    else
                    {
                        MessageVisibility = "Visible";
                        Message           = "Only scripts generated by AHK Plugin are supported.";
                    }
                }
            }
            SetGridVisibility();
        }
Esempio n. 2
0
        private void HandlePreviewDrop(object dropedFile)
        {
            var file = dropedFile as IDataObject;

            if (null == file)
            {
                return;
            }
            var documentsPath = (string[])file.GetData(DataFormats.FileDrop);
            var defaultFormat = DataFormats.Text;

            if (documentsPath != null)
            {
                foreach (var path in documentsPath)
                {
                    if (ProcessScript.IsGeneratedByAhkPlugin(path))
                    {
                        MessageVisibility = "Hidden";
                        var pathAlreadyAdded = FilesNameCollection.Any(p => p.FilePath.Equals(path));
                        if (!pathAlreadyAdded)
                        {
                            var scripts = ProcessScript.ReadImportedScript(path);
                            ScriptsCollection.AddRange(scripts);
                            var newFile = new ImportScriptItemTemplate
                            {
                                Content           = Path.GetFileNameWithoutExtension(path),
                                RemoveFileCommand = new RelayCommand(RemoveFile),
                                FilePath          = path
                            };
                            FilesNameCollection.Add(newFile);
                        }
                    }
                    else
                    {
                        MessageVisibility = "Visible";
                        Message           = "Only scripts generated by AHK Plugin are supported.";
                    }
                }
            }
            SetGridVisibility();
        }