Example #1
0
        private void Commandlist_SelectedIndexChanged(object sender, EventArgs e)
        {
            Stream myStream = null;

            Byte[] buffer;
            string filename = "commands/";
            string str      = Commandlist.Items[Commandlist.SelectedIndex].ToString();

            string[] newstr = str.Split(' ');
            filename += newstr[0];
            filename += ".txt";
            try
            {
                myStream = File.OpenRead(filename);
                using (myStream)
                {
                    if (myStream.Length > 2 * 1024)
                    {
                        MessageBox.Show("文件有点大,换个小点的吧!");
                        myStream.Close();
                    }
                    buffer = new Byte[myStream.Length];
                    myStream.Read(buffer, 0, (int)myStream.Length);
                    str = System.Text.Encoding.Default.GetString(buffer);
                    string[] strarray = str.Split(' ');
                    str = String.Join(String.Empty, strarray);
                    CommandBox.Clear();
                    CommandBox.Text = str;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: 无法打开指定文件. Original error: " + ex.Message);
            }
        }
Example #2
0
        private void MenuBarEvent()
        {
            fNewTool.Click += (object sender, EventArgs e) =>
            {
                CommandBox.ClearText();
                tabView[Index].Dgv.DataSource = null;
            };
            F0_Open.Click        += (object sender, EventArgs e) => { OpenFileDialog(); };
            fOpenTool.Click      += (object sender, EventArgs e) => { OpenFileDialog(); };
            F0_Save.Click        += (object sender, EventArgs e) => { SaveFileDialog(false); };
            fSaveTool.Click      += (object sender, EventArgs e) => { SaveFileDialog(false); };
            F0_Overwrite.Click   += (object sender, EventArgs e) => { SaveFileDialog(true); };
            fOverwriteTool.Click += (object sender, EventArgs e) => { SaveFileDialog(true); };
            fOutputTool.Click    += (object sender, EventArgs e) => { OutputCsvFile(); };
            fCloseTool.Click     += (object sender, EventArgs e) => { closeBtn_Click(sender, e); };

            F0_Undo.Click     += (object sender, EventArgs e) => { CommandBox.Undo(); };
            eUndo.Click       += (object sender, EventArgs e) => { CommandBox.Undo(); };
            F0_Redo.Click     += (object sender, EventArgs e) => { CommandBox.Redo(); };
            eRedo.Click       += (object sender, EventArgs e) => { CommandBox.Redo(); };
            eCutTool.Click    += (object sender, EventArgs e) => { CommandBox.Cut(); };
            eCopyTool.Click   += (object sender, EventArgs e) => { CommandBox.Copy(); };
            ePasteTool.Click  += (object sender, EventArgs e) => { CommandBox.Paste(); };
            eSelectTool.Click += (object sender, EventArgs e) => { CommandBox.SelectAll(); };

            vMenuTool.Click += (object sender, EventArgs e) => { menuBar.Visible = !menuBar.Visible; };
            vToolTool.Click += (object sender, EventArgs e) => { toolBar.Visible = !toolBar.Visible; };
            vTabTool.Click  += (object sender, EventArgs e) => { tabView.tabBar.Visible = !tabView.tabBar.Visible; };
            vInfoTool.Click += (object sender, EventArgs e) => { underBar.Visible = !underBar.Visible; };

            hVersionTool.Click += (object sender, EventArgs e) =>
            {
                using (VerInfoDialog form = new VerInfoDialog()) { form.ShowDialog(); }
            };
        }
        private void CommandBox_KeyDown(object sender, KeyEventArgs e)
        {
            //Show command hints
            if (e.Key == Key.Tab)
            {
                //ServerProcess.StandardInput.Write(CommandBox.Text + Key.Tab);
            }

            //Send Command(s)
            if (e.Key == Key.Enter && ServerIsRunning)
            {
                string[] CommandsToSend = CommandBox.Text.Split(';');
                foreach (var item in CommandsToSend)
                {
                    ServerProcess.StandardInput.WriteLine(item.Trim());
                    CommandHistoryListBox.Items.Add(item.Trim());
                }
                CommandBox.Clear();
            }

            /*
             * if (e.Key == Key.Up) //Cycle through command history backwards
             * {
             *  CommandBox.Text = CommandHistoryListBox.Items.GetItemAt(CommandHistoryListBox.Items.Count - 1 - CommandHistoryOffset).ToString();
             * }
             *
             * if (e.Key == Key.Down) //Cycle through command history forwards
             * {
             *
             * }*/
        }
 private void CommandBox_MouseWheel(object sender, MouseWheelEventArgs e)
 {
     if (e.MiddleButton == MouseButtonState.Pressed)
     {
         CommandBox.Clear();
     }
 }
Example #5
0
 public CommandUtility(CommandBox CommandBox, List <BasicCommand> Commands, int CommandIndex, Dictionary <string, object> Parameters)
 {
     this.CommandBox   = CommandBox;
     this.Commands     = Commands;
     this.CommandIndex = CommandIndex;
     this.Parameters   = Parameters;
 }
        private void SendCommandToPuppetMaster()
        {
            string cmd = CommandBox.Text;

            CommandBox.Clear();
            Log(">>> " + cmd);
            this.PuppetMaster.ParseCommand(cmd);
        }
Example #7
0
 void Start()
 {
     _ins                = this;
     CommandList         = GameObject.Find("UI Root/CommandBox/CommandList").transform;
     sprite_BG           = GameObject.Find("UI Root/CommandBox/sprite_BG").GetComponent <UISprite>();
     point               = GameObject.Find("UI Root/CommandBox/point");
     prefab_commandLabel = Resources.Load <GameObject>("Prefabs/commandLabel");
     sprite_BG.enabled   = false;
     point.SetActive(false);
 }
 //Commands
 private void SendCommand_Click(object sender, RoutedEventArgs e)
 {
     string[] CommandsToSend = CommandBox.Text.Split(Convert.ToChar(";"));
     foreach (var item in CommandsToSend)
     {
         ServerProcess.StandardInput.WriteLine(item.Trim());
         CommandHistoryListBox.Items.Add(item.Trim());
     }
     CommandBox.Clear();
     //UpdateCommandHistory();
 }
        public frmEditAppStruct()
        {
            InitializeComponent();
            m_undoRedoBuffer = new CommandBox();

            InitTree();

            UpdateAppMenuStatus();
            UpdateLogTableMenuStatus();
            UpdateUndoRedoStatus();
        }
Example #10
0
        public frmEditRules(IManageRuleData mgr, List <LogColumn> lstColumns)
        {
            InitializeComponent();

            SecurityEventService.Instance.DBManager = mgr;

            m_undoRedoBuffer = new CommandBox();
            m_columns        = lstColumns;

            InitSecurityEventTree();
        }
Example #11
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Debug.Log("A CommandBox already exists");
         Destroy(gameObject);
     }
 }
