/// <summary>
 /// Add a custom button to the default set.
 /// </summary>
 public void Add(ToolbarDataItem newItem)
 {
     if (_customButtons == null)
     {
         _customButtons = new ArrayList();
     }
     _customButtons.Add(newItem);
 }
Example #2
0
        /// <summary>
        /// Handle mouse down over a button on the customisation panel.
        /// </summary>
        private void CustomizePanelOnMouseDown(object sender, MouseEventArgs mouseEventArgs)
        {
            CRRoundButton button = sender as CRRoundButton;

            if (button != null)
            {
                // Make a copy of the item being dragged.
                ToolbarDataItem item = (ToolbarDataItem)button.Tag;
                _draggedButton = new CRToolbarItem(item)
                {
                    Control = button
                };
                _hasDragItem = false;
                _dragSource  = null;
            }
        }
 /// <summary>
 /// Add a custom button to the default set.
 /// </summary>
 public void Add(ToolbarDataItem newItem)
 {
     if (_customButtons == null)
     {
         _customButtons = new ArrayList();
     }
     _customButtons.Add(newItem);
 }
Example #4
0
 /// <summary>
 /// Initialises a new instance of the <see cref="CRToolbarItem"/> class.
 /// </summary>
 /// <param name="item"></param>
 public CRToolbarItem(ToolbarDataItem item)
 {
     DataItem = item;
 }
Example #5
0
 /// <summary>
 /// Initialises a new instance of the <see cref="CRToolbarItem"/> class.
 /// </summary>
 /// <param name="item"></param>
 public CRToolbarItem(ToolbarDataItem item)
 {
     DataItem = item;
 }
Example #6
0
        /// <summary>
        /// Load a single script from the specified manifest.
        /// </summary>
        private void LoadSingleScript(string path, ScriptManifest manifest)
        {
            string scriptFile = Path.Combine(path, manifest.ScriptFile);

            NLua.Lua lua = new NLua.Lua();
            lua.LoadCLRPackage();
            _luaAPI.RegisterFunctions(lua);
            bool success = true;
            try
            {
                lua.DoFile(scriptFile);
                LuaFunction fnc = lua.GetFunction("on_load");
                if (fnc != null)
                {
                    object[] res = fnc.Call();
                    if (res != null && res.Length == 1)
                    {
                        success = Convert.ToBoolean(res[0]);
                    }
                }

                // Cache this script object for event callbacks if the
                // init function returns success.
                if (success)
                {
                    if (_scriptObjects.ContainsKey(scriptFile))
                    {
                        // BUGBUG: What if we have scripts that register events? We need to tell
                        // them to unregister first. Add an interface for this.
                        NLua.Lua oldScript = _scriptObjects[scriptFile];
                        oldScript.Dispose();

                        _scriptObjects.Remove(scriptFile);
                    }
                    _scriptObjects.Add(scriptFile, lua);
                }

                if (manifest.InstallToToolbar)
                {
                    ToolbarDataItem item = new ToolbarDataItem
                    {
                        type = "button",
                        name = "Script",
                        label = manifest.Name,
                        tooltip = manifest.Description,
                        data = scriptFile,
                        image = manifest.IconFile
                    };
                    CRToolbarItemCollection.DefaultCollection.Add(item);
                }
            }
            catch (Exception e)
            {
                LogFile.WriteLine("Error loading script {0} : {1}", scriptFile, e.Message);
                success = false;
            }
            if (success)
            {
                LogFile.WriteLine("Loaded and initialised script {0}", scriptFile);
            }
            else
            {
                lua.Dispose();
            }
        }