private void ProgramSourceView_Drop(object sender, DragEventArgs e)
        {
            var directories = (string[])e.Data.GetData(DataFormats.FileDrop);

            var directoriesToAdd = new List <ProgramSource>();

            if (directories != null && directories.Length > 0)
            {
                foreach (var directory in directories)
                {
                    if (Directory.Exists(directory))
                    {
                        var source = new ProgramSource
                        {
                            Location = directory
                        };

                        directoriesToAdd.Add(source);
                    }
                }

                if (directoriesToAdd.Count() > 0)
                {
                    directoriesToAdd.ForEach(x => _settings.ProgramSources.Add(x));
                    ReIndexing();
                }
            }
        }
        private void programSourceView_Drop(object sender, DragEventArgs e)
        {
            var directories = (string[])e.Data.GetData(DataFormats.FileDrop);

            var directoriesToAdd = new List <ProgramSource>();

            if (directories != null && directories.Length > 0)
            {
                foreach (string directory in directories)
                {
                    if (Directory.Exists(directory) && !ProgramSettingDisplayList.Any(x => x.UniqueIdentifier == directory))
                    {
                        var source = new ProgramSource
                        {
                            Location         = directory,
                            UniqueIdentifier = directory,
                        };

                        directoriesToAdd.Add(source);
                    }
                }

                if (directoriesToAdd.Count > 0)
                {
                    directoriesToAdd.ForEach(x => _settings.ProgramSources.Add(x));
                    directoriesToAdd.ForEach(x => ProgramSettingDisplayList.Add(x));

                    programSourceView.Items.Refresh();
                    ReIndexing();
                }
            }
        }
        private void ButtonAdd_OnClick(object sender, RoutedEventArgs e)
        {
            string s = Directory.Text;

            if (!System.IO.Directory.Exists(s))
            {
                System.Windows.MessageBox.Show(_context.API.GetTranslation("flowlauncher_plugin_program_invalid_path"));
                return;
            }
            if (_editing == null)
            {
                if (!ProgramSetting.ProgramSettingDisplayList.Any(x => x.UniqueIdentifier == Directory.Text))
                {
                    var source = new ProgramSource
                    {
                        Location         = Directory.Text,
                        UniqueIdentifier = Directory.Text
                    };

                    _settings.ProgramSources.Insert(0, source);
                    ProgramSetting.ProgramSettingDisplayList.Add(source);
                }
            }
            else
            {
                _editing.Location = Directory.Text;
            }

            DialogResult = true;
            Close();
        }
        public Program(string sourcePath, ProgramSource sourceType)
        {
            SourcePath = sourcePath;
            SourceType = sourceType;

            Lines           = new List <ProgramLine>();
            LinesWithErrors = new List <ProgramLine>();
            Variables       = new Dictionary <string, NumberExpression>();
        }
Exemple #5
0
        private void btnAdd_OnClick(object sender, RoutedEventArgs e)
        {
            string location = tbLocation.Text;

            if (this.tbLocation.IsEnabled == true && string.IsNullOrEmpty(location))
            {
                MessageBox.Show("Please input Type field");
                return;
            }

            string type = cbType.SelectedItem as string;

            if (string.IsNullOrEmpty(type))
            {
                MessageBox.Show("Please input Type field");
                return;
            }

            int bonusPoint = 0;

            int.TryParse(this.tbBonusPoints.Text, out bonusPoint);

            if (!update)
            {
                ProgramSource p = new ProgramSource()
                {
                    Location    = this.tbLocation.IsEnabled ? location : null,
                    Enabled     = cbEnable.IsChecked ?? false,
                    Type        = type,
                    BonusPoints = bonusPoint
                };
                if (UserSettingStorage.Instance.ProgramSources.Exists(o => o.ToString() == p.ToString() && o != p))
                {
                    MessageBox.Show("Program source already exists!");
                    return;
                }
                UserSettingStorage.Instance.ProgramSources.Add(p);
                MessageBox.Show(string.Format("Add {0} program source successfully!", p.ToString()));
            }
            else
            {
                if (UserSettingStorage.Instance.ProgramSources.Exists(o => o.ToString() == updateProgramSource.ToString() && o != updateProgramSource))
                {
                    MessageBox.Show("Program source already exists!");
                    return;
                }
                updateProgramSource.Location    = this.tbLocation.IsEnabled ? location : null;
                updateProgramSource.Type        = type;
                updateProgramSource.Enabled     = cbEnable.IsChecked ?? false;
                updateProgramSource.BonusPoints = bonusPoint;
                MessageBox.Show(string.Format("Update {0} program source successfully!", updateProgramSource.ToString()));
            }
            UserSettingStorage.Instance.Save();
            settingWindow.ReloadProgramSourceView();
            Close();
        }
        public static CompilationResult CompileToTempDirectory(ProgramSource source, IFactory <ICompiler> compilers)
        {
            var tempDirectory = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            Directory.CreateDirectory(tempDirectory);

            var sourcePath = Path.GetTempFileName();

            File.WriteAllText(sourcePath, source.Code);

            return(compilers.Find(source.LanguageId).Compile(sourcePath, tempDirectory));
        }
