示例#1
0
 public AddNewItemForm()
 {
     // TODO - refactor CCD / Invoice insertion, as combobox. Load from Enum
     InitializeComponent();
     ExtraFunctions.LoadGWDItemsToComboBox(itemItemText);
     ExtraFunctions.LoadStoringToComboBox(itemBoxText);
 }
示例#2
0
        public RTHData.RTHDataBlock ReturnRTHDataBlock(int parentMemoryOffset)
        {
            //Initialize our RTH Data Block
            RTHData.RTHDataBlock RTH_Data_Block = new RTHData.RTHDataBlock();
            //Set our memory offset
            RTH_Data_Block.Memory_Offset = (uint)(parentMemoryOffset + EnumData.Offset);
            //Determine type and assign accordingly
            switch (EnumData.Attributes)
            {
            case mValue.ObjectAttributes.Enum8:
            {
                RTH_Data_Block.Data_Block =
                    ExtraFunctions.ValueToBytes((byte)EnumOptions[cmbxSelections.SelectedIndex].Value);
                break;
            }

            case mValue.ObjectAttributes.Enum16:
            {
                RTH_Data_Block.Data_Block =
                    ExtraFunctions.ValueToBytes((short)EnumOptions[cmbxSelections.SelectedIndex].Value);
                break;
            }

            case mValue.ObjectAttributes.Enum32:
            {
                RTH_Data_Block.Data_Block =
                    ExtraFunctions.ValueToBytes(EnumOptions[cmbxSelections.SelectedIndex].Value);
                break;
            }
            }
            //Set our block size
            RTH_Data_Block.Block_Size = RTH_Data_Block.Data_Block.Length;
            //Return the RTH Data Block instance
            return(RTH_Data_Block);
        }
