Ejemplo n.º 1
0
        public static void addIndex(Trait trait)
        {
            Index index = new Index();
            trait.index.Add(index);

            index.name = "Index " + trait.index.Count;
            index.value = 0;
        }
Ejemplo n.º 2
0
 private void printTrait(Trait trait, Label label, ListBox list)
 {
     label.Text = trait.name;
     if (trait.type == ControlType.Indexed)
     {
         for (int i = 0; i < trait.index.Count; i++)
         {
             list.Items.Add(trait.index[i].name);
         }
     }
     else if (trait.type == ControlType.Union)
     {
         for (int i = 0; i < trait.union.Count; i++)
         {
             list.Items.Add(trait.union[i].name);
         }
     }
     else if (trait.type == ControlType.Continuous)
     {
         list.Items.Add("Min: " + trait.min.ToString());
         list.Items.Add("Max: " + trait.max.ToString());
     }
 }
Ejemplo n.º 3
0
 //called by form IndexGenerator.cs
 public static void genIndex(Trait trait, int count, int start, int seperation, String prefix)
 {
     for (int i = 0; i < count; i++)
     {
         Index index = new Index();
         index.name = prefix + " " + (i + 1).ToString();
         index.value = start + (seperation * i);
         trait.index.Add(index);
     }
 }
Ejemplo n.º 4
0
 //called by form UnionGenerator.cs
 public static void genUnion(Trait trait, bool cont, int count, int start, int span, int seperation, String prefix)
 {
     if (cont)
     {
         span--;
         for (int i = 0; i < count; i++)
         {
             Union union = new Union();
             union.name = prefix + " " + (i + 1).ToString();
             union.type = ControlType.Continuous;
             union.min = start + ((span + seperation) * i);
             union.max = union.min + span;
             trait.union.Add(union);
         }
     }
     else
     {
         for (int i = 0; i < count; i++)
         {
             Union union = new Union();
             union.name = prefix + " " + (i + 1).ToString();
             union.type = ControlType.Indexed;
             union.min = start + (seperation * i);
             trait.union.Add(union);
         }
     }
 }
Ejemplo n.º 5
0
 public static void duplicateIndex(Trait trait)
 {
     trait.index.Insert(trait.indexSelect, trait.index[trait.indexSelect].clone());
 }
Ejemplo n.º 6
0
 public static void duplicateUnion(Trait trait)
 {
     trait.union.Insert(trait.unionSelect, trait.union[trait.unionSelect].clone());
 }
Ejemplo n.º 7
0
 private void setTrait(int t)
 {
     if (t < Data.traits.Count)
     {
         traitList.SelectedIndex = t;
         currentTrait = Data.traits[t];
     }
     else
     {
         traitList.SelectedIndex = Data.traits.Count - 1;
         if (traitList.SelectedIndex != -1)
         {
             currentTrait = Data.traits[t];
         }
     }
 }
