Пример #1
0
        public double ConfiguredIntensity(string itemName, PhonemeType phoneme, LipSyncMapItem item = null)
        {
            double retVal = 0;

            if (item == null)
            {
                item = FindMapItem(itemName);
            }

            if (item != null)
            {
                if (this.IsMatrix)
                {
                    if (item.ElementColors[phoneme] != Color.Black)
                    {
                        HSV hsvVal = HSV.FromRGB(new RGB(item.ElementColors[phoneme]));
                        retVal = hsvVal.V;
                        //retVal = 1.0;
                    }
                }
                else
                {
                    if (item.PhonemeList[phoneme.ToString()] == true)
                    {
                        HSV hsvVal = HSV.FromRGB(new RGB(item.ElementColor));
                        retVal = hsvVal.V;
                    }
                }
            }
            return(retVal);
        }
Пример #2
0
        public Color ConfiguredColor(string itemName, PhonemeType phoneme, LipSyncMapItem item = null)
        {
            Color retVal = Color.Black;

            if (item == null)
            {
                item = FindMapItem(itemName);
            }

            if (item != null)
            {
                if (this.IsMatrix)
                {
                    if (item.ElementColors[phoneme] != Color.Black)
                    {
                        retVal = item.ElementColors[phoneme];
                    }
                }
                else
                {
                    if (item.PhonemeList[phoneme.ToString()] == true)
                    {
                        HSV hsvVal = HSV.FromRGB(new RGB(item.ElementColor));
                        hsvVal.V = 1;
                        retVal   = hsvVal.ToRGB().ToArgb();
                    }
                }
            }
            return(retVal);
        }
Пример #3
0
        private LipSyncMapItem FindRenderMapItem (int row, int column)
        {
            
            if (startMapIndex == -1)
            {
                startMapIndex = _newMapping.MapItems.FindIndex(
                delegate(LipSyncMapItem mapItem)
                {
                    return mapItem.Name.Equals(_newMapping.StartNode);
                });
            }

            LipSyncMapItem retVal = null;

            int numGridCols = CalcNumDataGridCols;
            int numGridRows = CalcNumDataGridRows;
            int calcIndex;

            calcIndex = (stringsAreRows) ?
                ((numGridCols * (numGridRows - row - 1)) + column) + startMapIndex :
                ((numGridRows * column) + (numGridRows - row - 1)) + startMapIndex;

            if ((calcIndex >= 0) && (calcIndex < _newMapping.MapItems.Count))
            {
                retVal = _newMapping.MapItems.ElementAt(calcIndex);
            }

            return retVal;
        }
Пример #4
0
        public bool IsFaceComponentType(FaceComponent type, LipSyncMapItem item)
        {
            bool retVal = false;

            item?.FaceComponents.TryGetValue(type, out retVal);

            return(retVal);
        }
Пример #5
0
        public bool PhonemeState(string phonemeName, LipSyncMapItem item)
        {
            bool retVal = false;

            item?.PhonemeList.TryGetValue(phonemeName, out retVal);

            return(retVal);
        }
Пример #6
0
        private void assignNodes()
        {
            BuildRowNameList();

            LipSyncNodeSelect nodeSelectDlg = new LipSyncNodeSelect();

            nodeSelectDlg.MaxNodes          = _newMapping.MatrixStringCount * _newMapping.MatrixPixelsPerString;
            nodeSelectDlg.MatrixOptionsOnly = true;
            nodeSelectDlg.StringsAreRows    = _newMapping.StringsAreRows;
            nodeSelectDlg.NodeNames         = _rowNames;

            DialogResult dr = nodeSelectDlg.ShowDialog();

            if ((dr == DialogResult.OK) && (nodeSelectDlg.Changed == true))
            {
                List <LipSyncMapItem> newMappings = new List <LipSyncMapItem>();
                LipSyncMapItem        tempMapItem = null;

                _newMapping.StringsAreRows = nodeSelectDlg.StringsAreRows;
                stringsAreRows             = _newMapping.StringsAreRows;

                _rowNames.Clear();
                _rowNames.AddRange(nodeSelectDlg.NodeNames);

                foreach (string nodeName in nodeSelectDlg.NodeNames)
                {
                    tempMapItem = _newMapping.MapItems.Find(
                        delegate(LipSyncMapItem item)
                    {
                        return(item.Name.Equals(nodeName));
                    });

                    if (tempMapItem != null)
                    {
                        newMappings.Add(tempMapItem);
                    }
                    else
                    {
                        newMappings.Add(new LipSyncMapItem(nodeName, -1));
                    }
                }

                _newMapping.MapItems.Clear();

                int stringCount = 0;
                foreach (LipSyncMapItem mapItem in newMappings)
                {
                    mapItem.StringNum = stringCount++;
                    _newMapping.MapItems.Add(mapItem);
                }

                _newMapping.StartNode =
                    (_newMapping.MapItems.Count != 0) ? _newMapping.MapItems[0].Name : "";

                reconfigureDataTable();
            }
        }
