public static int GetComboDropDownWidth(IntPtr handle)
            {
                ComboBoxInfo cbi = new ComboBoxInfo();

                cbi.cbSize = Marshal.SizeOf(cbi);
                GetComboBoxInfo(handle, ref cbi);
                int width = cbi.rcButton.Right - cbi.rcButton.Left;

                return(width);
            }
示例#2
0
        private Rectangle GetDropDownButtonRect()
        {
            ComboBox     cb  = new ComboBox();
            ComboBoxInfo cbi = new ComboBoxInfo();

            cbi.cbSize = Marshal.SizeOf(cbi);
            Win32.GetComboBoxInfo(cb.Handle, ref cbi);
            cb.Dispose();
            int       width = cbi.rcButton.Rect.Width;
            Rectangle rect  = new Rectangle(this.Width - width - this._Margin * 2, this._Margin, this.Height - this._Margin, this.Height - this._Margin * 2);

            return(rect);
        }
 private void InitComboBox(EditableComboBox comboBox, ComboBoxInfo info)
 {
     comboBox.DataContext  = new StringListViewModel();
     comboBox.TextChanged += (s, e) => info.SearchFunction();
     comboBox.KeyDown     += (s, e) => {
         if (e.Key == Key.Return || e.Key == Key.Enter)
         {
             info.SearchFunction();
         }
     };
     comboBox.PrePreviewKeyDown += (s, e) => {
         if (e.KeyboardDevice.Modifiers == ModifierKeys.None && e.Key == Key.Down)
         {
             FileTreeView.Focus();
             e.Handled = true;
         }
     };
 }
示例#4
0
        private void InitComboBox(EditableComboBox comboBox, ComboBoxInfo info)
        {
            comboBox.DataContext  = new StringListViewModel(info.InitialItems);
            comboBox.TextChanged += (s, e) => {
                info.TextChanged(comboBox.Text);
                info.SearchFunction(false);
            };
            comboBox.KeyDown += (s, e) => {
                if ((e.KeyboardDevice.Modifiers == ModifierKeys.None) &&
                    (e.Key == Key.Return || e.Key == Key.Enter))
                {
                    info.SearchFunction(true);
                }
            };

            if (info.PreviousElement != null)
            {
                comboBox.PrePreviewKeyDown += (s, e) => {
                    if (e.KeyboardDevice.Modifiers == ModifierKeys.None && e.Key == Key.Up)
                    {
                        if (!comboBox.IsDropDownOpen)
                        {
                            info.PreviousElement.Focus();
                            e.Handled = true;
                        }
                    }
                };
            }

            if (info.NextElement != null)
            {
                comboBox.PrePreviewKeyDown += (s, e) => {
                    if (e.KeyboardDevice.Modifiers == ModifierKeys.None && e.Key == Key.Down)
                    {
                        if (!comboBox.IsDropDownOpen)
                        {
                            info.NextElement.Focus();
                            e.Handled = true;
                        }
                    }
                };
            }
        }
 public static extern bool GetComboBoxInfo(IntPtr hwndCombo, ref ComboBoxInfo info);
示例#6
0
		private static extern bool GetComboBoxInfo(IntPtr hwndCombo, ref ComboBoxInfo info);
    private void InitComboBox(EditableComboBox comboBox, ComboBoxInfo info) {
      comboBox.DataContext = new StringListViewModel(info.InitialItems);
      comboBox.TextChanged += (s, e) => {
        info.TextChanged(comboBox.Text);
        info.SearchFunction(false);
      };
      comboBox.KeyDown += (s, e) => {
        if ((e.KeyboardDevice.Modifiers == ModifierKeys.None) &&
            (e.Key == Key.Return || e.Key == Key.Enter)) {
          info.SearchFunction(true);
        }
      };

      if (info.PreviousElement != null) {
        comboBox.PrePreviewKeyDown += (s, e) => {
          if (e.KeyboardDevice.Modifiers == ModifierKeys.None && e.Key == Key.Up) {
            if (!comboBox.IsDropDownOpen) {
              info.PreviousElement.Focus();
              e.Handled = true;
            }
          }
        };
      }

      if (info.NextElement != null) {
        comboBox.PrePreviewKeyDown += (s, e) => {
          if (e.KeyboardDevice.Modifiers == ModifierKeys.None && e.Key == Key.Down) {
            if (!comboBox.IsDropDownOpen) {
              info.NextElement.Focus();
              e.Handled = true;
            }
          }
        };
      }
    }
