void InkStringView_Loaded(object sender, RoutedEventArgs e) { TextBlock tb = sender as TextBlock; Typeface typeface = new Typeface( tb.FontFamily, tb.FontStyle, tb.FontWeight, tb.FontStretch); FormattedText formattedText = new FormattedText( tb.Text, System.Threading.Thread.CurrentThread.CurrentCulture, tb.FlowDirection, typeface, tb.FontSize, tb.Foreground); StringViewModel svm = tb.DataContext as StringViewModel; svm.Bounds = formattedText.GetBoundingRect(); svm.MidlineY1 = svm.MidlineY2 = svm.Bounds.Top + 0.45 * (formattedText.Baseline - svm.Bounds.Top); double width = tb.ActualWidth; double height = tb.ActualHeight; var parent = VisualTreeHelper.GetParent(this); while (!(parent is Window)) { parent = VisualTreeHelper.GetParent(parent); } GeneralTransform gt = tb.TransformToAncestor(parent as UIElement); Point offset = gt.Transform(new Point(0, 0)); double controlTop = offset.Y; double controlLeft = offset.X; }
public async Task <IActionResult> SaveSearchData(int requestId, [FromBody] StringViewModel resultJson) { // on change le status request on le met à 3 await _requestGateway.ChangeStatusRequest(requestId, 3); // recup le project Id RequestData request = await _requestGateway.GetRequestById(requestId); // Verifier que le noeud existe tjrs if (_dGraphGateway.NodeExists(request.ProjectId, request.UidNode)) { List <NodeSearchData> nodesSearchData = JsonConvert.DeserializeObject <List <NodeSearchData> >(resultJson.Key); List <AddNodesToNodeData> nodes = await _dGraphGateway.CreateAddNodesToNodeData(request.ProjectId, request.Author, request.UidNode, nodesSearchData); await _dGraphGateway.AddNodesToNode(request.ProjectId, request.UidNode, nodes); _requestGateway.DeleteRequest(requestId); FluentResults.Result <string> resultNodes = await _dGraphGateway.FindByProjectId(request.ProjectId); // On envoit message à tous les gens du projet string nameProject = await GetProjectName(request.ProjectId); IEnumerable <string> userInProject = await _projectGateway.GetIdUserInProject(request.ProjectId); await _graphHub.ReceiveRequestDoneGiveNewNode(userInProject.ToList(), resultNodes.Value, request.DataEntity); await _projectHub.ReceiveRequestDone(userInProject.ToList(), Convert.ToString(request.ProjectId), request.DataEntity, nameProject); } return(Ok("Request done")); }
public ActionResult DeleteClassModalView(string classId) { StringViewModel str = new StringViewModel(); str.str = classId; return(PartialView(str)); }
public IActionResult Index() { StringViewModel svm = new StringViewModel { Documents = _db.Documents.Include(s => s.DocumentStrings) }; return(View(svm)); }
public void AddTestHelper() { var target = new DynamicViewModel(); ObjectViewModel <string> ob = new StringViewModel(); ob.Value = "Test"; target.Add(ob); Assert.IsTrue(target.Values.Count == 1); Assert.AreEqual("Test", ((ObjectViewModel <string>)target.Values[0]).Value); }
public IActionResult GetByTeam(StringViewModel selecao) { // retorna uma seleção e desta seleção é retirada uma lista de jogos Selecao jogosBuscado = _jogoRepository.ListarPorSelecao(selecao.Nome); if (jogosBuscado.JogoSelecaoCasaNavigation != null || jogosBuscado.JogoSelecaoVisitanteNavigation != null) { return(Ok(jogosBuscado)); } return(NotFound("Nenhum jogo encontrado para a seleção buscada")); }
public IActionResult GetByStadium(StringViewModel estadio) { List <Jogo> jogosBuscado = _jogoRepository.ListarPorEstadio(estadio.Nome); if (jogosBuscado.Count == 0) { return(NotFound("Nenhum jogo encontrado para o estádio buscado")); } return(Ok(jogosBuscado)); }
public void OnStringChangedTest() { bool isCalled = false; var stringProp = new StringProperty(false); var vm = new StringViewModel(stringProp); vm.OnChanged.Subscribe(x => isCalled = true); vm.StringValue.Value = "Hello"; isCalled.IsTrue(); }
public void Indexing() { StringViewModel viewModel = new StringViewModel("hello"); int hash = "hello".GetHashCode(); Assert.AreEqual(hash, viewModel["Hash"]); Assert.AreEqual("hello".Length, viewModel["Length"]); Uri a = new Uri("http://example.com/tables/Absorb/"); Uri b = new Uri("http://example.com/tables/"); Uri r = a.MakeRelativeUri(b); Assert.AreEqual("Meow/", Uri.UnescapeDataString(r.ToString())); }
public MainPage() { this.InitializeComponent(); DataContext = this; NavigationCacheMode = NavigationCacheMode.Enabled; Movies = new ObservableCollection <LatestViewModel>(); SearchResults = new ObservableCollection <SearchResultViewModel>(); UserName = new StringViewModel { Content = "Loading" }; Loaded += MainPage_Loaded; SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested; }
public void RepresentString( StringViewModel stringViewModel, TelegramMessageService messageService, IBotInputChat chat ) => messageService.SendText( chat, stringViewModel.Value, new ReplyKeyboardMarkup { Keyboard = new [] { new [] { new KeyboardButton { Text = stringViewModel.Tip }, } }, OneTimeKeyboard = true, } );
static void Main(string[] args) { /* EXAMPLES */ var array = ArrayViewModel.LeftRotationByD(new int[] { 1, 2, 3, 4, 5 }, 1); LinkedList <int> linkedlist = new LinkedList <int>(new int[] { 1, 2, 3, 4, 5 }); var fib = RecursionViewModel.Fibonacci(3); var palindrome = StringViewModel.IsStringPalindrome("Savvas"); var sorted = LinkedListViewModel.InsertItemInSortedList(linkedlist, new LinkedListNode <int>(1)); var removed = LinkedListViewModel.RemoveDuplicatesFromSortedList(linkedlist); ArrayViewModel.PrintMultiplicationTable(10); var result = ArrayViewModel.MaximumSumSubArray(new int[] { -2, -3, 4, -1, -2, 1, 5, -3 }); var tuple = StringViewModel.LongesConsecutiveCharacters("AABCDDBBBEA"); /* END OF EXAMPLES */ Console.ReadKey(); }
static void Main(string[] args) { /* EXAMPLES */ var array = ArrayViewModel.LeftRotationByD(new int[] { 1, 2, 3, 4, 5 }, 1); LinkedList <int> linkedlist = new LinkedList <int>(new int[] { 1, 2, 3, 4, 5 }); var fibN1 = 40; var watch = System.Diagnostics.Stopwatch.StartNew(); var fib = RecursionViewModel.Fibonacci(fibN1); watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; Console.WriteLine(string.Format("Fib Recursion n = {0} solution {2} Elapsed Ms {1}", fibN1, elapsedMs, fib)); Console.WriteLine(string.Format("Fib DP n = {0} solution {1}", fibN1, RecursionViewModel.Fibonacci_DynamicProgramming(fibN1))); var fibN2 = 40000; var watch2 = System.Diagnostics.Stopwatch.StartNew(); var fib2 = RecursionViewModel.Fibonacci_DynamicProgramming(fibN2); watch2.Stop(); var elapsedMs2 = watch2.ElapsedMilliseconds; Console.WriteLine(string.Format("Fib DP n = {0} solution {2} Elapsed Ms {1}", fibN2, elapsedMs2, fib2)); var palindrome = StringViewModel.IsStringPalindrome("Savvas"); var sorted = LinkedListViewModel.InsertItemInSortedList(linkedlist, new LinkedListNode <int>(1)); var removed = LinkedListViewModel.RemoveDuplicatesFromSortedList(linkedlist); ArrayViewModel.PrintMultiplicationTable(10); var result = ArrayViewModel.MaximumSumSubArray(new int[] { -2, -3, 4, -1, -2, 1, 5, -3 }); /* END OF EXAMPLES */ Console.ReadKey(); }
public void ToRootVmCjson_exports_object_including_string(StringViewModel vm) { var expected = ToJson(vm); CheckToRootVmCjson(vm, expected); }
public void NotificationChainManager_ExecuteAllChains_should_execute_callbacks() { var senderExpected = this; var propertyNameExpected = Guid.NewGuid().ToString(); var chain1_Callback1_WasCalled = false; var chain1_Callback2_WasCalled = false; object chain1_Callback2_Sender = null; string chain1_Callback2_PropertyName = null; string chain1_Callback2_DependentPropertyName = null; var chain2_Callback1_WasCalled = false; var chain2_Callback2_WasCalled = false; object chain2_Callback2_Sender = null; string chain2_Callback2_PropertyName = null; string chain2_Callback2_DependentPropertyName = null; var deepTestClassChain_Callback2_WasCalled = false; var manager = new NotificationChainManager(); manager.CreateOrGet("Chain1") .AndCall(() => chain1_Callback1_WasCalled = true) .AndCall((sender, property, dependentProperty) => { chain1_Callback2_WasCalled = true; chain1_Callback2_Sender = sender; chain1_Callback2_PropertyName = property; chain1_Callback2_DependentPropertyName = dependentProperty; }); manager.CreateOrGet("Chain2") .AndCall(() => chain2_Callback1_WasCalled = true) .AndCall((sender, property, dependentProperty) => { chain2_Callback2_WasCalled = true; chain2_Callback2_Sender = sender; chain2_Callback2_PropertyName = property; chain2_Callback2_DependentPropertyName = dependentProperty; }); var testViewModel = new StringViewModel(); manager.CreateOrGet(() => testViewModel) .On(() => testViewModel, dtc => dtc.String) .AndCall(() => chain2_Callback1_WasCalled = true) .AndCall((sender, property, dependentProperty) => { deepTestClassChain_Callback2_WasCalled = true; }); manager.ExecuteAllChains(senderExpected, new PropertyChangedEventArgs(propertyNameExpected)); Assert.True(chain1_Callback1_WasCalled, nameof(chain1_Callback1_WasCalled)); Assert.True(chain1_Callback2_WasCalled, nameof(chain1_Callback2_WasCalled)); Assert.Equal(senderExpected, chain1_Callback2_Sender); Assert.Equal(propertyNameExpected, chain1_Callback2_PropertyName); Assert.Equal("Chain1", chain1_Callback2_DependentPropertyName); Assert.True(chain2_Callback1_WasCalled, nameof(chain2_Callback1_WasCalled)); Assert.True(chain2_Callback2_WasCalled, nameof(chain2_Callback2_WasCalled)); Assert.Equal(senderExpected, chain2_Callback2_Sender); Assert.Equal(propertyNameExpected, chain2_Callback2_PropertyName); Assert.Equal("Chain2", chain2_Callback2_DependentPropertyName); Assert.True(deepTestClassChain_Callback2_WasCalled); }
public async Task SearchData(SearchViewModel model) { string resultJson = await GetSearchData(model); StringViewModel str = new StringViewModel(); str.Key = resultJson; string jsonModel = Json.Serialize <StringViewModel>(str); Console.WriteLine(jsonModel); string url = _options.Value.Url + "api/Diggos/SaveSearchData/" + model.RequestId; using (HttpClient client = new HttpClient()) using (HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, new Uri(url))) { //Console.WriteLine("création du fake json"); /*StringBuilder fakeJson = new StringBuilder(); * fakeJson.AppendLine("{"); * // Un New Logiciel * fakeJson.AppendLine("["); * // Un élément * fakeJson.AppendLine("{"); * fakeJson.AppendLine("\"Data\" : \"+339817264693\","); * fakeJson.AppendLine("\"Source\" : \"TwitterSearchPhone\","); * fakeJson.AppendLine("\"TypeOfData\" : \"Phone Number\""); * fakeJson.AppendLine("}"); * // Un élément * fakeJson.AppendLine("{"); * fakeJson.AppendLine("\"Data\" : \"0609157788\","); * fakeJson.AppendLine("\"Source\" : \"TwitterSearchPhone\","); * fakeJson.AppendLine("\"TypeOfData\" : \"Phone Number\""); * fakeJson.AppendLine("}"); * fakeJson.AppendLine("]"); * // Un New Logiciel * fakeJson.AppendLine("["); * // Un élément * fakeJson.AppendLine("{"); * fakeJson.AppendLine("\"Data\" : \"[email protected]\","); * fakeJson.AppendLine("\"Source\" : \"SearchMailByName\","); * fakeJson.AppendLine("\"TypeOfData\" : \"Mail\""); * fakeJson.AppendLine("}"); * // Un élément * fakeJson.AppendLine("{"); * fakeJson.AppendLine("\"Data\" : \"[email protected]\","); * fakeJson.AppendLine("\"Source\" : \"SearchMailByName\","); * fakeJson.AppendLine("\"TypeOfData\" : \"Mail\""); * fakeJson.AppendLine("}"); * // Un élément * fakeJson.AppendLine("{"); * fakeJson.AppendLine("\"Data\" : \"[email protected]\","); * fakeJson.AppendLine("\"Source\" : \"SearchMailByName\","); * fakeJson.AppendLine("\"TypeOfData\" : \"Mail\""); * fakeJson.AppendLine("}"); * fakeJson.AppendLine("]"); * fakeJson.AppendLine("}"); * StringViewModel str = new StringViewModel(); * str.Key = fakeJson.ToString();*/ /*StringViewModel str = new StringViewModel(); * str.Key = "[{\"Data\" : \"EFRIPGFERHIEGROFPEGR\",\"Source\" : \"TwitterSearchPhone\",\"TypeOfData\" : \"Phone Number\", \"Link\" : [{\"Uid\" : \"master\"}]},{\"Data\" : \"0609157788\",\"Source\" : \"TwitterSearchPhone\",\"TypeOfData\" : \"Phone Number\"},{\"Data\" : \"[email protected]\",\"Source\" : \"SearchMailByName\",\"TypeOfData\" : \"Mail\"},{\"Data\" : \"[email protected]\",\"Source\" : \"SearchMailByName\",\"TypeOfData\" : \"Mail\"},{\"Data\" : \"[email protected]\",\"Source\" : \"SearchMailByName\",\"TypeOfData\" : \"Mail\"}]"; * string jsonModel = Json.Serialize<StringViewModel>(str);*/ //Console.WriteLine(fakeJson.ToString()); request.Content = new StringContent(jsonModel, Encoding.UTF8, "application/json"); request.Headers.Add("Authorization", string.Format("Bearer {0}", _tokenService.GenerateToken())); await client.SendAsync(request); } }