Пример #7
0
        private void buttonAssign_Click(object sender, EventArgs e)
        {
            LipSyncNodeSelect nodeSelectDlg = new LipSyncNodeSelect();

            //nodeSelectDlg.MaxNodes = _mapping.MapItems.Count;
            nodeSelectDlg.MaxNodes          = Int32.MaxValue;
            nodeSelectDlg.MatrixOptionsOnly = false;
            nodeSelectDlg.SelectedNodeNames = _rowNames;
            nodeSelectDlg.AllowGroups       = _mapping.GroupsAllowed;
            nodeSelectDlg.AllowRecursiveAdd = _mapping.RecursionAllowed;

            DialogResult dr = nodeSelectDlg.ShowDialog();

            if ((dr == DialogResult.OK) && (nodeSelectDlg.Changed == true))
            {
                List <LipSyncMapItem> newMappings = new List <LipSyncMapItem>();
                LipSyncMapItem        tempMapItem = null;

                _mapping.LibraryReferenceName = nameTextBox.Text;
                _mapping.GroupsAllowed        = nodeSelectDlg.AllowGroups;
                _mapping.RecursionAllowed     = nodeSelectDlg.AllowRecursiveAdd;

                _rowNames.Clear();
                _rowNames.AddRange(nodeSelectDlg.SelectedNodeNames);

                foreach (string nodeName in nodeSelectDlg.SelectedNodeNames)
                {
                    tempMapItem = _mapping.MapItems.Find(
                        delegate(LipSyncMapItem item)
                    {
                        return(item.Name.Equals(nodeName));
                    });

                    if (tempMapItem != null)
                    {
                        newMappings.Add(tempMapItem);
                    }
                    else
                    {
                        newMappings.Add(new LipSyncMapItem(nodeName, -1));
                    }
                }

                _mapping.MapItems.Clear();

                int stringCount = 0;
                foreach (LipSyncMapItem mapItem in newMappings)
                {
                    mapItem.StringNum = stringCount++;
                    _mapping.MapItems.Add(mapItem);
                }

                reconfigureDataTable();
            }
            Refresh();
        }
Пример #8
0
 private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     dataGridView1.CurrentCell = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];
     Color newColor =
         (e.Button == MouseButtons.Left) ? lipSyncMapColorCtrl1.Color : Color.Black;
     
     LipSyncMapItem item =
         FindRenderMapItem(e.RowIndex, e.ColumnIndex);
         dataGridView1.CurrentCell.Value = (item == null) ? Color.Gray : newColor;
 }
Пример #9
0
        public LipSyncMapItem Clone()
        {
            LipSyncMapItem retVal = new LipSyncMapItem();
            retVal.Name = Name;
            retVal.PhonemeList = new Dictionary<string, bool>(PhonemeList);
            retVal.StringNum = StringNum;
            retVal.ElementColor = ElementColor;
            retVal.ElementGuid = ElementGuid;
            retVal.ElementColors = new Dictionary<PhonemeType, Color>(ElementColors);

            return retVal;
        }
Пример #10
0
        public LipSyncMapItem Clone()
        {
            LipSyncMapItem retVal = new LipSyncMapItem();

            retVal.Name          = Name;
            retVal.PhonemeList   = new Dictionary <string, bool>(PhonemeList);
            retVal.StringNum     = StringNum;
            retVal.ElementColor  = ElementColor;
            retVal.ElementGuid   = ElementGuid;
            retVal.ElementColors = new Dictionary <PhonemeType, Color>(ElementColors);

            return(retVal);
        }
Пример #11
0
        public LipSyncMapItem Clone()
        {
            LipSyncMapItem retVal = new LipSyncMapItem();

            retVal.Name           = Name;
            retVal.PhonemeList    = new Dictionary <string, bool>(PhonemeList, StringComparer.OrdinalIgnoreCase);
            retVal.StringNum      = StringNum;
            retVal.ElementColor   = ElementColor;
            retVal.ElementGuid    = ElementGuid;
            retVal.FaceComponents = new Dictionary <FaceComponent, bool>(FaceComponents);

            return(retVal);
        }
