//Logging einer Aktion private void LogAction(object sender, RoutedEventArgs e) { //Speichern des Namens des Quellelements string originalsource = e.OriginalSource is TextBox ? (e.OriginalSource as TextBox).Name : e.OriginalSource.ToString(); //Testen auf Art des Events anhand der EventArgs und Eintrag ins Log if (e.GetType() == typeof(MouseButtonEventArgs)) { Log.Append($"{originalsource}: MouseButtonPressed: {(e as MouseButtonEventArgs).ChangedButton}"); } else if (e.GetType() == typeof(KeyEventArgs)) { Log.Append($"{originalsource}: KeyPressed: {(e as KeyEventArgs).Key}"); } else if (e.GetType() == typeof(TextChangedEventArgs)) { Log.Append($"{originalsource}: TextChanged: {(e.OriginalSource as TextBox).Text}"); } else { Log.Append($"{originalsource}: Unknown Event"); } //Neue Zeile im Log Log.Append(Environment.NewLine); }
public void SimpleRoutedEvent_routed_event_handle_test() { var autoResetEvent = new AutoResetEvent(false); var routedEventContainer = Application.Current.Container.Resolve <IRoutedEventContainer>(); RoutedEventSender expectedRoutedEventSender = null; RoutedEventArgs expectedRoutedEventArgs = null; routedEventContainer.AddHandler(TestRoutedEvents.SimpleRoutedEvent, (sender, args) => { expectedRoutedEventSender = sender; expectedRoutedEventArgs = args; autoResetEvent.Set(); }); routedEventContainer.Raise(TestRoutedEvents.SimpleRoutedEvent, this, RoutedEventArgs.Empty); autoResetEvent.WaitOne(5000); Assert.IsNotNull(expectedRoutedEventSender); Assert.IsNotNull(expectedRoutedEventArgs); Assert.IsNotNull(expectedRoutedEventSender); Assert.IsTrue(expectedRoutedEventArgs.GetType() == typeof(RoutedEventArgs)); }
public void ShowEventArgument(RoutedEventArgs e) { StringBuilder sb = new StringBuilder(); sb.AppendLine("Event argument:"); sb.AppendLine($"\tType: \t{e.GetType().Name}"); sb.AppendLine($"\tSource: \t{e.Source}"); sb.AppendLine($"\tOriginalSource: \t{e.OriginalSource}"); MessageBox.Show(sb.ToString()); }
private async void AbbDebugSite_Click(object sender, RoutedEventArgs e) { try { Frame.Navigate(typeof(MobileDebug.DebugPage)); } catch (Exception exc) { await new Windows.UI.Popups.MessageDialog(exc.Message, e.GetType().Name).ShowAsync(); } }
/// <summary> /// Exporta el reporte seleccionado a un archivo de excel. /// </summary> /// <history> /// [jorcanche] 31/ago/2016 Created /// [emoguel] 08/09/2016 Ahora abre el visor de reportes /// </history> private async void lstReports_Select(object sender, RoutedEventArgs e) { if (e.GetType() == typeof(KeyEventArgs) && ((KeyEventArgs)e).Key != Key.Enter) { return; } var filters = new List <Tuple <string, string> >(); var daterange = DateHelper.DateRange(dtpDate.Value.Value, dtpDate.Value.Value); var dateFileName = DateHelper.DateRangeFileName(dtpDate.Value.Value, dtpDate.Value.Value); FileInfo fileinfo = null; if (lstReports.SelectedItem == null) { UIHelper.ShowMessage("You must select a report"); return; } switch ((lstReports.SelectedItem as ListBoxItem).Content.ToString()) { case "Deposits by PR": var lstRptDepPr = await BRReportsByLeadSource.GetRptDepositByPR(dtpDate.Value.Value, dtpDate.Value.Value, Context.User.LeadSource.lsID); if (lstRptDepPr.Any()) { filters.Add(Tuple.Create("Filter Range", daterange)); filters.Add(Tuple.Create("Lead Source", Context.User.LeadSource.lsID)); var lstDepPr = lstRptDepPr[0] as List <RptDepositsByPR>; var currencies = lstRptDepPr[1] as List <Currency>; var payType = lstRptDepPr[2] as List <PaymentType>; lstDepPr.ForEach(c => { c.guPRInvit1 = $"{c.guPRInvit1} {c.peN}"; c.gucu = currencies.First(cu => cu.cuID == c.gucu).cuN ?? ""; c.gupt = payType.First(pt => pt.ptID == c.gupt).ptN ?? ""; }); fileinfo = await ReportBuilder.CreateCustomExcelAsync(TableHelper.GetDataTableFromList(lstDepPr, true, false), filters, "Deposits by PR", dateFileName, clsFormatReports.RptDepositByPr(), blnShowSubtotal : true, blnRowGrandTotal : true, isPivot : true, addEnumeration : true); } else { UIHelper.ShowMessage("There is no data for make a report"); } break; } if (fileinfo != null) { frmDocumentViewer documentViewer = new frmDocumentViewer(fileinfo, Context.User.HasPermission(EnumPermission.RptExcel, EnumPermisionLevel.ReadOnly), false); documentViewer.Owner = this; documentViewer.ShowDialog(); } }
private void combination_Click(object sender, RoutedEventArgs e) { if (e.GetType() == typeof(KeyEventArgs) && (e as KeyEventArgs).Key != Key.Enter) { return; } result.Clear(); for (int i = 0; i < pre_idx; i++) { if (!int.TryParse(tb_input[i].Text, out int res)) { tb_output.Text += "저항값은 숫자만 가능합니다.\n\n"; tb_output.ScrollToEnd(); SystemSounds.Beep.Play(); return; } } if (int.TryParse(target.Text, out int t)) { target_value = t; dfs(0, 0, 0, new List <int>()); if (result.Count == 0) { tb_output.Text += "가능한 조합이 없습니다."; } else { tb_output.Text += $"### {target_value}Ω 을 만들 수 있는 저항 조합 ###\n"; int i = 1; foreach (var a in result) { int j = 1; tb_output.Text += $"조합{i++} -> "; foreach (var b in a) { tb_output.Text += $"{b}Ω" + (j++ < a.Count ? ", " : ""); } tb_output.Text += "\n"; tb_output.ScrollToEnd(); } } } else { tb_output.Text += "저항값은 숫자만 가능합니다.\n\n"; SystemSounds.Beep.Play(); } tb_output.Text += "\n------------------------------------------------\n\n"; tb_output.ScrollToEnd(); }
private void Color_Click(object sender, RoutedEventArgs e) { Console.WriteLine(e.GetType()); Button btn = sender as Button; selectedColor.Background = btn.Background; GlobalVars.outlnBrush = Color1.Background; GlobalVars.fillBrush = Color2.Background; foreach (var figure in GlobalVars.selected) { figure.Color = GlobalVars.outlnBrush; } planeHost.Redraw(); }
private EventType getEventType(RoutedEventArgs e) { string type = e.GetType().ToString(); if (type.Equals("System.Windows.RoutedEventArgs")) { return(EventType.kFocus); } else if (type.Equals("System.Windows.Input.KeyEventArgs")) { KeyEventArgs keyEvent = (KeyEventArgs)e; if (keyEvent.Key.Equals(Key.Enter)) { return(EventType.kEnterKey); } } return(EventType.kUnknown); }
public void StepClicked(object sender, RoutedEventArgs e) { if (e.GetType() == typeof(TravellerRoutedEventArgs)) { bool bUseStep = ((TravellerRoutedEventArgs)(Object)e).TravellerEventArgs == "true"; objTravellerRunTime.bUseStep = bUseStep; if (bUseStep) { if (bStep == true) { bStep = false; } else { bStep = true; } } else { bStep = false; } objTravellerRunTime.bStep = bStep; } }
public static void SetHandled(RoutedEventArgs args, bool handled) { HandlersMap.GetValueOrDefault(args.GetType())?.Invoke(args, handled); }
/// <summary> /// Raises a specific routed event. The <see cref="RoutedEvent"/> to be raised is identified within the <see cref="RoutedEventArgs"/> instance /// that is provided (as the <see cref="RoutedEvent"/> property of that event data). /// </summary> /// <param name="e">A <see cref="RoutedEventArgs"/> that contains the event data and also identifies the event to raise.</param> /// <exception cref="ArgumentNullException"><paramref name="e"/> is null.</exception> /// <exception cref="InvalidOperationException">The type of the routed event argument <paramref name="e"/> does not match the event handler second argument type.</exception> public void RaiseEvent(RoutedEventArgs e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } if (e.RoutedEvent == null) { return; } if (!e.RoutedEvent.HandlerSecondArgumentType.GetTypeInfo().IsAssignableFrom(e.GetType().GetTypeInfo())) { throw new InvalidOperationException("The type of second parameter of the handler (" + e.RoutedEvent.HandlerSecondArgumentType + ") is not assignable from the parameter 'e' type (" + e.GetType() + ")."); } var sourceWasNull = e.Source == null; if (sourceWasNull) // set the source to default if needed { e.Source = this; } e.StartEventRouting(); PropagateRoutedEvent(e); e.EndEventRouting(); if (sourceWasNull) // reset the source if it was not explicitly set (event might be reused again for other sources) { e.Source = null; } }
/// <summary> /// Exporta el reporte seleccionado a un archivo de excel. /// </summary> /// <history> /// [edgrodriguez] 21/Jun/2016 Created /// [jorcanche] 01/09/2016 modified se agrego validacion si no se selecciono un reporte /// [edgrodriguez] 05/09/2016 Modified. Se cambio el método CreateExcelCustom por CreatCustomExcel /// [emoguel] 08/09/2016 Modified. Ahora abre el visor de reportes /// </history> private async void lstHostReports_Select(object sender, RoutedEventArgs e) { if (e.GetType() == typeof(KeyEventArgs) && ((KeyEventArgs)e).Key != Key.Enter) { return; } var filters = new List <Tuple <string, string> >(); var daterange = DateHelper.DateRange(dtpDate.Value.Value, dtpDate.Value.Value); var dateFileName = DateHelper.DateRangeFileName(dtpDate.Value.Value, dtpDate.Value.Value); FileInfo fileinfo = null; if (lstHostReports.SelectedItem == null) { UIHelper.ShowMessage("You must select a report"); return; } switch ((lstHostReports.SelectedItem as ListBoxItem).Content.ToString()) { case "Premanifest": var lstPremanifest = await BRGeneralReports.GetRptPremanifest(dtpDate.Value.Value, salesRoom : Context.User.SalesRoom.srID); if (lstPremanifest.Any()) { filters.Add(Tuple.Create("Filter Range", daterange)); filters.Add(Tuple.Create("Sales Room", Context.User.SalesRoom.srID)); fileinfo = await ReportBuilder.CreateCustomExcelAsync(TableHelper.GetDataTableFromList(lstPremanifest, true, true), filters, "Premanifest", dateFileName, clsFormatReports.RptPremanifest()); } else { UIHelper.ShowMessage("There is no data for make a report"); } break; case "Premanifest With Gifts": var lstPremanifestWithG = await BRGeneralReports.GetRptPremanifestWithGifts(dtpDate.Value.Value, salesRoom : Context.User.SalesRoom.srID); if (lstPremanifestWithG.Any()) { filters.Add(Tuple.Create("Filter Range", daterange)); filters.Add(Tuple.Create("Sales Room", Context.User.SalesRoom.srID)); fileinfo = await ReportBuilder.CreateCustomExcelAsync(TableHelper.GetDataTableFromList(lstPremanifestWithG, true, true), filters, "Premanifest With Gifts", dateFileName, clsFormatReports.RptPremanifestWithGifts()); } else { UIHelper.ShowMessage("There is no data for make a report"); } break; case "Up List End": var lstUplistEnd = await BRReportsBySalesRoom.GetRptUplist(dtpDate.Value.Value.Date, salesRoom : Context.User.SalesRoom.srID, uplistType : 1); if (lstUplistEnd.Any()) { filters.Add(Tuple.Create("Filter Range", daterange)); filters.Add(Tuple.Create("Sales Room", Context.User.SalesRoom.srID)); var salesmans = lstUplistEnd.Select(c => c.Salesman).Distinct().ToList(); salesmans.ForEach(s => { var first = lstUplistEnd.FirstOrDefault(u => u.Salesman == s); var index = lstUplistEnd.IndexOf(first); lstUplistEnd.Where(c => c.Salesman == s && lstUplistEnd.IndexOf(c) != index).ToList().ForEach(c => { c.AmountM = 0; c.AmountYtd = 0; }); }); fileinfo = await ReportBuilder.CreateCustomExcelAsync(TableHelper.GetDataTableFromList(lstUplistEnd, true, true), filters, "Up List End", dateFileName, clsFormatReport.RptUpList(), isPivot : true, addEnumeration : true); } else { UIHelper.ShowMessage("There is no data for make a report"); } break; case "Up List Start": var lstUplistStart = await BRReportsBySalesRoom.GetRptUplist(dtpDate.Value.Value, salesRoom : Context.User.SalesRoom.srID); if (lstUplistStart.Any()) { filters.Add(Tuple.Create("Filter Range", daterange)); filters.Add(Tuple.Create("Sales Room", Context.User.SalesRoom.srID)); var newUplist = new List <RptUpList>(); var times = new List <string> { "08:00", "10:00", "12:00" }; //Replicamos los registros por cada registro de la lista times lstUplistStart.ForEach(c => { times.ForEach(t => { newUplist.Add(new RptUpList { Salesman = c.Salesman, SalesmanN = c.SalesmanN, SalesmanPost = c.SalesmanPost, SalesmanPostN = c.SalesmanPostN, DayOffList = c.DayOffList, Language = c.Language, Location = c.Location, Time = c.Time, TimeN = t, AmountYtd = c.AmountYtd, AmountM = c.AmountM }); }); }); fileinfo = await ReportBuilder.CreateCustomExcelAsync(TableHelper.GetDataTableFromList(newUplist, true, true), filters, "Up List Start", dateFileName, clsFormatReport.RptUpList(), isPivot : true, addEnumeration : true); } else { UIHelper.ShowMessage("There is no data for make a report"); } break; } if (fileinfo != null) { frmDocumentViewer documentViewver = new frmDocumentViewer(fileinfo, Context.User.HasPermission(EnumPermission.RptExcel, EnumPermisionLevel.ReadOnly), false); documentViewver.Owner = this; documentViewver.ShowDialog(); } }
/// <summary> /// Raises a specific routed event. The <see cref="RoutedEvent"/> to be raised is identified within the <see cref="RoutedEventArgs"/> instance /// that is provided (as the <see cref="RoutedEvent"/> property of that event data). /// </summary> /// <param name="e">A <see cref="RoutedEventArgs"/> that contains the event data and also identifies the event to raise.</param> /// <exception cref="ArgumentNullException"><paramref name="e"/> is null.</exception> /// <exception cref="InvalidOperationException">The type of the routed event argument <paramref name="e"/> does not match the event handler second argument type.</exception> public void RaiseEvent(RoutedEventArgs e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } if (e.RoutedEvent == null) { return; } if (!e.RoutedEvent.HandlerSecondArgumentType.GetTypeInfo().IsAssignableFrom(e.GetType().GetTypeInfo())) { throw new InvalidOperationException("The type of second parameter of the handler (" + e.RoutedEvent.HandlerSecondArgumentType + ") is not assignable from the parameter 'e' type (" + e.GetType() + ")."); } // temporarily disable errors from add/removes of entities during events in other threads, as it is always safe to do it now bool previousEnforce = EntityManager.EnforceThreads; EntityManager.EnforceThreads = false; var sourceWasNull = e.Source == null; if (sourceWasNull) // set the source to default if needed { e.Source = this; } e.StartEventRouting(); PropagateRoutedEvent(e); e.EndEventRouting(); // return to enforcing thread add/removes, if we were before EntityManager.EnforceThreads = previousEnforce; if (sourceWasNull) // reset the source if it was not explicitly set (event might be reused again for other sources) { e.Source = null; } }
private void Translate_Batch_Clicked(object sender, RoutedEventArgs e) { if (!(TranslateData.DataContext is Project.TranslationPair[] currentPairs)) { MessageBox.Show(this, "No section is open", "Turansuraetu", MessageBoxButton.OK, MessageBoxImage.Error); return; } ProgressDisplay disp = new ProgressDisplay(); List <ITranslateService> activeServices = ITranslateService.TranslationServices.Where(x => x.IsActive(this)).ToList(); bool overwriteTranslations = DoOverwrite.IsChecked; BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += (o, args) => { try { foreach (ITranslateService service in activeServices) { int i = 1; foreach (Project.TranslationPair pair in currentPairs) { disp.Update($"{service.GetType().Name} - {i}/{currentPairs.Length}", (double)i / currentPairs.Length); try { service.Translate(Translate.Language.Japanese, Translate.Language.English, pair.Original, ref pair.machine, overwriteTranslations); } catch (Exception e) { Dispatcher.Invoke(() => { MessageBox.Show( $"An error has occured whilst translating with {service.GetType().Name}: {e.GetType().Name} {e.Message}", "Turansuraetu", MessageBoxButton.OK, MessageBoxImage.Stop); }); } i++; } } } finally { disp.Done(); } }; worker.RunWorkerCompleted += (o, args) => { RefreshTable(); }; worker.RunWorkerAsync(); disp.ShowDialog(); }