Exemple #7
0
        private void btnEditProgramSource_OnClick(object sender, RoutedEventArgs e)
        {
            ProgramSource seletedProgramSource = programSourceView.SelectedItem as ProgramSource;

            if (seletedProgramSource != null)
            {
                ProgramSourceSetting programSource = new ProgramSourceSetting(this);
                programSource.UpdateItem(seletedProgramSource);
                programSource.ShowDialog();
            }
            else
            {
                MessageBox.Show("Please select a program source");
            }
        }
Exemple #8
0
        private void btnDeleteProgramSource_OnClick(object sender, RoutedEventArgs e)
        {
            ProgramSource seletedProgramSource = programSourceView.SelectedItem as ProgramSource;

            if (seletedProgramSource != null &&
                MessageBox.Show("Are your sure to delete " + seletedProgramSource.ToString(), "Delete ProgramSource",
                                MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                UserSettingStorage.Instance.ProgramSources.Remove(seletedProgramSource);
                programSourceView.Items.Refresh();
            }
            else
            {
                MessageBox.Show("Please select a program source");
            }
        }
Exemple #9
0
        public void UpdateItem(ProgramSource programSource)
        {
            updateProgramSource = UserSettingStorage.Instance.ProgramSources.FirstOrDefault(o => o == programSource);
            if (updateProgramSource == null)
            {
                MessageBox.Show("Invalid program source");
                Close();
                return;
            }

            update              = true;
            lblAdd.Text         = "Update";
            cbEnable.IsChecked  = programSource.Enabled;
            cbType.SelectedItem = programSource.Type;
            cbType.IsEnabled    = false;
            tbLocation.Text     = programSource.Location;
            tbBonusPoints.Text  = programSource.BonusPoints.ToString();
        }
Exemple #10
0
        private void btnEditProgramSource_OnClick(object sender, RoutedEventArgs e)
        {
            ProgramSource selectedProgramSource = programSourceView.SelectedItem as ProgramSource;

            if (selectedProgramSource != null)
            {
                //todo: update
                var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
                if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    string path = folderBrowserDialog.SelectedPath;
                    selectedProgramSource.Location = path;
                    UserSettingStorage.Instance.Save();
                    ReIndexing();
                }
            }
            else
            {
                MessageBox.Show("Please select a program source");
            }
        }
 public UserStartMenuProgramSource(ProgramSource source)
     : this()
 {
     this.BonusPoints = source.BonusPoints;
 }
 public UserStartMenuProgramSource(ProgramSource source)
     : this(source.Suffixes)
 {
     BonusPoints = source.BonusPoints;
 }
Exemple #13
0
 public AppPathsProgramSource(ProgramSource source)
     : this()
 {
     this.BonusPoints = source.BonusPoints;
 }
 public FileSystemProgramSource(ProgramSource source)
     : this(source.Location, source.MaxDepth, source.Suffixes)
 {
     this.BonusPoints = source.BonusPoints;
 }
 public AppPathsProgramSource(ProgramSource source)
     : this()
 {
     this.BonusPoints = source.BonusPoints;
 }
 public CommonStartMenuProgramSource(ProgramSource source)
     : this()
 {
     this.BonusPoints = source.BonusPoints;
 }
 public PortableAppsProgramSource(ProgramSource source)
     : this(source.Location)
 {
     this.BonusPoints = source.BonusPoints;
 }
        public Program(string sourcePath, ProgramSource sourceType)
        {
            SourcePath = sourcePath;
            SourceType = sourceType;

            Lines = new List<ProgramLine>();
            LinesWithErrors = new List<ProgramLine>();
            Variables = new Dictionary<string, NumberExpression>();
        }
Exemple #19
0
 public FileSystemProgramSource(ProgramSource source) : this(source.Location)
 {
     this.BonusPoints = source.BonusPoints;
 }
 public FileSystemFolderSourceShallow(ProgramSource source)
     : base(source)
 {
 }