private void ExecuteOrganizeWORegions(ExecuteEventArgs ea)
 {
     ClassOrganizer organizer = new ClassOrganizer();
     organizer.Organize(CodeRush.Documents.ActiveTextDocument,
                              CodeRush.Source.ActiveType,
                              false);
 }
Ejemplo n.º 2
0
        void _buttonDropB_ExecuteEvent(object sender, ExecuteEventArgs e)
        {
            List <int> supportedImageSizes = new List <int>()
            {
                32, 48, 64
            };

            Bitmap        bitmap;
            StringBuilder bitmapFileName = new StringBuilder();

            int selectedImageSize;

            if (supportedImageSizes.Contains(SystemInformation.IconSize.Width))
            {
                selectedImageSize = SystemInformation.IconSize.Width;
            }
            else
            {
                selectedImageSize = 32;
            }

            exitOn = !exitOn;
            string exitStatus = exitOn ? "on" : "off";

            bitmapFileName.AppendFormat(@"..\..\Res\Exit{0}{1}.bmp", exitStatus, selectedImageSize);

            bitmap = new System.Drawing.Bitmap(bitmapFileName.ToString());
            bitmap.MakeTransparent();

            _buttonDropB.LargeImage = _ribbon.ConvertToUIImage(bitmap);
        }
Ejemplo n.º 3
0
        private void actReSharperChangeSignature_Execute(ExecuteEventArgs ea)
        {
            bool      allowPersistResponse = false;
            string    title     = "Change Signature";
            string    message   = "CodeRush includes several useful refactorings dedicated to changing signatures. Select from one of the signature-changing refactorings below.";
            Redirects redirects = new Redirects();

            redirects.AddRefactoring("Add Parameter", "Place caret inside the parameter list before invoking.");
            redirects.AddRefactoring("Create Overload", "Place caret on the member declaration before invoking.");
            redirects.AddRefactoring("Decompose Parameter", "Place caret on the parameter to decompose before invoking.");
            redirects.AddRefactoring("Introduce Parameter Object", "Select the parameters to consolidate before invoking.");
            redirects.AddRefactoring("Make Extension", "Place caret on a method signature with parameters to extend before invoking.");
            redirects.AddRefactoring("Make Member non-Static", "Place caret on a static member signature before invoking.");
            redirects.AddRefactoring("Make Member Static", "Place caret on an instance member signature that can be made static before invoking.");
            redirects.AddRefactoring("Promote to Parameter", "Place caret on a local or field variable that can be promoted to a parameter before invoking.");
            redirects.AddRefactoring("Reorder Parameters", "Place caret on a parameter that can be reordered before invoking.");
            redirects.AddRefactoring("Safe Rename", "Place caret on a public member before invoking.");

            FrmResharperCompatibility frmResharperCompatibility = new FrmResharperCompatibility(title, message, redirects, allowPersistResponse);

            frmResharperCompatibility.ShowDialog(CodeRush.IDE);
            if (frmResharperCompatibility.Result == CompatibilityResult.ExecuteCommand)
            {
                CodeRush.Command.Execute(frmResharperCompatibility.Command, frmResharperCompatibility.Parameters);
            }
        }
        private void CleanupFileAndNamespaces_Execute(ExecuteEventArgs ea)
        {
            using (var action = CodeRush.Documents.ActiveTextDocument.NewCompoundAction("Cleanup File and Namespaces"))
            {
                // Store Address
                var Address = NavigationServices.GetCurrentAddress();

                // Find first NamespaceReference
                ElementEnumerable Enumerable =
                    new ElementEnumerable(CodeRush.Source.ActiveFileNode,
                                          LanguageElementType.NamespaceReference, true);
                NamespaceReference Reference = Enumerable.OfType<NamespaceReference>().FirstOrDefault();

                if (Reference == null)
                {
                    // No Namespace References to sort.
                    return;
                }
                // Move caret
                CodeRush.Caret.MoveTo(Reference.Range.Start);

                CleanupFile();
                InvokeRefactoring();
                // Restore Location
                NavigationServices.ResolveAddress(Address).Show();
            }
        }
Ejemplo n.º 5
0
 private void OnScriptFileExecuted(ExecuteEventArgs scriptFileExecuted)
 {
     if (scriptFileExecuted != null && this.ScriptFileExecuted != null)
     {
         this.ScriptFileExecuted(null, scriptFileExecuted);
     }
 }
Ejemplo n.º 6
0
        private void actAddLogging_Execute(ExecuteEventArgs ea)
        {
            try
            {
                Class activeClass = CodeRush.Source.ActiveClass;

                //IEnumerable<Method> methods = (IEnumerable<Method>)activeClass.AllMethods;

                fileChangeCollection = new FileChangeCollection();

                foreach (var method in activeClass.AllMethods)
                {
                    Method methodDetails = (Method)method;

                    System.Diagnostics.Debug.WriteLine(string.Format("Method:  Name:>{0}<  Type:>{1}<", methodDetails.Name, methodDetails.MethodType));
                    AddLoggingToMethod((DevExpress.CodeRush.StructuralParser.Method)method);
                }

                //Method activeMethod = CodeRush.Source.ActiveMethod;

                //AddLoggingToMethod(activeMethod);

                CodeRush.File.ApplyChanges(fileChangeCollection);
                CodeRush.Source.ParseIfTextChanged();

            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }
        }
Ejemplo n.º 7
0
        private void ReviseSelection_Execute(ExecuteEventArgs ea)
        {
            // Check we have a valid Active TextDocument and TextView
            TextDocument activeTextDocument = CodeRush.Documents.ActiveTextDocument;
            if (activeTextDocument == null)
                return;
            TextView activeView = activeTextDocument.ActiveView;
            if (activeView == null)
                return;

            // Extend Selection - This action only works on whole lines.
            activeView.Selection.ExtendToWholeLines();

            // Get Text in selection 
            SourceRange activeSelectionRange = activeView.Selection.Range;
            string textToDuplicate = activeTextDocument.GetText(activeSelectionRange);

            // Remove \r and split on \n - These will be added back later using GetComment
            string strippedText = textToDuplicate.Replace("\r", "");
            string[] commentedLines = strippedText.Split('\n');

            // Build Commented version of code 
            string commentedCode = String.Empty;
            for (int i = 0; i < commentedLines.Length; i++)
                if (commentedLines[i] != String.Empty || i != commentedLines.Length - 1)
                    commentedCode += CodeRush.Language.GetComment(" " + commentedLines[i]);

            // BuildReplacement text - Includes CommentedCode and OriginalText
            string textToInsert = CodeRush.Language.GetComment(" Old code:") + commentedCode
                                + CodeRush.Language.GetComment("-----------") + textToDuplicate;

            // Replace originalText with newly built code.
            activeTextDocument.SetText(activeSelectionRange, textToInsert);

        }