Example #12
0
 public ConsolePage()
 {
     this.InitializeComponent();
     this.NavigationCacheMode = NavigationCacheMode.Enabled;
     _cmdSem          = new SemaphoreSlim(1, 1);
     _outSem          = new SemaphoreSlim(1, 1);
     _activeRunSem    = new SemaphoreSlim(1, 1);
     _newCmd          = false;
     _cmdHistory      = new List <string>(20);
     _cmdHistoryIndex = 0;
     // Use a custom routed event handler to ensure we see ALL key events,
     // without this, some are silently handled by the UI framework
     CommandBox.AddHandler(UIElement.KeyDownEvent, new KeyEventHandler(CommandBox_KeyDown), true);
     ((App)Application.Current).PropertyChanged += ConsolePage_AppPropertyChanged;
 }
        public WindowSettings(CommandBox current)
        {
            InitializeComponent();
            this.txtTitle.Text = "Quicky simple settings";
            snapToEdge = Properties.Settings.Default.SnapToEdges;
            #region sticky windows
            if (snapToEdge)
            {
                WindowManager.RegisterWindow(this);
                m_NativeBehaviors = new NativeBehaviors(this);
                SnapToBehavior stb = new SnapToBehavior();
                stb.OriginalForm = this;
                NativeBehaviors.Add(stb);
            }

            #endregion

            currentCmd = current;

            #region FADE

            // Create the fade in storyboard
            fadeInStoryboard = new Storyboard();
            fadeInStoryboard.Completed += new EventHandler(fadeInStoryboard_Completed);
            DoubleAnimation fadeInAnimation = new DoubleAnimation(0.0, 1.0, new Duration(TimeSpan.FromSeconds(0.20)));
            Storyboard.SetTarget(fadeInAnimation, this);
            Storyboard.SetTargetProperty(fadeInAnimation, new PropertyPath(UIElement.OpacityProperty));
            fadeInStoryboard.Children.Add(fadeInAnimation);

            // Create the fade out storyboard
            fadeOutStoryboard = new Storyboard();
            fadeOutStoryboard.Completed += new EventHandler(fadeOutStoryboard_Completed);
            DoubleAnimation fadeOutAnimation = new DoubleAnimation(1.0, 0.0, new Duration(TimeSpan.FromSeconds(0.50)));
            Storyboard.SetTarget(fadeOutAnimation, this);
            Storyboard.SetTargetProperty(fadeOutAnimation, new PropertyPath(UIElement.OpacityProperty));
            fadeOutStoryboard.Children.Add(fadeOutAnimation);

            #endregion

            this.FadeIn();

            loadSettings();
        }
