コード例 #1
0
 private void SmartQuotesPlugInCommandExecuting(CommandExecutingEventArgs ea)
 {
     if (!ea.CancelDefault && ea.CommandName == "Edit.DeleteBackwards")
     {
         TextViewCaret caret = GetCaretInActiveFocusedView();
         if (caret != null)
         {
             if (this.settings.UseSmartDoubleQuotes 
                 && this.settings.DoubleQuotesEasyDelete
                 && caret.LeftChar == '\"' 
                 && caret.RightChar == '\"'
                 && CanExecuteFeature("Easy delete", "Deletes empty quotes and double quotes"))
             {
                 EasyDelete(caret, this.settings.DoubleQuotesUseTextFields);
                 return;
             }
             if (this.settings.UseSmartQuotes 
                 && this.settings.QuotesEasyDelete
                 && caret.LeftChar == '\'' 
                 && caret.RightChar == '\''
                 && CanExecuteFeature("Easy delete", "Deletes empty quotes and double quotes"))
             {
                 EasyDelete(caret, this.settings.QuotesUseTextFields);
                 return;
             }
         }
     }
 }
コード例 #2
0
 protected virtual void OnExecuting(CommandExecutingEventArgs e)
 {
     if (null != this.Executing)
     {
         this.Executing(this, e);
     }
 }
コード例 #3
0
 private void SmartQuotesPlugInCommandExecuting(CommandExecutingEventArgs ea)
 {
     if (!ea.CancelDefault && ea.CommandName == "Edit.DeleteBackwards")
     {
         TextViewCaret caret = GetCaretInActiveFocusedView();
         if (caret != null)
         {
             if (this.settings.UseSmartDoubleQuotes &&
                 this.settings.DoubleQuotesEasyDelete &&
                 caret.LeftChar == '\"' &&
                 caret.RightChar == '\"' &&
                 CanExecuteFeature("Easy delete", "Deletes empty quotes and double quotes"))
             {
                 EasyDelete(caret, this.settings.DoubleQuotesUseTextFields);
                 return;
             }
             if (this.settings.UseSmartQuotes &&
                 this.settings.QuotesEasyDelete &&
                 caret.LeftChar == '\'' &&
                 caret.RightChar == '\'' &&
                 CanExecuteFeature("Easy delete", "Deletes empty quotes and double quotes"))
             {
                 EasyDelete(caret, this.settings.QuotesUseTextFields);
                 return;
             }
         }
     }
 }
コード例 #4
0
        private void RadRichTextBox_CommandExecuting(object sender, CommandExecutingEventArgs e)
        {
            if (e.Command is SaveCommand)
            {
                e.Cancel = true;
                SaveDocument(); // A custom logic for saving document so you can change the properties of the Save File dialog.
            }

            if (e.Command is PasteCommand)
            {
                // Altering the PasteCommand to ensure only plain text is pasted in RadRichTextBox.
                // Obtain the content from the clipboard.
                RadDocument documentFromClipboard = ClipboardEx.GetDocument().ToDocument();

                TxtFormatProvider provider = new TxtFormatProvider();
                // Convert it to plain text.
                string plainText = provider.Export(documentFromClipboard);

                // Create a RadDocument instance from the plain text.
                RadDocument documentToInsert = provider.Import(plainText);
                // Set this document as a content to the clipboard.
                ClipboardEx.SetDocument(new DocumentFragment(documentToInsert));
            }

            if (e.Command is InsertTableCommand)
            {
                // Disable the possibility to insert tables into the document.
                MessageBox.Show("Inserting tables is not allowed.");
                e.Cancel = true;
            }
        }
コード例 #5
0
        protected void OnCommandExecuting(CommandExecutingEventArgs e)
        {
            var eh = this.CommandExecuting;

            if (eh != null)
            {
                eh(this, e);
            }
        }
コード例 #6
0
            protected virtual void OnExecuting(CommandExecutingEventArgs args)
            {
                var e = this.Executing;

                if (e != null)
                {
                    e(this, args);
                }
            }
コード例 #7
0
        /// <summary>
        /// Executes the command by relaying the call to the execute delegate specified in the constructor.
        /// </summary>
        /// <param name="parameter">The command parameter relayed to the execute delegate.</param>
        public override void Execute(object parameter)
        {
            var e = new CommandExecutingEventArgs(false, parameter, this);
            this.OnExecuting(e);

            if (!e.Cancel)
            {
                this.ExecuteDelegate(parameter);
                this.OnExecuted(parameter);
            }
        }