Ejemplo n.º 8
0
        //Internal Functions//////////////////////////////////////////////////////////////


        /*
         *  function for compiling information stored in Data.Traits
         *  returns string of finished DDL
         */
        private static String export()
        {
            String DDL = "";

            //Header
            DDL += ";*************************************************" + n;
            DDL += ";      Fixture: " + Data.fixture + n;
            DDL += ";      Brand: " + Data.manufacturer + n;
            DDL += ";      Channels: " + maxChannel().ToString() + n;
            DDL += ";      Notes: " + Data.notes + n;
            DDL += ";      Created by " + Data.creator + n;
            DDL += ";      Created on " + DateTime.Now.ToString("M/d/yyyy") + n;
            DDL += ";      Made using DDL Creator (TM)" + n;
            DDL += ";      (c)2008-2013 WindWorks Design" + n;
            DDL += ";      www.windworksdesign.com" + n;
            DDL += ";*************************************************" + n + n;

            //Device name
            DDL += "Device " + Data.fixture + n + n;

            //Trait definitions
            for (int t = 0; t < Data.traits.Count; t++)
            {
                Trait trait = Data.traits[t];

                switch (trait.type)
                {
                case ControlType.Continuous:     /////////////////
                    DDL += "           Trait " + trait.name + n;
                    DDL += "            Type " + trait.type.ToString() + n;
                    DDL += "         Channel " + trait.channel.ToString() + n;
                    DDL += "            Size " + sizeToString(trait.size) + n;
                    DDL += "          Invert " + boolToString(trait.invert) + n;
                    DDL += "           XAxis " + boolToString(trait.x) + n;
                    DDL += "           YAxis " + boolToString(trait.y) + n;
                    DDL += "           Black " + boolToString(trait.black) + n;
                    DDL += "         BoValue " + trait.blackValue.ToString() + n;
                    DDL += "          Master " + boolToString(trait.grand) + n;
                    DDL += "         Default " + trait.defaultValue.ToString() + n;
                    DDL += "         Maximum " + trait.max.ToString() + n;
                    DDL += "         Minimum " + trait.min.ToString() + n;
                    break;

                case ControlType.Indexed:     /////////////////
                    DDL += "           Trait " + trait.name + n;
                    DDL += "            Type " + trait.type.ToString() + n;
                    DDL += "         Channel " + trait.channel.ToString() + n;
                    DDL += "           Black " + boolToString(trait.black) + n;
                    DDL += "         BoValue " + trait.blackValue.ToString() + n;
                    DDL += "         Default " + trait.defaultValue.ToString() + n;
                    for (int i = 0; i < trait.index.Count; i++)
                    {
                        DDL += "           Index " + trait.index[i].name + "," + trait.index[i].value + n;
                    }
                    break;

                case ControlType.Union:     /////////////////
                    DDL += "           Trait " + trait.name + n;
                    DDL += "            Type " + trait.type.ToString() + n;
                    DDL += "         Channel " + trait.channel.ToString() + n;
                    DDL += "           Black " + boolToString(trait.black) + n;
                    DDL += "         BoValue " + trait.blackValue.ToString() + n;
                    DDL += "         Default " + trait.defaultValue.ToString() + n;
                    for (int u = 0; u < trait.union.Count; u++)
                    {
                        Union union = trait.union[u];
                        switch (union.type)
                        {
                        case ControlType.Continuous:
                            DDL += n;
                            DDL += "           Trait " + union.name + n;
                            DDL += "            Type Continuous" + n;
                            DDL += "         Maximum " + union.max.ToString() + n;
                            DDL += "         Minimum " + union.min.ToString() + n;
                            break;

                        case ControlType.Indexed:
                            //create new sub-type header based on previous entry
                            if ((u == 0) || (trait.union[u - 1].type == ControlType.Continuous))
                            {
                                DDL += n;
                                DDL += "           Trait " + trait.name + n;
                                DDL += "            Type Indexed" + n;
                            }
                            DDL += "           Index " + union.name + "," + union.min + n;
                            break;
                        }
                    }
                    DDL += n;
                    DDL += "           Trait " + trait.name + n;
                    DDL += "            Type EndUnion" + n;

                    break;
                } //type switch
                DDL += n + n;
            }     //trait loop

            DDL += "End";

            return(DDL);
        }
Ejemplo n.º 9
0
        public static void addTrait()
        {
            Trait trait = new Trait();
            traits.Add(trait);

            trait.name = "Trait " + traits.Count.ToString();
            trait.type = ControlType.Continuous;
            trait.channel = traits.Count; //TODO make channel account for 16Bit traits and holes in the channel layout
            trait.defaultValue = 0;
            trait.black = false;
            trait.blackValue = 0;

            trait.min = 0;
            trait.max = 255;
            trait.size = ControlSize.Bit8;
            trait.x = false;
            trait.y = false;
            trait.invert = false;
            trait.grand = false;

            trait.indexSelect = -1;
            trait.unionSelect = -1;
        }
Ejemplo n.º 10
0
 public UnionGenerator(Trait trait)
 {
     InitializeComponent();
     this.currentTrait = trait;
     updateList();
 }
Ejemplo n.º 11
0
 public static void duplicateUnion(Trait trait)
 {
     trait.union.Insert(trait.unionSelect, trait.union[trait.unionSelect].clone());
 }
Ejemplo n.º 12
0
        //checks the integrity of the data and shows a modal dialog with any errors
        public static bool check()
        {
            List <String> report = new List <String>();

            if (fixture == "")
            {
                report.Add("Missing Fixture Name");
            }
            if (traits.Count == 0)
            {
                report.Add("There are no traits to save");
            }

            for (int t = 0; t < traits.Count; t++)
            {
                Trait  trait     = traits[t];
                String traitName = trait.name;
                if (trait.name == "")
                {
                    report.Add("Trait " + (t + 1) + " has no name");
                    traitName = "Trait " + (t + 1);
                }

                //trait cross check
                for (int tt = 0; tt < traits.Count; tt++)
                {
                    if (tt != t) //all other traits
                    {
                        Trait  otherTrait = traits[tt];
                        String otherName  = otherTrait.name;
                        if (otherTrait.name == "")
                        {
                            otherName = "Trait " + (tt + 1);
                        }

                        if ((trait.type == ControlType.Continuous) &&
                            (trait.size == ControlSize.Bit16) &&
                            (trait.channel + 1 == otherTrait.channel))
                        {
                            report.Add(otherName + " collides with the upper (16 Bit) channel of " + traitName);
                        }

                        if (tt > t) //complete graph traits
                        {
                            if ((trait.name != "") && (trait.name == otherTrait.name))
                            {
                                report.Add("Traits " + (t + 1) + " and " + (tt + 1) + " are both named " + traitName);
                            }
                            if (trait.channel == otherTrait.channel)
                            {
                                report.Add(traitName + " and " + otherName + " occupy the same channel");
                            }
                        }
                    }
                }


                switch (trait.type)
                {
                case ControlType.Indexed:     /////////////////
                    for (int i = 0; i < trait.index.Count; i++)
                    {
                        Index index = trait.index[i];
                        if (index.name == "")
                        {
                            report.Add("Index " + (i + 1) + " [" + traitName + "] has no name");
                        }
                    }
                    break;

                case ControlType.Union:     /////////////////
                    for (int u = 0; u < trait.union.Count; u++)
                    {
                        Union union = trait.union[u];
                        if (union.name == "")
                        {
                            report.Add("Union " + (u + 1) + " [" + traitName + "] has no name");
                        }
                    }
                    break;
                }
            }

            if (report.Count == 0)
            {
                return(true);
            }
            else
            {
                ErrorReport dialog = new ErrorReport(report);
                return(dialog.ShowDialog() == DialogResult.OK);
            }
        }
