private void Init() { this.Size = new Size(Settings.Default.MainFormWidth, Settings.Default.MainFormHeight); #if !DEBUG checkForUpdatesToolStripMenuItem.Visible = false; #endif this.Text = ProgramUI.GetApplicationName() + " - " + ProgramUI.GetApplicationVersion(); Instance = this; var treeView = new FileSystemTree(); FileSysTree = treeView; treeView.Show(dockPanelMain, DockState.DockLeft); var logs = new Logs(); LogControl = logs.LogControl; logs.Show(dockPanelMain, DockState.DockBottom); MainDockPanel = dockPanelMain; foreach (var item in ProgramUI.GetConfigs()) { Type serviceType = Type.GetType(item.ToString()); IConfigService configService = Activator.CreateInstance(serviceType) as IConfigService; var UIControl = Helper.GetUIControl(configService); if (UIControl.IsVisibleInReleaseMode()) { var toolTrip = newToolStripMenuItem.DropDownItems.Add(configService.GetTitle()); toolTrip.Tag = configService; toolTrip.Click += new EventHandler(tsmiNewForm_Click); } } }
private static ControlConfig GetControlInstance(FileInfo fileFound) { foreach (var item in ProgramUI.GetConfigs()) { Type serviceType = Type.GetType(item.AssemblyQualifiedName); if (serviceType != null) { if (Activator.CreateInstance(serviceType) is IConfigService configService && Path.GetFileNameWithoutExtension(fileFound.Name).IndexOf(configService.GetConfigPrefixFilename()) >= 0) { Type promptType = Type.GetType($"{configService.GetPromptToolFullName()}, {serviceType.Assembly.GetName()}"); var content = Activator.CreateInstance(promptType) as ControlConfig; return(content); } } else { PromptHelper.ShowPromptWarning($"{item } not found"); } } return(null); }
private void tvFileSystem_DoubleClick(object sender, EventArgs e) { FileInfo file = SelectedFile; if (file != null) { ControlConfigUI content = null; foreach (var item in MainForm.MainDockPanel.Contents) { if (((DockContent)item).Tag?.ToString() == file.FullName) { content = ((ControlConfigUI)item); break; } } if (content == null) { foreach (var item in ProgramUI.GetConfigs()) { Type serviceType = Type.GetType(item.ToString()); IConfigService configService = Activator.CreateInstance(serviceType) as IConfigService; if (Path.GetFileNameWithoutExtension(file.Name).IndexOf(configService.GetConfigPrefixFilename()) >= 0) { Type formType = Type.GetType(configService.GetFormFullName()); content = Activator.CreateInstance(formType) as ControlConfigUI; break; } } } if (content != null) { content.CreateWS(file); content.Tag = file.FullName; content.Text = file.Name; content.Show(MainForm.MainDockPanel, WeifenLuo.WinFormsUI.Docking.DockState.Document); } } }
private void CreateNewConfiguration() { List <IConfigService> configServiceResult = new List <IConfigService>(); foreach (var item in ProgramUI.GetConfigs()) { Type serviceType = Type.GetType(item.AssemblyQualifiedName); IConfigService configService = Activator.CreateInstance(serviceType) as IConfigService; configServiceResult.Add(configService); PromptHelper.ShowPromptHighlight($"{configService.GetConfigPrefixFilename()} \t {configService.GetTitle()}"); } string serviceFileName = PromptHelper.EnterValue($"Enter the config name you want to create: "); IConfigService selectedService = configServiceResult.FirstOrDefault(item => item.GetConfigPrefixFilename() == serviceFileName); Type promptType = Type.GetType($"{selectedService.GetPromptToolFullName()}, {typeof(IConfigService).Assembly.GetName()}"); var control = Activator.CreateInstance(promptType) as ControlConfig; string defaultFilename = control.GetDefaultWorkspaceFilename(); string newFilename = Path.Combine(Path.GetDirectoryName(defaultFilename), $"{Path.GetFileNameWithoutExtension(defaultFilename)}{serviceFileName}{Path.GetExtension(defaultFilename)}"); control.CreateWS(new FileInfo(newFilename)); }