コード例 #1
0
        private void DataFlowList_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                var grid1 = sender as Grid;
                if (grid1 != null)
                {
                    var grid = grid1;
                    var item = grid.DataContext as DataFlowItem;
                    if (item != null)
                    {
                        var m = item;

                        //if (_context.Config.DataConfiguration.AutoCartClearTypes.Split(';').Contains(m.DataMessage.DataType))
                        //{
                        //    // Need to clear the current active cart
                        //    _context.ActiveCart.Slides.Clear();
                        //}
                        if (_context.Config.DataConfiguration.AutoCartAppendTypes.Split(';').Contains(m.DataMessage.DataType))
                        {
                            // Need to append to current active cart
                            _context.CreateCartForDataFlowItem(m, _context.PreviewCart);
                        }
                        if (_context.Config.DataConfiguration.AutoCartGenerationTypes.Split(';').Contains(m.DataMessage.DataType))
                        {
                            // Need to create a new cart
                            _context.CreateCartForDataFlowItem(m, null);
                        }
                        if (_context.Config.DataConfiguration.AutoEditorTypes.Split(';').Contains(m.DataMessage.DataType))
                        {
                            // Need to update the editor's template
                            if (_context.Config.DataConfiguration.DataFlowLeftActions.Split(';').Contains("Template"))
                            {
                                // Load template to editor
                                // Find appropriate template
                                var conf = _context.Config.DataConfiguration.DataItemConfigurations.Cast <DataItemConfiguration>().FirstOrDefault(c => c.DataType == m.DataMessage.DataType);
                                // Load corresponding template
                                if (conf != null)
                                {
                                    var newTemplate = new ManagerImageReference(_context.Config)
                                    {
                                        Template   = conf.DefaultTemplate,
                                        Link       = _context.Config.SlidesConfiguration.DefaultLink,
                                        CanRepeate = false
                                    };

                                    _context.EditorImage = newTemplate;
                                }
                            }
                            if (_context.Config.DataConfiguration.DataFlowLeftActions.Split(';').Contains("BackgroundUrl"))
                            {
                                // Set the background Uri
                                _context.EditorImage.Background = m.Url;
                            }
                            if (_context.Config.DataConfiguration.DataFlowLeftActions.Split(';').Contains("Context"))
                            {
                                // Set the context
                                _context.EditorImage.Context = m.DataMessage;
                            }
                            _context.EditorImage.ReRender(true);
                            _context.EditorImage = _context.EditorImage;
                        }
                    }
                }
            }
            catch (Exception)
            {
                // TODO HAndle and not generic Exceltion
            }
        }