public bool Execute(WorkFlowCommand command, Context context) { if (context?.ImageStream == null) { return(true); } if (!CheckCondition(command, context)) { return(true); } context.ImageStream.Seek(0, SeekOrigin.Begin); using (MagickImage image = new MagickImage(context.ImageStream)) { context.ImageStream.Seek(0, SeekOrigin.Begin); MagickGeometry geometry = new MagickGeometry(command.Properties["Width"].ToInt(context), command.Properties["Height"].ToInt(context)); if (command.Properties["Width"].IsPercentage(context) || command.Properties["Height"].IsPercentage(context)) { geometry = new MagickGeometry(new Percentage(command.Properties["Width"].ToInt(context)), new Percentage(command.Properties["Height"].ToInt(context))); } geometry.IgnoreAspectRatio = !command.Properties["KeepAspectRatio"].ToBool(context); image.Resize(geometry); image.Write(context.ImageStream, MagickFormat.Bmp); } return(true); }
public bool Execute(WorkFlowCommand command, Context context) { if (!CheckCondition(command, context)) { return(true); } Smart.Default.Settings.ConvertCharacterStringLiterals = false; var filename = command.Properties["FileNameTemplate"].ToString(context); filename = filename + Path.GetExtension(context.FileItem.TempFile).ToLower(); if (command.Properties["EnqueueAction"].ToBool(context)) { var file = Path.Combine(Settings.Instance.QueueFolder, Path.GetRandomFileName()); Utils.CreateFolder(file); File.Copy(context.FileItem.TempFile, file, true); WorkflowManager.Instance.Database.Add(new DbQueue(file, "CopyFile", filename)); Log.Debug("Adding to queue " + filename); } else { Utils.CreateFolder(filename); File.Copy(context.FileItem.TempFile, filename, command.Properties["Overwrite"].ToBool(context)); context.FileItem.FileName = filename; } return(true); }
public bool Execute(WorkFlowCommand command, Context context) { if (context?.ImageStream == null) { return(true); } if (!CheckCondition(command, context)) { return(true); } context.ImageStream.Seek(0, SeekOrigin.Begin); using (MagickImage image = new MagickImage(context.ImageStream)) { context.ImageStream.Seek(0, SeekOrigin.Begin); var midpoint = 1.0; if ((double)context.WorkFlow.Variables[command.Properties["MidPoint"].ToString(context)].GetAsObject() < 0) { midpoint = -(double)context.WorkFlow.Variables[command.Properties["MidPoint"].ToString(context)].GetAsObject() / 10.0; midpoint++; } if ((double)context.WorkFlow.Variables[command.Properties["MidPoint"].ToString(context)].GetAsObject() > 0) { midpoint = (100 - (double)context.WorkFlow.Variables[command.Properties["MidPoint"].ToString(context)].GetAsObject()) / 100.0; } image.Level( new Percentage((double)context.WorkFlow.Variables[command.Properties["BlackPoint"].ToString(context)] .GetAsObject()), new Percentage((double)context.WorkFlow.Variables[command.Properties["WhitePoint"].ToString(context)] .GetAsObject()), midpoint); image.Write(context.ImageStream, MagickFormat.Bmp); } return(true); }
public bool Execute(WorkFlowCommand command, Context context) { if (!CheckCondition(command, context)) { return(true); } switch (command.Properties["Source"].ToString(context)) { case "Folder": { var folder = command.Properties["Param"].ToString(context); if (string.IsNullOrEmpty(folder)) { Log.Error(" No folder specified in Param " + Name); return(false); } if (!Directory.Exists(folder)) { Log.Error(" Folder not exist " + Name + " " + folder); return(false); } var folders = Directory.GetDirectories(folder); var val = ""; foreach (var item in folders.OrderBy(x => x)) { val += Path.GetFileName(item) + "|"; } context.WorkFlow.Variables[command.Properties["Variable"].Value].Value = val; } break; } return(true); }
public bool Execute(WorkFlowCommand command, Context context) { try { if (!CheckCondition(command, context)) { return(true); } switch (command.Properties["Action"].Value) { case "Capture": CaptureAsync(); break; case "StartLiveView": StartLiveView(); break; case "StopLiveView": StopLiveView(); break; case "Autofocus": context.CameraDevice.AutoFocus(); break; } return(true); } catch (Exception ex) { Log.Debug("Error execute command", ex); return(false); } }
public bool Execute(WorkFlowCommand command, Context context) { if (context?.ImageStream == null) { return(true); } if (!CheckCondition(command, context)) { return(true); } context.ImageStream.Seek(0, SeekOrigin.Begin); using (MagickImage image = new MagickImage(context.ImageStream)) { context.ImageStream.Seek(0, SeekOrigin.Begin); if (command.Properties["Orientation"].Value == "Horizontal") { image.Flop(); } else { image.Flip(); } image.Write(context.ImageStream, MagickFormat.Jpg); } return(true); }
public WorkFlowCommand CreateCommand() { var command = new WorkFlowCommand(); command.Properties.Add(new CustomProperty() { Name = "Action", PropertyType = CustomPropertyType.ValueList, ValueList = new List <string>() { "Capture", "StartLiveView", "StopLiveView" } }); command.Properties.Add(new CustomProperty() { Name = "Param1", PropertyType = CustomPropertyType.String }); command.Properties.Add(new CustomProperty() { Name = "Param2", PropertyType = CustomPropertyType.String }); return(command); }
public bool Execute(WorkFlowCommand command) { try { switch (command.Properties["Action"].Value) { case "Capture": CaptureAsync(); break; case "StartLiveView": StartLiveView(); break; case "StopLiveView": StopLiveView(); break; } return(true); } catch (Exception ex) { Log.Debug("Error execute command", ex); return(false); } }
private void RemoveViewCommand(WorkFlowCommand command) { if (command != null) { SelectedViewCommandCollection?.Items.Remove(command); } if (SelectedViewCommandCollection?.Items.Count > 0) { SelectedViewCommand = SelectedViewCommandCollection.Items[0]; } }
private void DeleteEventCommandMethod(WorkFlowCommand command) { if (SelectedEvent != null && command != null) { SelectedEvent.CommandCollection.Items.Remove(command); if (SelectedEvent.CommandCollection.Items.Count > 0) { SelectedEventCommand = SelectedEvent.CommandCollection.Items[0]; } } }
public bool Execute(WorkFlowCommand command, Context context) { if (!CheckCondition(command, context)) { return(true); } Thread.Sleep(command.Properties["Seconds"].ToInt(context) * 1000); return(true); }
public bool Execute(WorkFlowCommand command) { switch (command.Properties["Action"].Value) { case "ShowView": WorkflowManager.Instance.OnMessage(new MessageEventArgs(Messages.ShowView, command.Properties["ViewName"].Value)); break; } return(true); }
public bool Execute(WorkFlowCommand command, Context context) { if (!CheckCondition(command, context)) { return(true); } context.WorkFlow.Variables[command.Properties["Variable"].Value].Value = ScriptEngine.Instance.ExecuteLine(command.Properties["Formula"].ToString(context), context); return(true); }
public bool Execute(WorkFlowCommand command, Context context) { if (!CheckCondition(command, context)) { return(true); } Utils.Run(command.Properties["Executable"].ToString(context), command.Properties["Parameter"].ToString(context)); return(true); }
public bool Execute(WorkFlowCommand command, Context context) { if (!CheckCondition(command, context)) { return(true); } switch (command.Properties["Action"].Value) { case "ShowView": WorkflowManager.Instance.OnMessage(new MessageEventArgs(Messages.ShowView, command.Properties["ViewName"].ToString(context))); break; case "FinishSession": WorkflowManager.Instance.OnMessage(new MessageEventArgs(Messages.SessionFinished, context)); break; case "CancelSession": WorkflowManager.Instance.OnMessage(new MessageEventArgs(Messages.SessionCanceled, context)); break; case "PreviousView": WorkflowManager.Instance.OnMessage(new MessageEventArgs(Messages.PreviousView, context)); break; case "UpdateThumb": WorkflowManager.Instance.OnMessage(new MessageEventArgs(Messages.ThumbCreate, context)); break; case "NextPhoto": WorkflowManager.Instance.OnMessage(new MessageEventArgs(Messages.NextPhoto, context)); break; case "PrevPhoto": WorkflowManager.Instance.OnMessage(new MessageEventArgs(Messages.PrevPhoto, context)); break; case "DeletePhoto": WorkflowManager.Instance.OnMessage(new MessageEventArgs(Messages.DeletePhoto, context)); break; case "ClearPhotos": WorkflowManager.Instance.OnMessage(new MessageEventArgs(Messages.ClearPhotos, context)); break; } return(true); }
public bool Execute(WorkFlowCommand command, Context context) { if (string.IsNullOrWhiteSpace(command.Properties["Event"].ToString(context))) { Log.Debug("No event specified for " + command.Name); return(false); } if (CheckCondition(command, context)) { WorkflowManager.Instance.OnMessage(new MessageEventArgs(command.Properties["Event"].ToString(context), command.Properties["Message"].ToString(context))); } return(true); }
public WorkFlowCommand GetCommand() { var command = new WorkFlowCommand(); command.Properties.Items.Add(new CustomProperty() { Name = "(Name)", PropertyType = CustomPropertyType.String }); command.Properties.Items.Add(new CustomProperty() { Name = "Condition", PropertyType = CustomPropertyType.Code }); return(command); }
public bool Execute(WorkFlowCommand command, Context context) { if (!CheckCondition(command, context)) { return(true); } Smart.Default.Settings.ConvertCharacterStringLiterals = false; var filename = command.Properties["FileNameTemplate"].ToString(context); filename = filename + Path.GetExtension(context.FileItem.TempFile); Utils.CreateFolder(filename); File.Copy(context.FileItem.TempFile, filename, command.Properties["Overwrite"].ToBool(context)); context.FileItem.FileName = filename; return(true); }
public bool CheckCondition(WorkFlowCommand command, Context context) { if (string.IsNullOrWhiteSpace(command.Properties["Condition"].ToString(context))) { return(true); } var var = new Engine(); foreach (var variable in context.WorkFlow.Variables.Items) { //e.Parameters[variable.Name] = new Exception(variable.Value); var.SetValue(variable.Name, variable.GetAsObject()); } return(var.Execute(command.Properties["Condition"].ToString(context)).GetCompletionValue().AsBoolean()); }
public bool Execute(WorkFlowCommand command, Context context) { if (!CheckCondition(command, context)) { return(true); } switch (command.Properties["Type"].ToString(context)) { case "Message": MessageBox.Show(command.Properties["Message"].ToString(context)); break; case "Warning": MessageBox.Show(command.Properties["Message"].ToString(context), "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); break; case "YesNo": return(MessageBox.Show(command.Properties["Message"].ToString(context), "", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes); case "SaveFile": var dialog = new SaveFileDialog(); dialog.Filter = command.Properties["FileNameFilter"].ToString(context); dialog.FileName = context.WorkFlow.Variables[command.Properties["Variable"].Value].Value; if (dialog.ShowDialog() == true) { context.WorkFlow.Variables[command.Properties["Variable"].Value].Value = dialog.FileName; } else { return(false); } break; } if (!string.IsNullOrEmpty(command.Properties["Message"].ToString(context))) { if (command.Properties["YesNo"].ToBool(context)) { return(MessageBox.Show(command.Properties["Message"].ToString(context), "", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes); } else { MessageBox.Show(command.Properties["Message"].ToString(context)); } } return(!command.Properties["Error"].ToBool(context)); }
public bool Execute(WorkFlowCommand command, Context context) { if (!CheckCondition(command, context)) { return(true); } if (ServiceProvider.Instance.DeviceManager.ConnectedDevices.Count == 0 || ServiceProvider.Instance.DeviceManager.SelectedCameraDevice == null || !ServiceProvider.Instance .DeviceManager.SelectedCameraDevice.IsConnected) { WorkflowManager.Instance.OnMessage(new MessageEventArgs(Messages.ShowMessage, command.Properties["Message"].ToString(context))); return(false); } return(true); }
public bool CheckCondition(WorkFlowCommand command, Context context) { try { if (string.IsNullOrWhiteSpace(command.Properties["Condition"].ToString(context))) { return(true); } return(ScriptEngine.Instance.Evaluate(command.Properties["Condition"].ToString(context), context)); } catch (Exception e) { Log.Error("CheckCondition error " + command.Name, e); } return(false); }
public bool Execute(WorkFlowCommand command, Context context) { if (!CheckCondition(command, context)) { return(true); } var var = new Engine(); foreach (var variable in context.WorkFlow.Variables.Items) { //e.Parameters[variable.Name] = new Exception(variable.Value); var.SetValue(variable.Name, variable.GetAsObject()); } context.WorkFlow.Variables[command.Properties["Variable"].Value].Value = var.Execute(command.Properties["Formula"].ToString(context)).GetCompletionValue().ToString(); return(true); }
public bool Execute(WorkFlowCommand command, Context context) { if (!CheckCondition(command, context)) { return(true); } if (!string.IsNullOrEmpty(command.Properties["Message"].ToString(context))) { if (command.Properties["YesNo"].ToBool(context)) { return(MessageBox.Show(command.Properties["Message"].ToString(context), "", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes); } else { MessageBox.Show(command.Properties["Message"].ToString(context)); } } return(!command.Properties["Error"].ToBool(context)); }
public bool Execute(WorkFlowCommand command, Context context) { if (context?.ImageStream == null) { return(true); } if (!CheckCondition(command, context)) { return(true); } context.ImageStream.Seek(0, SeekOrigin.Begin); using (MagickImage image = new MagickImage(context.ImageStream)) { context.ImageStream.Seek(0, SeekOrigin.Begin); image.Rotate((double)context.WorkFlow.Variables[command.Properties["Angle"].ToString(context)].GetAsObject()); image.Write(context.ImageStream, MagickFormat.Bmp); } return(true); }
public bool Execute(WorkFlowCommand command, Context context) { if (context?.ImageStream == null) { return(true); } if (!CheckCondition(command, context)) { return(true); } context.ImageStream.Seek(0, SeekOrigin.Begin); using (MagickImage image = new MagickImage(context.ImageStream)) { context.ImageStream.Seek(0, SeekOrigin.Begin); image.Grayscale(PixelIntensityMethod.Average); image.Write(context.ImageStream, MagickFormat.Bmp); } return(true); }
public bool Execute(WorkFlowCommand command, Context context) { if (context?.ImageStream == null) { return(true); } if (!CheckCondition(command, context)) { return(true); } context.ImageStream.Seek(0, SeekOrigin.Begin); using (MagickImage image = new MagickImage(context.ImageStream)) { context.ImageStream.Seek(0, SeekOrigin.Begin); image.BrightnessContrast(new Percentage((double)context.WorkFlow.Variables[command.Properties["Brightness"].ToString(context)].GetAsObject()), new Percentage((double)context.WorkFlow.Variables[command.Properties["Contrast"].ToString(context)].GetAsObject())); image.Write(context.ImageStream, MagickFormat.Jpg); } return(true); }
public WorkFlowCommand CreateCommand() { var command = new WorkFlowCommand(); command.Properties.Add(new CustomProperty() { Name = "Action", PropertyType = CustomPropertyType.ValueList, ValueList = new List <string>() { "ShowView" } }); command.Properties.Add(new CustomProperty() { Name = "ViewName", PropertyType = CustomPropertyType.View }); return(command); }
public bool Execute(WorkFlowCommand command, Context context) { if (context?.ImageStream == null) { return(true); } if (!CheckCondition(command, context)) { return(true); } Smart.Default.Settings.ConvertCharacterStringLiterals = false; var filename = command.Properties["FileNameTemplate"].ToString(context); Utils.CreateFolder(filename); context.ImageStream.Seek(0, SeekOrigin.Begin); using (MagickImage image = new MagickImage(context.ImageStream)) { context.ImageStream.Seek(0, SeekOrigin.Begin); switch (command.Properties["FileFormat"].Value) { case "Jpg": image.Write(filename + ".jpg"); break; case "Png": image.Write(filename + ".png"); break; case "Bmp": image.Write(filename + ".bmp"); break; } } return(true); }
public bool Execute(WorkFlowCommand command, Context context) { if (!CheckCondition(command, context)) { return(true); } switch (command.Properties["Action"].Value) { case "ShowView": WorkflowManager.Instance.OnMessage(new MessageEventArgs(Messages.ShowView, command.Properties["ViewName"].ToString(context))); break; case "FinishSession": WorkflowManager.Instance.OnMessage(new MessageEventArgs(Messages.SessionFinished, context)); break; case "SaveVariables": WorkflowManager.Instance.OnMessage(new MessageEventArgs(Messages.SaveVariables, context)); break; case "CancelSession": WorkflowManager.Instance.OnMessage(new MessageEventArgs(Messages.SessionCanceled, context)); break; case "PreviousView": WorkflowManager.Instance.OnMessage(new MessageEventArgs(Messages.PreviousView, context)); break; case "UpdateThumb": WorkflowManager.Instance.OnMessage(new MessageEventArgs(Messages.ThumbCreate, context)); break; case "NextPhoto": WorkflowManager.Instance.OnMessage(new MessageEventArgs(Messages.NextPhoto, context)); break; case "PrevPhoto": WorkflowManager.Instance.OnMessage(new MessageEventArgs(Messages.PrevPhoto, context)); break; case "DeletePhoto": WorkflowManager.Instance.OnMessage(new MessageEventArgs(Messages.DeletePhoto, context)); break; case "ClearPhotos": WorkflowManager.Instance.OnMessage(new MessageEventArgs(Messages.ClearPhotos, context)); break; case "ShowHelp": WorkflowManager.Instance.OnMessage(new MessageEventArgs(Messages.ShowHelp, context)); break; case "LoadImage": { try { var stream = new MemoryStreamEx(); var buffer = File.ReadAllBytes(context.FileItem.TempFile); stream.Write(buffer, 0, buffer.Length); stream.Seek(0, SeekOrigin.Begin); context.ImageStream = stream; Log.Debug("LoadImage executed"); } catch (Exception e) { Log.Debug("Error unload image", e); } } break; case "UnLoadImage": { try { context.ImageStream?.Close(); Log.Debug("UnLoadImage executed"); } catch (Exception e) { Log.Debug("Error unload image", e); } } break; } return(true); }