/// <summary>
        /// Called from context menu of Solution Explorer, processes given list of ProjectItems
        /// </summary>
        /// <param name="selectedItems">Items selected in Solution Explorer - to be searched</param>
        /// <param name="verbose">True if processing info should be printed to the output</param>
        public override void Process(Array selectedItems, bool verbose)
        {
            if (verbose)
            {
                VLOutputWindow.VisualLocalizerPane.WriteLine("Batch Move to Resources command started on selected items from Solution Explorer");
            }
            if (verbose)
            {
                ProgressBarHandler.StartIndeterminate(Microsoft.VisualStudio.Shell.Interop.Constants.SBAI_Find);
            }

            try {
                Results = new List <CodeStringResultItem>();

                base.Process(selectedItems, verbose);

                // remove empty strings
                Results.RemoveAll((item) => { return(item.Value.Trim().Length == 0); });

                // set each source file as readonly
                Results.ForEach((item) => {
                    VLDocumentViewsManager.SetFileReadonly(item.SourceItem.GetFullPath(), true);
                });
            } finally {
                if (verbose)
                {
                    ProgressBarHandler.StopIndeterminate(Microsoft.VisualStudio.Shell.Interop.Constants.SBAI_Find);
                }
            }

            if (verbose)
            {
                VLOutputWindow.VisualLocalizerPane.WriteLine("Batch Move to Resources completed - found {0} items to be moved", Results.Count);
            }
        }
Example #2
0
 void Start()
 {
     soundManager = FindObjectOfType <SoundManager>();
     matchHandler = FindObjectOfType <MatchHandler>();
     scoreManager = FindObjectOfType <ScoreManager>();
     progressBar  = FindObjectOfType <ProgressBarHandler>();
     allGems      = new GameObject[width, height];
     FillBoard();
 }
Example #3
0
 // Start is called before the first frame update
 void Start()
 {
     player         = Player.instance;
     multi          = Multiplier.instance;
     autoclicker    = Autoclicker.instance;
     progressBar    = ProgressBarHandler.instance;
     rectTransform  = GetComponent <RectTransform>();
     tooltipText    = transform.GetChild(0).GetComponent <Text>();
     upgradeHandler = UpgradeHandler.instance;
 }
Example #4
0
	public void SetReferences () {
        player = Player.instance;
        multi = Multiplier.instance;
        autoclicker = Autoclicker.instance;
        progressBar = ProgressBarHandler.instance;
        upgradeHandler = UpgradeHandler.instance;
        clicker = Clicker.instance;
        purchaseHandler = PurchaseHandler.instance;
        numberFormatter = NumberFormatter.instance;
        tooltip = Tooltip.instance;
        image = GetComponent<Image>();
	}