示例#3
0
        private void btnGraph_Click(object sender, EventArgs e)
        {
            double cAmount  = double.Parse(txtChangeAmount.Text);
            double maxPrice = double.Parse(txtMaxPrice.Text);
            double minPrice = double.Parse(txtMinPrice.Text);

            if (chbIncludeExtra.Checked && !ExtraFunctions.ValidateExtraConfiguration(txtPeriod.Text, tbExtraPeriod.Text,
                                                                                      cbPeriodType.SelectedIndex, cbExtraPeriodType.SelectedIndex))
            {
                showError(Constancts.ErrorMessagePeriodType);
            }
            double basePrice  = double.Parse(txtBasePrice.Text);
            int    period     = int.Parse(txtPeriod.Text);
            int    periodType = cbPeriodType.SelectedIndex;
            double newPrice   = basePrice;

            SetImport2FirstPeriods(period, basePrice);

            for (int i = period; i < _importDateData.Count; i++)
            {
                newPrice = AlgorithmFunctions.GetNewPrice(newPrice, period, periodType, _exportDateData, _exportSalesData, cAmount, maxPrice, minPrice);
                _exportPriceData.Add(newPrice);
                _exportSalesData.Add(AlgorithmFunctions.CalculateSales(newPrice, _importSalesData.ToArray()[i], double.Parse(txtBasePrice.Text)));
            }

            DateTime[] x  = _importDateData.ToArray();
            int[]      y  = _importSalesData.ToArray();
            int[]      y2 = _exportSalesData.ToArray();

            Grahps grahps = new Grahps(Constancts.CompareTitule, Constancts.Serie1, x, y, Constancts.Serie2, y2);

            grahps.ShowGrahpVaues();
        }
        private static Image Deswizzle(string FilePath)
        {
            EndianReader endianReader = new EndianReader((Stream) new FileStream(FilePath, FileMode.Open, FileAccess.Read), EndianType.LittleEndian);

            endianReader.BaseStream.Position = 12L;
            int height = endianReader.ReadInt32();
            int width  = endianReader.ReadInt32();

            endianReader.BaseStream.Position = 92L;
            string hexString = ExtraFunctions.BytesToHexString(endianReader.ReadBytes(12));

            endianReader.BaseStream.Position = 128L;
            int count = width * height * 4;

            byte[] buffer = endianReader.ReadBytes(count);
            endianReader.Close();
            if (hexString == "FF03000000FC0F000000F03F")
            {
                Image image = XboxScreenshot.DeswizzleA2R10G10B10(buffer, width, height);
                if (AppSettings.Settings.AdjustGamma)
                {
                    BitmapData bitmapData = ((Bitmap)image).LockBits(new Rectangle(0, 0, image.Width, image.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
                    XboxScreenshot.GammaCorrect(AppSettings.Settings.GammaValue, bitmapData);
                    ((Bitmap)image).UnlockBits(bitmapData);
                }
                return(image);
            }
            if (hexString == "0000FF0000FF0000FF000000")
            {
                return(XboxScreenshot.DeswizzleA8R8G8B8(buffer, width, height));
            }
            return((Image)null);
        }
示例#5
0
        public void LoadValue(HaloMap Map, int parentOffset)
        {
            base.Enabled = false;
            Map.IO.In.BaseStream.Position = parentOffset + ValueData.Offset;
            fullOffset     = (int)Map.IO.In.BaseStream.Position;
            HMap           = Map;
            ValueData.Size = Map.IO.In.ReadUInt32();
            Stream baseStream = Map.IO.In.BaseStream;

            baseStream.Position  += 8L;
            ValueData.Pointer     = Map.IO.In.ReadInt32() - Map.Map_Header.mapMagic;
            lblValueType.Text     = "data{" + ValueData.Size.ToString() + "}";
            txtArrayBox.MaxLength = (int)(ValueData.Size * 2);
            if (ValueData.Size > 0x400)
            {
                txtArrayBox.Text = "Data too long. Reading skipped.";
            }
            else if (((ValueData.Size > 0) && (ValueData.Pointer > 0)) && (ValueData.Pointer < Map.Map_Header.fileSize))
            {
                Map.IO.In.BaseStream.Position = ValueData.Pointer;
                txtArrayBox.Text = ExtraFunctions.BytesToHexString(Map.IO.In.ReadBytes((int)ValueData.Size));
                base.Enabled     = true;
            }
            Editted = false;
        }
示例#6
0
        public double AverageRate(string originalCurrency, string finalCurrency, int amountOfDays)
        {
            double        averageRate;
            List <double> dailyRates = GetDailyRates(originalCurrency, finalCurrency, amountOfDays);

            averageRate = dailyRates.Average();
            return(ExtraFunctions.SetSigFigs(averageRate, 5));
        }
示例#7
0
 public void LoadValue(HaloMap Map, int parentOffset)
 {
     Map.IO.In.BaseStream.Position = parentOffset + ValueData.Offset;
     fullOffset = (int)Map.IO.In.BaseStream.Position;
     HMap       = Map;
     byte[] data = Map.IO.In.ReadBytes(ValueData.Length);
     txtArrayBox.Text = ExtraFunctions.BytesToHexString(data);
     Editted          = false;
 }
    // Update is called once per frame
    public IEnumerator Play()
    {
        yield return(new WaitForSeconds(ExtraFunctions.RandomFromRange(TimeRange)));

        if (Darkness.activeInHierarchy)
        {
            Player.PlayOneShot(ExtraFunctions.RandomFromList(HorseNoisesL));
        }
        StartCoroutine(Play());
    }
示例#9
0
        public double[] MinMaxRate(string originalCurrency, string finalCurrency, int amountOfDays)
        {
            List <double> dailyRates = GetDailyRates(originalCurrency, finalCurrency, amountOfDays);
            double        minRate    = ExtraFunctions.SetSigFigs(dailyRates.Min(), 5);
            double        maxRate    = ExtraFunctions.SetSigFigs(dailyRates.Max(), 5);

            double[] minMaxRates = new double[2] {
                minRate, maxRate
            };
            return(minMaxRates);
        }
示例#10
0
        protected virtual void CalculateShellVelocity()
        {
            Vector3 direction = mousePosition - firePoint.position;
            float   yOffset   = -direction.y;

            direction = Vector3.ProjectOnPlane(direction, Vector3.up);
            float distance = Mathf.Clamp(direction.magnitude, minimumShellDistance, maxShellDistance);
            float angle    = Vector3.Angle(firePoint.forward, Vector3.up) * Mathf.Deg2Rad;

            shellVelocity = ExtraFunctions.CalculateLaunchSpeed(distance, yOffset, Physics.gravity.magnitude, angle);
        }
示例#11
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (base.Enabled)
     {
         if (txtArrayBox.Text.Length != txtArrayBox.MaxLength)
         {
             OutputMessenger.OutputMessage("Data array \"" + ValueData.Name + "\" could not be saved due to an invalid length of bytes.", this);
         }
         try
         {
             if (AppSettings.Settings.IP_and_XDK_Name == "")
             {
                 MessageBox.Show("XDK Name/IP not set");
             }
             else
             {
                 XboxDebugCommunicator communicator = new XboxDebugCommunicator(AppSettings.Settings.IP_and_XDK_Name);
                 if (!communicator.Connected)
                 {
                     try
                     {
                         communicator.Connect();
                     }
                     catch
                     {
                     }
                 }
                 XboxMemoryStream        stream = communicator.ReturnXboxMemoryStream();
                 HaloReach3d.IO.EndianIO nio    = new HaloReach3d.IO.EndianIO(stream, HaloReach3d.IO.EndianType.BigEndian);
                 nio.Open();
                 nio.Out.BaseStream.Position = ValueData.Pointer + HMap.Map_Header.mapMagic;
                 try
                 {
                     nio.Out.Write(ExtraFunctions.HexStringToBytes(txtArrayBox.Text), 0, txtArrayBox.Text.Length / 2);
                 }
                 catch
                 {
                     OutputMessenger.OutputMessage("Some invalid byte characters were intered in data array \"" + ValueData.Name + "\".\n They will not be saved.", this);
                     return;
                 }
                 nio.Close();
                 stream.Close();
                 communicator.Disconnect();
                 OutputMessenger.OutputMessage("Poked Chunk Values", this);
             }
         }
         catch
         {
             OutputMessenger.OutputMessage("Couldn't Poke Chunks", this);
         }
     }
 }
示例#12
0
        protected virtual void HandleReticle()
        {
            Vector3 hit = ExtraFunctions.GetHitPosition(firePoint.position, firePoint.forward, shellVelocity);

            if (hit != null)
            {
                reticlePosition = hit;
            }

            if (reticleTransform)
            {
                reticleTransform.position = ReticlePosition;
            }
        }
示例#13
0
 public BLF_Header(EndianIO IO, int position)
 {
     IO.In.BaseStream.Position = position;
     this.BLF_String           = IO.In.ReadAsciiString(4);
     this.HeaderSize           = IO.In.ReadInt32();
     this.Unknown8             = IO.In.ReadInt16();
     this.Unknown10            = IO.In.ReadInt16();
     this.Unknown12            = IO.In.ReadInt16();
     this.FileDescription      = ExtraFunctions.RemoveWhiteSpacingFromString(IO.In.ReadAsciiString(0x22));
     this.FileSize             = IO.In.ReadInt32();
     this.Unknown52            = IO.In.ReadBytes(8);
     this.Map_ID          = IO.In.ReadInt32();
     this.FileContentSize = IO.In.ReadInt32();
 }
示例#14
0
        public void InternalizeRawChunk(int rawPoolIndex)
        {
            //Get the raw chunk data
            byte[] rawChunk = Map.RawInformation.GetCompressedRawDataFromPoolIndex(rawPoolIndex);

            //Calculate the size to insert
            int paddingSize = ExtraFunctions.CalculatePadding((int)rawChunk.Length, 0x1000);

            //Block size to insert into the raw table
            int blockSize = paddingSize + (int)rawChunk.Length;

            //Open our IO
            Map.OpenIO();

            //Go to our external map index offset.
            Map.IO.Out.BaseStream.Position = Map.RawInformation.RawPools[rawPoolIndex].ChunkOffset + 4;

            //Write our value
            Map.IO.Out.Write((short)-1);

            //Skip 2 bytes
            Map.IO.Out.BaseStream.Position += 2;

            //Write our new raw data chunk offset.
            Map.IO.Out.Write((uint)Map.MapHeader.RawTableSize);

            //Close our IO
            Map.CloseIO();

            //Create our array for our bytes to insert
            byte[] dataToInsert = new byte[blockSize];
            for (int i = 0; i < dataToInsert.Length; i++)
            {
                dataToInsert[i] = 0xFF;
            }
            Array.Copy(rawChunk, dataToInsert, (int)rawChunk.Length);

            //Time to start inserting the block..
            ExtraFunctions.InsertBytes(Map.FileName, Map.MapHeader.RawTableOffset + Map.MapHeader.RawTableSize, dataToInsert);



            Map.OpenIO();
            Map.IO.Out.BaseStream.Position = 1160;
            Map.IO.Out.Write((map.MapHeader.RawTableSize + blockSize));
            Map.IO.Out.BaseStream.Position = 1144;
            Map.IO.Out.Write((map.MapHeader.localeTableAddressModifier + blockSize));
            Map.CloseIO();
        }
示例#15
0
            public static async Task <bool> RetriveVideos()
            {
                // Show Progress Ring

                // Reset DataContext and Lists


                // Send a request to the YouTube API to search for channels
                var searchChannelRequest = youtubeService.Channels.List("contentDetails");

                searchChannelRequest.Id         = "UC70UzaroFf5GcyecHOGw-tw"; // The WinBeta Channel ID
                searchChannelRequest.MaxResults = 1;                          // Only get one result (Only can be one channel with the same channel ID)

                // API response
                var searchChannelResponse = await searchChannelRequest.ExecuteAsync();

                var channel = searchChannelResponse.Items.First(); // Choose the first (and only) item

                // Send a request to the YouTube API to search for playlists on youtube channel
                // (for now only grab upload playlist, later on will grab all playlists and let user filter)
                var playlistRequest = youtubeService.PlaylistItems.List("snippet");

                playlistRequest.PlaylistId = channel.ContentDetails.RelatedPlaylists.Uploads; // Get the uploads playlist
                playlistRequest.MaxResults = 50;                                              // Max of 50 results

                // API response
                var playlistResponse = await playlistRequest.ExecuteAsync();

                // Loop through all items in upload playlist
                foreach (var playlistItem in playlistResponse.Items)
                {
                    // Create a video object to pass into the data context
                    VideoItem video = new VideoItem()
                    {
                        Title     = playlistItem.Snippet.Title,                                           // Video Title
                        Thumbnail = ExtraFunctions.GetVideoThumbnail(playlistItem),                       // Video thumbnail <- This function gets the highest quality avaliable
                        Date      = ExtraFunctions.ConvertVideoDateTime(playlistItem.Snippet.PublishedAt) // Get the published date (formated and converted to correct time zone)
                    };

                    // Add video to data context list
                    videos.Add(video);
                }

                return(true);
            }
示例#16
0
        private static Image Deswizzle(string FilePath)
        {
            //Open the temp dds
            FileStream   fs = new FileStream(FilePath, FileMode.Open, FileAccess.Read);
            EndianReader br = new EndianReader(fs, EndianType.LittleEndian);

            //Read the dds header
            br.BaseStream.Position = 0x0C;
            int height = br.ReadInt32();
            int width  = br.ReadInt32();

            //Read our random bytes
            br.BaseStream.Position = 0x5C;
            string randomBuf = ExtraFunctions.BytesToHexString(br.ReadBytes(12));

            //Read the buffer
            br.BaseStream.Position = 0x80;
            int size = width * height * 4;

            byte[] buffer = br.ReadBytes(size);
            br.Close();

            //A2R10G10B10
            if (randomBuf == "FF03000000FC0F000000F03F")
            {
                Image img = DeswizzleA2R10G10B10(buffer, width, height);
                //See if we have to fix the gamma
                if (AppSettings.Settings.AdjustGamma)
                {
                    BitmapData imageData = ((Bitmap)img).LockBits(
                        new Rectangle(0, 0, img.Width, img.Height),
                        ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
                    GammaCorrect(AppSettings.Settings.GammaValue, imageData);
                    ((Bitmap)img).UnlockBits(imageData);
                }
                return(img);
            }
            //A8R8G8B8?
            else if (randomBuf == "0000FF0000FF0000FF000000")
            {
                return(DeswizzleA8R8G8B8(buffer, width, height));
            }
            return(null);
        }
示例#17
0
 public void PokeValue(HaloReach3d.IO.EndianIO IO, int parentOffset)
 {
     if (base.Enabled)
     {
         if (txtArrayBox.Text.Length != txtArrayBox.MaxLength)
         {
             OutputMessenger.OutputMessage("Data array \"" + ValueData.Name + "\" could not be saved due to an invalid length of bytes.", this);
         }
         IO.Out.BaseStream.Position = ValueData.Pointer + HMap.Map_Header.mapMagic;
         try
         {
             IO.Out.Write(ExtraFunctions.HexStringToBytes(txtArrayBox.Text), 0, ExtraFunctions.HexStringToBytes(txtArrayBox.Text).Length);
         }
         catch
         {
             OutputMessenger.OutputMessage("Some invalid byte characters were intered in data array \"" + ValueData.Name + "\".\n They will not be saved.", this);
         }
     }
 }
示例#18
0
 public void SaveValue(EndianIO IO, int parentOffset)
 {
     if (txtArrayBox.Text.Length != txtArrayBox.MaxLength)
     {
         OutputMessenger.OutputMessage("Data array \"" + ValueData.Name + "\" could not be saved due to an invalid length of bytes.", this);
     }
     byte[] buffer = null;
     try
     {
         buffer = ExtraFunctions.HexStringToBytes(txtArrayBox.Text);
     }
     catch
     {
         OutputMessenger.OutputMessage("Some invalid byte characters were intered in data array \"" + ValueData.Name + "\".\n They will not be saved.", this);
         return;
     }
     IO.Out.BaseStream.Position = parentOffset + ValueData.Offset;
     IO.Out.Write(buffer);
 }
示例#19
0
 public BLF_Header(EndianIO IO, int position)
 {
     //Go to our selected position
     IO.In.BaseStream.Position = position;
     //Read the _blf head string
     BLF_String = IO.In.ReadAsciiString(4);
     //Read the headersize value
     HeaderSize = IO.In.ReadInt32();
     //Read our unknown values
     Unknown8  = IO.In.ReadInt16();
     Unknown10 = IO.In.ReadInt16();
     Unknown12 = IO.In.ReadInt16();
     //Read our file description
     FileDescription = ExtraFunctions.RemoveWhiteSpacingFromString(IO.In.ReadAsciiString(34));
     //Read our file size
     FileSize = IO.In.ReadInt32();
     //Read our unknown array
     Unknown52 = IO.In.ReadBytes(8);
     //Read our mapID
     Map_ID = IO.In.ReadInt32();
     //Read our fileContentSize value.
     FileContentSize = IO.In.ReadInt32();
 }
示例#20
0
        public RTHData.RTHDataBlock ReturnRTHDataBlock(int parentMemoryOffset)
        {
            //Initialize our RTH Data Block
            RTHData.RTHDataBlock RTH_Data_Block = new RTHData.RTHDataBlock();
            //Set our memory offset
            RTH_Data_Block.Memory_Offset = (uint)(parentMemoryOffset + BitmaskData.Offset);
            //Determine type and assign accordingly
            switch (BitmaskData.Attributes)
            {
            case mValue.ObjectAttributes.Bitmask8:
            {
                RTH_Data_Block.Data_Block =
                    ExtraFunctions.ValueToBytes((byte)BitHelper.ConvertToWriteableInteger(ReturnCheckedList()));
                break;
            }

            case mValue.ObjectAttributes.Bitmask16:
            {
                RTH_Data_Block.Data_Block =
                    ExtraFunctions.ValueToBytes((short)BitHelper.ConvertToWriteableInteger(ReturnCheckedList()));
                break;
            }

            case mValue.ObjectAttributes.Bitmask32:
            {
                RTH_Data_Block.Data_Block =
                    ExtraFunctions.ValueToBytes(BitHelper.ConvertToWriteableInteger(ReturnCheckedList()));
                break;
            }
            }
            //Reverse our value
            //Array.Reverse(RTH_Data_Block.Data_Block);
            //Set our block size
            RTH_Data_Block.Block_Size = RTH_Data_Block.Data_Block.Length;
            //Return the RTH Data Block instance
            return(RTH_Data_Block);
        }
示例#21
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            if (chbIncludeExtra.Checked && !ExtraFunctions.ValidateExtraConfiguration(txtPeriod.Text, tbExtraPeriod.Text,
                                                                                      cbPeriodType.SelectedIndex, cbExtraPeriodType.SelectedIndex))
            {
                showError(Constancts.ErrorMessagePeriodType);
            }

            DateTime[] dates  = _exportDateData.ToArray();
            int[]      sales  = _exportSalesData.ToArray();
            double[]   prices = _exportPriceData.ToArray();

            var csv = new StringBuilder();

            csv.AppendLine("DateTime;SalesByDay;Price");

            for (int i = 0; i < _exportDateData.Count; i++)
            {
                var newLine = string.Format("{0};{1};{2}", dates[i], sales[i], prices[i]);
                csv.AppendLine(newLine);
            }

            File.WriteAllText(@"C:\Users\jimen\source\repos\TestPriceAlgorithm\testCSV\Test.csv", csv.ToString());
        }
示例#22
0
        public Game1()
        {
            progressObject = ExtraFunctions.loadProgress();


            graphics = new GraphicsDeviceManager(this);

            Content.RootDirectory = "Content";

            TargetElapsedTime = TimeSpan.FromTicks(333333);

            graphics.IsFullScreen = true;
            //graphics.PreferredBackBufferWidth = sSCREEN_RESOLUTION_WIDTH;
            //graphics.PreferredBackBufferHeight = sSCREEN_RESOLUTION_HEIGHT;
            //graphics.ApplyChanges();
            //graphics.GraphicsDevice.Clear(Color.Black);

            mScreenManager = new ScreenManager(this);

            Components.Add(mScreenManager);

            instance = this;
            SoundManager.Initialize(this);
        }
示例#23
0
 public RTHData.RTHDataBlock ReturnRTHDataBlock(int parentMemoryOffset)
 {
     //Initialize our RTH Data Block
     RTHData.RTHDataBlock RTH_Data_Block = new RTHData.RTHDataBlock();
     //Set our memory offset
     RTH_Data_Block.Memory_Offset = (uint)(parentMemoryOffset + IdentData.Offset) - 12;
     //Get our class data
     byte[] classData = ExtraFunctions.StringToBytes(cmbxClass.Text);
     //Get our blank data
     byte[] blankData = new byte[8];
     //Create our identData array
     byte[] identData = null;
     //If the value isn't null
     if (cmbxName.Text != "<<null>>")
     {
         //Assign our ident
         identData =
             ExtraFunctions.HexStringToBytes(
                 HMap.IndexItems[HMap.GetTagIndexByClassAndName(cmbxClass.Text, cmbxName.Text)].Ident.ToString("X"));
     }
     else
     {
         //Otherwise, if it is, we assign a null value
         identData = new byte[4] {
             0xFF, 0xFF, 0xFF, 0xFF
         };
     }
     RTH_Data_Block.Data_Block =
         ExtraFunctions.HexStringToBytes(ExtraFunctions.BytesToHexString(classData) +
                                         ExtraFunctions.BytesToHexString(blankData) +
                                         ExtraFunctions.BytesToHexString(identData));
     //Set our block size
     RTH_Data_Block.Block_Size = 16;
     //Return the RTH Data Block instance
     return(RTH_Data_Block);
 }
        private void storageinfotimer_Tick(object sender, EventArgs e)
        {
            //Die Zahlen zur aktuellen Partition erhalten
            ulong[] values = DriveFunctions.GetPartitionSizeData(driveletter);

            //Die Zahlen in die Felder eintragen
            lbsizefilledbyte.Text = ExtraFunctions.GetNumberWithPoints(Convert.ToDouble(values[2]));
            lbsizefreebyte.Text   = ExtraFunctions.GetNumberWithPoints(Convert.ToDouble(values[1]));
            lbsizegesbyte.Text    = ExtraFunctions.GetNumberWithPoints(Convert.ToDouble(values[0]));

            lbsizefilled.Text = ExtraFunctions.UnitChange(Convert.ToDouble(values[2]));
            lbsizefree.Text   = ExtraFunctions.UnitChange(Convert.ToDouble(values[1]));
            lbsizeges.Text    = ExtraFunctions.UnitChange(Convert.ToDouble(values[0]));

            //Jetzt muss der Balken gezeichnet werden. Die Farbe ist AquaMarine
            Graphics g = picstoragebar.CreateGraphics();

            g.Clear(Color.LightGray);
            Color fillcolor = Color.Aqua;
            Brush brush     = new SolidBrush(fillcolor);

            //Die Werte müssen gezeichnet werden. Da die Größe des Balkens sich verändern kann, muss es
            //dynamisch berechnet werden können
            double percentfilled = values[2] * 100 / values[0];
            double lenbar        = picstoragebar.Size.Width / 100 * percentfilled;

            //Die Bar wird jetzt gezeichnet
            g.FillRectangle(brush, 0, 0, Convert.ToSingle(lenbar), picstoragebar.Size.Height);

            //Die Objekte disposen (da die viel RAM verbrauchen)
            g.Dispose();
            brush.Dispose();

            //Das Textlabel mit den Speicher auch aktualisieren
            lbstorageinfo.Text = ExtraFunctions.UnitChange(Convert.ToDouble(values[1])) + " frei von " + ExtraFunctions.UnitChange(Convert.ToDouble(values[0]));
        }
示例#25
0
 public static string GetUserKey()
 {
     return(ExtraFunctions.BytesToHexString(GetHash(GetOperatingSystemInfo())));
 }
示例#26
0
        protected void LoginButtonClick(object sender, EventArgs e)
        {
            //check for empty text boxes
            if (UsernameTextBox.Text.Length == 0)
            {
                StatusLabel.Text      = "Enter a username";
                StatusLabel.ForeColor = System.Drawing.Color.Red;
                return;
            }
            if (PasswordTextBox.Text.Length == 0)
            {
                StatusLabel.Text      = "Enter a password";
                StatusLabel.ForeColor = System.Drawing.Color.Red;
                return;
            }

            //open the xml document and check if user exists
            //if so, sign them in and start their session
            XmlDocument membersXML = new XmlDocument();

            membersXML.Load(Server.MapPath("~/App_Data/Member.xml"));
            XmlNodeList membersList = membersXML.SelectNodes("Members/Member");

            for (int i = 0; i < membersList.Count; i++)
            {
                if (membersList.Item(i).FirstChild.InnerText == UsernameTextBox.Text && membersList.Item(i).LastChild.InnerText == ExtraFunctions.HashFunction(PasswordTextBox.Text).ToString())
                {
                    Session["Username"] = UsernameTextBox.Text;
                    Session["Sid"]      = Session.SessionID;
                    Response.Redirect("Member/Member");
                }
            }
        }
        private void LoadLastData()
        {
            //Maximale Bytezahl berechnen
            long gesbyte = 0;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                gesbyte += Convert.ToInt64(dt.Rows[i].ItemArray[3].ToString());
            }

            //Einträge in der DataTable nach Size sortieren
            DataView v = dt.DefaultView;

            v.Sort = "Size DESC";

            //ListView füllen
            ImageList img = new ImageList();

            img.ColorDepth          = ColorDepth.Depth32Bit;
            img.ImageSize           = new Size(16, 16);
            lvinhalt.SmallImageList = img;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                long         size = Convert.ToInt64(v[i].Row.ItemArray[3].ToString());
                ListViewItem lvi  = new ListViewItem(v[i].Row.ItemArray[0].ToString());
                lvi.SubItems.Add(v[i].Row.ItemArray[2].ToString());
                lvi.SubItems.Add(ExtraFunctions.GetFileSizeKB(Convert.ToDouble(size)));

                //Grafik einblenden
                if (v[i].Row.ItemArray[1].ToString() == "Folder")
                {
                    img.Images.Add(FilesystemIcons.GetSmallIcon(DirectoryFunctions.CorrectPath(dirpath)));
                }
                else
                {
                    FileInfo f = new FileInfo(DirectoryFunctions.CorrectPath(dirpath) + v[i].Row.ItemArray[0].ToString());
                    try
                    {
                        if (f.Extension == ".lnk")
                        {
                            img.Images.Add(FilesystemIcons.GetSmallIcon(FileFunctions.GetShortcutPath(f.FullName)));
                        }
                        else
                        {
                            img.Images.Add(FilesystemIcons.GetSmallIcon(f.FullName));
                        }
                    }
                    catch
                    {
                        img.Images.Add(FilesystemIcons.GetIconByExtension_x16(f.Extension));
                    }
                }
                lvi.ImageIndex = img.Images.Count - 1;
                lvi.SubItems.Add(Math.Round(Convert.ToDouble(size * 100 / gesbyte), 2).ToString() + "%");

                lvinhalt.Items.Add(lvi);
            }

            lbsize.Text = ExtraFunctions.UnitChange(Convert.ToDouble(gesbyte));
            tabPage2.Controls.RemoveAt(0);
        }
