Ejemplo n.º 1
0
        private void btnCommands_Click(object sender, EventArgs e)
        {
            CommandForm cf = new CommandForm();

            cf.Show();
            Hide();
        }
Ejemplo n.º 2
0
 private void CommandMainForm_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Escape)
     {
         CommandForm.Close();
     }
 }
Ejemplo n.º 3
0
        public LockShipButton(int flid, CommandForm par)
        {
            fleetid = flid;
            form    = par;

            Click += new EventHandler(CommandButtonClick);
        }
Ejemplo n.º 4
0
 public commandEditor(CommandForm argControl, CommandLoaders.Command argCommand, MainWindow argMainWindow)
 {
     mainWindow    = argMainWindow;
     parentControl = argControl;
     command       = argCommand;
     InitializeComponent();
 }
Ejemplo n.º 5
0
        public async Task <IActionResult> Execute(CommandForm form)
        {
            var command = new Command
            {
                OperatorId = form.OperatorId,
                Ip         = form.Ip,
                Content    = form.Command
            };

            string content;

            await using (var stream = new MemoryStream())
            {
                command.WriteTo(stream);
                content = Encoding.UTF8.GetString(stream.ToArray());
            }

            var pipelineFilter = new CommandLinePipelineFilter
            {
                Decoder = new PackageDecoder()
            };

            var client  = new EasyClient <PackageInfo>(pipelineFilter).AsClient();
            var address = IPAddress.Parse(_serverIp);

            if (!await client.ConnectAsync(new IPEndPoint(address, _serverPort)))
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, "Failed to connect to the server."));
            }

            await client.SendAsync(Encoding.UTF8.GetBytes($"{CommandKey.Connect} {ClientType.Short.ToString()}{Package.Terminator}"));

            await client.SendAsync(Encoding.UTF8.GetBytes($"{CommandKey.Execute} {content}{Package.Terminator}"));

            while (true)
            {
                var p = await client.ReceiveAsync();

                if (p == null)
                {
                    return(StatusCode((int)HttpStatusCode.InternalServerError, "Connection dropped."));
                }

                if (!string.IsNullOrWhiteSpace(p.Content) && p.Content.Equals("Started", StringComparison.OrdinalIgnoreCase))
                {
                    await client.CloseAsync();

                    return(Ok(form.OperatorId));
                }
            }
        }
Ejemplo n.º 6
0
        protected virtual void Terminate()
        {
            _bIsRunning         = false;
            _controlDef.Pressed = false;

            if (CommandForm != null)
            {
                CommandForm.Close();
            }

            CommandForm = null;

            InteractionManager.Terminate();
        }
Ejemplo n.º 7
0
 public override void Run()
 {
     // MessageBox.Show("" + Plugin.FuncItems.Items[this.ScriptId]._cmdID);
     if (form == null) {
         form =  new CommandForm { BackColor = Color.Aqua };
     }
     if (form.Visible) {
         form.setFocus();
     }
     else {
         form.Show();
         form.setFocus();
     }
 }
Ejemplo n.º 8
0
 protected override bool RunDialog(IntPtr hwndOwner)
 {
     using (CommandForm frm = new CommandForm())
     {
         frm.Command   = this.Command;
         frm.Arguments = this.Arguments;
         bool flag = frm.ShowDialog() == DialogResult.OK;
         if (flag)
         {
             this.Command   = frm.Command;
             this.Arguments = frm.Arguments;
         }
         return(flag);
     }
 }
Ejemplo n.º 9
0
 private void DisplayForm()
 {
     if (CommandForm != null)
     {
         if (CommandForm.Visible)
         {
             CommandForm.Focus();
         }
         else
         {
             if (DisplayFormModal)
             {
                 CommandForm.ShowDialog(new WindowWrapper((IntPtr)Application.MainFrameHWND));
             }
             else
             {
                 CommandForm.Show(new WindowWrapper((IntPtr)Application.MainFrameHWND));
             }
         }
     }
 }
Ejemplo n.º 10
0
        public Result Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements)
        {
            application = commandData.Application.Application;
            doc         = commandData.Application.ActiveUIDocument.Document;
            StoreOriginalVisibility(doc.ActiveView);

            CommandForm commandForm = new CommandForm();

            if (DialogResult.OK == commandForm.ShowDialog())
            {
                analysisCat = commandForm.SelectedAnalysisCategory;
                commandForm.Close();

                mainForm = new MainForm(doc, analysisCat);
                if (mainForm.FoundStyles)
                {
                    if (DialogResult.OK == mainForm.ShowDialog())
                    {
                        DisplayManinForm();
                    }
                }
            }
            return(Result.Succeeded);
        }
Ejemplo n.º 11
0
        Result IExternalCommand.Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements)
        {
            try
            {
                m_app          = commandData.Application;
                m_doc          = m_app.ActiveUIDocument.Document;
                iniDataManager = new INIDataManager(m_app);

                if (iniDataManager.FindINI())
                {
                    TaskDialog taskdialog = new TaskDialog("BCF Reader");
                    taskdialog.MainInstruction   = "Open a BCF file.";
                    taskdialog.MainContent       = "Some bcf files have ever saved in this Revit project.\n You can open a new BCF file or choose a linked file on the file lists.";
                    taskdialog.AllowCancellation = true;
                    taskdialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, "Open a new BCF file.");
                    taskdialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, "Select a linked BCF file.");
                    iniDataManager.ReadINI();//collect reference data into referencedictionary

                    TaskDialogResult tResult = taskdialog.Show();
                    if (TaskDialogResult.CommandLink1 == tResult)
                    {
                        bcfFile = OpenBCF(iniDataManager.MasterFilePath);
                    }
                    else if (TaskDialogResult.CommandLink2 == tResult)
                    {
                        BcfListForm bcfForm = new BcfListForm();
                        bcfForm.RefDictionary = iniDataManager.RefDictionary;
                        bcfForm.DisplayBcfFiles();
                        if (DialogResult.OK == bcfForm.ShowDialog())
                        {
                            bcfFile = bcfForm.BCFPath;
                        }
                    }
                    iniDataManager.SelectedFilePath = bcfFile;
                    if (File.Exists(bcfFile))
                    {
                        commandForm = new CommandForm(m_app, bcfFile, iniDataManager);
                        commandForm.ShowDialog();
                    }
                    else if (bcfFile == null)
                    {
                    }
                    else
                    {
                        MessageBox.Show("BCF file dose not exist.\n" + bcfFile, "File Not Found", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else if (null != iniDataManager.MasterFilePath)
                {
                    bcfFile = OpenBCF(iniDataManager.MasterFilePath);
                    iniDataManager.SelectedFilePath = bcfFile;
                    if (null != bcfFile)
                    {
                        commandForm = new CommandForm(m_app, bcfFile, iniDataManager);
                        commandForm.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("This tool Cannot open the BCF file. Please select an appropriate file. \n" + ex.Message, "Failure: Opening BCF file", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            return(Result.Succeeded);
        }
Ejemplo n.º 12
0
        public LockShipButton(int flid, CommandForm par)
        {
            fleetid = flid;
            form = par;

            Click += new EventHandler(CommandButtonClick);
        }