public TextManageViewModel(IRegionManager regionManager, IPublisherService publisherService,
                                   ITextService textService)
        {
            mRegionManager    = regionManager;
            mPublisherService = publisherService;
            mTextService      = textService;
            var books = mPublisherService.GetPublishersAndBooks();

            foreach (var p in books)
            {
                foreach (var b in p.Books)
                {
                    var book = new BookVm
                    {
                        Title     = b.Title,
                        Id        = b.Id,
                        Publisher = p.Title
                    };
                    Books.Add(book);
                }
            }
            var texts = mTextService.GetTexts();

            foreach (var text in texts)
            {
                var book = Books.FirstOrDefault(a => a.Id == text.BookId);
                book?.Texts.Add(new TextVm
                {
                    Id    = text.Id,
                    Title = text.Title
                });
            }
        }
Пример #2
0
        public MyRootGraphic(
            int width, int height,
            ITextService ifonts)
            : base(width, height)
        {
            this._ifonts             = ifonts;
            this.graphicTimerTaskMan = new GraphicsTimerTaskManager(this);
            _defaultTextEditFont     = new RequestFont("tahoma", 10);

#if DEBUG
            dbugCurrentGlobalVRoot = this;
            dbug_Init(null, null, null);
#endif

            //create default render box***
            this.topWindowRenderBox = new TopWindowRenderBox(this, width, height);
            this.topWindowEventRoot = new TopWindowEventRoot(this.topWindowRenderBox);
            this.SubscribeGraphicsIntervalTask(normalUpdateTask,
                                               TaskIntervalPlan.Animation,
                                               20,
                                               (s, e) =>
            {
                this.PrepareRender();
                this.FlushAccumGraphics();
            });
        }
Пример #3
0
        //--------------------------------------------------------------
        #region Creation & Cleanup
        //--------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance of the <see cref="TextDocumentViewModel"/> class.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="document"/> is <see langword="null"/>.
        /// </exception>
        public TextDocumentViewModel(TextDocument document)
            : base(document)
        {
            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            var editor = document.Editor;

            // Mandatory services.
            _textService   = editor.Services.GetInstance <ITextService>().ThrowIfMissing();
            _windowService = editor.Services.GetInstance <IWindowService>().ThrowIfMissing();

            // Optional services.
            _searchService       = editor.Services.GetInstance <ISearchService>().WarnIfMissing();
            _highlightingService = editor.Services.GetInstance <IHighlightingService>().WarnIfMissing();

            _textContextMenu      = _textService.ContextMenu;
            PrintPreviewCommand   = new DelegateCommand(ShowPrintPreview);
            PrintCommand          = new DelegateCommand(Print);
            FindCommand           = new DelegateCommand(Find, CanFind);
            FindAndReplaceCommand = new DelegateCommand(FindAndReplace);
            CancelCommand         = new DelegateCommand(Cancel);
        }
Пример #4
0
 public TextsController(ITextService textService, IMapper mapper)
 {
     _textService = textService ??
                    throw new ArgumentNullException(nameof(textService));
     _mapper = mapper ??
               throw new ArgumentNullException(nameof(mapper));
 }
Пример #5
0
        public async Task GetTextEnTest()
        {
            TestingContext testingContext = new TestingContext();

            testingContext.AddAdminPrincipalMock();
            testingContext.AddInMemoryDb();
            testingContext.AddLogServiceMock();
            testingContext.AddEnglishCultureServiceMock();

            ApplicationDbContext dbContext = testingContext.GetSimple <ApplicationDbContext>();

            dbContext.Texts.Add(new Text()
            {
                Key       = "TestKey",
                ContentDe = "ContentDe  {0} {1} {2}",
                ContentEn = "ContentEn {0} {1} {2}",
            });
            await dbContext.SaveChangesAsync();

            ITextService textService = testingContext.GetService <TextService>();

            //Act
            string text = await textService.GetTextAsync("TestKey", "pl1", "pl2", "pl3");

            //Assert
            Assert.Equal("ContentEn pl1 pl2 pl3", text);
        }
