protected override void OnExecute(Command command, ExecutionContext context, System.Drawing.Rectangle buttonRect)
        {
            double lengthConversion = ActiveWindow.Units.Length.ConversionFactor;

            bool isImperial = Booleans[Resources.IsImperial].Value;
            bool isInternal = Booleans[Resources.ThreadIsInternal].Value;

            double pitch = isImperial ? (Const.inches / Values[Resources.ThreadPitch].Value) : (1E-3 * Values[Resources.ThreadPitch].Value);
            double angle = Values[Resources.ThreadAngle].Value * Math.PI / 180;

            Body[] bodies = SpaceClaimExtensions.GetAllSelectedIDesignFaces(Window.ActiveWindow)
                .Where(f => f.Shape.Geometry is Cylinder)
                .Select(f => f.Master.Parent.Shape.CopyFaces(new[] { f.Master.Shape }))
                .Select(b => b.Faces.First())
                .Select(f => CreateThreads(f, pitch, angle, isInternal))
                .ToArray();

            Part part = Window.ActiveWindow.Scene as Part;
            foreach (Body body in bodies)
                DesignBody.Create(part, Resources.ThreadStructureText, body);

            Settings.Default.IsImperial = isImperial;
            Settings.Default.IsInternal = isInternal;
            Settings.Default.Pitch = isImperial ? 0.0254 / pitch : pitch / 1E3;
            Settings.Default.Angle = angle * 180 / Math.PI;

            Settings.Default.Save();
        }
            // Command cmd = Command.Parse("1,a->b,R/L/N,0");
            public static Command Parse(string commandString)
            {
                Command command = new Command();

                if (commandString == null)
                {
                    throw new ArgumentNullException("commandString");
                }

                string[] commandParts = commandString.Split(new string[] { "->" }, StringSplitOptions.RemoveEmptyEntries);

                if (commandParts.Length < 2)
                {
                    throw new FormatException("Invalid command string format. Command parts separator not found.");
                }

                string[] leftParams = commandParts[0].Split(',');

                if (leftParams.Length < 2)
                {
                    throw new FormatException("Invalid command string format. Missing some command's left part parameters.");
                }

                string[] rightParams = commandParts[1].Split(',');

                if (rightParams.Length < 3)
                {
                    throw new FormatException("Invalid command string format. Missing some command's right part parameters.");
                }

                try
                {
                    command.InitialState = int.Parse(leftParams[0]);
                    command.InitialValue = char.Parse(leftParams[1]);

                    command.FinalValue = char.Parse(rightParams[0]);
                    command.FinalState = int.Parse(rightParams[2]);

                    switch (char.Parse(rightParams[1]))
                    {
                        case 'R':
                            command.Move = Directions.Right;
                            break;
                        case 'L':
                            command.Move = Directions.Left;
                            break;
                        case 'N':
                            command.Move = Directions.NoMotion;
                            break;
                        default:
                            throw new FormatException("Invalid command string format. Invalid direction.");
                    }
                }
                catch (Exception e)
                {
                    throw new FormatException("Invalid command string format.", e);
                }

                return command;
            }
        protected override void OnExecute(Command command, System.Drawing.Rectangle buttonRect)
        {
            base.OnExecute(command, buttonRect);

            foreach (Point point in controlForm.CalibrationPoints) {
                DesignBody desBody = ShapeHelper.CreateSphere(point, 0.1, part);
                desBody.Layer = referenceLayer;
            }

            foreach (VideoForm videoForm in controlForm.VideoForms) {
                Point point = videoForm.TrackingCamera.GetLine(PointUV.Origin).Evaluate(0.2).Point;
                DesignBody desBody = ShapeHelper.CreateSphere(point, 0.1, part);
                desBody.Layer = referenceLayer;

                foreach (PointUV pointUV in videoForm.TrackingCamera.CalibrationPoints) {
                    point = videoForm.TrackingCamera.GetLine(pointUV).Evaluate(0.2).Point;
                    //desBody = ShapeHelper.CreateSphere(point, 0.1, part);
                    //desBody.Layer = referenceLayer;
                    var desCurve = DesignCurve.Create(part, CurveSegment.Create(PointCurve.Create(point)));
                    desCurve.Layer = referenceLayer;
                }

                for (int i = 0; i < videoForm.Size.Width; i += videoForm.Size.Width / 12) {
                    for (int j = 0; j < videoForm.Size.Height; j += videoForm.Size.Height / 12) {
                        Line line = videoForm.TrackingCamera.GetLine(PointUV.Create(i, j));
                        var curveSegment = CurveSegment.Create(line, Interval.Create(-3, 6));
                        var desCurve = DesignCurve.Create(part, curveSegment);
                        desCurve.Layer = referenceLayer;
                    }
                }
            }
        }
 private bool AddCommand(Command c)
 {
     if (c == null)
     {
         DebugLog("WARNING: Cannot use NULL command");
         return false;
     }
     string cName = c.Name;
     if (string.IsNullOrEmpty(cName))
     {
         DebugLog("WARNING: Cannot use no-name command " + c.GetType());
         return false;
     }
     if (cName.StartsWith("!"))
     {
         //DebugLog("WARNING: Skipping command " + cName);
         return false;
     }
     if (c.Parameters == null)
     {
         // DebugLog("WARNING: Skipping non-paramerized command " + cName);
         return false;
     }
     int i = 0;
     while (i < c.Parameters.Parameters.Length)
     {
         Type from = (Type)c.Parameters.Parameters[i].SourceType;
         Type use = (Type)c.Parameters.Parameters[i].DestinationType;
         AddCommand(c, from, use);
         i++;
     }
     return true;
 }
 public void AddCommand(string commandName, Command cmd)
 {
     Button item = new Button();
     item.Text = commandName;
     item.Click += delegate {  cmd(); };
     theAmazingLayout.Controls.Add(item);
 }
 public ButtonCommandBinding(Button button, Command command)
 {
     button.Click += (o, e) =>
     {
         command.run();
     };
 }
        protected override void OnExecute(Command command, ExecutionContext context, System.Drawing.Rectangle buttonRect)
        {
            sweepAngle = Values[Resources.LenticularSweepAngle].Value * Math.PI / 180;
            interlaceCount = (int) Values[Resources.LenticularInterlaceCount].Value;
            interlaceWidth = (int) Values[Resources.LenticularInterlaceWidth].Value;

            SaveFileDialog dialog = new SaveFileDialog();
            dialog.Filter = "PNG Files (*.png)|*.png";
            DialogResult result = dialog.ShowDialog();

            if (result != DialogResult.OK)
                return;

            fileName = dialog.FileName;

            activeWindow = Window.ActiveWindow;
            originalWindowTrans = activeWindow.Projection;
            screenY = Line.Create(Point.Origin, originalWindowTrans.Inverse * Direction.DirY);

            string file = GetEnumeratedFileName(0);
            activeWindow.Export(WindowExportFormat.Png, file);
            Bitmap bitmap = (Bitmap) Bitmap.FromFile(file);

            width = bitmap.Width;
            height = bitmap.Height;
        }
        protected void CommitEditCommand()
        {
            try {
                if (incomingCommandTextBox.Text.Length == 0)
                    throw new Exception("Please enter an Incoming Command.");

                if (_controller.Commands.Where(i => i.Key == incomingCommandTextBox.Text).Count() > 0)
                    throw new DuplicateNameException("There already exists a Command with that Incoming Command. Choose a different string.");

                if (!File.Exists(targetTextBox.Text))
                    throw new FileNotFoundException("The Target cannot be found.");

                Command command = new Command
                {
                    IncomingCommand = incomingCommandTextBox.Text,
                    Target = targetTextBox.Text,
                    Arguments = argumentsTextBox.Text,
                    StartInDirectory = startInTextBox.Text
                };

                _controller.Commands.Add(command);

                LoadCommandsListView();
                DisableEditCommand();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
 private void button1_Click(object sender, EventArgs e)
 {
     var c = new Command();
     toReturn.Add(c);
     prpInCreation.SelectedObject = toReturn.Last();
     CommandList();
 }
        protected override void OnExecute(Command command, ExecutionContext context, System.Drawing.Rectangle buttonRect)
        {
            double surfaceDeviation = Values[Resources.TesselateSurfaceDeviationText].Value / ActiveWindow.Units.Length.ConversionFactor;
            double angleDeviation = Values[Resources.TesselateAngleDeviationText].Value / ActiveWindow.Units.Angle.ConversionFactor;

            ICollection<Face> faces = null;
            IDesignBody iDesignBody = Window.ActiveWindow.ActiveContext.SingleSelection as IDesignBody;
            if (iDesignBody != null)
                faces = (iDesignBody.Master.Shape as Body).Faces;
            else {
                ICollection<IDesignFace> iDesignFaces = Window.ActiveWindow.ActiveContext.GetSelection<IDesignFace>();
                foreach (IDesignFace iDesignFace in iDesignFaces) {
                    iDesignBody = iDesignFace.GetAncestor<DesignBody>();
                    continue; // TBD: handle multiple selection of faces across different DesignBodies
                }

                if (iDesignBody != null) {
                    List<Face> modelerFaces = new List<Face>();
                    foreach (DesignFace designFace in iDesignFaces) {
                        if (designFace.GetAncestor<DesignBody>() == iDesignBody)
                            modelerFaces.Add(designFace.Shape as Face);
                    }
                    if (modelerFaces.Count > 0)
                        faces = modelerFaces;
                }
                else
                    return;
            }

            iDesignBody.SetVisibility(null, false);
            Body body = iDesignBody.Shape as Body;

            IDictionary<Face, FaceTessellation> tessellationMap = body.GetTessellation(faces, FacetSense.RightHanded, new TessellationOptions(surfaceDeviation, angleDeviation));

            Body testfacetBody = null;
            List<Body> facetBodies = new List<Body>();
            Point[] points = new Point[3];

            foreach (FaceTessellation faceTessellation in tessellationMap.Values) {
                IList<FacetVertex> vertices = faceTessellation.Vertices;
                foreach (FacetStrip facetStrip in faceTessellation.FacetStrips) {
                    foreach (Facet facet in facetStrip.Facets) {
                        points[0] = vertices[facet.Vertex0].Position;
                        points[1] = vertices[facet.Vertex1].Position;
                        points[2] = vertices[facet.Vertex2].Position;

                        testfacetBody = ShapeHelper.CreatePolygon(points, null, 0);
                        if (testfacetBody != null)
                            facetBodies.Add(testfacetBody);
                    }
                }
            }

            // when the topology has holes (e.g. an annulus made with one surface), non-manifold vertices can occur when merging triangles around the hole.  The workaround is to merge the fragment lumps.
            facetBodies = new List<Body>(facetBodies.TryUnionBodies());
            facetBodies = new List<Body>(facetBodies.TryUnionBodies());
            foreach (Body facetBody in facetBodies)
                DesignBody.Create(iDesignBody.GetAncestor<Part>(), "Tesselation", facetBody);
        }
 public UnicornConnectionViewModel(UnicornConnection connection)
 {
     _connection = connection;
     TestConnection = new Command(ExecuteTestConnection, () => !ShowProgressBar);
     Save = new Command(ExecuteSave, () => !ShowProgressBar);
     Install = new Command(ExecuteInstall, () => !ShowProgressBar);
     DownloadPackage = new Command(ExecuteDownloadPackage, () => !ShowProgressBar);
 }
Beispiel #12
0
        public CategoryItem(string name, string description, Command command) 
            : this(name, description)
        {
            if (command == null) 
                throw new ArgumentNullException("command");

            control = new CategoryItemCommandControl(this, command);
        }
Beispiel #13
0
        private void btn_Accept_Click(object sender, EventArgs e)
        {
            //using client controller to save the new Command into the db

            clientController.insertCommandIntoDb(command);
            command = null;
            this.Close();
        }
Beispiel #14
0
        public ReportCommand(Command command, ClientController clientController)
        {
            InitializeComponent();
            this.command = command;
            this.clientController = clientController;

            init(command);
        }
Beispiel #15
0
        protected static void AssignID(Command cmd) {
            lock(internalSyncObject) {
                int icmd;

                if (null == cmds) {
                    cmds = new Command[20];
                    icmd = 0;
                }
                else {
                    Debug.Assert(cmds.Length > 0, "why is cmds.Length zero?");
                    Debug.Assert(icmdTry >= 0, "why is icmdTry negative?");

                    int icmdLim = cmds.Length;

                    if (icmdTry >= icmdLim)
                        icmdTry = 0;

                    // First look for an empty slot (starting at icmdTry).
                    for (icmd = icmdTry; icmd < icmdLim; icmd++)
                        if (null == cmds[icmd]) goto FindSlotComplete;
                    for (icmd = 0; icmd < icmdTry; icmd++)
                        if (null == cmds[icmd]) goto FindSlotComplete;

                    // All slots have Command objects in them. Look for a command
                    // with a null referent.
                    for (icmd = 0; icmd < icmdLim; icmd++)
                        if (null == cmds[icmd].Target) goto FindSlotComplete;

                    // Grow the array.
                    icmd = cmds.Length;
                    icmdLim = Math.Min(idLim - idMin, 2 * icmd);

                    if (icmdLim <= icmd) {
                        // Already at maximal size. Do a garbage collect and look again.
                        GC.Collect();
                        for (icmd = 0; icmd < icmdLim; icmd++) {
                            if (null == cmds[icmd] || null == cmds[icmd].Target)
                                goto FindSlotComplete;
                        }
                        throw new ArgumentException(SR.GetString(SR.CommandIdNotAllocated));
                    }
                    else {
                        Command[] newCmds = new Command[icmdLim];
                        Array.Copy(cmds, 0, newCmds, 0, icmd);
                        cmds = newCmds;
                    }
                }

FindSlotComplete:

                cmd.id = icmd + idMin;
                Debug.Assert(cmd.id >= idMin && cmd.id < idLim, "generated command id out of range");

                cmds[icmd] = cmd;
                icmdTry = icmd + 1;
            }
        }
    /// <summary>
    /// Adds the command.
    /// </summary>
    /// <param name="identifier">The identifier.</param>
    /// <param name="text">The text to appear as the command's text.</param>
    /// <param name="eventHandler">The event handler.</param>
    private void AddCommand(string identifier, string text, EventHandler eventHandler)
    {
      ICommandBar commandBar = this.commandBarManager.CommandBars[identifier];

      Command command = new Command();
      command.CommandBar = identifier;
      command.Separator = commandBar.Items.AddSeparator();
      command.Button = commandBar.Items.AddButton(text, eventHandler);
      this.commands.Add(command);
    }
Beispiel #17
0
 public ITreeBranch add_child(string name, ApplicationIcon icon, Command command)
 {
     var new_node = new TreeNode(name)
                        {
                            ImageKey = icon.name_of_the_icon,
                            SelectedImageKey = icon.name_of_the_icon
                        };
     node.Nodes.Add(new_node);
     return new TreeBranch(new_node, command);
 }
 private void ParseCommand(Command header, object[] @params)
 {
     switch (header)
     {
         case Command.Message:
             string text = (string)@params[1];
             //Casting params(1) to typeof string
             HandleMessagePacket(text);
             break;
     }
 }
Beispiel #19
0
 private void init(Command command)
 {
     txtFromCity.Text = clientController.getCityName(command.StartCityId);
     txtToCity.Text = clientController.getCityName(command.DestCityId);
     txtKgPerPallet.Text = command.Ware.WeightPerPallet.ToString();
     txtNrOfPallets.Text = command.Ware.NrOfPallets.ToString();
     txtDescription.Text = command.Ware.Description;
     txtPickUpDate.Text = command.StartTime.ToString();
     txtDeliveryDate.Text = DateTime.Today.AddDays(4).ToString();// excepting the worst case
     txtPrice.Text = command.CommandPrice.ToString();
 }
        /// <summary>
        /// Adds the specified command.
        /// </summary>
        /// <param name="command">The command to add.</param>
        public void AddCommand(Command command)
        {
            //	Ensure that this is not a duplicate.  In debug mode, assert that this is true.
            //	In release mode, fail silently (replacing the existing command) so as not to take
            //	down a running system.
            Debug.Assert(!commandTable.Contains(command.Identifier), "Duplicate command encountered.", String.Format("Command {0} already exists.", command.Identifier));

            //	Add the command to the command table.
            commandTable[command.Identifier] = command;

            //	Add the shortcut for the command to the shortcut table.
            AddShortcut(command);
        }
        /// <summary>
        /// Removes the specified command.
        /// </summary>
        /// <param name="command">The command to remove.</param>
        public void RemoveCommand(Command command)
        {
            //	Ensure that the command is in the table.  In debug mode, assert that this is true.
            //	In release mode, fail silently (replacing the existing command) so as not to take
            //	down a running system.
            Debug.Assert(commandTable.Contains(command.Identifier), "Command not found.", String.Format("Command {0} does not exist.", command.Identifier));

            //	Remove the command from the command table.
            commandTable.Remove(command.Identifier);

            //	Remove the shortcut for the command from the shortcut table.
            RemoveShortcut(command);
        }
        /// <summary>
        /// Displays the command item.
        /// </summary>
        /// <param name="command">The command.</param>
        public void DisplayCommandItem(Command command)
        {
            this.listProperties.BeginUpdate();
            this.listProperties.Items.Clear();

            this.listProperties.Items.Add(new ListViewItem(new string[] { "Command Id", command.Id }));
            this.listProperties.Items.Add(new ListViewItem(new string[] { "Command type", command.CommandType.ToString() }));
            this.listProperties.Items.Add(new ListViewItem(new string[] { "Command arguments", GetCommandArgs(command.Arguments) }));
            this.listProperties.Items.Add(new ListViewItem(new string[] { "Find method", command.FindMethod.MethodType.ToString() }));
            this.listProperties.Items.Add(new ListViewItem(new string[] { "Find arguments", GetCommandArgs(command.FindMethod.Arguments) }));

            this.listProperties.EndUpdate();
        }
        protected override void OnExecute(Command command, ExecutionContext context, System.Drawing.Rectangle buttonRect)
        {
            if (excelWorksheet == null)
                excelWorksheet = new ExcelWorksheet();

            Window activeWindow = Window.ActiveWindow;

            double length = 0;
            foreach (ITrimmedCurve iTrimmedCurve in activeWindow.GetAllSelectedITrimmedCurves()) {
                length += iTrimmedCurve.Length;
            }

            excelWorksheet.SetCell(row++, 1, length);
        }
		public WinFormsUserControl()
		{
			InitializeComponent();

			backgroundCommand = new Command();

			backgroundWorker = new BackgroundWorker();
			backgroundWorker.WorkerSupportsCancellation = true;
			backgroundWorker.DoWork += new DoWorkEventHandler(backgroundWorker_DoWork);
			backgroundWorker.RunWorkerAsync(Handle);
			components.Add(backgroundWorker);

			IsNotifyResizes = true;
		}
        /// <summary>
        /// Initializes a new instance of the CommandMenuItemEventBridge class.
        /// </summary>
        /// <param name="command">The Command for this Command to MenuItem event bridge.</param>
        /// <param name="menuItem">The MenuItem for this Command to MenuItem event bridge.</param>
        public CommandMenuItemEventBridge(Command command, MenuItem menuItem)
        {
            //	Set the command.
            this.command = command;

            //	Set the menu item.
            this.menuItem = menuItem;

            //	Add event handlers for the command events.
            command.EnabledChanged += new EventHandler(command_EnabledChanged);

            //	Add event handlers for the menu item events.
            menuItem.Click += new EventHandler(menuItem_Click);
        }
        private CommandToolStripMenuItem(Command command, bool inContextMenu, string text, Image image)
            : base(text, image)
        {
            //Registering these event handlers from the constructor used by the program initialiser eg.
            //when command == null consumes unecessary memory
            if(command != null)
            {
                base.DropDownOpening += CommandToolStripMenuItem_DropDownOpening;
                DropDown.Opening += DropDown_Opening;
            }

            Font = Program.DefaultFont;
            _inContextMenu = inContextMenu;
            Command = command;
            Update();
        }
			public override bool RegisterGUI(Command vsCommand, CommandBar vsCommandbar, bool toolBarOnly)
			{
				if(toolBarOnly)
				{
					_RegisterGUIBar(vsCommand, vsCommandbar);
				}
				else
				{
					_RegisterGuiContext(vsCommand, "Project");
					_RegisterGuiContext(vsCommand, "Item");
					_RegisterGuiContext(vsCommand, "Easy MDI Document Window");
					_RegisterGuiContext(vsCommand, "Cross Project Multi Item");
					_RegisterGuiContext(vsCommand, "Cross Project Multi Project");
				}
				return true;
			}
        private void addRowToCommandDataGridView(Command c)
        {
            DataGridViewRow directoryDataGridViewRow = new DataGridViewRow();

            DataGridViewTextBoxCell nameDataGridViewTextBoxCell = new DataGridViewTextBoxCell();
            directoryDataGridViewRow.Cells.Add(nameDataGridViewTextBoxCell);
            nameDataGridViewTextBoxCell.Value = c.getName();
            nameDataGridViewTextBoxCell.ReadOnly = false;

            DataGridViewTextBoxCell commandDataGridViewTextBoxCell = new DataGridViewTextBoxCell();
            directoryDataGridViewRow.Cells.Add(commandDataGridViewTextBoxCell);
            commandDataGridViewTextBoxCell.Value = c.getCommand();
            commandDataGridViewTextBoxCell.ReadOnly = false;

            preloadedConfigurationCommandsDataGridView.Rows.Add(directoryDataGridViewRow);
            preloadedConfigurationCommandsDataGridView.EditMode = DataGridViewEditMode.EditOnKeystroke;
        }
        /*#--------------------------------------------------------------------------#*/
        /*  Description: FiddleYardAppRun()
         *               Constructor
         *
         *
         *  Input(s)   :
         *
         *  Output(s)  :
         *
         *  Returns    :
         *
         *  Pre.Cond.  :
         *
         *  Post.Cond. :
         *
         *  Notes      :
         */
        /*#--------------------------------------------------------------------------#*/
        public FiddleYardAppRun(FiddleYardIOHandleVariables FYIOHandleVar, iFiddleYardIOHandle iFYIOH, FiddleYardApplicationVariables FYAppVar, FiddleYardMip50 FYMIP50, Log2LoggingFile FiddleYardApplicationLogging)
        {
            m_iFYIOH = iFYIOH;
            m_FYIOHandleVar = FYIOHandleVar;
            m_FYAppVar = FYAppVar;
            m_FYMIP50 = FYMIP50;
            m_FYAppLog = FiddleYardApplicationLogging;
            FYAppTrainDrive = new FiddleYardAppTrainDrive(m_FYIOHandleVar, m_iFYIOH, m_FYAppVar, m_FYMIP50, m_FYAppLog);
            State_Machine = State.Idle;

            Message Msg_TrackPower15VDown = new Message("TrackPower15VDown", " TrackPower15VDown ", (name, log) => SetMessage(name, 0, log)); // initialize and subscribe readback action, Message
            m_FYIOHandleVar.TrackPower15VDown.Attach(Msg_TrackPower15VDown);
            Sensor Sns_TrackPower15V = new Sensor("15VTrackPower", " 15V Track Power ", 0, (name, val, log) => SetMessage(name, val, log)); // initialize and subscribe sensors
            m_FYIOHandleVar.TrackPower15V.Attach(Sns_TrackPower15V);
            Command Act_Collect = new Command("Collect", (name) => SetMessage(name, 0, "")); // initialize and subscribe Commands
            m_FYAppVar.FormCollect.Attach(Act_Collect);
        }
        public static void Add(Command c)
        {
            if (commandMap.ContainsKey(c.name)) {
                Log.Error("Command \""+c.name+"\" already registered.");
                return;
            }

            if (c.key != Keys.None) {
                if (keyMap.ContainsKey(c.key))
                    Log.Error("Duplicate key binding '" + c.key + "'. Already assigned to \"" + keyMap[c.key].name + "\"");
                else
                    keyMap[c.key] = c;
            }

            commandMap[c.name] = c;
            MainForm.Instance.AddCommandEntry(c);
        }