コード例 #8
0
        static void ForceNewVersion_Executing(object sender, CommandExecutingEventArgs e)
        {
            Command command = (Command)sender;

            isForcingNewVersion = !isForcingNewVersion;
            //if (!isForcingNewVersion)
            //    return;

            //foreach (Document doc in Window.AllWindows.Select(w => w.Document).Distinct())
            //    LockDocument(doc);
        }
コード例 #9
0
 private void RadRichTextBoxCommandExecuting(object sender, CommandExecutingEventArgs e)
 {
     if (e.Command == this.radRichTextBox.Commands.OpenDocumentCommand)
     {
         e.Cancel = true;
         this.OpenFile(e.CommandParameter);
     }
     else if (e.Command == this.radRichTextBox.Commands.SaveCommand)
     {
         e.Cancel = true;
         this.SaveFile(e.CommandParameter);
     }
 }
コード例 #10
0
        void animatePlayCommand_Execute(object sender, CommandExecutingEventArgs e)
        {
            Command command = (Command)sender;

            //for (int i = 0; i < 33; i++)
            //    animator.Advance(1);

            if (Animation.IsAnimating)
            {
                Animation.IsPaused = !Animation.IsPaused; // toggle Play/Pause
            }
            else
            {
                Animation.Start(Resources.DistributeSpheresToolAnimationPlay, animator);
            }

            command.IsChecked = Animation.IsAnimating;
            command.Text      = Animation.IsAnimating ? Resources.DistributeSpheresToolAnimationPause : Resources.DistributeSpheresToolAnimationPlay;
        }
コード例 #11
0
        void createSphereCommand_Execute(object sender, CommandExecutingEventArgs e)
        {
            SphereSet sphereSet = SelectedSphereSet;

            if (sphereSet == null)
            {
                return;
            }

            Part sphereRootPart = Part.Create(Window.Document, "Spheres");

            Component.Create(Window.ActiveWindow.Scene as Part, sphereRootPart);
            Part innerSpherePart = Part.Create(Window.Document, "Inner Spheres");
            Part outerSpherePart = Part.Create(Window.Document, "Outer Spheres");

            Component.Create(sphereRootPart, innerSpherePart);
            Component.Create(sphereRootPart, outerSpherePart);

            Part spherePart = Part.Create(Window.Document, "Sphere");

            ShapeHelper.CreateSphere(Point.Origin, sphereSet.Radius * 2, spherePart);

            Body body = sphereSet.DesFace.Shape.Body;

            foreach (Point point in sphereSet.Positions)
            {
                bool isEdge = false;
                foreach (Edge edge in body.Edges.Where(edge => edge.Faces.Count == 1))
                {
                    if ((edge.ProjectPoint(point).Point - point).MagnitudeSquared() < (sphereSet.Radius * sphereSet.Radius))
                    {
                        isEdge = true;
                        break;
                    }
                }

                Component component = Component.Create(isEdge ? outerSpherePart : innerSpherePart, spherePart);
                component.Placement = Matrix.CreateTranslation(point.Vector);
            }
        }
コード例 #12
0
 private void CR_SmartGenerics_CommandExecuting(CommandExecutingEventArgs ea)
 {
     if (!CodeRush.Language.IsCSharp)
     {
         return;
     }
     if (!ea.CancelDefault && ea.CommandName == "Edit.DeleteBackwards")
     {
         TextViewCaret caret = GetCaretInActiveFocusedView();
         if (caret != null &&
             this.settings.UseSmartGenerics &&
             this.settings.SmartGenericsEasyDelete &&
             IsInsideGenerics() &&
             IsLeftTextEndedWithOpenGenericOperator(caret) &&
             IsRightTextStartedWithCloseGenericOperator(caret) &&
             CanExecuteFeature("Easy delete", "Deletes empty generics characters"))
         {
             EasyDelete(caret, this.settings.SmartGenericsUseTextFields);
             return;
         }
     }
 }
コード例 #13
0
 private void CR_SmartGenerics_CommandExecuting(CommandExecutingEventArgs ea)
 {
     if (!CodeRush.Language.IsCSharp)
     {
         return;
     }
     if (!ea.CancelDefault && ea.CommandName == "Edit.DeleteBackwards")
     {
         TextViewCaret caret = GetCaretInActiveFocusedView();
         if (caret != null
             && this.settings.UseSmartGenerics
             && this.settings.SmartGenericsEasyDelete
             && IsInsideGenerics()
             && IsLeftTextEndedWithOpenGenericOperator(caret)
             && IsRightTextStartedWithCloseGenericOperator(caret)
             && CanExecuteFeature("Easy delete", "Deletes empty generics characters"))
         {
             EasyDelete(caret, this.settings.SmartGenericsUseTextFields);
             return;
         }
     }
 }
