public bool GoToElement(int elementId)
        {
            try
            {
                var elem = Core.SM.Registry.Element[elementId];

                if (elem == null || elem.Deleted)
                {
                    return(false);
                }

                return(Core.Natives.ElWind.GoToElement(ElementWdwPtr.Read <IntPtr>(),
                                                       elementId));
            }
            catch (Win32Exception ex)
            {
                LogTo.Warning(ex, "Failed to read ElementWdwPtr");
                return(false);
            }
            catch (Exception ex)
            {
                LogTo.Error(ex, "SM internal method call threw an exception.");
                return(false);
            }
        }
        public bool GoToElement(int elementId)
        {
            bool ret = false;

            try
            {
                var elem = SMA.SMA.Instance.Registry.Element[elementId];

                if (elem == null || elem.Deleted)
                {
                    return(false);
                }

                /*ret = GoToMethod(ElementWdwPtr.Read<IntPtr>(),
                 *               elementId,
                 *               SMProcess.ThreadFactory.MainThread);*/

                ret = SMA.SMA.Instance.SMMgmt.ExecuteOnMainThread(NativeMethod.ElWdwGoToElement,
                                                                  ElementWdwPtr.Read <IntPtr>(),
                                                                  elementId) == 1;

                return(ret);
            }
            catch (Exception ex)
            {
                LogTo.Error(ex,
                            "SM internal method call threw an exception.");
                return(ret);
            }
        }
        public bool SetText(IControl control,
                            string text)
        {
            try
            {
                //SetTextMethod(ElementWdwPtr.Read<IntPtr>(),
                //              control.Id + 1,
                //              new DelphiUString(text));

                //return true;

                return(Core.Natives.ElWind.SetText(ElementWdwPtr.Read <IntPtr>(),
                                                   control,
                                                   text));
            }
            catch (Win32Exception ex)
            {
                LogTo.Warning(ex, "Failed to read ElementWdwPtr");
                return(false);
            }
            catch (Exception ex)
            {
                LogTo.Error(ex, "SM internal method call threw an exception.");
                return(false);
            }
        }
Esempio n. 4
0
        private bool OnWindowCreated(byte[] newVal)
        {
            if (ElementWdwPtr.Read <int>() == 0)
            {
                return(false);
            }

            ElementIdPtr             = SMProcess[Core.Natives.ElWind.ElementIdPtr];
            LimitChildrenCountPtr    = SMProcess[Core.Natives.Globals.LimitChildrenCountPtr];
            CurrentConceptIdPtr      = SMProcess[Core.Natives.Globals.CurrentConceptIdPtr];
            CurrentConceptGroupIdPtr = SMProcess[Core.Natives.Globals.CurrentConceptGroupIdPtr];
            CurrentRootIdPtr         = SMProcess[Core.Natives.Globals.CurrentRootIdPtr];
            CurrentHookIdPtr         = SMProcess[Core.Natives.Globals.CurrentHookIdPtr];
            LearningModePtr          = SMProcess[Core.Natives.ElWind.LearningModePtr];

            ElementIdPtr.RegisterValueChangedEventHandler <int>(OnElementChangedInternal);

            LastElementId = CurrentElementId;

            // TODO: ??? This somehow gets delayed and causes all sorts of troubles
            //OnElementChanged?.Invoke(new SMDisplayedElementChangedEventArgs(SMA.Instance,
            //                                                   CurrentElement,
            //                                                   null));

            IsAvailable = true;

            OnAvailableInternal?.Invoke();

            OnAvailable?.InvokeRemote(
                nameof(OnAvailable),
                h => OnAvailable -= h
                );

            return(true);
        }
        private bool OnWindowCreated(byte[] newVal)
        {
            if (ElementWdwPtr.Read <int>() == 0)
            {
                return(false);
            }

            ElementIdPtr        = SMProcess[SM17Natives.TElWind.ElementIdPtr];
            CurrentConceptIdPtr = SMProcess[SM17Natives.Globals.CurrentConceptIdPtr];
            CurrentRootIdPtr    = SMProcess[SM17Natives.Globals.CurrentRootIdPtr];
            CurrentHookIdPtr    = SMProcess[SM17Natives.Globals.CurrentHookIdPtr];

            ElementIdPtr.RegisterValueChangedEventHandler <int>(OnElementChangedInternal);

            LastElementId = CurrentElementId;

            // TODO: ??? This somehow gets delayed and causes all sorts of troubles
            //OnElementChanged?.Invoke(new SMDisplayedElementChangedArgs(SMA.Instance,
            //                                                   CurrentElement,
            //                                                   null));

            OnAvailable?.Invoke();

            return(true);
        }
