Example #1
0
 public void UpdateVisualizerExecutionStateValues(ElementIntentStates elementIntentStates)
 {
     if(_view!=null)
     {
         _view.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() => UpdateModelExecutionStateValues(elementIntentStates)));
     }
 }
Example #2
0
 private void UpdateModelExecutionStateValues(ElementIntentStates elementIntentStates)
 {
     if (_visualizerViewModel != null)
     {
         _visualizerViewModel.UpdateExecutionStateValues(elementIntentStates);
     }
 }
Example #3
0
 public void UpdateVisualizerExecutionStateValues(ElementIntentStates elementIntentStates)
 {
     if (_view != null)
     {
         _view.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() => UpdateModelExecutionStateValues(elementIntentStates)));
     }
 }
 public void UpdateExecutionStateValues(ElementIntentStates elementIntentStates)
 {
     foreach (var displayItem in DataModel.DisplayItems)
     {
         displayItem.ResetColor(true);
         displayItem.UpdateElementColors(elementIntentStates);
     }
 }
        private void ProcessUpdate(ElementIntentStates elementStates)
        {
            Stopwatch timer = new Stopwatch();

            timer.Start();

            //displayForm.PreviewControl.ProcessUpdate(elementStates);
            displayForm.PreviewControl.BeginInvoke(new ProcessUpdateDelegate(displayForm.PreviewControl.ProcessUpdate), new object[] { elementStates });

            timer.Stop();

            VixenPreviewControl.updateCount      += 1;
            VixenPreviewControl.lastUpdateTime    = timer.ElapsedMilliseconds;
            VixenPreviewControl.totalUpdateTime  += timer.ElapsedMilliseconds;
            VixenPreviewControl.averageUpdateTime = VixenPreviewControl.totalUpdateTime / VixenPreviewControl.updateCount;
        }
Example #6
0
        public void UpdateElementColors(ElementIntentStates elementIntentStates)
        {
            foreach (var elementIntentState in elementIntentStates)
            {
                var     elementId = elementIntentState.Key;
                Element element   = VixenSystem.Elements.GetElement(elementId);
                if (element == null)
                {
                    continue;
                }
                ElementNode node = VixenSystem.Elements.GetElementNodeForElement(element);
                if (node == null)
                {
                    continue;
                }

                var nodeLayout = NodeLayouts.FirstOrDefault(x => x.NodeId == node.Id);
                if (nodeLayout != null)
                {
                    nodeLayout.ElementState = elementIntentState.Value;
                }
            }
        }
Example #7
0
 private void UpdateModelExecutionStateValues(ElementIntentStates elementIntentStates)
 {
     if(_visualizerViewModel!=null)
     {
         _visualizerViewModel.UpdateExecutionStateValues(elementIntentStates);
     }
 }
 public void UpdateExecutionStateValues(ElementIntentStates elementIntentStates)
 {
     foreach (var displayItem in DataModel.DisplayItems)
     {
         displayItem.ResetColor(true);
         displayItem.UpdateElementColors(elementIntentStates);
     }
 }
Example #9
0
        public void UpdateElementColors(ElementIntentStates elementIntentStates)
        {
            foreach (var elementIntentState in elementIntentStates)
            {
                var elementId = elementIntentState.Key;
                Element element = VixenSystem.Elements.GetElement(elementId);
                if (element == null) continue;
                ElementNode node = VixenSystem.Elements.GetElementNodeForElement(element);
                if (node == null) continue;

                var nodeLayout = NodeLayouts.FirstOrDefault(x => x.NodeId == node.Id);
                if (nodeLayout != null)
                {
                    nodeLayout.ElementState = elementIntentState.Value;
                }
            }
        }
Example #10
0
        protected override void Update()
        {
            ElementIntentStates ElementStates = new ElementIntentStates();

            ViewManager.UpdateVisualizerExecutionStateValues(ElementStates);
        }
Example #11
0
        public void Update()
        {
            ElementIntentStates elementIntentStates = new ElementIntentStates(VixenSystem.Elements.ToDictionary(x => x.Id, x => x.State));

            _UpdateModuleState(elementIntentStates);
        }
Example #12
0
 private void _UpdateModuleState(ElementIntentStates elementIntentStates)
 {
     _PreviewModule.UpdateState(elementIntentStates);
 }
Example #13
0
 public void UpdateState(ElementIntentStates elementIntentStates)
 {
     // Get the data referenced locally so we can get off this thread if need be.
     ElementStates = elementIntentStates;
     ThreadBehavior.BeginInvoke(Update);
 }
