예제 #1
0
        private void EditCommand()
        {
            // Make sure at least one item is selected
            if (lstAvailableActions.SelectedItems.Count == 0)
            {
                return;
            }

            // Get first item selected, associated action, and selected application
            CommandInfo selectedItem    = (CommandInfo)lstAvailableActions.SelectedItem;
            var         selectedCommand = selectedItem.Command;

            if (selectedCommand == null)
            {
                return;
            }

            CommandDialog commandDialog = new CommandDialog(selectedCommand, selectedItem.Action);
            var           result        = commandDialog.ShowDialog();

            if (result != null && result.Value)
            {
                int index         = CommandInfos.IndexOf(selectedItem);
                var newActionInfo = CommandInfo.FromCommand(selectedCommand, selectedItem.Action);
                CommandInfos[index] = newActionInfo;
                RefreshActionGroup(newActionInfo.Action);
                SelectCommands(newActionInfo);
            }
        }
예제 #2
0
        private void EditCommand()
        {
            // Make sure at least one item is selected
            if (lstAvailableActions.SelectedItems.Count == 0)
            {
                return;
            }

            // Get first item selected, associated action, and selected application
            CommandInfo selectedItem    = (CommandInfo)lstAvailableActions.SelectedItem;
            var         selectedAction  = selectedItem.Action;
            var         selectedCommand = selectedItem.Command;

            if (selectedCommand == null)
            {
                return;
            }

            CommandDialog commandDialog = new CommandDialog(selectedCommand, selectedAction);
            var           result        = commandDialog.ShowDialog();

            if (result != null && result.Value)
            {
                int index = selectedAction.Commands.ToList().IndexOf(selectedCommand);
                selectedAction.RemoveCommand(selectedCommand);
                selectedAction.InsertCommand(index, selectedCommand);
            }
        }
예제 #3
0
 public bool ChangeCommand(ShellLink shellLink)
 {
     using (CommandDialog dlg = new CommandDialog())
     {
         dlg.Command   = shellLink.TargetPath;
         dlg.Arguments = shellLink.Arguments;
         if (dlg.ShowDialog() != DialogResult.OK)
         {
             return(false);
         }
         shellLink.TargetPath = dlg.Command;
         shellLink.Arguments  = dlg.Arguments;
         shellLink.Save();
         return(true);
     }
 }
예제 #4
0
 public bool ChangeCommand(WshShortcut shortcut)
 {
     using (CommandDialog dlg = new CommandDialog())
     {
         dlg.Command   = shortcut.TargetPath;
         dlg.Arguments = shortcut.Arguments;
         if (dlg.ShowDialog() != DialogResult.OK)
         {
             return(false);
         }
         shortcut.TargetPath = dlg.Command;
         shortcut.Arguments  = dlg.Arguments;
         shortcut.Save();
         return(true);
     }
 }
예제 #5
0
        async void DoSendCommandClick(object sender, ActionRequested how)
        {
            NodeBase      data = (NodeBase)(sender as ToolStripItem).Tag;
            CommandParams cPar = ctrl.PrepareSendCommand(data);

            if (cPar != null)
            {
                CommandDialog cdlg = new CommandDialog(cPar);
                if (cdlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                {
                    if (cPar.SBOrun)
                    {
                        string   sName = (cPar.CommandFlowFlag == CommandCtrlModel.Select_Before_Operate_With_Enhanced_Security) ? "SBOw" : "SBO";
                        NodeData d = (NodeData)data.Parent;
                        NodeData op = null, sel = null;
                        if (d != null)
                        {
                            if (d.Name == "SBOw" || d.Name == "SBO")
                            {
                                sName = "Oper";
                                sel   = (NodeData)data;
                            }
                            else
                            {
                                op = (NodeData)data;
                            }
                            NodeBase dd = d.Parent;
                            if (dd != null)
                            {
                                NodeData d2 = (NodeData)dd.FindChildNode(sName);
                                if (d2 != null)
                                {
                                    NodeData d3 = (NodeData)d2.FindChildNode("ctlVal");
                                    if (d3 != null)
                                    {
                                        if (op == null)
                                        {
                                            op = d3;
                                        }
                                        else
                                        {
                                            sel = d3;
                                        }
                                        ctrl.SendCommand(sel, cPar, how);
                                        await PutTaskDelay(cPar.SBOtimeout);

                                        ctrl.SendCommand(op, cPar, how);
                                    }
                                    else
                                    {
                                        Logger.getLogger().LogWarning("Cannot send SBO command sequence, ctlVal not found in " + d2.IecAddress);
                                    }
                                }
                                else
                                {
                                    Logger.getLogger().LogWarning("Cannot send SBO command sequence, " + sName + " not found in " + dd.IecAddress);
                                }
                            }
                            else
                            {
                                Logger.getLogger().LogWarning("Cannot send SBO command sequence, null parent of " + d.IecAddress);
                            }
                        }
                        else
                        {
                            Logger.getLogger().LogWarning("Cannot send SBO command sequence, null parent of " + data.IecAddress);
                        }
                    }
                    else
                    {
                        ctrl.SendCommand(data, cPar, how);
                    }
                }
            }
        }