Esempio n. 6
0
        public bool ApplyTemplate(int templateId, TemplateUseMode applyMode = TemplateUseMode.Apply)
        {
            var template = Core.SM.Registry.Template[templateId];

            if (template == null || template.Empty)
            {
                return(false);
            }

            return(Core.Natives.ElWind.ApplyTemplate(ElementWdwPtr.Read <IntPtr>(), templateId, applyMode));
        }
 public int GenerateCloze(bool memorize = true, bool askUserToScheduleInterval = false)
 {
     try
     {
         return(Core.Natives.ElWind.GenerateCloze(
                    ElementWdwPtr.Read <IntPtr>(),
                    memorize,
                    askUserToScheduleInterval));
     }
     catch (Exception ex)
     {
         LogTo.Error(ex, "Native method call threw an exception.");
         return(-1);
     }
 }
        public bool NextElementInLearningQueue()
        {
            try
            {
                SMA.SMA.Instance.SMMgmt.ExecuteOnMainThread(NativeMethod.ElWdwNextElementInLearningQueue,
                                                            ElementWdwPtr.Read <IntPtr>());

                return(true);
            }
            catch (Exception ex)
            {
                LogTo.Error(ex,
                            "SM internal method call threw an exception.");
                return(false);
            }
        }
        public bool PostponeRepetition(int interval)
        {
            try
            {
                SMA.SMA.Instance.SMMgmt.ExecuteOnMainThread(NativeMethod.PostponeRepetition,
                                                            ElementWdwPtr.Read <IntPtr>(),
                                                            interval);

                return(true);
            }
            catch (Exception ex)
            {
                LogTo.Error(ex,
                            "SM internal method call threw an exception.");
                return(false);
            }
        }
Esempio n. 10
0
        public bool SetElementState(int state)
        {
            try
            {
                SMA.SMA.Instance.SMMgmt.ExecuteOnMainThread(NativeMethod.ElWdwSetElementState,
                                                            ElementWdwPtr.Read <IntPtr>(),
                                                            state);

                return(true);
            }
            catch (Exception ex)
            {
                LogTo.Error(ex,
                            "SM internal method call threw an exception.");
                return(false);
            }
        }
Esempio n. 11
0
        public bool Done()
        {
            try
            {
                //return DoneMethod(ElementWdwPtr.Read<IntPtr>(),
                //                  SMProcess.ThreadFactory.MainThread);

                return(SMA.SMA.Instance.SMMgmt.ExecuteOnMainThread(NativeMethod.ElWdwDone,
                                                                   ElementWdwPtr.Read <IntPtr>()) == 1);
            }
            catch (Exception ex)
            {
                LogTo.Error(ex,
                            "SM internal method call threw an exception.");
                return(false);
            }
        }
Esempio n. 12
0
 public bool NextElementInLearningQueue()
 {
     try
     {
         return(Core.Natives.ElWind.ShowNextElementInLearningQueue(ElementWdwPtr.Read <IntPtr>()));
     }
     catch (Win32Exception ex)
     {
         LogTo.Warning(ex, "Failed to read ElementWdwPtr");
         return(false);
     }
     catch (Exception ex)
     {
         LogTo.Error(ex, "SM internal method call threw an exception.");
         return(false);
     }
 }
Esempio n. 13
0
 public int AppendAndAddElementFromText(ElementType elementType,
                                        string elementDesc)
 {
     try
     {
         return(SMA.SMA.Instance.SMMgmt.ExecuteOnMainThread(NativeMethod.AppendAndAddElementFromText,
                                                            ElementWdwPtr.Read <IntPtr>(),
                                                            (byte)elementType,
                                                            new DelphiUString(elementDesc)));
     }
     catch (Exception ex)
     {
         LogTo.Error(ex,
                     "SM internal method call threw an exception.");
         return(-1);
     }
 }
Esempio n. 14
0
 public bool SetElementState(ElementDisplayState state)
 {
     try
     {
         return(Core.Natives.ElWind.SetElementState(ElementWdwPtr.Read <IntPtr>(), state));
     }
     catch (Win32Exception ex)
     {
         LogTo.Warning(ex, "Failed to read ElementWdwPtr");
         return(false);
     }
     catch (Exception ex)
     {
         LogTo.Error(ex, "SM internal method call threw an exception.");
         return(false);
     }
 }
 public bool AddElementFromText(string elementDesc)
 {
     try
     {
         return(Core.Natives.ElWind.AddElementFromText(ElementWdwPtr.Read <IntPtr>(),
                                                       elementDesc));
     }
     catch (Win32Exception ex)
     {
         LogTo.Warning(ex, "Failed to read ElementWdwPtr");
         return(false);
     }
     catch (Exception ex)
     {
         LogTo.Error(ex, "SM internal method call threw an exception.");
         return(false);
     }
 }
Esempio n. 16
0
 public string GetText(IControl control)
 {
     try
     {
         return(Core.Natives.ElWind.GetText(ElementWdwPtr.Read <IntPtr>(),
                                            control));
     }
     catch (Win32Exception ex)
     {
         LogTo.Warning(ex, "Failed to read ElementWdwPtr");
         return(null);
     }
     catch (Exception ex)
     {
         LogTo.Error(ex, "SM internal method call threw an exception.");
         return(null);
     }
 }
