Esempio n. 1
0
 public ColorSetsSetupForm(ColorStaticData colorStaticData)
 {
     _data = colorStaticData;
     InitializeComponent();
     Icon = Resources.Icon_Vixen3;
     buttonAddColor.Image       = Tools.GetIcon(Resources.add, 16);
     buttonAddColor.Text        = "";
     buttonAddColorSet.Image    = Tools.GetIcon(Resources.add, 16);
     buttonAddColorSet.Text     = "";
     buttonRemoveColorSet.Image = Tools.GetIcon(Resources.delete, 16);
     buttonRemoveColorSet.Text  = "";
 }
Esempio n. 2
0
 public ColorSetsSetupForm(ColorStaticData colorStaticData)
 {
     _data = colorStaticData;
     InitializeComponent();
     Icon = Resources.Icon_Vixen3;
     buttonAddColor.BackgroundImage       = Resources.add;
     buttonAddColor.Text                  = "";
     buttonAddColorSet.BackgroundImage    = Resources.add;
     buttonAddColorSet.Text               = "";
     buttonRemoveColorSet.BackgroundImage = Resources.delete;
     buttonRemoveColorSet.Text            = "";
 }
Esempio n. 3
0
		public ColorSetsSetupForm(ColorStaticData colorStaticData)
		{
			_data = colorStaticData;
			InitializeComponent();
			ForeColor = ThemeColorTable.ForeColor;
			BackColor = ThemeColorTable.BackgroundColor;
			ThemeUpdateControls.UpdateControls(this);
			Icon = Resources.Icon_Vixen3;
			buttonAddColor.Image = Tools.GetIcon(Resources.add, 16);
			buttonAddColor.Text = "";
			buttonAddColorSet.Image = Tools.GetIcon(Resources.add, 16);
			buttonAddColorSet.Text = "";
			buttonRemoveColorSet.Image = Tools.GetIcon(Resources.delete, 16);
			buttonRemoveColorSet.Text = "";
		}
Esempio n. 4
0
        public ColorSetsSetupForm(ColorStaticData colorStaticData)
        {
            _data = colorStaticData;
            InitializeComponent();
            ForeColor = ThemeColorTable.ForeColor;
            BackColor = ThemeColorTable.BackgroundColor;

            Icon = Resources.Icon_Vixen3;
            int iconSize = (int)(16 * ScalingTools.GetScaleFactor());

            buttonAddColor.Image       = Tools.GetIcon(Resources.add, iconSize);
            buttonAddColor.Text        = "";
            buttonAddColorSet.Image    = Tools.GetIcon(Resources.add, iconSize);
            buttonAddColorSet.Text     = "";
            buttonRemoveColorSet.Image = Tools.GetIcon(Resources.delete, iconSize);
            buttonRemoveColorSet.Text  = "";
            ThemeUpdateControls.UpdateControls(this);
        }
