Ejemplo n.º 1
0
        }  //  private void frmGAVPI_FormClosing

        //
        //  loadToolStripMenuItem_Click()
        //
        //  A handler for the Load Profile menu item in the File menu, allowing the user to select an existing
        //  Binding Definition Profile.  The Binding Definition Profile may be edited and saved within frmProfile.
        //

        private void loadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //  If we're Listening for voice commands, stop Listening since we may be about to open another
            //  Profile...

            if (GAVPI.vi.IsListening)
            {
                btnMainStop_Click(sender, e);
            }

            //  Attempt to open a Profile and, if successful, enable the Listen button and the Profile->Modify
            //  menu item (these items should both be disabled in the absense of a loaded Profile during
            //  the frmGAVPI_Activated event handler).

            if (GAVPI.LoadProfile())
            {
                btnMainListen.Enabled         = true;
                editToolStripMenuItem.Enabled = true;
            }  //  if()

            //  Maintain a consistent Form status...

            btmStripStatus.Text = GAVPI.GetStatusString();

            return;
        }
Ejemplo n.º 2
0
        //
        //  private void ProfileEdited()
        //
        //  To maintain a consistent workflow, let's recognise when the current Profile has been edited by the
        //  user.  We'll update the state within each method that adds or removes aspects of the Profile that
        //  require persistence.
        //

        private void ProfileEdited()
        {
            //
            //  Changes have been made to the Profile.  If the Profile is named, ensure File->Save menu item is
            //  enabled.  Also ensure that File->Save As menu item is enabled.  We also need to indicate to the
            //  user, in the Form's status bar, that the Profile is presently unsaved.
            //

            if (GAVPI.vi_profile.IsEmpty())
            {
                btmStatusProfile.Text = null;

                return;
            }

            if (GAVPI.vi_profile.GetProfileFilename() != null)
            {
                this.saveToolStripMenuItem.Enabled = true;
            }

            GAVPI.vi_profile.Edited();

            this.saveAsToolStripMenuItem.Enabled = true;

            btmStatusProfile.Text = GAVPI.GetStatusString();
        }          //  private void ProfileEdited()
Ejemplo n.º 3
0
        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!GAVPI.SaveAsProfile())
            {
                return;
            }

            RefreshUI(Path.GetFileNameWithoutExtension(GAVPI.vi_profile.GetProfileFilename()));
        }
Ejemplo n.º 4
0
        private void loadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //  Attempt to load a Profile and then update the Form's UI elements and status.  (The Form's
            //  status bar should display the name of the opened Profile.)

            if (!GAVPI.LoadProfile())
            {
                return;
            }
        }
Ejemplo n.º 5
0
 private void AutoLoadProfiles_CheckedChanged(object sender, EventArgs e)
 {
     if (AutoLoadProfiles.Checked)
     {
         AutomaticallyListen.Enabled = true;
         GAVPI.EnableAutoOpenProfile(sender, e);
     }
     else
     {
         AutomaticallyListen.Enabled = false;
         GAVPI.DisableAutoOpenProfile(sender, e);
     }
 }
Ejemplo n.º 6
0
        // New Profile
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Exactly like modify, except we warn the user to save their current profile
            // before creating a new one.

            if (!GAVPI.NewProfile())
            {
                return;
            }

            //  Refer to our general Profile editing handler...

            modifyToolStripMenuItem_Click(sender, e);
        }
Ejemplo n.º 7
0
        //
        //  private void newToolStripMenuItem_Click( object, EventArgs )
        //
        //  Selecting the File->New menu item destroys any current Profile and establishes an empty Profile.
        //

        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //  Request a new profile...

            if (!GAVPI.NewProfile())
            {
                return;
            }

            RefreshUI(GAVPI.GetStatusString());

            //  The Profile hasn't been edited, so there are no changes to save, therefore let's disable the
            //  File menu's Save As and Save buttons for now.

            saveAsToolStripMenuItem.Enabled = false;
            saveToolStripMenuItem.Enabled   = false;
            btmStatusProfile.Text           = null;
        }  //  private void newToolStripMenuItem_Click( object, EventArgs )
Ejemplo n.º 8
0
        //
        //  private void frmProfile_Load( object, EventArgs )
        //
        //  Prior to frmProfile being rendered, we may dynamically change the availability of, or modify the
        //  content of, UI elements that offer indicators of the user's workflow.
        //

        private void frmProfile_Load(object sender, EventArgs e)
        {
            //  If we are re-modifying an existing Profile that has pending changes, ensure we re-enable
            //  File->Save and (if the Profile has already been saved - and named) the File->File As menu items.

            if (GAVPI.vi_profile.IsEdited())
            {
                ProfileEdited();
            }

            //  Reflect the Profile's current state in the Status Bar...

            btmStatusProfile.Text = GAVPI.GetStatusString();

            //  ...And display the name of an associated executable in the relevant text box.

            AssociatedProcessTextBox.Text = GAVPI.vi_profile.GetAssociatedProcess();
        }  //  private void frmProfile_Load()