Example #14
0
        private void LoadBtn_Click(object sender, EventArgs e)
        {
            string str;
            Stream myStream = null;

            openFileDialog.Filter      = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            openFileDialog.FilterIndex = 2;
            Byte[] buffer;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if ((myStream = openFileDialog.OpenFile()) != null)
                    {
                        using (myStream)
                        {
                            if (myStream.Length > 2 * 1024)
                            {
                                MessageBox.Show("文件有点大!");
                                myStream.Close();
                            }
                            buffer = new Byte[myStream.Length];
                            myStream.Read(buffer, 0, (int)myStream.Length);
                            str = System.Text.Encoding.Default.GetString(buffer);
                            //str.Replace(" ",String.Empty);
                            string[] newstr = str.Split(' ');
                            str = String.Join(String.Empty, newstr);
                            CommandBox.Clear();
                            CommandBox.Text = str;
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: 无法打开指定文件. Original error: " + ex.Message);
                }
            }
        }
 private void SendBTN_Click(object sender, EventArgs e)
 {
     if (CommandTextBox.Text.ToLower() == "cmds")         //check if the user send cmds so we can display the commands
     {
         CommandBox.AppendText(Functions.TextToBox[0]);   //Append text to the command richtextbox
         CommandTextBox.Clear();                          //clear the command textbox
     }
     else if (CommandTextBox.Text.ToLower() == "credits") //check if the user send credits so we can display the credits
     {
         CommandBox.AppendText(Functions.TextToBox[1]);   //Append text to the command richtextbox
         CommandTextBox.Clear();                          //clear the command textbox
     }
     else if (CommandTextBox.Text.ToLower() == "clear")
     {
         CommandBox.Clear();
         CommandTextBox.Clear();
     }
     else
     {
         NamedPipes.CommandPipe(CommandTextBox.Text); //command pipe function to send the text in the command textbox
         CommandTextBox.Clear();                      //clear the command textbox
     }
 }
Example #16
0
 private void CommandBox_DropDownClosed(object sender, EventArgs e)
 {
     this.BeginInvoke(new Action(() => { CommandBox.Select(CommandBox.Text.Length, 0); }));
 }
Example #17
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     GameConsole.Text += "\r\n" + _program.InputCommand(CommandBox.Text);
     CommandBox.Clear();
 }
Example #18
0
        private PSObject GetSingle(string caption, string message, string prompt, FieldDescription field, Type type)
        {
            string   help      = field.HelpMessage;
            PSObject psDefault = field.DefaultValue;

            if (null != type && type == typeof(PSCredential))
            {
                var credential = _host.UI.PromptForCredential(caption, message, psDefault?.ToString(), string.Empty, PSCredentialTypes.Default, PSCredentialUIOptions.Default);
                return(credential != null?PSObject.AsPSObject(credential) : null);
            }

            while (true)
            {
                // TODO: Only show the help message if they type '?' as their entry something, in which case show help and re-prompt.
                if (!String.IsNullOrEmpty(help))
                {
                    Write(ConsoleBrushes.ConsoleColorFromBrush(ConsoleBrushes.VerboseForeground), ConsoleBrushes.ConsoleColorFromBrush(ConsoleBrushes.VerboseBackground), help + "\n");
                }

                Write($"{prompt}: ");

                if (null != type && typeof(SecureString) == type)
                {
                    var userData = ReadLineAsSecureString() ?? new SecureString();
                    return(PSObject.AsPSObject(userData));
                } // Note: This doesn't look the way it does in PowerShell, but it should work :)
                else
                {
                    if (psDefault != null && psDefault.ToString().Length > 0)
                    {
                        if (Dispatcher.CheckAccess())
                        {
                            CurrentCommand = psDefault.ToString();
                            CommandBox.SelectAll();
                        }
                        else
                        {
                            Dispatcher.BeginInvoke(DispatcherPriority.Input, (Action <string>)(def =>
                            {
                                CurrentCommand = def;
                                CommandBox.SelectAll();
                            }), psDefault.ToString());
                        }
                    }

                    var userData = ReadLine();

                    if (type != null && userData.Length > 0)
                    {
                        object output;
                        var    ice = TryConvertTo(type, userData, out output);
                        // Special exceptions that happen when casting to numbers and such ...
                        if (ice == null)
                        {
                            return(PSObject.AsPSObject(output));
                        }
                        if ((ice.InnerException is FormatException) || (ice.InnerException is OverflowException))
                        {
                            Write(ConsoleBrushes.ErrorForeground, ConsoleBrushes.ErrorBackground,
                                  $@"Cannot recognize ""{userData}"" as a {type.FullName} due to a format error.\n");
                        }
                        else
                        {
                            return(PSObject.AsPSObject(String.Empty));
                        }
                    }
                    else if (userData.Length == 0)
                    {
                        return(PSObject.AsPSObject(String.Empty));
                    }
                    else
                    {
                        return(PSObject.AsPSObject(userData));
                    }
                }
            }
        }
