Ejemplo n.º 1
0
        private void LoadScripts()
        {
            //load all the scripts into the Script Object
            scriptObject.Reset();

            ScriptClass sc = new ScriptClass();

            sc.ParseCommand           += new SendCommandDelegate(Script_ParseCommand);
            sc.ParseCommandCurrent    += new SendCommandCurrentDelegate(Script_ParseCommandCurrent);
            sc.ParseIdentifier        += new ParseIdentifierDelegate(Script_ParseIdentifier);
            sc.ParseIdentifierCurrent += new ParseIdentifierCurrentDelegate(Script_ParseIdentifierCurrent);
            sc.GetIni       += new GetIniDelegate(Script_GetIni);
            sc.WriteIni     += new WriteIniDelegate(Script_WriteIni);
            sc.CheckIsOp    += new IsOpDelegate(Script_CheckIsOp);
            sc.CheckIsVoice += new IsVoiceDelegate(Script_CheckIsVoice);

            sc.RunScript     += new RunScriptDelegate(Script_RunScript);
            sc.GetDataFolder += new GetDataFolderDelegate(Script_GetDataFolder);

            scriptObject.AddObject("irc", (object)sc, true);
            scriptObject.AllowUI = true;
            scriptObject.State   = ScriptControlStates.Connected;

            //read in all the loaded script files
            if (File.Exists(scriptSettingsFile))
            {
                XmlSerializer deserializer = new XmlSerializer(typeof(IceChatVBScripts));
                TextReader    textReader   = new StreamReader(scriptSettingsFile);
                icechatVBScripts = (IceChatVBScripts)deserializer.Deserialize(textReader);
                textReader.Close();
                textReader.Dispose();
            }
            else
            {
                icechatVBScripts = new IceChatVBScripts();
            }



            foreach (String file in icechatVBScripts.listScripts)
            {
                if (File.Exists(this.CurrentFolder + Path.DirectorySeparatorChar + "Scripts" + Path.DirectorySeparatorChar + file))
                {
                    //System.Diagnostics.Debug.WriteLine("loading script file into engine: " + file);

                    StreamReader sr = new StreamReader(this.CurrentFolder + Path.DirectorySeparatorChar + "Scripts" + Path.DirectorySeparatorChar + file);
                    //add the script file into its own module
                    object o = new object();
                    Module m = scriptObject.Modules.Add(file, ref o);
                    m.AddCode(sr.ReadToEnd());

                    sr.Close();
                }
            }
        }
Ejemplo n.º 2
0
 public bool Compile(WScript wscript, Script script = null)
 {
     _wscript = wscript;
     if (_script != null)
     {
         _compiler.Reset();
     }
     _script = script;
     _compiler.AddObject("WScript", wscript, true);
     _compiler.AddCode("Function IIf(Expression, TruePart, FalsePart)\r\nIf Expression Then IIf = truepart Else IIf = falsepart\r\nEnd Function\r\n");
     if (script != null)
     {
         return(AddCode(script.GetCode()));
     }
     return(true);
 }
Ejemplo n.º 3
0
        public static void JsRun()
        {
            ScriptControlClass sc = new ScriptControlClass();

            sc.UseSafeSubset = true;
            sc.Language      = "JavaScript";

            var jsStrText = @"function add(name){
nameList.Push(one);
    return one;
}";

            var ddd = new object[] { "张三", "李四" };

            sc.AddCode(jsStrText);
            sc.AddObject("nameList", ddd, false);

            string str = sc.Run("add", new object[] { "dsds" }).ToString();
        }
        public static void Run(string filePath)
        {
            ScriptControlClass scripter = new ScriptControlClass();

            try {
                scripter.Language      = "VBScript";
                scripter.AllowUI       = false;
                scripter.UseSafeSubset = true;
                IAssert assert = new NunitAssert();
                scripter.AddObject("Assert", assert, false);

                string code = File.ReadAllText(filePath);
                scripter.AddCode(code);
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(scripter);
                scripter = null;
            }
        }
Ejemplo n.º 5
0
        public MainScreen()
        {
            /*
             * string[] args = Environment.GetCommandLineArgs();
             * if ( args.Length > 1 )
             * {
             * MessageBox.Show(args[1]);
             * this.Close();
             * return;
             * }
             * */



            this.displayQue = new List <IDisplayItem>();

            m_autoConnecting = false;
            m_pauseMsgs      = false;
            m_clipBoardData  = "";

            Device.Instance.BluetoothConnectEvent    += new BluetoothConnectEventHandler(OnBlackBerryConnectEvent);
            Device.Instance.BluetoothDisconnectEvent += new BluetoothDisconnectEventHandler(OnBlackBerryDisconnectEvent);
            Device.Instance.MsgArrivedEvent          += new MsgArrivedEventHandler(Instance_MsgArrivedEvent);

            m_toolbar = new Toolbar();
            Boolean toolBarVisable = ApplicationSettings.Instance.ToolBar.Visable;

            m_toolbar.showToolbar();
            if (!toolBarVisable)
            {
                m_toolbar.hideToolbar();
            }
            m_scriptControl = null;

            if (ApplicationSettings.Instance.EnableScript)
            {
                try
                {
                    m_scriptControl = new ScriptControlClass();
                    if (m_scriptControl != null)
                    {
                        m_scriptControl.Language = ApplicationSettings.Instance.ScriptLanguage;
                        m_scriptControl.AddObject("AlertWindow", this, true);
                        m_scriptControl.AddObject("BlackBerry", Device.Instance, true);
                    }
                    else
                    {
                        MessageBox.Show("Microsoft Scripting control is not installed.", "Blurts", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Microsoft Scripting control is not installed.", "Blurts", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            // setup file extension support

            /*
             * Registry.ClassesRoot.CreateSubKey(".blurts").SetValue("", "Blurts", Microsoft.Win32.RegistryValueKind.String);
             * Registry.ClassesRoot.CreateSubKey(@"Blurts\shell\open\command").SetValue("", Application.ExecutablePath + " \"%l\" ", Microsoft.Win32.RegistryValueKind.String);
             */



            if (!Directory.Exists(ApplicationSettings.Instance.LocalDataPath + @"\SMS"))
            {
                Directory.CreateDirectory(ApplicationSettings.Instance.LocalDataPath + @"\SMS");
            }

            HotKeysManager.Instance.SetHotKeys();



            InitializeComponent();


            //
            // signal
            //
            this.signal           = new SignalLevelCtrl();
            this.signal.BackColor = System.Drawing.Color.Transparent;
            this.signal.Location  = new System.Drawing.Point(440, 14);
            this.signal.Name      = "signal";
            this.signal.Size      = new System.Drawing.Size(35, 14);
            this.signal.TabIndex  = 9;
            this.signal.TabStop   = false;
            this.Controls.Add(this.signal);

            //
            // battery
            //
            this.battery           = new BatteryLevelCtrl();
            this.battery.BackColor = System.Drawing.Color.Transparent;
            this.battery.Location  = new System.Drawing.Point(436, 34);
            this.battery.Name      = "battery";
            this.battery.Size      = new System.Drawing.Size(43, 14);
            this.battery.TabIndex  = 8;
            this.battery.TabStop   = false;
            this.Controls.Add(this.battery);

            MainScreen_Resize(null, null);


            notifyIcon.Text = Application.ProductName + " - MLH Software";
        }