Пример #6
0
        public HtmlHost(HtmlHostCreationConfig config)
        {
            //use default style sheet

#if DEBUG
            if (!config.ValidateConfig())
            {
                throw new NotSupportedException();
            }
#endif

            _commonHtmlDoc = new HtmlDocument(this);
            if (config.ActiveSheet != null)
            {
                _commonHtmlDoc.CssActiveSheet = this.BaseStylesheet = config.ActiveSheet;
            }
            else
            {
                //use default
                _commonHtmlDoc.CssActiveSheet = this.BaseStylesheet =
                    LayoutFarm.WebDom.Parser.CssParserHelper.ParseStyleSheet(null,
                                                                             LayoutFarm.Composers.CssDefaults.DefaultCssData,
                                                                             true);
            }
            _rootgfx = config.RootGraphic;

            _textservice = config.TextService;
            _svgCreator  = new PaintLab.Svg.SvgCreator();
        }
Пример #7
0
 public DataController(ISecurityService securityService,
                       IBinaryService binaryService,
                       IQuestionService questionService,
                       IVersionService versionService,
                       ITagService tagService,
                       ICourseService courseService,
                       ICommentsService commentsService,
                       IUserProfileService userProfileService,
                       ICourseInstanceService courseInstanceService,
                       ITextService textService,
                       IExportService exportService,
                       INotificationService notificationService,
                       IFavoriteService favoriteService)
 {
     _securityService       = securityService;
     _binaryService         = binaryService;
     _questionService       = questionService;
     _tagService            = tagService;
     _courseService         = courseService;
     _commentsService       = commentsService;
     _userProfileService    = userProfileService;
     _courseInstanceService = courseInstanceService;
     _textService           = textService;
     _exportService         = exportService;
     _versionService        = versionService;
     _notificationService   = notificationService;
     _favoriteService       = favoriteService;
 }
Пример #8
0
        public override void Render(IDrawingContext context)
        {
            Rect rect = new Rect(this.ActualSize);

            context.DrawText(Brushes.Black, rect, this.FormattedText);

            if (this.parent.IsFocused)
            {
                ITextService textService = Locator.Current.GetService <ITextService>();
                Point        caretPos    = textService.GetCaretPosition(
                    this.formattedText,
                    this.parent.CaretIndex,
                    this.ActualSize);
                double[] lineHeights = textService.GetLineHeights(this.formattedText, this.ActualSize);
                Brush    caretBrush  = Brushes.Black;

                if (this.caretBlink)
                {
                    context.DrawLine(
                        new Pen(caretBrush, 1),
                        caretPos,
                        new Point(caretPos.X, caretPos.Y + lineHeights[0]));
                }
            }
        }
Пример #9
0
 public void TestSetUp()
 {
     _cityRepository  = new Mock <ICityRepository>();
     _textRepository  = new Mock <ITextRepository>();
     _locationService = new Mock <ILocationService>();
     _textService     = new TextService(_cityRepository.Object, _textRepository.Object, _locationService.Object);
 }
Пример #10
0
        void SetupStartHitPoint(CssBoxHitChain startChain, ITextService textService)
        {
            //find global location of start point
            HitInfo startHit = startChain.GetLastHit();

            //-----------------------------
            _startHitRun          = null;
            _startHitRunCharIndex = 0;
            switch (startHit.hitObjectKind)
            {
            case HitObjectKind.Run:
            {
                CssRun run = (CssRun)startHit.hitObject;
                //-------------------------------------------------------
                int sel_index;
                int sel_offset;
                run.FindSelectionPoint(textService,
                                       startHit.localX,
                                       out sel_index,
                                       out sel_offset);
                _startHitRunCharIndex = sel_index;
                //modify hitpoint
                _startHitHostLine = (CssLineBox)startChain.GetHitInfo(startChain.Count - 2).hitObject;
                _startLineBeginSelectionAtPixel = (int)(run.Left + sel_offset);
                _startHitRun = run;
            }
            break;

            case HitObjectKind.LineBox:
            {
                _startHitHostLine = (CssLineBox)startHit.hitObject;
                _startLineBeginSelectionAtPixel = startHit.localX;
                //make global
            }
            break;

            case HitObjectKind.CssBox:
            {
                CssBox box = (CssBox)startHit.hitObject;
                //find first nearest line at point
                CssLineBox startHitLine = FindNearestLine(box, startChain.RootGlobalY, 5);
                _startLineBeginSelectionAtPixel = 0;
                if (startHitLine != null)
                {
                    _startHitHostLine = startHitLine;
                }
                else
                {
                    //if not found?
                    _startHitHostLine = null;
                }
            }
            break;

            default:
            {
                throw new NotSupportedException();
            }
            }
        }
