void IActivatable.OnDeactivate(bool close) { // Note: The method is an explicit interface implementation because it should never be // called directly. It should only be called by an IConductor through the IActivatable // interface. Debug.Assert(WindowsHelper.CheckAccess(), "Screen conduction not called on UI thread."); Debug.Assert(IsOpen || !IsActive, "Invalid state: An item can only be active when it is open."); if (!IsOpen) { return; } if (!IsActive && !close) { return; } IsActive = false; if (close) { IsOpen = false; } OnDeactivated(new DeactivationEventArgs(close)); }
/// <summary> /// Performs a hit test at the current mouse position against a given element. /// </summary> /// <param name="element">The element.</param> /// <returns> /// <see langword="true"/> if the element was hit; otherwise, <see langword="false"/>. /// </returns> internal static bool HitTest(UIElement element) { var mousePosition = WindowsHelper.GetMousePosition(element); var hitTestResult = VisualTreeHelper.HitTest(element, mousePosition); return(hitTestResult != null); }
public DesktopShareDlg() { InitializeComponent(); this.CenterToScreen(); rgbmodeComboBox.Items.Add("8-bit colors"); rgbmodeComboBox.Items.Add("16-bit colors"); rgbmodeComboBox.Items.Add("24-bit colors"); rgbmodeComboBox.Items.Add("32-bit colors"); rgbmodeComboBox.SelectedIndex = 3; intervalNumericUpDown.Value = (decimal)update_interval; int i = 0; IntPtr ptr = IntPtr.Zero; while (WindowsHelper.GetDesktopWindowHWND(i, ref ptr)) { ShareWindow wnd = new ShareWindow(); if (WindowsHelper.GetWindow(ptr, ref wnd)) { windowsComboBox.Items.Add(wnd.szWindowTitle); windowHandles.Add(wnd.hWnd); } i++; } if (i > 0) { windowsComboBox.SelectedIndex = 0; } }
private void btnSure_Click(object sender, RoutedEventArgs e) { tbMsg.Text = string.Empty; if (object.Equals(cbTypes.SelectedValue, null)) { tbMsg.Text = TryFindResource("GatherInputDeviceType").ToString(); return; } if (string.IsNullOrWhiteSpace(tbPassword.Password)) { tbMsg.Text = TryFindResource("GatherInputPasswrod").ToString(); return; } DeviveInfo selectDevice = GatherViewModel.DeviveInfoList.Find(p => p.DeviceCode.Equals(DeviveInfo.DeviceCode)); if (selectDevice == null) { NewMessageBox.Show(string.Format(TryFindResource("GatherDeviceRemove").ToString(), DeviveInfo.DeviceCode)); return; } Conditions con = new Conditions(); con.AddItem("UserID", AppConfigInfos.CurrentUserInfos.UserID); con.AddItem("DeviceID", DeviveInfo.DeviceCode); con.AddItem("DevicePassword", tbPassword.Password); con.AddItem("TypeID", cbTypes.SelectedValue.ToString()); // 发送注册消息 ResultWindow resultWindow = WindowsHelper.ShowDialogWindow <ResultWindow>(this, MsgType.DeviceRegister, MsgType.DeviceRegisterResult, con, TryFindResource("GatherRegistering").ToString()); MessageBoxResult msgBoxResult = resultWindow.MessageBoxResult; if (msgBoxResult == MessageBoxResult.Cancel) { tbMsg.Text = TryFindResource("GatherRegisterOvertime").ToString(); } else if (msgBoxResult == MessageBoxResult.Yes) { ModelResponsible.Instance.SendOperationLog("CollectDeviceRegister"); this.Close(); //NewMessageBox.Show(TryFindResource("GatherRegisterSuccess").ToString(), ModelResponsible.Instance.ParentWindow); } else if (msgBoxResult == MessageBoxResult.No) { DeviceRegisterInfo deviceRegisterInfo = resultWindow.ResultValue as DeviceRegisterInfo; if (deviceRegisterInfo != null) { string msg = (TryFindResource("GatherDeviceRegisterError_" + deviceRegisterInfo.ResultCode) ?? string.Empty).ToString(); tbMsg.Text = msg; } else { tbMsg.Text = TryFindResource("GatherRegisterFailed").ToString(); } } }
/// <summary> /// ShowProgress /// </summary> /// <param name="msg"></param> public static void ShowProgress(string msg) { if (WindowsHelper.InvokeShowProgressDelegateInstance != null) { WindowsHelper.InvokeShowProgressDelegateInstance(msg); } }
private static async Task <ArgumentHandleResult> ProcessGoogleSpreadsheetsLocale(string id, [CanBeNull] string locale, bool around) { if (string.IsNullOrWhiteSpace(id)) { throw new InformativeException("ID is missing"); } var url = around ? $@"{InternalUtils.MainApiDomain}/u/around?id={id}" : $@"https://docs.google.com/spreadsheets/d/{id}/export?format=xlsx&authuser=0"; await LoadRemoveFileToNew(url, LocaleHelper.GetGoogleSheetsFilename()); SettingsHolder.Locale.LoadUnpacked = true; if (locale != null) { SettingsHolder.Locale.LocaleName = locale; } if (ModernDialog.ShowMessage("Custom locales updated. Would you like to restart app now?", "Locales updated", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { WindowsHelper.RestartCurrentApplication(); } return(ArgumentHandleResult.Successful); }
private void Download(string fileOrDirName, bool isFile) { string tip = "下载文件!请选择保存路径"; if (!isFile) { tip = "下载文件夹!请选择保存路径"; } string savePath = FileHelper.GetPathToSave(tip, fileOrDirName, null); if (savePath == null) { return; } if (File.Exists(savePath) || Directory.Exists(savePath)) { if (!WindowsHelper.ShowQuery(string.Format("{0}已经存在,确定要覆盖它吗?", FileHelper.GetFileNameNoPath(savePath)))) { return; } } OperationResult operationResult = this.fileDirectoryOutter.Download(this.ownerID, this.netDiskID, this.currentDirPath + fileOrDirName, savePath, isFile); if (!operationResult.Succeed) { MessageBox.Show(operationResult.ErrorMessage); this.LoadDirectory(this.currentDirPath, true); } }
/// <summary> /// Removes the range. /// </summary> /// <param name="items">The items.</param> public void RemoveRange(IEnumerable <T> items) { WindowsHelper.InvokeOnUI(() => { bool previousSuppressNotifications = _suppressNotifications; _suppressNotifications = true; try { foreach (var item in items) { var index = IndexOf(item); if (index >= 0) { RemoveItemBase(index); } } } finally { _suppressNotifications = previousSuppressNotifications; } OnPropertyChanged(new PropertyChangedEventArgs("Count")); OnPropertyChanged(new PropertyChangedEventArgs("Item[]")); OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); }); }
private void ExpandAll(Expander selectedExpander) { _isManualCollapseOrExpand = true; try { // Expand all expanders. foreach (var expander in _listBox.GetVisualDescendants().OfType <Expander>()) { expander.IsExpanded = true; // When an expander is expanded, only its properties should get focus. expander.Focusable = false; } // Move focus to first property of the selected expander. var listBoxItem = selectedExpander?.GetVisualDescendants().OfType <ListBoxItem>().FirstOrDefault(); if (listBoxItem != null) { WindowsHelper.BeginInvokeOnUI(() => { listBoxItem.Focus(); listBoxItem.BringIntoView(); }); } } finally { _isManualCollapseOrExpand = false; } }
public void ChangeNotifications() { WindowsHelper.InvokeOnUI(() => { new DependencyPropertyChangedEventsTestFrameworkElement().ChangedNotifications(); }); }
public IMessageHandler PickupResponse(int int_2, int int_3) { Class73 class2; bool flag = !Thread.CurrentThread.IsBackground; DateTime now = DateTime.Now; string id = this.method_1(int_2, int_3); Label_0074: class2 = this.safeDictionary_1.Get(id); if (class2 == null) { if (!((this.interface26_0 == null) || this.interface26_0.Connected)) { throw new Exception("Network connection is disconnected!"); } if (this.int_1 > 0) { TimeSpan span = (TimeSpan)(DateTime.Now - now); if (span.TotalSeconds >= this.int_1) { throw new TimeoutException("Timeout waiting for reply!"); } } if (flag) { WindowsHelper.DoWindowsEvents(); } Thread.Sleep(5); goto Label_0074; } this.safeDictionary_1.Remove(id); return(class2.method_0()); }
/// <summary> /// Collect memory snapshot and save it to the disk. This method forces full GC. /// Doesn't throw any errors even if the application is run with profiling disabled. /// </summary> /// <param name="name">The name of the memory snapshot. This is not a file name. Currently not used.</param> public static void GetSnapshot(string name) { var id = Helper.Id; switch (Helper.Platform) { case PlatformId.Linux: if (LinuxHelper.IsLibCoreApiAlreadyLoaded()) { Helper.InvokeCoreApi(() => LibCoreApi.V1_Memory_GetSnapshot(id, name)); } break; case PlatformId.MacOsX: if (MacOsXHelper.IsLibCoreApiAlreadyLoaded()) { Helper.InvokeCoreApi(() => LibCoreApi.V1_Memory_GetSnapshot(id, name)); } break; case PlatformId.Windows: if (WindowsHelper.IsCoreApiDllAlreadyLoaded()) { Helper.InvokeCoreApi(() => CoreApiDll.V1_Memory_GetSnapshot(id, name)); } break; default: throw new PlatformNotSupportedException(); } }
/// <summary> /// Enable/disable collecting memory allocation data. Does nothing if collecting allocation data is disabled in the /// profiler. To check whether the collecting is enabled, use <see cref="GetFeatures" /> with /// <see cref="MemoryFeatures.CollectAllocations" /> flag. /// Doesn't throw any errors even if the application is run with profiling disabled. /// </summary> public static void CollectAllocations(bool enable) { var id = Helper.Id; switch (Helper.Platform) { case PlatformId.Linux: if (LinuxHelper.IsLibCoreApiAlreadyLoaded()) { Helper.InvokeCoreApi(() => LibCoreApi.V1_Memory_CollectAllocations(id, enable)); } break; case PlatformId.MacOsX: if (MacOsXHelper.IsLibCoreApiAlreadyLoaded()) { Helper.InvokeCoreApi(() => LibCoreApi.V1_Memory_CollectAllocations(id, enable)); } break; case PlatformId.Windows: if (WindowsHelper.IsCoreApiDllAlreadyLoaded()) { Helper.InvokeCoreApi(() => CoreApiDll.V1_Memory_CollectAllocations(id, enable)); } break; default: throw new PlatformNotSupportedException(); } }
/// <summary> /// 执法记录仪移除 /// </summary> /// <param name="deviceCode"></param> public static void DevieItemRemove(string deviceCode) { DeviveInfo deviveInfo = GatherViewModel.DeviveInfoList.Find(p => p.DeviceCode.Equals(deviceCode)); if (deviveInfo != null) { GatherViewModel.DeviveInfoList.Remove(deviveInfo); MatchWindow matchWindow = WindowsHelper.GetWindow <MatchWindow>(); if (matchWindow != null && matchWindow.DeviveInfo.DeviceCode.Equals(deviceCode)) { matchWindow.Close(); } DeviceRegisterWindow registerWindow = WindowsHelper.GetWindow <DeviceRegisterWindow>(); if (registerWindow != null && registerWindow.DeviveInfo.DeviceCode.Equals(deviceCode)) { registerWindow.Close(); } HandCollectWindow handCollectWindow = WindowsHelper.GetWindow <HandCollectWindow>(); if (handCollectWindow != null && handCollectWindow.DeviveInfo.DeviceCode.Equals(deviceCode)) { handCollectWindow.Close(); } } }
private void btnCollectUp_Click(object sender, RoutedEventArgs e) { string logIds = string.Empty; foreach (CollectLogInfo mi in ManageViewModel.CollectLogs) { if (mi.IsChecked && mi.UpLoadState != "2") { logIds += mi.LogID + ","; } } if (string.IsNullOrEmpty(logIds)) { NewMessageBox.Show(TryFindResource("LogsControlBtnCollectUploadEmpty").ToString()); return; } LoginWindow loginWindow = WindowsHelper.ShowDialogWindow <LoginWindow>(ModelResponsible.Instance.ParentWindow, PermissionConfig.DataSearchModuleUpload, "0"); if (loginWindow.MessageBoxResult == MessageBoxResult.OK) { SearchManager.GetInstance().UploadCollectLog(logIds); SearchManager.GetInstance().SendOperationLog("CollectLogBulkUpload"); LogHelper.Instance.WirteLog(string.Format("LogsControl: UserCode:{0} btnCollectUp Upload logIds:{1}", AppConfigInfos.CurrentUserInfos.UserCode, logIds), LogLevel.LogDebug); } }
private void btnPaly_Click(object sender, RoutedEventArgs e) { LogHelper.Instance.WirteLog(string.Format("FileButtonControl: UserCode:{0} btnPlay", AppConfigInfos.CurrentUserInfos.UserCode), LogLevel.LogDebug); if ((MediaInfo)this.DataContext != null) { string filepath = ((MediaInfo)this.DataContext).FilePath + ((MediaInfo)this.DataContext).FileName; if (!System.IO.File.Exists(filepath)) { NewMessageBox.Show(TryFindResource("SearchManagerPlayFileNoData").ToString()); return; } WindowsHelper.GetOrNewWindow <PlayWindow>(true).UpdateSelectTab((MediaInfo)this.DataContext); LogHelper.Instance.WirteLog(string.Format("FileButtonControl: UserCode:{0} btnPlay AddHisPlayMediaList", AppConfigInfos.CurrentUserInfos.UserCode), LogLevel.LogDebug); ModelResponsible.Instance.AnalyzeHisPlayMediaList((MediaInfo)this.DataContext); LogHelper.Instance.WirteLog(string.Format("FileButtonControl: UserCode:{0} btnPlay Playing", AppConfigInfos.CurrentUserInfos.UserCode), LogLevel.LogDebug); SearchManager.GetInstance().SendOperationLog("CollectEvidencePlay", (MediaInfo)this.DataContext); WindowsHelper.ShowDialogWindow <PlayWindow>(ModelResponsible.Instance.ParentWindow); } else { LogHelper.Instance.WirteLog(string.Format("FileButtonControl: UserCode:{0} btnPlay NoMediaInfo", AppConfigInfos.CurrentUserInfos.UserCode), LogLevel.LogDebug); } }
private void OnHyperlinkMouseUp(object sender, MouseButtonEventArgs e) { if (_click) { WindowsHelper.ViewInBrowser(Model.CupObject.CupUpdateInformation?.InformationUrl); } }
/// <summary> /// 主窗口关闭,系统退出 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BaseWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) { // 数据库没有连接上则不需要验证 if (!AppConfigInfos.AppStateInfos.DataBaseState.Equals("1")) { LoginWindow loginWindow = WindowsHelper.ShowDialogWindow <LoginWindow>(this, PermissionConfig.AppClose, "0"); if (loginWindow.MessageBoxResult != MessageBoxResult.OK) { e.Cancel = true; return; } else { MainMessage.Instance.SendOperationLog("CollectAppExit"); } } else { MessageBoxResult result = NewMessageBox.Show(TryFindResource("appMainExitApp").ToString(), MessageBoxButton.OKCancel, this); if (result != MessageBoxResult.OK) { e.Cancel = true; return; } } WarnInfo.WarnHelper.Instance.ReceiveDataHandler -= Instance_ReceiveDataHandler; ModuleDispather.Instance.Dispose(); LogHelper.Instance.Dispose(); AppHelper.CloseKey(); App.Current.Shutdown(); }
/// <summary> /// /// </summary> /// <param name="gridPanel"></param> /// <param name="qm"></param> public static void DisplayData( MoleculeGridPanel gridPanel, QueryManager qm) { if (gridPanel == null) // if grid panel not defined assume display is in normal results panel { gridPanel = SessionManager.Instance.QueryResultsControl.MoleculeGridPageControl.MoleculeGridPanel; QbUtil.SetMode(QueryMode.Browse); // put into browse mode } else if (gridPanel.Parent is PopupGrid) // display in popup grid { PopupGrid pug = gridPanel.Parent as PopupGrid; pug.Initialize(qm); // be sure popup is initialized WindowsHelper.FitFormOnScreen(pug); pug.Show(); } MoleculeGridControl grid = qm.MoleculeGrid; gridPanel.Visible = true; grid.Visible = true; grid.DataSource = qm.DataTable; // set the datasource for the grid to the datatable RefreshDataDisplay(qm); }
public void GetGradientClosest9() { WindowsHelper.InvokeOnUI(() => { Color color0 = Color.FromArgb(255, 0, 0, 0); Color color1 = Color.FromArgb(255, 0, 255, 0); Color color2 = Color.FromArgb(255, 255, 255, 255); Palette palette = new Palette(PaletteMode.Closest) { new PaletteEntry(0, color0), new PaletteEntry(2, color2), new PaletteEntry(1, color1) }; GradientStopCollection gradient = palette.GetGradient(-1, 1.75); Assert.AreEqual(6, gradient.Count); Assert.AreEqual(0.0, gradient[0].Offset); Assert.AreEqual(color0, gradient[0].Color); Assert.AreEqual(1.5f / 2.75f, (float)gradient[1].Offset); Assert.AreEqual(color0, gradient[1].Color); Assert.AreEqual(1.5f / 2.75f, (float)gradient[2].Offset); Assert.AreEqual(color1, gradient[2].Color); Assert.AreEqual(2.5f / 2.75f, (float)gradient[3].Offset); Assert.AreEqual(color1, gradient[3].Color); Assert.AreEqual(2.5f / 2.75f, (float)gradient[4].Offset); Assert.AreEqual(color2, gradient[4].Color); Assert.AreEqual(1.0, gradient[5].Offset); Assert.AreEqual(color2, gradient[5].Color); }); }
private Dictionary <string, int> iconIndexDic = new Dictionary <string, int>();// ".txt" - 3 private int GetIconIndex(string fileName) { string[] ary = fileName.Split('.'); if (ary.Length == 1) { return(1); } try { string extendName = "." + ary[ary.Length - 1].ToLower(); if (!this.iconIndexDic.ContainsKey(extendName)) { int index = 1; Icon icon = WindowsHelper.GetSystemIconByFileType(extendName, true); if (icon != null) { this.imageList1.Images.Add(icon); index = this.imageList1.Images.Count - 1; } this.iconIndexDic.Add(extendName, index); } return(this.iconIndexDic[extendName]); } catch (Exception ee) { ee = ee; return(1); } }
public void GetGradientLessOrEqual2() { WindowsHelper.InvokeOnUI(() => { Color color0 = Color.FromArgb(255, 0, 0, 0); Color color1 = Color.FromArgb(255, 0, 255, 0); Color color2 = Color.FromArgb(255, 255, 255, 255); Palette palette = new Palette(PaletteMode.LessOrEqual) { new PaletteEntry(0, color0), new PaletteEntry(2, color2), new PaletteEntry(1, color1) }; GradientStopCollection gradient = palette.GetGradient(0.5, 1.5); Assert.AreEqual(4, gradient.Count); Assert.AreEqual(0, gradient[0].Offset); Assert.AreEqual(color0, gradient[0].Color); Assert.AreEqual(0.5, gradient[1].Offset); Assert.AreEqual(color0, gradient[1].Color); Assert.AreEqual(0.5, gradient[2].Offset); Assert.AreEqual(color1, gradient[2].Color); Assert.AreEqual(1, gradient[3].Offset); Assert.AreEqual(color1, gradient[3].Color); }); }
public void RoundToDevicePixelsTest() { // 1 : 1 (device pixels : device-independent pixels) Assert.AreEqual(-1.0, WindowsHelper.RoundToDevicePixels(-0.5, 1.0)); Assert.AreEqual(0.0, WindowsHelper.RoundToDevicePixels(-0.4, 1.0)); Assert.AreEqual(0.0, WindowsHelper.RoundToDevicePixels(0.0, 1.0)); Assert.AreEqual(0.0, WindowsHelper.RoundToDevicePixels(0.4, 1.0)); Assert.AreEqual(1.0, WindowsHelper.RoundToDevicePixels(0.5, 1.0)); Assert.AreEqual(1.0, WindowsHelper.RoundToDevicePixels(1.0, 1.0)); Assert.AreEqual(1.0, WindowsHelper.RoundToDevicePixels(1.4, 1.0)); Assert.AreEqual(2.0, WindowsHelper.RoundToDevicePixels(1.5, 1.0)); // 2 : 1 (device pixels : device-independent pixels) Assert.AreEqual(-0.5, WindowsHelper.RoundToDevicePixels(-0.5, 0.5)); Assert.AreEqual(-0.5, WindowsHelper.RoundToDevicePixels(-0.25, 0.5)); Assert.AreEqual(0.0, WindowsHelper.RoundToDevicePixels(-0.24, 0.5)); Assert.AreEqual(0.0, WindowsHelper.RoundToDevicePixels(0.0, 0.5)); Assert.AreEqual(0.0, WindowsHelper.RoundToDevicePixels(0.24, 0.5)); Assert.AreEqual(0.5, WindowsHelper.RoundToDevicePixels(0.25, 0.5)); Assert.AreEqual(0.5, WindowsHelper.RoundToDevicePixels(0.5, 0.5)); Assert.AreEqual(0.5, WindowsHelper.RoundToDevicePixels(0.74, 0.5)); Assert.AreEqual(1.0, WindowsHelper.RoundToDevicePixels(0.75, 0.5)); // Points Assert.AreEqual(new Point(5.0, 7.5), WindowsHelper.RoundToDevicePixels(new Point(5.4, 7.7), new Size(1.0, 0.5))); // Rectangles Assert.AreEqual(new Rect(5.0, 7.5, 10, 10.5), WindowsHelper.RoundToDevicePixels(new Rect(5.4, 7.7, 9.7, 10.6), new Size(1.0, 0.5))); }
public async Task <bool> TryToPack(AcCommonObjectPackerParams packerParams) { try { using (var waiting = packerParams.Progress == null ? WaitingDialog.Create("Packing…") : null) { var progress = waiting ?? packerParams.Progress; var cancellation = waiting?.CancellationToken ?? packerParams.Cancellation; await Task.Run(() => { var destination = packerParams.Destination ?? Path.Combine(Location, $"{Id}-{(this as IAcObjectVersionInformation)?.Version ?? "0"}-{DateTime.Now.ToUnixTimestamp()}.zip"); using (var output = File.Create(destination)) { Pack(output, packerParams, new Progress <string>(x => progress?.Report(AsyncProgressEntry.FromStringIndetermitate($"Packing: {x}…"))), cancellation); } if (cancellation.IsCancellationRequested) { return; } if (packerParams.ShowInExplorer) { WindowsHelper.ViewFile(destination); } }); } return(true); } catch (Exception e) { NonfatalError.Notify("Can’t pack", e); return(false); } }
private static async Task <ArgumentHandleResult> ProcessGoogleSpreadsheetsLocale(string id, [CanBeNull] string locale, bool around) { if (string.IsNullOrWhiteSpace(id)) { throw new InformativeException(ToolsStrings.Common_IdIsMissing); } var url = around ? $@"{InternalUtils.MainApiDomain}/u/around?id={id}" : $@"https://docs.google.com/spreadsheets/d/{id}/export?format=xlsx&authuser=0"; await Task.Run(() => { if (File.Exists(LocaleHelper.GetGoogleSheetsFilename())) { FileUtils.Recycle(LocaleHelper.GetGoogleSheetsFilename()); FileUtils.TryToDelete(LocaleHelper.GetGoogleSheetsFilename()); } }); await LoadRemoteFileToNew(url, LocaleHelper.GetGoogleSheetsFilename()); SettingsHolder.Locale.LoadUnpacked = true; if (locale != null) { SettingsHolder.Locale.LocaleName = locale; } ActionExtension.InvokeInMainThreadAsync(() => { if (ModernDialog.ShowMessage(AppStrings.CustomLocalesUpdated_Message, AppStrings.CustomLocalesUpdated_Title, MessageBoxButton.YesNo) == MessageBoxResult.Yes) { WindowsHelper.RestartCurrentApplication(); } }); return(ArgumentHandleResult.Successful); }
private static void CheckAccess() { if (!WindowsHelper.CheckAccess()) { throw new InvalidOperationException("View model properties and methods must be accessed on UI thread."); } }
private void SetAeroGlass(bool enable) { if (!IsLoaded) { return; } if (enable == _isAeroGlassEnabled) { return; } _isAeroGlassEnabled = enable && WindowsHelper.SetAeroGlass(this, enable); if (_isAeroGlassEnabled) { // Set background transparent. _background = Background; Background = Brushes.Transparent; } else { // Restore background. Background = _background; } }
/// <summary> /// 取消配对 /// </summary> /// <param name="deviceCode"></param> private void CancelMatch(string deviceCode, string deviceID) { Conditions con = new Conditions(); con.AddItem("DeviceID", deviceID); con.AddItem("DeviceCode", deviceCode); // 发送配对消息 ResultWindow resultWindow = WindowsHelper.ShowDialogWindow <ResultWindow>(this, MsgType.DeviceCancelPair, MsgType.DeviceCancelPairResult, con, TryFindResource("GatherCancelPairing").ToString()); MessageBoxResult msgBoxResult = resultWindow.MessageBoxResult; if (msgBoxResult == MessageBoxResult.Cancel) { tbMsg.Text = TryFindResource("GatherCancelPairOverTime").ToString(); } else if (msgBoxResult == MessageBoxResult.Yes) { NewMessageBox.Show(TryFindResource("GatherCancelPairSuccess").ToString(), this); tbMsg.Text = string.Empty; btnCanelMatch.Visibility = Visibility.Hidden; } else if (msgBoxResult == MessageBoxResult.No) { DevicePairInfo devicePairInfo = resultWindow.ResultValue as DevicePairInfo; if (devicePairInfo.ResultCode == 2) { NewMessageBox.Show(TryFindResource("GatherCancelPairFail").ToString(), this); } else { NewMessageBox.Show(TryFindResource("GatherCancelPairFailed").ToString(), this); } } }
private void ExportCollectionButton_OnClick(object sender, RoutedEventArgs e) { try { var game = ProcessMonitor.RunningGameType; if (!game.HasValue) { return; } var collection = ArchetypeManager.GetCollection(game.Value); if (collection != null) { string export = ArchetypeManager.GetExportedDeck(game.Value, collection); if (WindowsHelper.TryCopyToClipboard(export, out string blockingWindowText)) { MessageBox.Show("Collection exported to clipboard", "Success"); } else { MessageBox.Show(blockingWindowText != null ? $"Unable to access clipboard.\nPlease close this window: {blockingWindowText}" : "Unable to access clipboard.", "Error"); } } else { MessageBox.Show("Something went wrong...", "Error"); } } catch (Exception ex) { Logger.LogError(ex.ToString()); MessageBox.Show($"Something went wrong...\n\n{ex.Message}", "Error"); } }
/// <summary> /// 告警明细 /// </summary> /// <param name="als"></param> public void SearchAlarmLogDetail(AlarmLogsSearch als, bool showWindow = true) { if (!AppHelper.CheckAppState(ModelResponsible.Instance.ParentWindow)) { return; } Conditions cons = new Conditions(); cons.AddItem("AlarmLevel", als.IsAdvanced ? als.AlarmLevel : ""); cons.AddItem("AlarmCode", als.IsAdvanced ? als.AlarmCode : ""); cons.AddItem("AlarmModule", (als.IsAdvanced && !string.IsNullOrEmpty(als.AlarmModule)) ? als.AlarmModule : "16,17,18,19,21,23,25,28"); cons.AddItem("AlarmStatus", als.IsAdvanced ? als.AlarmStatus : ""); cons.AddItem("AlarmIp", EEMSConfigHelper.GetValueByCommomConfig("config/CommonConfig/local_machine_ip", "127.0.0.1")); cons.AddItem("AlarmStartTime", als.AlarmStartTime); cons.AddItem("AlarmEndTime", als.SearchTime); cons.AddItem("PageIndex", als.PageIndex.ToString()); cons.AddItem("PageCount", als.PageCount.ToString()); if (showWindow) { ResultWindow resultWindow = WindowsHelper.ShowDialogWindow <ResultWindow>(null, MsgType.AlarmLogRequest, MsgType.AlarmLogRespond, cons, Application.Current.FindResource("SearchManagerSearch").ToString(), AppConfigInfos.AppStateInfos.SearchTimeOut); MessageBoxResult msgBoxResult = resultWindow.MessageBoxResult; if (msgBoxResult == MessageBoxResult.Cancel) { NewMessageBox.Show(Application.Current.FindResource("SearchManagerSearchFail").ToString()); } } else { ModelResponsible.Instance.SendMessage(MsgType.AlarmLogRequest, cons); } }