protected override void ExecuteAction(string ribbonId) { IMessageService cropLabMessageService = MessageServiceFactory.GetCropLabMessageService(); CropLabErrorHandler errorHandler = CropLabErrorHandler.InitializeErrorHandler(cropLabMessageService); Selection selection = this.GetCurrentSelection(); if (!ShapeUtil.IsSelectionShape(selection)) { HandleInvalidSelectionError(CropLabErrorHandler.ErrorCodeSelectionIsInvalid, FeatureName, CropLabErrorHandler.SelectionTypePicture, 1, errorHandler); return; } ShapeRange shapeRange = ShapeUtil.GetShapeRange(selection); if (shapeRange.Count < 1) { HandleInvalidSelectionError(CropLabErrorHandler.ErrorCodeSelectionIsInvalid, FeatureName, CropLabErrorHandler.SelectionTypePicture, 1, errorHandler); return; } if (!ShapeUtil.IsAllPicture(shapeRange)) { HandleErrorCode(CropLabErrorHandler.ErrorCodeSelectionMustBePicture, FeatureName, errorHandler); return; } try { ShapeRange result = CropOutPadding.Crop(shapeRange); result?.Select(); } catch (CropLabException e) { HandleCropLabException(e, FeatureName, errorHandler); } }
protected override void ExecuteAction(string ribbonId) { IMessageService cropLabMessageService = MessageServiceFactory.GetCropLabMessageService(); CropLabErrorHandler errorHandler = CropLabErrorHandler.InitializeErrorHandler(cropLabMessageService); if (!ShapeUtil.IsSelectionShape(this.GetCurrentSelection())) { HandleInvalidSelectionError(CropLabErrorHandler.ErrorCodeSelectionIsInvalid, FeatureName, CropLabErrorHandler.SelectionTypeShapeOrPicture, 1, errorHandler); return; } ShapeRange shapeRange = this.GetCurrentSelection().ShapeRange; if (shapeRange.Count < 1) { HandleInvalidSelectionError(CropLabErrorHandler.ErrorCodeSelectionIsInvalid, FeatureName, CropLabErrorHandler.SelectionTypeShapeOrPicture, 1, errorHandler); return; } if (!ShapeUtil.IsAllPictureOrShape(shapeRange)) { HandleErrorCode(CropLabErrorHandler.ErrorCodeSelectionMustBeShapeOrPicture, FeatureName, errorHandler); return; } float slideWidth = this.GetCurrentPresentation().SlideWidth; float slideHeight = this.GetCurrentPresentation().SlideHeight; bool hasChange = CropToSlide.Crop(shapeRange, this.GetCurrentSlide(), slideWidth, slideHeight); if (!hasChange) { HandleErrorCode(CropLabErrorHandler.ErrorCodeNoShapeOverBoundary, FeatureName, errorHandler); } }
private void ExecuteCropToAspectRatio(string aspectRatioRawString) { IMessageService cropLabMessageService = MessageServiceFactory.GetCropLabMessageService(); CropLabErrorHandler errorHandler = CropLabErrorHandler.InitializeErrorHandler(cropLabMessageService); Selection selection = this.GetCurrentSelection(); float aspectRatioWidth = 0.0f; float aspectRatioHeight = 0.0f; if (!TryParseAspectRatio(aspectRatioRawString, out aspectRatioWidth, out aspectRatioHeight)) { HandleErrorCode(CropLabErrorHandler.ErrorCodeAspectRatioIsInvalid, FeatureName, errorHandler); return; } float aspectRatio = aspectRatioWidth / aspectRatioHeight; try { CropToAspectRatio.Crop(selection, aspectRatio); } catch (CropLabException e) { HandleCropLabException(e, FeatureName, errorHandler); } }
protected override void ExecuteAction(string ribbonId) { this.StartNewUndoEntry(); IMessageService cropLabMessageService = MessageServiceFactory.GetCropLabMessageService(); CropLabErrorHandler errorHandler = CropLabErrorHandler.InitializeErrorHandler(cropLabMessageService); if (!ShapeUtil.IsSelectionShape(this.GetCurrentSelection())) { HandleInvalidSelectionError(CropLabErrorHandler.ErrorCodeSelectionIsInvalid, FeatureName, CropLabErrorHandler.SelectionTypeShape, 1, errorHandler); return; } ShapeRange shapeRange = this.GetCurrentSelection().ShapeRange; if (shapeRange.Count < 1) { HandleInvalidSelectionError(CropLabErrorHandler.ErrorCodeSelectionIsInvalid, FeatureName, CropLabErrorHandler.SelectionTypeShape, 1, errorHandler); return; } if (!ShapeUtil.IsAllShape(shapeRange)) { HandleErrorCode(CropLabErrorHandler.ErrorCodeSelectionMustBeShape, FeatureName, errorHandler); return; } try { CropToShape.Crop(this.GetCurrentSlide(), this.GetCurrentSelection()); } catch (CropLabException) { HandleErrorCode(CropLabErrorHandler.ErrorCodeUndefined, FeatureName, errorHandler); } }
protected override void ExecuteAction(string ribbonId) { IMessageService cropLabMessageService = MessageServiceFactory.GetCropLabMessageService(); CropLabErrorHandler errorHandler = CropLabErrorHandler.InitializeErrorHandler(cropLabMessageService); if (!ShapeUtil.IsSelectionShape(this.GetCurrentSelection())) { HandleInvalidSelectionError(CropLabErrorHandler.ErrorCodeSelectionIsInvalid, FeatureName, CropLabErrorHandler.SelectionTypePicture, 2, errorHandler); return; } ShapeRange shapeRange = this.GetCurrentSelection().ShapeRange; if (shapeRange.Count < 2) { HandleInvalidSelectionError(CropLabErrorHandler.ErrorCodeSelectionIsInvalid, FeatureName, CropLabErrorHandler.SelectionTypePicture, 2, errorHandler); return; } if (!ShapeUtil.IsAllPictureWithReferenceObject(shapeRange)) { HandleErrorCode(CropLabErrorHandler.ErrorCodeSelectionMustBePicture, FeatureName, errorHandler); return; } bool hasChange = CropToSame.CropSelection(shapeRange); if (!hasChange) { HandleErrorCode(CropLabErrorHandler.ErrorCodeNoDimensionCropped, FeatureName, errorHandler); } }
static void Main(string[] args) { IPerson person = PersonFactory.CreatePerson(); IPerson sponsor = PersonFactory.CreatePerson(); IMessageService messageService = MessageServiceFactory.CreateMessageService(person, sponsor); string message = messageService.SendMessage(person, sponsor); System.Console.WriteLine(message); }
protected override void OnStartup(StartupEventArgs e) { LogUtil.LogInfo("App", "OnStartup", "Staring up."); base.OnStartup(e); var window = new Shell(); // Create the ViewModel to which // the main window binds. _viewModel = new MainWindowViewModel(MessageServiceFactory.GetMessagingServiceInstance()); //Set the view models to the windows data context. window.DataContext = _viewModel; window.Show(); //Register views for secondary windows. ModalViewRegistry.Instance.RegisterView(Constants.HELP_VIEW, typeof(HelpView)); ModalViewRegistry.Instance.RegisterView(Constants.PICTURE_PICKER_VIEW, typeof(ImagePickerView)); }
protected override void ExecuteAction(string ribbonId) { IMessageService cropLabMessageService = MessageServiceFactory.GetCropLabMessageService(); CropLabErrorHandler errorHandler = CropLabErrorHandler.InitializeErrorHandler(cropLabMessageService); Selection selection = this.GetCurrentSelection(); if (!ShapeUtil.IsSelectionShape(selection)) { HandleInvalidSelectionError(CropLabErrorHandler.ErrorCodeSelectionIsInvalid, FeatureName, CropLabErrorHandler.SelectionTypePicture, 1, errorHandler); return; } ShapeRange shapeRange = selection.ShapeRange; if (shapeRange.Count < 1) { HandleInvalidSelectionError(CropLabErrorHandler.ErrorCodeSelectionIsInvalid, FeatureName, CropLabErrorHandler.SelectionTypePicture, 1, errorHandler); return; } if (!ShapeUtil.IsAllPicture(shapeRange)) { HandleErrorCode(CropLabErrorHandler.ErrorCodeSelectionMustBePicture, FeatureName, errorHandler); return; } if (ribbonId.Contains(CommonText.DynamicMenuButtonId)) { CustomAspectRatioDialogBox dialog = new CustomAspectRatioDialogBox(shapeRange[1]); dialog.DialogConfirmedHandler += ExecuteCropToAspectRatio; dialog.ShowDialog(); } else if (ribbonId.Contains(CommonText.DynamicMenuOptionId)) { int optionRawStringStartIndex = ribbonId.LastIndexOf(CommonText.DynamicMenuButtonId) + CommonText.DynamicMenuOptionId.Length; string optionRawString = ribbonId.Substring(optionRawStringStartIndex).Replace('_', ':'); ExecuteCropToAspectRatio(optionRawString); } }
public void Setup() { _mockApiConnection = MockRepository.GenerateMock <IApiConnection>(); _mockMarketInformationServiceFactory = MockRepository.GenerateMock <MarketInformationServiceFactory>(); _mockAccountInformationServiceFactory = MockRepository.GenerateMock <AccountInformationServiceFactory>(); _mockCfdMarketServiceFactory = MockRepository.GenerateMock <CfdMarketServiceFactory>(); _mockOrderServiceFactory = MockRepository.GenerateMock <OrderServiceFactory>(); _mockFutureOptionServiceFactory = MockRepository.GenerateMock <FutureOptionServiceFactory>(); _mockMessageServiceFactory = MockRepository.GenerateMock <MessageServiceFactory>(); _mockNewsServiceFactory = MockRepository.GenerateMock <NewsServiceFactory>(); _spreadMarketServiceFactory = MockRepository.GenerateMock <SpreadMarketServiceFactory>(); _serviceManager = new ServiceManager(); _serviceManager.SetUpServiceManagerForMocking( _mockApiConnection, _mockMarketInformationServiceFactory, _mockAccountInformationServiceFactory, _mockCfdMarketServiceFactory, _mockOrderServiceFactory, _mockFutureOptionServiceFactory, _mockMessageServiceFactory, _mockNewsServiceFactory, _spreadMarketServiceFactory); }
public void FutureOptionServiceFactoryCreatesFutureOptionServiceWithAValidApiConnection() { var service = new MessageServiceFactory().Create(_mockApiConnection); Assert.IsInstanceOfType(typeof(MessageService), service); }