Пример #12
0
        public double ConfiguredIntensity(LipSyncMapItem item)
        {
            double retVal = 0;

            if (!IsMatrix)
            {
                if (item != null)
                {
                    retVal = HSV.VFromRgb(item.ElementColor);
                }
            }

            return(retVal);
        }
Пример #13
0
        public Color ConfiguredColor(LipSyncMapItem item)
        {
            Color retVal = Color.Black;

            if (!IsMatrix)
            {
                if (item != null)
                {
                    HSV hsvVal = HSV.FromRGB(item.ElementColor);
                    hsvVal.V = 1;
                    retVal   = hsvVal.ToRGB();
                }
            }

            return(retVal);
        }
Пример #14
0
        public bool PhonemeState(string itemName, string phonemeName, LipSyncMapItem item = null)
        {
            bool retVal = false;

            if (item == null)
            {
                item = FindMapItem(itemName);
            }

            if (item != null)
            {
                item.PhonemeList.TryGetValue(phonemeName, out retVal);
            }

            return(retVal);
        }
Пример #15
0
        public Tuple <double, Color> ConfiguredColorAndIntensity(LipSyncMapItem item)
        {
            double intensityRetVal = 0;
            Color  colorRetVal     = Color.Black;

            if (!IsMatrix)
            {
                if (item != null)
                {
                    HSV hsvVal = HSV.FromRGB(item.ElementColor);
                    hsvVal.V        = 1;
                    colorRetVal     = hsvVal.ToRGB();
                    intensityRetVal = HSV.VFromRgb(item.ElementColor);
                }
            }

            return(new Tuple <double, Color>(intensityRetVal, colorRetVal));
        }
Пример #16
0
        public double ConfiguredIntensity(string itemName, PhonemeType phoneme, LipSyncMapItem item = null)
        {
            double retVal = 0;

            if (item == null)
            {
                item = FindMapItem(itemName);
            }

            if (item != null)
            {
                if (!this.IsMatrix)
                {
                    if (item.PhonemeList[phoneme.ToString()] == true)
                    {
                        retVal = HSV.VFromRgb(item.ElementColor);
                    }
                }
            }
            return(retVal);
        }
Пример #17
0
        private DataTable BuildDialogFromMap(LipSyncMapData data)
        {
            nameTextBox.Text = data.LibraryReferenceName;

            stringCount        = _newMapping.MatrixStringCount;
            pixelCount         = _newMapping.MatrixPixelsPerString;
            zoomTrackbar.Value = _newMapping.ZoomLevel;

            DataTable dt   = BuildBlankTable();
            int       cols = CalcNumDataGridCols;
            int       rows = CalcNumDataGridRows;

            LipSyncMapItem mapItem = null;

            DataRow dr;

            for (int row = 0; row < rows; row++)
            {
                dr = dt.Rows[row];
                for (int col = 0; col < cols; col++)
                {
                    mapItem = FindRenderMapItem(row, col);


                    if (mapItem != null)
                    {
                        dr[col] =
                            (mapItem.ElementColors.ContainsKey(phonemeArray[currentPhonemeIndex]) == false) ?
                            Color.Black : mapItem.ElementColors[phonemeArray[currentPhonemeIndex]];
                    }
                    else
                    {
                        dr[col] = Color.Gray;
                    }
                }
            }

            return(dt);
        }
Пример #18
0
        private void BuilMapDataFromDialog()
        {
            int currentRow = 0;

            _mapping.LibraryReferenceName = nameTextBox.Text;
            _mapping.Notes = notesTextBox.Text;

            _mapping.StringCount = _rowNames.Count();
            _mapping.MapItems.Clear();

            for (int stringNum = 0; stringNum < _rowNames.Count; stringNum++)
            {
                DataRow        dr          = currentDataTable.Rows[currentRow];
                string         elementName = dr[0].ToString();
                LipSyncMapItem item        = new LipSyncMapItem();
                ElementNode    theNode     = FindElementNode(elementName);

                item.Name        = dr[0].ToString();
                item.ElementGuid = theNode.Id;
                item.StringNum   = stringNum;

                for (int theCount = 1; theCount < dr.ItemArray.Count() - 1; theCount++)
                {
                    bool checkVal =
                        (dr[theCount].GetType() == typeof(Boolean)) ? (Boolean)dr[theCount] : false;
                    item.PhonemeList.Add(
                        dr.Table.Columns[theCount].ColumnName, checkVal
                        );
                }
                item.ElementColor = (Color)dr[dr.ItemArray.Count() - 1];

                _mapping.MapItems.Add(item);
                currentRow++;
                if (currentRow >= currentDataTable.Rows.Count)
                {
                    return;
                }
            }
        }