Example #14
0
        public void ProcessUpdate(ElementIntentStates elementStates)
        {
            renderTimer.Reset();
            renderTimer.Start();
            if (!_paused)
            {
                //FastPixel fp = new FastPixel(_background.Width, _background.Height);
                FastPixel fp      = new FastPixel(new Bitmap(_alphaBackground));
                Bitmap    floodBG = null;
                if (UseFloods)
                {
                    floodBG = PreviewTools.Copy32BPPBitmapSafe(_blankAlphaBackground);
                    //floodBG = new Bitmap(_blankAlphaBackground);
                    //floodBG = new Bitmap(_blankAlphaBackground.Width, _blankAlphaBackground.Height);
                    //Graphics g = Graphics.FromImage(floodBG);
                    //g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
                    //SolidBrush brush = new SolidBrush(Color.FromArgb(50, 255, 0, 0));
                    //g.FillEllipse(brush, new Rectangle(200, 200, 300, 300));
                    //g.DrawImage(_blankAlphaBackground, 0, 0);
                    //g.FillRectangle(_backgroundBrush, new Rectangle(0, 0, _blankAlphaBackground.Width, _blankAlphaBackground.Height));
                }
                fp.Lock();

                foreach (var channelIntentState in elementStates)
                {
                    var     elementId = channelIntentState.Key;
                    Element element   = VixenSystem.Elements.GetElement(elementId);
                    if (element == null)
                    {
                        continue;
                    }
                    ElementNode node = VixenSystem.Elements.GetElementNodeForElement(element);
                    if (node == null)
                    {
                        continue;
                    }

                    //foreach (IIntentState intentState in channelIntentState.Value)
                    //{
                    //    intentState.Dispatch(DisplayItems[0]);
                    //}

                    foreach (IIntentState <LightingValue> intentState in channelIntentState.Value)
                    {
                        if (_background != null)
                        {
                            List <PreviewPixel> pixels;
                            if (NodeToPixel.TryGetValue(node, out pixels))
                            {
                                foreach (PreviewPixel pixel in pixels)
                                {
                                    //Color.FromArgb((int)(Intensity * byte.MaxValue), Color.R, Color.G, Color.B);
                                    //LightingValue v = intentState.GetValue();
                                    //Color c = v.GetOpaqueIntensityAffectedColor();
                                    //Color c = v.GetAlphaChannelIntensityAffectedColor();
                                    Color c = intentState.GetValue().GetAlphaChannelIntensityAffectedColor();
                                    //Color c = Color.White;
                                    pixel.Draw(fp, c);
                                }
                            }
                        }
                    }
                }

                //if (UseFloods)
                //{
                //    foreach (DisplayItem displayItem in DisplayItems)
                //    {
                //        if (displayItem.Shape.StringType == PreviewBaseShape.StringTypes.Flood)
                //        {
                //            Color c = displayItem.Shape._pixels[0].PixelColor;
                //            int alpha = c.A;
                //            //int maxAlpha = 255 - BackgroundAlpha;
                //            //if (maxAlpha < 255)
                //            //{

                //            //}
                //            displayItem.Shape._pixels[0].PixelColor = Color.FromArgb(alpha, c.R, c.G, c.B);
                //            displayItem.Shape.Draw(floodBG, false, null);
                //            displayItem.Shape._pixels[0].PixelColor = Color.FromArgb(255 - BackgroundAlpha, 0, 0, 0);
                //        }
                //    }
                //}
                fp.Unlock(true);

                // First, draw our background image opaque
                bufferedGraphics.Graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
                //if (UseFloods)
                //{
                //    bufferedGraphics.Graphics.DrawImage(_background, 0, 0, _background.Width, _background.Height);
                //}
                //else
                //{
                //    bufferedGraphics.Graphics.DrawImage(_alphaBackground, 0, 0, _alphaBackground.Width, _alphaBackground.Height);
                //}

                // Now, draw our "pixel" image using alpha blending
                ///bufferedGraphics.Graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
                if (UseFloods)
                {
                    bufferedGraphics.Graphics.DrawImage(floodBG, 0, 0, _blankAlphaBackground.Width, _blankAlphaBackground.Height);
                }
                bufferedGraphics.Graphics.DrawImage(fp.Bitmap, 0, 0, fp.Width, fp.Height);

                if (!this.Disposing && bufferedGraphics != null)
                {
                    bufferedGraphics.Render(Graphics.FromHwnd(this.Handle));
                }

                fp = null;
            }

            renderTimer.Stop();
            lastRenderUpdateTime = renderTimer.ElapsedMilliseconds;
        }
		protected override void Update()
		{
			ElementIntentStates ElementStates = new ElementIntentStates();
			ViewManager.UpdateVisualizerExecutionStateValues(ElementStates);
		}