Example #19
0
 public void setEndOfScopeAsChild(CommandBox EndOfScope)
 {
     endOfScope = EndOfScope;
     endOfScope.transform.SetParent (transform);
     endOfScope.transform.localScale = new Vector2 (1, 1);
 }
Example #20
0
 /// <summary>
 /// Occurs when the form is shown on the screen.
 /// </summary>
 private void Run_Shown(object sender, EventArgs e)
 {
     // Ensure that the window and text area both have focus when the window comes into view.
     Activate();
     CommandBox.Focus();
 }
Example #21
0
 void Start()
 {
     commandBox = gameObject.GetComponentInParent<CommandBox>();
     command = commandBox.command;
     repetitions = GetComponent<Text>();
     repetitions.text = command.repetitionMax.ToString() + "x";
     clicked = holding = false;
 }
        private void save()
        {
            #region enable statusbar
            this.IsEnabled = false;
            //Create a new instance of our ProgressBar Delegate that points
            //  to the ProgressBar's SetValue method.
            UpdateProgressBarDelegate updatePbDelegate = new UpdateProgressBarDelegate(ProgressBarStatus.SetValue);
            bool usePGB = false;
            //Stores the value of the ProgressBar
            double value = 0;
            #endregion
            try
            {
                #region enable statusbar

                usePGB = true;
                //Configure the ProgressBar
                StatusGrid.Visibility = System.Windows.Visibility.Visible;
                ProgressBarStatus.Minimum = 0;
                ProgressBarStatus.Maximum = RepositoryLibrary.Repositorys.Count + 1;// add 1 for cleaning operation
                ProgressBarStatus.Value = 0;



                #endregion

                foreach (CommandRepository repo in RepositoryLibrary.Repositorys)
                {

                    repo.Save();
                    #region Step statusbar
                    if (usePGB)
                    {
                        value += 1;
                        ProgressbarLabel.Text = "Saving repositorys, please wait...";
                        //Update the Value of the ProgressBar:

                        Dispatcher.Invoke(updatePbDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { ProgressBar.ValueProperty, value });

                    }

                    #endregion
                }

            }
            catch (Exception ex)
            {

                sendMessage(ex.Message, "Unhandled error");

            }
            finally
            {
                #region Cleanup
                ProgressbarLabel.Text = "Cleaning up icondsfolder...";
                MyImageWorker.CleanIconFolder();
                value += 1;
                Dispatcher.Invoke(updatePbDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { ProgressBar.ValueProperty, value });
                #endregion

                ProgressbarLabel.Text = string.Empty;
                StatusGrid.Visibility = System.Windows.Visibility.Collapsed;
                commandRepositoryViewSource = null;
                runCommandViewSource = null;
                callReload();
                currentCmd = null;
                GC.Collect();
            }

        }
 public CommandManager(CommandBox current)
 {
     InitializeComponent();
     currentCmd = current;
     StatusGrid.Visibility = System.Windows.Visibility.Collapsed;
 }
 private void MenuItem_Click(object sender, RoutedEventArgs e)
 {
     Show();
     WindowState = WindowState.Normal;
     CommandBox.Focus();
 }
 private void CommandBox_TextChanged(object sender, EventArgs e)
 {
     CommandBox.SelectionStart = CommandBox.Text.Length; //this get all the text
     CommandBox.ScrollToCaret();                         //so with this we can scroll to the bottom
 }
Example #26
0
        /// <summary>
        /// Executes a shell command synchronously.
        /// </summary>
        /// <param name="command">string command</param>
        /// <returns>string, as output of the command.</returns>
        public void ExecuteCommandSync ( CommandBox currentBox = null )
        {
            try
            {
                if ( currentBox != null )
                {
                    if ( this. Command. ToUpper ( ) == "QUICKY RELOAD" )
                        restart ( currentBox );
                }

                if ( this. Type == CommandType. SimpleRunCommand )
                    System. Diagnostics. Process. Start ( this. Command );
                else if ( this. Type == CommandType. CMDExecutedCommand )
                    executespecial ( this. Command );
                else if ( this. Type == CommandType. AutoCadCommand )
                    executeAutocadCommand ( this. Command );


            }
            catch ( Exception )
            {
                throw;
            }
        }
Example #27
0
 private void SetCurrentCommand(string command)
 {
     CommandBox.Text = command;
     CommandBox.Select(CommandBox.Text.Length, 0);
 }
Example #28
0
 private void restart ( CommandBox currentBox )
 {
     Properties. Settings. Default. Save ( );
     currentBox. Restart ( );
 }