Ejemplo n.º 1
0
        public void ShowDialog(BoolDelegate action)
        {
            var g   = PushView("UI/Dialog");
            var dia = g.GetComponent <DialogUI>();

            dia.SetCb(action);
        }
Ejemplo n.º 2
0
    public void Init(int width, int height, float cardPadding, BoolDelegate onCarouselSwap, BoolDelegate onShowEndOfDayCard, int carouselLength = -1, bool clearOnRepopulate = true, bool verticalMode = false, bool allowRecommending = false)
    {
        _verticalMode                        = verticalMode;
        _cardPadding                         = cardPadding;
        HideNoResultsCardDelegate            = onCarouselSwap;
        SetEndOfDayNoResultsCardTextDelegate = onShowEndOfDayCard;

        // Initialize carousels and populate with blank cards
        if (null == _mainCarousel)
        {
            GameObject mainCarouselObject = NGUITools.AddChild(gameObject);
            mainCarouselObject.name = "MainCarousel";
            _mainCarousel           = mainCarouselObject.AddComponent <CardCarousel>();
        }
        int dayIndex = (!_verticalMode ? dayOfWeekController.SelectedDay.IndexOfDay : -1);

        _mainCarousel.Init(dayIndex, width, height, cardPadding, PresentDetailCardHelper, carouselLength, clearOnRepopulate, _verticalMode, allowRecommending);
        _mainCarousel.OnNoCardsForSelectedDay = InvokeShowNoResultsCard;
        if (null == _secondaryCarousel)
        {
            GameObject secondaryCarouselObject = NGUITools.AddChild(gameObject);
            secondaryCarouselObject.name = "SecondaryCarousel";
            _secondaryCarousel           = secondaryCarouselObject.AddComponent <CardCarousel>();
        }
        if (!_verticalMode)
        {
            // If the next day index is out of bounds, init with prev just so he's initialized with something.
            int curIndex          = dayOfWeekController.SelectedDay.IndexOfDay;
            int secondaryDayIndex = curIndex == dayOfWeekController.NumberOfDays - 1 ? curIndex - 1 : curIndex + 1;
            _secondaryCarousel.Init(secondaryDayIndex, width, height, cardPadding, PresentDetailCardHelper, carouselLength, clearOnRepopulate, _verticalMode, allowRecommending);
            _secondaryCarousel.OnNoCardsForSelectedDay = InvokeShowNoResultsCard;
        }
    }
        public void SpecifyTermination(BoolDelegate terminationCriterion, State successorState, string successorInitName, VoidDelegate termination = null)
        {
            if (Parent.CheckForState(successorState) || successorState == null)
            {
                StateInitialization init = null;
                if (successorInitName != null)
                {
                    foreach (StateInitialization iinit in StateInitializations)
                    {
                        if (iinit.Name == successorInitName)
                        {
                            init = iinit;
                        }
                    }
                }

                StateTerminationSpecifications.Add(new StateTerminationSpecification(terminationCriterion, successorState, init, termination));
                if (StateDefaultTermination == null && termination != null)
                {
                    StateDefaultTermination = termination;
                }
            }
            else
            {
                Debug.LogError(Parent.ControlLevelName + ": Attempted to add successor state to state " + StateName + " but this state is not found in control level " + Parent.ControlLevelName);
            }
        }
Ejemplo n.º 4
0
    public void ShowBanner(AdPlacementType placementType = AdPlacementType.Banner, BoolDelegate onAdLoaded = null)
    {
        if (isShowingBanner)
        {
            Debug.Log("AdsManager: A banner is already being shown"); return;
        }
        if (DoNotShowAds(placementType))
        {
            onAdLoaded?.Invoke(false);
            return;
        }
        ;
        StartCoroutine(CoShowBanner(placementType, onAdLoaded));

        /*switch (CurrentAdNetwork)
         * {
         *  case CustomMediation.AD_NETWORK.Unity:
         *      UnityAdsManager.ShowBanner(CustomMediation.GetUnityPlacementId(placementType));
         *      break;
         *  case CustomMediation.AD_NETWORK.FAN:
         *      FacebookAudienceNetworkHelper.instance.ShowBanner(CustomMediation.GetFANPlacementId(placementType));
         *      break;
         * }
         * showingBanners.Add(CurrentAdNetwork);*/
    }
        public void SpecifyStateTermination(BoolDelegate terminationCriterion, State successorState, VoidDelegate termination, State state = null)
        {
            List <State> stateList = new List <State>();

            if (state == null)
            {
                stateList = AvailableStates;
            }
            else
            {
                stateList.Add(state);
            }
            foreach (State s in stateList)
            {
                if (CheckForState(s))
                {
                    s.SpecifyTermination(terminationCriterion, successorState, termination);
                }
                else
                {
                    Debug.LogError("Attempted to specify StateTerminationSpecification for state named " + state.StateName
                                   + " via ControlLevel " + ControlLevelName + ", but this ControlLevel does" +
                                   " not contain this state. Perhaps you need to add it using the ControlLevel.AddActiveStates method.");
                }
            }
        }