Esempio n. 5
0
        public bool Perform(IEnumerable <IElementNode> selectedNodes)
        {
            if (!SilentMode)
            {
                DialogResult dr = ShowDialog();
                if (dr != DialogResult.OK)
                {
                    return(false);
                }
            }

            // note: the color property can only be applied to leaf nodes.

            // pull out the new data settings from the form elements
            ElementColorType colorType;
            string           colorSetName = "";

            System.Drawing.Color singleColor = System.Drawing.Color.Black;

            if (radioButtonOptionSingle.Checked)
            {
                colorType    = ElementColorType.SingleColor;
                singleColor  = colorPanelSingleColor.Color;
                colorSetName = null;
            }
            else if (radioButtonOptionMultiple.Checked)
            {
                colorType    = ElementColorType.MultipleDiscreteColors;
                colorSetName = comboBoxColorSet.SelectedItem.ToString();
                singleColor  = System.Drawing.Color.Empty;
            }
            else if (radioButtonOptionFullColor.Checked)
            {
                colorType    = ElementColorType.FullColor;
                singleColor  = System.Drawing.Color.Empty;
                colorSetName = null;
            }
            else
            {
                Logging.Warn("Unexpected radio option selected");
                colorType    = ElementColorType.SingleColor;
                singleColor  = colorPanelSingleColor.Color;
                colorSetName = null;
            }


            // PROPERTY SETUP
            // go through all elements, making a color property for each one.
            // (If any has one already, check with the user as to what they want to do.)
            IEnumerable <IElementNode> leafElements    = selectedNodes.SelectMany(x => x.GetLeafEnumerator()).Distinct();
            List <IElementNode>        leafElementList = leafElements.ToList();

            bool askedUserAboutExistingProperties = false;
            bool overrideExistingProperties       = false;

            int colorPropertiesAdded      = 0;
            int colorPropertiesConfigured = 0;
            int colorPropertiesSkipped    = 0;

            MessageBoxForm messageBox;

            foreach (IElementNode leafElement in leafElementList)
            {
                bool        skip             = false;
                ColorModule existingProperty = null;

                if (leafElement.Properties.Contains(ColorDescriptor.ModuleId))
                {
                    if (!askedUserAboutExistingProperties)
                    {
                        //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                        MessageBoxForm.msgIcon = SystemIcons.Warning;                         //this is used if you want to add a system icon to the message form.
                        messageBox             = new MessageBoxForm("Some elements already have color properties set up. Should these be overwritten?",
                                                                    "Color Setup", true, false);
                        messageBox.ShowDialog();
                        overrideExistingProperties       = (messageBox.DialogResult == DialogResult.OK);
                        askedUserAboutExistingProperties = true;
                    }

                    skip             = !overrideExistingProperties;
                    existingProperty = leafElement.Properties.Get(ColorDescriptor.ModuleId) as ColorModule;
                }
                else
                {
                    existingProperty = leafElement.Properties.Add(ColorDescriptor.ModuleId) as ColorModule;
                    colorPropertiesAdded++;
                }

                if (!skip)
                {
                    if (existingProperty == null)
                    {
                        Logging.Error("Null color property for element " + leafElement.Name);
                    }
                    else
                    {
                        existingProperty.ColorType    = colorType;
                        existingProperty.SingleColor  = singleColor;
                        existingProperty.ColorSetName = colorSetName;
                        colorPropertiesConfigured++;
                    }
                }
                else
                {
                    colorPropertiesSkipped++;
                }
            }


            // PATCHING
            // go through each element, walking the tree of patches, building up a list.  If any are a 'color
            // breakdown' already, warn/check with the user if it's OK to overwrite them.  Make a new breakdown
            // filter for each 'leaf' of the patching process. If it's fully patched to an output, ignore it.

            List <IDataFlowComponentReference> leafOutputs = new List <IDataFlowComponentReference>();

            foreach (IElementNode leafElement in leafElementList.Where(x => x.Element != null))
            {
                leafOutputs.AddRange(_FindLeafOutputsOrBreakdownFilters(VixenSystem.DataFlow.GetComponent(leafElement.Element.Id)));
            }

            bool askedUserAboutExistingFilters = false;
            bool overrideExistingFilters       = false;
            ColorBreakdownModule breakdown     = null;

            int colorFiltersAdded      = 0;
            int colorFiltersConfigured = 0;
            int colorFiltersSkipped    = 0;

            foreach (IDataFlowComponentReference leaf in leafOutputs)
            {
                bool skip = false;

                if (leaf.Component is ColorBreakdownModule)
                {
                    if (!askedUserAboutExistingFilters)
                    {
                        //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                        MessageBoxForm.msgIcon = SystemIcons.Warning;                         //this is used if you want to add a system icon to the message form.
                        messageBox             = new MessageBoxForm("Some elements are already patched to color filters. Should these be overwritten?",
                                                                    "Color Setup", true, false);
                        messageBox.ShowDialog();
                        overrideExistingFilters       = (messageBox.DialogResult == DialogResult.OK);
                        askedUserAboutExistingFilters = true;
                    }

                    skip      = !overrideExistingFilters;
                    breakdown = leaf.Component as ColorBreakdownModule;
                }
                else if (leaf.Component.OutputDataType == DataFlowType.None)
                {
                    // if it's a dead-end -- ie. most likely a controller output -- skip it
                    skip = true;
                }
                else
                {
                    // doesn't exist? make a new module and assign it
                    breakdown =
                        ApplicationServices.Get <IOutputFilterModuleInstance>(ColorBreakdownDescriptor.ModuleId) as ColorBreakdownModule;
                    VixenSystem.DataFlow.SetComponentSource(breakdown, leaf);
                    VixenSystem.Filters.AddFilter(breakdown);
                    colorFiltersAdded++;
                }

                if (!skip)
                {
                    List <ColorBreakdownItem> newBreakdownItems = new List <ColorBreakdownItem>();
                    bool mixColors = false;
                    ColorBreakdownItem cbi;

                    switch (colorType)
                    {
                    case ElementColorType.FullColor:
                        mixColors = true;

                        foreach (var color in comboBoxColorOrder.SelectedItem.ToString().ToCharArray())
                        {
                            switch (color)
                            {
                            case 'R':
                                cbi       = new ColorBreakdownItem();
                                cbi.Color = System.Drawing.Color.Red;
                                cbi.Name  = Red;
                                newBreakdownItems.Add(cbi);
                                break;

                            case 'G':
                                cbi       = new ColorBreakdownItem();
                                cbi.Color = System.Drawing.Color.Lime;
                                cbi.Name  = Green;
                                newBreakdownItems.Add(cbi);
                                break;

                            case 'B':
                                cbi       = new ColorBreakdownItem();
                                cbi.Color = System.Drawing.Color.Blue;
                                cbi.Name  = Blue;
                                newBreakdownItems.Add(cbi);
                                break;
                            }
                        }
                        break;

                    case ElementColorType.MultipleDiscreteColors:
                        mixColors = false;

                        ColorStaticData csd = ApplicationServices.GetModuleStaticData(ColorDescriptor.ModuleId) as ColorStaticData;

                        if (!csd.ContainsColorSet(colorSetName))
                        {
                            Logging.Error("Color sets doesn't contain " + colorSetName);
                        }
                        else
                        {
                            ColorSet cs = csd.GetColorSet(colorSetName);
                            foreach (var c in cs)
                            {
                                cbi       = new ColorBreakdownItem();
                                cbi.Color = c;
                                // heh heh, this can be.... creative.
                                cbi.Name = c.Name;
                                newBreakdownItems.Add(cbi);
                            }
                        }

                        break;

                    case ElementColorType.SingleColor:
                        mixColors = false;
                        cbi       = new ColorBreakdownItem();
                        cbi.Color = singleColor;
                        newBreakdownItems.Add(cbi);
                        break;
                    }

                    breakdown.MixColors      = mixColors;
                    breakdown.BreakdownItems = newBreakdownItems;

                    colorFiltersConfigured++;
                }
                else
                {
                    colorFiltersSkipped++;
                }
            }

            if (!SilentMode)
            {
                //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                MessageBoxForm.msgIcon = SystemIcons.Information;                 //this is used if you want to add a system icon to the message form.
                messageBox             = new MessageBoxForm("Color Properties:  " + colorPropertiesAdded + " added, " +
                                                            colorPropertiesConfigured + " configured, " + colorPropertiesSkipped + " skipped. " +
                                                            "Color Filters:  " + colorFiltersAdded + " added, " + colorFiltersConfigured + " configured, " +
                                                            colorFiltersSkipped + " skipped.",
                                                            "Color Setup", false, false);
                messageBox.ShowDialog();
            }

            return(true);
        }