コード例 #14
0
 void animateStepCommand_Execute(object sender, CommandExecutingEventArgs e)
 {
     animator.Advance(1);
 }
コード例 #15
0
 private void PlugIn1_CommandExecuting(CommandExecutingEventArgs ea)
 {
     // @SurlyDev: This is for you -- convert spaces to camel case on a paste...
     if (_ConvertingSpacesToCamelCase && ea.CommandName == "Edit.Paste")
         if (Clipboard.ContainsText())
         {
             string text = Clipboard.GetText();
             if (text.Length > 255)
                 return;
             char[] punctuation = { ' ', '/', '@', ':', '.' };
             string[] tokens = text.Split(punctuation, 255, StringSplitOptions.RemoveEmptyEntries);
             string newText = String.Empty;
             foreach (string token in tokens)
             {
                 if (token.Length > 1)
                     newText += char.ToUpper(token[0]).ToString() + token.Substring(1);
                 else if (token.Length > 0)
                     newText += char.ToUpper(token[0]).ToString();
             }
             Clipboard.SetText(newText);
         }
 }
コード例 #16
0
 void OnCommandExecuting(object sender, CommandExecutingEventArgs e)
 {
     e.Cancel = true;
 }
コード例 #17
0
ファイル: PlugIn1.cs プロジェクト: modulexcite/CR_MultiSelect
 private void PlugIn1_CommandExecuting(CommandExecutingEventArgs ea)
 {
     if (ea.CommandName == "Edit.Cut")
     {
         if (CodeRushPlaceholder.MultiSelect.SelectionExists(CodeRush.TextViews.Active))
         {
             Cut();
             ea.CancelDefault = true;
             ea.CancelEvent = true;
         }
     }
     else if (ea.CommandName == "Edit.Copy")
     {
         // Skorkin: Is there a way to determine the order in which an event is listened to? IOW priority.
         if (CodeRushPlaceholder.MultiSelect.SelectionExists(CodeRush.TextViews.Active))
         {
             Copy();
             ea.CancelDefault = true;
             ea.CancelEvent = true;
         }
     }
     else if (ea.CommandName == "Edit.Paste")
     {
         if (MultiSelect.IsOnClipboard())
         {
             Paste();
             ea.CancelDefault = true;
         }
     }
 }
コード例 #18
0
        static void c_Executing(object sender, CommandExecutingEventArgs e)
        {
            // Find the document and model in the active widnow:
            Document doc      = Window.ActiveWindow.Document;
            Part     rootPart = doc.MainPart;

            // File, where volumes will be written.
            System.IO.StreamWriter fff = new System.IO.StreamWriter(doc.Path + ".volumes");

            /* this loop is over all unique parts, i.e. Master parts.
             * fff.WriteLine("document.Parts");
             * foreach (Part p in doc.Parts)
             * {
             *  fff.WriteLine("{0}", p.DisplayName);
             * }
             *
             * fff.WriteLine("document.IParts");
             * foreach (IPart ipart in doc.MainPart.GetDescendants<IPart>())
             * {
             *  fff.WriteLine("{0} {1} in {2}", ipart.Master.DisplayName, ipart.Root, ipart.GetAncestor<IPart>().Master.DisplayName);
             * }
             */

            // fff.WriteLine("document.DesignBodies");
            foreach (IPart ipart in getAllParts(doc.MainPart))
            {
                foreach (IDesignBody ibody in ipart.Master.Bodies)
                {
                    string all_names = ibody.Master.Name;
                    IPart  p         = ipart;
                    while (p.Parent != null)
                    {
                        all_names = p.Master.DisplayName + " / " + all_names;
                        p         = p.GetAncestor <IPart>();
                    }
                    fff.WriteLine("{0}: {1}", all_names, ibody.Shape.Volume);
                }
                fff.WriteLine("");
            }


            /* check that rootPart is the model's root:
             * Debug.Assert(rootPart.Parent == null);
             * Debug.Assert(rootPart.Root == rootPart);
             *
             * // loop over all parts of the model:
             * foreach (IPart ipart in getAllParts(rootPart))
             * {
             *  // output component names
             *  fff.WriteLine("{0}:", ipart.Master.DisplayName);
             *
             *  // get names of all parents
             *  string all__names = ipart.Master.Name;
             *  string all_dnames = ipart.Master.DisplayName;
             *  IInstance cpart = ipart.Parent;
             *  // while (cpart != null)
             *  // {
             *      // all__names = cpart.Master.Name + '.' + all__names;
             *      // all_dnames = cpart.Master.DisplayName + '.' + all_dnames;
             *      // cpart = cpart.Parent;
             *  // }
             *
             *  double cvol = 0.0, v = 0.0; // volume of all bodies in the current component
             *  foreach (IDesignBody ib in ipart.Master.Bodies)
             *  {
             *      v = ib.Shape.Volume;
             *      fff.WriteLine("{0} {1}: {2}", all__names, ib.Master.Name, v);
             *      fff.WriteLine("{0} {1}: {2}", all_dnames, ib.Master.Name, v);
             *  }
             * } */
            MessageBox.Show(SpaceClaim.Api.V16.Application.MainWindow, "Output to " + doc.Path + ".volumes", "Volumes", MessageBoxButtons.OK);

            fff.Close();
        }
