public EnqueuedCommand(CommandAction cmd, string in_input, int source, CallbackAction clbk) { command = cmd; input = in_input; callback = clbk; sourceInstruction = source; }
public FloatSelector( MVRScript plug, bool insideRestore, CallbackAction call, string startAtom = null, AtomStorableSelector _storableSelected = null) { try { currentValue = new JSONStorableFloat("current value", 0f, setValue, -1f, 1f, false); plug.RegisterFloat(currentValue); currentValueSlider = plug.CreateSlider(currentValue, true); currentValueSlider.gameObject.SetActive(false); this.insideRestore = insideRestore; if (_storableSelected == null) { storableSelected = new AtomStorableSelector(plug, SyncStorable, startAtom); } else { storableSelected = _storableSelected; storableSelected.Add(SyncStorable); } floatChooser = new JSONStorableStringChooser("floatTarget", null, null, "Value", SyncfloatTarget); UIDynamicPopup dp = plug.CreateScrollablePopup(floatChooser); dp.popupPanelHeight = 820f; plug.RegisterStringChooser(floatChooser); } catch (Exception e) { SuperController.LogError("Exception caught: " + e); } }
public static void Open(Vector2 screenPosition, List <ComponentType> types, List <bool> typeSelections, CallbackAction callback) { ComponentTypeChooser.callback = callback; ComponentTypeChooser.types = types; ComponentTypeChooser.typeSelections = typeSelections; GetWindowWithRect <ComponentTypeChooser>(new Rect(screenPosition, kDefaultSize), true, "Choose Component", true); }
public ComponentTypeListView(TreeViewState state, List <ComponentType> types, List <bool> typeSelections, CallbackAction callback) : base(state) { this.callback = callback; this.types = types; this.typeSelections = typeSelections; Reload(); }
private void RunCallback(SchemaItem schemaItem, CallbackAction actionName) { if (schemaItem.Callback == null) { return; } string callbackName = schemaItem.Callback.Method + "," + schemaItem.Callback.Type; var timer = new Stopwatch(); timer.Start(); try { var args = new object[] { transatedConnection, transaction, actionName, version }; CallbackHelper.RunCallback(delegateType, callbackName, args, argTypes); } catch (Exception ex) { throw new Exception("Error in " + actionName + " callback", ex); } finally { timer.Stop(); if (timer.ElapsedMilliseconds > 20) { DebugLog("Callback: {2} {0} {1}ms", callbackName, timer.ElapsedMilliseconds, actionName); } } }
private void Send(string command, Action <string> handler, bool callOnFailure) { if (!Closed) { lastResponse = DateTime.Now; var action = responseHandler; if (action == null) { link.SendCommand(command); } responseHandler = (s, success) => { responseHandler = null; if (action != null) { action(s, success); Send(command, handler, callOnFailure); } else if (success || callOnFailure) { handler(s); } }; } }
/// <summary> /// 执行回调函数 /// </summary> /// <param name="input"></param> /// <returns></returns> public string Callback(object input) { if (CallbackAction == null) { return(TargetState); } return(CallbackAction.Execute(input)); }
public Callbacks(CallbackAction f) { _callbacks = new List <CallbackAction>(); if (f != null) { Add(f); } }
/// <summary> /// Initializes the signals /// </summary> protected override void InitSignals() { base.InitSignals(); TextChangedCallback = new CallbackActionString((text) => SendSignal(myTextChangedEventKey, new SignalArgsString(Util.GetStringFromC_UTF32(text)))); AddInternalSignal(tguiWidget_connectString(CPointer, Util.ConvertStringForC_ASCII("TextChanged"), TextChangedCallback)); SelectionChangedCallback = new CallbackAction(() => SendSignal(mySelectionChangedEventKey)); AddInternalSignal(tguiWidget_connect(CPointer, Util.ConvertStringForC_ASCII("SelectionChanged"), SelectionChangedCallback)); }
protected override void InitSignals() { base.InitSignals(); ValueChangedCallback = new CallbackActionUInt((val) => SendSignal(myValueChangedEventKey, new SignalArgsUInt(val))); AddInternalSignal(tguiWidget_connectUInt(CPointer, Util.ConvertStringForC_ASCII("ValueChanged"), ValueChangedCallback)); FullCallback = new CallbackAction(() => SendSignal(myFullEventKey)); AddInternalSignal(tguiWidget_connect(CPointer, Util.ConvertStringForC_ASCII("Full"), FullCallback)); }
public void Init(MVRScript script, CallbackAction call, string filter = "", string startVal = "None", string name = "atom", bool right = false) { this.filter = filter; atomChoices = new JSONStorableStringChooser(name, atomsUIDList, startVal, name, SyncAtom); script.RegisterStringChooser(atomChoices); popup = script.CreateScrollablePopup(atomChoices, right); popup.popupPanelHeight = System.String.IsNullOrEmpty(filter) ? 800f : 250f; popup.popup.onOpenPopupHandlers += SyncAtomChoices; }
public void Click() { Callback?.Notify(); foreach (Action item in CallbackAction) { item?.Invoke(); } CallbackAction.ForEach( (item) => item?.Invoke()); }
public ComponentTypeListView(TreeViewState state, List <ComponentType> types, List <bool> typeSelections, CallbackAction callback) : base(state) { this.callback = callback; this.types = types; this.typeSelections = typeSelections; typeNames = new List <GUIContent>(types.Count); for (var i = 0; i < types.Count; ++i) { typeNames.Add(new GUIContent(EntityQueryGUI.SpecifiedTypeName(types[i].GetManagedType()))); } Reload(); }
/// <summary> /// Get activities of dialog. /// </summary> /// <returns></returns> public override IEnumerator <Task> GetActivities() { bool isToSetUpCallBack = false; //Task checks the availibity of contact and sets the flag if contact is available. Task <ActivityResult> checkContactAvailibility = this.CreateCodeActivity_CheckAvailability(); yield return(checkContactAvailibility); if (isContactAvailable) { //Speak connecting to user statement. Task <ActivityResult> stmtConnectingToUser = Create_StmtConnectingToUser(); yield return(stmtConnectingToUser); } else { //Code Activity to load grammar to ask if want to set up call back. Task <ActivityResult> loadGrammar = this.CreateCodeActivity_LoadGrammar(); yield return(loadGrammar); //Ask if want to set up a call back. Task <ActivityResult> speechQA = this.Create_SpeechQuestionAnswerActivity(); yield return(speechQA.ContinueWith((task) => { if (task.Exception != null) { NextAction = CallbackAction.ConnectToUser; //Speak connecting to user statement. Task <ActivityResult> stmtConnectingToUser = Create_StmtConnectingToUser(); } else { RecognitionResult aqResult = speechQA.Result.Output["Result"] as RecognitionResult; isToSetUpCallBack = bool.Parse((string)aqResult.Semantics.Value); } })); if (isToSetUpCallBack) { NextAction = CallbackAction.SetupCallback; //Code activity to set up a call back. isSuccessinCallback = true; //intialize as true. Task <ActivityResult> setupCallback = this.CreateCodeActivity_SetupCallback(); yield return(setupCallback); //Notify customer that call back is set up. Task <ActivityResult> stmtCallbackcnfrm = this.Create_stmtCallbackcnfrm(); yield return(stmtCallbackcnfrm); } } }
public ComponentTypeListView(TreeViewState state, List <ComponentType> types, HashSet <ComponentType> typeSelections, List <ComponentType> previouslySelected, CallbackAction callback) : base(state) { this.callback = callback; this.types = types; this.typeSelections = typeSelections; this.previouslySelected = previouslySelected; typeNames = new List <GUIContent>(types.Count); for (var i = 0; i < types.Count; ++i) { typeNames.Add(new GUIContent(Properties.Editor.TypeUtility.GetTypeDisplayName(types[i].GetManagedType()))); } Reload(); }
/// <summary> /// Cheks if selected contact is available. /// </summary> private void Code_ifContactIsAvailable(object sender, EventArgs e) { var availability = this.ContactInfo.Availability; if (availability == PresenceAvailability.IdleOnline || availability == PresenceAvailability.Online) { //Contact is available. this.NextAction = CallbackAction.ConnectToUser; //Set isContactAvailable flag isContactAvailable = true; } }
public static Action CreateAction <T1, T2, T3, T4, T5>(string desc, string method, Action.CallbackActionDelegate func) { Action action = new CallbackAction(method, desc, new Type[] { typeof(T1), typeof(T2), typeof(T3), typeof(T4), typeof(T5) }, func); if (mgr != null) { string name = action.name.ToLower(); if (mgr.registered_actions.ContainsKey(name.ToLower())) { mgr.registered_actions.Remove(name); } mgr.registered_actions.Add(name, action); } return(action); }
public AtomStorableSelector( MVRScript plug, CallbackAction call, string startAtom = "None") : base(call) { try { atomSelected = new AtomSelector(plug, this.SyncAtom, startAtom); storableChooser = new JSONStorableStringChooser("element", null, null, "Element", SyncStorable); plug.RegisterStringChooser(storableChooser); UIDynamicPopup dp = plug.CreateScrollablePopup(storableChooser); dp.popupPanelHeight = 960f; } catch (Exception e) { SuperController.LogError("Exception caught: " + e); } }
public ActionSelector( MVRScript plug, CallbackAction call = null, string name = "action", string startAtom = null, AtomStorableSelector _storableSelected = null) : base(call) { try { actionButton = plug.CreateButton(null, true); actionButton.button.onClick.AddListener(CallAction); //actionButton.button.gameObject.SetActive(false); actionButton.button.enabled = false; skipSaveRestore = new JSONStorableBool("skip saverestore", false); plug.RegisterBool(skipSaveRestore); if (_storableSelected == null) { storableSelected = new AtomStorableSelector(plug, SyncStorable, startAtom); } else { SuperController.LogMessage("..."); storableSelected = _storableSelected; storableSelected.Add(SyncStorable); } actionChooser = new JSONStorableStringChooser(name, null, null, name, SyncActionTarget); plug.RegisterStringChooser(actionChooser); UIDynamicPopup dp = plug.CreateScrollablePopup(actionChooser); dp.popupPanelHeight = 820f; plug.CreateToggle(skipSaveRestore).toggle.onValueChanged.AddListener( b => { if (storableSelected.storable != null && storableSelected.storable.name != "None") { SyncStorable(storableSelected.storable.name); } }); } catch (Exception e) { SuperController.LogError("Exception caught: " + e); } }
public void runSlideshow(int startIndex) { if (startIndex == -1) { startIndex = 0; } AnomalousMvcContext context = slideshow.createContext(ResourceProvider, standaloneController.GUIManager, startIndex); context.RuntimeName = editorController.EditorContextRuntimeName; context.setResourceProvider(ResourceProvider); context.BlurAction = "Common/Blur"; CallbackAction blurAction = new CallbackAction("Blur", blurContext => { NavigationModel model = blurContext.getModel <NavigationModel>(Medical.SlideshowProps.BaseContextProperties.NavigationModel); Slide slide = slideshow.get(model.CurrentIndex); if (SlideshowContextBlurred != null) { SlideshowContextBlurred.Invoke(blurContext); } ThreadManager.invoke(new Action(() => { if (lastEditSlide == slide) { if (SlideSelected != null) { SlideSelected.Invoke(null, IEnumerableUtil <Slide> .EmptyIterator); } } if (SlideSelected != null) { SlideSelected.Invoke(slide, IEnumerableUtil <Slide> .EmptyIterator); } })); }); context.Controllers["Common"].Actions.add(blurAction); if (SlideshowContextStarting != null) { SlideshowContextStarting.Invoke(context); } standaloneController.TimelineController.setResourceProvider(editorController.ResourceProvider); standaloneController.MvcCore.startRunningContext(context); }
/// <summary> /// Initializes the signals /// </summary> protected override void InitSignals() { base.InitSignals(); MousePressedCallback = new CallbackAction(() => SendSignal(myMousePressedEventKey)); AddInternalSignal(tguiWidget_connect(CPointer, Util.ConvertStringForC_ASCII("MousePressed"), MousePressedCallback)); ClosedCallback = new CallbackAction(ProcessClosedSignal); AddInternalSignal(tguiWidget_connect(CPointer, Util.ConvertStringForC_ASCII("Closed"), ClosedCallback)); MaximizedCallback = new CallbackAction(() => SendSignal(myMaximizedEventKey)); AddInternalSignal(tguiWidget_connect(CPointer, Util.ConvertStringForC_ASCII("Maximized"), MaximizedCallback)); MinimizedCallback = new CallbackAction(() => SendSignal(myMinimizedEventKey)); AddInternalSignal(tguiWidget_connect(CPointer, Util.ConvertStringForC_ASCII("Minimized"), MinimizedCallback)); EscapeKeyPressedCallback = new CallbackAction(() => SendSignal(myEscapeKeyPressedEventKey)); AddInternalSignal(tguiWidget_connect(CPointer, Util.ConvertStringForC_ASCII("EscapeKeyPressed"), EscapeKeyPressedCallback)); }
/// <summary>Starts the downloading of a XAP package.</summary> /// <param name="packageUri">The URI of the XAP file to download.</param> /// <param name="callback">The callback to invoke when the operation is complete.</param> public void DownloadAsync(Uri packageUri, CallbackAction<IPackage> callback) { // Setup initial conditions. if (packageUri == null) throw new ArgumentNullException("packageUri"); // Start the download. var downloader = new DeploymentCatalog(packageUri); downloader.DownloadCompleted += (s, args) => { if (callback == null) return; var callbackPayload = new Callback<IPackage> { Cancelled = args.Cancelled, Error = args.Error, }; if (!callbackPayload.HasError) callbackPayload.Result = new PackageWrapper(downloader); callback(callbackPayload); }; downloader.DownloadAsync(); }
/// <summary> /// Initializes the internal signals /// </summary> protected virtual void InitSignals() { PositionChangedCallback = new CallbackActionVector2f((pos) => SendSignal(myPositionChangedEventKey, new SignalArgsVector2f(pos))); AddInternalSignal(tguiWidget_connectVector2f(CPointer, Util.ConvertStringForC_ASCII("PositionChanged"), PositionChangedCallback)); SizeChangedCallback = new CallbackActionVector2f((size) => SendSignal(mySizeChangedEventKey, new SignalArgsVector2f(size))); AddInternalSignal(tguiWidget_connectVector2f(CPointer, Util.ConvertStringForC_ASCII("SizeChanged"), SizeChangedCallback)); MouseEnteredCallback = new CallbackAction(() => SendSignal(myMouseEnteredEventKey)); AddInternalSignal(tguiWidget_connect(CPointer, Util.ConvertStringForC_ASCII("MouseEntered"), MouseEnteredCallback)); MouseLeftCallback = new CallbackAction(() => SendSignal(myMouseLeftEventKey)); AddInternalSignal(tguiWidget_connect(CPointer, Util.ConvertStringForC_ASCII("MouseLeft"), MouseLeftCallback)); FocusedCallback = new CallbackAction(() => SendSignal(myFocusedEventKey)); AddInternalSignal(tguiWidget_connect(CPointer, Util.ConvertStringForC_ASCII("Focused"), FocusedCallback)); UnfocusedCallback = new CallbackAction(() => SendSignal(myUnfocusedEventKey)); AddInternalSignal(tguiWidget_connect(CPointer, Util.ConvertStringForC_ASCII("Unfocused"), UnfocusedCallback)); AnimationFinishedCallback = new CallbackActionAnimation((type, visible) => SendSignal(myAnimationFinishedEventKey, new SignalArgsAnimation(type, visible))); AddInternalSignal(tguiWidget_connectAnimation(CPointer, Util.ConvertStringForC_ASCII("AnimationFinished"), AnimationFinishedCallback)); }
public void GetFocuserState(CallType callType = CallType.Async, Guid? clientId = null, CallbackAction callback = null, Control callbackUIControl = null) { IsolatedAction(() => { try { if (m_ConnectedFocuser != null && m_ConnectedFocuser.Connected) { // NOTE: Everyone can get the focuser state, even when it has been engaged FocuserState state = m_ConnectedFocuser.GetCurrentState(); if (!double.IsNaN(state.Temperature)) NativeHelpers.CurrentTemperature = (float) state.Temperature; OnFocuserState(state); return state; } return null; } catch (Exception ex) { OnFocuserErrored(); Trace.WriteLine(ex.GetFullStackTrace()); return ex; } }, callType, callback, callbackUIControl); }
public void GetCameraState(CallType callType = CallType.Async, Guid? clientId = null, CallbackAction callback = null, Control callbackUIControl = null) { IsolatedAction(() => { try { if (m_CameraDriver != null && m_CameraDriver.Connected) { VideoState state = m_CameraDriver.GetCurrentState(CameraStateQuery.All); OnVideoState(state); } } catch (Exception ex) { OnVideoErrored(); Trace.WriteLine(ex.GetFullStackTrace()); return ex; } return null; }, callType, callback, callbackUIControl); }
public void TelescopeSlewNearBy(double distanceInArcSec, GuideDirections direction, CallType callType = CallType.Async, Guid? clientId = null, CallbackAction callback = null, Control callbackUIControl = null) { IsolatedAction((distance, dir) => { try { if (m_ConnectedTelescope != null && m_ConnectedTelescope.Connected) { AssertTelescopeEngagement(clientId); m_ConnectedTelescope.SlewNearBy(distance, dir); TelescopeEquatorialPosition position = m_ConnectedTelescope.GetEquatorialPosition(); OnTelescopePosition(position); return position; } return null; } catch (Exception ex) { OnTelescopeErrored(); Trace.WriteLine(ex.GetFullStackTrace()); return ex; } }, distanceInArcSec, direction, callType, callback, callbackUIControl); }
private void toolStripInsertRecord_DropDownOpening(object sender, EventArgs e) { // find current subrecord and guess likely candidates // this could be much smarter try { toolStripInsertRecord.DropDownItems.Clear(); var br = Selection.Record as Record; var sr = Selection.SubRecord; if (br != null) { RecordStructure rs; if (RecordStructure.Records.TryGetValue(br.Name, out rs)) { var usedNames = new StringDictionary(); var delayedAddItems = new List <ToolStripMenuItem>(); var srs = (sr != null) ? sr.Structure : null; bool found = (srs == null); int idx = listSubrecord.GetFocusedItem(); if (idx < 0) { var indicies = listSubrecord.GetSelectionIndices(); idx = indicies != null && indicies.Length > 0 ? indicies[0] : -1; } foreach (var s in rs.subrecords) { if (!found && sr.Structure.Equals(s)) { found = true; } if (usedNames.ContainsKey(s.name)) { continue; } usedNames.Add(s.name, s.name); var callback = new CallbackAction <SubrecordStructure>( s, subItem => { var srnew = new SubRecord(subItem); if (idx == -1) { br.AddRecord(srnew); idx = br.SubRecords.Count - 1; } else { br.InsertRecord(idx + 1, srnew); idx = idx + 1; } br.MatchRecordStructureToRecord(SubRecords.ToArray()); FireDataChanged(); SelectIndex(idx); } ); var item = new ToolStripMenuItem(s.name, null, callback.ExecuteEvent); item.Tag = s; if (found) { toolStripInsertRecord.DropDownItems.Add(item); } else { delayedAddItems.Add(item); } } if (delayedAddItems.Count > 0) { if (toolStripInsertRecord.DropDownItems.Count > 0) { toolStripInsertRecord.DropDownItems.Add("-"); } toolStripInsertRecord.DropDownItems.AddRange(delayedAddItems.ToArray()); } } } else { toolStripInsertRecord.DropDownItems.Add("NEW_"); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
} // 0x0080BD00-0x0080BD10 // Methods public void RegisterActionListener(CallbackAction cb) { } // 0x0080B240-0x0080B250
} // 0x00C57850-0x00C57940 public void UnregisterActionListener(CallbackAction cb) { } // 0x00C57940-0x00C57A30
private void RunCallback(SchemaItem schemaItem, CallbackAction actionName) { if (schemaItem.Callback == null) return; string callbackName = schemaItem.Callback.Method + "," + schemaItem.Callback.Type; var timer = new Stopwatch(); timer.Start(); try { var args = new object[] { transatedConnection, transaction, actionName, version }; CallbackHelper.RunCallback(delegateType, callbackName, args, argTypes); } catch (Exception ex) { throw new Exception("Error in " + actionName + " callback", ex); } finally { timer.Stop(); if (timer.ElapsedMilliseconds > 20) DebugLog("Callback: {2} {0} {1}ms", callbackName, timer.ElapsedMilliseconds, actionName); } }
private void TryConnectASCOMVideo(CallType callType = CallType.Async, CallbackAction callback = null, Control callbackUIControl = null) { IsolatedAction(() => { try { if (m_ConnectedVideo != null && m_ConnectedVideo.ProgId != Settings.Default.ASCOMProgIdVideo) { ASCOMClient.Instance.DisconnectVideo(m_ConnectedVideo); m_ConnectedVideo = null; } if (m_ConnectedVideo == null && !string.IsNullOrEmpty(Settings.Default.ASCOMProgIdVideo)) { m_ConnectedVideo = ASCOMClient.Instance.CreateVideo(Settings.Default.ASCOMProgIdVideo); } if (m_ConnectedVideo != null) { if (!m_ConnectedVideo.Connected) { OnVideoConnecting(); m_ConnectedVideo.Connected = true; OnVideoConnected(); } else OnVideoConnected(); VideoState state = m_ConnectedVideo.GetCurrentState(); OnVideoState(state); return state; } return null; } catch (Exception ex) { OnVideoErrored(); Trace.WriteLine(ex.GetFullStackTrace()); return ex; } }, callType, callback, callbackUIControl); }
private void DisconnectOccuRecVideoCamera(CallType callType = CallType.Async, CallbackAction callback = null, Control callbackUIControl = null) { IsolatedAction(() => { try { if (m_CameraDriver != null && m_CameraDriver.Connected) { m_CameraDriver.Connected = false; } } catch (Exception ex) { OnVideoErrored(); Trace.WriteLine(ex.GetFullStackTrace()); return ex; } OnVideoDisconnected(); return null; }, callType, callback, callbackUIControl); }
private void DisconnectASCOMVideoCamera(CallType callType = CallType.Async, CallbackAction callback = null, Control callbackUIControl = null) { IsolatedAction(() => { try { if (m_ConnectedVideo != null) { ASCOMClient.Instance.DisconnectVideo(m_ConnectedVideo); m_ConnectedVideo = null; } } catch (Exception ex) { OnVideoErrored(); Trace.WriteLine(ex.GetFullStackTrace()); return ex; } OnVideoDisconnected(); return null; }, callType, callback, callbackUIControl); }
public void PerformTelescopePingActions(CallType callType = CallType.Async, Guid? clientId = null, CallbackAction callback = null, Control callbackUIControl = null) { IsolatedAction(() => { try { if (m_ConnectedTelescope != null && m_ConnectedTelescope.Connected) { TelescopeState state = m_ConnectedTelescope.GetCurrentState(); OnTelescopeState(state); } } catch (Exception ex) { OnTelescopeErrored(); Trace.WriteLine(ex.GetFullStackTrace()); return ex; } return null; }, callType, callback, callbackUIControl); }
/// <summary> /// Connects to an endpoint. /// </summary> public async Task <bool> BeginConnect(Uri endpointUrl, EventHandler <IMessageSocketAsyncEventArgs> callback, object state) { if (endpointUrl == null) { throw new ArgumentNullException(nameof(endpointUrl)); } if (m_socket != null) { throw new InvalidOperationException("The socket is already connected."); } SocketError error = SocketError.NotInitialized; CallbackAction doCallback = (SocketError socketError) => callback(this, new TcpMessageSocketConnectAsyncEventArgs(socketError) { UserToken = state }); IPAddress[] hostAdresses; try { // Get DNS host information hostAdresses = await Dns.GetHostAddressesAsync(endpointUrl.DnsSafeHost); } catch (SocketException e) { Utils.Trace("Name resolution failed for: {0} Error: {1}", endpointUrl.DnsSafeHost, e.Message); error = e.SocketErrorCode; goto ErrorExit; } // Get IPv4 and IPv6 address IPAddress[] addressesV4 = hostAdresses.Where(a => a.AddressFamily == AddressFamily.InterNetwork).ToArray(); IPAddress[] addressesV6 = hostAdresses.Where(a => a.AddressFamily == AddressFamily.InterNetworkV6).ToArray(); // Get port int port = endpointUrl.Port; if (port <= 0 || port > UInt16.MaxValue) { port = Utils.UaTcpDefaultPort; } int arrayV4Index = 0; int arrayV6Index = 0; bool moreAddresses; m_socketResponses = 0; m_tcs = new TaskCompletionSource <SocketError>(); do { error = SocketError.NotInitialized; lock (m_socketLock) { if (addressesV6.Length > arrayV6Index) { m_socketResponses++; } if (addressesV4.Length > arrayV4Index) { m_socketResponses++; } if (m_tcs.Task.IsCompleted) { m_tcs = new TaskCompletionSource <SocketError>(); } } if (addressesV6.Length > arrayV6Index && m_socket == null) { if (BeginConnect(addressesV6[arrayV6Index], AddressFamily.InterNetworkV6, port, doCallback) == SocketError.Success) { return(true); } arrayV6Index++; } if (addressesV4.Length > arrayV4Index && m_socket == null) { if (BeginConnect(addressesV4[arrayV4Index], AddressFamily.InterNetwork, port, doCallback) == SocketError.Success) { return(true); } arrayV4Index++; } moreAddresses = addressesV6.Length > arrayV6Index || addressesV4.Length > arrayV4Index; if (moreAddresses && !m_tcs.Task.IsCompleted) { await Task.Delay(1000); } if (!moreAddresses || m_tcs.Task.IsCompleted) { error = await m_tcs.Task; switch (error) { case SocketError.Success: return(true); case SocketError.ConnectionRefused: break; default: goto ErrorExit; } } } while (moreAddresses); ErrorExit: doCallback(error); return(false); }
public void TryConnectFocuser(CallType callType = CallType.Async, Guid? clientId = null, CallbackAction callback = null, Control callbackUIControl = null) { IsolatedAction(() => { try { if (m_ConnectedFocuser != null && m_ConnectedFocuser.ProgId != Settings.Default.ASCOMProgIdFocuser) { AssertFocuserEngagement(clientId); ASCOMClient.Instance.DisconnectFocuser(m_ConnectedFocuser); m_ConnectedFocuser = null; } if (m_ConnectedFocuser == null && !string.IsNullOrEmpty(Settings.Default.ASCOMProgIdFocuser)) { m_ConnectedFocuser = ASCOMClient.Instance.CreateFocuser( Settings.Default.ASCOMProgIdFocuser, Settings.Default.FocuserLargeStep, Settings.Default.FocuserSmallStep, Settings.Default.FocuserSmallestStep); } if (m_ConnectedFocuser != null) { if (!m_ConnectedFocuser.Connected) { OnFocuserConnecting(); m_ConnectedFocuser.Connected = true; OnFocuserConnected(); } else OnFocuserConnected(); FocuserState state = m_ConnectedFocuser.GetCurrentState(); OnFocuserState(state); return state; } return null; } catch (Exception ex) { OnFocuserErrored(); Trace.WriteLine(ex.GetFullStackTrace()); return ex; } }, callType, callback, callbackUIControl); }
public void GetTelescopeState(CallType callType = CallType.Async, Guid? clientId = null, CallbackAction callback = null, Control callbackUIControl = null) { IsolatedAction(() => { try { if (m_ConnectedTelescope != null && m_ConnectedTelescope.Connected) { AssertTelescopeEngagement(clientId); TelescopeEquatorialPosition position = m_ConnectedTelescope.GetEquatorialPosition(); OnTelescopePosition(position); return position; } return null; } catch (Exception ex) { OnTelescopeErrored(); Trace.WriteLine(ex.GetFullStackTrace()); return ex; } }, callType, callback, callbackUIControl); }
} // 0x00C57840-0x00C57850 public void RegisterActionListener(CallbackAction cb) { } // 0x00C57850-0x00C57940
public void DisconnectTelescope(CallType callType = CallType.Async, Guid? clientId = null, CallbackAction callback = null, Control callbackUIControl = null) { IsolatedAction(() => { try { if (m_ConnectedTelescope != null) { AssertTelescopeEngagement(clientId); ASCOMClient.Instance.DisconnectTelescope(m_ConnectedTelescope); m_ConnectedTelescope = null; } } catch (Exception ex) { OnTelescopeErrored(); Trace.WriteLine(ex.GetFullStackTrace()); return ex; } OnTelescopeDisconnected(); return null; }, callType, callback, callbackUIControl); }
public SingleEvent(CallbackAction cb = CallbackAction.None) { callback = cb; }
public void DisconnectVideoCamera(CallType callType = CallType.Async, Guid? clientId = null, CallbackAction callback = null, Control callbackUIControl = null) { if (m_ConnectedVideo != null) DisconnectASCOMVideoCamera(callType, callback, callbackUIControl); else if (m_CameraDriver != null) DisconnectOccuRecVideoCamera(callType, callback, callbackUIControl); }
} // 0x0080B240-0x0080B250 public void UnregisterActionListener(CallbackAction cb) { } // 0x0080B250-0x0080B260
public void FocuserMoveOut(FocuserStepSize stepSize, CallType callType = CallType.Async, Guid? clientId = null, CallbackAction callback = null, Control callbackUIControl = null) { IsolatedAction((x) => { try { if (m_ConnectedFocuser != null && m_ConnectedFocuser.Connected) { AssertFocuserEngagement(clientId); m_ConnectedFocuser.MoveOut(x); FocuserPosition position = m_ConnectedFocuser.GetCurrentPosition(); OnFocuserPosition(position); return position; } return null; } catch (Exception ex) { OnFocuserErrored(); Trace.WriteLine(ex.GetFullStackTrace()); return ex; } }, stepSize, callType, callback, callbackUIControl); }
/// <summary>Starts the downloading of a XAP package.</summary> /// <param name="xapName">The name of the XAP file to download (assumes that it is within the ClientBin of the hosting site).</param> /// <param name="callback">The callback to invoke when the operation is complete.</param> public void DownloadAsync(string xapName, CallbackAction<IPackage> callback) { xapName = xapName.RemoveEnd(xapExtension) + xapExtension; DownloadAsync(new Uri(xapName, UriKind.Relative), callback); }
public void FocuserSetTempComp(bool useTempComp, CallType callType = CallType.Async, Guid? clientId = null, CallbackAction callback = null, Control callbackUIControl = null) { IsolatedAction((x) => { try { if (m_ConnectedFocuser != null && m_ConnectedFocuser.Connected) { AssertFocuserEngagement(clientId); m_ConnectedFocuser.ChangeTempComp(x); FocuserState state = m_ConnectedFocuser.GetCurrentState(); OnFocuserState(state); return state; } return null; } catch (Exception ex) { OnFocuserErrored(); Trace.WriteLine(ex.GetFullStackTrace()); return ex; } }, useTempComp, callType, callback, callbackUIControl); }
private void TryConnectOccuRecVideo(CallType callType = CallType.Async, CallbackAction callback = null, Control callbackUIControl = null) { IsolatedAction(() => { try { if (m_CameraDriver != null) { if (!m_CameraDriver.Connected) { OnVideoConnecting(); m_CameraDriver.Connected = true; OnVideoConnected(); } else OnVideoConnected(); VideoState state = m_CameraDriver.GetCurrentState(CameraStateQuery.All); OnVideoState(state); return state; } return null; } catch (Exception ex) { OnVideoErrored(); Trace.WriteLine(ex.GetFullStackTrace()); return ex; } }, callType, callback, callbackUIControl); }
public void TelescopePulseGuide(GuideDirections direction, PulseRate pulseRate, CallType callType = CallType.Async, Guid? clientId = null, CallbackAction callback = null, Control callbackUIControl = null) { IsolatedAction((x, y) => { try { if (m_ConnectedTelescope != null && m_ConnectedTelescope.Connected) { AssertTelescopeEngagement(clientId); m_ConnectedTelescope.PulseGuide(x, y, Settings.Default.TelPulseDuration); TelescopeEquatorialPosition position = m_ConnectedTelescope.GetEquatorialPosition(); OnTelescopePosition(position); return position; } return null; } catch (Exception ex) { OnTelescopeErrored(); Trace.WriteLine(ex.GetFullStackTrace()); return ex; } }, direction, pulseRate, callType, callback, callbackUIControl); }
public void TryConnectTelescope(CallType callType = CallType.Async, Guid? clientId = null, CallbackAction callback = null, Control callbackUIControl = null) { IsolatedAction(() => { try { if (m_ConnectedTelescope != null && m_ConnectedTelescope.ProgId != Settings.Default.ASCOMProgIdTelescope) { AssertTelescopeEngagement(clientId); ASCOMClient.Instance.DisconnectTelescope(m_ConnectedTelescope); m_ConnectedTelescope = null; } if (m_ConnectedTelescope == null && !string.IsNullOrEmpty(Settings.Default.ASCOMProgIdTelescope)) m_ConnectedTelescope = ASCOMClient.Instance.CreateTelescope(Settings.Default.ASCOMProgIdTelescope, Settings.Default.TelPulseSlowestRate, Settings.Default.TelPulseSlowRate, Settings.Default.TelPulseFasterRate); if (m_ConnectedTelescope != null) { if (!m_ConnectedTelescope.Connected) { OnTelescopeConnecting(); m_ConnectedTelescope.Connected = true; OnTelescopeConnected(); } else OnTelescopeConnected(); TelescopeCapabilities capabilities = m_ConnectedTelescope.GetTelescopeCapabilities(); OnTelescopeCapabilitiesKnown(capabilities); TelescopeState state = m_ConnectedTelescope.GetCurrentState(); OnTelescopeState(state); return state; } return null; } catch (Exception ex) { OnTelescopeErrored(); Trace.WriteLine(ex.GetFullStackTrace()); return ex; } }, callType, callback, callbackUIControl); }
public void CameraOSDUp(CallType callType = CallType.Async, Guid? clientId = null, CallbackAction callback = null, Control callbackUIControl = null) { IsolatedAction(() => { try { if (m_CameraDriver != null && m_CameraDriver.Connected) { m_CameraDriver.OSDUp(); } } catch (Exception ex) { OnVideoErrored();; Trace.WriteLine(ex.GetFullStackTrace()); return ex; } return null; }, callType, callback, callbackUIControl); }
/// <summary> /// Try to connect to endpoint and do callback if connected successfully /// </summary> /// <param name="address">Endpoint address</param> /// <param name="addressFamily">Endpoint address family</param> /// <param name="port">Endpoint port</param> /// <param name="callback">Callback that must be executed if the connection would be established</param> private SocketError BeginConnect(IPAddress address, AddressFamily addressFamily, int port, CallbackAction callback) { var socket = new Socket(addressFamily, SocketType.Stream, ProtocolType.Tcp); var args = new SocketAsyncEventArgs() { UserToken = callback, RemoteEndPoint = new IPEndPoint(address, port), }; args.Completed += new EventHandler <SocketAsyncEventArgs>(OnSocketConnected); if (!socket.ConnectAsync(args)) { // I/O completed synchronously OnSocketConnected(socket, args); return(args.SocketError); } return(SocketError.InProgress); }
public void TryConnectVideoCamera(CallType callType = CallType.Async, Guid? clientId = null, CallbackAction callback = null, Control callbackUIControl = null) { if (m_CameraDriver != null) TryConnectOccuRecVideo(callType, callback, callbackUIControl); else if (m_ConnectedVideo != null || !string.IsNullOrEmpty(Settings.Default.ASCOMProgIdVideo)) TryConnectASCOMVideo(callType, callback, callbackUIControl); }