示例#8
0
        /// <summary>
        /// Gets the MTRL data of the given mesh
        /// </summary>
        /// <param name="mesh">The mesh to obtain the data from</param>
        /// <returns>The MTRLData of the given mesh</returns>
        public MTRLData MTRL3D(int mesh)
        {
            MTRLData mtrlData    = null;
            bool     isDemiHuman = false;

            if (selectedItem.PrimaryMTRLFolder != null)
            {
                isDemiHuman = selectedItem.PrimaryMTRLFolder.Contains("demihuman");
            }

            var itemVersion = IMC.GetVersion(selectedCategory, selectedItem, false).Item1;
            var itemType    = Helper.GetCategoryType(selectedCategory);

            try
            {
                if (selectedItem.ItemName.Equals(Strings.Face) || selectedItem.ItemName.Equals(Strings.Hair) || isDemiHuman)
                {
                    string slotAbr;

                    if (isDemiHuman)
                    {
                        slotAbr = Info.slotAbr[SelectedPart.Name];
                    }
                    else if (selectedCategory.Equals(Strings.Character))
                    {
                        var race = materialStrings[mesh].Substring(materialStrings[mesh].IndexOf("c") + 1, 4);

                        if (materialStrings[mesh].Contains("h00"))
                        {
                            var hairNum    = materialStrings[mesh].Substring(materialStrings[mesh].IndexOf("h00") + 1, 4);
                            var mtrlFolder = string.Format(Strings.HairMtrlFolder, race, hairNum);
                            slotAbr = materialStrings[mesh].Substring(materialStrings[mesh].LastIndexOf("_") - 3, 3);
                            slotAbr = Info.HairTypes.FirstOrDefault(x => x.Value == slotAbr).Key;

                            var hairInfo = MTRL.GetMTRLDatafromType(selectedItem, SelectedRace, hairNum, slotAbr, itemVersion, selectedCategory);
                            return(hairInfo.Item1);
                        }
                        else if (materialStrings[mesh].Contains("f00"))
                        {
                            var faceNum    = materialStrings[mesh].Substring(materialStrings[mesh].IndexOf("f00") + 1, 4);
                            var mtrlFolder = string.Format(Strings.FaceMtrlFolder, race, faceNum);
                            slotAbr = materialStrings[mesh].Substring(materialStrings[mesh].LastIndexOf("_") - 3, 3);
                            slotAbr = Info.FaceTypes.FirstOrDefault(x => x.Value == slotAbr).Key;

                            var faceInfo = MTRL.GetMTRLDatafromType(selectedItem, SelectedRace, faceNum, slotAbr, itemVersion, selectedCategory);
                            return(faceInfo.Item1);
                        }
                        else
                        {
                            slotAbr = selectedPart.Name;
                        }
                    }
                    else
                    {
                        slotAbr = selectedPart.Name;
                    }

                    var info = MTRL.GetMTRLDatafromType(selectedItem, SelectedRace, selectedPart.Name, slotAbr, itemVersion, selectedCategory);
                    mtrlData = info.Item1;
                }
                else
                {
                    Tuple <MTRLData, ObservableCollection <ComboBoxInfo> > info;

                    if (itemType.Equals("character") || itemType.Equals("equipment"))
                    {
                        try
                        {
                            if (materialStrings[mesh].Contains("b00") || materialStrings[mesh].Contains("t00") || materialStrings[mesh].Contains("h00"))
                            {
                                if (materialStrings[mesh].Contains("mt_c"))
                                {
                                    var mtrlFolder = "";
                                    var race       = materialStrings[mesh].Substring(materialStrings[mesh].IndexOf("c") + 1, 4);

                                    if (materialStrings[mesh].Contains("b00"))
                                    {
                                        mtrlFolder = string.Format(Strings.BodyMtrlFolder, race, materialStrings[mesh].Substring(materialStrings[mesh].IndexOf("b00") + 1, 4));
                                    }
                                    else if (materialStrings[mesh].Contains("t00"))
                                    {
                                        mtrlFolder = string.Format(Strings.TailMtrlFolder, race, materialStrings[mesh].Substring(materialStrings[mesh].IndexOf("t00") + 1, 4));
                                    }
                                    else if (materialStrings[mesh].Contains("h00"))
                                    {
                                        mtrlFolder = string.Format(Strings.HairMtrlFolder, race, materialStrings[mesh].Substring(materialStrings[mesh].IndexOf("h00") + 1, 4));
                                    }

                                    var mtrlFile = materialStrings[mesh].Substring(1);

                                    return(MTRL.GetMTRLInfo(Helper.GetItemOffset(FFCRC.GetHash(mtrlFolder), FFCRC.GetHash(mtrlFile)), true));
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Debug.WriteLine(ex.Message);
                            Debug.WriteLine(ex.StackTrace);
                        }
                    }
                    else
                    {
                        info = MTRL.GetMTRLData(selectedItem, SelectedRace.ID, selectedCategory, SelectedPart.Name, itemVersion, "", "", "0000");
                    }

                    if (SelectedPart.Name.Equals("Secondary"))
                    {
                        info = MTRL.GetMTRLData(selectedItem, SelectedRace.ID, selectedCategory, SelectedPart.Name, itemVersion, "Secondary", "", "0000");
                    }
                    else
                    {
                        string part   = "a";
                        string itemID = selectedItem.PrimaryModelID;

                        if (materialStrings.Count > 1)
                        {
                            try
                            {
                                part   = materialStrings[mesh].Substring(materialStrings[mesh].LastIndexOf("_") + 1, 1);
                                itemID = materialStrings[mesh].Substring(materialStrings[mesh].IndexOf("_") + 2, 4);
                            }
                            catch (Exception ex)
                            {
                                Debug.WriteLine(ex.Message);
                                Debug.WriteLine(ex.StackTrace);
                            }
                        }

                        if (selectedCategory.Equals(Strings.Pets))
                        {
                            part = "1";
                        }

                        info = MTRL.GetMTRLData(selectedItem, SelectedRace.ID, selectedCategory, part, itemVersion, "", itemID, "0000");
                    }

                    if (info != null)
                    {
                        mtrlData = info.Item1;
                    }
                    else
                    {
                        var combo = new ComboBoxInfo()
                        {
                            Name = "Default", ID = materialStrings[mesh].Substring(materialStrings[mesh].IndexOf("c") + 1, 4), IsNum = false
                        };

                        if (SelectedPart.Name.Equals("-"))
                        {
                            info = MTRL.GetMTRLData(selectedItem, combo.ID, selectedCategory, "a", itemVersion, "", "", "0000");
                        }
                        else
                        {
                            info = MTRL.GetMTRLData(selectedItem, combo.ID, selectedCategory, SelectedPart.Name, itemVersion, "", "", "0000");
                        }

                        mtrlData = info.Item1;
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                Debug.WriteLine(ex.StackTrace);
                return(null);
            }

            return(mtrlData);
        }
示例#9
0
        /// <summary>
        /// 是否按下
        /// </summary>
        /// <returns></returns>
        private bool GetComboBoxButtonPressed()
        {
            ComboBoxInfo cbi = GetTheComboBoxInfo();

            return(cbi.stateButton == ComboBoxButtonState.STATE_SYSTEM_PRESSED);
        }
示例#10
0
        /// <summary>
        /// 下拉框范围
        /// </summary>
        /// <returns></returns>
        private Rectangle GetDropDownButtonRect()
        {
            ComboBoxInfo cbi = GetTheComboBoxInfo();

            return(cbi.rcButton.Rect);
        }
示例#11
0
        /// <summary>
        /// Parses the MTRL file for items that contains types
        /// </summary>
        /// <param name="item">currently selected item</param>
        /// <param name="race">currently selected race</param>
        /// <param name="part">currently selected part</param>
        /// <param name="type">currently selected type</param>
        /// <param name="IMCVersion">version of the selected item</param>
        /// <param name="selectedCategory">The category of the item</param>
        /// <returns>A tuple containing the MTRLInfo and Observable Collection containing texture map names</returns>
        public static Tuple <MTRLData, ObservableCollection <ComboBoxInfo> > GetMTRLDatafromType(ItemData item, ComboBoxInfo race, string part, string type, string IMCVersion, string selectedCategory)
        {
            string MTRLFolder, MTRLFile;
            string MTRLPath       = "";
            bool   isUncompressed = true;
            int    offset         = 0;

            if (item.ItemName.Equals(Strings.Face))
            {
                MTRLFolder = String.Format(Strings.FaceMtrlFolder, race.ID, part.PadLeft(4, '0'));
                MTRLFile   = String.Format(Strings.FaceMtrlFile, race.ID, part.PadLeft(4, '0'), Info.FaceTypes[type]);
                offset     = Helper.GetItemOffset(FFCRC.GetHash(MTRLFolder), FFCRC.GetHash(MTRLFile));
                MTRLPath   = MTRLFolder + "/" + MTRLFile;

                isUncompressed = true;
            }
            else if (item.ItemName.Equals(Strings.Hair))
            {
                MTRLFolder     = String.Format(Strings.HairMtrlFolder, race.ID, part.PadLeft(4, '0'));
                isUncompressed = true;

                if (type.Equals(Strings.Accessory))
                {
                    MTRLFile = String.Format(Strings.HairMtrlFile, race.ID, part.PadLeft(4, '0'), Info.HairTypes[type], "b");
                }
                else
                {
                    MTRLFile = String.Format(Strings.HairMtrlFile, race.ID, part.PadLeft(4, '0'), Info.HairTypes[type], "a");
                }

                MTRLPath = MTRLFolder + "/" + MTRLFile;
                offset   = Helper.GetItemOffset(FFCRC.GetHash(MTRLFolder), FFCRC.GetHash(MTRLFile));
            }
            else if (selectedCategory.Equals(Strings.Mounts))
            {
                isUncompressed = false;

                if (item.PrimaryMTRLFolder.Contains("demihuman"))
                {
                    MTRLFile = String.Format(Strings.DemiMtrlFile, item.PrimaryModelID.PadLeft(4, '0'), item.PrimaryModelBody.PadLeft(4, '0'), type);
                }
                else
                {
                    MTRLFile = String.Format(Strings.MonsterMtrlFile, item.PrimaryModelID.PadLeft(4, '0'), item.PrimaryModelBody.PadLeft(4, '0'), part);
                }

                MTRLPath = item.PrimaryMTRLFolder + IMCVersion + "/" + MTRLFile;

                offset = Helper.GetItemOffset(FFCRC.GetHash(item.PrimaryMTRLFolder + IMCVersion), FFCRC.GetHash(MTRLFile));
            }

            var mtrlInfo = GetMTRLInfo(offset, isUncompressed);

            mtrlInfo.MTRLPath   = MTRLPath;
            mtrlInfo.MTRLOffset = offset;

            return(new Tuple <MTRLData, ObservableCollection <ComboBoxInfo> >(mtrlInfo, mtrlInfo.TextureMaps));
        }
示例#12
0
        /// <summary>
        /// Gets the races that have an mtrl file for the given item
        /// </summary>
        /// <remarks>
        /// Goes through a list of all races to see if an mtrl file exists within the items material folder
        /// </remarks>
        /// <param name="item">Selected item to check</param>
        /// <param name="selectedCategory">The category of the selected item</param>
        /// <param name="IMCVersion">The items version from its imc file</param>
        /// <returns>ObservableCollection of ComboBoxInfo classes containing race and race ID</returns>
        public static ObservableCollection <ComboBoxInfo> GetMTRLRaces(ItemData item, string selectedCategory, string IMCVersion)
        {
            ObservableCollection <ComboBoxInfo> cbiList;
            Dictionary <int, string>            racesDict = new Dictionary <int, string>();
            string MTRLFolder;

            if (item.ItemName.Equals(Strings.Body))
            {
                foreach (string race in Info.IDRace.Keys)
                {
                    MTRLFolder = String.Format(Strings.BodyMtrlFolder, race, "0001");

                    racesDict.Add(FFCRC.GetHash(MTRLFolder), race);
                }

                cbiList = new ObservableCollection <ComboBoxInfo>(Helper.FolderExistsListRace(racesDict));
            }
            else if (item.ItemName.Equals(Strings.Face))
            {
                foreach (string race in Info.IDRace.Keys)
                {
                    MTRLFolder = String.Format(Strings.FaceMtrlFolder, race, "0001");

                    racesDict.Add(FFCRC.GetHash(MTRLFolder), race);
                }

                cbiList = new ObservableCollection <ComboBoxInfo>(Helper.FolderExistsListRace(racesDict));
            }
            else if (item.ItemName.Equals(Strings.Hair))
            {
                foreach (string race in Info.IDRace.Keys)
                {
                    MTRLFolder = String.Format(Strings.HairMtrlFolder, race, "0001");

                    racesDict.Add(FFCRC.GetHash(MTRLFolder), race);
                }

                cbiList = new ObservableCollection <ComboBoxInfo>(Helper.FolderExistsListRace(racesDict));
            }
            else if (item.ItemName.Equals(Strings.Tail))
            {
                foreach (string race in Info.IDRace.Keys)
                {
                    MTRLFolder = String.Format(Strings.TailMtrlFolder, race, "0001");

                    racesDict.Add(FFCRC.GetHash(MTRLFolder), race);
                }

                cbiList = new ObservableCollection <ComboBoxInfo>(Helper.FolderExistsListRace(racesDict));
            }
            else if (item.ItemName.Equals(Strings.Face_Paint) || item.ItemName.Equals(Strings.Equipment_Decals) || item.ItemCategory.Equals("9901"))
            {
                cbiList = new ObservableCollection <ComboBoxInfo>();
                ComboBoxInfo cbi = new ComboBoxInfo()
                {
                    Name = Strings.All, ID = "0", IsNum = true
                };
                cbiList.Add(cbi);
            }
            else if (selectedCategory.Equals(Strings.Pets) || selectedCategory.Equals(Strings.Mounts) || selectedCategory.Equals(Strings.Minions))
            {
                cbiList = new ObservableCollection <ComboBoxInfo>();
                ComboBoxInfo cbi = new ComboBoxInfo()
                {
                    Name = Strings.Monster, ID = "0", IsNum = true
                };
                cbiList.Add(cbi);
            }
            else
            {
                string type = Helper.GetCategoryType(selectedCategory);

                ObservableCollection <ComboBoxInfo> cbiInfo = new ObservableCollection <ComboBoxInfo>();

                var fileHashList = Helper.GetAllFilesInFolder(FFCRC.GetHash(item.PrimaryMTRLFolder + IMCVersion));

                if (type.Equals("weapon") || type.Equals("accessory") || type.Equals("food"))
                {
                    cbiInfo.Add(new ComboBoxInfo()
                    {
                        Name = Strings.All, ID = Strings.All, IsNum = false
                    });
                }
                else
                {
                    foreach (string raceID in Info.raceID.Values)
                    {
                        Console.WriteLine(selectedCategory);
                        var MTRLFile = String.Format(Strings.EquipMtrlFile, raceID, item.PrimaryModelID, Info.slotAbr[selectedCategory], "a");

                        var fileHash = FFCRC.GetHash(MTRLFile);

                        if (fileHashList.Contains(fileHash))
                        {
                            cbiInfo.Add(new ComboBoxInfo()
                            {
                                Name = Info.IDRace[raceID], ID = raceID, IsNum = false
                            });
                        }
                    }
                }

                cbiList = cbiInfo;
            }
            return(cbiList);
        }
   public static extern Boolean GetComboBoxInfo(
 IntPtr hwndCombo,
 ref ComboBoxInfo info);
 public static int GetComboDropDownWidth( IntPtr handle )
 {
     ComboBoxInfo cbi = new ComboBoxInfo();
     cbi.cbSize = Marshal.SizeOf( cbi );
     GetComboBoxInfo( handle, ref cbi );
     int width = cbi.rcButton.Right - cbi.rcButton.Left;
     return width;
 }
示例#15
0
 private ComboBoxInfo GetComboBoxInfo()
 {
     ComboBoxInfo info = new ComboBoxInfo();
     info.cbSize = Marshal.SizeOf(info);
     GetComboBoxInfo(this.Handle, ref info);
     return info;
 }
示例#16
0
 protected override void OnHandleCreated(EventArgs e)
 {
     ComboBoxInfo info=new ComboBoxInfo();
     base.OnHandleCreated(e);
     info = new ComboBoxInfo();
     info.cbSize = Marshal.SizeOf(info);
     if (GetComboBoxInfo(base.Handle, ref info))
     {
         this.hEdit = info.hwndEdit;
     }
 }