Example #5
0
 public void Show(ProgressBar bar, int i)
 {
     if (bar.InvokeRequired)
     {
         ProgressBarHandler obj = new ProgressBarHandler(Show);
         bar.Invoke(obj, bar, i);
     }
     else
     {
         bar.Value = i;
     }
 }
        /// <summary>
        /// Uses given translation provider and source and target languages to translate data
        /// </summary>
        public static void Translate(List <AbstractTranslateInfoItem> dict, TRANSLATE_PROVIDER provider, string from, string to)
        {
            AbstractTranslatorService service = null;

            // get translation service
            switch (provider)
            {
            case TRANSLATE_PROVIDER.BING:
                service = BingTranslator.GetService(SettingsObject.Instance.BingAppId);
                break;

            case TRANSLATE_PROVIDER.MYMEMORY:
                service = MyMemoryTranslator.GetService();
                break;

            case TRANSLATE_PROVIDER.GOOGLE:
                service = GoogleTranslator.GetService();
                break;
            }
            if (service == null)
            {
                throw new Exception("Cannot resolve translation provider!");
            }
            else
            {
                try {
                    ProgressBarHandler.StartDeterminate(dict.Count, "Translating...");

                    int completed = 0;
                    // use the service to translate texts
                    foreach (AbstractTranslateInfoItem item in dict)
                    {
                        string oldValue = item.Value;
                        item.Value = service.Translate(from, to, oldValue, SettingsObject.Instance.OptimizeSpecialSequencesInTranslation);
                        completed++;

                        VLOutputWindow.VisualLocalizerPane.WriteLine("Translated \"{0}\" as \"{1}\" ", oldValue, item.Value);
                        ProgressBarHandler.SetDeterminateProgress(completed, "Translating...");
                    }
                } finally {
                    ProgressBarHandler.StopDeterminate("Translation finished", "Ready");
                }
            }
        }
        /// <summary>
        /// Called from context menu of a code file, processes selected block of code
        /// </summary>
        /// <param name="verbose">True if processing info should be printed to the output</param>
        public override void ProcessSelection(bool verbose)
        {
            base.ProcessSelection(verbose);

            if (verbose)
            {
                VLOutputWindow.VisualLocalizerPane.WriteLine("Batch Inline command started on text selection of active document ");
            }
            if (verbose)
            {
                ProgressBarHandler.StartIndeterminate(Microsoft.VisualStudio.Shell.Interop.Constants.SBAI_Find);
            }

            try {
                Results = new List <CodeReferenceResultItem>();

                Process(currentlyProcessedItem, IntersectsWithSelection, verbose);

                // remove items laying outside the selection
                Results.RemoveAll((item) => {
                    return(IsItemOutsideSelection(item));
                });

                // set each source file as readonly
                Results.ForEach((item) => {
                    VLDocumentViewsManager.SetFileReadonly(item.SourceItem.GetFullPath(), true);
                });
            } finally {
                // clear cached data
                trieCache.Clear();
                trieCache.Clear();
                codeUsingsCache.Clear();

                if (verbose)
                {
                    ProgressBarHandler.StopIndeterminate(Microsoft.VisualStudio.Shell.Interop.Constants.SBAI_Find);
                }
            }
            if (verbose)
            {
                VLOutputWindow.VisualLocalizerPane.WriteLine("Found {0} items to be moved", Results.Count);
            }
        }
        /// <summary>
        /// Called from context menu of a code file, processes selected block of code
        /// </summary>
        /// <param name="verbose">True if processing info should be printed to the output</param>
        public override void ProcessSelection(bool verbose)
        {
            base.ProcessSelection(verbose); // initialize class variables

            if (verbose)
            {
                VLOutputWindow.VisualLocalizerPane.WriteLine("Batch Move to Resources command started on text selection of active document ");
            }
            if (verbose)
            {
                ProgressBarHandler.StartIndeterminate(Microsoft.VisualStudio.Shell.Interop.Constants.SBAI_Find);
            }

            try {
                Results = new List <CodeStringResultItem>();

                Process(currentlyProcessedItem, IntersectsWithSelection, verbose); // process active document, leaving only those items that have non-empty intersection with the selection

                // remove empty strings and result items laying outside the selection
                Results.RemoveAll((item) => {
                    bool empty = item.Value.Trim().Length == 0;
                    return(empty || IsItemOutsideSelection(item));
                });

                // set each source file as readonly
                Results.ForEach((item) => {
                    VLDocumentViewsManager.SetFileReadonly(item.SourceItem.GetFullPath(), true);
                });
            } finally {
                if (verbose)
                {
                    ProgressBarHandler.StopIndeterminate(Microsoft.VisualStudio.Shell.Interop.Constants.SBAI_Find);
                }
            }

            if (verbose)
            {
                VLOutputWindow.VisualLocalizerPane.WriteLine("Found {0} items to be moved", Results.Count);
            }
        }
        /// <summary>
        /// Called from context menu of a code file, processes current document
        /// </summary>
        /// <param name="verbose">True if processing info should be printed to the output</param>
        public override void Process(bool verbose)
        {
            base.Process(verbose); // initialize class variables

            if (verbose)
            {
                VLOutputWindow.VisualLocalizerPane.WriteLine("Batch Inline command started on active document... ");
            }
            if (verbose)
            {
                ProgressBarHandler.StartIndeterminate(Microsoft.VisualStudio.Shell.Interop.Constants.SBAI_Find);
            }

            try {
                Results = new List <CodeReferenceResultItem>();

                Process(currentlyProcessedItem, verbose);

                // set each source file as readonly
                Results.ForEach((item) => {
                    VLDocumentViewsManager.SetFileReadonly(item.SourceItem.GetFullPath(), true);
                });
            } finally {
                // clear cached data
                trieCache.Clear();
                codeUsingsCache.Clear();

                if (verbose)
                {
                    ProgressBarHandler.StopIndeterminate(Microsoft.VisualStudio.Shell.Interop.Constants.SBAI_Find);
                }
            }
            if (verbose)
            {
                VLOutputWindow.VisualLocalizerPane.WriteLine("Found {0} items to be moved", Results.Count);
            }
        }
        /// <summary>
        /// Called from context menu of a code file, processes current document
        /// </summary>
        /// <param name="verbose">True if processing info should be printed to the output</param>
        public override void Process(bool verbose)
        {
            base.Process(verbose); // initialize class variables

            if (verbose)
            {
                VLOutputWindow.VisualLocalizerPane.WriteLine("Batch Move to Resources command started on active document... ");
            }
            if (verbose)
            {
                ProgressBarHandler.StartIndeterminate(Microsoft.VisualStudio.Shell.Interop.Constants.SBAI_Find);
            }

            try {
                Results = new List <CodeStringResultItem>();

                Process(currentlyProcessedItem, verbose);                                // process active document

                Results.RemoveAll((item) => { return(item.Value.Trim().Length == 0); }); // remove empty strings

                // set each source file as readonly
                Results.ForEach((item) => {
                    VLDocumentViewsManager.SetFileReadonly(item.SourceItem.GetFullPath(), true);
                });
            } finally {
                if (verbose)
                {
                    ProgressBarHandler.StopIndeterminate(Microsoft.VisualStudio.Shell.Interop.Constants.SBAI_Find);
                }
            }

            if (verbose)
            {
                VLOutputWindow.VisualLocalizerPane.WriteLine("Found {0} items to be moved", Results.Count);
            }
        }
