protected void Page_Load(object sender, EventArgs e)
    {
        ObjectName = screenObject.Property("Object Name").Value;
        OSAEObjectState os = OSAEObjectStateManager.GetObjectStateValue(ObjectName);

        CurrentState = os.Value;

        OffTimer    = Convert.ToUInt16(OSAEObjectPropertyManager.GetObjectPropertyValue(ObjectName, "OFF TIMER").Value);
        TimeInState = (int)os.TimeInState;

        string sBackColor = screenObject.Property("Back Color").Value;
        string sForeColor = screenObject.Property("Fore Color").Value;
        string sPrefix    = screenObject.Property("Prefix").Value;
        string sSuffix    = screenObject.Property("Suffix").Value;
        string iFontSize  = screenObject.Property("Font Size").Value;

        if (CurrentState == "OFF")
        {
            sValue = os.StateLabel;
        }
        else
        {
            span   = TimeSpan.FromSeconds(OffTimer - TimeInState); //Or TimeSpan.FromSeconds(seconds); (see Jakob C´s answer)
            sValue = span.ToString(@"mm\:ss");
        }

        TimerLabel.Text = sValue;
        TimerLabel.Attributes.Add("Style", "position:absolute;top:" + (Int32.Parse(screenObject.Property("Y").Value) + 50).ToString() + "px;left:" + (Int32.Parse(screenObject.Property("X").Value) + 10).ToString() + "px;z-index:" + (Int32.Parse(screenObject.Property("ZOrder").Value) + 10).ToString() + ";");

        if (sBackColor != "")
        {
            try
            {
                TimerLabel.BackColor = Color.FromName(sBackColor);
            }
            catch (Exception)
            {
            }
        }
        if (sForeColor != "")
        {
            try
            {
                TimerLabel.ForeColor = Color.FromName(sForeColor);
            }
            catch (Exception)
            {
            }
        }
        if (iFontSize != "")
        {
            try
            {
                TimerLabel.Font.Size = new FontUnit(iFontSize);
            }
            catch (Exception)
            {
            }
        }
    }
예제 #2
0
        public OSAEObjectState GetObjectState(string name)
        {
            OSAEObjectState state = OSAEObjectStateManager.GetObjectStateValue(name);

            Log.Debug("Looking up object state:  " + name + ".  I Found " + state.StateLabel + ".");
            return(state);
        }
        public void Update()
        {
            OSAEObjectState stateCurrent = OSAEObjectStateManager.GetObjectStateValue(objName);

            LastStateChange = stateCurrent.LastStateChange;
            if (CurState != stateCurrent.Value)
            {
                CurState = stateCurrent.Value;
                Update_Button();
            }
        }
예제 #4
0
 public OSAEObjectState GetObjectState(string name, string authkey)
 {
     if (OSAESecurity.Authorize(authkey, name))
     {
         OSAEObjectState state = OSAEObjectStateManager.GetObjectStateValue(name);
         Log.Debug("Looking up object state:  " + name + ".  I Found " + state.StateLabel + ".");
         return(state);
     }
     else
     {
         return(null);
     }
 }
예제 #5
0
        public void Update()
        {
            bool            stateChanged = false;
            OSAEObjectState stateCurrent = OSAEObjectStateManager.GetObjectStateValue(objName);

            if (this.CurState != stateCurrent.Value)
            {
                stateChanged = true;
            }
            this.CurState        = stateCurrent.Value;
            this.CurStateLabel   = stateCurrent.StateLabel;
            this.LastStateChange = stateCurrent.LastStateChange;
            if (stateChanged)
            {
                // add update code here!
            }
        }
예제 #6
0
        public void Update()
        {
            bool            stateChanged = false;
            OSAEObjectState stateCurrent = OSAEObjectStateManager.GetObjectStateValue(objName);

            if (this.CurState != stateCurrent.Value)
            {
                stateChanged = true;
            }
            this.CurState        = stateCurrent.Value;
            this.CurStateLabel   = stateCurrent.StateLabel;
            this.LastStateChange = stateCurrent.LastStateChange;
            if (stateChanged)
            {
                // Code that executes when the associated object has changed
                refreshControl();
            }
        }
예제 #7
0
        public void Update()
        {
            Dispatcher.Invoke((Action)(() =>
            {
                string sValue;
                OSAEObjectState os = OSAEObjectStateManager.GetObjectStateValue(ObjectName);
                CurrentState = os.Value;

                TimeSpan ts = DateTime.Now - LastUpdated;
                TimeInState = (int)ts.TotalSeconds;
                if (os.Value == "OFF")
                {
                    sValue = os.StateLabel;
                    timerLabel.Content = sValue;
                }
                else
                {
                    span = TimeSpan.FromSeconds(OffTimer - TimeInState); //Or TimeSpan.FromSeconds(seconds); (see Jakob C´s answer)
                    sValue = span.ToString(@"mm\:ss");
                }
            }));
        }
예제 #8
0
        public TimerLabel(OSAEObject sObj)
        {
            InitializeComponent();
            screenObject = sObj;
            screenName   = Name;

            ObjectName = screenObject.Property("Object Name").Value;

            OSAEObjectState os = OSAEObjectStateManager.GetObjectStateValue(ObjectName);

            CurrentState = os.Value;

            OffTimer    = Convert.ToInt16(OSAEObjectPropertyManager.GetObjectPropertyValue(ObjectName, "OFF TIMER").Value);
            TimeInState = (int)os.TimeInState;

            string sValue;
            string sBackColor = screenObject.Property("Back Color").Value;
            string sForeColor = screenObject.Property("Fore Color").Value;
            string iFontSize  = screenObject.Property("Font Size").Value;
            string sFontName  = screenObject.Property("Font Name").Value;

            if (CurrentState == "OFF")
            {
                sValue = os.StateLabel;
            }
            else
            {
                span   = TimeSpan.FromSeconds(OffTimer - TimeInState); //Or TimeSpan.FromSeconds(seconds); (see Jakob C´s answer)
                sValue = span.ToString(@"mm\:ss");
            }

            if (sValue != "")
            {
                if (sBackColor != "")
                {
                    try
                    {
                        BrushConverter  conv  = new BrushConverter();
                        SolidColorBrush brush = conv.ConvertFromString(sBackColor) as SolidColorBrush;
                        timerLabel.Background = brush;
                    }
                    catch { }
                }
                if (sForeColor != "")
                {
                    try
                    {
                        BrushConverter  conv  = new BrushConverter();
                        SolidColorBrush brush = conv.ConvertFromString(sForeColor) as SolidColorBrush;
                        timerLabel.Foreground = brush;
                    }
                    catch { }
                }
                if (iFontSize != "")
                {
                    try
                    { timerLabel.FontSize = Convert.ToDouble(iFontSize); }
                    catch { }
                }
                timerLabel.Content = sValue;
            }
            else
            {
                timerLabel.Content = "";
            }

            timer.Interval = 1000;
            timer.Enabled  = true;
            timer.Elapsed += new ElapsedEventHandler(timer_tick);
        }
예제 #9
0
        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"); }
        }
예제 #10
0
        public OSAEObjectState GetObjectState(string name)
        {
            OSAEObjectState state = OSAEObjectStateManager.GetObjectStateValue(name);

            return(state);
        }