Example #1
0
        //menu gösterilsin mi??**
        protected override bool CanShowMenu()
        {
            HelperSmartOp.LoadContextMenuBackup(ref cxtMenuStrip);

            // Firing Show Script
            _doLuaScript.DoShow(ref cxtMenuStrip, SelectedItemPaths);
            HelperSmartOp.BackupContextMenu(ref cxtMenuStrip);

            HelperSmartOp.PrepareContextMenuForRelease(ref cxtMenuStrip);
            // resume from here **
            CreateItemsClickEvent(cxtMenuStrip.Items);
            return(true);
        }
Example #2
0
        void Update()
        {
            string branchesPath = Path.Combine(System.IO.Path.GetDirectoryName(this.GetType().Assembly.Location), OgzContext.Resource1.strBranchFolderName);

            if (!Directory.Exists(branchesPath))
            {
                Directory.CreateDirectory(branchesPath);
            }
            string[] files = Directory.GetFiles(branchesPath, ("*" + Resource1.strBranchFileExt));

            DetachItemsClickEvents(cxtMenuStrip.Items);
            HelperSmartOp.UpdateContextMenuStrip(ref cxtMenuStrip, files);
            CreateItemsClickEvent(cxtMenuStrip.Items);
        }
Example #3
0
        void Load()
        {
            string branchesPath = Path.Combine(System.IO.Path.GetDirectoryName(this.GetType().Assembly.Location), OgzContext.Resource1.strBranchFolderName);

            if (!Directory.Exists(branchesPath))
            {
                Directory.CreateDirectory(branchesPath);
            }
            string[] files = Directory.GetFiles(branchesPath, ("*" + Resource1.strBranchFileExt));

            // Create Context Menu Strip
            cxtMenuStrip = HelperSmartOp.BranchFilesToContextMenuStrip(files);
            CreateItemsClickEvent(cxtMenuStrip.Items);

            startBranchFilesListener(branchesPath);//branch dosyalarındaki değişimleri takip et
        }
Example #4
0
        public static void UpdateContextMenuStrip(ref ContextMenuStrip cxtMenuStrip, string[] branchFiles)
        {
            cxtMenuStrip.Items.Clear();

            foreach (string file in branchFiles)
            {
                try
                {
                    // Read BranchMenu from JSON file
                    var branchMenu = HelperSmartOp.JSONToBranchMenu(file);
                    // Add new BranchMenu to ContextMenuStrip
                    AddBranchToContextMenuStrip(ref cxtMenuStrip, branchMenu);
                }
                catch { }
            }

            //RemoveAllItems(ref cxtMenuStrip);
        }
Example #5
0
        //BranchMenu yü ContextMenuStrip e dönüştür
        public static ContextMenuStrip BranchFilesToContextMenuStrip(string[] branchFiles)
        {
            ContextMenuStrip returnObj = new ContextMenuStrip();

            foreach (string file in branchFiles)
            {
                try
                {
                    // Read BranchMenu from JSON file
                    var branchMenu = HelperSmartOp.JSONToBranchMenu(file);

                    // Add new BranchMenu to ContextMenuStrip
                    AddBranchToContextMenuStrip(ref returnObj, branchMenu);
                }
                catch { }
            }

            return(returnObj);
        }
Example #6
0
        internal void DoShow(ref System.Windows.Forms.ContextMenuStrip cxtMenuStrip, IEnumerable <string> selectedPaths = null)
        {
            List <string> selectedItemPaths = new List <string>();;

            if (selectedPaths != null && selectedPaths.Count() > 0)
            {
                selectedItemPaths = selectedPaths.ToList();
            }

            var branchMenuList = HelperSmartOp.ToBranchMenuList(ref cxtMenuStrip);

            var  newBranchMenuList = new List <OgzShell.Branch.BranchMenu>();
            bool isAnyScriptRunned = false;

            foreach (var branchMenu in branchMenuList)
            {
                if (branchMenu.Script == null || !(branchMenu.Script is OgzShell.Branch.ContextLua) || string.IsNullOrWhiteSpace((branchMenu.Script as OgzShell.Branch.ContextLua).Show))
                {
                    newBranchMenuList.Add(branchMenu);
                    continue;
                }

                StringBuilder sbScript = new StringBuilder();

                #region Assign _SELECTEDPATHS
                //"_SELECTEDPATHS = {\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\"}
                sbScript.Append(_SELECTEDPATHS + " = {");
                int selItemsCount = selectedItemPaths.Count;
                for (int i = 0; i < selItemsCount; i++)
                {
                    sbScript.Append(string.Format(Resource1.strLuaStringFormat + ", ", selectedItemPaths[i]));
                    //sbScript.Append(string.Format("[[\"{0}\"]], ", selectedItemPaths[i]));//**__
                }
                sbScript.Append("}");
                //sbScript.Append(string.Format(Resource1.strLuaStringFormat + "}} ", selectedItemPaths[selItemsCount - 1]));
                //sbScript.Append(string.Format("[[\"{0}\"]]}}", selectedItemPaths[selItemsCount - 1]));
                #endregion

                #region Assign _MENU
                sbScript.AppendLine();//End Current Line
                //polyline = {color="blue", thickness=2, npoints=4, {x=13, y=4}, items={{x=-10, y=0}, {x=-10, y=1}}}
                sbScript.Append(_MENU + " = {");
                sbScript.Append(string.Format("CanShowMenu={0}, ", branchMenu.CanShowMenu.ToString().ToLower()));


                var _script = branchMenu.Script as OgzShell.Branch.ContextLua;
                sbScript.Append(string.Format("Script={{Show=" + Resource1.strLuaStringFormat + "}}, ", _script.Show));
                //sbScript.Append(string.Format("Script={{Show=\"{0}\"}}, ", _script.Show));
                // Script=
                // Remove first char '{' and append to sbScript
                sbScript.Append(GetIBranchLuaTableString(branchMenu).Remove(0, 1));

                #endregion

                sbScript.AppendLine();//end current line

                // Append user lua script
                sbScript.Append((branchMenu.Script as OgzShell.Branch.ContextLua).Show);

                //string finalScript = sbScript.ToString();
                //System.IO.File.WriteAllText(@"C:\OguzhanE\Projects\CSharp\WinForms\OgzShell\tst\luaScr.txt", finalScript);

                //Run Lua show script
                using (Lua lua = new Lua())
                {
                    lua.LoadCLRPackage();
                    lua.DoString(sbScript.ToString());

                    isAnyScriptRunned = true;
                    // Add 'New'(may be edit BranchMenu) BranchMenu to list
                    newBranchMenuList.Add(LuaTableToBranchMenu(lua.GetTable(_MENU)));
                }
            }

            if (isAnyScriptRunned && newBranchMenuList.Count > 0)
            {
                /// Apply Changes to ContextMenuStrip
                HelperSmartOp.UpdateContextMenuStrip(ref cxtMenuStrip, newBranchMenuList);
            }
        }