Пример #11
0
        public GameManager(ITextService textService, IMenuActionService menuActionService, ICreatureService creatureService)
        {
            this._menuActionService = menuActionService;
            this._textService       = textService;

            _instructionsManager = new InstructionsManager(menuActionService, textService);
            _fightManager        = new FightManager(textService, creatureService);
        }
Пример #12
0
 public static ITextService GetTextService()
 {
     if (s_textService == null)
     {
         s_textService = PixelFarm.Drawing.WinGdi.WinGdiPlusPlatform.GetTextService();
     }
     return(s_textService);
 }
Пример #13
0
        public MainViewModel(IConfiguration configuration, ITextService textService)
        {
            _configuration = configuration;
            _textService   = textService;

            Debug.WriteLine($"Value from config: {_configuration["MyKey"]}");
            Debug.WriteLine($"Value from TextService: {_textService.GetText()}");
        }
Пример #14
0
        public MainPresenter(IMainView view, ITextService service) : base(view)
        {
            _service = service;
            _timer   = new Timer(new TimerCallback(ChangeColor), null, -1, -1);

            View.FlashIntervalChanged += () => FlashIntervalChanged(View.Interval);
            View.ViewClosed           += () => ViewClosed(view.WorkableText);
        }
        public object ToStringWith(ITextService textServiceValue)
        {
            if (IsKey)
            {
                return(textServiceValue.Compile(KeyOrValue, CultureInfo.CurrentUICulture, out _));
            }

            return(KeyOrValue);
        }
Пример #16
0
        private HtmlHost(WebDom.CssActiveSheet activeSheet)
        {
            this.BaseStylesheet = activeSheet;
            this.commonHtmlDoc  = new HtmlDocument();
            this.commonHtmlDoc.CssActiveSheet = activeSheet;


            this._textservice = MyFontServices.GetTextService();
        }
Пример #17
0
        public XamlApp(IServiceProvider services, ITextService textService)
        {
            InitializeComponent();

            Services = services;

            Debug.WriteLine($"The .NET Purple color is {Resources["DotNetPurple"]}");
            Debug.WriteLine($"The injected text service had a message: '{textService.GetText()}'");
        }
Пример #18
0
        /// <summary>
        /// Initializes a new instance of <see cref="TextController"/>.
        /// </summary>
        /// <param name="textService">The text service.</param>
        public TextController(ITextService textService)
        {
            if (textService == null)
            {
                throw new ArgumentNullException("textService");
            }

            _textService = textService;
        }
Пример #19
0
 public Logic(
     IConsoleService consoleService,
     ITextService textService,
     IMapper mapper)
 {
     this.consoleService = consoleService;
     this.mapper         = mapper;
     this.textService    = textService;
 }
Пример #20
0
 public void Bind(HtmlVisualRoot htmlVisualRoot)
 {
     _htmlVisualRoot = htmlVisualRoot;
     _isBinded       = htmlVisualRoot != null;
     if (_isBinded)
     {
         _textService = htmlVisualRoot.GetTextService();
     }
 }
Пример #21
0
        public GetText()
        {
            var repository = A.Fake <ITextRepository>();

            service = new TextService(repository);

            A.CallTo(() => repository.GetWelcomeText())
            .Returns(new TextEntity("TEST"));
        }
Пример #22
0
        protected override Size MeasureOverride(Size constraint)
        {
            if (!string.IsNullOrEmpty(this.parent.Text))
            {
                ITextService textService = Locator.Current.GetService <ITextService>();
                return(textService.Measure(this.FormattedText, constraint));
            }

            return(new Size());
        }