Ejemplo n.º 6
0
    IEnumerator CoShowBanner(AdPlacementType placementType = AdPlacementType.Banner, BoolDelegate onAdLoaded = null)
    {
        bool isSuccess = false;
        WaitForSecondsRealtime checkInterval = new WaitForSecondsRealtime(0.3f);

        var adPriority = GetAdsNetworkPriority(placementType);

        for (int i = 0; i < adPriority.Count; i++)
        {
            bool checkAdNetworkDone = false;
            var  adsHelper          = GetAdsNetworkHelper(adPriority[i]);
            if (adsHelper == null)
            {
                continue;
            }
            adsHelper.ShowBanner(placementType,
                                 (success) => { checkAdNetworkDone = true; isSuccess = success; onAdLoaded?.Invoke(success); });
            while (!checkAdNetworkDone)
            {
                yield return(checkInterval);
            }
            if (isSuccess)
            {
                //showingBanners.Add(CurrentAdNetwork);
                isShowingBanner = true;
                break;
            }
        }
    }
Ejemplo n.º 7
0
        private void SafeDisableButtons(bool value)
        {
            if (button1.InvokeRequired)
            {
                var del = new BoolDelegate(SafeDisableButtons);
                button1.Invoke(del, new object[] { value });
            }
            else
            {
                button1.Enabled = false;
            }
            if (button2.InvokeRequired)
            {
                var del = new BoolDelegate(SafeDisableButtons);
                button2.Invoke(del, new object[] { value });
            }
            else
            {
                button2.Enabled = false;
            }

            if (button3.InvokeRequired)
            {
                var del = new BoolDelegate(SafeDisableButtons);
                button3.Invoke(del, new object[] { value });
            }
            else
            {
                button3.Enabled = false;
            }
        }
Ejemplo n.º 8
0
 public void AddValueListener(BoolDelegate theDelegate)
 {
     using (TimedLock.Lock(listenerLock))
     {
         BoolValueReceived += theDelegate;
     }
 }
Ejemplo n.º 9
0
 public FileLoader(FileMD5 file, string netDirPath, string localDirPath, BoolDelegate downLoadFinish)
 {
     this.file         = file;
     this.netDirPath   = netDirPath;
     this.localDirPath = localDirPath;
     this.downFinish   = downLoadFinish;
 }
Ejemplo n.º 10
0
    IEnumerator CoReward(BoolDelegate onFinish, AdPlacementType placementType)
    {
        RewardResult           rewardResult = new RewardResult(); string errorMsg = string.Empty;
        WaitForSecondsRealtime checkInterval = new WaitForSecondsRealtime(0.3f);

        List <CustomMediation.AD_NETWORK> adPriority = GetAdsNetworkPriority(placementType);

        for (int i = 0; i < adPriority.Count; i++)
        {
            bool checkAdNetworkDone     = false;
            IAdsNetworkHelper adsHelper = GetAdsNetworkHelper(adPriority[i]);
            if (adsHelper == null)
            {
                continue;
            }
            adsHelper.Reward(placementType, (result) =>
            {
                checkAdNetworkDone = true; rewardResult = result;
            });
            while (!checkAdNetworkDone)
            {
                yield return(checkInterval);
            }
            if (rewardResult.type == RewardResult.Type.Finished)
            {
                currentAdsHelper = adsHelper;
                break;
            }
            if (rewardResult.type == RewardResult.Type.Canceled)
            {
                break;
            }                                                               //if a reward ads was shown and user skipped it, stop looking for more ads
        }

        /*for (int i = 0; i < adsNetworkHelpers.Count; i++)
         * {
         *  bool checkAdNetworkDone = false;
         *  adsNetworkHelpers[i].Reward(placementType, (result) =>
         *  {
         *      checkAdNetworkDone = true; rewardResult = result;
         *  });
         *  while (!checkAdNetworkDone)
         *  {
         *      yield return checkInterval;
         *  }
         *  if (rewardResult.type == RewardResult.Type.Finished)
         *  {
         *      currentAdsHelper = adsNetworkHelpers[i];
         *      break;
         *  }
         *  if (rewardResult.type == RewardResult.Type.Canceled) { break; } //if a reward ads was shown and user skipped it, stop looking for more ads
         * }*/
        onFinish(rewardResult.type == RewardResult.Type.Finished);
        Manager.LoadingAnimation(false);
        if (rewardResult.type == RewardResult.Type.LoadFailed)
        {
            ShowError(rewardResult.message, placementType);
        }
    }
