private void AppsBoxUpdate(bool force) { if (force) { CacheData.CurrentAppInfo = default; } if (CacheData.CurrentAppInfo?.Any() != true) { return; } var selectedItem = string.Empty; if (appsBox.SelectedIndex >= 0) { selectedItem = appsBox.SelectedItem.ToString(); } appsBox.Items.Clear(); appsBox.Items.AddRange(CacheData.CurrentAppInfo.Select(x => x.Name).Cast <object>().ToArray()); if (appsBox.SelectedIndex < 0 && !string.IsNullOrWhiteSpace(Arguments.AppName)) { var appName = CacheData.FindAppData(Arguments.AppName).Key; if (string.IsNullOrWhiteSpace(appName) || !appsBox.Items.Contains(appName)) { appName = CacheData.FindAppData(Arguments.AppName).Name; } if (!string.IsNullOrWhiteSpace(appName) && appsBox.Items.Contains(appName)) { appsBox.SelectedItem = appName; } } if (appsBox.SelectedIndex < 0 && !string.IsNullOrWhiteSpace(Settings.LastItem) && appsBox.Items.Contains(Settings.LastItem)) { appsBox.SelectedItem = Settings.LastItem; } if (!string.IsNullOrWhiteSpace(selectedItem)) { appsBox.SelectedItem = selectedItem; } if (appsBox.SelectedIndex < 0) { appsBox.SelectedIndex = 0; } if (!Settings.StartMenuIntegration) { return; } var appNames = appsBox.Items.Cast <object>().Select(item => item.ToString()); SystemIntegration.UpdateStartMenuShortcuts(appNames); }
private void OpenWithForm_FormClosing(object sender, FormClosingEventArgs e) { Reg.RemoveSubKey(Settings.RegistryPath); if (!Settings.StartMenuIntegration) { return; } var appNames = appsBox.Items.Cast <string>(); SystemIntegration.UpdateStartMenuShortcuts(appNames); }
public static SystemIntegration SaveCultivations(SystemIntegration schedule) { if (schedule == null) { return(null); } DeviceService.InitData(); var tSchedule = schedule.CellCultivation; tSchedule.BatchNumber = CurrentContext.BatchNumber; tSchedule.CreatedAt = Common.Utility.Common.ToUnixTime(DateTime.Now); using (var db = new IotContext()) { db.CellCultivations.Add(tSchedule); db.SaveChanges(); } using (var db = new IotContext()) { schedule.Rocker.CultivationId = tSchedule.Id; db.Rockers.Add(schedule.Rocker); schedule.Gas.CultivationId = tSchedule.Id; db.Gases.Add(schedule.Gas); schedule.TemperatureGauge.DeviceId = tSchedule.Id; db.TemperatureGauges.Add(schedule.TemperatureGauge); var p = new List <Pump>() { schedule.PumpIn, schedule.PumpOut }; foreach (var each in p) { each.CultivationId = tSchedule.Id; db.Pumps.Add(each); } db.SaveChanges(); } return(schedule); }
private void MenuViewForm_FormClosing(object sender, FormClosingEventArgs e) { PreventClosure = true; if (Opacity > 0) { Opacity = 0; } if (!Settings.StartMenuIntegration) { return; } try { var appNames = appsListView.Items.OfType <ListViewItem>().Select(x => x.Text).Where(x => !x.EqualsEx("Portable")); SystemIntegration.UpdateStartMenuShortcuts(appNames); } catch (Exception ex) when(ex.IsCaught()) { Log.Write(ex); } }
private void ShellBtns_Click(object sender, EventArgs e) => SystemIntegration.Enable(sender as Button == addToShellBtn);
private static void Main() { Settings.Initialize(); var instanceKey = PathEx.LocalPath.GetHashCode().ToString(); using (new Mutex(true, instanceKey, out var newInstance)) { Language.ResourcesNamespace = typeof(Program).Namespace; MessageBoxEx.TopMost = true; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (newInstance && Arguments.ValidPaths.Any() && !ActionGuid.IsDisallowInterface) { Application.Run(new OpenWithForm().Plus()); return; } if (newInstance || ActionGuid.IsAllowNewInstance) { Application.Run(new MenuViewForm().Plus()); return; } if (!EnvironmentEx.CommandLineArgs(false).Any()) { return; } switch (EnvironmentEx.CommandLineArgs(false).Count) { case 1: { var first = EnvironmentEx.CommandLineArgs(false).First(); switch (first) { case ActionGuid.FileTypeAssociationAll: foreach (var appData in CacheData.CurrentAppInfo) { var assocData = appData.Settings?.FileTypeAssoc; assocData?.SystemRegistryAccess?.AssociateFileTypes(true); } return; case ActionGuid.RepairAppsSuite: Recovery.RepairAppsSuite(); return; case ActionGuid.RepairDirs: Recovery.RepairAppsSuiteDirs(); return; case ActionGuid.RepairVariable: Recovery.RepairEnvironmentVariable(); return; } break; } case 2: { var first = EnvironmentEx.CommandLineArgs(false).First(); switch (first) { case ActionGuid.FileTypeAssociation: FileTypeAssoc.Associate(EnvironmentEx.CommandLineArgs(false).SecondOrDefault()); return; case ActionGuid.RestoreFileTypes: FileTypeAssoc.Restore(EnvironmentEx.CommandLineArgs(false).SecondOrDefault()); return; case ActionGuid.SystemIntegration: SystemIntegration.Enable(EnvironmentEx.CommandLineArgs(false).SecondOrDefault().ToBoolean()); return; } break; } } if (!Arguments.ValidPaths.Any()) { return; } IntPtr hWnd; var stopwatch = new Stopwatch(); stopwatch.Start(); do { hWnd = Reg.Read(Settings.RegistryPath, "Handle", IntPtr.Zero); }while (hWnd == IntPtr.Zero && stopwatch.Elapsed.TotalSeconds <= 10); if (hWnd != IntPtr.Zero) { WinApi.NativeHelper.SendArgs(hWnd, Arguments.ValidPathsStr); } } }