Пример #23
0
 private static ISafeString GetSut(ITextService textService = null,
                                   IFactory <ISafeString> safeStringFactory = null,
                                   ISafeStringToStringMarshaler marshaler   = null)
 {
     return(new SafeString(
                textService ?? Stubs.Get <ITextService>(),
                safeStringFactory ?? Stubs.GetFactory <ISafeString>(),
                Stubs.GetFactory <ISafeBytes>(),
                marshaler ?? Stubs.Get <ISafeStringToStringMarshaler>()));
 }
        public MainShell(ITextService textService, INavigationService navigationService)
        {
            _textService = textService;

            this.InitializeComponent();

            var rootFrame = Content as Frame;

            navigationService.InitializeFrame(rootFrame);
        }
Пример #25
0
        public MainPageViewModel(IEnumerable <ITextService> textServices)
        {
            Configuration = App.Current.Services.GetService <IConfiguration>();

            //var logger = App.Current.Services.GetService<ILogger<MainPageViewModel>>();

            //logger.LogInformation("hello");

            textService = textServices.FirstOrDefault();
            Text        = textService.GetText();
        }
Пример #26
0
        public TextServiceUsingLocalizationProvider(ITextService textService)
        {
            _textService = textService;
            _textService.TranslationLoaded += _textService_TranslationLoaded;
            AvailableCultures = new ObservableCollection <CultureInfo>();

            foreach (var textServiceSupportedCulture in _textService.SupportedCultures)
            {
                AvailableCultures.Add(textServiceSupportedCulture.Value);
            }
        }
Пример #27
0
        public static void CreateCanvasControlOnExistingControl(
            Control landingControl,
            int xpos, int ypos,
            int w, int h,
            InnerViewportKind internalViewportKind,
            out UISurfaceViewportControl canvasViewport)
        {
            //1. init
            InitWinform();
            IInstalledTypefaceProvider fontLoader = s_fontstore;
            //2.
            ITextService textService = null;

            switch (internalViewportKind)
            {
            default:
                //gdi, gdi on gles
                textService = PixelFarm.Drawing.WinGdi.WinGdiPlusPlatform.GetTextService();
                break;

            case InnerViewportKind.PureAgg:
            case InnerViewportKind.AggOnGLES:
            case InnerViewportKind.GLES:
                textService = new OpenFontTextService();
                break;
            }

            PixelFarm.Drawing.WinGdi.WinGdiPlusPlatform.SetInstalledTypefaceProvider(fontLoader);
            //---------------------------------------------------------------------------

            MyRootGraphic myRootGfx = new MyRootGraphic(w, h, textService);
            //---------------------------------------------------------------------------

            var       innerViewport        = canvasViewport = new UISurfaceViewportControl();
            Rectangle screenClientAreaRect = Conv.ToRect(Screen.PrimaryScreen.WorkingArea);

            canvasViewport.InitRootGraphics(myRootGfx, myRootGfx.TopWinEventPortal, internalViewportKind);
            canvasViewport.Bounds =
                new System.Drawing.Rectangle(xpos, ypos,
                                             screenClientAreaRect.Width,
                                             screenClientAreaRect.Height);

            landingControl.Controls.Add(canvasViewport);
            //
            Form ownerForm = landingControl.FindForm();

            if (ownerForm != null)
            {
                ownerForm.FormClosing += (s, e) =>
                {
                    innerViewport.Close();
                };
            }
        }