示例#28
0
        public void SaveLocale(int LocaleTableIndex, int StringIndex, string strName)
        {
            //Get our Locale Table
            LocaleHandler.LocaleTable selectedTable = LocaleTables[LocaleTableIndex];

            //Compare our string lengths.
            if (selectedTable.LocaleStrings[StringIndex].Name.Length == strName.Length)
            {
                //Open our IO
                Map.OpenIO();

                //Go to that locale's position
                Map.IO.Out.BaseStream.Position = selectedTable.LocaleTableOffset +
                                                 selectedTable.LocaleStrings[StringIndex].Offset;

                //Write our new locale.
                Map.IO.Out.WriteAsciiString(strName, strName.Length);

                //Close our IO
                Map.CloseIO();
            }
            else
            {
                //Get our variables
                int differenceStringLength = strName.Length - selectedTable.LocaleStrings[StringIndex].Name.Length;
                int oldTableSize           = selectedTable.LocaleTableSize;
                int newTableSize           = selectedTable.LocaleTableSize + differenceStringLength;
                int oldTableSizePadded     = oldTableSize + ExtraFunctions.CalculatePadding(oldTableSize, 0x1000);
                int newTableSizePadded     = newTableSize + ExtraFunctions.CalculatePadding(newTableSize, 0x1000);
                int differenceTableSize    = newTableSizePadded - oldTableSizePadded;

                //Let's recalculate some variables.

                //Open our IO
                Map.OpenIO();

                //Go to our following string index's position
                Map.IO.Out.BaseStream.Position = selectedTable.LocaleTableIndexOffset + ((StringIndex + 1) * 8);

                //Loop for every string after.
                for (int i = StringIndex + 1; i < selectedTable.LocaleCount; i++)
                {
                    //Skip 4 bytes
                    Map.IO.Out.BaseStream.Position += 4;
                    //Write our new index
                    Map.IO.Out.Write(selectedTable.LocaleStrings[i].Offset + differenceStringLength);
                }

                //Let's shift our other tables

                //Loop for each table after this one.
                for (int i = LocaleTableIndex + 1; i < LocaleTables.Count; i++)
                {
                    //Go to that table's offset.
                    Map.IO.Out.BaseStream.Position = LocaleTables[i].Offset + 8;

                    //Shift our values
                    LocaleTables[i].LocaleTableOffset      += differenceTableSize;
                    LocaleTables[i].LocaleTableIndexOffset += differenceTableSize;

                    //Write our values.
                    Map.IO.Out.Write((LocaleTables[i].LocaleTableIndexOffset - Map.MapHeader.localeTableAddressModifier));
                    Map.IO.Out.Write((LocaleTables[i].LocaleTableOffset - Map.MapHeader.localeTableAddressModifier));
                }

                byte[] restOfTable = new byte[0];
                try
                {
                    //Read the rest of our table after we'll insert
                    Map.IO.In.BaseStream.Position = selectedTable.LocaleTableOffset + selectedTable.LocaleStrings[StringIndex + 1].Offset;
                    restOfTable = Map.IO.In.ReadBytes(oldTableSize - selectedTable.LocaleStrings[StringIndex].Offset);
                }
                catch { }
                //Close our IO
                Map.CloseIO();

                //Check our difference.
                if (differenceTableSize > 0)
                {
                    //Insert
                    ExtraFunctions.InsertBytes(Map.FileName, selectedTable.LocaleTableOffset + oldTableSizePadded, differenceTableSize);
                }
                else if (differenceTableSize < 0)
                {
                    //Delete
                    ExtraFunctions.DeleteBytes(Map.FileName, selectedTable.LocaleTableOffset + newTableSizePadded, oldTableSizePadded - newTableSizePadded);
                }

                //Open our IO
                Map.OpenIO();

                //Let's write our new strings name.
                Map.IO.Out.BaseStream.Position = selectedTable.LocaleTableOffset + selectedTable.LocaleStrings[StringIndex].Offset;
                Map.IO.Out.WriteAsciiString(strName, strName.Length + 1);

                //Write the ending of our table
                Map.IO.Out.Write(restOfTable);

                Map.IO.Out.Write(new byte[newTableSizePadded - newTableSize]);

                //Lets go write our new locale table size
                Map.IO.Out.BaseStream.Position = selectedTable.Offset + 4;

                //Write our new size.
                Map.IO.Out.Write(newTableSize);

                //Close our IO
                Map.CloseIO();

                //Set our new table size
                selectedTable.LocaleTableSize = newTableSize;
            }



            //Open our IO
            Map.OpenIO();

            //Go back to the beginning of the table
            Map.IO.SeekTo(selectedTable.LocaleTableOffset);
            byte[] hash = SHA1.Create().ComputeHash(Map.IO.In.ReadBytes(
                                                        selectedTable.LocaleTableSize));
            //Seek to where the hash is
            Map.IO.SeekTo(selectedTable.Offset + 0x24);
            //Write it
            Map.IO.Out.Write(hash);

            //Go back to the beginning of the index table
            Map.IO.SeekTo(selectedTable.LocaleTableIndexOffset);
            hash = SHA1.Create().ComputeHash(Map.IO.In.ReadBytes(0x08 * selectedTable.LocaleCount));
            //Seek to where the hash is
            Map.IO.SeekTo(selectedTable.Offset + 0x10);
            //Write it
            Map.IO.Out.Write(hash);
            //Close our IO
            Map.CloseIO();
        }