Example #11
0
 double GetNativeProgress(ProgressBarHandler progressBarHandler) =>
 GetNativeProgressBar(progressBarHandler).Progress;
Example #12
0
 double GetNativeProgress(ProgressBarHandler progressBarHandler) =>
 (double)GetNativeProgressBar(progressBarHandler).Progress / ProgressBarExtensions.Maximum;
Example #13
0
 AProgressBar GetNativeProgressBar(ProgressBarHandler progressBarHandler) =>
 progressBarHandler.PlatformView;
Example #14
0
 public static void MapProgress(ProgressBarHandler handler, IProgress progress)
 {
     handler.TypedNativeView?.UpdateProgress(progress);
 }
 AProgressBar GetNativeProgressBar(ProgressBarHandler progressBarHandler) =>
 (AProgressBar)progressBarHandler.View;
 private void Awake()
 {
     instance = this;
 }
Example #17
0
 public WebViewClientClass(ProgressBarHandler handler)
 {
     this.handler = handler;
 }
Example #18
0
 UIProgressView GetNativeProgressBar(ProgressBarHandler progressBarHandler) =>
 progressBarHandler.NativeView;
Example #19
0
 UIProgressView GetNativeProgressBar(ProgressBarHandler progressBarHandler) =>
 (UIProgressView)progressBarHandler.View;
        /// <summary>
        /// Starts the command, taking array of selected project items as a parameter
        /// </summary>
        public void Process(Array array)
        {
            try {
                searchedProjectItems.Clear();
                loadedResxItems.Clear();

                // find all ResX files contained within selected project items
                List <GlobalTranslateProjectItem> resxFiles = new List <GlobalTranslateProjectItem>();
                foreach (UIHierarchyItem o in array)
                {
                    if (o.Object is ProjectItem)
                    {
                        ProjectItem item = (ProjectItem)o.Object;
                        SearchForResxFiles(item, resxFiles);
                    }
                    else if (o.Object is Project)
                    {
                        Project proj = (Project)o.Object;
                        SearchForResxFiles(proj.ProjectItems, resxFiles);
                    }
                    else if (o.Object is Solution)
                    {
                        Solution s = (Solution)o.Object;
                        SearchForResxFiles(s.Projects, resxFiles);
                    }
                    else
                    {
                        throw new Exception("Unexpected project item type: " + o.Object.GetVisualBasicType());
                    }
                }

                // display form, allowing user to choose source and target language and select ResX files, where translation should be performed
                GlobalTranslateForm form = new GlobalTranslateForm(resxFiles);
                if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    List <AbstractTranslateInfoItem> data = new List <AbstractTranslateInfoItem>();
                    try {
                        // collect string data from checked ResX files
                        ProgressBarHandler.StartIndeterminate(Microsoft.VisualStudio.Shell.Interop.Constants.SBAI_Find);
                        foreach (GlobalTranslateProjectItem item in resxFiles)
                        {
                            if (item.Checked)
                            {
                                AddDataForTranslation(item, data);
                            }
                        }
                        ProgressBarHandler.StopIndeterminate(Microsoft.VisualStudio.Shell.Interop.Constants.SBAI_Find);

                        // translate collected data using given language pair
                        TranslationHandler.Translate(data, form.Provider, form.LanguagePair.FromLanguage, form.LanguagePair.ToLanguage);

                        // replace original texts with the translated ones
                        ProgressBarHandler.StartIndeterminate(Microsoft.VisualStudio.Shell.Interop.Constants.SBAI_Find);
                        foreach (AbstractTranslateInfoItem i in data)
                        {
                            i.ApplyTranslation();
                        }
                    } finally {
                        // unloads all ResX files that were originally closed
                        foreach (ResXProjectItem item in loadedResxItems)
                        {
                            item.Flush();
                            item.Unload();
                        }
                        ProgressBarHandler.StopIndeterminate(Microsoft.VisualStudio.Shell.Interop.Constants.SBAI_Find);
                    }
                }
            } finally {
                MenuManager.OperationInProgress = false;
            }
        }