Esempio n. 1
0
        // Summary:
        // Checks a given path for source files. If source files exist, this displays all files in the file list.

        private void checkPath(string filePath)
        {
            if (filePath == null)
            {
                throw new ArgumentNullException("filePath");
            }

            //Valid source extensions
            List <string> extensions = new List <string>();

            extensions.Add("cs");
            extensions.Add("vb");
            extensions.Add("xaml");

            //Check if this is a valid path
            if (Directory.Exists(filePath))
            {
                this.FileList.Items.Clear();

                int validCount = 0;

                bool isValid = false;

                //Location files
                foreach (string fileName in Directory.GetFiles(filePath, "*"))
                {
                    isValid = false;

                    string fileExtension = Path.GetExtension(fileName);

                    foreach (string ext in extensions)
                    {
                        if (fileExtension == "." + ext)
                        {
                            isValid = true;
                        }
                    }

                    if (isValid)
                    {
                        validCount++;
                    }

                    if (fileExtension != ".resx")
                    {
                        FileListItem fli = new FileListItem(fileName, isValid);
                        this.FileList.Items.Add(fli);
                    }
                }

                if (validCount == 0)
                {
                    ErrorDialog dialog = new ErrorDialog("No source files found in the target directory.", "No Source Files Found", ErrorDialog.ErrorType.Message);
                    dialog.ShowDialog();

                    this.ProjectFilesLabel.Visibility = Visibility.Hidden;
                    this.FileList.Visibility          = Visibility.Hidden;
                }
                else
                {
                    this.ProjectFilesLabel.Visibility = Visibility.Visible;
                    this.FileList.Visibility          = Visibility.Visible;

                    this.FilePath.Text = filePath;
                }
            }
            else
            {
                ErrorDialog dialog = new ErrorDialog("Invalid Path Entered.", "Invalid Path", ErrorDialog.ErrorType.Warning);
                dialog.ShowDialog();

                this.FilePath.Focus();
                this.FilePath.Text = "";

                this.ProjectFilesLabel.Visibility = Visibility.Hidden;
                this.FileList.Visibility          = Visibility.Hidden;
            }
        }
Esempio n. 2
0
        private void AddTask(object sender, RoutedEventArgs e)
        {
            GroupElement groupElement = Targets.SelectedItem as GroupElement;

            if (groupElement != null)
            {
                TargetElement selElm = groupElement.ElementBase as TargetElement;

                if (selElm != null)
                {
                    if (!selElm.IsImported)
                    {
                        AddTaskDialog dialog       = new AddTaskDialog();
                        bool?         dialogResult = dialog.ShowDialog();

                        if (!dialogResult.HasValue)
                        {
                            return;
                        }

                        if (dialogResult.Value)
                        {
                            try
                            {
                                Microsoft.Build.BuildEngine.BuildTask elm = selElm.TargetObject.AddNewTask(dialog.TaskName);

                                elm.Condition = dialog.Condition;

                                if (dialog.TaskParam.Length > 0)
                                {
                                    string[] pList = dialog.TaskParam.Split(',');

                                    foreach (string param in pList)
                                    {
                                        string[] pPart = param.Split('=');

                                        if (pPart.Length == 2)
                                        {
                                            elm.SetParameterValue(pPart[0], pPart[1]);
                                        }
                                    }
                                }
                            }
                            catch (System.Xml.XmlException ex)
                            {
                                ErrorDialog errorMessage = new ErrorDialog(ex.Message);
                                errorMessage.ShowDialog();
                            }
                            catch (ArgumentException ex)
                            {
                                ErrorDialog errorMessage = new ErrorDialog(ex.Message);
                                errorMessage.ShowDialog();
                            }

                            groupElement.Refresh();
                        }
                    }
                }
                else
                {
                    AddTaskBtn.IsEnabled = false;
                }
            }
        }