public static void InstallUpdateAndRestart(DownloadedUpdate update) { try { Logger.AutoUpdate.LogDebug("Begin install"); File.Delete(TempNewAppPath); using (var tempNewAppFile = File.OpenWrite(TempNewAppPath)) update.UpdateBytes.WriteTo(tempNewAppFile); Logger.AutoUpdate.LogDebug("Extracted update"); File.Delete(TempOldAppPath); File.Move(App.Location, TempOldAppPath); File.Move(TempNewAppPath, App.Location); Logger.AutoUpdate.LogDebug("Replaced executable"); // disable settings with external state before upgrade, as the new version maybe uses a different system. StartWithSpotify.Disable(); Autostart.Disable(); Logger.AutoUpdate.LogDebug("Restarting"); Process.Start(App.Location, "/updateRestart").Dispose(); Application.Current.Dispatcher.Invoke(() => Application.Current.Shutdown()); } catch (Exception e) { Logger.AutoUpdate.LogException("Installation failed:", e); Logger.AutoUpdate.LogInfo("Starting failure cleanup"); // cleanup failed installation // try to restore app executable if (!File.Exists(App.Location)) { if (File.Exists(TempOldAppPath)) { File.Move(TempOldAppPath, App.Location); } else if (File.Exists(TempNewAppPath)) { File.Move(TempNewAppPath, App.Location); } } // delete update file if it still exists File.Delete(TempNewAppPath); Logger.AutoUpdate.LogInfo("Finished failure cleanup"); // rethrow exception throw; } finally { update.Dispose(); } }
public void tray_settings(object sender, EventArgs e) { if (_settingsOpen) { try { _settingsWindow.Focus(); } catch (Exception) { //ignore } return; } using (_settingsWindow = new frmSettings()) { _settingsOpen = true; _settingsWindow.actionManager = _actions; var tempConfig = _config.Clone(); _settingsWindow.config = _config; var dlgResult = _settingsWindow.ShowDialog(); if (dlgResult == DialogResult.OK) { _config = _settingsWindow.config; if (_settingsWindow.startWithWindows) { if (!Autostart.IsAutoStartEnabled()) { Autostart.SetAutoStart(); } } else { if (Autostart.IsAutoStartEnabled()) { Autostart.UnSetAutoStart(); } } _config.Save(_configPath); _actions.LoadConfig(_config); } else { _config = tempConfig; _synapticsHelper.Config = tempConfig; _actions.LoadConfig(_config); } _settingsWindow.Close(); _settingsOpen = false; } }
/// <summary> /// Creates a script block which loads a QuickTime video at runtime. /// </summary> /// <returns>Script block that will load a QuickTime video</returns> private string BuildScriptBlock() { string scriptBlock = string.Format("LoadQuickTime('QTPlaceholder_{0}', '{1}', {2}, {3}, '{4}', '{5}', '{6}', {7});", ltlScript.ClientID, HTMLHelper.HTMLEncode(URLHelper.ResolveUrl(VideoURL)), Width, Height, ShowControls.ToString().ToLowerCSafe(), Autostart.ToString().ToLowerCSafe(), Loop.ToString().ToLowerCSafe(), ScriptHelper.GetString(GetString("Media.NotSupported"))); return(ScriptHelper.GetScript(scriptBlock)); }
public static void SetAutostart(Autostart setting) { var startupFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup); switch (setting) { case Autostart.Disable: DeleteShortcut(startupFolderPath); break; case Autostart.Enable: CreateShortcut(startupFolderPath); break; } }
protected override void Render(HtmlTextWriter output) { StringBuilder sb = new StringBuilder("<OBJECT ID='" + this.ClientID + "' name='" + this.ClientID + "' " + "CLASSID='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6'" + "VIEWASTEXT" + "height=" + Height + " " + "width=" + Width + ">"); //Render properties as object parameters sb.Append("<PARAM name='URL' value='" + FileName + "'>"); sb.Append("<PARAM name='mute' value='" + Mute.ToString() + "'>"); sb.Append("<PARAM name='AutoStart' value='" + Autostart.ToString() + "'>"); sb.Append("<PARAM name='balance' value='" + Balance + "'>"); sb.Append("<PARAM name='enabled' value='" + Enabled.ToString() + "'>"); sb.Append("<PARAM name='fullScreen' value='" + Fullscreen.ToString() + "'>"); sb.Append("<PARAM name='playCount' value='" + PlayCount.ToString() + "'>"); if (Volume >= 0) { sb.Append("<PARAM name='volume' value='" + Volume + "'>"); } sb.Append("<PARAM name='rate' value='" + Rate + "'>"); sb.Append("<PARAM name='StretchToFit' value='" + StretchToFit.ToString() + "'>"); sb.Append("<PARAM name='enabledContextMenu' value='" + EnableContextMenu.ToString() + "'>"); //output ending object tag sb.Append("</OBJECT>"); //flush everything to the output stream output.Write(sb.ToString()); }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { if (PortalContext.IsDesignMode(PortalContext.ViewMode)) { ltlPlaceholder.Text = "<table style=\"border: 1px solid Gray;background-color:#eee;width:" + Width + "px;height:" + Height + "px\"><tr><td style=\"vertical-align:middle;text-align:center;color:Gray;\">" + GetString("global.herecomesvideo").ToUpperCSafe() + "</td></tr></table>"; } else { // Auto activation hack if (AutoActivation) { ltlPlaceholder.Text = "<div class=\"VideoLikeContent\" id=\"RMPlaceholder_" + ltlScript.ClientID + "\" ></div>"; // Register external script ScriptHelper.RegisterScriptFile(Page, "~/CMSWebParts/Media/RealMedia_files/video.js"); // Call function for video object insertion ltlScript.Text = BuildScriptBlock(); } else { // Movie ltlPlaceholder.Text = "<div class=\"VideoLikeContent\" ><div class=\"Video\"><object classid=\"clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA\" width=\"" + Width + "\" height=\"" + Height + "\">" + "<param name=\"src\" value=\"" + UrlResolver.ResolveUrl(VideoURL) + "\" />" + "<param name=\"autostart\" value=\"" + Autostart.ToString().ToLowerCSafe() + "\" />" + "<param name=\"wmode\" value=\"transparent\" />" + "<param name=\"loop\" value=\"" + Loop + "\" />" + "<param name=\"logo\" value=\"false\" />" + "<param name=\"controls\" value=\"ImageWindow\" />" + "<param name=\"console\" value=\"one\" />" + "<!--[if !IE]>-->" + "<embed height=\"" + Height + "\" loop=\"" + Loop + "\" wmode=\"transparent\" src=\"" + HTMLHelper.HTMLEncode(UrlResolver.ResolveUrl(VideoURL)) + "\" type=\"audio/x-pn-realaudio-plugin\" width=\"" + Width + "\" controls=\"ImageWindow\" autostart=\"" + Autostart + "\" console=\"one\" logo=\"false\" />" + "<!--<![endif]-->" + "<noembed>" + GetString("RealMedia.NotSupported") + "</noembed>" + "\n" + "</object></div>"; // Control panel if (ShowControls) { ltlPlaceholder.Text += "<div class=\"Controls\"><object classid=\"clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA\" width=\"" + Width + "\" height=\"" + ControlsHeight + "\">" + "<param name=\"src\" value=\"" + HTMLHelper.HTMLEncode(UrlResolver.ResolveUrl(VideoURL)) + "\" />" + "<param name=\"autostart\" value=\"" + Autostart.ToString().ToLowerCSafe() + "\" />" + "<param name=\"wmode\" value=\"transparent\" />" + "<param name=\"loop\" value=\"" + Loop + "\" />" + "<param name=\"controls\" value=\"ControlPanel\" />" + "<param name=\"logo\" value=\"false\" />" + "<param name=\"console\" value=\"one\" />" + "<!--[if !IE]>-->" + "<embed height=\"" + ControlsHeight + "\" loop=\"" + Loop + "\" wmode=\"transparent\" src=\"" + HTMLHelper.HTMLEncode(UrlResolver.ResolveUrl(VideoURL)) + "\" type=\"audio/x-pn-realaudio-plugin\" width=\"" + Width + "\" controls=\"ControlPanel\" autostart=\"" + Autostart + "\" console=\"one\" logo=\"false\" />" + "<!--<![endif]-->" + "<noembed>" + GetString("RealMedia.NotSupported") + "</noembed>" + "</object></div>"; } // End div ltlPlaceholder.Text += "</div>"; } } } }
public Mbsettings(SerializationInfo info, StreamingContext context) { Autostart = (bool)info.GetValue("AutoStart", Autostart.GetType()); Parity = (Parity)info.GetValue("Parity", Parity.GetType()); StopBit = (StopBits)info.GetValue("StopBit", StopBit.GetType()); }
private void frmSettings_Load(object sender, EventArgs e) { setHeight(settingsHeight[0]); var defaultActions = DefaultActions.getDefaultActions(); var defaultActionList = (from action in defaultActions select new { DisplayMember = action.Key, ValueMember = action.Value }).ToList(); comboSingleTap.DisplayMember = "DisplayMember"; comboSingleTap.ValueMember = "ValueMember"; comboSingleTap.DataSource = defaultActionList; comboSingleTap.SelectedValue = config.MouseTapOne == null ? DefaultAction.NoAction : config.MouseTapOne.GetValue(); comboSingleTap.SelectedValueChanged += comboTapsChanged; comboLongSingleTap.BindingContext = new BindingContext(); comboLongSingleTap.DisplayMember = "DisplayMember"; comboLongSingleTap.ValueMember = "ValueMember"; comboLongSingleTap.DataSource = defaultActionList; comboLongSingleTap.SelectedValue = config.MouseTapOneLong == null ? DefaultAction.NoAction : config.MouseTapOneLong.GetValue(); comboLongSingleTap.SelectedValueChanged += comboTapsChanged; comboTwoTaps.BindingContext = new BindingContext(); comboTwoTaps.DisplayMember = "DisplayMember"; comboTwoTaps.ValueMember = "ValueMember"; comboTwoTaps.DataSource = defaultActionList; comboTwoTaps.SelectedValue = config.MouseTapTwo == null ? DefaultAction.NoAction : config.MouseTapTwo.GetValue(); comboTwoTaps.SelectedValueChanged += comboTapsChanged; comboLongTwoTaps.BindingContext = new BindingContext(); comboLongTwoTaps.DisplayMember = "DisplayMember"; comboLongTwoTaps.ValueMember = "ValueMember"; comboLongTwoTaps.DataSource = defaultActionList; comboLongTwoTaps.SelectedValue = config.MouseTapTwoLong == null ? DefaultAction.NoAction : config.MouseTapTwoLong.GetValue(); comboLongTwoTaps.SelectedValueChanged += comboTapsChanged; comboThreeTaps.BindingContext = new BindingContext(); comboThreeTaps.DisplayMember = "DisplayMember"; comboThreeTaps.ValueMember = "ValueMember"; comboThreeTaps.DataSource = defaultActionList; comboThreeTaps.SelectedValue = config.MouseTapThree == null ? DefaultAction.NoAction : config.MouseTapThree.GetValue(); comboThreeTaps.SelectedValueChanged += comboTapsChanged; comboLongThreeTaps.BindingContext = new BindingContext(); comboLongThreeTaps.DisplayMember = "DisplayMember"; comboLongThreeTaps.ValueMember = "ValueMember"; comboLongThreeTaps.DataSource = defaultActionList; comboLongThreeTaps.SelectedValue = config.MouseTapThreeLong == null ? DefaultAction.NoAction : config.MouseTapThreeLong.GetValue(); comboLongThreeTaps.SelectedValueChanged += comboTapsChanged; trackTapTolerance.Value = config.MouseTapsLongMovingArea; trackLongTapTime.Value = config.MouseTapsLongMs; lblTapTolerance.Text = trackTapTolerance.Value + " px"; lblLongTapTime.Text = trackLongTapTime.Value + " ms"; trackScrollingAcceleration.Value = trackScrollingAcceleration.Maximum - config.ScrollAcceleration + trackScrollingAcceleration.Minimum; trackScrollingSpeed.Value = config.ScrollSpeed; chkScrollingVertical.Checked = config.ScrollVertical; chkScrollingHorizontal.Checked = config.ScrollHorizontal; chkScrollingReverse.Checked = config.ScrollReverse; chkScrollingAcceleration.Checked = config.ScrollAccelerationEnabled; startWithWindows = Autostart.IsAutoStartEnabled(); chkWindows.Checked = startWithWindows; chkWindows.CheckedChanged += windowsAutoStartChanged; cbSwipe2L.BindingContext = new BindingContext(); cbSwipe2L.DisplayMember = "DisplayMember"; cbSwipe2L.ValueMember = "ValueMember"; cbSwipe2L.DataSource = defaultActionList; cbSwipe2L.SelectedValue = config.SwipeTwoLeft == null ? DefaultAction.NoAction : config.SwipeTwoLeft.GetValue(); cbSwipe2L.SelectedValueChanged += comboSwipesChanged; cbSwipe2R.BindingContext = new BindingContext(); cbSwipe2R.DisplayMember = "DisplayMember"; cbSwipe2R.ValueMember = "ValueMember"; cbSwipe2R.DataSource = defaultActionList; cbSwipe2R.SelectedValue = config.SwipeTwoRight == null ? DefaultAction.NoAction : config.SwipeTwoRight.GetValue(); cbSwipe2R.SelectedValueChanged += comboSwipesChanged; cbSwipe3U.BindingContext = new BindingContext(); cbSwipe3U.DisplayMember = "DisplayMember"; cbSwipe3U.ValueMember = "ValueMember"; cbSwipe3U.DataSource = defaultActionList; cbSwipe3U.SelectedValue = config.SwipeThreeUp == null ? DefaultAction.NoAction : config.SwipeThreeUp.GetValue(); cbSwipe3U.SelectedValueChanged += comboSwipesChanged; cbSwipe3D.BindingContext = new BindingContext(); cbSwipe3D.DisplayMember = "DisplayMember"; cbSwipe3D.ValueMember = "ValueMember"; cbSwipe3D.DataSource = defaultActionList; cbSwipe3D.SelectedValue = config.SwipeThreeDown == null ? DefaultAction.NoAction : config.SwipeThreeDown.GetValue(); cbSwipe3D.SelectedValueChanged += comboSwipesChanged; cbSwipe3L.BindingContext = new BindingContext(); cbSwipe3L.DisplayMember = "DisplayMember"; cbSwipe3L.ValueMember = "ValueMember"; cbSwipe3L.DataSource = defaultActionList; cbSwipe3L.SelectedValue = config.SwipeThreeLeft == null ? DefaultAction.NoAction : config.SwipeThreeLeft.GetValue(); cbSwipe3L.SelectedValueChanged += comboSwipesChanged; cbSwipe3R.BindingContext = new BindingContext(); cbSwipe3R.DisplayMember = "DisplayMember"; cbSwipe3R.ValueMember = "ValueMember"; cbSwipe3R.DataSource = defaultActionList; cbSwipe3R.SelectedValue = config.SwipeThreeRight == null ? DefaultAction.NoAction : config.SwipeThreeRight.GetValue(); cbSwipe3R.SelectedValueChanged += comboSwipesChanged; cbSwipeBorderT.BindingContext = new BindingContext(); cbSwipeBorderT.DisplayMember = "DisplayMember"; cbSwipeBorderT.ValueMember = "ValueMember"; cbSwipeBorderT.DataSource = defaultActionList; cbSwipeBorderT.SelectedValue = config.SwipeBorderTop == null ? DefaultAction.NoAction : config.SwipeBorderTop.GetValue(); cbSwipeBorderT.SelectedValueChanged += comboSwipesChanged; cbSwipeBorderB.BindingContext = new BindingContext(); cbSwipeBorderB.DisplayMember = "DisplayMember"; cbSwipeBorderB.ValueMember = "ValueMember"; cbSwipeBorderB.DataSource = defaultActionList; cbSwipeBorderB.SelectedValue = config.SwipeBorderBottom == null ? DefaultAction.NoAction : config.SwipeBorderBottom.GetValue(); cbSwipeBorderB.SelectedValueChanged += comboSwipesChanged; cbSwipeBorderL.BindingContext = new BindingContext(); cbSwipeBorderL.DisplayMember = "DisplayMember"; cbSwipeBorderL.ValueMember = "ValueMember"; cbSwipeBorderL.DataSource = defaultActionList; cbSwipeBorderL.SelectedValue = config.SwipeBorderLeft == null ? DefaultAction.NoAction : config.SwipeBorderLeft.GetValue(); cbSwipeBorderL.SelectedValueChanged += comboSwipesChanged; cbSwipeBorderR.BindingContext = new BindingContext(); cbSwipeBorderR.DisplayMember = "DisplayMember"; cbSwipeBorderR.ValueMember = "ValueMember"; cbSwipeBorderR.DataSource = defaultActionList; cbSwipeBorderR.SelectedValue = config.SwipeBorderRight == null ? DefaultAction.NoAction : config.SwipeBorderRight.GetValue(); cbSwipeBorderR.SelectedValueChanged += comboSwipesChanged; }