示例#1
0
        public static void GetTranslations(TranslateCommand translateCommand)
        {
            foreach (string lang in translateCommand.Translations.Keys)
            {
                int counter = 0;
                Newtonsoft.Json.Linq.JArray requestTexts = new Newtonsoft.Json.Linq.JArray();

                while (counter <= 24 && counter < translateCommand.Translations[lang].Stories.Count)
                {
                    JObject text = new JObject();
                    text.Add("Text", translateCommand.Translations[lang].Stories[counter].Title);
                    requestTexts.Add(text);
                    counter++;
                }

                List <string> translations = GetTranslation(requestTexts, lang, translateCommand.DisplayLanguage).Result;

                if (translations.Count > 0)
                {
                    for (int i = 0; i < translations.Count; i++)
                    {
                        translateCommand.Translations[lang].Stories[i].TranslatedTitle = translations[i];
                    }
                }
            }
        }
示例#2
0
 public AbpCliTranslateAppService(
     TranslateCommand translateCommand,
     ICurrentDirectoryHelper currentDirectoryHelper)
 {
     _translateCommand       = translateCommand;
     _currentDirectoryHelper = currentDirectoryHelper;
 }
 public void Initialize(INavigationParameters parameters)
 {
     InputText = parameters[ConfigPage.TranslatePage] as string;
     if (!string.IsNullOrWhiteSpace(InputText))
     {
         TranslateCommand.Execute();
     }
 }
示例#4
0
 private void TranslateObject()
 {
     LastCommand?.Deactivate(Application.Current.MainWindow);
     LastCommand          = new TranslateCommand(Application.Current.MainWindow, SelectedObject);
     LastCommand.OnApply += () =>
     {
         LastCommand.Deactivate(Application.Current.MainWindow);
         LastCommand = null;
     };
 }
示例#5
0
        public void InsertInUnDoRedoForTranslate(int xAmmount, int yAmmount, Api.Shapes.Rectangle rectangle)
        {
            ICommand iCommand = new TranslateCommand(xAmmount, yAmmount, rectangle);

            undoCommands.Push(iCommand);
            redoCommands.Clear();
            if (EnableDisableUndoRedoFeature != null)
            {
                EnableDisableUndoRedoFeature(null, null);
            }
        }
示例#6
0
        public ActionResult <WorldStoryRecords> Get([FromQuery] int count = 10, [FromQuery] string displayLanguage = "en")
        {
            NosyBot.Services.Repositories.NosyRepository repo = new NosyBot.Services.Repositories.NosyRepository();

            WorldStoryRecords records = repo.GetRegionStories(count);

            TranslateCommand translate = new TranslateCommand()
            {
                DisplayLanguage = displayLanguage
            };

            // Now translate AMERICAS if necessary
            foreach (StoryRecord story in records.Americas)
            {
                story.TranslatedTitle = story.Title;

                if (story.Language != null && story.Language != displayLanguage)
                {
                    translate.AddStory(story);
                }
                //story.TranslatedTitle = NosyBot.Services.Utilities.ServiceProxies.GetTranslation(story.Title, story.Language, displayLanguage).Result;
            }

            // EMEA
            foreach (StoryRecord story in records.EMEA)
            {
                story.TranslatedTitle = story.Title;

                if (story.Language != null && story.Language != displayLanguage)
                {
                    translate.AddStory(story);
                }
                //story.TranslatedTitle = NosyBot.Services.Utilities.ServiceProxies.GetTranslation(story.Title, story.Language, displayLanguage).Result;
            }

            // APAC
            foreach (StoryRecord story in records.APAC)
            {
                story.TranslatedTitle = story.Title;

                if (story.Language != null && story.Language != displayLanguage)
                {
                    translate.AddStory(story);
                }
                //story.TranslatedTitle = NosyBot.Services.Utilities.ServiceProxies.GetTranslation(story.Title, story.Language, displayLanguage).Result;
            }

            NosyBot.Services.Utilities.ServiceProxies.GetTranslations(translate);

            return(records);
        }
示例#7
0
        public void OnMouseUp(object sender, MouseEventArgs e)
        {
            if (Move)
            {
                foreach (IDrawingObject obj in this.targetObj)
                {
                    TranslateCommand command = new TranslateCommand(obj, lastDiff);
                    this.canvas.AddCommand(command);
                }
                Move = false;
            }

            StateLeftMouseDown = false;
            this.lastDiff      = new Point(0, 0);
        }
