Esempio n. 1
0
 private void UpdateBar(UAVCommons.UAVSingleParameter value, ColorProgressBar.ColorProgressBar bar)
 {
     bar.Minimum = Convert.ToInt32(value.Min) * 100;
     bar.Maximum = Convert.ToInt32(value.Max) * 100;
     bar.Value   = Convert.ToInt32(Convert.ToDouble(value.Value) * 100);
     bar.Refresh();
 }
Esempio n. 2
0
        //ProgressBar progressBar_progress;

        public RulesWindow(ref ColorProgressBar.ColorProgressBar progressBar_prog)
        {
            cpb2_prog = progressBar_prog;
            InitializeComponent();
            database = MainWindow.database;
            colorTheme();
        }
Esempio n. 3
0
 public FieldCompare(eListCollection ListCollection, eListConversation ListConversation, ref ColorProgressBar.ColorProgressBar progressBar_prog)
 {
     eLC = ListCollection;
     conversationList = ListConversation;
     cpb2_prog        = progressBar_prog;
     InitializeComponent();
     for (int l = 0; l < eLC.Lists.Length; l++)
     {
         comboBox_List.Items.Add("[" + l + "]: " + eLC.Lists[l].listName + " (" + eLC.Lists[l].elementValues.Length + ")");
     }
     CheckCompareButton(null, null);
     database = MainWindow.database;
     colorTheme();
 }
Esempio n. 4
0
        public static void UpdateProgressBar2(ColorProgressBar.ColorProgressBar prg, int value)
        {
            try
            {
                if (prg.InvokeRequired)
                {
                    UpdateProgressBarCallback2 d = UpdateProgressBar2;
                    prg.Invoke(d, prg, value);
                    return;
                }

                prg.Value = value;
            }
            catch
            {
                // This catch is simply here to avoid the OCCASIONAL crash of the application when closing it by pressing the stop button in visual studio while it is running tasks
            }
        }
