private void Diagnostic(object parameter) { System.Windows.Controls.UserControl ctrl = parameter as System.Windows.Controls.UserControl; IMasterDisplayWindow displayWin = Window.GetWindow(ctrl) as IMasterDisplayWindow; SettingManager.Instance.Diagnostic(displayWin); }
public static Rect GetOwnerWindowRect(Window messageBox, IMasterDisplayWindow owner) { if (null == owner) { return(new Rect(0, 0, 0, 0)); } double ratio = 1; double ownerLeft = 0; double ownerTop = 0; double ownerWidth = 0; double ownerHeight = 0; ownerWidth = owner.GetWidth(); ownerHeight = owner.GetHeight(); ownerLeft = owner.GetLeft(); ownerTop = owner.GetTop(); ratio = owner.GetSizeRatio(); ratio = ratio > 0 ? ratio : 1; if (ratio != 1) { double width = messageBox.Width * ratio; double height = messageBox.Height * ratio; double left = ownerLeft + (ownerWidth - width) / 2; double top = ownerTop + (ownerHeight - height) / 2; return(new Rect(left, top, width, height)); } else { return(new Rect(messageBox.Left, messageBox.Top, messageBox.Width, messageBox.Height)); } }
public void ShowPromptTip(string prompt, string extraInfo) { IMasterDisplayWindow masterWindow = GetCurrentMainDisplayWindow(); if (null == masterWindow) { log.Info("Can not show error message for master window is null"); return; } CloseMessageBoxTip(); _messageBoxTip = new MessageBoxTip(); _messageTipExtraInfo = extraInfo; Window tipOwner = null; if ( null != (masterWindow as VideoPeopleWindow) && LayoutBackgroundWindow.Instance.IsLoaded && LayoutBackgroundWindow.Instance.LayoutOperationbarWindow.IsLoaded ) { tipOwner = LayoutBackgroundWindow.Instance.LayoutOperationbarWindow; } log.InfoFormat("ShowPromptTip(MessageBoxTip), hash: {0}, tipOwner is null:{1}, ", _messageBoxTip.GetHashCode(), null == tipOwner); DisplayUtil.SetWindowCenterAndOwner(_messageBoxTip, masterWindow, tipOwner); _messageBoxTip.SetTitleAndMsg(LanguageUtil.Instance.GetValueByKey("PROMPT"), prompt, LanguageUtil.Instance.GetValueByKey("CONFIRM")); _messageBoxTip.ShowDialog(); _messageBoxTip = null; _messageTipExtraInfo = ""; }
public void p2pCall(string peerInfo) { log.InfoFormat("p2pCall: {0}", peerInfo); Rest.ServerRest.P2PUserRest peerUser = JsonConvert.DeserializeObject <Rest.ServerRest.P2PUserRest>(peerInfo); if (null == peerUser) { log.InfoFormat("Failed to parse p2pCall data: {0}", peerInfo); return; } string userId = peerUser.userId.ToString(); if (string.IsNullOrEmpty(userId.Trim())) { log.Info("Failed P2P Call for empty userId"); return; } if (LoginManager.Instance.CurrentLoginStatus == LoginStatus.LoggedIn && !LoginManager.Instance.IsRegistered) { IMasterDisplayWindow ownerWindow = (MainWindow)System.Windows.Application.Current.MainWindow; MessageBoxTip tip = new MessageBoxTip(ownerWindow); tip.SetTitleAndMsg(LanguageUtil.Instance.GetValueByKey("PROMPT"), LanguageUtil.Instance.GetValueByKey("FAIL_TO_CALL_FOR_REGISTER_FAILURE"), LanguageUtil.Instance.GetValueByKey("CONFIRM")); tip.ShowDialog(); return; } CallController.Instance.P2pCallPeer(userId, peerUser.imageUrl, peerUser.displayName); }
public MessageBoxTip(IMasterDisplayWindow backgroundWindow, Window owner) : this() { _backgroundWindow = backgroundWindow; if (null != owner) { this.Owner = owner; } }
public MessageBoxTip(IMasterDisplayWindow backgroundWindow) : this() { _backgroundWindow = backgroundWindow; if (null != backgroundWindow) { this.Owner = backgroundWindow.GetWindow(); } }
public MessageBoxConfirm(IMasterDisplayWindow ownerWindow) : this() { _ownerWindow = ownerWindow; if (null != ownerWindow) { this.Owner = ownerWindow.GetWindow(); } }
public void Diagnostic(IMasterDisplayWindow msgOwner) { WaitingCollectLogView waitingview = new WaitingCollectLogView(); string appDataFolder = Utils.GetConfigDataPath(); LogFileCollector collector = new LogFileCollector(appDataFolder); Task.Run(() => { collector.Collect(); _isLogUploadSuccess = collector.UploadToOss(); CollectLogFinished(this, waitingview); }); waitingview.Owner = msgOwner.GetWindow(); waitingview.Topmost = true; waitingview.ShowDialog(); if (!_isLogUploadSuccess) { using (CommonOpenFileDialog dialog = new CommonOpenFileDialog()) { dialog.Title = LanguageUtil.Instance.GetValueByKey("CHOOSE_LOG_FILE_PATH"); dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); dialog.IsFolderPicker = true; if (dialog.ShowDialog() == CommonFileDialogResult.Ok) { try { collector.SaveAsTo(dialog.FileName); } catch (Exception ex) { log.ErrorFormat("Error:\n {0}", ex.Message); MessageBoxTip tip1 = new MessageBoxTip(msgOwner); tip1.SetTitleAndMsg(LanguageUtil.Instance.GetValueByKey("PROMPT"), string.Format("Error:\n {0}", ex.Message), LanguageUtil.Instance.GetValueByKey("CONFIRM")); tip1.ShowDialog(); return; } } else { // no save file, just exit. return; } } } MessageBoxTip tip2 = new MessageBoxTip(msgOwner); string msg = LanguageUtil.Instance.GetValueByKey("SAVE_LOG_FILE_SUCCESS"); if (_isLogUploadSuccess) { msg = LanguageUtil.Instance.GetValueByKey("UPLOAD_LOG_FILE_SUCCESS"); } tip2.SetTitleAndMsg(LanguageUtil.Instance.GetValueByKey("PROMPT"), msg, LanguageUtil.Instance.GetValueByKey("CONFIRM")); tip2.ShowDialog(); }
public void ShowDialog(IMasterDisplayWindow masterDisplayWindow, string title, string content, string okText) { _masterDisplayWindow = masterDisplayWindow; this.TitleLabel.Content = title; this.ContentTextBlock.Text = content; this.OkTextButton.ButtonContent = okText; SetProperPosition(); this.ShowDialog(); }
public static void CenterWindowOnMasterWindowScreen(Window window, IMasterDisplayWindow masterWindow) { log.InfoFormat("Center window on master window screen, window: widht={0}, height={1}", window.Width, window.Height); if (null == masterWindow) { log.Info("Master window is null and can not center window"); return; } Screen screen = DpiUtil.GetScreenByHandle(masterWindow.GetHandle()); double currentRatio = 1; uint currentScreenDpiX = 96; uint currentScreenDpiY = 96; try { DpiUtil.GetDpiByScreen(screen, out currentScreenDpiX, out currentScreenDpiY); currentRatio = (double)currentScreenDpiX / 96; } catch (DllNotFoundException e) { log.ErrorFormat("Can not load windows dll: {0}", e); } //if (masterWindow.GetWindow().WindowState == WindowState.Minimized) //{ // masterWindow.GetWindow().WindowState = WindowState.Normal; //} double tempWidth = window.Width; double tempHeight = window.Height; double left = 0; double top = 0; if (screen.DeviceName.Equals(System.Windows.Forms.Screen.PrimaryScreen.DeviceName)) { log.InfoFormat("Set window on primary screen, screen: left={0}, top: {1}, width: {2}, height: {3}, ratio: {4}" , screen.Bounds.Left, screen.Bounds.Top, screen.Bounds.Width, screen.Bounds.Height, currentRatio ); left = (screen.Bounds.Left / currentRatio + (screen.Bounds.Width / currentRatio - tempWidth) / 2); top = (screen.Bounds.Top / currentRatio + (screen.Bounds.Height / currentRatio - tempHeight) / 2); } else { log.InfoFormat("Set window on extend screen, screen: left={0}, top: {1}, width: {2}, height: {3}, ratio: {4}" , screen.Bounds.Left, screen.Bounds.Top, screen.Bounds.Width, screen.Bounds.Height, currentRatio ); left = (screen.Bounds.Left * currentRatio + (screen.Bounds.Width * currentRatio - tempWidth) / 2); top = (screen.Bounds.Top * currentRatio + (screen.Bounds.Height * currentRatio - tempHeight) / 2); } window.Left = left; window.Top = top; log.InfoFormat("window is centered, left: {0}, top: {1}, set value: {2} - {3}", window.Left, window.Top, left, top); }
/* * adjust window size if it is not on primary screen * */ public static void AdjustWindowPosition(Window window, IMasterDisplayWindow masterWindow) { log.Info("Adjust window pos begin"); bool needAdjust = false; IntPtr handle = new WindowInteropHelper(window).Handle; Screen screen = DpiUtil.GetScreenByHandle(handle); if (!screen.Primary) { try { needAdjust = true; uint dpiX = 0; uint dpiY = 0; DpiUtil.GetDpiByScreen(screen, out dpiX, out dpiY); uint primaryDpiX = 0; uint primaryDpiY = 0; DpiUtil.GetDpiByScreen(Screen.PrimaryScreen, out primaryDpiX, out primaryDpiY); double ratio = (double)dpiX / (double)primaryDpiX; if (ratio > 1) { window.Width *= ratio; window.Height *= ratio; log.Info("adjust window size according to non primary screen's dpi"); } } catch (Exception e) { log.ErrorFormat("fail to adjust window size according to non primary screen's dpi: {0}", e); } } if (screen.Bounds.Height / window.Height < 1.2) { needAdjust = true; window.Height = screen.Bounds.Height / 1.2d; window.Width = window.Height * masterWindow.GetInitialWidth() / masterWindow.GetInitialHeight(); log.Info("adjust window size according to screen resolution"); } try { if (needAdjust) { Utils.MySetWindowPos(handle, new Rect(screen.Bounds.Left + (screen.Bounds.Width - window.Width) / 2, screen.Bounds.Top + (screen.Bounds.Height - window.Height) / 2, window.Width, window.Height)); } } catch (Exception e) { log.ErrorFormat("fail to adjust window size and position: {0}", e); } log.Info("Adjust window pos end"); }
public static void SetWindowCenterAndOwner(Window window, IMasterDisplayWindow masterWindow, Window owner = null) { if (null == masterWindow) { log.Info("Master window is null and can not center window"); return; } System.Windows.Rect masterWindowRect = masterWindow.GetWindowRect(); window.Left = masterWindowRect.Left + (masterWindowRect.Width - window.Width) / 2; window.Top = masterWindowRect.Top + (masterWindowRect.Height - window.Height) / 2; window.WindowStartupLocation = WindowStartupLocation.Manual; window.Owner = null == owner?masterWindow.GetWindow() : owner; }
public PopUpHeaderSelectWindow(IMasterDisplayWindow ownerWindow) { InitializeComponent(); //disable move this window this.SourceInitialized += Window_SourceInitialized; GetDpi(); _ownerWindow = ownerWindow; this.Owner = ownerWindow.GetWindow(); updateImg("pack://application:,,,/Resources/Icons/uploadHeaderBackGround.jpg"); EVSdkManager.Instance.EventUploadUserImageComplete += EVSdkWrapper_EventUploadUserImageComplete; EVSdkManager.Instance.EventError += EVSdkWrapper_EventError; }
private void ConfirmBtn_Click(object sender, RoutedEventArgs e) { string szNameDisplayedInConf = this.textBoxDisplayName.Text.Trim(); if (string.IsNullOrEmpty(szNameDisplayedInConf)) { this.textBoxDisplayName.Tag = LanguageUtil.Instance.GetValueByKey("NAME_DISPLAYED_IN_CONF"); } Window window = Window.GetWindow(this); IMasterDisplayWindow ownerWindow = window as IMasterDisplayWindow; if (null == ownerWindow) { ownerWindow = (MainWindow)Application.Current.MainWindow; } if (szNameDisplayedInConf.Length > Utils.DISPLAY_NAME_MAX_LENGTH) { log.InfoFormat("The length of name exceeds {0}.", Utils.DISPLAY_NAME_MAX_LENGTH); MessageBoxTip tip = new MessageBoxTip(ownerWindow); tip.SetTitleAndMsg( LanguageUtil.Instance.GetValueByKey("PROMPT") , string.Format(LanguageUtil.Instance.GetValueByKey("NAME_DISPLAYED_IN_CONF_MAX_LENGTH"), Utils.DISPLAY_NAME_MAX_LENGTH) , LanguageUtil.Instance.GetValueByKey("CONFIRM") ); tip.ShowDialog(); return; } if (Regex.IsMatch(szNameDisplayedInConf, Utils.INVALID_DISPLAY_NAME_REGEX)) { log.Info("Invalid char in name."); MessageBoxTip tip = new MessageBoxTip(ownerWindow); tip.SetTitleAndMsg( LanguageUtil.Instance.GetValueByKey("PROMPT") , LanguageUtil.Instance.GetValueByKey("NAME_DISPLAYED_IN_CONF_INCORRECT_PROMPT") , LanguageUtil.Instance.GetValueByKey("CONFIRM") ); tip.ShowDialog(); return; } ConfirmEvent?.Invoke(szNameDisplayedInConf); }
public WebBrowserWrapperView(WebBrowserUrlType webBrowserUrlType, IMasterDisplayWindow masterWin, bool updateOnLoaded = true) { _webBrowserUrlType = webBrowserUrlType; _masterDisplayWindow = masterWin; _updateUrlOnLoaded = updateOnLoaded; InitializeComponent(); this.browser.Visibility = Visibility.Collapsed; this.loadPromptPresenter.Content = _loadingView; this.loadPromptPresenter.Visibility = Visibility.Visible; _browserLoadTimer.Interval = 20 * 1000; _browserLoadTimer.AutoReset = false; _browserLoadTimer.Elapsed += BrowserLoadTimer_Elapsed; _loadFailedView.ReloadEvent += LoadFailedView_ReloadEvent; _conferenceJsEvent = new ConferenceJsEvent(this.browser, masterWin); _conferenceJsEvent.PageCreatedEvent += ConferenceJsEvent_PageCreatedEvent; this.browser.RegisterJsObject("conferenceObj", _conferenceJsEvent, new BindingOptions() { CamelCaseJavascriptNames = false }); //this.browser.JavascriptObjectRepository.Register("conferenceObj", _conferenceJsEvent, true, new BindingOptions() { CamelCaseJavascriptNames = false }); this.browser.MenuHandler = new CustomMenuHandler(); this.browser.RequestHandler = new ConfCefRequestHandler(); this.browser.ConsoleMessage += OnBrowserConsoleMessage; this.browser.LoadError += Browser_LoadError; this.browser.IsBrowserInitializedChanged += Browser_IsBrowserInitializedChanged; this.browser.Loaded += Browser_Loaded; //this.browser.GotFocus += Browser_GotFocus; //this.browser.LostFocus += Browser_LostFocus; this.browser.PreviewTextInput += Browser_PreviewTextInput; this.Loaded += WebBrowserWrapperView_Loaded; this.Unloaded += WebBrowserWrapperView_Unloaded; LoginManager.Instance.PropertyChanged += LoginManager_PropertyChanged; }
private static Screen GetSuitableScreen(IMasterDisplayWindow masterWindow) { if (System.Windows.Forms.Screen.AllScreens.Length == 1) { return(System.Windows.Forms.Screen.PrimaryScreen); } else { // there are more than one screens. Screen rejectiveWinScreen = DpiUtil.GetScreenByHandle(masterWindow.GetHandle()); Screen[] screens = System.Windows.Forms.Screen.AllScreens; foreach (System.Windows.Forms.Screen s in screens) { if (!s.DeviceName.Equals(rejectiveWinScreen.DeviceName)) { return(s); } } } return(null); }
public void ShowPromptByTime(string content, int duration, IMasterDisplayWindow masterWin, Window activeWindow) { if (string.IsNullOrEmpty(content)) { return; } _masterWindow = masterWin; log.Info("Show prompt by time"); if (null != _autoCloseTimer && _autoCloseTimer.Enabled) { log.InfoFormat("Timer enabled:{0}", _autoCloseTimer.Enabled); _autoCloseTimer.Enabled = false; } //log.Info("Begin to show prompt content."); //this.label.Content = content; //this.Show(); ////this.Top += (WindowDownRatio * ratio); //StartAutoCloseTimer(duration); //SetProperPosition(); Application.Current.Dispatcher.InvokeAsync(() => { // note: Put the code below the UI thread queue to make sure the execution after the last arrival item timeout. log.Info("Begin to show prompt content."); this.label.Content = content; this.Show(); //this.Top += (WindowDownRatio * ratio); StartAutoCloseTimer(duration); SetProperPosition(); log.InfoFormat("window IsActive: {0}, null != activeWindow: {1}", this.IsActive, null != activeWindow); if (IsActive && null != activeWindow) { log.Info("activeWindow, activate"); activeWindow.Activate(); } }); }
private void Join_Click(object sender, RoutedEventArgs e) { log.Info("Join conference click"); bool valid = true; string szServerAddress; if (LoginProgressEnum.EnterpriseJoinConf == LoginManager.Instance.LoginProgress) { szServerAddress = this.textBoxServerAddress.Text.Trim(); if (string.IsNullOrEmpty(szServerAddress)) { this.textBoxServerAddress.Tag = LanguageUtil.Instance.GetValueByKey("SERVER"); valid = false; } } else { szServerAddress = Utils.CloudServerDomain; } string szConfId = this.comboBoxConfId.Text.Trim(); if (string.IsNullOrEmpty(szConfId)) { valid = false; } string szNameDisplayedInConf = this.textBoxNameDisplayedInConf.Text.Trim(); if (string.IsNullOrEmpty(szNameDisplayedInConf)) { this.textBoxNameDisplayedInConf.Tag = LanguageUtil.Instance.GetValueByKey("NAME_DISPLAYED_IN_CONF"); } if (!valid) { log.Info("Null value."); return; } Window window = Window.GetWindow(this); IMasterDisplayWindow ownerWindow = window as IMasterDisplayWindow; if (null == ownerWindow) { ownerWindow = (MainWindow)Application.Current.MainWindow; } if (!Regex.IsMatch(szConfId, VALID_CONF_ID)) { log.Info("Invalid conf id."); MessageBoxTip tip = new MessageBoxTip(ownerWindow); tip.SetTitleAndMsg( LanguageUtil.Instance.GetValueByKey("PROMPT") , LanguageUtil.Instance.GetValueByKey("INVALID_CONFERENCE_ID") , LanguageUtil.Instance.GetValueByKey("CONFIRM") ); tip.ShowDialog(); return; } if (szNameDisplayedInConf.Length > Utils.DISPLAY_NAME_MAX_LENGTH) { log.InfoFormat("The lenght of name exceeds {0}.", Utils.DISPLAY_NAME_MAX_LENGTH); MessageBoxTip tip = new MessageBoxTip(ownerWindow); tip.SetTitleAndMsg( LanguageUtil.Instance.GetValueByKey("PROMPT") , string.Format(LanguageUtil.Instance.GetValueByKey("NAME_DISPLAYED_IN_CONF_MAX_LENGTH"), Utils.DISPLAY_NAME_MAX_LENGTH) , LanguageUtil.Instance.GetValueByKey("CONFIRM") ); tip.ShowDialog(); return; } if (Regex.IsMatch(szNameDisplayedInConf, Utils.INVALID_DISPLAY_NAME_REGEX)) { log.Info("Invalid char in name."); MessageBoxTip tip = new MessageBoxTip(ownerWindow); tip.SetTitleAndMsg( LanguageUtil.Instance.GetValueByKey("PROMPT") , LanguageUtil.Instance.GetValueByKey("NAME_DISPLAYED_IN_CONF_INCORRECT_PROMPT") , LanguageUtil.Instance.GetValueByKey("CONFIRM") ); tip.ShowDialog(); return; } log.Info("Correct value and go ahead."); Utils.SetDisplayNameInConf(szNameDisplayedInConf); bool enableCamera = null == this.turnOffCamera.IsChecked || !this.turnOffCamera.IsChecked.Value; bool enableMicrophone = null == this.turnOffMicrophone.IsChecked || !this.turnOffMicrophone.IsChecked.Value; Utils.SetDisableCameraOnJoinConf(!enableCamera); Utils.SetDisableMicOnJoinConf(!enableMicrophone); // join the conference if (LoginStatus.LoggedIn == LoginManager.Instance.CurrentLoginStatus) { EVSdkManager.Instance.EnableCamera(enableCamera); EVSdkManager.Instance.EnableMic(enableMicrophone); if (string.IsNullOrEmpty(szNameDisplayedInConf)) { szNameDisplayedInConf = LoginManager.Instance.DisplayName; } log.Info("Join conf -- start video call."); this._viewModel.StartJoinConference(szConfId, szNameDisplayedInConf, _confPassword, ownerWindow); } else if (LoginStatus.NotLogin == LoginManager.Instance.CurrentLoginStatus || LoginStatus.LoginFailed == LoginManager.Instance.CurrentLoginStatus) { log.Info("Join conf -- anonymous."); LoginManager.Instance.AnonymousJoinConference( false , LoginManager.Instance.EnableSecure , szServerAddress , LoginManager.Instance.ServerPort , szConfId , "" , enableCamera , enableMicrophone ); } }
private void Join_Click(object sender, RoutedEventArgs e) { string szNameDisplayedInConf = this.textBoxDisplayName.Text.Trim(); if (string.IsNullOrEmpty(szNameDisplayedInConf)) { this.textBoxDisplayName.Tag = LanguageUtil.Instance.GetValueByKey("NAME_DISPLAYED_IN_CONF"); } Window window = Window.GetWindow(this); IMasterDisplayWindow ownerWindow = window as IMasterDisplayWindow; if (null == ownerWindow) { ownerWindow = (MainWindow)Application.Current.MainWindow; } if (szNameDisplayedInConf.Length > Utils.DISPLAY_NAME_MAX_LENGTH) { log.InfoFormat("The lenght of name exceeds {0}.", Utils.DISPLAY_NAME_MAX_LENGTH); MessageBoxTip tip = new MessageBoxTip(ownerWindow); tip.SetTitleAndMsg( LanguageUtil.Instance.GetValueByKey("PROMPT") , string.Format(LanguageUtil.Instance.GetValueByKey("NAME_DISPLAYED_IN_CONF_MAX_LENGTH"), Utils.DISPLAY_NAME_MAX_LENGTH) , LanguageUtil.Instance.GetValueByKey("CONFIRM") ); tip.ShowDialog(); return; } if (Regex.IsMatch(szNameDisplayedInConf, Utils.INVALID_DISPLAY_NAME_REGEX)) { log.Info("Invalid char in name."); MessageBoxTip tip = new MessageBoxTip(ownerWindow); tip.SetTitleAndMsg( LanguageUtil.Instance.GetValueByKey("PROMPT") , LanguageUtil.Instance.GetValueByKey("NAME_DISPLAYED_IN_CONF_INCORRECT_PROMPT") , LanguageUtil.Instance.GetValueByKey("CONFIRM") ); tip.ShowDialog(); return; } Utils.SetDisplayNameInConf(szNameDisplayedInConf); bool enableCamera = null == this.turnOffCamera.IsChecked || !this.turnOffCamera.IsChecked.Value; bool enableMicrophone = null == this.turnOffMicrophone.IsChecked || !this.turnOffMicrophone.IsChecked.Value; Utils.SetDisableCameraOnJoinConf(!enableCamera); Utils.SetDisableMicOnJoinConf(!enableMicrophone); Application.Current.Dispatcher.InvokeAsync(() => { LoginManager.Instance.AnonymousJoinConference( _isJoinDirectly , ("https" == _joinConfProtocol.ToLower()) , _joinConfAddress , (uint)_joinConfPort , _joinConfId , _joinConfPassword , enableCamera , enableMicrophone ); }); ClearJoinConfData(); }
public static System.Windows.Forms.Screen SetWndOnSuitableScreen(Window window, IMasterDisplayWindow masterWindow) { log.InfoFormat("set screen for window: {0}", window.Title); Screen screen = GetSuitableScreen(masterWindow); if (screen == null) { return(null); } log.InfoFormat("target screen is {0}", screen.DeviceName); //IntPtr handle = new WindowInteropHelper(window).Handle; Screen currentScreen = DpiUtil.GetScreenByPoint((int)window.Left, (int)window.Top); if (screen.Equals(currentScreen)) { // already in the suitable screen, do nothing. screen = currentScreen; } log.DebugFormat("current screen is {0}", currentScreen.DeviceName); System.Windows.Forms.Screen masterWindowScreen = DpiUtil.GetScreenByHandle(masterWindow.GetHandle()); double currentRatio = 1; double primaryRatio = 1; uint currentScreenDpiX = 96; uint currentScreenDpiY = 96; uint primaryDpiX = 96; uint primaryDpiY = 96; try { DpiUtil.GetDpiByScreen(screen, out currentScreenDpiX, out currentScreenDpiY); currentRatio = (double)currentScreenDpiX / 96; DpiUtil.GetDpiByScreen(System.Windows.Forms.Screen.PrimaryScreen, out primaryDpiX, out primaryDpiY); primaryRatio = (double)primaryDpiX / 96; } catch (DllNotFoundException e) { log.ErrorFormat("Can not load windows dll: {0}", e); } log.DebugFormat("```````1```{0}, {1}, {2}, {3}", window.Left, window.Top, window.Width, window.Height); if (masterWindow.GetWindow().WindowState == WindowState.Minimized) { masterWindow.GetWindow().WindowState = WindowState.Normal; } double tempWidth = window.Width; double tempHeight = window.Height; if (currentScreen.DeviceName.Equals(System.Windows.Forms.Screen.PrimaryScreen.DeviceName)) { log.DebugFormat("currentScreen in Primary"); window.Left = (screen.Bounds.Left / primaryRatio + (screen.Bounds.Width / primaryRatio - tempWidth) / 2); window.Top = (screen.Bounds.Top / primaryRatio + (screen.Bounds.Height / primaryRatio - tempHeight) / 2); } else { log.DebugFormat("currentScreen in extend"); window.Left = (screen.Bounds.Left * currentRatio + (screen.Bounds.Width * currentRatio - tempWidth) / 2); window.Top = (screen.Bounds.Top * currentRatio + (screen.Bounds.Height * currentRatio - tempHeight) / 2); } log.Info("Set window on suitable screen end."); return(screen); }
protected void JoinConference(string conferenceNumber, string displayName, string password, IMasterDisplayWindow ownerWindow) { if (string.IsNullOrEmpty(conferenceNumber.Trim())) { return; } if (LoginManager.Instance.CurrentLoginStatus == LoginStatus.LoggedIn && !LoginManager.Instance.IsRegistered) { if (null == ownerWindow) { ownerWindow = (MainWindow)System.Windows.Application.Current.MainWindow; } MessageBoxTip tip = new MessageBoxTip(ownerWindow); tip.SetTitleAndMsg(LanguageUtil.Instance.GetValueByKey("PROMPT"), LanguageUtil.Instance.GetValueByKey("FAIL_TO_CALL_FOR_REGISTER_FAILURE"), LanguageUtil.Instance.GetValueByKey("CONFIRM")); tip.ShowDialog(); return; } CallController.Instance.JoinConference(conferenceNumber, displayName, password); }
public void CheckSoftwareUpdate(bool showPrompt) { StringBuilder sb = new StringBuilder(); sb.Append(Properties.Settings.Default.SoftwareUpdateAddress) .Append("/") .Append(Properties.Settings.Default.SoftwareUpdateFlag) .Append("/") .Append(Properties.Settings.Default.SoftwareUpdateBundleId) .Append("/"); if (!string.IsNullOrEmpty(Properties.Settings.Default.SoftwareUpdateAppInfoPrefix)) { sb.Append(Properties.Settings.Default.SoftwareUpdateAppInfoPrefix).Append("."); } sb.Append(Properties.Settings.Default.SoftwareUpdateAppInfo); string swUpdateUrl = sb.ToString(); log.InfoFormat("Software update url:{0}", swUpdateUrl); WaitingWindow waitingWindow = null; if (showPrompt) { Application.Current.Dispatcher.InvokeAsync(() => { waitingWindow = new WaitingWindow(LanguageUtil.Instance.GetValueByKey("CHECKING_UPDATE")); IMasterDisplayWindow masterWindow = ((MainWindow)Application.Current.MainWindow).GetCurrentMainDisplayWindow(); if (null != masterWindow) { waitingWindow.Owner = masterWindow.GetWindow(); } waitingWindow.ShowDialog(); }); } Task.Run(() => { RestClient restClient = new RestClient(); RestResponse response = null; try { response = restClient.GetObject(swUpdateUrl); if (response.StatusCode >= HttpStatusCode.BadRequest) { log.InfoFormat("Failed to get app info for software update, status code: {0}", response.StatusCode); if (showPrompt) { Application.Current.Dispatcher.InvokeAsync(() => { if (null != waitingWindow) { waitingWindow.Close(); } ShowNotFoundNewVersion(); }); } return; } Rest.SoftwareUpdateRest.AppInfoRest appInfo = JsonConvert.DeserializeObject <Rest.SoftwareUpdateRest.AppInfoRest>(response.Content); log.InfoFormat("Software update info, version:{0}, url:{1}", appInfo.VERSION, appInfo.DOWNLOAD_URL); string currentVersion = Utils.GetEdition(); log.InfoFormat("Current app version: {0}", currentVersion); string[] arrAppInfo = appInfo.VERSION.Split('.'); string[] arrCurrentVersion = currentVersion.Split('.'); int len = arrAppInfo.Length > arrCurrentVersion.Length ? arrAppInfo.Length : arrCurrentVersion.Length; bool newVersionFound = false; for (int i = 0; i < len; ++i) { int newItem = int.Parse(arrAppInfo[i]); int currentItem = int.Parse(arrCurrentVersion[i]); if (newItem > currentItem) { newVersionFound = true; break; } else if (newItem < currentItem) { break; } } if (!newVersionFound) { if (showPrompt) { Application.Current.Dispatcher.InvokeAsync(() => { if (null != waitingWindow) { waitingWindow.Close(); } ShowNotFoundNewVersion(); }); } return; } Application.Current.Dispatcher.InvokeAsync(() => { if (null != waitingWindow) { waitingWindow.Close(); } SoftwareUpdateWindow.Instance.Reset(appInfo.VERSION, appInfo.DOWNLOAD_URL); IMasterDisplayWindow masterWindow = ((MainWindow)Application.Current.MainWindow).GetCurrentMainDisplayWindow(); DisplayUtil.SetWindowCenterAndOwner(SoftwareUpdateWindow.Instance, masterWindow); if (null != masterWindow) { log.InfoFormat("Set soft update window owner to window:{0}", masterWindow.GetHashCode()); } SoftwareUpdateWindow.Instance.Show(); if (null != SoftwareUpdateWindow.Instance.Owner) { // set the owner active or the owner will hide when cancel the software update window. SoftwareUpdateWindow.Instance.Owner.Activate(); } }); } catch (Exception ex) { log.ErrorFormat("Failed to get app info for software update, exception:{0}", ex); if (showPrompt) { Application.Current.Dispatcher.InvokeAsync(() => { if (null != waitingWindow) { waitingWindow.Close(); } ShowNotFoundNewVersion(); }); } } }); }
public void StartJoinConference(string confNumber, string displayName, string password, IMasterDisplayWindow ownerWindow) { JoinConference(confNumber, displayName, password, ownerWindow); }
public ConferenceJsEvent(CefSharp.Wpf.ChromiumWebBrowser browser, IMasterDisplayWindow masterDisplayWindow) { this._browser = browser; this._masterDisplayWindow = masterDisplayWindow; }