コード例 #19
0
        private static void c_Executing(object sender, CommandExecutingEventArgs e)
        {
            Window aw = Window.ActiveWindow;

            // section plane. It is not null only if sketch or section mode is on.
            Plane sP = aw.ActiveContext.SectionPlane;

            if (sP != null)
            {
                int sw = aw.Size.Width;
                int sh = aw.Size.Height;
                // get screen center, right-mid and upper mid
                System.Drawing.Point sm = new System.Drawing.Point((int)Math.Round(sw * 0.5), (int)Math.Round(sh * 0.5));
                System.Drawing.Point sr = new System.Drawing.Point(sw, sm.Y);
                System.Drawing.Point su = new System.Drawing.Point(sm.X, 1);
                // screen center projection onto section plane in model coordinates
                Point mm;
                if (sP.TryIntersectLine(aw.ActiveContext.GetCursorRay(sm), out mm))
                {
                    // get projections of right mid and upper mid and use these projections
                    // to define bas vectors.
                    Point mr, mu;
                    sP.TryIntersectLine(aw.ActiveContext.GetCursorRay(sr), out mr);
                    sP.TryIntersectLine(aw.ActiveContext.GetCursorRay(su), out mu);
                    Vector bx  = mr - mm;
                    Vector bz  = Vector.Cross(bx, mu - mm); // normal to section plane looking to us
                    Vector by  = Vector.Cross(bz, bx);
                    double ext = bx.Magnitude;
                    // rotate view to look perpendicular to section plane
                    double fe = ext * Math.Min(sw, sh) / Math.Max(sw, sh) * 2;
                    aw.SetProjection(Frame.Create(mm, bx.Direction, by.Direction), fe);

                    // generate string for clipboard
                    string f3 = " {0:G5} {1:G5} {2:G5} ";
                    string f1 = " {0:G5} ";
                    string pc = "";

                    // or command
                    pc  = "or";
                    pc += string.Format(f3, nullify(mm.X * cc), nullify(mm.Y * cc), nullify(mm.Z * cc));
                    // bas command
                    bx  = bx.Direction.UnitVector;
                    by  = by.Direction.UnitVector;
                    pc += "bas";
                    pc += string.Format(f3, nullify(bx.X), nullify(bx.Y), nullify(bx.Z));
                    pc += string.Format(f3, nullify(by.X), nullify(by.Y), nullify(by.Z));
                    // ext command
                    pc += "ext";
                    pc += string.Format(f1, ext * cc);

                    // tune formatting
                    pc = pc.Replace(",", ".");
                    pc = pc.Replace("E+000", " ");
                    pc = pc.Replace("E-000", " ");
                    pc = pc.Replace("E+00", "E+");
                    pc = pc.Replace("E-00", "E-");
                    pc = pc.Replace("E+0", "E+");
                    pc = pc.Replace("E-0", "E-");

                    // put to clipboard
                    ClipBoard.SetText(pc);
                }
                else
                {
                    SpaceClaim.Api.V16.Application.ReportStatus("Section plane exists but cannot intersect with cursor ray", StatusMessageType.Information, null);
                }
            }
            else
            {
                // try to read plot commands from clipboard
                Frame  fr;
                double ext;
                if (TryParseClipboard(out fr, out ext))
                {
                    // If clipboard parsed, add a new plane to the model
                    DatumPlane.Create(aw.Document.MainPart, "MCNP plot plane", Plane.Create(fr));
                }
                else
                {
                    SpaceClaim.Api.V16.Application.ReportStatus("Clipboard does not contain MCNP plot commands.", StatusMessageType.Warning, null);
                }
            }
        }
 void OnCommandExecuting(object sender, CommandExecutingEventArgs e)
 {
     e.Cancel = true;
 }