using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO.Ports; using System.Linq; using System.Runtime.Remoting.Contexts; using System.Security.Cryptography; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Navigation; using System.Windows.Threading; using BeWo.Core; using BeWo.Core.Config; using BeWo.Core.Service; using BeWo.Scheduler.View; using BeWo.SchulbegleitenderDienst; using BeWo.ServiceProxy; using BeWo.Services; using BeWo.View; using BeWo.View.Detail; using BeWo.View.Detail.Zeiterfassung; using BeWo.View.Document; using BeWo.View.Master; using BeWo.View.Navigation; using BeWo.View.Windows; using BeWo.ViewModel; using BS.Shared; using BS.Shared.Core; using BS.Shared.DataContracts; using BS.Shared.Extensions; using BS.Shared.Translation; using DevExpress.XtraEditors; using Hyperlink = System.Windows.Documents.Hyperlink; namespace BeWo { public enum UIContext { SupportConcept = 0, Customer = 1, Person = 2, Employee = 3, Organisation = 4, Team = 5, Dokumente = 6, User = 7, UserGroup = 8, Report = 9, Scheduler = 10, Wohnheim = 11, Vertretungen = 12, CustomerTeam = 13, Scheduling = 14, Finance = 15, Administration = 16, AiConversation = 17, AiConversationPopup = 18 } public partial class MainControl { private const string _PINInfoText = "Um Zugriff auf Ihre Daten zu bekommen, benötigen wir eine PIN."; private readonly Stack _ModalPopupControls = new Stack(); private BeWoView _CurrentDetailView; private Control _CurrentModalPopup; private HomeView _HomeView; private bool _TermineInitialized; private Dictionary _Views = new Dictionary(); private WaitLayer2 _WaitLayer; public MainControl() { InitializeComponent(); BeWoApp.MainControl = this; InitCommandBindings(); KeyDown += MainControl_KeyDown; NavigateToHomeView(); #if DEBUG if (DebugConfig.CurrentConfig is object && DebugConfig.CurrentConfig.SelectView is UIContext context) { NavigateTo(GetViewForUIContext(context)); } #endif // ToDo: Neuer Kalender nur im Debug-Modus! #if DEBUG ButtonScheduling.Visibility = Visibility.Visible; #else ButtonScheduling.Visibility = Visibility.Collapsed; #endif //EditorLocalizer.Active = new CustomDXEditorLocalizer(); //SchedulerControlLocalizer.Active = new CustomSchedulerLocalizer(); //GridControlLocalizer.Active = new CustomGridLocalizer(); // ToDo: Testen! // var bewoClientType = BeWoApp.Mandator.BeWoClientType; //var hasKilometerauswertung = BeWoApp.AppSettings.ShowDistanceFields && (BeWoApp.LoggedOnUser.HasRight(UserRightType.Kilometerauswertung_View) || BeWoApp.LoggedOnUser.HasRight(UserRightType.KilometerauswertungEigene_View)); //var hideAuswertungen = !BeWoApp.LoggedOnUser.HasRight(UserRightType.Auswertungen_BerichteAnsehen) && // !BeWoApp.LoggedOnUser.HasRight(UserRightType.Auswertungen_StundenuebersichtAnsehen) && // !BeWoApp.LoggedOnUser.HasRight(UserRightType.Auswertungen_HilfeplanuebersichtAnsehen) && // !BeWoApp.LoggedOnUser.HasRight(UserRightType.Analysis_ServiceOverview_View) && // !BeWoApp.LoggedOnUser.HasRight(UserRightType.Analysis_Auslastung_View) && // (bewoClientType != 3 || !BeWoApp.LoggedOnUser.HasRight(UserRightType.Analysis_EmployeeOverviewAll_View)) && // (BeWoApp.Tenant == "3010479871" || (!BeWoApp.LoggedOnUser.HasRight(UserRightType.Mitarbeiterstundenkonto_ViewAll) && !BeWoApp.LoggedOnUser.HasRight(UserRightType.Mitarbeiterstundenkonto_ViewSelf) && !BeWoApp.LoggedOnUser.HasRight(UserRightType.Mitarbeiterstundenkonto_ViewTeams))) && // !BeWoApp.LoggedOnUser.HasRight(UserRightType.Jahresbericht) && // !BeWoApp.Mandator.AllowSbd && // !(BeWoApp.AppSettings.ShowPivotGrid && BeWoApp.LoggedOnUser.HasRight(UserRightType.PivotTabelleAnsehen)) && // !(BeWoApp.AppSettings.ShowDienstplanung && BeWoApp.LoggedOnUser.HasRight(UserRightType.DienstplanungAnsehen)) && // !(BeWoApp.AppSettings.ShowUrlaubsplanung && BeWoApp.LoggedOnUser.HasRight(UserRightType.AbwesenheitsPlanungAnsehen)) && // !BeWoApp.LoggedOnUser.HasRight(UserRightType.BewertungAuswertung_View) && // !BeWoApp.LoggedOnUser.HasRight(UserRightType.Analysis_ServiceOverview_View) && // !hasKilometerauswertung; //if(hideAuswertungen) // { // button_Reports.Visibility = Visibility.Collapsed; // } OpenedModalViewWindows = new List(); if (!string.IsNullOrWhiteSpace(BeWoApp.AppSettings.TimeRecordingMenuName)) { button_serviceRecord.Content = BeWoApp.AppSettings.TimeRecordingMenuName; } BeWoApp.InitAutoUILocking(); AufOffeneTerminePruefen(); //BeWoApp.InitBlubb(); #if !DEBUG if (this.button_Scheduler.Visibility == Visibility.Visible && !BeWoApp.AppSettings.IsSchedulerAllowed) { this.button_Scheduler.Visibility = Visibility.Collapsed; } if (this.button_Wohnheim.Visibility == Visibility.Visible && !BeWoApp.AppSettings.IsWohnheimAllowed) { this.button_Wohnheim.Visibility = Visibility.Collapsed; } if (this.button_ResourceBooking.Visibility == Visibility.Visible && !BeWoApp.AppSettings.ShowRessources) { this.button_ResourceBooking.Visibility = Visibility.Collapsed; } if (BeWoApp.Mandator == null || !BeWoApp.Mandator.AllowSbd) { this.button_SchulbegleitenderDienst.Visibility = Visibility.Collapsed; } if (BeWoApp.LoggedOnUser != null && BeWoApp.LoggedOnUser.HasRight(UserRightType.DocumentsAllowViewAll) && BeWoApp.AppSettings.ShowWohnhilfe) { this.button_Dokumente.Visibility = Visibility.Visible; } else { this.button_Dokumente.Visibility = Visibility.Collapsed; } #endif #if DEBUG //DebugHelperViewButton.Visibility = Visibility.Visible; #endif UpdateMandator(); ControlFactory = new BeWoControlFactory(); WindowFactory = new BeWoWindowFactory(); WindowService = new BeWoWindowService(WindowFactory, ControlFactory); } private AnimatedBeWoWindow _CurrentAnimatedBeWoWindow; public AnimatedBeWoWindow CurrentAnimatedBeWoWindow { get => _CurrentAnimatedBeWoWindow; set { if (value == _CurrentAnimatedBeWoWindow) return; _CurrentAnimatedBeWoWindow = value; if (value is null) HideModalBackgroundFade(.5); else { ShowModalBackgroundFade(.5); } } } internal IControlFactory ControlFactory { get; set; } internal IWindowFactory WindowFactory { get; set; } internal IWindowService WindowService { get; set; } public List OpenedModalViewWindows { get; set; } internal Dictionary Views { get { return _Views; } } public Grid ModalPopupBackGround { get; private set; } public HomeView HomeView { get { return _HomeView; } set { _HomeView = value; } } public BeWoView ActiveView { get { if (DetailFrame.Children.Count > 0) { return DetailFrame.Children[0] as BeWoView; } return null; } } public bool IsMaximized { get; set; } public bool IsModalPopupOpen => _CurrentModalPopup is object; private bool _HatNeueTermine; public bool HatNeueTermine { get => _HatNeueTermine; set { _HatNeueTermine = value; NewAppointmentsOutlinedTextBlock.Visibility = value && BeWoApp.LoggedOnUser != null && BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderAnsehen) ? Visibility.Visible : Visibility.Collapsed; if (ActiveView?.GetType() == typeof(SchedulerMasterView)) { var schedulerMasterView = (SchedulerMasterView)ActiveView; if (schedulerMasterView.grid_root.Children.Count > 0) { var child0 = schedulerMasterView.grid_root.Children[0]; if (child0?.GetType() == typeof(NewSchedulerView)) { var scheduler = (NewSchedulerView)schedulerMasterView.grid_root.Children[0]; scheduler.UpdateRequestString(); } } } else if (ActiveView?.GetType() == typeof(HomeView)) { var homeDragPanelView = (HomeView)ActiveView; homeDragPanelView.UpdateRequestsHyperLink(); } } } public event EventHandler LogoutClicked; public void ResetView(UIContext uiContext) { if (_Views.ContainsKey(uiContext)) { _Views.Remove(uiContext); } } private BeWoView GetViewForUIContext(UIContext uiContext) { if (uiContext == UIContext.Administration) return new AdministrationView(); if (_Views.ContainsKey(uiContext)) return _Views[uiContext]; BeWoView view = null; switch (uiContext) { case UIContext.Person: view = new PersonNavigationView(); break; case UIContext.Customer: view = new CustomerNavigationView(); break; case UIContext.Organisation: view = new OrganisationNavigationView(); break; case UIContext.SupportConcept: view = new SupportConceptNavigationView(); break; case UIContext.Team: view = new TeamNavigationView(); break; case UIContext.Dokumente: view = new DokumenteView(); break; case UIContext.User: view = new UserNavigationView(); break; case UIContext.UserGroup: view = new UserGroupNavigationView(); break; case UIContext.Employee: view = new EmployeeNavigationView(); break; case UIContext.Report: view = new ReportView(); break; case UIContext.Scheduler: view = new SchedulerMasterView(); break; case UIContext.Wohnheim: view = new WohnheimNavigationView(); break; case UIContext.Vertretungen: view = new VertretungsMainView2(); break; case UIContext.CustomerTeam: view = new CustomerTeamNavigationView(); break; case UIContext.Scheduling: view = new SchedulingMasterView(); break; case UIContext.Finance: view = new FinanceView(); break; case UIContext.AiConversation: view = new AiConversationView(); break; case UIContext.AiConversationPopup: view = new AiConversationView(); break; } _Views[uiContext] = view; return view; } public event PropertyChangedEventHandler PropertyChanged; public void AnimateOpacity(double pOpacitiy, double pDuration) { // System.Windows.Media.TransformGroup group = this.DetailFrame.RenderTransform as System.Windows.Media.TransformGroup; // System.Windows.Media.ScaleTransform scale = group.Children[0] as System.Windows.Media.ScaleTransform; var lAnimation = new DoubleAnimation(); // lAnimation.From = scale.ScaleX; // lAnimation.To = pOpacitiy; lAnimation.From = DetailFrame.Opacity; lAnimation.To = pOpacitiy; lAnimation.Duration = TimeSpan.FromMilliseconds(pDuration); DetailFrame.BeginAnimation(OpacityProperty, lAnimation); // scale.BeginAnimation(System.Windows.Media.ScaleTransform.ScaleXProperty, lAnimation); // scale.BeginAnimation(System.Windows.Media.ScaleTransform.ScaleYProperty, lAnimation); } public void AnimateOpacity(double pOpacitiy) { AnimateOpacity(pOpacitiy, 500); } public void ChangePopupOpacityMode(bool isPopUpVisible) { if (isPopUpVisible) { AnimateOpacity(0.5, 200); } else { AnimateOpacity(1, 100); } } public void CloseCurrentPopUp() { if (ModalPopupBackGround != null) { Dispatcher.BeginInvoke( DispatcherPriority.Normal, (Action)delegate { grid_main.Children.Remove(_CurrentModalPopup); _CurrentModalPopup = null; if (_ModalPopupControls.Count == 0) { HideModalBackground(); } else { var control = _ModalPopupControls.Pop(); _CurrentModalPopup = control; grid_main.Children.Add(control); Panel.SetZIndex(control, int.MaxValue); } }); } } public void HideCurrentModalViewWindows() { if (ModalPopupBackGround != null) { Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)delegate { ModalPopupBackGround.Visibility = Visibility.Collapsed; foreach (var modalPopup in OpenedModalViewWindows) { modalPopup.Hide(); } }); } } public void ShowCurrentModalViewWindowsAgain() { if (OpenedModalViewWindows.Count > 0 && ModalPopupBackGround != null) { ModalPopupBackGround.Visibility = Visibility.Visible; foreach (var modalPopup in OpenedModalViewWindows) { modalPopup.Show(); } } } public void EndWaiting() { Dispatcher.BeginInvoke( DispatcherPriority.Normal, (Action)delegate { if (_WaitLayer != null) { grid_main.Children.Remove(_WaitLayer); _WaitLayer = null; } }); } public void NavigateToServiceRecordView(long? supportConceptOid) { if (DoSaveCheck()) { VMFactory.CreateServiceRecordVMAsync( BeWoApp.LoggedOnUser.Employee.EmployeeOid, vm => this.Dispatch( delegate { vm.DispatcherObject = this; NavigateTo(new ServiceRecordView2(vm, supportConceptOid)); })); } } public void NavigateToAdditionalServiceView(long? supportConceptOid) { if (DoSaveCheck()) { VMFactory.CreateServiceRecordVMAsync( BeWoApp.LoggedOnUser.Employee.EmployeeOid, vm => Cache.GetInstance().GetAllActiveAndArchivedCustomerCompact( c => this.Dispatch( delegate { vm.DispatcherObject = this; if (vm.NewVM != null) vm.NewVM.ServiceRecordType = ServiceRecordTypeId.AdditionalService; NavigateTo(new AdditionalServiceView(vm, c)); }))); } } public void ShowControlAsModalPopup(Control control) { ShowControlAsModalPopup(control, HorizontalAlignment.Center, VerticalAlignment.Center); } public void ShowControlAsModalPopup(Control control, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment) { Dispatcher.BeginInvoke( DispatcherPriority.Normal, (Action)delegate { if (_CurrentModalPopup != null) { grid_main.Children.Remove(_CurrentModalPopup); _ModalPopupControls.Push(_CurrentModalPopup); } else { ShowModalBackground(); } _CurrentModalPopup = control; control.HorizontalAlignment = horizontalAlignment; control.VerticalAlignment = verticalAlignment; Grid.SetColumnSpan(control, 3); Grid.SetRowSpan(control, 3); grid_main.Children.Add(control); Panel.SetZIndex(control, 1000); }); } public void StartWaiting() { Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)StartWaitingImmediately); } public void StartWaitingImmediately() { if (_WaitLayer == null) { _WaitLayer = new WaitLayer2(); Grid.SetColumnSpan(_WaitLayer, 3); Grid.SetRowSpan(_WaitLayer, 3); grid_main.Children.Add(_WaitLayer); Panel.SetZIndex(_WaitLayer, int.MaxValue); //_WaitLayer.RefreshUI(); } } internal void ClearDetailFrame() { foreach (var window in BeWoApp.CurrentBeWo.MainWindow.OwnedWindows) { ((System.Windows.Window)window).Close(); } BeWoView lOld = null; if (DetailFrame.Children.Count == 1) { lOld = DetailFrame.Children[0] as BeWoView; } _CurrentDetailView = null; if (lOld != null) { if (lOld is HomeView) { var hdpv = lOld as HomeView; hdpv.SaveState(); BeWoApp.SaveAppSettings(); } lOld.BlendOutComplete += (s, e) => DetailFrame.Children.Remove(lOld); lOld.BlendOut(); } DetailFrame.Children.Clear(); } internal void Maximize() { var animation = new ThicknessAnimationUsingKeyFrames(); var t = new Thickness(-5, 0, -5, 0); animation.KeyFrames.Add(new SplineThicknessKeyFrame(t, KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 500)), new KeySpline(1, 0, 1, 1))); animation.Completed += maximizeAnimation_Completed; AnimateToolbarOut(0); DetailFrame.BeginAnimation(MarginProperty, animation); BeWoApp.AppSettings.WindowState = AppSettings.WindowStateType.Maximised; BeWoApp.SaveAppSettings(); // toolbarButtonPanel.Visibility = Visibility.Hidden; // toolbarBord.Visibility = Visibility.Hidden; // LogoutButtonPanel.Visibility = Visibility.Hidden; ////###HOMEVIEW HomeButtonPanel.Visibility = Visibility.Hidden; // toolbarScrollViewer.Visibility = Visibility.Hidden; } internal void Minimize() { var animation = new ThicknessAnimationUsingKeyFrames(); var t = new Thickness(140, 35, 140, 85); animation.KeyFrames.Add(new SplineThicknessKeyFrame(t, KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 500)), new KeySpline(0, 1, 1, 1))); animation.Completed += minimizeAnimation_Completed; AnimateToolbarIn(0); DetailFrame.BeginAnimation(MarginProperty, animation); BeWoApp.AppSettings.WindowState = AppSettings.WindowStateType.Default; BeWoApp.SaveAppSettings(); // toolbarButtonPanel.Visibility = Visibility.Visible; // toolbarBord.Visibility = Visibility.Visible; // LogoutButtonPanel.Visibility = Visibility.Visible; ////###HOMEVIEW HomeButtonPanel.Visibility = Visibility.Visible; // toolbarScrollViewer.Visibility = Visibility.Visible; } internal void NavigateTo(BeWoView pElement) { if (BeWoApp.RenderTier < 2) NavigateToWithoutFade(pElement); else NavigateToWithFade(pElement); } internal void NavigateToWithoutFade(BeWoView pElement) { if (pElement == null) { NavigateToHomeView(); } else { if (DetailFrame.Children.Count == 1) { var lOld = DetailFrame.Children[0] as BeWoView; if (lOld != null) { if (lOld is HomeView) { var hdpv = lOld as HomeView; hdpv.SaveState(); BeWoApp.SaveAppSettings(); } } DetailFrame.Children.Clear(); } if (pElement != null) { DetailFrame.Children.Add(pElement); } _CurrentDetailView = pElement; DetailFrame.Children.RemoveRange(2); } } internal void NavigateToWithFade(BeWoView pElement) { if (pElement == null) { NavigateToHomeView(); } else { BeWoView lOld = null; if (DetailFrame.Children.Count > 0) { lOld = DetailFrame.Children[0] as BeWoView; if (DetailFrame.Children.Count > 1) { DetailFrame.Children.RemoveRange(1); } if (lOld != null && lOld.Equals(pElement)) return; } if (pElement != null) { pElement.Opacity = 0; DetailFrame.Children.Add(pElement); pElement.Focus(); pElement.BlendIn(); // Object obj = pElement.Template.FindName("togglebutton_maximise", pElement); // obj = pElement.FindName("togglebutton_maximise"); // if (maximizeButton != null) // { // maximizeButton.IsChecked = IsMaximized; // } } _CurrentDetailView = pElement; if (lOld != null) { if (lOld is HomeView) { var hdpv = lOld as HomeView; hdpv.SaveState(); BeWoApp.SaveAppSettings(); } lOld.BlendOutComplete += (s, e) => { if (DetailFrame.Children.Count > 1) DetailFrame.Children.Remove(lOld); }; lOld.BlendOut(); } DetailFrame.Children.RemoveRange(2); } } protected virtual void FirePropertyChanged(string pPropertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(pPropertyName)); } } private void AnimateToolbarIn(int delay) { var animation = new DoubleAnimationUsingKeyFrames(); animation.BeginTime = new TimeSpan(0, 0, 0, 0, delay); animation.KeyFrames.Add(new SplineDoubleKeyFrame(-5, KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 500)), new KeySpline(0, 1, 1, 1))); animation.KeyFrames.Add(new SplineDoubleKeyFrame(0, KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 1000)), new KeySpline(0.35, 0.5, 0.5, 0.9))); var group = (TransformGroup)toolbarRoot.RenderTransform; var trans = (TranslateTransform)group.Children[3]; var animationButtons = new DoubleAnimationUsingKeyFrames(); animationButtons.BeginTime = new TimeSpan(0, 0, 0, 0, delay); animationButtons.KeyFrames.Add(new SplineDoubleKeyFrame(0, KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 500)), new KeySpline(0, 1, 1, 1))); var groupButtons = (TransformGroup)toolbarContent.RenderTransform; var transButtons = (TranslateTransform)groupButtons.Children[3]; transButtons.BeginAnimation(TranslateTransform.YProperty, animationButtons); trans.BeginAnimation(TranslateTransform.YProperty, animation); } private void AnimateToolbarOut(int delay) { var animation = new DoubleAnimationUsingKeyFrames(); animation.BeginTime = new TimeSpan(0, 0, 0, 0, delay); animation.KeyFrames.Add(new SplineDoubleKeyFrame(45, KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 500)), new KeySpline(1, 0, 1, 1))); var group = (TransformGroup)toolbarRoot.RenderTransform; var trans = (TranslateTransform)group.Children[3]; var animationButtons = new DoubleAnimationUsingKeyFrames(); animationButtons.BeginTime = new TimeSpan(0, 0, 0, 0, delay); animationButtons.KeyFrames.Add(new SplineDoubleKeyFrame(100, KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 500)), new KeySpline(1, 0, 1, 1))); var groupButtons = (TransformGroup)toolbarContent.RenderTransform; var transButtons = (TranslateTransform)groupButtons.Children[3]; transButtons.BeginAnimation(TranslateTransform.YProperty, animationButtons); trans.BeginAnimation(TranslateTransform.YProperty, animation); } public bool DoSaveCheck() { return _CurrentDetailView is null || _CurrentDetailView.DoSaveCheck(); } private void InitCommandBindings() { CommandBindings.Add( new CommandBinding( ApplicationCommands.Save, (s, e) => { if (_CurrentModalPopup is null) { _CurrentDetailView.SaveData(); } else { _CurrentDetailView.ModalPopUpSaveInvoked(); } }, (s, e) => { if (_CurrentModalPopup is null) { e.CanExecute = _CurrentDetailView?.IsDirty ?? false; } else { e.CanExecute = _CurrentDetailView != null && (_CurrentModalPopup is BeWoView view && view.IsDirty); } })); CommandBindings.Add(new CommandBinding(BeWoCommands.Excel, (s, e) => _CurrentDetailView.ExportToExcel(e.Parameter as string), (s, e) => e.CanExecute = _CurrentDetailView != null ? _CurrentDetailView.CanExcelExport : false)); CommandBindings.Add(new CommandBinding(ApplicationCommands.Delete, (s, e) => _CurrentDetailView.Delete(), (s, e) => e.CanExecute = _CurrentDetailView != null ? _CurrentDetailView.CanDelete : false)); CommandBindings.Add(new CommandBinding(BeWoCommands.Word, (s, e) => _CurrentDetailView.ExportToWord(e.Parameter as string), (s, e) => e.CanExecute = _CurrentDetailView != null ? _CurrentDetailView.CanWordExport : false)); CommandBindings.Add( new CommandBinding( ApplicationCommands.Close, (s, e) => { if (_CurrentModalPopup == null && DoSaveCheck()) { if (_CurrentDetailView.ParentView != null) _CurrentDetailView.ParentView.ChildViewClosed(); NavigateToParentView(_CurrentDetailView.ParentView); } else { _CurrentDetailView.ModalPopUpCloseInvoked(); } }, (s, e) => e.CanExecute = _CurrentDetailView != null)); } internal void UpdateMandator() { if (BeWoApp.Mandator is null) return; var url = BeWoApp.Mandator.Website.ToNullIfEmpty(); var haslogo = BeWoApp.Mandator.Logo?.Original is object; if (haslogo) { image2.Source = Utils.CreateBitmapImageFromByteArray(BeWoApp.Mandator.Logo.Original); Grid.SetColumn(txt_logo, 2); txt_logo2.Visibility = Visibility.Visible; if (Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out Uri res)) { hyperlink_2.NavigateUri = res; } else { hyperlink_2.NavigateUri = null; } column2.Width = new GridLength(1, GridUnitType.Auto); } else { Grid.SetColumn(txt_logo, 0); txt_logo2.Visibility = Visibility.Collapsed; column2.Width = new GridLength(150); } } private void NavigateToParentView(BeWoView beWoView) { if (beWoView is CustomerNavigationView && !_Views.ContainsKey(UIContext.Customer)) { _Views.Add(UIContext.Customer, beWoView); } else if (beWoView is EmployeeNavigationView && !_Views.ContainsKey(UIContext.Employee)) { _Views.Add(UIContext.Employee, beWoView); } else if (beWoView is OrganisationNavigationView && !_Views.ContainsKey(UIContext.Organisation)) { _Views.Add(UIContext.Organisation, beWoView); } else if (beWoView is PersonNavigationView && !_Views.ContainsKey(UIContext.Person)) { _Views.Add(UIContext.Person, beWoView); } else if (beWoView is SupportConceptNavigationView && !_Views.ContainsKey(UIContext.SupportConcept)) { _Views.Add(UIContext.SupportConcept, beWoView); } else if (beWoView is TeamNavigationView && !_Views.ContainsKey(UIContext.Team)) { _Views.Add(UIContext.Team, beWoView); } else if (beWoView is UserNavigationView && !_Views.ContainsKey(UIContext.User)) { _Views.Add(UIContext.User, beWoView); } else if (beWoView is UserGroupNavigationView && !_Views.ContainsKey(UIContext.UserGroup)) { _Views.Add(UIContext.UserGroup, beWoView); } else if (beWoView is WohnheimNavigationView && !_Views.ContainsKey(UIContext.Wohnheim)) { _Views.Add(UIContext.Wohnheim, beWoView); } NavigateTo(beWoView); } private void MainControl_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Back) { e.Handled = true; } } private void NavigateToHomeView() { if (_HomeView == null) { _HomeView = new HomeView(); } else { //_HomeView.ReorderPanels(); } NavigateTo(_HomeView); // VarFieldListVM v = new VarFieldListVM(l); // NavigateTo(new VarFieldView(v)); } private void OnLoadedStoryboard_Completed(object sender, EventArgs e) { if (BeWoApp.AppSettings.WindowState == AppSettings.WindowStateType.Maximised) { Maximize(); IsMaximized = true; FirePropertyChanged("IsMaximized"); } } internal void ShowModalBackgroundFade(double duration = 0.3, double opacity = 0.5) { if (ModalPopupBackGround is Grid && grid_main.Children.Contains(ModalPopupBackGround)) return; ShowModalBackground(0); DoubleAnimation lAnim = new DoubleAnimation(opacity, new Duration(TimeSpan.FromSeconds(duration))); ModalPopupBackGround.BeginAnimation(OpacityProperty, lAnim); } internal void ShowModalBackground(double start_opacity = .5) { if (ModalPopupBackGround is Grid && grid_main.Children.Contains(ModalPopupBackGround)) return; ModalPopupBackGround = new Grid { IsHitTestVisible = true, Background = Brushes.White, Opacity = start_opacity }; Grid.SetColumnSpan(ModalPopupBackGround, 3); Grid.SetRowSpan(ModalPopupBackGround, 3); grid_main.Children.Add(ModalPopupBackGround); Panel.SetZIndex(ModalPopupBackGround, 500); } internal void HideModalBackgroundFade(double duration = 0.3) { if (ModalPopupBackGround is null || !grid_main.Children.Contains(ModalPopupBackGround)) return; DoubleAnimation lAnim = new DoubleAnimation(0, new Duration(TimeSpan.FromSeconds(duration))); lAnim.Completed += (s, e) => { HideModalBackground(); }; ModalPopupBackGround.BeginAnimation(OpacityProperty, lAnim); } internal void HideModalBackground() { if (ModalPopupBackGround is null || !grid_main.Children.Contains(ModalPopupBackGround)) return; grid_main.Children.Remove(ModalPopupBackGround); ModalPopupBackGround = null; } private void logoutanimation_Completed(object sender, EventArgs e) { //var navigationService = NavigationService.GetNavigationService(this); //if (navigationService != null) //{ // navigationService.Navigate(new LoginPage()); BeWoApp.UserName = string.Empty; BeWoApp.UserPassword = string.Empty; // BeWoApp.Tenant = ""; BeWoApp.LoggedOnUser = null; //} if (LogoutClicked != null) LogoutClicked(null, new EventArgs()); } private void btn_home_Click(object sender, RoutedEventArgs e) { if (!(_CurrentDetailView is HomeView) && DoSaveCheck()) { NavigateToHomeView(); } } private void button_AccountingTransacation_Click(object sender, RoutedEventArgs e) { if (DoSaveCheck()) { NavigateTo(GetViewForUIContext(UIContext.Finance)); } } private void button_Administration_Click(object sender, RoutedEventArgs e) { if (DoSaveCheck()) { NavigateTo(GetViewForUIContext(UIContext.Administration)); } } // private void ExcelExport_RequestNavigate(object sender, RequestNavigateEventArgs e) // { // BeWoCommands.Excel.Execute(LinkEngine.ExcelFileId, ExcelExport); // LinkEngine.GenerateNewExcelLink(); // } // private void WordExport_RequestNavigate(object sender, RequestNavigateEventArgs e) // { // BeWoCommands.Word.Execute(LinkEngine.WordFileId, WordExport); // LinkEngine.GenerateNewWordLink(); // } private void button_Customer_Click(object sender, RoutedEventArgs e) { if (DoSaveCheck()) { NavigateTo(GetViewForUIContext(UIContext.Customer)); } } private void button_Wohnheim_Click(object sender, RoutedEventArgs e) { if (DoSaveCheck()) { NavigateTo(GetViewForUIContext(UIContext.Wohnheim)); } } private void button_Employee_Click(object sender, RoutedEventArgs e) { if (DoSaveCheck()) { NavigateTo(GetViewForUIContext(UIContext.Employee)); } } private void button_Home(object sender, RoutedEventArgs e) { if (DoSaveCheck()) { // NavigateTo(new HomeView()); NavigateTo(new HomeView()); } } private void button_Logout(object sender, RoutedEventArgs e) { if (DoSaveCheck()) { Cache.GetInstance().ClearAll(); _Views = new Dictionary(); var animation = new DoubleAnimationUsingKeyFrames(); animation.KeyFrames.Add(new SplineDoubleKeyFrame(100, KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 500)), new KeySpline(1, 0, 1, 1))); var group = (TransformGroup)toolbarRoot.RenderTransform; var trans = (TranslateTransform)group.Children[3]; trans.BeginAnimation(TranslateTransform.YProperty, animation); animation = new DoubleAnimationUsingKeyFrames(); animation.Completed += logoutanimation_Completed; animation.KeyFrames.Add(new SplineDoubleKeyFrame(-200, KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 500)), new KeySpline(1, 0, 1, 1))); group = (TransformGroup)image.RenderTransform; trans = (TranslateTransform)group.Children[3]; trans.BeginAnimation(TranslateTransform.XProperty, animation); ClearDetailFrame(); } //Hier das mit Chat Refreshen if (BeWoApp.MainControl != null && BeWoApp.MainControl.HomeView.ServiceChatView != null) { if (BeWoApp.MainControl.HomeView.ServiceChatView.ChatMainControl != null && BeWoApp.MainControl.HomeView.ServiceChatView.ChatMainControl.GlobalListeningThreadtimer != null) { BeWoApp.MainControl.HomeView.ServiceChatView.ChatMainControl.GlobalListeningThreadtimer.Stop(); BeWoApp.MainControl.HomeView.ServiceChatView.ChatMainControl.GlobalListeningThreadtimer = null; BeWoApp.MainControl.HomeView.ServiceChatView.ChatMainControl.ShouldInterruptContactsThread = true; } if (BeWoApp.MainControl.HomeView.ServiceChatView.ServiceChat.EmojiView != null) { BeWoApp.MainControl.HomeView.ServiceChatView.ServiceChat.EmojiView.Close(); BeWoApp.MainControl.HomeView.ServiceChatView.ServiceChat.EmojiView = null; } if (BeWoApp.MainControl.HomeView.ServiceChatView.ChatMainControl != null) { BeWoApp.MainControl.HomeView.ServiceChatView.ChatMainControl.DeleteTempFiles(); } BeWoApp.MainControl.HomeView.ServiceChatView.Close(); BeWoApp.MainControl.HomeView.ServiceChatView = null; } BeWoApp.Cleanup(); //Ende } private void button_Organisation_Click(object sender, RoutedEventArgs e) { if (DoSaveCheck()) { NavigateTo(GetViewForUIContext(UIContext.Organisation)); } } private void button_Person_Click(object sender, RoutedEventArgs e) { if (DoSaveCheck()) { NavigateTo(GetViewForUIContext(UIContext.Person)); } } private void button_Reports_Click(object sender, RoutedEventArgs e) { if (DoSaveCheck()) { NavigateTo(GetViewForUIContext(UIContext.Report)); } } private void button_ResourceBooking_Click(object sender, RoutedEventArgs e) { if (DoSaveCheck()) { ServiceFacade.DoResourceServiceAsync( s1 => s1.GetAllResources(), r1 => ServiceFacade.DoEmployeeServiceAsync( s2 => s2.GetAllActiveEmployeesCompact(), r2 => { if (r1.Count > 0 && r2.Count > 0) { try { Dictionary> lCategoriesToResources = r1.Select(res => res.ResourceCategory).Distinct().OrderBy(cat => cat.TypeDescription).Select(cat => new { Key = cat, Value = r1.Where(res => res.ResourceCategory.Equals(cat)).OrderBy(res => res.Name).ToList() }).ToDictionary(a => a.Key, a => a.Value); this.Dispatch(delegate { NavigateTo(new BookingView(lCategoriesToResources, r2, BeWoApp.LoggedOnUser.Employee)); }); } catch (Exception) { MessageBox.Show("Bitte legen Sie zunächst unter Verwaltung Resourcen und Resourcenkategorien an."); } } })); } } private void button_Scheduler_Click(object sender, RoutedEventArgs e) { if (DoSaveCheck()) { NavigateTo(GetViewForUIContext(UIContext.Scheduler)); } } private void button_SupportConcept_Click(object sender, RoutedEventArgs e) { if (DoSaveCheck()) { NavigateTo(GetViewForUIContext(UIContext.SupportConcept)); } } private void button_Team_Click(object sender, RoutedEventArgs e) { if (DoSaveCheck()) { NavigateTo(GetViewForUIContext(UIContext.Team)); } } private void button_Dokumente_Click(object sender, RoutedEventArgs e) { if (DoSaveCheck()) { NavigateTo(GetViewForUIContext(UIContext.Dokumente)); } } private void button_CustomerTeam_Click(object sender, RoutedEventArgs e) { if (DoSaveCheck()) { NavigateTo(GetViewForUIContext(UIContext.CustomerTeam)); } } private void button_UserGroup_Click(object sender, RoutedEventArgs e) { if (DoSaveCheck()) { NavigateTo(GetViewForUIContext(UIContext.UserGroup)); } } private void button_User_Click(object sender, RoutedEventArgs e) { if (DoSaveCheck()) { NavigateTo(GetViewForUIContext(UIContext.User)); } } private void button_ai_chat_Click(object sender, RoutedEventArgs e) { if (DoSaveCheck()) { NavigateTo(GetViewForUIContext(UIContext.AiConversation)); } } //private void button_assessmentSheetEntry_Click(object sender, RoutedEventArgs e) //{ // if (this.DoSaveCheck()) // { // this.NavigateTo(new AssessmentSheetEntryView()); // } //} private void button_resources_Click(object sender, RoutedEventArgs e) { if (DoSaveCheck()) { VMFactory.CreateResourceListVMAsync(cb => this.Dispatch(delegate { NavigateTo(new RessourceView(cb)); })); } } private void button_serviceRecord_Click(object sender, RoutedEventArgs e) { NavigateToServiceRecordView(null); } private void button_additionalService_Click(object sender, RoutedEventArgs e) { NavigateToAdditionalServiceView(null); } private void maximizeAnimation_Completed(object sender, EventArgs e) { IsMaximized = true; } private void minimizeAnimation_Completed(object sender, EventArgs e) { IsMaximized = false; } private void toolbarRoot_MouseEnter(object sender, MouseEventArgs e) { if (IsMaximized) { AnimateToolbarIn(500); } } private void toolbarRoot_MouseLeave(object sender, MouseEventArgs e) { if (IsMaximized) { AnimateToolbarOut(200); } } private void toolbarScrollViewer_ScrollChanged(object sender, ScrollChangedEventArgs e) { e.Handled = true; } private void Hyperlink_OnRequestNavigate(object sender, RequestNavigateEventArgs e) { // Hier Token anfordern; Hier nicht notwendig -> Link auf www.beyondsoft.de var url = (sender as Hyperlink).NavigateUri.ToString(); if (string.IsNullOrWhiteSpace(url)) return; Process.Start(new ProcessStartInfo(url)); } private void button_Support_Click(object sender, RoutedEventArgs e) { var mailButton = new Button { Content = "*", FontFamily = new FontFamily("Wingdings"), FontSize = 16, Width = 25, Margin = new Thickness(5), HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center }; var phoneButton = new Button { Content = ")", FontFamily = new FontFamily("Wingdings"), FontSize = 16, Width = 25, Margin = new Thickness(5), HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center }; var cancelButton = new Button { Content = "Schließen" }; cancelButton.Margin = new Thickness(5); cancelButton.Width = 100; cancelButton.HorizontalAlignment = HorizontalAlignment.Right; var mailLabel = new Label { Content = "Support-Mail schreiben", FontWeight = FontWeights.Bold, Margin = new Thickness(5), HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center }; //var mailButtonLabel = new Button //{ // Content = "Support-Mail schreiben", // FontWeight = FontWeights.Bold, // Margin = new Thickness(5), // HorizontalContentAlignment = HorizontalAlignment.Center, // VerticalContentAlignment = VerticalAlignment.Center, // Style = null, // Background = Brushes.Transparent //}; //mailButtonLabel.Content = mailLabel; var textBlockMail = new TextBlock { Foreground = Brushes.Black, Margin = new Thickness(45, 5, 5, 5), Text = "Wenn Sie auf das Brief-Symbol klicken öffnet sich ein Fenster,\nin dem Sie eine E-Mail an den BeWoPlaner-Support formulieren können" }; var phoneLabel = new Label { Content = "PIN für Support erhalten", FontWeight = FontWeights.Bold, Margin = new Thickness(5), HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center }; var textBlockPhone = new TextBlock { Foreground = Brushes.Black, Margin = new Thickness(45, 5, 5, 5), Text = "Wenn Sie auf das PIN-Symbol klicken, wird Ihnen eine zufällige Support-PIN angezeigt.\n\n" + "Benötigen wir zur Lösung einer Support-Anfrage den Zugriff auf Ihre Datenbank,\n" + "werden Sie " + Translator.Translate("vom Support-Mitarbeiter") + " gebeten, ihm eine solche Support-PIN zu übermitteln.\n" + "Diese PIN ist nur einmalig nutzbar/gültig. Sie wird nicht automatisch an den Support übermittelt.\n" + "Dies stellt sicher, dass " + Translator.Translate("ein Support-Mitarbeiter") + " nicht ohne Ihre Einwilligung auf Ihre Datenbank zugreifen kann.\n" + "Jeder Support-Zugriff auf Ihre Datenbank wird zudem mit Hilfe der PIN protokolliert." }; /* * www.ownsoft.de */ var tvLabel = new Label { Content = "Support per Fernwartung", FontWeight = FontWeights.Bold, Margin = new Thickness(40, 5, 5, 5) }; var textBlockTeamViewer = new TextBlock { Foreground = Brushes.Black, Margin = new Thickness(45, 5, 5, 5), Text = "Wenn Sie in einem Telefonat mit " + Translator.Translate("einem unserer Support-Mitarbeiter") + " aufgefordert werden\nden Teamviewer zu installieren, so können Sie ihn hier herunterladen." }; var supportToolLink = new TextBlock { Foreground = Brushes.Black, Margin = new Thickness(45, 5, 5, 5), FontSize = 12 }; String linkText = "Teamviewer herunterladen"; String url = "https://get.teamviewer.com/dj5y4zy"; if (!String.IsNullOrWhiteSpace(BeWoApp.Mandator.SupportToolUrl)) { url = BeWoApp.Mandator.SupportToolUrl; if (BeWoApp.Mandator.SupportToolUrl.Contains("<") && BeWoApp.Mandator.SupportToolUrl.Contains(">") && BeWoApp.Mandator.SupportToolUrl.IndexOf("<") > 0) { linkText = BeWoApp.Mandator.SupportToolUrl.Substring(0, BeWoApp.Mandator.SupportToolUrl.IndexOf("<")); url = BeWoApp.Mandator.SupportToolUrl.Substring(BeWoApp.Mandator.SupportToolUrl.IndexOf("<")); url = url.Replace("<", "").Replace(">", ""); } } Hyperlink link = new Hyperlink(); link.NavigateUri = new Uri(url); link.TargetName = "newWindow"; link.Inlines.Add(linkText); supportToolLink.Inlines.Add(link); link.RequestNavigate += (s, e2) => { System.Diagnostics.Process.Start( new System.Diagnostics.ProcessStartInfo((s as Hyperlink).NavigateUri.ToString())); }; BeWoWindow bewoWindow = BeWoWpfUtils.CreateBeWoPopupWindow(300, 1000, true); cancelButton.Click += delegate { bewoWindow.Close(); }; mailButton.Click += delegate { bewoWindow.Close(); CreateSupportMailWindow(); }; phoneButton.Click += delegate { bewoWindow.Close(); CreateSupportRequestWindow(); }; //var mailHelpButton = new Button //{ // Content = "?", // Width = 25, // Margin = new Thickness(5), // HorizontalContentAlignment = HorizontalAlignment.Center, // VerticalContentAlignment = VerticalAlignment.Center, // ToolTip = "Wenn Sie auf das Brief-Symbol klicken öffnet sich ein Fenster,\nin dem Sie eine E-Mail an den BeWoPlaner-Support formulieren können" //}; //var phoneHelpButton = new Button //{ // Content = "?", // Width = 25, // Margin = new Thickness(5), // HorizontalContentAlignment = HorizontalAlignment.Center, // VerticalContentAlignment = VerticalAlignment.Center, // ToolTip = "Wenn Sie auf das PIN-Symbol klicken, wird Ihnen eine zufällige Support-PIN angezeigt.\n\n" + // "Benötigen wir zur Lösung einer Support-Anfrage den Zugriff auf Ihre Datenbank,\n" + // "werden Sie vom Support-Mitarbeiter gebeten, ihm eine solche Support-PIN zu übermitteln.\n" + // "Diese PIN ist nur einmalig nutzbar/gültig. Sie wird nicht automatisch an den Support übermittelt.\n" + // "Dies stellt sicher, dass ein Support-Mitarbeiter nicht ohne Ihre Einwilligung auf Ihre Datenbank zugreifen kann.\n"+ // "Jeder Support-Zugriff auf Ihre Datenbank wird zudem mit Hilfe der PIN protokolliert." //}; var centeredStackPanel = new StackPanel { Orientation = Orientation.Vertical, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center }; var mailStackPanel = new StackPanel { Orientation = Orientation.Horizontal }; var phoneStackPanel = new StackPanel { Orientation = Orientation.Horizontal }; var tvStackPanel = new StackPanel { Orientation = Orientation.Horizontal }; mailStackPanel.Children.Add(mailButton); mailStackPanel.Children.Add(mailLabel); phoneStackPanel.Children.Add(phoneButton); phoneStackPanel.Children.Add(phoneLabel); centeredStackPanel.Children.Add(mailStackPanel); centeredStackPanel.Children.Add(textBlockMail); centeredStackPanel.Children.Add(phoneStackPanel); centeredStackPanel.Children.Add(textBlockPhone); centeredStackPanel.Children.Add(tvLabel); centeredStackPanel.Children.Add(textBlockTeamViewer); centeredStackPanel.Children.Add(supportToolLink); centeredStackPanel.Children.Add(cancelButton); var grid = new Grid { Background = (LinearGradientBrush)FindResource("ObjectEditBackgroundBrush") }; grid.Children.Add(centeredStackPanel); bewoWindow.GroupBoxContent = grid; bewoWindow.rootGroupBox.Header = "Support"; bewoWindow.Owner = BeWoApp.CurrentBeWo.MainWindow; bewoWindow.Show(); } private void CreateSupportMailWindow() { BeWoWindow bewoWindow = BeWoWpfUtils.CreateBeWoPopupWindow(600, 800); bewoWindow.SizeChanged += delegate { bewoWindow.Left = ActualWidth / 2 - bewoWindow.Width / 2; bewoWindow.Top = ActualHeight / 2 - bewoWindow.Height / 2; }; //var grid = new Grid //{ // Background = (LinearGradientBrush) FindResource("ObjectEditBackgroundBrush") //}; //var infoGrid = new Grid //{ // Background = (LinearGradientBrush) FindResource("ObjectEditBackgroundBrush") //}; //var beschreibungLabel = new Label {Content = "Hier können Sie eine E-Mail an den BeWoPlaner-Support formulieren.", Margin = new Thickness(3)}; //var betreffLabel = new Label {Content = "Betreff:", Margin = new Thickness(3)}; //var betreffTextBox = new TextBox {Margin = new Thickness(3, 3, 3, 0)}; //var nachrichtsTextBox = new TextBox //{ // Margin = new Thickness(3), // AcceptsReturn = true, // VerticalScrollBarVisibility = ScrollBarVisibility.Auto, // HorizontalScrollBarVisibility = ScrollBarVisibility.Auto //}; //var pinCheckBox = new CheckBox //{ // Margin = new Thickness(3), // Content = "PIN anfügen", // ToolTip = "Nur mit dieser PIN erhält ein Servicemitarbeiter Zugang zu Ihren Daten" //}; //var abbrechenButton = new Button {Margin = new Thickness(3), Content = "Abbrechen"}; //var schliessenButton = new Button {Margin = new Thickness(3), Content = "Schließen"}; //var sendenButton = new Button //{ // Margin = new Thickness(3), // Content = "Senden", // HorizontalAlignment = HorizontalAlignment.Left //}; //var zurueckButton = new Button //{ // Margin = new Thickness(3), // Content = "Zurück" //}; //var weiterButton = new Button //{ // Margin = new Thickness(3), // Content = "Weiter", // HorizontalAlignment = HorizontalAlignment.Left //}; //weiterButton.Click += delegate { bewoWindow.GroupBoxContent = infoGrid; }; //zurueckButton.Click += delegate //{ // bewoWindow.GroupBoxContent = grid; // bewoWindow.Left = ActualWidth/2 - bewoWindow.Width/2; // bewoWindow.Top = ActualHeight/2 - bewoWindow.Height/2; //}; //grid.ColumnDefinitions.Add(new ColumnDefinition {Width = GridLength.Auto}); //grid.ColumnDefinitions.Add(new ColumnDefinition {Width = GridLength.Auto}); //grid.ColumnDefinitions.Add(new ColumnDefinition {Width = new GridLength(1, GridUnitType.Star)}); //grid.ColumnDefinitions.Add(new ColumnDefinition {Width = GridLength.Auto}); //grid.RowDefinitions.Add(new RowDefinition {Height = GridLength.Auto}); //grid.RowDefinitions.Add(new RowDefinition {Height = GridLength.Auto}); //grid.RowDefinitions.Add(new RowDefinition {Height = new GridLength(1, GridUnitType.Star)}); //grid.RowDefinitions.Add(new RowDefinition {Height = GridLength.Auto}); //grid.RowDefinitions.Add(new RowDefinition {Height = GridLength.Auto}); //Grid.SetRow(beschreibungLabel, 0); //Grid.SetRow(betreffLabel, 1); //Grid.SetRow(betreffTextBox, 1); //Grid.SetRow(nachrichtsTextBox, 2); //Grid.SetRow(abbrechenButton, 3); //Grid.SetRow(weiterButton, 3); //Grid.SetColumn(betreffLabel, 0); //Grid.SetColumn(betreffTextBox, 1); //Grid.SetColumn(nachrichtsTextBox, 0); //Grid.SetColumn(abbrechenButton, 3); //Grid.SetColumn(weiterButton, 0); //Grid.SetColumnSpan(beschreibungLabel, 4); //Grid.SetColumnSpan(betreffTextBox, 3); //Grid.SetColumnSpan(nachrichtsTextBox, 4); //Grid.SetColumnSpan(weiterButton, 2); //grid.Children.Add(beschreibungLabel); //grid.Children.Add(betreffLabel); //grid.Children.Add(betreffTextBox); //grid.Children.Add(nachrichtsTextBox); //grid.Children.Add(abbrechenButton); //grid.Children.Add(weiterButton); //abbrechenButton.Click += delegate { bewoWindow.Close(); }; //schliessenButton.Click += delegate { bewoWindow.Close(); }; //sendenButton.Click += delegate //{ // if (betreffTextBox.Text.IsNullOrEmpty()) // { // MessageBox.Show("Bitte geben Sie einen Betreff an.", "Senden nicht möglich", // MessageBoxButton.OK, MessageBoxImage.Warning); // return; // } // if (nachrichtsTextBox.Text.IsNullOrEmpty()) // { // MessageBox.Show("Bitte tragen Sie eine Nachricht ein.", "Senden nicht möglich", // MessageBoxButton.OK, MessageBoxImage.Warning); // return; // } // string nachricht = nachrichtsTextBox.Text; // if (pinCheckBox.IsChecked.HasValue && pinCheckBox.IsChecked.Value) // { // nachricht += string.Format("\r\rPIN: {0}", GeneratePIN()); // } // EMailVersenden(betreffTextBox.Text, nachricht); //}; //var infoTextBlock = new TextBlock //{ // Text = _PINInfoText, // Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 0)), // Margin = new Thickness(3), // TextWrapping = TextWrapping.Wrap, // TextAlignment = TextAlignment.Center, // VerticalAlignment = VerticalAlignment.Center //}; //var naviStackPanel = new StackPanel {Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Right}; //naviStackPanel.Children.Add(zurueckButton); //naviStackPanel.Children.Add(schliessenButton); //infoGrid.RowDefinitions.Add(new RowDefinition {Height = new GridLength(1, GridUnitType.Star)}); //infoGrid.RowDefinitions.Add(new RowDefinition {Height = GridLength.Auto}); //infoGrid.RowDefinitions.Add(new RowDefinition {Height = GridLength.Auto}); //infoGrid.ColumnDefinitions.Add(new ColumnDefinition()); //infoGrid.ColumnDefinitions.Add(new ColumnDefinition()); //Grid.SetRow(infoTextBlock, 0); //Grid.SetRow(pinCheckBox, 1); //Grid.SetRow(naviStackPanel, 2); //Grid.SetRow(sendenButton, 2); //Grid.SetColumn(naviStackPanel, 1); //Grid.SetColumnSpan(infoTextBlock, 2); //infoGrid.Children.Add(infoTextBlock); //infoGrid.Children.Add(pinCheckBox); //infoGrid.Children.Add(sendenButton); //infoGrid.Children.Add(naviStackPanel); SupportEMailControl ctrl = new SupportEMailControl(); ctrl.SenderName = String.Format("{0} {1}", BeWoApp.LoggedOnEmployee.FirstName, BeWoApp.LoggedOnEmployee.LastName); if (BeWoApp.LoggedOnEmployee.ContactInformations != null) { foreach (var contact in BeWoApp.LoggedOnEmployee.ContactInformations) { if (contact.ContactType == ContactType.business_Mail) { ctrl.SenderEMail = contact.ContactValue; } } } ctrl.CancelButtonClicked += delegate { bewoWindow.Close(); }; ctrl.OkButtonClicked += delegate { string nachricht = ctrl.Message; nachricht = String.Format("Supportanfrage von {0} <{1}>:\n\n{2}", ctrl.SenderName, ctrl.SenderEMail, nachricht); if (ctrl.CheckBoxSupportPin.IsChecked.HasValue && ctrl.CheckBoxSupportPin.IsChecked.Value) { nachricht += string.Format("\n\nPIN: {0}", GeneratePIN()); } EMailVersenden(ctrl.SenderName, ctrl.SenderEMail, ctrl.Subject, nachricht, bewoWindow); }; bewoWindow.GroupBoxContent = ctrl; bewoWindow.rootGroupBox.Header = "E-Mail versenden"; bewoWindow.Owner = BeWoApp.CurrentBeWo.MainWindow; bewoWindow.Show(); } private void EMailVersenden(string senderName, string senderEMail, string betreff, string nachricht, BeWoWindow window) { var result = ServiceFacade.DoMailServiceSync(m => m.SendEMailWithSender(senderName, senderEMail, betreff, nachricht)); if (result) { window.Close(); MessageBox.Show("Die E-Mail wurde erfolgreich versendet.", "E-Mail senden", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("Die E-Mail konnte leider nicht gesendet werden", "E-Mail senden", MessageBoxButton.OK, MessageBoxImage.Error); } } private void CreateSupportRequestWindow() { BeWoWindow bewoWindow = BeWoWpfUtils.CreateBeWoPopupWindow(withDynamicSize: true); #region PIN Erzeugen var grid = new Grid { Width = 300d, Background = (LinearGradientBrush)FindResource("ObjectEditBackgroundBrush") }; var label1 = new Label { Content = "Ihre PIN lautet:", HorizontalAlignment = HorizontalAlignment.Center }; var boldLabel = new Label { Content = "", FontWeight = FontWeights.Bold, HorizontalAlignment = HorizontalAlignment.Center }; var label3 = new Label { Content = "Bitte geben Sie diese PIN beim Support-Anruf an", HorizontalAlignment = HorizontalAlignment.Center }; var cancelButton = new Button { Content = "Schließen" }; cancelButton.Click += delegate { bewoWindow.Close(); }; var centeredStackPanel = new StackPanel { Orientation = Orientation.Vertical, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center }; centeredStackPanel.Children.Add(label1); centeredStackPanel.Children.Add(boldLabel); centeredStackPanel.Children.Add(label3); centeredStackPanel.Children.Add(cancelButton); grid.Children.Add(centeredStackPanel); #endregion #region InfoText var infoTextBlock = new TextBlock { Text = _PINInfoText, Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 0)), Margin = new Thickness(3), TextWrapping = TextWrapping.Wrap, TextAlignment = TextAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; var infoGrid = new Grid { Background = (LinearGradientBrush)FindResource("ObjectEditBackgroundBrush") }; var pinErzeugenButton = new Button { Content = "PIN erzeugen", Margin = new Thickness(3) }; infoGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); infoGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); Grid.SetRow(infoTextBlock, 0); Grid.SetRow(pinErzeugenButton, 1); infoGrid.Children.Add(infoTextBlock); infoGrid.Children.Add(pinErzeugenButton); pinErzeugenButton.Click += delegate { bewoWindow.GroupBoxContent = grid; boldLabel.Content = GeneratePIN(); }; #endregion bewoWindow.GroupBoxContent = infoGrid; bewoWindow.rootGroupBox.Header = "Support"; bewoWindow.Owner = BeWoApp.CurrentBeWo.MainWindow; bewoWindow.Show(); } private static string GeneratePIN(int maxSize = 5) { var data = new byte[1]; var crypto = new RNGCryptoServiceProvider(); var result = new StringBuilder(maxSize); char[] chars = "ABCDEFGHJKLMNPQRSTUVWXYZ123456789".ToCharArray(); crypto.GetBytes(data); data = new byte[maxSize]; crypto.GetBytes(data); foreach (byte b in data) result.Append(chars[b % (chars.Length)]); var pin = new SupportPinDC { Pin = result.ToString(), IsUsed = false, CreationDate = DateTime.Now }; pin.ExpirationDate = pin.CreationDate.Value.AddDays(3); ServiceFacade.DoUserServiceAsync(p => { long res = -1; while (res == -1L) { pin = new SupportPinDC { Pin = result.ToString(), IsUsed = false, CreationDate = DateTime.Now }; pin.ExpirationDate = pin.CreationDate.Value.AddDays(3); res = p.InsertNewSupportPin(pin); } }, false); return result.ToString(); } private void button_Template_Click(object sender, RoutedEventArgs e) { if (DoSaveCheck()) { NavigateTo(new WordDocumentTemplateView(TableID.Mandator, 1)); } } //private void UIElement_OnMouseEnter(object sender, MouseEventArgs e) //{ // AufOffeneTerminePruefen(); //} public void InitOffeneTermine() { //if (!_TermineInitialized && BeWoApp.LoggedOnEmployee != null) //{ // AufOffeneTerminePruefen(); // _TermineInitialized = true; //} } public void AufOffeneTerminePruefen() { if (BeWoApp.LoggedOnEmployee != null && BeWoApp.LoggedOnEmployee.EmployeeOid != null && BeWoApp.AppSettings.IsSchedulerAllowed) ServiceFacade.DoResourceServiceAsync(rs => rs.GetAllOpenAppointmentsForEmployee(BeWoApp.LoggedOnEmployee.EmployeeOid.Value), r => this.Dispatch(delegate { HatNeueTermine = r.Count > 0; }), false); } private void ToolbarContent_OnLoaded(object sender, RoutedEventArgs e) { InitOffeneTermine(); } private void Button_Vertretungen_OnClick(object sender, RoutedEventArgs e) { if (DoSaveCheck()) { NavigateTo(GetViewForUIContext(UIContext.Vertretungen)); } } private void Button_Scheduling_Click(object sender, RoutedEventArgs e) { if (DoSaveCheck()) { NavigateTo(GetViewForUIContext(UIContext.Scheduling)); } } private void button_ai_chat_popup_Click(object sender, RoutedEventArgs e) { var view = GetViewForUIContext(UIContext.AiConversationPopup); var window = BeWoWindowBuilder.GetBeWoWindow("Ai Chat", view, 800, 1200); window.Show(); } } }