protected void si_S2I1ImagePicked(object sender, EventArgs e) { OSAEImageManager imgMgr = new OSAEImageManager(); State2Img1 = imgMgr.GetImage((int)sender); MemoryStream ms1 = new MemoryStream(State1Img1.Data); BitmapImage bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.StreamSource = ms1; bitmapImage.EndInit(); ImageBehavior.SetAnimatedSource(imgState2Img1, bitmapImage); //imgState2Img1.Source = LoadImage(State2Img1.Data); imgState2Img1.ToolTip = "Width:" + imgState2Img1.Width + " Height:" + imgState2Img1.Height; Validate_Initial_Coordinates(); lblState2X.IsEnabled = true; lblState2Y.IsEnabled = true; txtState2X.IsEnabled = true; txtState2Y.IsEnabled = true; lblZOrder.IsEnabled = true; txtZOrder.IsEnabled = true; if (State2Img1.Type != "gif") { btnLoadS2I2.IsEnabled = true; imgState2Img2.IsEnabled = true; } }
protected void si_S1I1ImagePicked(object sender, EventArgs e) { OSAEImageManager imgMgr = new OSAEImageManager(); State1Img1 = imgMgr.GetImage((int)sender); MemoryStream ms1 = new MemoryStream(State1Img1.Data); BitmapImage bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.StreamSource = ms1; bitmapImage.EndInit(); ImageBehavior.SetAnimatedSource(imgState1Img1, bitmapImage); //imgState1Img1.Source = LoadImage(State1Img1.Data); imgState1Img1.ToolTip = "Width:" + imgState1Img1.Width + " Height:" + imgState1Img1.Height; Validate_Initial_Coordinates(); lblState1X.IsEnabled = false; lblState1Y.IsEnabled = false; txtState1X.IsEnabled = true; txtState1Y.IsEnabled = true; lblZOrder.IsEnabled = true; txtZOrder.IsEnabled = true; if (State1Img1.Type != "gif") { btnLoadS1I2.IsEnabled = true; imgState1Img2.IsEnabled = true; } }
protected void si_OffImagePicked(object sender, EventArgs e) { OSAEImageManager imgMgr = new OSAEImageManager(); offImg = imgMgr.GetImage((int)sender); imgState2.Source = LoadImage(offImg.Data); }
protected void si_ImagePicked(object sender, EventArgs e) { OSAEImageManager imgMgr = new OSAEImageManager(); img = imgMgr.GetImage((int)sender); imgScreen.Source = LoadImage(img.Data); }
protected void si_ImagePicked(object sender, EventArgs e) { OSAEImageManager imgMgr = new OSAEImageManager(); img = imgMgr.GetImage((int)sender); imgMethod.Source = LoadImage(img.Data); }
protected void si_S2I4ImagePicked(object sender, EventArgs e) { OSAEImageManager imgMgr = new OSAEImageManager(); State2Img4 = imgMgr.GetImage((int)sender); imgState2Img4.Source = LoadImage(State2Img4.Data); Validate_Initial_Coordinates(); }
protected void siNormal_ImagePicked(object sender, EventArgs e) { OSAEImageManager imgMgr = new OSAEImageManager(); imgNormalRaw = imgMgr.GetImage((int)sender); imgNormal.Source = LoadImage(imgNormalRaw.Data); Validate_Initial_Coordinates(); }
protected void siPressed_ImagePicked(object sender, EventArgs e) { OSAEImageManager imgMgr = new OSAEImageManager(); imgPressedRaw = imgMgr.GetImage((int)sender); imgPressed.Source = LoadImage(imgPressedRaw.Data); Validate_Initial_Coordinates(); }
protected void si_S1I1ImagePicked(object sender, EventArgs e) { OSAEImageManager imgMgr = new OSAEImageManager(); State1Img1 = imgMgr.GetImage((int)sender); imgState1Img1.Source = LoadImage(State1Img1.Data); imgState1Img1.ToolTip = "Width:" + imgState1Img1.Width + " Height:" + imgState1Img1.Height; Validate_Initial_Coordinates(); }
protected void gvImages_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeleteImage") { GridViewRow row = (GridViewRow)((ImageButton)e.CommandSource).NamingContainer; OSAEImageManager imgmrg = new OSAEImageManager(); imgmrg.DeleteImage(Int32.Parse(gvImages.DataKeys[row.RowIndex].Value.ToString())); loadImages(); } }
protected void si_S2I3ImagePicked(object sender, EventArgs e) { OSAEImageManager imgMgr = new OSAEImageManager(); State2Img3 = imgMgr.GetImage((int)sender); imgState2Img3.Source = LoadImage(State2Img3.Data); imgState2Img3.ToolTip = "Width:" + imgState2Img3.Width + " Height:" + imgState2Img3.Height; Validate_Initial_Coordinates(); btnLoadS2I4.IsEnabled = true; imgState2Img4.IsEnabled = true; }
protected void si_S2I2ImagePicked(object sender, EventArgs e) { OSAEImageManager imgMgr = new OSAEImageManager(); State2Img2 = imgMgr.GetImage((int)sender); imgState2Img2.Source = LoadImage(State2Img2.Data); imgState2Img2.ToolTip = "Width:" + imgState2Img2.Width + " Height:" + imgState2Img2.Height; Validate_Initial_Coordinates(); btnLoadS2I3.IsEnabled = true; imgState2Img3.IsEnabled = true; lblAnimationDelay.IsEnabled = true; txtDelay.IsEnabled = true; chkRepeat.IsEnabled = true; }
private void LoadCurrentScreenObject(string screenName) { OSAEImageManager imgMgr = new OSAEImageManager(); try { img = imgMgr.GetImage(OSAEObjectPropertyManager.GetObjectPropertyValue(screenName, "Background Image").Value); if (img != null) { imgScreen.Source = LoadImage(img.Data); } } catch { } }
/// <summary> /// Load the objects from the DB into the combo box /// </summary> private void LoadCurrentScreenObject(string controlName) { OSAEImageManager imgMgr = new OSAEImageManager(); cboObject.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Object Name").Value; cboProperty.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Property Name").Value; txtFont.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Font Name").Value; txtSize.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Font Size").Value; cboForeColor.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Fore Color").Value; cboBackColor.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Back Color").Value; txtPrefix.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Prefix").Value; txtSuffix.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Suffix").Value; txtX.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "X").Value; txtY.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Y").Value; txtZOrder.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "ZOrder").Value; }
/// <summary> /// Load the objects from the DB into the combo box /// </summary> private void LoadCurrentScreenObject(string controlName) { cboPressObject.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Press Object Name").Value; cboPressMethod.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Press Method Name").Value; txtPressParam1.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Press Method Param 1").Value; txtPressParam2.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Press Method Param 2").Value; cboPressScript.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Press Script Name").Value; txtPressScriptParam1.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Press Script Param 1").Value; txtPressScriptParam2.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Press Script Param 2").Value; cboReleaseObject.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Release Object Name").Value; cboReleaseMethod.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Release Method Name").Value; txtReleaseParam1.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Release Method Param 1").Value; txtReleaseParam2.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Release Method Param 2").Value; cboReleaseScript.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Release Script Name").Value; txtReleaseScriptParam1.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Release Script Param 1").Value; txtReleaseScriptParam2.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Release Script Param 2").Value; txtNormalX.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "X").Value; txtNormalY.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Y").Value; OSAEImageManager imgMgr = new OSAEImageManager(); try { imgNormalRaw = imgMgr.GetImage(OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Normal Image").Value); imgNormal.Source = LoadImage(imgNormalRaw.Data); Validate_Initial_Coordinates(); } catch (Exception ex) { } try { imgPressedRaw = imgMgr.GetImage(OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Pressed Image").Value); imgPressed.Source = LoadImage(imgPressedRaw.Data); Validate_Initial_Coordinates(); } catch (Exception ex) { } }
protected void si_S2I1ImagePicked(object sender, EventArgs e) { OSAEImageManager imgMgr = new OSAEImageManager(); State2Img1 = imgMgr.GetImage((int)sender); imgState2Img1.Source = LoadImage(State2Img1.Data); imgState2Img1.ToolTip = "Width:" + imgState2Img1.Width + " Height:" + imgState2Img1.Height; Validate_Initial_Coordinates(); lblState2X.IsEnabled = true; lblState2Y.IsEnabled = true; txtState2X.IsEnabled = true; txtState2Y.IsEnabled = true; lblZOrder.IsEnabled = true; txtZOrder.IsEnabled = true; btnLoadS2I2.IsEnabled = true; imgState2Img2.IsEnabled = true; }
private void LoadCurrentScreenObject(string controlName) { cboScreens.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Screen").Value; txtX.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "X").Value; txtY.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Y").Value; OSAEImageManager imgMgr = new OSAEImageManager(); try { img = imgMgr.GetImage(OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Image").Value); imgScreen.Source = LoadImage(img.Data); Validate_Initial_Coordinates(); } catch (Exception ex) { } }
private void btnAdd_Click(object sender, RoutedEventArgs e) { //Configure open file dialog box Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.FileName = "Document"; // Default file name dlg.Filter = "All supported graphics|*.jpg;*.jpeg;*.gif;*.png;|" + "JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|" + "Gif (*.gif)|*.gif|" + "Portable Network Graphic (*.png)|*.png"; // Filter files by extension if (dlg.ShowDialog() == true) { BitmapImage img = new BitmapImage(new Uri(dlg.FileName)); string fileName = Path.GetFileName(dlg.FileName).Split('.')[0]; string ext = Path.GetFileName(dlg.FileName).Split('.')[1]; OSAEImageManager imgMgr = new OSAEImageManager(); int imgID = 0; byte[] byt; if (ext.ToLower() == "jpg" || ext.ToLower() == "jpeg") { byt = imgMgr.GetJPGFromImageControl(img); imgID = imgMgr.AddImage(fileName, ext, byt); } else if (ext.ToLower() == "png") { byt = imgMgr.GetPNGFromImageControl(img); imgID = imgMgr.AddImage(fileName, ext, byt); } else if (ext.ToLower() == "gif") { byt = imgMgr.GetGIFFromFileStream(dlg.FileName); imgID = imgMgr.AddImage(fileName, ext, byt); } BindImages(); } }
/// <summary> /// Load the objects from the DB into the combo box /// </summary> private void LoadCurrentScreenObject(string controlName) { OSAEImageManager imgMgr = new OSAEImageManager(); cboObject.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Object Name").Value; cboProperty.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Property Name").Value; txtFont.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Font Name").Value; txtSize.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Font Size").Value; cboForeColor.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Fore Color").Value; cboBackColor.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Back Color").Value; txtPrefix.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Prefix").Value; txtSuffix.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Suffix").Value; txtX.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "X").Value; txtY.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Y").Value; // OSAEObjectPropertyManager.ObjectPropertySet(sName, "Zorder", "1", "GUI"); // OSAEScreenControlManager.ScreenObjectAdd(currentScreen, cboObject.Text, sName); }
protected void si_S1I2ImagePicked(object sender, EventArgs e) { OSAEImageManager imgMgr = new OSAEImageManager(); State1Img2 = imgMgr.GetImage((int)sender); imgState1Img2.Source = LoadImage(State1Img2.Data); Validate_Initial_Coordinates(); }
public void fillObject(ExportObject exObj) { if (exObj.Type == "Image") { OSAEImageManager IM = new OSAEImageManager(); OSAEImage img = IM.GetImage(exObj.Name); exObj.ExportFileName = exObj.Name + "." + img.Type; exObj.byteData = img.Data; exObj.ByteSize = img.Data.Length; } else if (exObj.Type == "File") { using (FileStream fs = new FileStream(exObj.Name, FileMode.Open, FileAccess.Read)) { byte[] filebytes = new byte[fs.Length]; int numBytesToRead = (int)fs.Length; int numBytesRead = 0; while (numBytesToRead > 0) { int n = fs.Read(filebytes, numBytesRead, numBytesToRead); if (n == 0) { break; } numBytesRead += n; numBytesToRead -= n; } numBytesToRead = filebytes.Length; exObj.ByteSize = filebytes.Length; } } else if (exObj.Type == "Log") { DataSet myDataSet = new DataSet(); if (exObj.Name == "Debug Log") { myDataSet = OSAESql.RunSQL("SELECT * FROM osae_debug_log"); DataTable dt = myDataSet.Tables[0]; StringBuilder sb = new StringBuilder(); for (int k = 0; k < dt.Columns.Count; k++) { sb.Append(dt.Columns[k].ColumnName + ','); } sb.Append("\r\n"); for (int i = 0; i < dt.Rows.Count; i++) { for (int k = 0; k < dt.Columns.Count; k++) { sb.Append(dt.Rows[i][k].ToString().Replace(",", ";") + ','); } sb.Append("\r\n"); } exObj.stringData = sb.ToString(); exObj.byteData = Encoding.UTF8.GetBytes(exObj.stringData); exObj.ByteSize = exObj.byteData.Length; } else if (exObj.Name == "Event Log") { myDataSet = OSAESql.RunSQL("SELECT * FROM osae_event_log"); DataTable dt = myDataSet.Tables[0]; StringBuilder sb = new StringBuilder(); for (int k = 0; k < dt.Columns.Count; k++) { sb.Append(dt.Columns[k].ColumnName + ','); } sb.Append("\r\n"); for (int i = 0; i < dt.Rows.Count; i++) { for (int k = 0; k < dt.Columns.Count; k++) { sb.Append(dt.Rows[i][k].ToString().Replace(",", ";") + ','); } sb.Append("\r\n"); } exObj.stringData = sb.ToString(); exObj.byteData = Encoding.UTF8.GetBytes(exObj.stringData); exObj.ByteSize = exObj.byteData.Length; } else if (exObj.Name == "Method Log") { myDataSet = OSAESql.RunSQL("SELECT * FROM osae_method_log"); DataTable dt = myDataSet.Tables[0]; StringBuilder sb = new StringBuilder(); for (int k = 0; k < dt.Columns.Count; k++) { sb.Append(dt.Columns[k].ColumnName + ','); } sb.Append("\r\n"); for (int i = 0; i < dt.Rows.Count; i++) { for (int k = 0; k < dt.Columns.Count; k++) { sb.Append(dt.Rows[i][k].ToString().Replace(",", ";") + ','); } sb.Append("\r\n"); } exObj.stringData = sb.ToString(); exObj.byteData = Encoding.UTF8.GetBytes(exObj.stringData); exObj.ByteSize = exObj.byteData.Length; } else { if (exObj.Name == "Server Log") { myDataSet = OSAESql.RunSQL("SELECT * FROM osae_log"); } else { myDataSet = OSAESql.RunSQL("SELECT * FROM osae_log WHERE Logger = '" + exObj.Name + "'"); } DataTable dt = myDataSet.Tables[0]; StringBuilder sb = new StringBuilder(); for (int k = 0; k < dt.Columns.Count; k++) { sb.Append(dt.Columns[k].ColumnName + ','); } sb.Append("\r\n"); for (int i = 0; i < dt.Rows.Count; i++) { for (int k = 0; k < dt.Columns.Count; k++) { sb.Append(dt.Rows[i][k].ToString().Replace(",", ";") + ','); } sb.Append("\r\n"); } exObj.stringData = sb.ToString(); exObj.byteData = Encoding.UTF8.GetBytes(exObj.stringData); exObj.ByteSize = exObj.byteData.Length; } } else if (exObj.Type == "Object") { string sql = OSAE.OSAEObjectManager.ObjectExport(exObj.Name); exObj.stringData = sql; exObj.byteData = Encoding.UTF8.GetBytes(exObj.stringData); exObj.ByteSize = exObj.byteData.Length; } else if (exObj.Type == "ObjectType") { string sql = OSAE.OSAEObjectTypeManager.ObjectTypeExport(exObj.Name); exObj.stringData = sql; exObj.byteData = Encoding.UTF8.GetBytes(exObj.stringData); exObj.ByteSize = exObj.byteData.Length; } else if (exObj.Type == "Pattern") { string sql = OSAE.OSAEScriptManager.PatternExport(exObj.Name); exObj.stringData = sql; exObj.byteData = Encoding.UTF8.GetBytes(exObj.stringData); exObj.ByteSize = exObj.byteData.Length; } else if (exObj.Type == "Readers") { //string sql = OSAE.OSAEReadersManager.ReaderExport(exObj.Name); //exObj.stringData = sql; //exObj.byteData = Encoding.UTF8.GetBytes(exObj.stringData); //exObj.ByteSize = exObj.byteData.Length; } else if (exObj.Type == "Schedule") { string sql = OSAE.OSAEScheduleManager.ScheduleExport(exObj.Name); exObj.stringData = sql; exObj.byteData = Encoding.UTF8.GetBytes(exObj.stringData); exObj.ByteSize = exObj.byteData.Length; } else if (exObj.Type == "Screen") { string sql = OSAE.OSAEObjectManager.ObjectExport(exObj.Name); exObj.stringData = sql; exObj.byteData = Encoding.UTF8.GetBytes(exObj.stringData); exObj.ByteSize = exObj.byteData.Length; } else if (exObj.Type == "Script") { string sql = OSAE.OSAEScriptManager.ExportScript(exObj.Name); exObj.stringData = sql; exObj.byteData = Encoding.UTF8.GetBytes(exObj.stringData); exObj.ByteSize = exObj.byteData.Length; } }
/// <summary> /// Load the objects from the DB into the combo box /// </summary> private void LoadCurrentScreenObject(string controlName) { OSAEImageManager imgMgr = new OSAEImageManager(); cboObject.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Object Name").Value; cboState1.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 Name").Value; try { State1Img1 = imgMgr.GetImage(OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 Image").Value); imgState1Img1.Source = LoadImage(State1Img1.Data); Validate_Initial_Coordinates(); } catch (Exception ex) { } try { State1Img2 = imgMgr.GetImage(OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 Image 2").Value); imgState1Img2.Source = LoadImage(State1Img2.Data); Validate_Initial_Coordinates(); } catch (Exception ex) { } try { State1Img3 = imgMgr.GetImage(OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 Image 3").Value); imgState1Img3.Source = LoadImage(State1Img3.Data); Validate_Initial_Coordinates(); } catch (Exception ex) { } try { State1Img4 = imgMgr.GetImage(OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 Image 4").Value); imgState1Img4.Source = LoadImage(State1Img4.Data); Validate_Initial_Coordinates(); } catch (Exception ex) { } txtState1X.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 X").Value; txtState1Y.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 Y").Value; cboState2.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 Name").Value; try { State2Img1 = imgMgr.GetImage(OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 Image").Value); imgState2Img1.Source = LoadImage(State2Img1.Data); Validate_Initial_Coordinates(); } catch (Exception ex) { } try { State2Img2 = imgMgr.GetImage(OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 Image 2").Value); imgState2Img2.Source = LoadImage(State2Img2.Data); Validate_Initial_Coordinates(); } catch (Exception ex) { } try { State2Img3 = imgMgr.GetImage(OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 Image 3").Value); imgState2Img3.Source = LoadImage(State2Img3.Data); Validate_Initial_Coordinates(); } catch (Exception ex) { } try { State2Img4 = imgMgr.GetImage(OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 Image 4").Value); imgState2Img4.Source = LoadImage(State2Img4.Data); Validate_Initial_Coordinates(); } catch (Exception ex) { } txtState2X.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 X").Value; txtState2Y.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 Y").Value; cboSliderMethod.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Slider Method").Value; try { chkRepeat.IsChecked = Convert.ToBoolean(OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Repeat Animation").Value); } catch (Exception ex) { chkRepeat.IsChecked = true; } try { chkSlider.IsChecked = Convert.ToBoolean(OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Show Slider").Value); } catch (Exception ex) { chkSlider.IsChecked = false; } try { txtDelay.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Frame Delay").Value; } catch (Exception ex) { txtDelay.Text = "500"; } }
private void LoadCurrentScreenObject(string controlName) { cboScreens.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Screen").Value; txtX.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "X").Value; txtY.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Y").Value; txtZOrder.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "ZOrder").Value; OSAEImageManager imgMgr = new OSAEImageManager(); try { img = imgMgr.GetImage(OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Image").Value); imgScreen.Source = LoadImage(img.Data); Validate_Initial_Coordinates(); } catch (Exception ex) { } }
private void LoadCurrentScreenObject(string screenName) { OSAEImageManager imgMgr = new OSAEImageManager(); try { img = imgMgr.GetImage(OSAEObjectPropertyManager.GetObjectPropertyValue(screenName, "Background Image").Value); if (img != null) { imgScreen.Source = LoadImage(img.Data); } } catch (Exception ex) { } }
/// <summary> /// Load the objects from the DB into the combo box /// </summary> private void LoadCurrentScreenObject(string controlName) { string sCheckName = ""; OSAEImageManager imgMgr = new OSAEImageManager(); cboObject.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Object Name").Value; cboState1.SelectedValue = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 Name").Value; try { sCheckName = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 Image").Value; if (sCheckName != "") { State1Img1 = imgMgr.GetImage(sCheckName); MemoryStream ms1 = new MemoryStream(State1Img1.Data); BitmapImage bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.StreamSource = ms1; bitmapImage.EndInit(); ImageBehavior.SetAnimatedSource(imgState1Img1, bitmapImage); //imgState1Img1.Source = LoadImage(State1Img1.Data); Validate_Initial_Coordinates(); lblState1X.IsEnabled = false; lblState1Y.IsEnabled = false; txtState1X.IsEnabled = true; txtState1Y.IsEnabled = true; lblZOrder.IsEnabled = true; txtZOrder.IsEnabled = true; if (State1Img1.Type != "gif") { btnLoadS1I2.IsEnabled = true; imgState1Img2.IsEnabled = true; } } } catch { } try { sCheckName = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 Image 2").Value; if (sCheckName != "") { State1Img2 = imgMgr.GetImage(sCheckName); imgState1Img2.Source = LoadImage(State1Img2.Data); txtDelay.IsEnabled = true; chkRepeat.IsEnabled = true; btnLoadS1I3.IsEnabled = true; Validate_Initial_Coordinates(); } } catch { } try { sCheckName = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 Image 3").Value; if (sCheckName != "") { State1Img3 = imgMgr.GetImage(sCheckName); imgState1Img3.Source = LoadImage(State1Img3.Data); txtDelay.IsEnabled = true; chkRepeat.IsEnabled = true; btnLoadS1I4.IsEnabled = true; Validate_Initial_Coordinates(); } } catch { } try { sCheckName = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 Image 4").Value; if (sCheckName != "") { State1Img4 = imgMgr.GetImage(sCheckName); imgState1Img4.Source = LoadImage(State1Img4.Data); txtDelay.IsEnabled = true; chkRepeat.IsEnabled = true; Validate_Initial_Coordinates(); } } catch { } txtState1X.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 X").Value; txtState1Y.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 Y").Value; txtZOrder.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "ZOrder").Value; cboState2.SelectedValue = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 Name").Value; try { sCheckName = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 Image").Value; if (sCheckName != "") { State2Img1 = imgMgr.GetImage(sCheckName); MemoryStream ms1 = new MemoryStream(State2Img1.Data); BitmapImage bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.StreamSource = ms1; bitmapImage.EndInit(); ImageBehavior.SetAnimatedSource(imgState2Img1, bitmapImage); //imgState2Img1.Source = LoadImage(State2Img1.Data); Validate_Initial_Coordinates(); lblState2X.IsEnabled = true; lblState2Y.IsEnabled = true; txtState2X.IsEnabled = true; txtState2Y.IsEnabled = true; lblZOrder.IsEnabled = true; txtZOrder.IsEnabled = true; if (State1Img1.Type != "gif") { btnLoadS2I2.IsEnabled = true; imgState1Img2.IsEnabled = true; } } } catch { } try { sCheckName = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 Image 2").Value; if (sCheckName != "") { State2Img2 = imgMgr.GetImage(sCheckName); imgState2Img2.Source = LoadImage(State2Img2.Data); txtDelay.IsEnabled = true; chkRepeat.IsEnabled = true; btnLoadS2I3.IsEnabled = true; Validate_Initial_Coordinates(); } } catch { } try { sCheckName = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 Image 3").Value; if (sCheckName != "") { State2Img3 = imgMgr.GetImage(sCheckName); imgState2Img3.Source = LoadImage(State2Img3.Data); txtDelay.IsEnabled = true; chkRepeat.IsEnabled = true; btnLoadS2I4.IsEnabled = true; Validate_Initial_Coordinates(); } } catch { } try { sCheckName = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 Image 4").Value; if (sCheckName != "") { State2Img4 = imgMgr.GetImage(sCheckName); imgState2Img4.Source = LoadImage(State2Img4.Data); txtDelay.IsEnabled = true; chkRepeat.IsEnabled = true; Validate_Initial_Coordinates(); } } catch { } txtState2X.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 X").Value; txtState2Y.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 Y").Value; chkSlider.IsEnabled = OSAEObjectPropertyManager.ObjectPropertyExists(cboObject.SelectedValue.ToString(), "Level"); if (chkSlider.IsEnabled) { try { chkSlider.IsChecked = Convert.ToBoolean(OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Show Slider").Value); } catch { chkSlider.IsChecked = false; } if (chkSlider.IsChecked.Value) cboSliderMethod.SelectedValue = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Slider Method").Value; } try { chkRepeat.IsChecked = Convert.ToBoolean(OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Repeat Animation").Value); } catch { chkRepeat.IsChecked = true; } try { txtDelay.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Frame Delay").Value; } catch { txtDelay.Text = "500"; } }
public void Update() { OSAEImageManager imgMgr = new OSAEImageManager(); bool stateChanged = false; try { OSAEObjectState stateCurrent = OSAEObjectStateManager.GetObjectStateValue(ObjectName); if (CurState != stateCurrent.Value) { stateChanged = true; } CurState = stateCurrent.Value; CurStateLabel = stateCurrent.StateLabel; LastStateChange = stateCurrent.LastStateChange; } catch { } foreach (OSAEObjectProperty p in screenObject.Properties) { if (p.Value.ToLower() == CurState.ToLower()) { StateMatch = p.Name.Substring(0, p.Name.LastIndexOf(' ')); } } try { Location.X = Double.Parse(OSAE.OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name, StateMatch + " X").Value); Location.Y = Double.Parse(OSAE.OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name, StateMatch + " Y").Value); try { string propertyCheck = OSAEObjectPropertyManager.GetObjectPropertyValue(ObjectName, "Light Level").Value; if (propertyCheck != "") { LightLevel = Convert.ToUInt16(propertyCheck); } else { LightLevel = 100; } } catch { } if (sliderVisible && updatingSlider == false) { try { CurLevel = OSAEObjectPropertyManager.GetObjectPropertyValue(ObjectName, "Level").Value; } catch { CurLevel = "0"; } Dispatcher.Invoke((Action)(() => { sldSlider.ToolTip = CurLevel + "%"; sldSlider.Value = Convert.ToUInt16(CurLevel); if (CurLevel != "") { Image.ToolTip = ObjectName + "\n" + CurStateLabel + " (" + CurLevel + "%) since: " + LastStateChange; } else { Image.ToolTip = ObjectName + "\n" + CurStateLabel + " since: " + LastStateChange; } })); } if (stateChanged) { timer.Stop(); string imgName = screenObject.Property(StateMatch + " Image").Value; string imgName2 = screenObject.Property(StateMatch + " Image 2").Value; string imgName3 = screenObject.Property(StateMatch + " Image 3").Value; string imgName4 = screenObject.Property(StateMatch + " Image 4").Value; if (imgName != "") { OSAEImage img1 = imgMgr.GetImage(imgName); if (img1 != null) { ms1 = new MemoryStream(img1.Data); imageFrames = 1; currentFrame = 1; Dispatcher.Invoke((Action)(() => { BitmapImage bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.StreamSource = ms1; bitmapImage.EndInit(); Image.Source = bitmapImage; ImageWidth = bitmapImage.Width; ImageHeight = bitmapImage.Height; })); // Primary Frame is loaded, load up additional frames for the time to display. if (imgName2 != "") { OSAEImage img2 = imgMgr.GetImage(imgName2); if (img2 != null) { ms2 = new MemoryStream(img2.Data); imageFrames = 2; if (imgName3 != "") { OSAEImage img3 = imgMgr.GetImage(imgName3); if (img3 != null) { ms3 = new MemoryStream(img3.Data); imageFrames = 3; if (imgName4 != "") { OSAEImage img4 = imgMgr.GetImage(imgName4); if (img4 != null) { ms4 = new MemoryStream(img4.Data); imageFrames = 4; } } } } } } } } else { Dispatcher.Invoke((Action)(() => { Image.Source = null; // Image.Visibility = System.Windows.Visibility.Hidden; })); } if (imageFrames > 1) { timer.Start(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "StateImage Update"); } }
protected void si_S1I2ImagePicked(object sender, EventArgs e) { OSAEImageManager imgMgr = new OSAEImageManager(); State1Img2 = imgMgr.GetImage((int)sender); imgState1Img2.Source = LoadImage(State1Img2.Data); imgState1Img2.ToolTip = "Width:" + imgState1Img2.Width + " Height:" + imgState1Img2.Height; Validate_Initial_Coordinates(); btnLoadS1I3.IsEnabled = true; imgState1Img3.IsEnabled = true; lblAnimationDelay.IsEnabled = true; txtDelay.IsEnabled = true; chkRepeat.IsEnabled = true; }
public StateImage(OSAEObject sObject, string appName) { InitializeComponent(); OSAEImageManager imgMgr = new OSAEImageManager(); gAppName = appName; screenObject = sObject; ObjectName = screenObject.Property("Object Name").Value; // ObjectType = screenObject.Property("Object Name").Value; LinkedObject = OSAEObjectManager.GetObjectByName(ObjectName); SliderMethod = screenObject.Property("Slider Method").Value; CurState = OSAEObjectStateManager.GetObjectStateValue(ObjectName).Value; CurStateLabel = OSAEObjectStateManager.GetObjectStateValue(ObjectName).StateLabel; try { string propertyCheck = OSAEObjectPropertyManager.GetObjectPropertyValue(ObjectName, "Light Level").Value; if (propertyCheck != "") { LightLevel = Convert.ToUInt16(propertyCheck); } else { LightLevel = 100; } } catch { } LastStateChange = OSAEObjectStateManager.GetObjectStateValue(ObjectName).LastStateChange; Image.ToolTip = ObjectName + " " + CurStateLabel + "\n" + "since: " + LastStateChange; Image.Tag = ObjectName; Image.MouseLeftButtonUp += new MouseButtonEventHandler(State_Image_MouseLeftButtonUp); foreach (OSAEObjectProperty p in screenObject.Properties) { if (p.Value.ToLower() == CurState.ToLower()) { StateMatch = p.Name.Substring(0, p.Name.LastIndexOf(' ')); } } try { string imgName = screenObject.Property(StateMatch + " Image").Value; string imgName2 = screenObject.Property(StateMatch + " Image 2").Value; string imgName3 = screenObject.Property(StateMatch + " Image 3").Value; string imgName4 = screenObject.Property(StateMatch + " Image 4").Value; try { repeatAnimation = Convert.ToBoolean(screenObject.Property("Repeat Animation").Value); } catch { OSAEObjectPropertyManager.ObjectPropertySet(screenObject.Name, "Repeat Animation", "TRUE", gAppName); repeatAnimation = true; } try { frameDelay = Convert.ToInt16(screenObject.Property("Frame Delay").Value); } catch { frameDelay = 100; OSAEObjectPropertyManager.ObjectPropertySet(screenObject.Name, "Frame Delay", "100", gAppName); } OSAEImage img1 = imgMgr.GetImage(imgName); if (img1 != null) { ms1 = new MemoryStream(img1.Data); BitmapImage bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.StreamSource = ms1; bitmapImage.EndInit(); Image.Source = bitmapImage; ImageWidth = bitmapImage.Width; ImageHeight = bitmapImage.Height; Image.Visibility = System.Windows.Visibility.Visible; imageFrames = 1; currentFrame = 1; OSAEImage img2 = imgMgr.GetImage(imgName2); if (img2 != null) { ms2 = new MemoryStream(img2.Data); imageFrames = 2; OSAEImage img3 = imgMgr.GetImage(imgName3); if (img3 != null) { ms3 = new MemoryStream(img3.Data); imageFrames = 3; OSAEImage img4 = imgMgr.GetImage(imgName4); if (img4 != null) { ms4 = new MemoryStream(img4.Data); imageFrames = 4; } } } } else { Image.Source = null; Image.Visibility = System.Windows.Visibility.Hidden; } } catch { } sliderVisible = Convert.ToBoolean(screenObject.Property("Show Slider").Value); if (sliderVisible) { sldSlider.Visibility = System.Windows.Visibility.Visible; try { CurLevel = OSAEObjectPropertyManager.GetObjectPropertyValue(ObjectName, "Level").Value; sldSlider.Value = Convert.ToUInt16(CurLevel); } catch { } } else { sldSlider.Visibility = System.Windows.Visibility.Hidden; } timer.Interval = TimeSpan.FromMilliseconds(frameDelay); timer.Tick += this.timer_Tick; if (imageFrames > 1) { timer.Start(); } }
/// <summary> /// Load the objects from the DB into the combo box /// </summary> private void LoadCurrentScreenObject(string controlName) { cboPressObject.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Press Object Name").Value; cboPressMethod.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Press Method Name").Value; txtPressParam1.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Press Method Param 1").Value; txtPressParam2.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Press Method Param 2").Value; cboPressScript.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Press Script Name").Value; txtPressScriptParam1.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Press Script Param 1").Value; txtPressScriptParam2.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Press Script Param 2").Value; cboReleaseObject.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Release Object Name").Value; cboReleaseMethod.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Release Method Name").Value; txtReleaseParam1.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Release Method Param 1").Value; txtReleaseParam2.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Release Method Param 2").Value; cboReleaseScript.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Release Script Name").Value; txtReleaseScriptParam1.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Release Script Param 1").Value; txtReleaseScriptParam2.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Release Script Param 2").Value; txtNormalX.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "X").Value; txtNormalY.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Y").Value; txtZOrder.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "ZOrder").Value; OSAEImageManager imgMgr = new OSAEImageManager(); try { imgNormalRaw = imgMgr.GetImage(OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Normal Image").Value); imgNormal.Source = LoadImage(imgNormalRaw.Data); Validate_Initial_Coordinates(); } catch { } try { imgPressedRaw = imgMgr.GetImage(OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Pressed Image").Value); imgPressed.Source = LoadImage(imgPressedRaw.Data); Validate_Initial_Coordinates(); } catch { } }
public StateImage(OSAEObject sObject, string appName) { InitializeComponent(); OSAEImageManager imgMgr = new OSAEImageManager(); gAppName = appName; screenObject = sObject; ObjectName = screenObject.Property("Object Name").Value; LinkedObject = OSAEObjectManager.GetObjectByName(ObjectName); SliderMethod = screenObject.Property("Slider Method").Value; CurState = OSAEObjectStateManager.GetObjectStateValue(ObjectName).Value; CurStateLabel = OSAEObjectStateManager.GetObjectStateValue(ObjectName).StateLabel; try { string propertyCheck = OSAEObjectPropertyManager.GetObjectPropertyValue(ObjectName, "Light Level").Value; if (propertyCheck != "") LightLevel = Convert.ToUInt16(propertyCheck); else LightLevel = 100; } catch { } LastStateChange = OSAEObjectStateManager.GetObjectStateValue(ObjectName).LastStateChange; Image.ToolTip = ObjectName + " " + CurStateLabel + "\n" + "since: " + LastStateChange; Image.Tag = ObjectName; Image.MouseLeftButtonUp += new MouseButtonEventHandler(State_Image_MouseLeftButtonUp); foreach (OSAEObjectProperty p in screenObject.Properties) { if (p.Value.ToLower() == CurState.ToLower()) StateMatch = p.Name.Substring(0, p.Name.LastIndexOf(' ')); } try { string imgName = screenObject.Property(StateMatch + " Image").Value; string imgName2 = screenObject.Property(StateMatch + " Image 2").Value; string imgName3 = screenObject.Property(StateMatch + " Image 3").Value; string imgName4 = screenObject.Property(StateMatch + " Image 4").Value; try { repeatAnimation = Convert.ToBoolean(screenObject.Property("Repeat Animation").Value); } catch { OSAEObjectPropertyManager.ObjectPropertySet(screenObject.Name, "Repeat Animation", "TRUE", gAppName); repeatAnimation = true; } try { frameDelay = Convert.ToInt16(screenObject.Property("Frame Delay").Value); } catch { frameDelay = 100; OSAEObjectPropertyManager.ObjectPropertySet(screenObject.Name, "Frame Delay", "100", gAppName); } OSAEImage img1 = imgMgr.GetImage(imgName); if (img1.Type == "gif") { ms1 = new MemoryStream(img1.Data); BitmapImage bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.StreamSource = ms1; bitmapImage.EndInit(); //Image.Source = bitmapImage; ImageWidth = bitmapImage.Width; ImageHeight = bitmapImage.Height; ImageBehavior.SetAnimatedSource(Image, bitmapImage); Image.Visibility = System.Windows.Visibility.Visible; } else if (img1 != null) { ms1 = new MemoryStream(img1.Data); BitmapImage bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.StreamSource = ms1; bitmapImage.EndInit(); Image.Source = bitmapImage; ImageWidth = bitmapImage.Width; ImageHeight = bitmapImage.Height; Image.Visibility = System.Windows.Visibility.Visible; imageFrames = 1; currentFrame = 1; OSAEImage img2 = imgMgr.GetImage(imgName2); if (img2 != null) { ms2 = new MemoryStream(img2.Data); imageFrames = 2; OSAEImage img3 = imgMgr.GetImage(imgName3); if (img3 != null) { ms3 = new MemoryStream(img3.Data); imageFrames = 3; OSAEImage img4 = imgMgr.GetImage(imgName4); if (img4 != null) { ms4 = new MemoryStream(img4.Data); imageFrames = 4; } } } } else { Image.Source = null; Image.Visibility = System.Windows.Visibility.Hidden; } } catch { } sliderVisible = Convert.ToBoolean(screenObject.Property("Show Slider").Value); if (sliderVisible) { sldSlider.Visibility = System.Windows.Visibility.Visible; try { CurLevel = OSAEObjectPropertyManager.GetObjectPropertyValue(ObjectName, "Level").Value; sldSlider.Value = Convert.ToUInt16(CurLevel); } catch { } } else sldSlider.Visibility = System.Windows.Visibility.Hidden; timer.Interval = TimeSpan.FromMilliseconds(frameDelay); timer.Tick += this.timer_Tick; if (imageFrames > 1) timer.Start(); }
public void Update() { OSAEImageManager imgMgr = new OSAEImageManager(); bool stateChanged = false; try { OSAEObjectState stateCurrent = OSAEObjectStateManager.GetObjectStateValue(ObjectName); if (CurState != stateCurrent.Value) stateChanged = true; CurState = stateCurrent.Value; CurStateLabel = stateCurrent.StateLabel; LastStateChange = stateCurrent.LastStateChange; } catch { } foreach (OSAEObjectProperty p in screenObject.Properties) { if (p.Value.ToLower() == CurState.ToLower()) StateMatch = p.Name.Substring(0, p.Name.LastIndexOf(' ')); } try { Location.X = Double.Parse(OSAE.OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name, StateMatch + " X").Value); Location.Y = Double.Parse(OSAE.OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name, StateMatch + " Y").Value); try { string propertyCheck = OSAEObjectPropertyManager.GetObjectPropertyValue(ObjectName, "Light Level").Value; if (propertyCheck != "") LightLevel = Convert.ToUInt16(propertyCheck); else LightLevel = 100; } catch { } if (sliderVisible && updatingSlider == false) { try { CurLevel = OSAEObjectPropertyManager.GetObjectPropertyValue(ObjectName, "Level").Value; } catch { CurLevel = "0"; } Dispatcher.Invoke((Action)(() => { sldSlider.ToolTip = CurLevel + "%"; sldSlider.Value = Convert.ToUInt16(CurLevel); if (CurLevel != "") Image.ToolTip = ObjectName + "\n" + CurStateLabel + " (" + CurLevel + "%) since: " + LastStateChange; else Image.ToolTip = ObjectName + "\n" + CurStateLabel + " since: " + LastStateChange; })); } if (stateChanged) { timer.Stop(); string imgName = screenObject.Property(StateMatch + " Image").Value; string imgName2 = screenObject.Property(StateMatch + " Image 2").Value; string imgName3 = screenObject.Property(StateMatch + " Image 3").Value; string imgName4 = screenObject.Property(StateMatch + " Image 4").Value; if (imgName != "") { OSAEImage img1 = imgMgr.GetImage(imgName); if (img1.Type == "gif") { ms1 = new MemoryStream(img1.Data); Dispatcher.Invoke((Action)(() => { Image.Source = null; Image.ToolTip = ObjectName + " " + CurStateLabel + "\n" + "since: " + LastStateChange; BitmapImage bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.StreamSource = ms1; bitmapImage.EndInit(); ImageWidth = bitmapImage.Width; ImageHeight = bitmapImage.Height; ImageBehavior.SetAnimatedSource(Image, bitmapImage); Image.Visibility = System.Windows.Visibility.Visible; })); } else if (img1 != null) { ms1 = new MemoryStream(img1.Data); imageFrames = 1; currentFrame = 1; Dispatcher.Invoke((Action)(() => { Image.Source = null; Image.ToolTip = ObjectName + " " + CurStateLabel + "\n" + "since: " + LastStateChange; BitmapImage bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.StreamSource = ms1; bitmapImage.EndInit(); Image.Source = bitmapImage; ImageWidth = bitmapImage.Width; ImageHeight = bitmapImage.Height; ImageBehavior.SetAnimatedSource(Image, bitmapImage); })); // Primary Frame is loaded, load up additional frames for the time to display. if (imgName2 != "") { OSAEImage img2 = imgMgr.GetImage(imgName2); if (img2 != null) { ms2 = new MemoryStream(img2.Data); imageFrames = 2; if (imgName3 != "") { OSAEImage img3 = imgMgr.GetImage(imgName3); if (img3 != null) { ms3 = new MemoryStream(img3.Data); imageFrames = 3; if (imgName4 != "") { OSAEImage img4 = imgMgr.GetImage(imgName4); if (img4 != null) { ms4 = new MemoryStream(img4.Data); imageFrames = 4; } } } } } } } } else { Dispatcher.Invoke((Action)(() => { Image.Source = null; // Image.Visibility = System.Windows.Visibility.Hidden; })); } if (imageFrames > 1) timer.Start(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "StateImage Update"); } }
/// <summary> /// Load the objects from the DB into the combo box /// </summary> private void LoadCurrentScreenObject(string controlName) { string sCheckName = ""; OSAEImageManager imgMgr = new OSAEImageManager(); cboObject.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Object Name").Value; cboState1.SelectedValue = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 Name").Value; try { sCheckName = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 Image").Value; if (sCheckName != "") { State1Img1 = imgMgr.GetImage(sCheckName); imgState1Img1.Source = LoadImage(State1Img1.Data); Validate_Initial_Coordinates(); lblState1X.IsEnabled = false; lblState1Y.IsEnabled = false; txtState1X.IsEnabled = true; txtState1Y.IsEnabled = true; lblZOrder.IsEnabled = true; txtZOrder.IsEnabled = true; btnLoadS1I2.IsEnabled = true; imgState1Img2.IsEnabled = true; } } catch { } try { sCheckName = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 Image 2").Value; if (sCheckName != "") { State1Img2 = imgMgr.GetImage(sCheckName); imgState1Img2.Source = LoadImage(State1Img2.Data); txtDelay.IsEnabled = true; chkRepeat.IsEnabled = true; btnLoadS1I3.IsEnabled = true; Validate_Initial_Coordinates(); } } catch { } try { sCheckName = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 Image 3").Value; if (sCheckName != "") { State1Img3 = imgMgr.GetImage(sCheckName); imgState1Img3.Source = LoadImage(State1Img3.Data); txtDelay.IsEnabled = true; chkRepeat.IsEnabled = true; btnLoadS1I4.IsEnabled = true; Validate_Initial_Coordinates(); } } catch { } try { sCheckName = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 Image 4").Value; if (sCheckName != "") { State1Img4 = imgMgr.GetImage(sCheckName); imgState1Img4.Source = LoadImage(State1Img4.Data); txtDelay.IsEnabled = true; chkRepeat.IsEnabled = true; Validate_Initial_Coordinates(); } } catch { } txtState1X.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 X").Value; txtState1Y.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 Y").Value; txtZOrder.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "ZOrder").Value; cboState2.SelectedValue = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 Name").Value; try { sCheckName = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 Image").Value; if (sCheckName != "") { State2Img1 = imgMgr.GetImage(sCheckName); imgState2Img1.Source = LoadImage(State2Img1.Data); Validate_Initial_Coordinates(); lblState2X.IsEnabled = true; lblState2Y.IsEnabled = true; txtState2X.IsEnabled = true; txtState2Y.IsEnabled = true; lblZOrder.IsEnabled = true; txtZOrder.IsEnabled = true; btnLoadS2I2.IsEnabled = true; } } catch { } try { sCheckName = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 Image 2").Value; if (sCheckName != "") { State2Img2 = imgMgr.GetImage(sCheckName); imgState2Img2.Source = LoadImage(State2Img2.Data); txtDelay.IsEnabled = true; chkRepeat.IsEnabled = true; btnLoadS2I3.IsEnabled = true; Validate_Initial_Coordinates(); } } catch { } try { sCheckName = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 Image 3").Value; if (sCheckName != "") { State2Img3 = imgMgr.GetImage(sCheckName); imgState2Img3.Source = LoadImage(State2Img3.Data); txtDelay.IsEnabled = true; chkRepeat.IsEnabled = true; btnLoadS2I4.IsEnabled = true; Validate_Initial_Coordinates(); } } catch { } try { sCheckName = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 Image 4").Value; if (sCheckName != "") { State2Img4 = imgMgr.GetImage(sCheckName); imgState2Img4.Source = LoadImage(State2Img4.Data); txtDelay.IsEnabled = true; chkRepeat.IsEnabled = true; Validate_Initial_Coordinates(); } } catch { } txtState2X.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 X").Value; txtState2Y.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 Y").Value; chkSlider.IsEnabled = OSAEObjectPropertyManager.ObjectPropertyExists(cboObject.SelectedValue.ToString(), "Level"); if (chkSlider.IsEnabled) { try { chkSlider.IsChecked = Convert.ToBoolean(OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Show Slider").Value); } catch { chkSlider.IsChecked = false; } if (chkSlider.IsChecked.Value) { cboSliderMethod.SelectedValue = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Slider Method").Value; } } try { chkRepeat.IsChecked = Convert.ToBoolean(OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Repeat Animation").Value); } catch { chkRepeat.IsChecked = true; } try { txtDelay.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Frame Delay").Value; } catch { txtDelay.Text = "500"; } }