Ejemplo n.º 13
0
 public static void duplicateIndex(Trait trait)
 {
     trait.index.Insert(trait.indexSelect, trait.index[trait.indexSelect].clone());
 }
Ejemplo n.º 14
0
 public static void deleteTrait(Trait trait)
 {
     traits.Remove(trait);
 }
Ejemplo n.º 15
0
 public UnionGenerator(Trait trait)
 {
     InitializeComponent();
     this.currentTrait = trait;
     updateList();
 }
Ejemplo n.º 16
0
        public Trait clone()
        {
            Trait trait = new Trait();
            trait.name = this.name;
            trait.type = this.type;
            trait.channel = this.channel;
            trait.defaultValue = this.defaultValue;
            trait.black = this.black;
            trait.blackValue = this.blackValue;
            trait.min = this.min;
            trait.max = this.max;
            trait.size = this.size;
            trait.x = this.x;
            trait.y = this.y;
            trait.invert = this.invert;
            trait.grand = this.grand;
            trait.indexSelect = this.indexSelect;
            trait.unionSelect = this.unionSelect;

            for (int i = 0; i < this.index.Count; i++)
            {
                trait.index.Add(this.index[i].clone());
            }
            for (int i = 0; i < this.union.Count; i++)
            {
                trait.union.Add(this.union[i].clone());
            }

            return trait;
        }
Ejemplo n.º 17
0
 //copies line data into the appropriate property of the given trait
 //called by buildTraits()
 private static void loadLine(Trait trait, Line line)
 {
     if (line.type == valueType.INDEX)
     {
         trait.index.Add(line.indexValue);
     }
     else if (line.type == valueType.UNION)
     {
         trait.union.Add(line.unionValue);
     }
     else //discrete value
     {
         switch (line.keyword.index)
         {
             case 1:
                 trait.name = line.stringValue;
                 break;
             case 2:
                 trait.type = line.typeValue;
                 break;
             case 3:
                 trait.channel = line.intValue;
                 break;
             case 4:
                 trait.size = line.sizeValue;
                 break;
             case 5:
                 trait.invert = line.boolValue;
                 break;
             case 6:
                 trait.x = line.boolValue;
                 break;
             case 7:
                 trait.y = line.boolValue;
                 break;
             case 8:
                 trait.black = line.boolValue;
                 break;
             case 9:
                 trait.blackValue = line.intValue;
                 break;
             case 10:
                 trait.grand = line.boolValue;
                 break;
             case 11:
                 trait.defaultValue = line.intValue;
                 break;
             case 12:
                 trait.max = line.intValue;
                 break;
             case 13:
                 trait.min = line.intValue;
                 break;
         }
     }
 }
Ejemplo n.º 18
0
        public static void addUnion(Trait trait)
        {
            Union union = new Union();

            if (trait.union.Count > 0)
            {
                //if there are things in the list, use the last type (better workflow)
                union.type = trait.union[trait.union.Count - 1].type;
            }
            else
            {
                union.type = ControlType.Continuous;
            }

            trait.union.Add(union);
            union.name = "Union " + trait.union.Count;
            union.min = 0;
            union.max = 255;
        }