Ejemplo n.º 8
0
 private void ScriptExecuted(object sender, ExecuteEventArgs scriptInfo)
 {
     if (scriptInfo.ScriptFileInfo != null)
     {
         if (scriptInfo.Succeeded)
         {
             TimeSpan s = DateTime.Now - this.timer;
             this.LogBuildMessage(string.Format(CultureInfo.CurrentCulture, "Successfully executed: {0} ({1} seconds)", scriptInfo.ScriptFileInfo.Name, s.TotalSeconds));
             this.timer = DateTime.Now;
         }
         else
         {
             TimeSpan s = DateTime.Now - this.timer;
             this.LogBuildWarning(string.Format(CultureInfo.CurrentCulture, "Failed to executed: {0}. {1} ({2} seconds)", scriptInfo.ScriptFileInfo.Name, scriptInfo.ExecutionException.Message, s.TotalSeconds));
             this.timer = DateTime.Now;
         }
     }
     else
     {
         if (scriptInfo.SqlInfo != null)
         {
             foreach (SqlError infoMessage in scriptInfo.SqlInfo)
             {
                 this.LogBuildMessage("    - " + infoMessage.Message);
             }
         }
     }
 }
Ejemplo n.º 9
0
        void _buttonDropB_ExecuteEvent(object sender, ExecuteEventArgs e)
        {
            // get string value from combo box 2
            string stringValue = _comboBox2.StringValue;

            MessageBox.Show("String value in advanced combo is: " + stringValue);
        }