Ejemplo n.º 9
0
        }     //  private void AssociatedProcessButton_Click( object, EventArgs )

        //
        //  private void AssociatedProcessTextBox_LostFocus( object, EventArgs )
        //
        //  If the user manually edits the content of the associated process filename text box, acknowledge
        //  those changes.
        //

        private void AssociatedProcessTextBox_TextChanged(object sender, EventArgs e)
        {
            //  Assign the content of the TextBox to the Profile. CHECK TO MAKE SURE OLD ONE IS REMOVED!

            if (GAVPI.vi_profile.GetAssociatedProcess() == AssociatedProcessTextBox.Text)
            {
                return;
            }

            GAVPI.vi_profile.SetAssociatedProcess(AssociatedProcessTextBox.Text);

            //  Add to the process tracker (infers removal of a prior instance).

            GAVPI.AddAutoOpenProfile(AssociatedProcessTextBox.Text, GAVPI.vi_profile.GetProfileFilename());

            //  Consider this Profile edited.

            ProfileEdited();
        }  //  private void AssociatedProcessTextBox_LostFocus( object, EventArgs )
Ejemplo n.º 10
0
        //
        //  public void RefreshUI( string )
        //
        //  Request that the User Interface updates any elements that are dependant on states that may change
        //  beyond the scope of the current thread of execution.  This method is typically called by way of the
        //  GAVPI class.
        //

        public void RefreshUI(string status)
        {
            //  Ensure the log is updated to reflect any additional entries and move to the last log item...

            lstMainHearing.DataSource = GAVPI.Log.ToArray();
            lstMainHearing.TopIndex   = GAVPI.Log.Count() - 1;

            //  The UI reflects a different workflow depending on whether it is currently listening on voice
            //  recognition commands or otherwise.

            if (GAVPI.vi.IsListening)
            {
                btnMainStop.Enabled           = true;
                btnMainListen.Enabled         = false;
                editToolStripMenuItem.Enabled = false;
            }
            else
            {
                btnMainListen.Enabled         = true;
                btnMainStop.Enabled           = false;
                editToolStripMenuItem.Enabled = true;
            }  //  if()

            //  If a Profile isn't loaded, disable Profile->Modify and the Listen button.

            if (GAVPI.vi_profile.IsEmpty())
            {
                btnMainListen.Enabled         = false;
                editToolStripMenuItem.Enabled = false;
            }

            //  If we don't wish to update the status text, simply pass null as an argument to RefreshUI()

            if (status != null)
            {
                btmStripStatus.Text = status;
            }
            else
            {
                btmStripStatus.Text = GAVPI.GetStatusString();
            }
        }  //  public void RefreshUI( string )
Ejemplo n.º 11
0
        // Modify Existing
        private void modifyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                GAVPI.OpenProfileEditor(sender, e);

                //  Enable both the Listen button and the Profile->Modify menu item if the current Profile is
                //  populated.

                if (GAVPI.vi_profile.IsEmpty())
                {
                    return;
                }

                btnMainListen.Enabled         = true;
                editToolStripMenuItem.Enabled = true;

                //
                //  VI_Profile takes care of tracking changes and the saved/unsaved state of the current Profile.
                //  We can act on this knowledge to update the status in the UI and also inform the user of those
                //  unsaved changes should they choose a potentially destructive act (exiting the program, opening
                //  an existing Profile).
                //

                btmStripStatus.Text = GAVPI.GetStatusString();
            }
            catch (Exception profile_exception)
            {
                MessageBox.Show("Profile Editor Crashed.\n" + profile_exception.Message, "Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation,
                                MessageBoxDefaultButton.Button1);

                GAVPI.vi_profile.NewProfile();
            }
        }  //  private void modifyToolStripMenuItem_Click( object, EventArgs )
Ejemplo n.º 12
0
 private void exitToolStripMenuItem_Click(object sender, EventArgs e)
 {
     this.Close();
     GAVPI.ShowTrayMessage("GAVPI", "is still running, close it from the tray.");
 }
Ejemplo n.º 13
0
 private void btnMainStop_Click(object sender, EventArgs e)
 {
     GAVPI.StopListening(sender, e);
 }
Ejemplo n.º 14
0
        }  //  private void modifyToolStripMenuItem_Click( object, EventArgs )

        #endregion
        #region Settings
        private void mainStripSettings_Click(object sender, EventArgs e)
        {
            GAVPI.OpenSettings(sender, e);
        }