示例#29
0
        protected void RegisterButtonClick(object sender, EventArgs e)
        {
            //check image verifier
            if (!Session["verifyString"].ToString().ToLower().Equals(ImageVerifierTextBox.Text.ToLower()))
            {
                StatusLabel.Text      = "Image verification not correct";
                StatusLabel.ForeColor = System.Drawing.Color.Red;
                return;
            }

            //check if textboxes are empty
            if (UsernameTextBox.Text.Length == 0)
            {
                StatusLabel.Text      = "Enter a username";
                StatusLabel.ForeColor = System.Drawing.Color.Red;
                return;
            }
            if (PasswordTextBox.Text.Length == 0)
            {
                StatusLabel.Text      = "Enter a password";
                StatusLabel.ForeColor = System.Drawing.Color.Red;
                return;
            }

            //check if username is already in the xml file
            XmlDocument membersXML = new XmlDocument();

            membersXML.Load(Server.MapPath("~/App_Data/Member.xml"));
            XmlNodeList membersList = membersXML.SelectNodes("Members/Member");

            for (int i = 0; i < membersList.Count; i++)
            {
                if (membersList.Item(i).FirstChild.InnerText == UsernameTextBox.Text)
                {
                    StatusLabel.Text      = "Username already exists";
                    StatusLabel.ForeColor = System.Drawing.Color.Red;
                    return;
                }
            }

            //create a new user in the file
            XmlElement newMember         = membersXML.CreateElement("Member");
            XmlElement newMemberUserName = membersXML.CreateElement("UserName");
            XmlElement newMemberPassword = membersXML.CreateElement("Password");

            newMemberUserName.InnerText = UsernameTextBox.Text;
            //hash the password
            newMemberPassword.InnerText = ExtraFunctions.HashFunction(PasswordTextBox.Text).ToString();
            newMember.AppendChild(newMemberUserName);
            newMember.AppendChild(newMemberPassword);
            membersXML.DocumentElement.AppendChild(newMember);
            membersXML.Save(Server.MapPath("~/App_Data/Member.xml"));
            StatusLabel.Text      = "User created";
            StatusLabel.ForeColor = System.Drawing.Color.Black;

            //add username to cookies for easier logging in in the future
            if (Response.Cookies["UserData"] != null & Response.Cookies["UserData"]["Username"] != null)
            {
                Response.Cookies["UserData"]["Username"] = UsernameTextBox.Text;
            }
            else
            {
                HttpCookie usernameCookie = new HttpCookie("UserData");
                usernameCookie["Username"] = UsernameTextBox.Text;
                usernameCookie.Expires     = DateTime.Now.AddDays(1d);
                Response.Cookies.Add(usernameCookie);
            }
        }
        private void ShowPathContent()
        {
            //ListView leeren
            lvfs.Items.Clear();

            //Wenn der Pfad leer ist, sollen die Drives angezeigt werden. Wenn aber ein Pfad enthalten ist
            //soll der Inhalt des Pfades (Ordner) angezeigt werden
            if (_aktpfad == "")
            {
                smlist.Images.Clear();

                //Nun werden alle Drives geladen und angezeigt
                foreach (DriveInfo drive in DriveInfo.GetDrives())
                {
                    //Icon ermitteln
                    smlist.Images.Add(FilesystemIcons.GetSmallIcon(string.Concat(drive.Name.Substring(0, 2) + @"\")));
                    //Jetzt muss geschaut werden, ob der Drive aktiv ist oder nicht und danach entschieden werden
                    if (drive.IsReady)
                    {
                        ListViewItem lvi = new ListViewItem(string.Concat(drive.Name.Substring(0, 2), " ", DriveFunctions.GetVolumeLabel(Convert.ToChar(drive.Name.Substring(0, 1)))), smlist.Images.Count - 1);
                        lvi.SubItems.Add(""); //Dummy
                        //Der Typ wird anhand des DriveType angegeben. Bei Size kommt der maximale Speicherplatz
                        if (drive.DriveType == DriveType.Fixed)
                        {
                            lvi.SubItems.Add(DriveFunctions.DRIVE_VOLUMELABEL_STD_HDD);
                        }
                        else if (drive.DriveType == DriveType.CDRom)
                        {
                            lvi.SubItems.Add(DriveFunctions.DRIVE_VOLUMELABEL_STD_OPT);
                        }
                        else if (drive.DriveType == DriveType.Removable)
                        {
                            lvi.SubItems.Add(DriveFunctions.DRIVE_VOLUMELABEL_STD_EXT);
                        }
                        else if (drive.DriveType == DriveType.Network)
                        {
                            lvi.SubItems.Add(DriveFunctions.DRIVE_VOLUMELABEL_STD_NET);
                        }
                        else
                        {
                            lvi.SubItems.Add("Unbekannter Laufwerkstyp");
                        }

                        lvi.SubItems.Add(ExtraFunctions.UnitChange(drive.TotalSize));
                        lvfs.Items.Add(lvi);
                    }
                    else
                    {
                        ListViewItem lvi = new ListViewItem(string.Concat(drive.Name.Substring(0, 2), @"\"), smlist.Images.Count - 1);
                        lvi.SubItems.Add(""); //Dummy
                        //Der Typ wird anhand des DriveType angegeben. Bei Size kommt der maximale Speicherplatz
                        if (drive.DriveType == DriveType.Fixed)
                        {
                            lvi.SubItems.Add(DriveFunctions.DRIVE_VOLUMELABEL_STD_HDD);
                        }
                        else if (drive.DriveType == DriveType.CDRom)
                        {
                            lvi.SubItems.Add(DriveFunctions.DRIVE_VOLUMELABEL_STD_OPT);
                        }
                        else if (drive.DriveType == DriveType.Removable)
                        {
                            lvi.SubItems.Add(DriveFunctions.DRIVE_VOLUMELABEL_STD_EXT);
                        }
                        else if (drive.DriveType == DriveType.Network)
                        {
                            lvi.SubItems.Add(DriveFunctions.DRIVE_VOLUMELABEL_STD_NET);
                        }
                        else
                        {
                            lvi.SubItems.Add("Unbekannter Laufwerkstyp");
                        }
                        lvfs.Items.Add(lvi);
                    }
                }
            }
            else
            {
                DirectoryInfo dirinfo = new DirectoryInfo(_aktpfad);
                smlist.Images.Clear();
                smlist.Images.Add(FilesystemIcons.ICON_FILE_16x);

                //Zuerst kommen die Directories
                foreach (DirectoryInfo d in dirinfo.GetDirectories())
                {
                    try
                    {
                        smlist.Images.Add(FilesystemIcons.GetSmallIcon(d.FullName));
                    }
                    catch                                                      //Wenn das Icon über GetSmallIcon nicht genommen wird
                    {
                        smlist.Images.Add(FilesystemIcons.ICON_DIRECTORY_16x); //Ersatzicon
                    }
                    ListViewItem lvi = new ListViewItem(d.Name, smlist.Images.Count - 1);
                    lvi.SubItems.Add(d.LastWriteTime.ToString());
                    lvi.SubItems.Add(Extra.StringResource.GetStringResourceFromFile("@shell32.dll,-10152").ToString());
                    lvfs.Items.Add(lvi);
                }

                //Jetzt kommen die Files. Hier kann man denselben Code wie in ExplorerPlusFileView verwenden
                //Nun wird die Liste gefüllt
                foreach (FileInfo file in dirinfo.GetFiles())
                {
                    //Anhand der Erweiterung schauen, ob es eine Verknüpfung ist oder nicht
                    try
                    {
                        try
                        {
                            if (file.Extension == ".lnk")
                            {
                                smlist.Images.Add(FilesystemIcons.GetSmallIcon(FileFunctions.GetShortcutPath(file.FullName)));
                            }
                            else
                            {
                                smlist.Images.Add(FilesystemIcons.GetSmallIcon(file.FullName));
                            }
                        }
                        catch
                        {
                            smlist.Images.Add(FilesystemIcons.GetIconByExtension_x16(file.Extension));
                        }
                        ListViewItem lvi = new ListViewItem(file.Name, smlist.Images.Count - 1);
                        lvi.SubItems.Add(file.LastWriteTime.ToString());
                        lvi.SubItems.Add(FileFunctions.GetFileTypeDescription(file.Extension));

                        //Wenn die dateigröße unter 1024 Bytes ist, soll stattdessen 1 KB ausgegeben werden
                        if (file.Length < 1024)
                        {
                            lvi.SubItems.Add("1 KB");
                        }
                        else
                        {
                            lvi.SubItems.Add(ExtraFunctions.GetFileSizeKB(Convert.ToDouble(file.Length)));
                        }
                        lvfs.Items.Add(lvi);
                    }
                    catch (UnauthorizedAccessException)
                    { //Geht nicht, da kein Zugriff
                    }
                    catch
                    {
                        ListViewItem lvi = new ListViewItem(file.Name, 0);
                        lvi.SubItems.Add(file.LastWriteTime.ToString());
                        lvi.SubItems.Add(FileFunctions.GetFileTypeDescription(file.Extension));

                        //Wenn die dateigröße unter 1024 Bytes ist, soll stattdessen 1 KB ausgegeben werden
                        if (file.Length < 1024)
                        {
                            lvi.SubItems.Add("1 KB");
                        }
                        else
                        {
                            lvi.SubItems.Add(ExtraFunctions.GetFileSizeKB(Convert.ToDouble(file.Length)));
                        }
                        lvfs.Items.Add(lvi);
                    }
                }
            }
            cbrecentpaths.Text = _aktpfad;
        }