예제 #1
0
        private void buttonAddController_Click(object sender, EventArgs e)
        {
            List <KeyValuePair <string, object> > outputModules = new List <KeyValuePair <string, object> >();
            var availableModules = ApplicationServices.GetAvailableModules <IPreviewModuleInstance>();

            foreach (KeyValuePair <Guid, string> kvp in availableModules)
            {
                outputModules.Add(new KeyValuePair <string, object>(kvp.Value, kvp.Key));
            }
            Common.Controls.ListSelectDialog addForm = new Common.Controls.ListSelectDialog("Add Preview", (outputModules));
            if (addForm.ShowDialog() == DialogResult.OK)
            {
                IModuleDescriptor moduleDescriptor = ApplicationServices.GetModuleDescriptor((Guid)addForm.SelectedItem);
                string            name             = moduleDescriptor.TypeName;
                PreviewFactory    previewFactory   = new PreviewFactory();
                OutputPreview     preview          = (OutputPreview)previewFactory.CreateDevice((Guid)addForm.SelectedItem, name);
                VixenSystem.Previews.Add(preview);
                // In the case of a controller that has a form, the form will not be shown
                // until this event handler completes.  To make sure it's in a visible state
                // before evaluating if it's running or not, we're calling DoEvents.
                // I hate DoEvents calls, so if you know of a better way...
                Application.DoEvents();

                // select the new controller, and then repopulate the list -- it will make sure the currently
                // displayed controller is selected.
                _PopulateFormWithController(preview);
                _PopulateControllerList();

                _changesMade = true;
                Refresh();
            }
        }
예제 #2
0
        public IOutputDevice ReadObject(XElement element)
        {
            try {
                string name = XmlHelper.GetAttribute(element, ATTR_NAME);
                if (name == null)
                {
                    return(null);
                }

                Guid?typeId = XmlHelper.GetGuidAttribute(element, ATTR_TYPE_ID);
                if (typeId == null)
                {
                    return(null);
                }

                Guid?instanceId = XmlHelper.GetGuidAttribute(element, ATTR_INSTANCE_ID);
                if (instanceId == null)
                {
                    return(null);
                }

                PreviewFactory previewFactory = new PreviewFactory();
                OutputPreview  preview        = (OutputPreview)previewFactory.CreateDevice(typeId.Value, instanceId.Value, name);

                _Populate(preview, element);

                return(preview);
            } catch (Exception e) {
                logging.Error("Error loading Preview from XML", e);
                return(null);
            }
        }
예제 #3
0
        public IOutputDevice ReadObject(XElement element)
        {
            string name = XmlHelper.GetAttribute(element, ATTR_NAME);

            if (name == null)
            {
                return(null);
            }

            Guid?typeId = XmlHelper.GetGuidAttribute(element, ATTR_TYPE_ID);

            if (typeId == null)
            {
                return(null);
            }

            Guid?instanceId = XmlHelper.GetGuidAttribute(element, ATTR_INSTANCE_ID);

            if (instanceId == null)
            {
                return(null);
            }

            PreviewFactory previewFactory = new PreviewFactory();
            OutputPreview  preview        = (OutputPreview)previewFactory.CreateDevice(typeId.Value, instanceId.Value, name);

            _Populate(preview, element);

            return(preview);
        }
예제 #4
0
        private void buttonDuplicateSelected_Click(object sender, EventArgs e)
        {
            if (listViewControllers.SelectedItems.Count > 0)
            {
                foreach (ListViewItem item in listViewControllers.SelectedItems)
                {
                    OutputPreview op = item.Tag as OutputPreview;

                    PreviewFactory previewFactory = new PreviewFactory();
                    OutputPreview  preview        = (OutputPreview)previewFactory.CreateDevice(op.ModuleId, op.Name + "-copy");
                    if (preview.PreviewModule is IPreviewModuleInstance newInstance)
                    {
                        if (op.PreviewModule is IPreviewModuleInstance origInstance)
                        {
                            var md = origInstance.ModuleData.Clone();
                            //The new module will have it's own instance data. If we want to replace it we need to replace it in the
                            //ModuleStore as well so it will be saved. So remove it and then assign it and then update it in the store
                            md.ModuleDataSet.RemoveModuleInstanceData(newInstance);
                            newInstance.ModuleData = md;
                            md.ModuleDataSet.AssignModuleInstanceData(newInstance);
                        }
                    }
                    VixenSystem.Previews.Add(preview);
                    _PopulateFormWithController(preview);
                }

                _PopulateControllerList();

                _changesMade = true;
                Refresh();
            }
        }