private void AutoStartCheck() { var AutoStart = ApplicationAutostart.IsAutostartAsync(APP_NAME); var isAutoStart = AutoStart.Result; AutoStartCheckBox.IsChecked = isAutoStart; SetAutoStart(isAutoStart); this.WindowState = WindowState.Minimized; this.ResizeMode = ResizeMode.CanMinimize; notifyIcon = new System.Windows.Forms.NotifyIcon(); notifyIcon.Visible = true; notifyIcon.Icon = new Icon("favicon.ico"); notifyIcon.ShowBalloonTip(100, APP_NAME, APP_DESCRIPTION, System.Windows.Forms.ToolTipIcon.Info); notifyIcon.MouseDoubleClick += NotifyIcon_MouseDoubleClick; System.Windows.Forms.MenuItem[] menuItems = new System.Windows.Forms.MenuItem[] { new System.Windows.Forms.MenuItem("Open", (sender, args) => { ShowApplication(); }), new System.Windows.Forms.MenuItem("Exit", (sender, args) => { Close(); }) }; notifyIcon.ContextMenu = new System.Windows.Forms.ContextMenu(menuItems); this.Hide(); }
//Autostart private async void CheckBox_Changed(object sender, RoutedEventArgs e) { autostartCheckBox.Checked -= CheckBox_Changed; autostartCheckBox.Unchecked -= CheckBox_Changed; // bool succ = await ApplicationAutostart.SetAutostartAsync((bool)autostartCheckBox.IsChecked, "TouchInjector", Properties.Resources.AutostartTaskDescription, "-minimized", true); autostartCheckBox.IsChecked = (autostartCheckBox.IsChecked == succ); // autostartCheckBox.Checked += CheckBox_Changed; autostartCheckBox.Unchecked += CheckBox_Changed; }
public void SetAutoStart(bool isAutoStart) { var x = ApplicationAutostart.SetAutostartAsync(isAutoStart, APP_NAME, APP_DESCRIPTION); if (x.Result) { AutoStartCheckBox.Content = isAutoStart ? "Auto start (Yes)" : "Auto start (No)"; } else { AutoStartCheckBox.Content = "Auto start (No)"; } }
public async void Initialize() { ScanScreens(); feedbackCheckBox.IsChecked = Properties.Settings.Default.TouchFeedback; portBox.Text = Properties.Settings.Default.ListeningPort.ToString(); bool touch = await InitTouch(); bool tuio = await Connect(); touchInjectionStatus.Content = (touch) ? Properties.Resources.TouchReady : Properties.Resources.TouchError; SetStatus((touch && tuio) ? TouchInjectorStatus.Ready : TouchInjectorStatus.Error); autostartCheckBox.IsChecked = await ApplicationAutostart.IsAutostartAsync("TouchInjector"); autostartCheckBox.Checked += CheckBox_Changed; autostartCheckBox.Unchecked += CheckBox_Changed; }