Пример #28
0
        public override void UpdateRunWidth()
        {
            ITextService txServices = Root.TextServices;
            Size         size;

            if (IsLineBreak)
            {
                //TODO: review here
                //we should not store this as a text run
                //if this is a linebreak it should be encoded at the end of this visual line
                size = new Size(0, (int)Math.Round(txServices.MeasureBlankLineHeight(GetFont())));
                _outputUserCharAdvances = null;
            }
            else
            {
                //TODO: review here again
                //1. after GSUB process, output glyph may be more or less
                //than original input char buffer(mybuffer)

                if (txServices.SupportsWordBreak)
                {
                    var textBufferSpan = new TextBufferSpan(_mybuffer);
                    int len            = _mybuffer.Length;
                    if (_content_unparsed)
                    {
                        //parse the content first
                        _lineSegs = txServices.BreakToLineSegments(ref textBufferSpan);
                    }
                    //
                    _content_unparsed = false;
                    //output glyph position
                    _outputUserCharAdvances = new int[len];

                    int outputTotalW, outputLineHeight;
                    txServices.CalculateUserCharGlyphAdvancePos(ref textBufferSpan, _lineSegs, GetFont(),
                                                                _outputUserCharAdvances, out outputTotalW, out outputLineHeight);
                    size = new Size(outputTotalW, outputLineHeight);
                }
                else
                {
                    _content_unparsed = false;
                    int len = _mybuffer.Length;
                    _outputUserCharAdvances = new int[len];
                    int outputTotalW, outputLineHeight;
                    var textBufferSpan = new TextBufferSpan(_mybuffer);
                    txServices.CalculateUserCharGlyphAdvancePos(ref textBufferSpan, GetFont(),
                                                                _outputUserCharAdvances, out outputTotalW, out outputLineHeight);
                    size = new Size(outputTotalW, outputLineHeight);
                }
            }
            //---------
            this.SetSize(size.Width, size.Height);
            MarkHasValidCalculateSize();
        }
Пример #29
0
        private HtmlHost(WebDom.CssActiveSheet activeSheet)
        {
            this.BaseStylesheet = activeSheet;
            this.commonHtmlDoc  = new HtmlDocument();
            this.commonHtmlDoc.CssActiveSheet = activeSheet;


            this._textservice = MyFontServices.GetTextService();
            HtmlContainerTextService.SetTextService(this._textservice);
            _svgCreator = new Svg.SvgCreator();
        }
Пример #30
0
        public void TestSetUp()
        {
            _cityRepository  = new CityRepository(_dbConnStr);
            _textRepository  = new TextRepository(_dbConnStr);
            _apiService      = new ApiService();
            _locationService = new LocationService(_cityRepository, _apiService);
            _textService     = new TextService(_cityRepository, _textRepository, _locationService);

            _textController               = new TextController(_textService);
            _textController.Request       = new HttpRequestMessage();
            _textController.Configuration = new HttpConfiguration();
        }
Пример #31
0
        //--------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="TextDocumentViewModel"/> class.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="document"/> is <see langword="null"/>.
        /// </exception>
        public TextDocumentViewModel(TextDocument document)
            : base(document)
        {
            if (document == null)
                throw new ArgumentNullException(nameof(document));

            var editor = document.Editor;

            // Mandatory services.
            _textService = editor.Services.GetInstance<ITextService>().ThrowIfMissing();
            _windowService = editor.Services.GetInstance<IWindowService>().ThrowIfMissing();

            // Optional services.
            _searchService = editor.Services.GetInstance<ISearchService>().WarnIfMissing();
            _highlightingService = editor.Services.GetInstance<IHighlightingService>().WarnIfMissing();

            _textContextMenu = _textService.ContextMenu;
            PrintPreviewCommand = new DelegateCommand(ShowPrintPreview);
            PrintCommand = new DelegateCommand(Print);
            FindCommand = new DelegateCommand(Find, CanFind);
            FindAndReplaceCommand = new DelegateCommand(FindAndReplace);
            CancelCommand = new DelegateCommand(Cancel);
        }
 public TextController(ITextService textService)
 {
     this.textService = textService;
 }
Пример #33
0
 public ModuleAViewOneViewModel(ITextService textService)
 {
     _textService = textService;
 }
        public TextServiceDirectWrite()
        {
            try
            {
                interop = new TextServiceDirectWriteInterop();
            }
            catch (Exception exception)
            {
                // dll load issue
                Debugger.Break();
                MessageBox.Show("Failed to load DirectWrite interop dll: " + exception.ToString());
            }

            #if true
            uniscribeService = new TextServiceUniscribe();
            #else // TODO: support Windows.Data.Text for universal script segmentation support
            #endif
        }