Ejemplo n.º 10
0
        private void ButtonSaveSettings_ExecuteEvent(object sender, ExecuteEventArgs e)
        {
            try
            {
                Settings settings = Settings.Instance;
                settings.SpeedChecked       = ButtonSpeed.BooleanValue;
                settings.CadenceChecked     = ButtonCadence.BooleanValue;
                settings.PowerChecked       = ButtonPower.BooleanValue;
                settings.LRBalanceChecked   = ButtonLRBalance.BooleanValue;
                settings.HeartRateChecked   = ButtonHeartRate.BooleanValue;
                settings.LTorqueChecked     = ButtonLTorqueEff.BooleanValue;
                settings.RTorqueChecked     = ButtonRTorqueEff.BooleanValue;
                settings.LSmoothChecked     = ButtonLSmoothness.BooleanValue;
                settings.RSmoothChecked     = ButtonRSmoothness.BooleanValue;
                settings.AltitudeChecked    = ButtonAltitude.BooleanValue;
                settings.GradeChecked       = ButtonGrade.BooleanValue;
                settings.TemperatureChecked = ButtonTemperature.BooleanValue;

                settings.MapWidth  = (int)SpinnerMapWidth.DecimalValue;
                settings.MapHeight = (int)SpinnerMapHeight.DecimalValue;

                if (CheckCurrentAppSize.BooleanValue)
                {
                    settings.AppWidth     = _form.Width;
                    settings.AppHeight    = _form.Height;
                    settings.AppSizeWrite = true;
                }

                Settings.Instance.Modified = true;
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 11
0
        void _buttonDropB_ExecuteEvent(object sender, ExecuteEventArgs e)
        {
            List <int> supportedImageSizes = new List <int>()
            {
                32, 48, 64
            };

            StringBuilder bitmapFileName = new StringBuilder();

            int selectedImageSize;

            if (supportedImageSizes.Contains(SystemInformation.IconSize.Width))
            {
                selectedImageSize = SystemInformation.IconSize.Width;
            }
            else
            {
                selectedImageSize = 32;
            }

            exitOn = !exitOn;
            string exitStatus = exitOn ? "On" : "Off";

            var bitmap = GetResourceBitmap(string.Format("Exit{0}{1}.bmp", exitStatus, selectedImageSize));

            bitmap.MakeTransparent();

            _buttonDropB.LargeImage = _ribbonControl.ConvertToUIImage(bitmap);
        }
 private void actReSharperGoToInheritor_Execute(ExecuteEventArgs ea)
 {
   if (CodeRush.Source.ActiveMember != null)
     CodeRush.Command.Execute("Navigate", "Overrides");
   else
     CodeRush.Command.Execute("Navigate", "Descendants");
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Called by NeonSwitch to execute a synchronous subcommand.
 /// </summary>
 /// <param name="args">The command execution context including the arguments.</param>
 /// <remarks>
 /// <note>
 /// Implementations can use the various <see cref="ExecuteEventArgs.Write(string)"/> method
 /// overloads in <see cref="ExecuteEventArgs"/> to stream text back to the caller.
 /// </note>
 /// </remarks>
 public void Execute(ExecuteEventArgs args)
 {
     foreach (var voice in SpeechEngine.InstalledVoices.Keys)
     {
         args.WriteLine(voice);
     }
 }
Ejemplo n.º 14
0
        private void SpAtDesignTime_Execute(ExecuteEventArgs ea)
        {
            IEnumerable <ProjectItem> enumerable = CodeRush.ApplicationObject.Solution.FindStartUpProject().ProjectItems.Cast <ProjectItem>();

            Trace.Listeners.Add(new DefaultTraceListener {
                LogFileName = "log.txt"
            });
            foreach (ProjectItem item in enumerable)
            {
                if (item.Name.ToLower() == "app.config" || item.Name.ToLower() == "web.config")
                {
                    foreach (var connectionString in Options.GetConnectionStrings())
                    {
                        if (!string.IsNullOrEmpty(connectionString.Name))
                        {
                            ConnectionStringSettings connectionStringSettings = GetConnectionStringSettings(item, connectionString.Name);
                            if (connectionStringSettings != null)
                            {
                                DropDatabase(connectionStringSettings.ConnectionString, connectionString.Name);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 15
0
        public static void LapChanged(object sender, ExecuteEventArgs e)
        {
            RibbonComboBox selectChartViewComboBox = sender as RibbonComboBox;

            if (selectChartViewComboBox == null)
            {
                return;
            }
            s_lap = (int)selectChartViewComboBox.SelectedItem;
            if (s_lap > 0)
            {
                s_lapStartIndex = DataManager.Instance.LapManager.GetStartIndex(s_lap);
                s_lapEndIndex   = DataManager.Instance.LapManager.GetEndIndex(s_lap);
            }
            else
            {
                s_lapStartIndex = 0;
                s_lapEndIndex   = DataManager.Instance.RecordList.Count - 1;
            }
            if (s_lap >= 0)
            {
                List <RecordValues> list = DataManager.Instance.RecordList;
                DateTime            from = list[s_lapStartIndex].Timestamp;
                DateTime            to   = list[s_lapEndIndex].Timestamp;
                TimeSpan            span = new TimeSpan(to.Ticks - from.Ticks);
                ChartHelp.SetIntervals(span);
            }

            DataManager.Instance.ClearChart();
            DataManager.Instance.FillChart();
        }
        public void Login(object sender, ExecuteEventArgs args)
        {
            IsLoading = true;
            DidLoginFail = false;

            LoginRepository.LoginAsync(
                new Models.LoginCredentials(UserName, args.MethodParameter as string),
                (result, authToken, ex) =>
                {
                    IsLoading = false;
                    if (ex == null)
                    {
                        DidLoginFail = !result;
                        if (!DidLoginFail)
                        {
                            UserMetaData.AuthToken = authToken;
                            Bxf.Shell.Instance.ShowView("/Views/Customers.xaml", null, null, null);
                        }
                    }
                    else
                    {
                        DidLoginFail = true;
                    }
                });
        }
Ejemplo n.º 17
0
 private void exploreXafErrors_Execute(ExecuteEventArgs ea) {
     Project startUpProject = CodeRush.ApplicationObject.Solution.FindStartUpProject();
     Property outPut = startUpProject.ConfigurationManager.ActiveConfiguration.FindProperty(ConfigurationProperty.OutputPath);
     bool isWeb = IsWeb(startUpProject);
     string fullPath = startUpProject.FindProperty(ProjectProperty.FullPath).Value + "";
     string path = Path.Combine(fullPath, outPut.Value.ToString()) + "";
     if (isWeb)
         path = Path.GetDirectoryName(startUpProject.FullName);
     Func<Stream> streamSource = () => {
         var path1 = path + "";
         File.Copy(Path.Combine(path1, "expressAppFrameWork.log"), Path.Combine(path1, "expressAppFrameWork.locked"), true);
         return File.Open(Path.Combine(path1, "expressAppFrameWork.locked"), FileMode.Open, FileAccess.Read, FileShare.Read);
     };
     var reader = new ReverseLineReader(streamSource);
     var stackTrace = new List<string>();
     foreach (var readline in reader) {
         stackTrace.Add(readline);
         if (readline.Trim().StartsWith("The error occured:") || readline.Trim().StartsWith("The error occurred:")) {
             stackTrace.Reverse();
             string errorMessage = "";
             foreach (string trace in stackTrace) {
                 errorMessage += trace + Environment.NewLine;
                 if (trace.Trim().StartsWith("----------------------------------------------------"))
                     break;
             }
             Clipboard.SetText(errorMessage);
             break;
         }
     }
 }
Ejemplo n.º 18
0
        private void myCPU_OnExecuteDone(object sender, ExecuteEventArgs args)
        {
            MethodInvoker method = delegate
            {
                Console.WriteLine("Execute Done in GUI ");
                if (this.myCPU.mdHazard)
                {
                    this.label43.Text   = "A mul or div has been excuted, 4 cycle penalties!";
                    this.myCPU.mdHazard = false;
                }
                this.setExecutePipelineLabel(args.CurrentInstructionIndex);
                this.setCPUValuesToView();
                executeDone = true;

                /*if (fetchDone && decodeDone && executeDone && storeDone)
                 * {
                 *  Console.WriteLine("Execute was last to finish, setting labels.");
                 *  setPipelineValuesToView();
                 * } */
            };

            if (this.InvokeRequired)
            {
                this.Invoke(method);
            }
            else
            {
                method.Invoke();
            }
        }
 private void action1_Execute(ExecuteEventArgs ea)
 {
     if (enabled)
     {
         navigateToDefinition(CodeRush.Source.Active);
     }
 }
        void doubleCommentAction_Execute(ExecuteEventArgs ea)
        {
            var activeTextDocument = CodeRush.Documents.ActiveTextDocument;
            if (activeTextDocument == null)
            {
                return;
            }

            var selection = activeTextDocument.ActiveViewSelection;
            selection.ExtendToWholeLines();

            var lang = CodeRush.Language;

            var commentedSelection = string.Empty;

            var lines = selection.Lines;

            foreach (var line in lines)
            {
                var lineText = line.TrimStart();

                var commentLine = lang.GetComment(lang.GetComment(lineText));
                var idx = commentLine.LastIndexOf(System.Environment.NewLine);
                commentLine = commentLine.Remove(idx);
                commentedSelection += commentLine;
            }

            selection.Text = commentedSelection;
            selection.Format();

            if (selection.AnchorIsAtEnd)
                selection.SwapPoints();
            selection.Clear();
        }
Ejemplo n.º 21
0
        private void loadProjects_Execute(ExecuteEventArgs ea)
        {
            var dte = CodeRush.ApplicationObject;
            var uihSolutionExplorer = dte.Windows.Item(Constants.vsext_wk_SProjectWindow).Object as UIHierarchy;

            if (uihSolutionExplorer == null || uihSolutionExplorer.UIHierarchyItems.Count == 0)
            {
                return;
            }
            var uiHierarchyItem = uihSolutionExplorer.UIHierarchyItems.Item(1);

            string constants = Constants.vsext_wk_SProjectWindow;

            if (ea.Action.ParentMenu == "Object Browser Objects Pane")
            {
                constants = Constants.vsWindowKindObjectBrowser;
            }
            Project        dteProject    = FindProject(uiHierarchyItem);
            ProjectElement activeProject = CodeRush.Language.LoadProject(dteProject);

            if (activeProject != null)
            {
                var projectLoader = new ProjectLoader();
                var selectedAssemblyReferences = activeProject.GetSelectedAssemblyReferences(constants).ToList();
                projectLoader.Load(selectedAssemblyReferences.ToList(), NotifyOnNotFound);
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Ejemplo n.º 22
0
        private void RemoveQuotesFromString_Execute(ExecuteEventArgs ea)
        {
            TextString TheString = CodeRush.Source.ActiveString;
            var        TheRange  = TheString.Range;

            CodeRush.Documents.ActiveTextDocument.SetText(new SourceRange(TheRange.Start.OffsetPoint(0, -1), TheRange.End.OffsetPoint(0, 1)), (string)TheString.PrimitiveExpression.PrimitiveValue);
        }
Ejemplo n.º 23
0
 void _buttonUnselect_ExecuteEvent(object sender, ExecuteEventArgs e)
 {
     if (_tabGroupTableTools.ContextAvailable != ContextAvailability.NotAvailable)
     {
         _tabGroupTableTools.ContextAvailable = ContextAvailability.NotAvailable;
     }
 }
Ejemplo n.º 24
0
        private void actReSharperSurroundWithTemplate_Execute(ExecuteEventArgs ea)
        {
            bool      allowPersistResponse = false;
            string    title     = "Surround With Template";
            string    message   = "CodeRush includes several built-in features to wrap and modify selections. There are keyboard shortcuts for many of these (just select the code you want to modify and press the specified key), and you can also access these from the right-click context menu. Select from one of the options below.";
            Redirects redirects = new Redirects();

            redirects.AddSelectionEmbedding("block", "Embeds a selection inside block delimiters (e.g., {} braces in C# or C++).");
            redirects.AddSelectionEmbedding("lock", "Embeds a selection inside a lock statement.");
            redirects.AddSelectionEmbedding("region", "Embeds a selection inside a region.");
            redirects.AddSelectionEmbedding("SyncLock", "Embeds a selection inside a SyncLock statement.");
            redirects.AddSelectionEmbedding("ToString", "Converts a selection to a string, escaping characters as needed.");
            redirects.AddSelectionEmbedding("try/catch", "Embeds a selection inside a try/catch block.");
            redirects.AddSelectionEmbedding("try/catch/finally", "Embeds a selection inside a try/catch/finally block.");
            redirects.AddSelectionEmbedding("try/finally", "Embeds a selection inside a try/finally block.");
            redirects.AddSelectionEmbedding("using", "Embeds a selection inside a using statement.");
            redirects.AddSelectionEmbedding("WaitCursor", "Embeds a selection inside code that displays an hourglass cursor while the code executes.");
            redirects.AddOptionsPage("Embedding Options && Customization", "Editor\\Selections\\Embedding", "Click this button to view, change, and create custom embeddings.");

            FrmResharperCompatibility frmResharperCompatibility = new FrmResharperCompatibility(title, message, redirects, allowPersistResponse);

            frmResharperCompatibility.ShowDialog(CodeRush.IDE);
            if (frmResharperCompatibility.Result == CompatibilityResult.ExecuteCommand)
            {
                CodeRush.Command.Execute(frmResharperCompatibility.Command, frmResharperCompatibility.Parameters);
            }
        }
Ejemplo n.º 25
0
        private void exploreXafErrors_Execute(ExecuteEventArgs ea)
        {
            Project startUpProject = CodeRush.ApplicationObject.Solution.FindStartUpProject();
            Property outPut = startUpProject.ConfigurationManager.ActiveConfiguration.FindProperty(ConfigurationProperty.OutputPath);
            Property fullPath = startUpProject.FindProperty(ProjectProperty.FullPath);
            string path = Path.Combine(fullPath.Value.ToString(),outPut.Value.ToString());
            var reader = new InverseReader(Path.Combine(path,"expressAppFrameWork.log"));
            var stackTrace = new List<string>();
            while (!reader.SOF) {
                string readline = reader.Readline();
                stackTrace.Add(readline);
                if (readline.Trim().StartsWith("The error occured:")) {
                    stackTrace.Reverse();
                    string errorMessage = "";
                    foreach (string trace in stackTrace) {
                        errorMessage += trace + Environment.NewLine;
                        if (trace.Trim().StartsWith("----------------------------------------------------"))
                            break;
                    }
                    Clipboard.SetText(errorMessage);
                    break;
                }
            }
            reader.Close();

        }
Ejemplo n.º 26
0
        public void MovieSelected(object sender, ExecuteEventArgs args)
        {
            var movie = args.MethodParameter as Movie;
            var message = new ShowViewMessage(MoviesViewTargets.Detail, movie);

            MessageBus.Publish<ShowViewMessage>(message);
        }
        private void TemplateExpandWithCollapsedRegions_Execute(ExecuteEventArgs ea)
        {
            TextDocument ActiveDoc = CodeRush.Documents.ActiveTextDocument;

            using (ActiveDoc.NewCompoundAction("TemplateExpandWithCollapsedRegions"))
            {
                var LinesFromStart = CodeRush.Caret.Line;
                var LinesFromEnd = ActiveDoc.LineCount - LinesFromStart;

                DevExpress.CodeRush.Core.Action Action = CodeRush.Actions.Get("TemplateExpand");
                Action.DoExecute();

                // Calculate line range that template expanded into.
                SourceRange TemplateExpandRange = new SourceRange(new SourcePoint(LinesFromStart, 1),
                                              new SourcePoint(ActiveDoc.LineCount - LinesFromEnd,
                                                  ActiveDoc.GetLine(LinesFromEnd).Length - 1)
                    );
                // Reparse everything just in case.
                CodeRush.Documents.ParseActive();
                CodeRush.Documents.ActiveTextDocument.ParseIfTextChanged();

                // Execute a delayed collapse of all regions in the ExpansionRange
                RangeRegionCollapser Collapser = new RangeRegionCollapser(TemplateExpandRange);
                Collapser.PerformDelayedCollapse(150);

            }
        }
 private void action1_Execute(ExecuteEventArgs ea)
 {
     if (enabled)
     {
         refactoringProvider1.Execute();
     }
 }
Ejemplo n.º 29
0
        /// <summary>
        /// Raise an event ExecuteEventArgs
        /// (Used when a query is executed)
        /// </summary>
        private void RaiseExecuteEvent()
        {
            ExecuteEventArgs e = new ExecuteEventArgs();

            e.StatementName = statement.Id;
            Executed(this, e);
        }
Ejemplo n.º 30
0
 private void actQuickPair_Execute(ExecuteEventArgs ea)
 {
     string left = actQuickPair.Parameters["Left"].ValueAsStr;
     string right = actQuickPair.Parameters["Right"].ValueAsStr;
     bool positionCaretBetweenDelimiters = actQuickPair.Parameters["CaretBetween"].ValueAsBool;
     if (left.StartsWith("\","))
     {
         if (right == "true")
             positionCaretBetweenDelimiters = true;
         right = left.Substring(2).Trim();
         left = "\"";
     }
     TextDocument activeTextDocument = CodeRush.Documents.ActiveTextDocument;
     if (activeTextDocument == null)
         return;
     TextView activeView = activeTextDocument.ActiveView;
     if (activeView == null)
         return;
     TextViewSelection selection = activeView.Selection;
     if (selection == null)
         return;
     TextViewCaret caret = activeView.Caret;
     if (caret == null)
         return;
     if (selection.Exists)
     {
         Embedding embedding = new Embedding();
         embedding.Style = EmbeddingStyle.StartEnd;
         string[] top = { left };
         string[] bottom = { right };
         embedding.Top = top;
         embedding.Bottom = bottom;
         if (positionCaretBetweenDelimiters)
             embedding.AdjustSelection = PostEmbeddingSelectionAdjustment.Leave;
         else
             embedding.AdjustSelection = PostEmbeddingSelectionAdjustment.Extend;
         bool needToMoveCaretToTheRight = false;
     if (selection.AnchorPosition < selection.ActivePosition)
             needToMoveCaretToTheRight = true;
         using (activeTextDocument.NewCompoundAction(STR_EmbedQuickPair))
         {
             activeTextDocument.EmbedSelection(embedding);
             if (needToMoveCaretToTheRight)
             {
                 selection.Set(selection.ActivePosition, selection.AnchorPosition);
             }
         }
     }
     else
     {
         if (CodeRush.Windows.IntellisenseEngine.HasSelectedCompletionSet(activeView))
             CodeRush.Command.Execute("Edit.InsertTab");
         using (activeTextDocument.NewCompoundAction(STR_QuickPair))
             if (positionCaretBetweenDelimiters)
                 activeTextDocument.ExpandText(caret.SourcePoint, left + "«Caret»«Field()»" + right + "«FinalTarget»");
             else
                 activeTextDocument.InsertText(caret.SourcePoint, left + right);
     }
 }
        private void ExecuteOrganizeWORegions(ExecuteEventArgs ea)
        {
            ClassOrganizer organizer = new ClassOrganizer();

            organizer.Organize(CodeRush.Documents.ActiveTextDocument,
                               CodeRush.Source.ActiveType,
                               false);
        }
Ejemplo n.º 32
0
 private void TraceMessageEventHandler(object sender, SqlInfoMessageEventArgs e)
 {
     if (this.ScriptFileExecuted != null)
     {
         ExecuteEventArgs args = new ExecuteEventArgs(e.Errors);
         this.ScriptFileExecuted(null, args);
     }
 }
 private void FlushHandler(object sender, ExecuteEventArgs e)
 {
     if (_logger.IsDebugEnabled)
     {
         _logger.Debug("Flush cacheModel named " + this._id + " for statement '" + e.StatementName + "'");
     }
     this.Flush();
 }
Ejemplo n.º 34
0
 void _exitButton_ExecuteEvent(object sender, ExecuteEventArgs e)
 {
     // Close form asynchronously since we are in a ribbon event
     // handler, so the ribbon is still in use, and calling Close
     // will eventually call _ribbon.DestroyFramework(), which is
     // a big no-no, if you still use the ribbon.
     this.BeginInvoke(new MethodInvoker(this.Close));
 }
        private void ExecuteCutCurrentMember(ExecuteEventArgs ea)
        {
            bool selected =
                 Utilities.SelectCurrentMember(CodeRush.Caret, CodeRush.Documents.ActiveTextDocument);

            if (selected == true)
                CodeRush.Clipboard.Cut();
        }
Ejemplo n.º 36
0
        /// <summary>
        /// Adds a new item to the Model (if it
        /// is a collection).
        /// </summary>
        public virtual void AddNew(object sender, ExecuteEventArgs e)
        {
#if ANDROID || IOS
            BeginAddNew();
#else
            DoAddNew();
#endif
        }
Ejemplo n.º 37
0
        /// <summary>
        /// Adds a new item to the Model (if it
        /// is a collection).
        /// </summary>
        public virtual void AddNew(object sender, ExecuteEventArgs e)
        {
#if SILVERLIGHT
            BeginAddNew();
#else
            DoAddNew();
#endif
        }
Ejemplo n.º 38
0
        void _richFont_OnPreview(object sender, ExecuteEventArgs e)
        {
            PropVariant propChangesProperties;

            e.CommandExecutionProperties.GetValue(ref RibbonProperties.FontProperties_ChangedProperties, out propChangesProperties);
            IPropertyStore changedProperties = (IPropertyStore)propChangesProperties.Value;

            UpdateRichTextBox(changedProperties);
        }
Ejemplo n.º 39
0
        public async override void Save(object sender, ExecuteEventArgs e)
        {
            //base.Save(sender, e);
            IsBusy = true;
            Model.ApplyEdit();
            Model = await Model.SaveAsync();

            IsBusy = false;
        }
Ejemplo n.º 40
0
        void _recentItems_ExecuteEvent(object sender, ExecuteEventArgs e)
        {
            if (e.Key.PropertyKey == RibbonProperties.RecentItems)
            {
                // go over recent items
                object[] objectArray = (object[])e.CurrentValue.PropVariant.Value;
                for (int i = 0; i < objectArray.Length; ++i)
                {
                    IUISimplePropertySet propertySet = objectArray[i] as IUISimplePropertySet;

                    if (propertySet != null)
                    {
                        PropVariant propLabel;
                        propertySet.GetValue(ref RibbonProperties.Label,
                                             out propLabel);
                        string label = (string)propLabel.Value;

                        PropVariant propLabelDescription;
                        propertySet.GetValue(ref RibbonProperties.LabelDescription,
                                             out propLabelDescription);
                        string labelDescription = (string)propLabelDescription.Value;

                        PropVariant propPinned;
                        propertySet.GetValue(ref RibbonProperties.Pinned,
                                             out propPinned);
                        bool pinned = (bool)propPinned.Value;

                        // update pinned value
                        _recentItems[i].Pinned = pinned;
                    }
                }
            }
            else if (e.Key.PropertyKey == RibbonProperties.SelectedItem)
            {
                // get selected item index
                uint selectedItem = (uint)e.CurrentValue.PropVariant.Value;

                // get selected item label
                PropVariant propLabel;
                e.CommandExecutionProperties.GetValue(ref RibbonProperties.Label,
                                                      out propLabel);
                string label = (string)propLabel.Value;

                // get selected item label description
                PropVariant propLabelDescription;
                e.CommandExecutionProperties.GetValue(ref RibbonProperties.LabelDescription,
                                                      out propLabelDescription);
                string labelDescription = (string)propLabelDescription.Value;

                // get selected item pinned value
                PropVariant propPinned;
                e.CommandExecutionProperties.GetValue(ref RibbonProperties.Pinned,
                                                      out propPinned);
                bool pinned = (bool)propPinned.Value;
            }
        }
Ejemplo n.º 41
0
        void _buttonDropA_ExecuteEvent(object sender, ExecuteEventArgs e)
        {
            // load bitmap from file
            Bitmap bitmap = GetResourceBitmap("Drop32.bmp");

            bitmap.MakeTransparent();

            // set large image property
            _buttonDropA.LargeImage = _ribbonControl.ConvertToUIImage(bitmap);
        }
        private void ExecuteCutCurrentMember(ExecuteEventArgs ea)
        {
            bool selected =
                Utilities.SelectCurrentMember(CodeRush.Caret, CodeRush.Documents.ActiveTextDocument);

            if (selected == true)
            {
                CodeRush.Clipboard.Cut();
            }
        }
Ejemplo n.º 43
0
        private void MarkerClearAllAction_Execute(ExecuteEventArgs ea)
        {
            List <IMarker> markers = new List <IMarker>();

            LoadMarkerList(markers, false);
            foreach (IMarker marker in markers)
            {
                CodeRush.Markers.Remove(marker);
            }
        }
Ejemplo n.º 44
0
 private void CollapseXML_Execute(ExecuteEventArgs ea)
 {
     var Doc = CodeRush.Documents.ActiveTextDocument;
     var elements = new ElementEnumerable(Doc.FileNode, LanguageElementType.HtmlElement, true);
     foreach (SP.HtmlElement html in elements.OfType<SP.HtmlElement>())
     {
         var attributes = html.Attributes.OfType<SP.HtmlAttribute>().ToList();
         if (attributes.Any(at => at.Name.ToLower() == "id" || at.Name.ToLower() == "name"))
             html.CollapseInView(Doc.ActiveView);
     }
 }
        private void action1_Execute(ExecuteEventArgs ea)
        {
            Document currentDocument = CodeRush.Documents == null ? null : CodeRush.Documents.Active;

              IMarker marker = CodeRush.Markers.Collect();

              if ((marker != null) && (currentDocument != null) &&
            !marker.FileName.Equals(currentDocument.FullName, StringComparison.OrdinalIgnoreCase))
              {
            currentDocument.Close(EnvDTE.vsSaveChanges.vsSaveChangesPrompt);
              }
        }
 private void acnCreateTestMethod_Execute(ExecuteEventArgs ea)
 {
     if (!IsAvailable())
         return;
     var text = string.Empty;
     if (CodeRush.Selection.Exists)
         text = CodeRush.Selection.Text;
     else if (CodeRush.Caret.InsideComment)
         text = CodeRush.Source.ActiveComment.Name;
     else
         return;
     CreateTestMethod(text);
 }
Ejemplo n.º 47
0
 private void ImportTemplates_Execute(ExecuteEventArgs ea)
 {
     // Package: https://raw2.github.com/RoryBecker/CodeRushTemplatePackages/master/CS_PluginTemplatesPackage.xml
     // Template: https://raw2.github.com/RoryBecker/CodeRushPluginTemplates/master/CS_NewAction.xml
     // Template: https://raw2.github.com/groovyghoul/fakeiteasy-coderush-templates/master/CSharp_Custom_FakeItEasy.xml
     //TemplateLoader TemplateLoader = new TemplateLoader();
     //TemplateLoader.ImportTemplatePackageViaUrl("https://raw2.github.com/RoryBecker/CodeRushTemplatePackages/master/CS_PluginTemplatesPackage.xml");
     //TemplateLoader.SaveAndReloadTemplates();
     using (TemplateImporter TemplateImporter = new TemplateImporter())
     {
         TemplateImporter.ShowDialog();
     }
 }
Ejemplo n.º 48
0
        private void convertProject_Execute(ExecuteEventArgs ea) {
            string path = Options.ReadString(Options.ProjectConverterPath);
            string token = Options.ReadString(Options.Token);
            if (!string.IsNullOrEmpty(path) && !string.IsNullOrEmpty(token)) {
                var directoryName = Path.GetDirectoryName(CodeRush.Solution.Active.FileName);

                var userName = string.Format("/s /k:{0} \"{1}\"", token, directoryName);
                Process.Start(path, userName);
                actionHint1.Text = "Project Converter Started !!!";
                Rectangle rectangle = Screen.PrimaryScreen.Bounds;
                actionHint1.PointTo(new Point(rectangle.Width / 2, rectangle.Height / 2));
            }
        }
Ejemplo n.º 49
0
		private void MultiSelectEdit_Execute(ExecuteEventArgs ea)
		{
			TextView TheView = CodeRush.TextViews.Active;
			var TheMultiSelect = CodeRush.MultiSelect.Get(TheView);
			if (TheMultiSelect == null || TheMultiSelect.Selections.Count == 0)
			{
				return;
			}
			var StartingSelectionRange = TheView.Selection.Range;
			LinkSourceRanges(TheView, StartingSelectionRange, TheMultiSelect.Selections.ToRanges());
			LinkOriginalRange(TheView, StartingSelectionRange, TheMultiSelect.Selections.ToRanges());
			TheMultiSelect.RefreshHighlighting(TheView);
		}
Ejemplo n.º 50
0
 private void action1_Execute(ExecuteEventArgs ea)
 {
     if (timer1.Enabled)
     {
         timer1.Enabled = false;
         timer1.Stop();
         _editorGraphics.FillRectangle(_background, GetRectangle(TextView.Active));
     }
     else
     {
         timer1.Enabled = true;
         timer1.Start();
     }
 }
Ejemplo n.º 51
0
 private void SpAtDesignTime_Execute(ExecuteEventArgs ea) {
     IEnumerable<ProjectItem> enumerable = CodeRush.ApplicationObject.Solution.FindStartUpProject().ProjectItems.Cast<ProjectItem>();
     Trace.Listeners.Add(new DefaultTraceListener { LogFileName = "log.txt" });
     foreach (ProjectItem item in enumerable) {
         if (item.Name.ToLower() == "app.config" || item.Name.ToLower() == "web.config") {
             foreach (var connectionString in Options.GetConnectionStrings()) {
                 if (!string.IsNullOrEmpty(connectionString.Name)) {
                     ConnectionStringSettings connectionStringSettings = GetConnectionStringSettings(item, connectionString.Name);
                     if (connectionStringSettings != null) {
                         DropDatabase(connectionStringSettings.ConnectionString, connectionString.Name);
                     }
                 }
             }
             
         }
     }
 }
        /// <summary>
        /// Add a developer comment.
        /// </summary>
        /// <param name="ea"></param>
        /// <developer>Paul Mrozowski</developer>
        /// <created>08/04/2006</created>
        private void actInitials_Execute(ExecuteEventArgs ea)
        {            
            TextDocument doc = TextDocument.Active;
            SourcePoint sp = CodeRush.Caret.SourcePoint;            
                        
            string line = doc.GetText(sp.Line);             
            string xmlDoc = CodeRush.Language.ActiveExtension.XMLDocCommentBegin;
            bool xmlComment = line.TrimStart().StartsWith(xmlDoc);
            if (xmlDoc == null)
                xmlDoc = "///";
            
            if (xmlComment)
            {                
                doc.QueueInsert(sp, String.Format("<developer>{0}</developer>\r\n{1}{2} <created>{3:" + m_dateformat + "}</created>", 
                                        this.m_devName, 
                                        line.Substring(0, line.IndexOf(xmlDoc)), 
                                        xmlDoc, 
                                        System.DateTime.Now));
            }
            else
            {
                string commentLine = CodeRush.Language.ActiveExtension.SingleLineCommentBegin;
                if (commentLine == null)
                {
                	commentLine = "//";
                }
                
                string comment = "";

                if (this.m_fullName)
                {
                    comment = String.Format("{0} {1} - {2:" + m_dateformat + "} - ", commentLine, this.m_devName, System.DateTime.Now);
                }
                else
                {
                    comment = String.Format("{0} {1} - {2:" + m_dateformat + "} - ", commentLine, this.m_devInitials, System.DateTime.Now);
                }
               
                doc.QueueInsert(sp, comment);
                CodeRush.Caret.MoveToEndOfLine();
                CodeRush.Caret.DeleteLeftWhiteSpace();                
            }
            
            doc.ApplyQueuedEdits("Developer Comment");            
        }
        private void actExpandProperties_Execute(ExecuteEventArgs ea)
        {
            //TypeDeclaration typeDeclaration = CodeRush.Source.ActiveType as TypeDeclaration;
            //if (typeDeclaration == null)
            //    return;
            //TextDocument textDocument = CodeRush.Documents.ActiveTextDocument;
            //if (textDocument == null)
            //    return;
            //foreach(Member member in typeDeclaration.AllMembers)
            //    Filter(textDocument, member);

            //StringBuilder code = new StringBuilder();
            //foreach(Filter filter in _Filters)
            //    filter.GenerateCode(textDocument, code);

            //textDocument.QueueInsert(typeDeclaration.BlockCodeRange.Start, code.ToString());

            //textDocument.ApplyQueuedEdits("Organize Members");
        }
Ejemplo n.º 54
0
        private void actMultiSelectIntegratedPaste_Execute(ExecuteEventArgs ea)
        {
            TextDocument activeTextDocument = CodeRush.Documents.ActiveTextDocument;
            if (activeTextDocument == null)
                return;
            TypeDeclaration activeType = CodeRush.Source.ActiveClassInterfaceOrStruct;
            if (activeType == null)
                return;
            MultiSelect multiSelect = CodeRushPlaceholder.MultiSelect.FromClipboard();
            if (multiSelect == null)
                return;

            multiSelect.PrepareToGenerate();
            QueueAdd(activeTextDocument, activeType, multiSelect, LanguageElementType.Method);
            QueueAdd(activeTextDocument, activeType, multiSelect, LanguageElementType.Property);
            QueueAdd(activeTextDocument, activeType, multiSelect, LanguageElementType.Event);
            QueueAdd(activeTextDocument, activeType, multiSelect, LanguageElementType.Variable);
            QueueAdd(activeTextDocument, activeType, multiSelect, LanguageElementType.Unknown);
            activeTextDocument.ApplyQueuedEdits("Integrated Paste");
        }
Ejemplo n.º 55
0
        private void actCautiousChange_Execute(ExecuteEventArgs ea)
        {
            var activeTextDocument = CodeRush.Documents.ActiveTextDocument;
            if (activeTextDocument == null)
                return;

            var selection = activeTextDocument.ActiveViewSelection;
            selection.ExtendToWholeLines();

            var commentedSelection = Environment.NewLine + CodeRush.Language.GetComment("Old code");

            foreach (var line in selection.Lines)
                commentedSelection += CodeRush.Language.GetComment(line);
            commentedSelection += CodeRush.Language.GetComment("--------------");

            selection.Text = commentedSelection + selection.Text;

            if(selection.AnchorIsAtEnd)
                selection.SwapPoints();
            selection.Clear();
        }
    private void actReSharperChangeSignature_Execute(ExecuteEventArgs ea)
    {
      bool allowPersistResponse = false;
      string title = "Change Signature";
      string message = "CodeRush includes several useful refactorings dedicated to changing signatures. Select from one of the signature-changing refactorings below.";
      Redirects redirects = new Redirects();

      redirects.AddRefactoring("Add Parameter", "Place caret inside the parameter list before invoking.");
      redirects.AddRefactoring("Create Overload", "Place caret on the member declaration before invoking.");
      redirects.AddRefactoring("Decompose Parameter", "Place caret on the parameter to decompose before invoking.");
      redirects.AddRefactoring("Introduce Parameter Object", "Select the parameters to consolidate before invoking.");
      redirects.AddRefactoring("Make Extension", "Place caret on a method signature with parameters to extend before invoking.");
      redirects.AddRefactoring("Make Member non-Static", "Place caret on a static member signature before invoking.");
      redirects.AddRefactoring("Make Member Static", "Place caret on an instance member signature that can be made static before invoking.");
      redirects.AddRefactoring("Promote to Parameter", "Place caret on a local or field variable that can be promoted to a parameter before invoking.");
      redirects.AddRefactoring("Reorder Parameters", "Place caret on a parameter that can be reordered before invoking.");
      redirects.AddRefactoring("Safe Rename", "Place caret on a public member before invoking.");

      FrmResharperCompatibility frmResharperCompatibility = new FrmResharperCompatibility(title, message, redirects, allowPersistResponse);
      frmResharperCompatibility.ShowDialog(CodeRush.IDE);
      if (frmResharperCompatibility.Result == CompatibilityResult.ExecuteCommand)
        CodeRush.Command.Execute(frmResharperCompatibility.Command, frmResharperCompatibility.Parameters);
    }
    private void actReSharperSurroundWithTemplate_Execute(ExecuteEventArgs ea)
    {
      bool allowPersistResponse = false;
      string title = "Surround With Template";
      string message = "CodeRush includes several built-in features to wrap and modify selections. There are keyboard shortcuts for many of these (just select the code you want to modify and press the specified key), and you can also access these from the right-click context menu. Select from one of the options below.";
      Redirects redirects = new Redirects();

      redirects.AddSelectionEmbedding("block", "Embeds a selection inside block delimiters (e.g., {} braces in C# or C++).");
      redirects.AddSelectionEmbedding("lock", "Embeds a selection inside a lock statement.");
      redirects.AddSelectionEmbedding("region", "Embeds a selection inside a region.");
      redirects.AddSelectionEmbedding("SyncLock", "Embeds a selection inside a SyncLock statement.");
      redirects.AddSelectionEmbedding("ToString", "Converts a selection to a string, escaping characters as needed.");
      redirects.AddSelectionEmbedding("try/catch", "Embeds a selection inside a try/catch block.");
      redirects.AddSelectionEmbedding("try/catch/finally", "Embeds a selection inside a try/catch/finally block.");
      redirects.AddSelectionEmbedding("try/finally", "Embeds a selection inside a try/finally block.");
      redirects.AddSelectionEmbedding("using", "Embeds a selection inside a using statement.");
      redirects.AddSelectionEmbedding("WaitCursor", "Embeds a selection inside code that displays an hourglass cursor while the code executes.");
      redirects.AddOptionsPage("Embedding Options && Customization", "Editor\\Selections\\Embedding", "Click this button to view, change, and create custom embeddings.");

      FrmResharperCompatibility frmResharperCompatibility = new FrmResharperCompatibility(title, message, redirects, allowPersistResponse);
      frmResharperCompatibility.ShowDialog(CodeRush.IDE);
      if (frmResharperCompatibility.Result == CompatibilityResult.ExecuteCommand)
        CodeRush.Command.Execute(frmResharperCompatibility.Command, frmResharperCompatibility.Parameters);
    }
Ejemplo n.º 58
0
 private void collapseAllItemsInSolutionExplorer_Execute(ExecuteEventArgs ea) {
     CodeRush.ApplicationObject.Solution.CollapseAllFolders();
 }
Ejemplo n.º 59
0
 private void loadProjects_Execute(ExecuteEventArgs ea) {
     var dte = CodeRush.ApplicationObject;
     var UIHSolutionExplorer = dte.Windows.Item(Constants.vsext_wk_SProjectWindow).Object as UIHierarchy;
     if (UIHSolutionExplorer == null || UIHSolutionExplorer.UIHierarchyItems.Count == 0)
         return;
     var uiHierarchyItem = UIHSolutionExplorer.UIHierarchyItems.Item(1);
     
     string constants = Constants.vsext_wk_SProjectWindow;
     if (ea.Action.ParentMenu == "Object Browser Objects Pane")
         constants = Constants.vsWindowKindObjectBrowser;
     Project dteProject = FindProject(uiHierarchyItem);
     ProjectElement activeProject = CodeRush.Language.LoadProject(dteProject);
     if (activeProject != null) {
         var projectLoader = new ProjectLoader();
         var selectedAssemblyReferences = activeProject.GetSelectedAssemblyReferences(constants).ToList();
         projectLoader.Load(selectedAssemblyReferences.ToList(), NotifyOnNotFound);
     } else {
         throw new NotImplementedException();
     }
 }
Ejemplo n.º 60
0
 private async void OnRefreshListExecute(object sender, ExecuteEventArgs args)
 {
     var dir = this.viewModelWrapper.CurrentDirectory;
     if (dir != null)
         await dir.OnRefreshAsync(this, this.progress);
 }