示例#8
0
        public void ControllerCommandUndoRedo()
        {
            //Set up the model
            Model model = new Model();

            model.SetSize(new SizeF(1000, 1000)); //Set the container size so that the shape can be moved

            //Set up the shape element
            Shape shape = new Shape();

            shape.Location = new PointF(100, 100);
            model.Shapes.Add("Shape1", shape);

            //Set up the controller
            Controller controller = new Controller(model);

            //Set up the action
            shape.ActionElement = controller.CloneElement(shape);

            //Set up the command
            TranslateCommand command = controller.CommandFactory.CreateTranslateCommand();

            command.Elements = new ElementList(true);
            command.Elements.Add(shape);
            command.Dx = 20;
            command.Dy = 30;

            //Translate the action and execute the command
            command.Translate();
            controller.ExecuteCommand(command);

            Assert.IsTrue(shape.Location == new PointF(120, 130), "Translate command not applied correctly to controller.");
            Assert.IsTrue(controller.UndoStack.Count == 1, "Controller undo stack is not correct.");

            controller.UndoCommand();

            Assert.IsTrue(shape.Location == new PointF(100, 100), "Command Undo not applied correctly to controller.");
            Assert.IsTrue(controller.RedoStack.Count == 1, "Controller redo stack is not correct.");

            controller.RedoCommand();

            Assert.IsTrue(shape.Location == new PointF(120, 130), "Translate command not redone correctly on controller.");
            Assert.IsTrue(controller.UndoStack.Count == 1, "Controller undo stack is not correct after redo.");
            Assert.IsTrue(controller.RedoStack.Count == 0, "Controller redo stack is not correct after redo.");
        }
示例#9
0
        public ActionResult <List <StoryRecord> > Get(string country = "us", [FromQuery] int count = 10, [FromQuery] string displayLanguage = "en")
        {
            NosyBot.Services.Repositories.NosyRepository repo = new NosyBot.Services.Repositories.NosyRepository();

            List <StoryRecord> records   = repo.GetLatestStoriesForCountry(country, count);
            TranslateCommand   translate = new TranslateCommand()
            {
                DisplayLanguage = displayLanguage
            };

            foreach (StoryRecord story in records)
            {
                story.TranslatedTitle = story.Title;

                if (story.Language != null && story.Language != displayLanguage)
                {
                    translate.AddStory(story);
                }
            }

            NosyBot.Services.Utilities.ServiceProxies.GetTranslations(translate);

            return(records);
        }
示例#10
0
        public ActionResult <ContinentStoryRecords> Continents([FromQuery] int count = 10, [FromQuery] string displayLanguage = "en")
        {
            NosyBot.Services.Repositories.NosyRepository repo = new NosyBot.Services.Repositories.NosyRepository();

            ContinentStoryRecords records = repo.GetContinentStories(count);

            TranslateCommand translate = new TranslateCommand()
            {
                DisplayLanguage = displayLanguage
            };

            // Translate NA
            foreach (StoryRecord story in records.NorthAmerica)
            {
                story.TranslatedTitle = story.Title;
                if (story.Language != null && story.Language != displayLanguage)
                {
                    translate.AddStory(story);
                }
            }

            // Translate SA
            foreach (StoryRecord story in records.SouthAmerica)
            {
                story.TranslatedTitle = story.Title;
                if (story.Language != null && story.Language != displayLanguage)
                {
                    translate.AddStory(story);
                }
            }

            // Translate EU
            foreach (StoryRecord story in records.Europe)
            {
                story.TranslatedTitle = story.Title;
                if (story.Language != null && story.Language != displayLanguage)
                {
                    translate.AddStory(story);
                }
            }

            // Translate AS
            foreach (StoryRecord story in records.Asia)
            {
                story.TranslatedTitle = story.Title;
                if (story.Language != null && story.Language != displayLanguage)
                {
                    translate.AddStory(story);
                }
            }

            // Translate AF
            foreach (StoryRecord story in records.Africa)
            {
                story.TranslatedTitle = story.Title;
                if (story.Language != null && story.Language != displayLanguage)
                {
                    translate.AddStory(story);
                }
            }

            // Translate AU
            foreach (StoryRecord story in records.Australia)
            {
                story.TranslatedTitle = story.Title;
                if (story.Language != null && story.Language != displayLanguage)
                {
                    translate.AddStory(story);
                }
            }

            NosyBot.Services.Utilities.ServiceProxies.GetTranslations(translate);

            return(records);
        }