Ejemplo n.º 11
0
 public PerformActionState(BoolDelegate _hasActionPlan, IGoap _goapData, StateMachine _controller, Queue <GoapAction> _currentActions, GameObject _agent)
 {
     currentActions = _currentActions;
     hasActionPlan  = _hasActionPlan;
     goapData       = _goapData;
     controller     = _controller;
     agent          = _agent;
 }
Ejemplo n.º 12
0
        public TextInputNotification(string title, string defaultText, BoolDelegate complete)
        {
            tav           = new TextAlertView(title, this, defaultText);
            this.complete = complete;
            tav.Show();

            AppDelegate.SetUsingViewController(true);
        }
Ejemplo n.º 13
0
 public void RemoveValueListener(BoolDelegate theDelegate)
 {
     using (TimedLock.Lock(listenerLock))
     {
         BoolValueReceived -= theDelegate;
         //SuggestGoingInActive(); // TODO: here or only after certain calls to this method?  get rid of it all together? (ie always keep the same taglist but only use the values we care about...since taglist updates take time)
     }
 }
Ejemplo n.º 14
0
        public void SetCheckBox(string name, BoolDelegate cb)
        {
            var tog = GetName(name).GetComponent <UIToggle>();

            EventDelegate.Add(tog.onChange, delegate {
                cb(tog.value);
            });
        }
Ejemplo n.º 15
0
        public Heartbeat(string instanceName, BoolDelegate greenCondition, BoolDelegate yellowCondition, StringDelegate callerStatusString)
        {
            heartbeatStatus = new HeartbeatStatus();
            heartbeatStatus.InstanceName = instanceName;

            _greenCondition += greenCondition;
            _yellowCondition += yellowCondition;
            _callerStatusString += callerStatusString;
        }
Ejemplo n.º 16
0
 public static void DoBoolDelegate(BoolDelegate func, GameObject arg, bool state)
 {
     try {
         func(arg, state);
     } catch (Exception ex) {
         //TopTip.addTip(a.Method.Name + "执行出错" + ex.ToString());
         FuncUtil.ShowError(func.Method.Name + "执行出错" + ex.ToString());
     }
 }
Ejemplo n.º 17
0
 public static Composite ExecuteReturnAlwaysSuccess(BoolDelegate condition, CreateBehavior behavior)
 {
     return
         (new DecoratorContinue(ret => condition.Invoke(null),
                                new PrioritySelector(
                                    behavior.Invoke(null),
                                    new Zeta.TreeSharp.Action(ret => RunStatus.Success)
                                    )
                                ));
 }
Ejemplo n.º 18
0
 //Condition Failure => return Success
 //Behavior Failure => return Success
 //Behavior Success => return Success
 public static Composite ExecuteReturnAlwaysSuccess(BoolDelegate condition, CreateBehavior behavior)
 {
     return
     new DecoratorContinue(ret => condition.Invoke(null),
         new PrioritySelector(
             behavior.Invoke(null),
             new Zeta.TreeSharp.Action(ret => RunStatus.Success)
         )
     );
 }
 /// <summary>
 /// Adds a single control level termination specification.
 /// </summary>
 /// <param name="criterion">Criterion.</param>
 /// <param name="method">Method.</param>
 /// <remarks>Parameters consist of a single criterion for termination, and an optional termination method. If a termination method is not specified, the DefaultTerminationMethod will run after the TerminationCriterion returns true.</remarks>
 /// <overloads>There are two overloads for this method.</overloads>
 public void AddTerminationSpecification(BoolDelegate criterion, VoidDelegate method = null)
 {
     if (method == null)
     {
         controlLevelTerminationSpecifications.Add(new ControlLevelTerminationSpecification(criterion, controlLevelDefaultTermination));
     }
     else
     {
         controlLevelTerminationSpecifications.Add(new ControlLevelTerminationSpecification(criterion, method));
     }
 }
