protected void Delete(object sender, EventArgs e) { if (this.SelectedWorkSpace == -1) { return; } if (WinHelper.MessageBox("Do you really want to delete this Text?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } (Core.Core.Instanse.Data[this.SelectedWorkSpace].Text[this.SelectedText] as Text).Delete(); Core.Core.Instanse.Data[this.SelectedWorkSpace].Text.RemoveAt(this.SelectedText); if (this.TextChanged != null) { this.TextChanged(); } }
/// <summary> /// Check if update available, asks and show window that download update /// </summary> public static void Update() { string url = CheckUpdate(); if (url != string.Empty) { if (WinHelper.MessageBox("Update available. Do you want to update now?", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { Updater updaterWindow = new Updater() { URL = url }; updaterWindow.ShowDialog(); } else { //toolStripUpdateLabel.Text = "Update available!"; } } }
public void LoadConfig() { StreamingSetting c = Config.Current.StreamingSetting; txtPuerto.Text = c.Port == 0 ? "" : c.Port.ToString(); WinHelper.ComboBoxSelectByText(cboUsuarios, c.MaxUsers.ToString()); if (c.Type == StreamingTypes.Audio) { rdAudio.Checked = true; } else if (c.Type == StreamingTypes.Video) { rdVideo.Checked = true; } else if (c.Type == StreamingTypes.AudioVideo) { rdAudioVideo.Checked = true; } }
private void EULA_Load(object sender, EventArgs e) { this.Icon = Resources.Resources.IconRed; this.Text = Brand.Brand.Name + " " + this.Text; licenseLabel.Text = Brand.Brand.Name + " " + licenseLabel.Text; try { switch (Brand.Brand.Name) { case "Umax": { Accepted = bool.Parse(WinHelper.ReadRegistryKey(@"SOFTWARE\Umax SoftWorks", "EULA")); break; } } } catch (Exception) { this.Accepted = false; } }
private void WindowClosing(object sender, CancelEventArgs e) { if (this.Exit) { if (WinHelper.MessageBox("Do you really want close program?", "Exit...", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No) { e.Cancel = true; return; } if (!this.Visible) { this.Visible = true; } // Log if (RunTime.Instance.LogWindow != null) { RunTime.Instance.LogWindow.Close(); WPFApplication.DoEvents(); } this.updateTimer.Stop(); // Events this.trayIcon.DeInitializeEvents(); this.mainMenu.DeInitializeEvents(); this.trayIcon.Visible = false; this.trayIcon.Dispose(); // Exit WindowsHelper.Exit(); } else { e.Cancel = true; this.Visible = false; } }
public static bool EulaCheck() { try { switch (Brand.Name) { case "Umax": { return(bool.Parse(WinHelper.ReadRegistryKey(@"SOFTWARE\Umax SoftWorks", "EULA"))); } default: { return(false); } } } catch (Exception) { return(false); } }
private void Delete(object sender, EventArgs e) { if (!this.CanExecuteAction) { return; } if (WinHelper.MessageBox("Do you really want to delete this Template?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } (Core.Core.Instanse.Data[this.SelectedWorkSpace].Templates[this.SelectedTemplate] as Template).Changed -= this.EventHandler; (Core.Core.Instanse.Data[this.SelectedWorkSpace].Templates[this.SelectedTemplate] as Template).Delete(); Core.Core.Instanse.Data[this.SelectedWorkSpace].Templates.RemoveAt(this.SelectedTemplate); if (this.TemplateChanged != null) { this.TemplateChanged(); } }
private void applyButton_Click(object sender, EventArgs e) { GuiOptions.Instanse.Monitor = monitorCheckBox.Checked; GuiOptions.Instanse.MonitorNotifications = baloonsShowBaloonsCheckBox.Checked; GuiOptions.Instanse.MonitorNotificationsTime = (int)baloonsShowTimeNumericUpDown.Value; // Saving GuiOptions.Instanse.Save(); // Managing monitor if (GuiOptions.Instanse.Monitor) { if (File.Exists(Path.Combine(Application.StartupPath, "Monitor.exe"))) { System.Diagnostics.Process.Start(Path.Combine(Application.StartupPath, "Monitor.exe"), "-quiet"); } } else { WinHelper.SendMessage(Keys.F10, Umax.Brand.Brand.Name + " Doorway Studio 2012 Monitor"); } }
private void Initialize() { try { // Monitor monitorCheckBox.Checked = GuiOptions.Instanse.Monitor; // Baloons baloonsShowBaloonsCheckBox.Checked = GuiOptions.Instanse.MonitorNotifications; if (GuiOptions.Instanse.MonitorNotificationsTime < baloonsShowTimeNumericUpDown.Minimum || GuiOptions.Instanse.MonitorNotificationsTime > baloonsShowTimeNumericUpDown.Maximum) { baloonsShowTimeNumericUpDown.Value = 15; } else { baloonsShowTimeNumericUpDown.Value = GuiOptions.Instanse.MonitorNotificationsTime; } // General log generalLogSaveCheckBox.Enabled = GuiOptions.Instanse.MonitorLog; generalLogFileTextBox.Text = GuiOptions.Instanse.MonitorLogFileName; generalLogDirectoryTextBox.Text = GuiOptions.Instanse.MonitorLogDirectory; // Update log updateLogSaveCheckBox.Enabled = GuiOptions.Instanse.MonitorUpdateLog; updateLogFileTextBox.Text = GuiOptions.Instanse.MonitorUpdateLogFileName; updateLogDirectoryTextBox.Text = GuiOptions.Instanse.MonitorUpdateLogDirectory; // Events this.monitorCheckBox_CheckedChanged(null, null); this.generalLogSaveCheckBox_CheckedChanged(null, null); this.updateLogCheckBox_CheckedChanged(null, null); } catch (Exception) { WinHelper.MessageBox("Error!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Extract the icon based on the current data. /// </summary> public void UpdateIcon() { ImageSource newIcon = null; IconType newType = IconType.Warning; if (!string.IsNullOrEmpty(this.iconPath)) { newIcon = WinHelper.ExtractIcon(this.iconPath, this.iconIndex); if (newIcon != null) { newType = IconType.Custom; } } else { Program p = this as Program; if (p == null) // Not a program - use the default icon. { newType = IconType.Default; } else { if (p.IsValidFile) // Valid file? { newIcon = WinHelper.ExtractAssociatedIcon(p.PathAbsolute); newType = IconType.Custom; } else if (p.IsValidPath) // Valid dictionary? { newType = IconType.Default; } } } this.Icon = newIcon; this.IconType = newType; }
private void Initialize() { try { reportingCheckBox.Checked = GuiOptions.Instanse.Report; reportRDCheckBox.Checked = GuiOptions.Instanse.ReportRnD; fromTextBox.Text = GuiOptions.Instanse.ReportFrom; toTextBox.Text = GuiOptions.Instanse.ReportTo; subjectTextBox.Text = GuiOptions.Instanse.ReportSubject; messageTextBox.Text = GuiOptions.Instanse.ReportMessage; hostTextBox.Text = GuiOptions.Instanse.ReportHost; portNumericUpDown.Value = GuiOptions.Instanse.ReportPort; loginTextBox.Text = GuiOptions.Instanse.ReportLogin; passwordTextBox.Text = GuiOptions.Instanse.ReportPassword; attachLogsCheckBox.Checked = GuiOptions.Instanse.ReportAttachments; } catch (Exception) { WinHelper.MessageBox("Error!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void ValidateNoWin() { var gameBoard = new TestableGameBoard(); Assert.False(WinHelper.IsWinningMove(gameBoard)); }
private void LoadCamara(int camara) { VideoSetting setting; if (_camaraActual >= 0) { setting = _settings[_camaraActual]; SaveCamara(setting); } _camaraActual = camara; setting = _settings[camara]; bool habilitada = false; txtIpHost.Text = ""; txtIpUsuario.Text = ""; txtIpPassword.Text = ""; txtIpPort.Text = ""; txtLogPreview.Text = ""; SetUrl(""); cboPerfiles.Items.Clear(); cboPresetPosition.Items.Clear(); cbVideoDevice.SelectedIndex = -1; cbVideoSize.SelectedIndex = -1; cbVideoSubtype.SelectedIndex = -1; cbNorma.SelectedIndex = -1; btnPreviewStop_Click(null, null); habilitada = !string.IsNullOrEmpty(setting.VideoDevice); if (setting.VideoSource == VideoSources.IpCamera) { this.VideoSource = VidGrab.TVideoSource.vs_IPCamera; } else { this.VideoSource = VidGrab.TVideoSource.vs_VideoCaptureDevice; } if (this.VideoSource == VidGrab.TVideoSource.vs_IPCamera) { txtIpHost.Text = setting.Host; txtIpUsuario.Text = setting.Username; txtIpPassword.Text = setting.Password; if (setting.Port > 0) { txtIpPort.Text = setting.Port.ToString(); } else { txtIpPort.Text = ""; } SetUrl(setting.StreamUrl); bool result = true; if (!string.IsNullOrEmpty(setting.Profile)) { txtLogPreview.Text = "Buscando perfiles...."; Application.DoEvents(); result = LoadPerfiles(); txtLogPreview.Text = ""; Application.DoEvents(); WinHelper.ComboBoxSelectByValue(cboPerfiles, setting.Profile); } if (result) { if (!string.IsNullOrEmpty(setting.PresetStartupPosition)) { txtLogPreview.Text = "Buscando presets...."; Application.DoEvents(); LoadPresets(); txtLogPreview.Text = ""; Application.DoEvents(); WinHelper.ComboBoxSelectByValue(cboPresetPosition, setting.PresetStartupPosition); } } habilitada = !string.IsNullOrEmpty(setting.StreamUrl); } else { WinHelper.ComboBoxSelectByText(cbVideoDevice, setting.VideoDevice); WinHelper.ComboBoxSelectByText(cbVideoSize, setting.VideoSize); WinHelper.ComboBoxSelectByText(cbVideoSubtype, setting.VideoFormatSubType); WinHelper.ComboBoxSelectByText(cbNorma, setting.VideoNorma); habilitada = !string.IsNullOrEmpty(setting.VideoDevice); } chkHabilitada.Checked = habilitada; }
public void Connect() { mHandle = WtsApi32.WTSVirtualChannelOpen(IntPtr.Zero, -1, ChannelMessage.ChannelName); if (mHandle == IntPtr.Zero) { //Log("RDP Virtual channel Open Failed: " + new Win32Exception().Message); return; } try { byte[] buf = new byte[1024]; uint bytesRead; string text = ""; while (true) { if (WtsApi32.WTSVirtualChannelRead(mHandle, 0, buf, (uint)buf.Length, out bytesRead) != 0) { text = Encoding.Unicode.GetString(buf, 0, (int)bytesRead); } if (!string.IsNullOrEmpty(text)) { #region old /*string result = ""; * for (int i = 0; i < text.Length; i++) * { * if ((int)text[i] > 32 && (int)text[i] < 127) * { * result += text[i].ToString(); * } * else * { * result += string.Format("\\u{0:x4}", (int)text[i]); * } * } * * string tmpResult = new Regex(@"\\u([0-9A-F]{4})", RegexOptions.IgnoreCase | RegexOptions.Compiled).Replace( * result, x => string.Empty + Convert.ToChar(Convert.ToUInt16(x.Result("$1"), 16)));*/ /* //1、获取桌面窗口的句柄 * IntPtr desktopPtr = WinHelper.GetDesktopWindow(); * Write(desktopPtr.ToString() + ":" + GetHandleInfo(desktopPtr) + "\r\n"); * //2、获得一个子窗口(这通常是一个顶层窗口,当前活动的窗口) * IntPtr winPtr = WinHelper.GetWindow(desktopPtr, GetWindowCmd.GW_CHILD); * Write(winPtr.ToString() + ":" + GetHandleInfo(winPtr) + "\r\n"); * //3、循环取得桌面下的所有子窗口 * while (winPtr != IntPtr.Zero) * { * //4、继续获取下一个子窗口 * winPtr = WinHelper.GetWindow(winPtr, GetWindowCmd.GW_HWNDNEXT); * Write(winPtr.ToString() + ":" + GetHandleInfo(winPtr) + "\r\n"); * if (GetHandleInfo(winPtr).Contains("记事本")) * { * break; * } * }*/ #endregion if (text.Contains("使用服务端输入法")) { //解除键盘监控钩子 btnUninstallHook_Click(this, null); } else if (text.Contains("使用客户端输入法")) { btnInstallHook_Click(this, null); } else { WinHelper.SetForegroundWindow(WinHelper.foreGroundHandle); //WinHelper.SendMessage(WinHelper.foreGroundHandle, 11, IntPtr.Zero, IntPtr.Zero); //WinHelper.SendMessage(WinHelper.foreGroundHandle, 11, (IntPtr)(-1), IntPtr.Zero); WinHelper.SendText(text, WinHelper.foreGroundHandle); } } } } catch (Win32Exception ex) { //Log("RDP Virtual channel Query Failed: " + ex.Message); return; } }
private void StartUpLoaded(object sender, RoutedEventArgs e) { this.InitializeImages(); this.InitializeOptions(); // UI Language switch (Core.Core.Instanse.Options.Language) { case LanguageType.English: { RunTime.Instance.Localization = new ResourceManager("Umax.Resources.Localization.UI.Classic.English", typeof(Umax.Resources.Localization.UI.Classic.English).Assembly); break; } case LanguageType.Russian: { RunTime.Instance.Localization = new ResourceManager("Umax.Resources.Localization.UI.Classic.Russian", typeof(Umax.Resources.Localization.UI.Classic.Russian).Assembly); break; } } this.InitializeUI(); // Checking .Net FX if (!WindowsHelper.FXCheck()) { if (WinHelper.MessageBox("Microsoft .Net Framework 3.5 isn't installed. Please install it!\r\nDo you like to ignore and continue?", "Error!", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == System.Windows.Forms.DialogResult.No) { WPFApplication.Current.Shutdown(); } } // Update check if (WindowsHelper.UpdateFilesAvailable()) { WindowsHelper.StartMonitor("-update -quiet"); Close(); } // Initializing Core this.InitializeCore(); // Monitor if (GuiOptions.Instanse.Monitor) { WindowsHelper.StartMonitor("-quiet"); } // Checking accepting EULA if (!WindowsHelper.EulaCheck()) { using (EULA eulaWindow = new EULA()) { eulaWindow.ShowDialog(); if (!eulaWindow.Accepted) { this.Close(); } } } this.ShowMainWindow(); }
/// <summary> /// 另存为 /// </summary> /// <param name="oldFileName"></param> /// <param name="newFileName"></param> /// <returns></returns> public static bool SaveAs(string oldFileName, string newFileName = null) { //实例化Excel var flg = false; Microsoft.Office.Interop.Excel.Application excelApp = null; Microsoft.Office.Interop.Excel.Workbook workbook = null; Microsoft.Office.Interop.Excel.Worksheet worksheet = null; try { excelApp = new Microsoft.Office.Interop.Excel.Application(); excelApp.Visible = false; //提示框 excelApp.DisplayAlerts = false; //打开文件,n.FullPath是文件路径 workbook = excelApp.Application.Workbooks.Open(oldFileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Worksheets[1]; //for (int i = 1; i < workbook.Sheets.Count; ) //{ // repExcel.DisplayAlerts = false; // worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Worksheets[i]; // worksheet.Delete(); // repExcel.DisplayAlerts = true; //} if (newFileName == null) { newFileName = oldFileName;// Path.ChangeExtension(filesavefilename, "html"); } object savefilename = (object)newFileName; object ofmt = Microsoft.Office.Interop.Excel.XlFileFormat.xlExcel8; //如果文件存在则删除 if (System.IO.File.Exists(newFileName)) { System.IO.File.Delete(newFileName); } //进行另存为操作 workbook.SaveAs(savefilename, ofmt, Type.Missing, Type.Missing, Type.Missing, Type.Missing , Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing , Type.Missing, Type.Missing, Type.Missing, Type.Missing); flg = true; //逐步关闭所有使用的对象 IntPtr t = new IntPtr(excelApp.Hwnd); int processId; workbook.Close(false, Type.Missing, Type.Missing); excelApp.Quit(); System.Runtime.InteropServices.Marshal.ReleaseComObject(worksheet); worksheet = null; System.Runtime.InteropServices.Marshal.ReleaseComObject(workbook); workbook = null; System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp.Application.Workbooks); System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp); excelApp = null; //垃圾回收 GC.Collect(); WinHelper.GetWindowThreadProcessId(t, out processId); WinHelper.KillProcessByPID(processId); return(true); } catch (Exception ex) { try { excelApp.Quit(); System.Runtime.InteropServices.Marshal.ReleaseComObject(worksheet); System.Runtime.InteropServices.Marshal.ReleaseComObject(workbook); //调用window api查找Excel进程,并用关闭 IntPtr t = new IntPtr(excelApp.Hwnd); int processId; WinHelper.GetWindowThreadProcessId(t, out processId); WinHelper.KillProcessByPID(processId); worksheet = null; workbook = null; excelApp = null; } catch { } throw ex; //return false; } return(flg); }