Esempio n. 17
0
 public int AppendElement(ElementType elementType)
 {
     try
     {
         return(Core.Natives.ElWind.AppendElement(ElementWdwPtr.Read <IntPtr>(),
                                                  elementType));
     }
     catch (Win32Exception ex)
     {
         LogTo.Warning(ex, "Failed to read ElementWdwPtr");
         return(-1);
     }
     catch (Exception ex)
     {
         LogTo.Error(ex, "SM internal method call threw an exception.");
         return(-1);
     }
 }
Esempio n. 18
0
        public bool QuitSMUpdateLock()
        {
            try
            {
                SM17Natives.Instance.ElWind.QuitUpdateLock.Invoke(
                    ElementWdwPtr.Read <IntPtr>(),
                    true
                    );

                return(true);
            }
            catch (Exception ex)
            {
                LogTo.Error(ex,
                            "SM internal method call threw an exception.");
                return(false);
            }
        }
Esempio n. 19
0
 public bool PostponeRepetition(int interval)
 {
     try
     {
         return(Core.Natives.ElWind.PostponeRepetition(ElementWdwPtr.Read <IntPtr>(),
                                                       interval));
     }
     catch (Win32Exception ex)
     {
         LogTo.Warning(ex, "Failed to read ElementWdwPtr");
         return(false);
     }
     catch (Exception ex)
     {
         LogTo.Error(ex, "SM internal method call threw an exception.");
         return(false);
     }
 }
Esempio n. 20
0
        public bool ForceRepetitionAndResume(int interval,
                                             bool adjustPriority)
        {
            try
            {
                SMA.SMA.Instance.SMMgmt.ExecuteOnMainThread(NativeMethod.ForceRepetitionAndResume,
                                                            ElementWdwPtr.Read <IntPtr>(),
                                                            interval,
                                                            adjustPriority);

                return(true);
            }
            catch (Exception ex)
            {
                LogTo.Error(ex,
                            "SM internal method call threw an exception.");
                return(false);
            }
        }
Esempio n. 21
0
        public bool AddElementFromText(string elementDesc)
        {
            try
            {
                //return AddElementFromTextFunc(ElementWdwPtr.Read<IntPtr>(),
                //                              new DelphiUString(elementDesc),
                //                              SMProcess.ThreadFactory.MainThread) > 0;

                return(SMA.SMA.Instance.SMMgmt.ExecuteOnMainThread(NativeMethod.ElWdwAddElementFromText,
                                                                   ElementWdwPtr.Read <IntPtr>(),
                                                                   new DelphiUString(elementDesc)) > 0);
            }
            catch (Exception ex)
            {
                LogTo.Error(ex,
                            "SM internal method call threw an exception.");
                return(false);
            }
        }
Esempio n. 22
0
        public bool QuitSMUpdateLock()
        {
            try
            {
                Core.Natives.ElWind.QuitUpdateLock.Invoke(ElementWdwPtr.Read <IntPtr>(),
                                                          true);

                return(true);
            }
            catch (Win32Exception ex)
            {
                LogTo.Warning(ex, "Failed to read ElementWdwPtr");
                return(false);
            }
            catch (Exception ex)
            {
                LogTo.Error(ex, "SM internal method call threw an exception.");
                return(false);
            }
        }
Esempio n. 23
0
 public bool ForceRepetition(int interval,
                             bool adjustPriority)
 {
     try
     {
         return(Core.Natives.ElWind.ForceRepetitionExt(ElementWdwPtr.Read <IntPtr>(),
                                                       interval,
                                                       adjustPriority));
     }
     catch (Win32Exception ex)
     {
         LogTo.Warning(ex, "Failed to read ElementWdwPtr");
         return(false);
     }
     catch (Exception ex)
     {
         LogTo.Error(ex, "SM internal method call threw an exception.");
         return(false);
     }
 }
Esempio n. 24
0
        public int AppendElement(ElementType elementType)
        {
            try
            {
                //return AppendElementFunc(ElementWdwPtr.Read<IntPtr>(),
                //                         (byte)elementType,
                //                         0, // ??
                //                         SMProcess.ThreadFactory.MainThread);

                return(SMA.SMA.Instance.SMMgmt.ExecuteOnMainThread(NativeMethod.ElWdwAppendElement,
                                                                   ElementWdwPtr.Read <IntPtr>(),
                                                                   (byte)elementType,
                                                                   0 /* ?? */));
            }
            catch (Exception ex)
            {
                LogTo.Error(ex,
                            "SM internal method call threw an exception.");
                return(-1);
            }
        }
Esempio n. 25
0
        public bool SetText(IControl control,
                            string text)
        {
            try
            {
                //SetTextMethod(ElementWdwPtr.Read<IntPtr>(),
                //              control.Id + 1,
                //              new DelphiUString(text));

                //return true;

                return(SMA.SMA.Instance.SMMgmt.ExecuteOnMainThread(NativeMethod.ElWdwSetText,
                                                                   ElementWdwPtr.Read <IntPtr>(),
                                                                   control.Id + 1,
                                                                   new DelphiUString(text)) == 1);
            }
            catch (Exception ex)
            {
                LogTo.Error(ex,
                            "SM internal method call threw an exception.");
                return(false);
            }
        }