Ejemplo n.º 19
0
        } //end fixLines()

        //copies line data into the appropriate property of the given trait
        //called by buildTraits()
        private static void loadLine(Trait trait, Line line)
        {
            if (line.type == valueType.INDEX)
            {
                trait.index.Add(line.indexValue);
            }
            else if (line.type == valueType.UNION)
            {
                trait.union.Add(line.unionValue);
            }
            else //discrete value
            {
                switch (line.keyword.index)
                {
                case 1:
                    trait.name = line.stringValue;
                    break;

                case 2:
                    trait.type = line.typeValue;
                    break;

                case 3:
                    trait.channel = line.intValue;
                    break;

                case 4:
                    trait.size = line.sizeValue;
                    break;

                case 5:
                    trait.invert = line.boolValue;
                    break;

                case 6:
                    trait.x = line.boolValue;
                    break;

                case 7:
                    trait.y = line.boolValue;
                    break;

                case 8:
                    trait.black = line.boolValue;
                    break;

                case 9:
                    trait.blackValue = line.intValue;
                    break;

                case 10:
                    trait.grand = line.boolValue;
                    break;

                case 11:
                    trait.defaultValue = line.intValue;
                    break;

                case 12:
                    trait.max = line.intValue;
                    break;

                case 13:
                    trait.min = line.intValue;
                    break;
                }
            }
        } //end loadLine()
Ejemplo n.º 20
0
        //a trait is considered complete when a new line has a keyword that has already been loaded
        private static void buildTraits(List<Line> lines)
        {
            bool[] loadStates = new bool[16]; //keeps track of which properties have already occured
            List<Line> extraKeys = new List<Line>();
            List<Line> extraValues = new List<Line>();
            Line line = null;
            Trait trait = new Trait();

            while (lines.Count > 0) //while there's another line
            {
                line = lines[0];

                if (line.state == lineState.DONE)
                {

                    if ((line.type != valueType.INDEX) && (line.type != valueType.UNION)) //unions and indexes bypass the end trait detection
                    {
                        int keyword = line.keyword.index;

                        //block recognition
                        if (loadStates[keyword] || (keyword == 15)) //duplicate keyword reached (or END), submit trait and reset
                        {
                            //TODO see if holes can be plugged with extraKeys and extraValues

                            //submit the trait
                            Data.traits.Add(trait);
                            trait = new Trait();
                            //reset load states
                            for (int i = 0; i < loadStates.Length; i++)
                            {
                                loadStates[i] = false;
                            }
                        }

                        loadStates[keyword] = true;
                    }

                    //load the current line
                    loadLine(trait, line);
                }
                else if(line.state == lineState.NOVALUE)
                {
                    extraKeys.Add(line);
                }
                else if (line.state == lineState.NOKEY)
                {
                    if (line.type == valueType.INDEX) { loadLine(trait, line); }
                    else { extraValues.Add(line); }
                }

                lines.Remove(line);
            }
        }
Ejemplo n.º 21
0
 public static void deleteIndex(Trait trait)
 {
     trait.index.Remove(trait.index[trait.indexSelect]);
     if (trait.indexSelect >= trait.index.Count)
     {
         trait.indexSelect--;
     }
 }
Ejemplo n.º 22
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = DialogResult.Yes;

            if (confirmDeletionsToolStripMenuItem.Checked)
            {
                dialogResult = MessageBox.Show("Are you sure you want to delete this?", "Delete?", MessageBoxButtons.YesNo);
            }

            if (dialogResult == DialogResult.Yes)
            {
                if (listContextMenu.SourceControl == traitList)
                {
                    Data.deleteTrait(currentTrait);

                    if (traitList.SelectedIndex >= traitList.Items.Count)
                    {
                        traitList.SelectedIndex--;
                    }

                    refreshTraits();

                    //update currentTrait
                    if (traitList.SelectedIndex != -1)
                    {
                        currentTrait = Data.traits[traitList.SelectedIndex];
                    }

                    refreshProperties();
                }
                else if (listContextMenu.SourceControl == indexList)
                {
                    Data.deleteIndex(currentTrait);
                    refreshIndex(false);
                    refreshIndexProperties(false);
                }
                else if (listContextMenu.SourceControl == unionList)
                {
                    Data.deleteUnion(currentTrait);
                    refreshUnion(false);
                    refreshUnionProperties(false);
                }
                IO.saved = false;

            }
        }
Ejemplo n.º 23
0
 public static void deleteTrait(Trait trait)
 {
     traits.Remove(trait);
 }
Ejemplo n.º 24
0
        //Trait list
        private void traitList_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                traitList.SelectedIndex = traitList.IndexFromPoint(e.Location);
                if (traitList.SelectedIndex != -1)
                {
                    listContextMenu.Show(traitList, e.Location);
                }
            }

            if (traitList.SelectedIndex != -1)
            {
                int index = traitList.SelectedIndex;
                currentTrait = Data.traits[index];
                if (e.Button == MouseButtons.Left) { traitList.DoDragDrop(index, DragDropEffects.Move); }
                refreshProperties();
            }
        }
Ejemplo n.º 25
0
 public static void deleteUnion(Trait trait)
 {
     trait.union.Remove(trait.union[trait.unionSelect]);
     if (trait.unionSelect >= trait.union.Count)
     {
         trait.unionSelect--;
     }
 }