Ejemplo n.º 20
0
 public void OpenTargetting(Targeting t, BoolDelegate returnCall)
 {
     if (targetting.Setup(t, returnCall)) //Different from normal, to encapsulate skipping behaviour that's possible.
     {
         targetting.Activate();
     }
     else
     {
         RogueUIPanel.ExitAllWindows(); //SWITCH THIS TO UI CONTROLLER WHEN THAT'S IN
     }
 }
Ejemplo n.º 21
0
 public bool Any(List <GameObject> gos, BoolDelegate check)
 {
     for (int i = 0; i < gos.Count; i++)
     {
         if (check(gos[i]))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 22
0
 public void SetProgressBarMode(bool isIndeterminate)
 {
     if (Thread.CurrentThread != Dispatcher.Thread)
     {
         BoolDelegate _delegate = new BoolDelegate(SetProgressBarMode);
         Dispatcher.Invoke(DispatcherPriority.Normal, _delegate, isIndeterminate);
     }
     else
     {
         progressBar.IsIndeterminate = isIndeterminate;
     }
 }
Ejemplo n.º 23
0
        /*
         * Unfortunately C# has so support for macros :-(.
         *
         * Useful macros would be like:
         * #define TRY(expr) do { try { expr } catch { AddError(#expr " failed."); return false; } } while (0)
         * #define TEST(name, desc) do { AddOutput(#desc); res = Test ## name(); if (!res) { ++errors; } } while (0)
         *
         * However it can use something like function pointers, so i ended up using this methods for
         * making testing a little bit easier. Of course it's not good as the macros above, but may save some time.
         */
        /// <summary>
        /// Executes a test, increases errors if failed.
        /// </summary>
        /// <param name="descr">description of the test</param>
        /// <param name="tests">amount of tests already done -> will be incremented</param>
        /// <param name="errors">amount of errors so far -> will be incremented if test fails</param>
        /// <param name="b">test function to execute</param>
        private void TEST(string descr, ref uint tests, ref uint errors, BoolDelegate b)
        {
            bool res;

            ++tests;
            AddOutput(descr);
            res = b();
            if (!res)
            {
                ++errors;
            }
        }
 private void DefineTermination(BoolDelegate terminationCriterion, State successorState, StateInitialization successorInit = null, VoidDelegate termination = null)
 {
     TerminationCriterion = terminationCriterion;
     if (termination != null)
     {
         Termination = termination;
     }
     SuccessorState = successorState;
     if (successorInit != null)
     {
         successorState.StateActiveInitialization = successorInit;
     }
 }
Ejemplo n.º 25
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="objs"></param>
        /// <param name="del"></param>
        /// <returns></returns>
        public static bool FOR_EACH_CK(T[] objs, BoolDelegate del)
        {
            int c = objs.Length;

            for (int i = 0; i < c; ++i)
            {
                if (!del.Invoke(objs[i]))
                {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 26
0
 private void SafeDisableB3(bool value)
 {
     if (button3.InvokeRequired)
     {
         var del = new BoolDelegate(SafeDisableB3);
         button3.Invoke(del, new object[] { value });
     }
     else
     {
         button3.Enabled = false;
         button3.Visible = false;
     }
 }
Ejemplo n.º 27
0
 public void OnDestroy()
 {
     onSubmit            = null;
     onHover             = null;
     onClick             = null;
     onToggleChanged     = null;
     onDragStart         = null;
     onDragEnd           = null;
     onSliderChanged     = null;
     onScrollbarChanged  = null;
     onDrag              = null;
     onDrapDownChanged   = null;
     onInputFieldChanged = null;
 }
Ejemplo n.º 28
0
        public SQLControl()
        {
            InitializeComponent();

            // initialize delegates
            SetResultsDel   = new StringBoolDelegate(this.SetMessage);
            ShowResultsDel  = new DataTableDelegate(this.ShowResults);
            SetUpFormDel    = new BoolDelegate(this.SetUpForm);
            ChangeCursorDel = new CursorDelegate(this.ChangeCursor);
            SetMessageDel   = new StringDelegate(this.ShowMessage);

            Condlg          = new ConnectionDialog();
            m_bQueryRunning = false;
            m_bConnected    = false;
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Remove entries that correspond to the search
        /// </summary>
        /// <param name="search">search delegate</param>
        public void Remove(BoolDelegate search)
        {
            Dictionary <string, object> entry = new Dictionary <string, object> ();

            for (int i = entries.Count - 1; i >= 0; i--)
            {
                for (int j = 0; j < fieldNames.Length; j++)
                {
                    entry [fieldNames [j]] = entries [i] [j];
                }
                if (search(entry))
                {
                    entries.RemoveAt(i);
                }
            }
        }
Ejemplo n.º 30
0
 public bool Setup(Targeting t, BoolDelegate endResult)
 {
     current    = t;
     returnCall = endResult;
     //current = t.Initialize();
     if (current.BeginTargetting(Player.player.location, LOS.lastCall))
     {
         if (highlights != null)
         {
             if (highlights.GetLength(0) != current.length || highlights.GetLength(1) != current.length)
             {
                 foreach (HighlightBlock h in highlights)
                 {
                     Destroy(h.gameObject);
                 }
                 BuildArea();
             }
         }
         else
         {
             BuildArea();
         }
         for (int i = 0; i < current.length; i++)
         {
             for (int j = 0; j < current.length; j++)
             {
                 //Debug pattern
                 highlights[i, j].Hide();
             }
         }
         return(true);
     }
     else
     {
         Debug.Log("UI asked to quit early, so locking point in now");
         if (!current.LockPoint()) //UI thinks we don't even need it, so just skip this whole thing
         {
             Debug.LogError("Targeting item that skips can NOT have more than one point! This is unecessary behaviour, and must be fixed immediately to maintain invariants.");
             #if UNITY_EDITOR
             UnityEditor.EditorApplication.isPlaying = false;
             #endif
         }
         return(false);
     }
 }
Ejemplo n.º 31
0
        /// <summary>
        /// Return entries that correspond to search
        /// </summary>
        /// <param name="search">search delegate</param>
        public object[][] Search(BoolDelegate search)
        {
            List <object[]>             res   = new List <object[]> ();
            Dictionary <string, object> entry = new Dictionary <string, object> ();

            for (int i = 0; i < entries.Count; i++)
            {
                for (int j = 0; j < fieldNames.Length; j++)
                {
                    entry [fieldNames [j]] = entries [i] [j];
                }
                if (search(entry))
                {
                    res.Add((object[])entries [i].Clone());
                }
            }
            return(res.ToArray());
        }
Ejemplo n.º 32
0
 public void Clear()
 {
     onSubmit      = null;
     onClick       = null;
     onDoubleClick = null;
     onHover       = null;
     onPress       = null;
     onSelect      = null;
     onScroll      = null;
     onDragStart   = null;
     onDrag        = null;
     onDragOver    = null;
     onDragOut     = null;
     onDragEnd     = null;
     onDrop        = null;
     onKey         = null;
     onTooltip     = null;
 }
Ejemplo n.º 33
0
	public void Init(int width, int height, float cardPadding, BoolDelegate onCarouselSwap, BoolDelegate onShowEndOfDayCard, int carouselLength = -1, bool clearOnRepopulate = true, bool verticalMode = false, bool allowRecommending = false)
	{
		_verticalMode = verticalMode;
		_cardPadding = cardPadding;
		HideNoResultsCardDelegate = onCarouselSwap;
		SetEndOfDayNoResultsCardTextDelegate = onShowEndOfDayCard;

		// Initialize carousels and populate with blank cards
		if (null == _mainCarousel)
		{
			GameObject mainCarouselObject = NGUITools.AddChild(gameObject);
			mainCarouselObject.name = "MainCarousel";
			_mainCarousel = mainCarouselObject.AddComponent<CardCarousel>();
		}
		int dayIndex = (!_verticalMode ? dayOfWeekController.SelectedDay.IndexOfDay : -1);
		_mainCarousel.Init(dayIndex, width, height, cardPadding, PresentDetailCardHelper, carouselLength, clearOnRepopulate, _verticalMode, allowRecommending);
		_mainCarousel.OnNoCardsForSelectedDay = InvokeShowNoResultsCard;
		if (null == _secondaryCarousel)
		{
			GameObject secondaryCarouselObject = NGUITools.AddChild(gameObject);
			secondaryCarouselObject.name = "SecondaryCarousel";
			_secondaryCarousel = secondaryCarouselObject.AddComponent<CardCarousel>();
		}
		if (!_verticalMode)
		{
			// If the next day index is out of bounds, init with prev just so he's initialized with something.
			int curIndex = dayOfWeekController.SelectedDay.IndexOfDay;
			int secondaryDayIndex =  curIndex == dayOfWeekController.NumberOfDays-1 ? curIndex - 1 : curIndex + 1;
			_secondaryCarousel.Init(secondaryDayIndex, width, height, cardPadding, PresentDetailCardHelper, carouselLength, clearOnRepopulate, _verticalMode, allowRecommending);
			_secondaryCarousel.OnNoCardsForSelectedDay = InvokeShowNoResultsCard;
		}
	}
Ejemplo n.º 34
0
        // ボタン動作設定登録関数
        private void Add(int WorkID, BoolDelegate Action, int Digit, BoolDelegate OnOffCheck,
            BoolDelegate OffOnCheck, BoolDelegate RelatedDelegate, int Address, int BankStore, 
            int SearchType = SystemConstants.DB_GROUP_SEARCH_TYPE_BTN, int DefaultMode = SystemConstants.BTN_OFF)
        {
            ButtonActionStruct actionStruct = new ButtonActionStruct();
            actionStruct.WorkID = WorkID;
            actionStruct.ActionDelegate = Action;
            actionStruct.OnOffCheck = OnOffCheck;
            actionStruct.OffOnCheck = OffOnCheck;
            actionStruct.RelatedDelegate = RelatedDelegate;
            actionStruct.Digit = Digit;
            actionStruct.Address = Address;
            actionStruct.BankStore = BankStore;
            actionStruct.SearchType = SearchType;
            actionStruct.DefaultMode = DefaultMode;

            map.Add(
                WorkID,
                actionStruct
            );
        }
Ejemplo n.º 35
0
 /// <summary>
 /// 界面在退出或者用户点击返回之前都可以注册执行逻辑
 /// </summary>
 protected void RegisterReturnLogic(BoolDelegate newLogic)
 {
     returnPreLogic = newLogic;
 }
Ejemplo n.º 36
0
 public bool CallBoolDelegate(BoolDelegate d)
 {
     return d();
 }
Ejemplo n.º 37
0
 public AandC(string s, BoolDelegate v)
 {
     A = s;
     C = v;
 }
Ejemplo n.º 38
0
 public AandC(string s)
 {
     A = s;
     C = () => true;
 }
Ejemplo n.º 39
0
 public KeyAssignment(Keys key, BoolDelegate function, bool toggle = true)
 {
     mKey = key;
       mDelegate = function;
       mToggle = toggle;
 }
Ejemplo n.º 40
0
 //Condition Failure => return Success
 //Behavior Failure => return Failure
 //Behavior Success =>return Success
 public static Composite ExecuteReturnSuccessOrBehaviorResult(BoolDelegate condition, CreateBehavior behavior)
 {
     return new DecoratorContinue(ret => condition.Invoke(null), behavior.Invoke(null));
 }
 public void SetProgressBarMode(bool isIndeterminate)
 {
     if (Thread.CurrentThread != Dispatcher.Thread)
     {
         BoolDelegate _delegate = new BoolDelegate(SetProgressBarMode);
         Dispatcher.Invoke(DispatcherPriority.Normal, _delegate, isIndeterminate);
     }
     else
     {
         progressBar.IsIndeterminate = isIndeterminate;                
     }
 }
Ejemplo n.º 42
0
 public StateLearning(List<Section> sections, BoolDelegate IsPredictorsWorkedWell, VoidDelegate NotifyLearningIsDone)
     : base(sections)
 {
     this.NotifyLearningIsDone = NotifyLearningIsDone;
       this.IsPredictorsWorkWell = IsPredictorsWorkedWell;
 }
Ejemplo n.º 43
0
 static extern bool EnumWindows(BoolDelegate d, IntPtr lParam);
        /// <summary>
        /// Creates a HomeOS device library instance supporting assocation with HomeOS hubs, using wifi, serial or storage devices (USB host, SD card) 
        /// to transfer credentials.   
        /// </summary>
        /// <param name="manufacturer">A string identifying the manufacturer, e.g. "Microsoft Research"</param>
        /// <param name="deviceTypeIdentifier">A string identifying the device type, e.g. "MoistureSensor"</param>
        /// <param name="setupWifiAuthCode">The authentication code used for wifi setup networks to prove that the caller has physical access to this device (it should be written on the device)</param>
        /// <param name="wifi">The instance of the wifi module.  Cannot be null.</param>
        /// <param name="led">The instance of an LED module to show the wifi connection state.  Can be null.  The LED will not be controlled if the doNotControlLed delegate returns true.</param>
        /// <param name="display">The instance of a display module to show the wifi connection state.  Can be null.  The display will not be controlled if the doNotControlLed delegate returns true.</param>
        /// <param name="serialPort">The serial port to use to receive wifi network credentials.  Can be null.</param>
        /// <param name="doNotManageWifi">A delegate specifying when NOT to manage wifi, e.g. allowing the program to stop wifi scanning and assocation for a time.  Can be null.</param>
        /// <param name="doNotControlScreen">A delegate specifying when NOT to control the screen (i.e. if your program wants to control the screen)</param>
        /// <param name="doNotControlLed">A delegate specifying when NOT to control the led (i.e. if your program wants to control the led)</param>
        /// <param name="enableWifiSetupNetworks">Enable wifi-based discovery using "setup" network</param>
        /// <param name="doUDPDiscovery">Listens and responds to UDP packets from HomeOS trying to discover this device, over both "setup" and home networks.  If this is off, the device will still beacon periodically over UDP.  Normally leave it on.</param>
        public HomeOSGadgeteerDevice(
            string manufacturer,
            string deviceTypeIdentifier,
            string setupWifiAuthCode,

            GTM.GHIElectronics.WiFi_RS21 wifi,
            GTM.GHIElectronics.MulticolorLed led = null,
            GTM.Module.DisplayModule display = null,
            string serialPort = null,
            BoolDelegate doNotManageWifi = null,
            BoolDelegate doNotControlScreen = null,
            BoolDelegate doNotControlLed = null,

            bool enableWifiSetupNetworks = true,
            bool doUDPDiscovery = true

            )
        {
            if (manufacturer == null) throw new ArgumentNullException("manufacturer");
            if (deviceTypeIdentifier == null) throw new ArgumentNullException("deviceTypeIdentifier");
            if (setupWifiAuthCode == null) throw new ArgumentNullException("setupAuthCode");
            if (wifi == null) throw new ArgumentNullException("wifi");
            this.wifi = wifi;
            this.led = led;
            this.display = display;
            if (display != null)
            {
                display.SimpleGraphics.AutoRedraw = false;
            }

            if (serialPort != null)
            {
                new Thread(() => SerialReadThread(serialPort)).Start();
            }

            this.SkipWifiTimer = doNotManageWifi ?? defaultFalse;
            this.DoNotControlScreen = doNotControlScreen ?? defaultFalse;
            this.DoNotControlLed = doNotControlLed ?? defaultFalse;

            this.DoUDPDiscovery = doUDPDiscovery;
            EnableWifiSetupNetworks = enableWifiSetupNetworks;
            this.SetupAuthCode = setupWifiAuthCode;
            this.TypeIdentifier = deviceTypeIdentifier;
            this.Manufacturer = manufacturer;

            wifi.Interface.NetworkInterface.EnableDhcp();
            wifi.Interface.WirelessConnectivityChanged += Interface_WirelessConnectivityChanged;
            wifi.Interface.NetworkAddressChanged += Interface_NetworkAddressChanged;

            if (!wifi.Interface.IsOpen)
                wifi.Interface.Open();
            NetworkInterfaceExtension.AssignNetworkingStackTo(wifi.Interface);


            Thread thread = new Thread(DiscoveryThread);
            thread.Start();

            LoadData();

            wifiTimer = new GT.Timer(WifiScanPeriod);
            wifiTimer.Tick += wifiTimer_Tick;
            wifiTimer.Start();

            WebServer.SetupWebEvent(webPath).WebEventReceived += new WebEvent.ReceivedWebEventHandler(CredentialsWebEventReceived);

            SetLed();
            SetScreen();

            GT.Program.BeginInvoke(new VoidDelegate(() => wifiTimer_Tick(wifiTimer)), null);
        }
Ejemplo n.º 45
0
 public bool PosInfoLockedCall(BoolDelegate func)
 {
     lock (m_posInfo)
         return func();
 }