/// <summary> /// /// Command Manager example /// http://help.solidworks.com/2012/English/api/sldworksapi/Create_Flyouts_in_the_CommandManager_Example_CSharp.htm /// /// Adding menus and toolbars /// http://www.angelsix.com/cms/products/tutorials/64-solidworks/74-solidworks-menus-a-toolbars /// /// Defining dynamic methods /// http://msdn.microsoft.com/en-us/library/exczf7b9(v=vs.100).aspx /// </summary> private void UISetup() { config_info = new ConfigInfo(config_path); plugin_info = config_info.list(); plugin_icon_img_path = Path.GetFullPath(Path.Combine(working_dir(), "IconSprite.bmp")); try { callback_handler = (new PluginCall(config_info, this)).callback_container; mSWApplication.SetAddinCallbackInfo(0, (object)callback_handler, mSWCookie); } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.Message + "\n" + e.StackTrace); } bool commands_added = add_commands(); ThreadPool.QueueUserWorkItem((x) => { System.Net.Sockets.Socket s = PluginCall.run_host(config_info.host_info()["proc_name"], config_info.host_info()["proc_path"]); s.Close(); }); }
private void populate_config_vals(ConfigInfo config_data) { plugins = config_data.list(); callback_container = build_container(); config = config_data.host_info(); String working_dir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); host_port = Convert.ToInt32(config["host_port"]); host_ip = config["host_ip"]; String host_proc_relative_dir = Path.GetFullPath(Path.Combine(working_dir, "..\\..\\host")); host_proc_name = config["proc_name"]; if (String.IsNullOrEmpty(host_proc_name)) { // Find the exe in the host proc dir try { var files = Directory.EnumerateFiles(host_proc_relative_dir, "*.exe", System.IO.SearchOption.TopDirectoryOnly); foreach (String file in files) { host_proc_name = Path.GetFileNameWithoutExtension(file); } } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.Message); } } host_proc_path = config["proc_path"]; if (String.IsNullOrEmpty(host_proc_path)) { // path as relative location from the dir host_proc_path = Path.GetFullPath(Path.Combine(host_proc_relative_dir, host_proc_name + ".exe")); } host_proc_args = config["proc_args"]; }