private void Window_Loaded(object sender, RoutedEventArgs e) { lblDBVersion.Content = osae.GetObjectPropertyValue("SYSTEM", "DB Version").Value; txbxZipcode.Text = osae.GetObjectPropertyValue("SYSTEM", "ZIP Code").Value; if (osae.GetObjectPropertyValue("SYSTEM", "Debug").Value == "TRUE") { cbDebugging.SelectedItem = cbDebugging.Items[0]; } else { cbDebugging.SelectedItem = cbDebugging.Items[1]; } }
private void loadPlugins() { pluginList = new BindingList <PluginDescription>(); List <string> osapdFiles = new List <string>(); string[] pluginFile = Directory.GetFiles(osae.APIpath + "\\AddIns", "*.osapd", SearchOption.AllDirectories); osapdFiles.AddRange(pluginFile); foreach (string path in osapdFiles) { if (!string.IsNullOrEmpty(path)) { PluginDescription desc = new PluginDescription(); desc.Deserialize(path); desc.Status = "Stopped"; desc.Enabled = false; List <OSAE.OSAEObject> objs = osae.GetObjectsByType(desc.Type); foreach (OSAE.OSAEObject o in objs) { if (osae.GetObjectPropertyValue(o.Name, "Computer Name").Value == osae.ComputerName || desc.Type == o.Name) { desc.Name = o.Name; if (o.Enabled == 1) { desc.Enabled = true; } desc.Status = o.State.Value; } } pluginList.Add(desc); } } dgLocalPlugins.ItemsSource = pluginList; }
private void Window_Loaded(object sender, RoutedEventArgs e) { Load_App_Name(); try { oRecognizer.SpeechRecognized += new EventHandler <SpeechRecognizedEventArgs>(oRecognizer_SpeechRecognized); oRecognizer.AudioStateChanged += new EventHandler <AudioStateChangedEventArgs>(oRecognizer_StateChanged); AudioState state = oRecognizer.AudioState; // This shows AudioState.Stopped } catch (Exception ex) { AddToLog("Unable to configure oRecognizer"); AddToLog("Error: " + ex.Message); } Load_Settings(); Load_Grammer(); try { oRecognizer.SetInputToDefaultAudioDevice(); AddToLog("Recognizer Settings: "); AddToLog("-- Level: " + oRecognizer.AudioLevel.ToString()); AddToLog("-- End Silence Timeout: " + oRecognizer.EndSilenceTimeout); AddToLog("-- Recognition Babble Timeout: " + oRecognizer.BabbleTimeout); AddToLog("Audio Format Settings: "); AddToLog("-- EncodingFormat: " + oRecognizer.AudioFormat.EncodingFormat); AddToLog("-- Channel Count: " + oRecognizer.AudioFormat.ChannelCount); AddToLog("-- Bits Per Sample: " + oRecognizer.AudioFormat.BitsPerSample); AddToLog("-- Samples Per Second: " + oRecognizer.AudioFormat.SamplesPerSecond); AddToLog("-- Average Bytes Per Second: " + oRecognizer.AudioFormat.AverageBytesPerSecond); gSpeechPlugin = OSAEApi.GetObjectPropertyValue(gAppName, "Can Hear this Plugin").Value.ToString(); AddToLog("-- I will ignore speech from: " + gSpeechPlugin); oRecognizer.RecognizeAsync(); AddToLog("Finished Loading, Recognition Started..."); } catch (Exception ex) { AddToLog("Unable to set Default Audio Device. Check Sound Card."); AddToLog("Error: " + ex.Message); } }
private void Load_Objects(String sScreen) { MySqlCommand CMD = new MySqlCommand(); // MySqlDataReader myReader = new MySqlDataReader(); String sState = ""; String sStateMatch = ""; String sImage = ""; CMD.Connection = CN; CMD.CommandType = CommandType.Text; //COUNT **ALL** control objects for this screen //CMD.CommandText = "SELECT COUNT(*) as Results FROM osae_v_screen_object WHERE screen_name=?pscreen"; //CMD.Parameters.AddWithValue("?pscreen", sScreen); //try //{ // CN.Open(); // iObjectCount = Convert.ToInt32(CMD.ExecuteScalar()); // CN.Close(); //} //catch (Exception myerror) //{ // MessageBox.Show("GUI Error Load_Objects 1: " + myerror.Message); // CN.Close(); //} CMD.Parameters.Clear(); //Select **ALL** control objects for this screen CMD.CommandText = "SELECT * FROM osae_v_object_property WHERE object_id IN(SELECT control_id FROM osae_v_screen_object WHERE screen_name=?pscreen) AND property_name='ZOrder' ORDER BY property_value"; CMD.Parameters.AddWithValue("?pscreen", sScreen); try { CN.Open(); MySqlDataReader myReader = CMD.ExecuteReader(); while (myReader.Read()) { ScreenObject so = new ScreenObject(); so.Control_Name = Convert.ToString(myReader.GetString("object_name")); so.Control_Type = Convert.ToString(myReader.GetString("object_type")); aScreenObject.Add(so); } CN.Close(); } catch (MySqlException myerror) { MessageBox.Show("GUI Error Load_Objects 2: " + myerror.Message); CN.Close(); } CMD.Parameters.Clear(); foreach (ScreenObject dso in aScreenObject) { if (dso.Control_Type == "CONTROL STATE IMAGE") { dso.Object_Name = OSAEApi.GetObjectProperty(dso.Control_Name, "Object Name"); Image dsi = new Image(); dsi.Tag = dso.Object_Name; dsi.MouseLeftButtonDown += new MouseButtonEventHandler(State_Image_MouseLeftButtonDown); sState = OSAEApi.GetObjectState(dso.Object_Name); CMD.Parameters.Clear(); CMD.CommandText = "SELECT COALESCE(last_state_change,NOW()) FROM osae_v_object WHERE object_name=?ObjectName"; CMD.Parameters.AddWithValue("?ObjectName", dso.Object_Name); try { CN.Open(); dso.Object_State_Time = Convert.ToString(CMD.ExecuteScalar()); CN.Close(); } catch (Exception myerror) { MessageBox.Show("GUI Error Load_Objects 2.5: " + myerror.Message); CN.Close(); } CMD.Parameters.Clear(); CMD.CommandText = "SELECT property_name FROM osae_v_object_property WHERE object_name=?ObjectName AND property_value=?pstate"; CMD.Parameters.AddWithValue("?ObjectName", dso.Control_Name); CMD.Parameters.AddWithValue("?pstate", sState); try { CN.Open(); sStateMatch = Convert.ToString(CMD.ExecuteScalar()); CN.Close(); if (sStateMatch != "") { sStateMatch = sStateMatch.Substring(0, 7); } sImage = OSAEApi.GetObjectProperty(dso.Control_Name, sStateMatch + " Image"); if (File.Exists(OSAEApi.APIpath + sImage)) { sImage = OSAEApi.APIpath + sImage; } OSAE.ObjectProperty pZOrder = OSAEApi.GetObjectPropertyValue(dso.Control_Name, "ZOrder"); OSAE.ObjectProperty pX = OSAEApi.GetObjectPropertyValue(dso.Control_Name, sStateMatch + " X"); OSAE.ObjectProperty pY = OSAEApi.GetObjectPropertyValue(dso.Control_Name, sStateMatch + " Y"); dso.Object_State = sState; dso.ScreenImage = dsi; if (File.Exists(sImage)) { canGUI.Children.Add(dsi); Double dX = Convert.ToDouble(pX.Value); Canvas.SetLeft(dsi, dX); Double dY = Convert.ToDouble(pY.Value); Canvas.SetTop(dsi, dY); byte[] byteArray = File.ReadAllBytes(sImage); var imageStream = new MemoryStream(byteArray); var bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.StreamSource = imageStream; bitmapImage.EndInit(); //canGUI.Background = new ImageBrush(bitmapImage); dsi.Source = bitmapImage; if (pZOrder.Value == "0") { // dsi.SendToBack(); } else { // dsi.BringToFront(); } dsi.Visibility = System.Windows.Visibility.Visible; } else { dsi.Source = null; dsi.Visibility = System.Windows.Visibility.Hidden; } } catch (Exception myerror) { MessageBox.Show("GUI Error Load_Objects 3: " + myerror.Message); CN.Close(); } } else if (dso.Control_Type == "CONTROL PROPERTY LABEL") { dso.Object_Name = OSAEApi.GetObjectProperty(dso.Control_Name, "Object Name"); String sPropertyName = OSAEApi.GetObjectProperty(dso.Control_Name, "Property Name"); dso.Property_Name = sPropertyName; String sPropertyValue = OSAEApi.GetObjectProperty(dso.Object_Name, sPropertyName); String sBackColor = OSAEApi.GetObjectProperty(dso.Control_Name, "Back Color"); String sForeColor = OSAEApi.GetObjectProperty(dso.Control_Name, "Fore Color"); String sPrefix = OSAEApi.GetObjectProperty(dso.Control_Name, "Prefix"); String sSuffix = OSAEApi.GetObjectProperty(dso.Control_Name, "Suffix"); String iFontSize = OSAEApi.GetObjectProperty(dso.Control_Name, "Font Size"); String sFontName = OSAEApi.GetObjectProperty(dso.Control_Name, "Font Name"); Label dpl = new Label(); dpl.Tag = dso.Object_Name; OSAE.ObjectProperty pX = OSAEApi.GetObjectPropertyValue(dso.Control_Name, "X"); OSAE.ObjectProperty pY = OSAEApi.GetObjectPropertyValue(dso.Control_Name, "Y"); canGUI.Children.Add(dpl); dso.ScreenLabel = dpl; Double dX = Convert.ToDouble(pX.Value); Canvas.SetLeft(dpl, dX); Double dY = Convert.ToDouble(pY.Value); Canvas.SetTop(dpl, dY); if (sPropertyValue != "") { if (sBackColor != "") { try { BrushConverter conv = new BrushConverter(); SolidColorBrush brush = conv.ConvertFromString(sBackColor) as SolidColorBrush; dpl.Background = brush; } catch (Exception myerror) { } } if (sForeColor != "") { try { BrushConverter conv = new BrushConverter(); SolidColorBrush brush = conv.ConvertFromString(sForeColor) as SolidColorBrush; dpl.Foreground = brush; } catch (Exception myerror) { } } if (iFontSize != "") { try { dpl.FontSize = Convert.ToDouble(iFontSize); } catch (Exception myerror) { } } dpl.Content = sPrefix + sPropertyValue + sSuffix; dso.Object_State = ""; } else { dpl.Content = ""; } } else if (dso.Control_Type == "CONTROL STATIC LABEL") { dso.Object_Name = OSAEApi.GetObjectProperty(dso.Control_Name, "Object Name"); String sPropertyValue = OSAEApi.GetObjectProperty(dso.Object_Name, "Value"); String sBackColor = OSAEApi.GetObjectProperty(dso.Control_Name, "Back Color"); String sForeColor = OSAEApi.GetObjectProperty(dso.Control_Name, "Fore Color"); Label dsl = new Label(); dsl.Tag = dso.Object_Name; OSAE.ObjectProperty pX = OSAEApi.GetObjectPropertyValue(dso.Control_Name, "X"); OSAE.ObjectProperty pY = OSAEApi.GetObjectPropertyValue(dso.Control_Name, "Y"); canGUI.Children.Add(dsl); Double dX = Convert.ToDouble(pX.Value); Canvas.SetLeft(dsl, dX); Double dY = Convert.ToDouble(pY.Value); Canvas.SetTop(dsl, dY); if (sPropertyValue != "") { if (sBackColor != "") { try { BrushConverter conv = new BrushConverter(); SolidColorBrush brush = conv.ConvertFromString(sBackColor) as SolidColorBrush; dsl.Background = brush; } catch (Exception myerror) { } } if (sForeColor != "") { try { BrushConverter conv = new BrushConverter(); SolidColorBrush brush = conv.ConvertFromString(sForeColor) as SolidColorBrush; dsl.Foreground = brush; } catch (Exception myerror) { } } dsl.Content = sPropertyValue; } else { dsl.Content = ""; } } // else if aScreenObject(iLoop).Control_Type = "CONTROL TIMER LABEL" Then // iTimerLabelCount = iTimerLabelCount + 1 // aScreenObject(iLoop).Control_Index = iTimerLabelCount // aScreenObject(iLoop).Object_Name = OSAEApi.GetObjectProperty(aScreenObject(iLoop).Control_Name, "Object Name") // sPropertyName = OSAEApi.GetObjectProperty(aScreenObject(iLoop).Control_Name, "Type") // aScreenObject(iLoop).Property_Name = sPropertyName // sPropertyValue = OSAEApi.GetObjectProperty(aScreenObject(iLoop).Object_Name, "OFF Timer") // aScreenObject(iLoop).Property_Value = sPropertyValue // sBackColor = OSAEApi.GetObjectProperty(aScreenObject(iLoop).Control_Name, "Back Color") // sForeColor = OSAEApi.GetObjectProperty(aScreenObject(iLoop).Control_Name, "Fore Color") // aControlTimerLabel(iTimerLabelCount).Tag = iLoop // sState = OSAEApi.GetObjectState(aScreenObject(iLoop).Object_Name) // aScreenObject(iLoop).Object_State = sState // CMD.Parameters.Clear() // CMD.CommandText = "SELECT COALESCE(last_updated,NOW()) FROM osae_v_object WHERE object_name=?ObjectName" // CMD.Parameters.AddWithValue("?ObjectName", aScreenObject(iLoop).Object_Name) // try // { // CN.Open(); // aScreenObject(iLoop).Object_Last_Updated = CMD.ExecuteScalar; // CN.Close(); // } // catch (MySqlException myerror) // { // MessageBox.Show("GUI Error Load_Objects 2.7: " & myerror.Message); // CN.Close(); // } // CMD.Parameters.Clear(); // CMD.CommandText = "SELECT COALESCE(last_state_change,NOW()) FROM osae_v_object WHERE object_name=?ObjectName"; // CMD.Parameters.AddWithValue("?ObjectName", aScreenObject(iLoop).Object_Name); // try // { // CN.Open(); // aScreenObject(iLoop).Object_State_Time = CMD.ExecuteScalar; // CN.Close(); // } // catch (MySqlException myerror) // { // MessageBox.Show("GUI Error Load_Objects 666: " & myerror.Message); // CN.Close(); // } // iX = Val("" & OSAEApi.GetObjectProperty(aScreenObject(iLoop).Control_Name, "X")); // iY = Val("" & OSAEApi.GetObjectProperty(aScreenObject(iLoop).Control_Name, "Y")); // if (sBackColor <> "") // { // try // { // aControlTimerLabel(aScreenObject(iLoop).Control_Index).BackColor = Color.FromName(sBackColor); // } // catch (MySqlException myerror) // {} // } // if (sForeColor <> "") // { // try // { // aControlTimerLabel(aScreenObject(iLoop).Control_Index).ForeColor = Color.FromName(sForeColor) // } // catch (MySqlException myerror) // {} // } // aControlTimerLabel(aScreenObject(iLoop).Control_Index).Text = sPropertyValue; // aControlTimerLabel(aScreenObject(iLoop).Control_Index).Width = sPropertyValue.Length * 7; // aControlTimerLabel(aScreenObject(iLoop).Control_Index).Left = iX; // aControlTimerLabel(aScreenObject(iLoop).Control_Index).Top = iY; // aControlTimerLabel(aScreenObject(iLoop).Control_Index).BringToFront(); // aControlTimerLabel(aScreenObject(iLoop).Control_Index).Visible = True; // else if (aScreenObject(iLoop).Control_Type = "CONTROL METHOD IMAGE") // iMethodImageCount = iMethodImageCount + 1 // aScreenObject(iLoop).Object_Name = OSAEApi.GetObjectProperty(aScreenObject(iLoop).Control_Name, "Object Name") // aScreenObject(iLoop).Control_Index = iMethodImageCount // aControlMethodImage(aControlMethodImage.Count).Tag = iLoop // g_toolTip.SetToolTip(aControlMethodImage(iMethodImageCount), aScreenObject(iLoop).Object_Name) // CMD.Parameters.Clear() // try // { // sImage = OSAEApi.GetObjectProperty(aScreenObject(iLoop).Control_Name, "Image"); // sImage = sImage.Replace(".\", "\"); // If File.Exists(gAppPath & sImage) Then sImage = gAppPath & sImage // iZOrder = Val(OSAEApi.GetObjectProperty(aScreenObject(iLoop).Control_Name, "ZOrder")); // iX = Val("" & OSAEApi.GetObjectProperty(aScreenObject(iLoop).Control_Name, "X")); // iY = Val("" & OSAEApi.GetObjectProperty(aScreenObject(iLoop).Control_Name, "Y")); // if (File.Exists(sImage)) // { // aControlMethodImage(aScreenObject(iLoop).Control_Index).Image = Image.FromFile(sImage); // aScreenObject(iLoop).Object_State = "" // aControlMethodImage(aScreenObject(iLoop).Control_Index).Left = iX; // aControlMethodImage(aScreenObject(iLoop).Control_Index).Top = iY; // aControlMethodImage(aScreenObject(iLoop).Control_Index).Visible = True; // } // else // { // aControlMethodImage(aScreenObject(iLoop).Control_Index).Image = Nothing; // aControlMethodImage(aScreenObject(iLoop).Control_Index).Visible = False; // } // } // catch (MySqlException myerror) // { // MessageBox.Show("GUI Error Load_Objects 4: " + myerror.Message); // CN.Close(); // } else if (dso.Control_Type == "CONTROL NAVIGATION IMAGE") { dso.Object_Name = OSAEApi.GetObjectProperty(dso.Control_Name, "Screen"); dso.Object_State = ""; Image dni = new Image(); dni.Tag = dso.Object_Name; //aControlNavImage(iNavImageCount).Tag = iLoop // g_toolTip.SetToolTip(aControlNavImage(iNavImageCount), aScreenObject(iLoop).Object_Name) CMD.Parameters.Clear(); try { sImage = OSAEApi.GetObjectProperty(dso.Control_Name, "Image"); if (File.Exists(OSAEApi.APIpath + sImage)) { sImage = OSAEApi.APIpath + sImage; } OSAE.ObjectProperty pZOrder = OSAEApi.GetObjectPropertyValue(dso.Control_Name, "ZOrder"); OSAE.ObjectProperty pX = OSAEApi.GetObjectPropertyValue(dso.Control_Name, "X"); OSAE.ObjectProperty pY = OSAEApi.GetObjectPropertyValue(dso.Control_Name, "Y"); if (File.Exists(sImage)) { canGUI.Children.Add(dni); Double dX = Convert.ToDouble(pX.Value); Canvas.SetLeft(dni, dX); Double dY = Convert.ToDouble(pY.Value); Canvas.SetTop(dni, dY); byte[] byteArray = File.ReadAllBytes(sImage); var imageStream = new MemoryStream(byteArray); var bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.StreamSource = imageStream; bitmapImage.EndInit(); //canGUI.Background = new ImageBrush(bitmapImage); dni.Source = bitmapImage; if (pZOrder.Value == "0") { // dsi.SendToBack(); } else { // dsi.BringToFront(); } } } catch (MySqlException myerror) { MessageBox.Show("GUI Error Load_Objects 5: " + myerror.Message); CN.Close(); } } // ElseIf aScreenObject(iLoop).Control_Type = "USER CONTROL" Then // iUserControlCount += 1 // Dim sUCType As String = OSAEApi.GetObjectProperty(aScreenObject(iLoop).Control_Name, "Control Type") // If sUCType = "USER CONTROL WEATHER" Then // Me.Controls.Add(New ucWeather) // aScreenObject(iLoop).Control_Index = Me.Controls.Count - 1 // Me.Controls(aScreenObject(iLoop).Control_Index).Top = OSAEApi.GetObjectProperty(aScreenObject(iLoop).Control_Name, "Y") // Me.Controls(aScreenObject(iLoop).Control_Index).Left = OSAEApi.GetObjectProperty(aScreenObject(iLoop).Control_Name, "X") // Me.Controls(aScreenObject(iLoop).Control_Index).BringToFront() // ' // End If // End If //If iStateImageList.EndsWith(",") Then iStateImageList = iStateImageList.Substring(0, iStateImageList.Length - 1) //Timer1.Enabled = True } }