Пример #19
0
        public Tuple <double, Color> ConfiguredColorAndIntensity(string itemName, string phoneme, LipSyncMapItem item)
        {
            double intensityRetVal = 0;
            Color  colorRetVal     = Color.Black;

            if (item == null)
            {
                item = FindMapItem(itemName);
            }

            if (item != null)
            {
                if (!IsMatrix)
                {
                    if (item.PhonemeList[phoneme] == true)
                    {
                        HSV hsvVal = HSV.FromRGB(item.ElementColor);
                        hsvVal.V        = 1;
                        colorRetVal     = hsvVal.ToRGB().ToArgb();
                        intensityRetVal = HSV.VFromRgb(item.ElementColor);
                    }
                }
            }
            return(new Tuple <double, Color>(intensityRetVal, colorRetVal));
        }
Пример #20
0
 public Color ConfiguredColor(string itemName, PhonemeType phoneme, LipSyncMapItem item = null)
 {
     return(ConfiguredColor(itemName, phoneme.ToString(), item));
 }
Пример #21
0
        private void BuilMapDataFromDialog()
        {
            int currentRow = 0;

            _mapping.StringCount = _rowNames.Count();
            _mapping.MapItems.Clear();

            for (int stringNum = 0; stringNum < _rowNames.Count; stringNum++)
            {
                DataRow dr = currentDataTable.Rows[currentRow];
                string elementName = dr[0].ToString();
                LipSyncMapItem item = new LipSyncMapItem();
                ElementNode theNode = FindElementNode(elementName);
                    
                item.Name = dr[0].ToString();
                item.ElementGuid = theNode.Id;
                item.StringNum = stringNum;

                for (int theCount = 1; theCount < dr.ItemArray.Count() - 1; theCount++) 
                {
                    bool checkVal =
                        (dr[theCount].GetType() == typeof(Boolean)) ? (Boolean)dr[theCount] : false;
                    item.PhonemeList.Add(
                        dr.Table.Columns[theCount].ColumnName, checkVal
                        );
                }
                item.ElementColor = (Color)dr[dr.ItemArray.Count() - 1];

                _mapping.MapItems.Add(item);
                currentRow++;
                if (currentRow >= currentDataTable.Rows.Count)
                {
                    return;
                }
            }
        }
Пример #22
0
        public bool PhonemeState(string itemName, string phonemeName, LipSyncMapItem item = null)
        {
            bool retVal = false;
            
            if (item == null)
            {
                item = FindMapItem(itemName);
            }
            
            if (item != null)
            {
                item.PhonemeList.TryGetValue(phonemeName, out retVal);
            }

            return retVal;
        }
Пример #23
0
 public Color ConfiguredColor(string itemName, PhonemeType phoneme, LipSyncMapItem item = null)
 {
     Color retVal = Color.Black;
     
     if (item == null)
     {
         item = FindMapItem(itemName);
     }
     
     if (item != null)
     {
         if (this.IsMatrix) 
         {
             if (item.ElementColors[phoneme] != Color.Black)
             {
                 retVal = item.ElementColors[phoneme];
             }
         }
         else
         {
             if (item.PhonemeList[phoneme.ToString()] == true)
             {
                 HSV hsvVal = HSV.FromRGB(new RGB(item.ElementColor));
                 hsvVal.V = 1;
                 retVal = hsvVal.ToRGB().ToArgb();
             }
         }
     }
     return retVal;
 }
Пример #24
0
        public double ConfiguredIntensity(string itemName, PhonemeType phoneme, LipSyncMapItem item = null)
        {
            double retVal = 0;
            
            if (item == null)
            {
                item = FindMapItem(itemName);
            }
            
            if (item != null)
            {
                if (this.IsMatrix)
                {
                    if (item.ElementColors[phoneme] != Color.Black)
                    {
                        HSV hsvVal = HSV.FromRGB(new RGB(item.ElementColors[phoneme]));
                        retVal = hsvVal.V;
                        //retVal = 1.0;
                    }

                }
                else 
                {
                    if (item.PhonemeList[phoneme.ToString()] == true)
                    {
                        HSV hsvVal = HSV.FromRGB(new RGB(item.ElementColor));
                        retVal = hsvVal.V;
                    }
                }
            }
            return retVal;

        }