Esempio n. 5
0
        // only works for PW !!!
        public eList[] Load(string elFile, ref ColorProgressBar.ColorProgressBar cpb2)
        {
            eList[] Li = new eList[0];
            addonIndex = new Dictionary <int, int>();

            Listcnts  = null;
            ListOsets = null;
            Listver   = -1;
            SStat     = new int[5] {
                0, 0, 0, 0, 0
            };

            string fileStream = Path.GetDirectoryName(elFile) + "\\elements.list.count";

            if (File.Exists(fileStream))
            {
                Listcnts  = new SortedList();
                ListOsets = new SortedList();
                using (StreamReader reader = new StreamReader(fileStream))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        string[] val = line.Split('=');
                        if (val[0] == "ver")
                        {
                            Listver = Convert.ToInt16(val[1]);
                        }
                        else if (val[0] == "offset")
                        {
                            ListOsets.Add(val[1], val[2]);
                        }
                        else
                        {
                            Listcnts.Add(val[0], val[1]);
                        }
                    }
                }
            }

            // open the element file
            FileStream   fs = File.OpenRead(elFile);
            BinaryReader br = new BinaryReader(fs);

            Version = br.ReadInt16();
            if (Listver > -1)
            {
                Version = Listver;
            }
            Signature = br.ReadInt16();

            // check if a corresponding configuration file exists
            string[] configFiles = Directory.GetFiles(Application.StartupPath + "\\configs", "PW_*_v" + Version + ".cfg");
            if (configFiles.Length > 0)
            {
                // configure an eList array with the configuration file
                ConfigFile   = configFiles[0];
                Li           = loadConfiguration(ConfigFile);
                cpb2.Maximum = Li.Length;
                cpb2.Value   = 0;

                // read the element file
                for (int l = 0; l < Li.Length; l++)
                {
                    SStat[0] = l;
                    Application.DoEvents();

                    // read offset
                    if (Li[l].listOffset != null)
                    {
                        // offset > 0
                        if (Li[l].listOffset.Length > 0)
                        {
                            Li[l].listOffset = br.ReadBytes(Li[l].listOffset.Length);
                        }
                    }
                    // autodetect offset (for list 20 & 100)
                    else
                    {
                        if (l == 0)
                        {
                            byte[] t      = br.ReadBytes(4);
                            byte[] len    = br.ReadBytes(4);
                            byte[] buffer = br.ReadBytes(BitConverter.ToInt32(len, 0));
                            Li[l].listOffset = new byte[t.Length + len.Length + buffer.Length];
                            Array.Copy(t, 0, Li[l].listOffset, 0, t.Length);
                            Array.Copy(len, 0, Li[l].listOffset, 4, len.Length);
                            Array.Copy(buffer, 0, Li[l].listOffset, 8, buffer.Length);
                        }
                        if (l == 20)
                        {
                            byte[] tag    = br.ReadBytes(4);
                            byte[] len    = br.ReadBytes(4);
                            byte[] buffer = br.ReadBytes(BitConverter.ToInt32(len, 0));
                            byte[] t      = br.ReadBytes(4);
                            Li[l].listOffset = new byte[tag.Length + len.Length + buffer.Length + t.Length];
                            Array.Copy(tag, 0, Li[l].listOffset, 0, tag.Length);
                            Array.Copy(len, 0, Li[l].listOffset, 4, len.Length);
                            Array.Copy(buffer, 0, Li[l].listOffset, 8, buffer.Length);
                            Array.Copy(t, 0, Li[l].listOffset, 8 + buffer.Length, t.Length);
                        }
                        int NPC_WAR_TOWERBUILD_SERVICE_index = 100;
                        if (Version >= 191)
                        {
                            NPC_WAR_TOWERBUILD_SERVICE_index = 99;
                        }
                        if (l == NPC_WAR_TOWERBUILD_SERVICE_index)
                        {
                            byte[] tag    = br.ReadBytes(4);
                            byte[] len    = br.ReadBytes(4);
                            byte[] buffer = br.ReadBytes(BitConverter.ToInt32(len, 0));
                            Li[l].listOffset = new byte[tag.Length + len.Length + buffer.Length];
                            Array.Copy(tag, 0, Li[l].listOffset, 0, tag.Length);
                            Array.Copy(len, 0, Li[l].listOffset, 4, len.Length);
                            Array.Copy(buffer, 0, Li[l].listOffset, 8, buffer.Length);
                        }
                    }

                    // read conversation list
                    if (l == ConversationListIndex)
                    {
                        if (Version >= 191)
                        {
                            long sourcePosition = br.BaseStream.Position;
                            int  listLength     = 0;
                            bool run            = true;
                            while (run)
                            {
                                run = false;
                                try
                                {
                                    br.ReadByte();
                                    listLength++;
                                    run = true;
                                }
                                catch
                                { }
                            }
                            br.BaseStream.Position = sourcePosition;
                            Li[l].elementTypes[0]  = "byte:" + listLength;
                        }
                        else
                        {
                            // Auto detect only works for Perfect World elements.data !!!
                            if (Li[l].elementTypes[0].Contains("AUTO"))
                            {
                                byte[] pattern        = (Encoding.GetEncoding("GBK")).GetBytes("facedata\\");
                                long   sourcePosition = br.BaseStream.Position;
                                int    listLength     = -72 - pattern.Length;
                                bool   run            = true;
                                while (run)
                                {
                                    run = false;
                                    for (int i = 0; i < pattern.Length; i++)
                                    {
                                        listLength++;
                                        if (br.ReadByte() != pattern[i])
                                        {
                                            run = true;
                                            break;
                                        }
                                    }
                                }
                                br.BaseStream.Position = sourcePosition;
                                Li[l].elementTypes[0]  = "byte:" + listLength;
                            }
                        }

                        Li[l].elementValues       = new object[1][];
                        Li[l].elementValues[0]    = new object[Li[l].elementTypes.Length];
                        Li[l].elementValues[0][0] = readValue(br, Li[l].elementTypes[0]);
                    }
                    // read lists
                    else
                    {
                        if (Version >= 191)
                        {
                            Li[l].listType = br.ReadInt32();
                        }
                        if (Listver > -1 && Listcnts[l.ToString()] != null)
                        {
                            int num = Convert.ToInt32(Listcnts[l.ToString()]);
                            Li[l].elementValues = new object[num][];
                            br.ReadBytes(4);
                        }
                        else
                        {
                            Li[l].elementValues = new object[br.ReadInt32()][];
                        }

                        SStat[1] = Li[l].elementValues.Length;

                        if (Version >= 191)
                        {
                            Li[l].elementSize = br.ReadInt32();
                        }

                        // go through all elements of a list
                        for (int e = 0; e < Li[l].elementValues.Length; e++)
                        {
                            Li[l].elementValues[e] = new object[Li[l].elementTypes.Length];

                            // go through all fields of an element
                            int idtest = -1;
                            for (int f = 0; f < Li[l].elementValues[e].Length; f++)
                            {
                                Li[l].elementValues[e][f] = readValue(br, Li[l].elementTypes[f]);
                                if (Li[l].elementFields[f] == "ID")
                                {
                                    idtest   = Int32.Parse(Li[l].GetValue(e, f));
                                    SStat[2] = idtest;
                                    if (l == 0)
                                    {
                                        if (!addonIndex.ContainsKey(idtest))
                                        {
                                            addonIndex.Add(idtest, e);
                                        }
                                        else
                                        {
                                            MessageBox.Show("Error: Found duplicate Addon id:" + idtest);
                                            addonIndex[idtest] = e;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    cpb2.Value++;
                }
            }
            else
            {
                MessageBox.Show("No corressponding configuration file found!\nVersion: " + Version + "\nPattern: " + "configs\\PW_*_v" + Version + ".cfg");
            }

            br.Close();
            fs.Close();

            return(Li);
        }
Esempio n. 6
0
 public eListCollection(string elFile, ref ColorProgressBar.ColorProgressBar cpb2)
 {
     Lists = Load(elFile, ref cpb2);
 }