Ejemplo n.º 1
0
        private bool ValidateWebBehaviour()
        {
            List <string> errors = new List <string>();

            if (string.IsNullOrWhiteSpace(tbName.Text))
            {
                errors.Add("Name is required.");
            }

            if (tbDescription.Text == null)
            {
                tbDescription.Text = string.Empty;
            }

            if (webActions.Any() == false)
            {
                errors.Add("At least 1 web action needs to be present");
            }

            if (errors.Any())
            {
                WarningAlert.Show(string.Join("\n", errors));
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        private bool ValidateManifest()
        {
            List <string> errors = new List <string>();

            if (string.IsNullOrWhiteSpace(tbName.Text))
            {
                errors.Add("Package name is required.");
            }

            if (cbbMainDll.SelectedValue == null)
            {
                errors.Add("Main DLL is required, Please add a DLL to the package contents.");
            }

            if (string.IsNullOrWhiteSpace(tbVersion.Text))
            {
                errors.Add("Version is required.");
            }

            if (errors.Any())
            {
                WarningAlert.Show(string.Join("\n", errors));
                return(false);
            }

            return(true);
        }
Ejemplo n.º 3
0
 private void BtnCreate_Click(object sender, RoutedEventArgs e)
 {
     if (!versionSettings.Validate())
     {
         WarningAlert.Show("Invalid settings. One or more settings are not filled in.");
         return;
     }
     if (!edit)
     {
         Version = new Models.Version();
     }
     if (tbName.Text.Length > 0)
     {
         Version.Name     = tbName.Text;
         Version.Locale   = (cbLocales.SelectedItem as ComboBoxItem).Tag.ToString();
         Version.Settings = versionSettings;
         Version.Pages    = new System.Collections.ObjectModel.ObservableCollection <Models.Page>();
         DialogResult     = true;
         Close();
     }
     else
     {
         lbNameError.Text = "Enter a name";
     }
 }
Ejemplo n.º 4
0
 private void FinishSelection()
 {
     if (SelectedNode == null)
     {
         WarningAlert.Show("Please select a node.");
         return;
     }
     Close();
 }
Ejemplo n.º 5
0
        void OnFileChangedIgnore(object o, EventArgs args)
        {
            WarningAlert wa  = new WarningAlert(Catalog.GetString("Are you sure you want to ignore the changes?"), Catalog.GetString("Due to the way Bless handles files, ignoring these changes may corrupt your data."), null);
            ResponseType res = (ResponseType)wa.Run();

            wa.Destroy();

            if (res == ResponseType.Ok)
            {
                this.Visible          = false;
                dataView.Notification = false;
                dataView.Buffer.FileOperationsAllowed = true;
            }
        }
Ejemplo n.º 6
0
        private void BtnRemove_Click(object sender, RoutedEventArgs e)
        {
            Behaviour webbehaviour = (Behaviour)lsbBehaviours.SelectedItem;

            if (ValidateWebBehaviourRemoval(webbehaviour))
            {
                if (ConfirmAlert.Show($"Web behaviour '{webbehaviour.Name}' will be removed.").DialogResult.Value)
                {
                    behaviours.Remove((Behaviour)lsbBehaviours.SelectedItem);
                    Studio.GetBehaviourConfiguration().Behaviours.Remove((Behaviour)lsbBehaviours.SelectedItem);
                }
            }
            else
            {
                WarningAlert.Show("This web behaviour cannot be removed because it's used in the project.");
            }
        }
Ejemplo n.º 7
0
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            if (parameters.Validate())
            {
                WebAction            = availableActions.Find(webaction => webaction.Id == cbbType.SelectedValue.ToString());
                WebAction.Parameters = parameters;

                if (WebAction.Type == Interpic.Models.Behaviours.Action.ActionType.Check)
                {
                    CheckAction checkWebAction = WebAction as CheckAction;
                    checkWebAction.BehaviourWhenFalse = (Behaviour)cbbBehaviourWhenFalse.SelectedItem;
                    checkWebAction.BehaviourWhenTrue  = (Behaviour)cbbBehaviourWhenTrue.SelectedItem;
                    WebAction = checkWebAction;
                }
                Close();
            }
            else
            {
                WarningAlert.Show("Not all parameters have been set!");
            }
        }
Ejemplo n.º 8
0
        public void CancelAllTasks(string errorMessage = null)
        {
            TaskToExecute.IsCanceled = true;
            if (errorMessage != null)
            {
                if (!this.Dispatcher.CheckAccess())
                {
                    this.Dispatcher.Invoke(() =>
                    {
                        ErrorAlert.Show(errorMessage);
                        WarningAlert.Show("The task has been canceled.");
                    });
                }
                else
                {
                    ErrorAlert.Show(errorMessage);
                    WarningAlert.Show("The task has been canceled.");
                }
            }

            Close();
        }
Ejemplo n.º 9
0
        private async void ExecuteTasks()
        {
            while (!complete)
            {
                taskCounter++;
                TaskToExecute = TasksToExecute[taskCounter];
                if (!TaskToExecute.IsCanceled)
                {
                    lbTaskName.Text        = TaskToExecute.TaskName;
                    lbTaskDescription.Text = TaskToExecute.TaskDescription;

                    pbTotalProgress.Value     = taskCounter;
                    TaskToExecute.Icon.Source = new BitmapImage(new Uri("/Interpic.UI;component/Icons/ArrowRightBold.png", UriKind.RelativeOrAbsolute));
                    lbTitle.Text         = String.Format("Processing task {0} of {1}", (taskCounter + 1).ToString(), TasksToExecute.Count.ToString());
                    Title                = lbTitle.Text + ": " + lbTaskName.Text;
                    TaskToExecute.Dialog = this;
                    TaskToExecute.BeforeExecution();
                    pbProgress.IsIndeterminate = TaskToExecute.IsIndeterminate;

                    if (TaskToExecute.IsCancelable)
                    {
                        TaskToExecute.CancellationTokenSource = new CancellationTokenSource();
                        try
                        {
                            executingInnerTask = TaskToExecute.Execute();
                            await executingInnerTask;
                            PassThrough();
                            TaskToExecute.Icon.Source = new BitmapImage(new Uri("/Interpic.UI;component/Icons/CheckmarkGreen.png", UriKind.RelativeOrAbsolute));
                        }
                        catch (OperationCanceledException)
                        {
                            TaskToExecute.IsCanceled = true;
                            TaskToExecute.FireCanceledEvent(this);
                            TaskToExecute.Icon.Source = new BitmapImage(new Uri("/Interpic.UI;component/Icons/FailRed.png", UriKind.RelativeOrAbsolute));
                            if (taskCounter != TasksToExecute.Count - 1)
                            {
                                ConfirmAlert alert = new ConfirmAlert("Task canceled./nThe next task will now execute.");
                                if (alert.ShowDialog() == false)
                                {
                                    complete = true;
                                    Close();
                                }
                            }
                        }
                        if (!executingInnerTask.IsCanceled)
                        {
                            TaskToExecute.AfterExecution();
                            TaskToExecute.Icon.Source = new BitmapImage(new Uri("/Interpic.UI;component/Icons/CheckmarkGreen.png", UriKind.RelativeOrAbsolute));
                            TaskToExecute.FireExecutedEvent(this);
                        }
                        else
                        {
                            TaskToExecute.AfterExecution();
                            TaskToExecute.Icon.Source = new BitmapImage(new Uri("/Interpic.UI;component/Icons/FailRed.png", UriKind.RelativeOrAbsolute));
                            TaskToExecute.FireCanceledEvent(this);
                        }
                    }
                    else
                    {
                        executingInnerTask = TaskToExecute.Execute();
                        await executingInnerTask;

                        TaskToExecute.AfterExecution();
                        PassThrough();
                        if (!TaskToExecute.IsCanceled)
                        {
                            TaskToExecute.Icon.Source = new BitmapImage(new Uri("/Interpic.UI;component/Icons/CheckmarkGreen.png", UriKind.RelativeOrAbsolute));
                            TaskToExecute.FireExecutedEvent(this);
                        }
                        else
                        {
                            TaskToExecute.Icon.Source = new BitmapImage(new Uri("/Interpic.UI;component/Icons/FailRed.png", UriKind.RelativeOrAbsolute));
                            TaskToExecute.FireCanceledEvent(this);
                        }
                    }

                    if (taskCounter == TasksToExecute.Count - 1)
                    {
                        if (TasksToExecute.Any(task => task.IsCanceled == true))
                        {
                            WarningAlert.Show("One or more tasks where canceled!");
                        }
                        complete = true;
                        Close();
                    }
                }
                else
                {
                    if (taskCounter == TasksToExecute.Count - 1)
                    {
                        if (TasksToExecute.Any(task => task.IsCanceled == true))
                        {
                            WarningAlert.Show("One or more tasks where canceled!");
                        }
                        complete = true;
                        Close();
                    }
                }
            }
        }
Ejemplo n.º 10
0
        public static Project LoadProject(string path)
        {
            try
            {
                Project project = JsonConvert.DeserializeObject <Project>(File.ReadAllText(path));
                // when the project has been moved
                if (project.Path != path)
                {
                    project.Path = path;
                }

                if (!Directory.Exists(project.OutputFolder))
                {
                    WarningAlert.Show("Output folder not found.\nPlease specify an output folder.");
                    System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog();
                    DialogResult result = dialog.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        project.OutputFolder = dialog.SelectedPath;
                        SaveProjectTask   task       = new SaveProjectTask(project);
                        ProcessTaskDialog saveDialog = new ProcessTaskDialog(task, "Saving...");
                        saveDialog.ShowDialog();
                        if (saveDialog.TaskToExecute.IsCanceled)
                        {
                            throw new Exception("Could not save the project.");
                        }
                    }
                    else
                    {
                        throw new Exception("Invalid path.");
                    }
                }


                if (!Directory.Exists(project.OutputFolder))
                {
                    WarningAlert.Show("Project folder not found.\nPlease specify an output folder.");
                    System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog();
                    DialogResult result = dialog.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        project.ProjectFolder = dialog.SelectedPath;
                        SaveProjectTask   task       = new SaveProjectTask(project);
                        ProcessTaskDialog saveDialog = new ProcessTaskDialog(task, "Saving...");
                        saveDialog.ShowDialog();
                        if (saveDialog.TaskToExecute.IsCanceled)
                        {
                            throw new Exception("Could not save the project.");
                        }
                    }
                    else
                    {
                        throw new Exception("Invalid path.");
                    }
                }
                return(JsonConvert.DeserializeObject <Project>(File.ReadAllText(path)));
            }
            catch (Exception ex)
            {
                ErrorAlert.Show("Could not load project:\n" + ex.Message);
            }
            return(null);
        }