public static int DDEntryPoint(int argc, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr, SizeParamIndex = 0)] string[] args) { try { var parsedArgs = new List <string>(); parsedArgs.AddRange(args); var instance = parsedArgs[0]; parsedArgs.RemoveAt(0); using (var I = new ServerInterface()) if (I.ConnectToInstance(instance, true).HasFlag(ConnectivityLevel.Connected)) { I.GetComponent <ITGInterop>().InteropMessage(String.Join(" ", parsedArgs)); } } catch { } return(0); }
/// <summary> /// Tries to start a <see cref="ControlPanel"/> for a given <see cref="InstanceListBox"/> <paramref name="index"/> /// </summary> /// <param name="index">The <see cref="ListBox.SelectedIndex"/> of <see cref="InstanceListBox"/> to connect to</param> async void TryConnectToIndexInstance(int index) { if (index == ListBox.NoMatches) { return; } var instanceName = InstanceData[index].Name; if (ControlPanel.InstancesInUse.TryGetValue(instanceName, out ControlPanel activeCP)) { activeCP.BringToFront(); return; } var InstanceAccessor = new ServerInterface(masterInterface as ServerInterface); try { ConnectivityLevel res = ConnectivityLevel.None; await WrapServerOp(() => { res = InstanceAccessor.ConnectToInstance(instanceName); }); if (!res.HasFlag(ConnectivityLevel.Connected)) { MessageBox.Show("Unable to connect to instance! Does it exist?"); RefreshInstances(); } else if (!res.HasFlag(ConnectivityLevel.Authenticated)) { MessageBox.Show("The current user is not authorized to access this instance!"); } else { new ControlPanel(InstanceAccessor).Show(); } } catch { InstanceAccessor.Dispose(); throw; } }