Exemple #1
0
 public Sizes isUserExisting(string sizes)
 {
     DataTable dt = new DataTable("Category");
     dt.Clear();
     string query = "SELECT * FROM Sizes where ProductSize='" + sizes + "'";
     dt = DataAccess.DBAdapter.GetRecordSet(query);
     Sizes log = null;
     if (dt.Rows.Count > 0)
     {
         log = new Sizes(dt.Rows[0]);
     }
     return log;
 }
Exemple #2
0
        public string insertSizes(Sizes cats)
        {
            string Message = string.Empty;
            int result = 0;
            con.Open();
            SqlCommand cmd = new SqlCommand("INSERT INTO [Sizes]([ProductSize]) VALUES (@ProductSize)", con);
            cmd.Parameters.AddWithValue("@ProductSize", cats.ProductSize);

            result = cmd.ExecuteNonQuery();

            con.Close();
            return Message;
        }
        internal void SerializeMetadataTables(BlobBuilder writer)
        {
            var sizes = new Sizes(_blobHeapSize, _guidWriter.Count);

            SerializeHeader(writer, sizes);

            // tables:
            SerializeDocumentTable(writer, sizes);
            SerializeMethodTable(writer, sizes);

            // heaps:
            writer.LinkSuffix(_guidWriter);
            WriteBlobHeap(writer);
        }
 public Popup Create(Sizes size, UIElement content = null)
 {
     var container = new ContentControl
     {
         HorizontalContentAlignment = HorizontalAlignment.Stretch,
         VerticalContentAlignment = VerticalAlignment.Stretch,
         Height = Window.Current.Bounds.Height,
         Width = Window.Current.Bounds.Width,
         Content = content,
     };
     var popup = new Popup
     {
         Child = container,
         HorizontalOffset = 0,
         VerticalOffset = 0,
     };
     WindowSizeChangedEventHandler handler = (s, e) =>
     {
         if (popup.IsOpen)
         {
             container.Height = e.Size.Height;
             container.Width = e.Size.Width;
         }
     };
     if (size == Sizes.FullScreen)
     {
         popup.RegisterPropertyChangedCallback(Popup.IsOpenProperty, (d, e) =>
         {
             if (popup.IsOpen)
             {
                 Window.Current.SizeChanged += handler;
             }
             else
             {
                 Window.Current.SizeChanged -= handler;
             }
         });
     }
     return popup;
 }
Exemple #5
0
 public Animal(ConsumptionType consumptionType, Sizes size)
 {
     ConsumptionType = consumptionType;
     Size            = size;
 }
Exemple #6
0
 public static float Height(Size size)
 {
     return(Sizes.BarHeight(size));
 }
        public Task MemorySmaps()
        {
            if (PlatformDetails.RunningOnLinux == false)
            {
                using (ServerStore.ContextPool.AllocateOperationContext(out JsonOperationContext context))
                    using (var process = Process.GetCurrentProcess())
                    {
                        var sharedClean = MemoryInformation.GetSharedCleanInBytes(process);
                        var rc          = Win32MemoryQueryMethods.GetMaps();
                        var djv         = new DynamicJsonValue
                        {
                            ["Totals"] = new DynamicJsonValue
                            {
                                ["WorkingSet"]          = process.WorkingSet64,
                                ["SharedClean"]         = Sizes.Humane(sharedClean),
                                ["PrivateClean"]        = "N/A",
                                ["TotalClean"]          = rc.ProcessClean,
                                ["RssHumanly"]          = Sizes.Humane(process.WorkingSet64),
                                ["SharedCleanHumanly"]  = Sizes.Humane(sharedClean),
                                ["PrivateCleanHumanly"] = "N/A",
                                ["TotalCleanHumanly"]   = Sizes.Humane(rc.ProcessClean)
                            },
                            ["Details"] = rc.Json
                        };
                        using (var write = new BlittableJsonTextWriter(context, ResponseBodyStream()))
                        {
                            context.Write(write, djv);
                        }
                        return(Task.CompletedTask);
                    }
            }

            using (ServerStore.ContextPool.AllocateOperationContext(out JsonOperationContext context))
            {
                var buffers = new[]
                {
                    ArrayPool <byte> .Shared.Rent(SmapsReader.BufferSize),
                    ArrayPool <byte> .Shared.Rent(SmapsReader.BufferSize)
                };
                try
                {
                    var result = new SmapsReader(buffers).CalculateMemUsageFromSmaps <SmapsReaderJsonResults>();
                    var djv    = new DynamicJsonValue
                    {
                        ["Totals"] = new DynamicJsonValue
                        {
                            ["WorkingSet"]          = result.Rss,
                            ["SharedClean"]         = result.SharedClean,
                            ["PrivateClean"]        = result.PrivateClean,
                            ["TotalClean"]          = result.SharedClean + result.PrivateClean,
                            ["TotalDirty"]          = result.TotalDirty, // This includes not only r-ws buffer and voron files, but also dotnet's and heap dirty memory
                            ["RssHumanly"]          = Sizes.Humane(result.Rss),
                            ["SharedCleanHumanly"]  = Sizes.Humane(result.SharedClean),
                            ["PrivateCleanHumanly"] = Sizes.Humane(result.PrivateClean),
                            ["TotalCleanHumanly"]   = Sizes.Humane(result.SharedClean + result.PrivateClean)
                        },
                        ["Details"] = result.SmapsResults.ReturnResults()
                    };

                    using (var write = new BlittableJsonTextWriter(context, ResponseBodyStream()))
                    {
                        context.Write(write, djv);
                    }

                    return(Task.CompletedTask);
                }
                finally
                {
                    ArrayPool <byte> .Shared.Return(buffers[0]);

                    ArrayPool <byte> .Shared.Return(buffers[1]);
                }
            }
        }
Exemple #8
0
        public static (long WorkingSet, long ProcessClean, DynamicJsonArray Json) GetMaps()
        {
            long processClean = 0;

            const uint uintMaxVal = uint.MaxValue;
            var        dja        = new DynamicJsonArray();

            GetSystemInfo(out var systemInfo);

            var procMinAddress = systemInfo.minimumApplicationAddress;
            var procMaxAddress = systemInfo.maximumApplicationAddress;
            var processHandle  = GetCurrentProcess();
            var results        = new Dictionary <string, (long Size, long Clean, long Dirty)>();

            while (procMinAddress.ToInt64() < procMaxAddress.ToInt64())
            {
                MEMORY_BASIC_INFORMATION memoryBasicInformation;
                VirtualQueryEx(processHandle, (byte *)procMinAddress.ToPointer(),
                               &memoryBasicInformation, new UIntPtr((uint)sizeof(MEMORY_BASIC_INFORMATION)));

                // if this memory chunk is accessible
                if (memoryBasicInformation.Protect == (uint)MemoryProtectionConstants.PAGE_READWRITE &&
                    memoryBasicInformation.State == (uint)MemoryStateConstants.MEM_COMMIT &&
                    memoryBasicInformation.Type == (uint)MemoryTypeConstants.MEM_MAPPED)
                {
                    var encodedString = GetEncodedFilename(processHandle, ref memoryBasicInformation);
                    if (encodedString != null)
                    {
                        var regionSize = memoryBasicInformation.RegionSize.ToInt64();
                        for (long size = uintMaxVal; size < regionSize + uintMaxVal; size += uintMaxVal)
                        {
                            var partLength = size > regionSize ? regionSize % uintMaxVal : uintMaxVal;

                            var totalDirty = AddressWillCauseHardPageFault((byte *)memoryBasicInformation.BaseAddress.ToPointer(), (uint)partLength,
                                                                           performCount: true);
                            var totalClean = partLength - totalDirty;

                            if (results.TryGetValue(encodedString, out var values))
                            {
                                var prevValClean = values.Clean + totalClean;
                                var prevValDirty = values.Dirty + totalDirty;
                                var prevValSize  = values.Size + partLength;
                                results[encodedString] = (prevValSize, prevValClean, prevValDirty);
                            }
                            else
                            {
                                results[encodedString] = (partLength, totalClean, totalDirty);
                            }

                            processClean += totalClean;
                        }
                    }
                }

                // move to the next memory chunk
                procMinAddress = new IntPtr(procMinAddress.ToInt64() + memoryBasicInformation.RegionSize.ToInt64());
            }

            foreach (var result in results)
            {
                var djv = new DynamicJsonValue
                {
                    ["File"]              = result.Key,
                    ["Size"]              = result.Value.Size,
                    ["SizeHumanly"]       = Sizes.Humane(result.Value.Size),
                    ["Rss"]               = "N/A",
                    ["SharedClean"]       = "N/A",
                    ["SharedDirty"]       = "N/A",
                    ["PrivateClean"]      = "N/A",
                    ["PrivateDirty"]      = "N/A",
                    ["TotalClean"]        = result.Value.Clean,
                    ["TotalCleanHumanly"] = Sizes.Humane(result.Value.Clean),
                    ["TotalDirty"]        = result.Value.Dirty,
                    ["TotalDirtyHumanly"] = Sizes.Humane(result.Value.Dirty)
                };

                dja.Add(djv);
            }

            using (var currentProcess = Process.GetCurrentProcess())
            {
                var workingSet = currentProcess.WorkingSet64;
                return(workingSet, processClean, dja);
            }
        }
Exemple #9
0
 public StandardSize(string name, Sizes sizes)
 {
     this.Name  = name;
     this.Sizes = sizes;
 }
		private void RadioButtonSizeCustomPercent_Checked(object sender, RoutedEventArgs e)
		{
			_sizeOption = Sizes.SizeCustomPercent;
			PercentDialog percentDialog = new PercentDialog();
			percentDialog.ValueSet += (snd, args) =>
			{
				_customPercent = args;
				Trace.WriteLine(_customPercent);
			};
			percentDialog.ShowDialog();
		}
 private void SerializeMethodTable(BlobBuilder writer, Sizes sizes)
 {
     foreach (var row in _methodTable)
     {
         writer.WriteReference(MetadataTokens.GetHeapOffset(row.Spans), isSmall: (sizes.BlobIndexSize == 2));
     }
 }
Exemple #12
0
 public FoodItem(string name, double price, Sizes portion)
 {
     Name    = name;
     Price   = price;
     Portion = portion;
 }
Exemple #13
0
        private void AddMattressObject()
        {
            if (!(txtOrderId.Text.Length > 0 & txtDateOfOrder.Text.Length > 0))
            {
                throw new Exception("Поля кода или даты заказа не должны быть пусты.");
            }
            //if (cmbTables.SelectedItem == null)
            //    throw new Exception("Не выбран стол сборки.");
            if (listBoxMattressList.SelectedItem == null)
            {
                throw new Exception("Не выбран матрас.");
            }
            string tableName = null;

            if (cmbTables.SelectedItem != null)
            {
                tableName = cmbTables.SelectedItem.ToString();
            }

            int numbers = 1;

            if (txtNumbers.Text.Length != 0)
            {
                numbers = Convert.ToInt32(txtNumbers.Text);
            }

            int lenght, width;

            if (!(cmbSizes.SelectedItem == null & (txtCustomLenght.Text.Length == 0 & txtCustomWidth.Text.Length == 0)))
            {
                if (cmbSizes.SelectedItem != null)
                {
                    Sizes tempSize = (Sizes)cmbSizes.SelectedItem;
                    lenght = tempSize.lenght;
                    width  = tempSize.width;
                }
                else
                {
                    if (txtCustomLenght.Text.Length != 0 & txtCustomWidth.Text.Length != 0)
                    {
                        lenght = Convert.ToInt32(txtCustomLenght.Text);
                        width  = Convert.ToInt32(txtCustomWidth.Text);
                    }
                    else
                    {
                        throw new Exception("Не указана длинна или ширина матраса.");
                    }
                }
            }
            else
            {
                throw new Exception("Отсутствуют данные о размере.");
            }

            if (globalTypesList == null)
            {
                globalTypesList = new List <MattressObjectV2>();
            }

            MattressObjectV2 tempMattressObject = new MattressObjectV2(txtOrderId.Text + " : " + txtDateOfOrder.Text, tableName, (Mattresses)listBoxMattressList.SelectedItem, lenght, width, numbers);

            if (globalTypesList.Contains(tempMattressObject))
            {
                numbers += globalTypesList.Find(mattress => mattress == tempMattressObject).Numbers;
                globalTypesList.Remove(tempMattressObject);
                listBoxTypesList.Items.Remove(tempMattressObject);
                tempMattressObject = new MattressObjectV2(txtOrderId.Text + " : " + txtDateOfOrder.Text, tableName, (Mattresses)listBoxMattressList.SelectedItem, lenght, width, numbers);
            }

            globalTypesList.Add(tempMattressObject);
            listBoxTypesList.Items.Add(tempMattressObject);

            txtNumbers.Clear();
        }
Exemple #14
0
        public (long Rss, long SharedClean, long PrivateClean, DynamicJsonArray Json) CalculateMemUsageFromSmaps()
        {
            var state = SearchState.None;
            var dja   = new DynamicJsonArray();

            using (var currentProcess = Process.GetCurrentProcess())
                using (var fileStream = new FileStream($"/proc/{currentProcess.Id}/smaps", FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    var    read = ReadFromFile(fileStream, _currentBuffer);
                    var    offsetForNextBuffer = 0;
                    long   tmpRss = 0, tmpSharedClean = 0, tmpPrivateClean = 0;
                    string resultString = null;
                    long   valSize = 0, valRss = 0, valPrivateDirty = 0, valSharedDirty = 0, valSharedClean = 0, valPrivateClean = 0;
                    while (true)
                    {
                        if (read == 0)
                        {
                            return(tmpRss, tmpSharedClean, tmpPrivateClean, dja);
                        }

                        var switchBuffer = false;
                        for (var i = offsetForNextBuffer; i < _endOfBuffer[_currentBuffer]; i++)
                        {
                            byte[] term;
                            var    offset = 0;
                            if (_smapsBuffer[_currentBuffer][i] == 'r')
                            {
                                term = _rwsBytes;
                            }
                            else if (_smapsBuffer[_currentBuffer][i] == 'R')
                            {
                                term = _rssBytes;
                            }
                            else if (_smapsBuffer[_currentBuffer][i] == 'S')
                            {
                                term   = _sizeBytes; // or SharedDirty or SharedCleanBytes (which ARE longer in length from Size)
                                offset = _sharedCleanBytes.Length - term.Length;
                            }
                            else if (_smapsBuffer[_currentBuffer][i] == 'P')
                            {
                                term = _privateCleanBytes; // or PrivateDirty (which is not longer in length from PrivateCleanBytes)
                            }
                            else if (_smapsBuffer[_currentBuffer][i] == 'L')
                            {
                                term = _lockedBytes;
                            }
                            else
                            {
                                continue;
                            }

                            // check if the current buffer too small for the search term and read next buff if so
                            if (switchBuffer == false && i + term.Length + offset > _endOfBuffer[_currentBuffer])
                            {
                                var nextBuffer = (_currentBuffer + 1) % 2;
                                read         = ReadFromFile(fileStream, nextBuffer);
                                switchBuffer = true;
                            }

                            var searchedBuffer   = _currentBuffer;
                            var positionToSearch = i;
                            var hasMatch         = true;
                            for (var j = 1; j < term.Length; j++)
                            {
                                positionToSearch++;
                                if (positionToSearch == _smapsBuffer[searchedBuffer].Length)
                                {
                                    // we assume max search term length doesn't exceed buffer length..
                                    searchedBuffer   = (searchedBuffer + 1) % 2;
                                    positionToSearch = 0;
                                    Debug.Assert(switchBuffer);
                                }

                                // for 'S' and 'P' we might have to search different term:
                                if (_smapsBuffer[searchedBuffer][positionToSearch] != term[j])
                                {
                                    if (term == _privateCleanBytes) // didn't find PrivateCleanBytes - try to find PrivateDiryBytes
                                    {
                                        term = _privateDirtyBytes;
                                        if (_smapsBuffer[searchedBuffer][positionToSearch] == term[j])
                                        {
                                            continue;
                                        }
                                    }

                                    if (term == _sizeBytes) // didn't find Size - try to find SharedCleanBytes
                                    {
                                        term = _sharedCleanBytes;
                                        if (_smapsBuffer[searchedBuffer][positionToSearch] == term[j])
                                        {
                                            continue;
                                        }
                                    }

                                    if (term == _sharedCleanBytes) // didn't find SharedCleanBytes - try to find SharedDirtyBytes
                                    {
                                        term = _sharedDirtyBytes;
                                        if (_smapsBuffer[searchedBuffer][positionToSearch] == term[j])
                                        {
                                            continue;
                                        }
                                    }

                                    hasMatch = false;
                                    break;
                                }
                            }

                            if (hasMatch == false)
                            {
                                continue;
                            }

                            // now read value.. search until reached letter 'B' (value ends with "kB")
                            var bytesSearched       = 0;
                            var posInTempBuf        = 0;
                            var valueSearchPosition = i + term.Length;
                            var foundValue          = false;
                            var foundK = false;

                            while (bytesSearched < _tempBufferBytes.Length) // just a bullpark figure, usually ~40 bytes are enough
                            {
                                if (valueSearchPosition == _smapsBuffer[searchedBuffer].Length)
                                {
                                    searchedBuffer      = (_currentBuffer + 1) % 2;
                                    valueSearchPosition = 0;

                                    if (switchBuffer == false)
                                    {
                                        var readFromNextBuffer = ReadFromFile(fileStream, searchedBuffer);
                                        if (readFromNextBuffer == 0)
                                        {
                                            // this should not happen, the file ended without a value
                                            break;
                                        }

                                        switchBuffer = true;
                                    }
                                }

                                var currentChar = _smapsBuffer[searchedBuffer][valueSearchPosition];

                                if (term == _rwsBytes) // value is filename which comes after last white-space and before '\n'
                                {
                                    // zero previous entries
                                    if (posInTempBuf == 0)
                                    {
                                        resultString    = null; // zero previous entries
                                        valSize         = 0;
                                        valRss          = 0;
                                        valPrivateDirty = 0;
                                        valSharedDirty  = 0;
                                        valSharedClean  = 0;
                                        valPrivateClean = 0;
                                    }

                                    if (currentChar == ' ' || currentChar == '\t')
                                    {
                                        posInTempBuf = 0;
                                    }
                                    else if (currentChar == '\n')
                                    {
                                        break;
                                    }
                                    else
                                    {
                                        _tempBufferBytes[posInTempBuf++] = currentChar;
                                    }
                                }
                                else
                                {
                                    if (currentChar >= '0' && currentChar <= '9')
                                    {
                                        _tempBufferBytes[posInTempBuf++] = currentChar;
                                    }

                                    if (currentChar == 'k')
                                    {
                                        foundK = true;
                                    }

                                    if (currentChar == 'B')
                                    {
                                        foundValue = true;
                                        break;
                                    }
                                }

                                ++valueSearchPosition;
                                ++bytesSearched;
                            }

                            if (term != _rwsBytes)
                            {
                                if (foundValue == false)
                                {
                                    ThrowNotContainsValidValue(term, currentProcess.Id);
                                }
                                if (foundK == false)
                                {
                                    ThrowNotContainsKbValue(term, currentProcess.Id);
                                }
                            }


                            i += term.Length + bytesSearched;
                            if (i >= _smapsBuffer[_currentBuffer].Length)
                            {
                                offsetForNextBuffer = _smapsBuffer[_currentBuffer].Length - i;
                            }
                            else
                            {
                                offsetForNextBuffer = 0;
                            }


                            long resultLong = 0;
                            if (term != _rwsBytes)
                            {
                                var multiplier = 1;
                                for (var j = posInTempBuf - 1; j >= 0; j--)
                                {
                                    resultLong += (_tempBufferBytes[j] - (byte)'0') * multiplier;
                                    multiplier *= 10;
                                }

                                resultLong *= 1024; // "kB"
                            }
                            else
                            {
                                resultString = posInTempBuf > 0 ? Encoding.UTF8.GetString(_tempBufferBytes, 0, posInTempBuf) : "";
                            }

                            if (term == _rwsBytes)
                            {
                                if (state != SearchState.None)
                                {
                                    ThrowNotRwsTermAfterLockedTerm(state, term, currentProcess.Id);
                                }
                                state = SearchState.Rws;
                            }
                            else if (term == _sizeBytes)
                            {
                                if (state != SearchState.Rws)
                                {
                                    continue; // found Rss but not after rw-s - irrelevant
                                }
                                state   = SearchState.Size;
                                valSize = resultLong;
                            }
                            else if (term == _rssBytes)
                            {
                                if (state != SearchState.Size)
                                {
                                    continue; // found Rss but not after rw-s - irrelevant
                                }
                                state   = SearchState.Rss;
                                tmpRss += resultLong;
                                valRss  = resultLong;
                            }
                            else if (term == _sharedCleanBytes)
                            {
                                if (state != SearchState.Rss)
                                {
                                    continue; // found Shared_Clean but not after Rss (which must come after rw-s) - irrelevant
                                }
                                state           = SearchState.SharedClean;
                                tmpSharedClean += resultLong;
                                valSharedClean  = resultLong;
                            }
                            else if (term == _sharedDirtyBytes)
                            {
                                if (state != SearchState.SharedClean)
                                {
                                    continue;
                                }
                                state          = SearchState.SharedDirty;
                                valSharedDirty = resultLong;
                            }
                            else if (term == _privateCleanBytes)
                            {
                                if (state != SearchState.SharedDirty)
                                {
                                    continue;
                                }
                                state            = SearchState.PrivateClean;
                                tmpPrivateClean += resultLong;
                                valPrivateClean  = resultLong;
                            }
                            else if (term == _privateDirtyBytes)
                            {
                                if (state != SearchState.PrivateClean)
                                {
                                    continue;
                                }
                                state           = SearchState.PrivateDirty;
                                valPrivateDirty = resultLong;
                            }
                            else if (term == _lockedBytes)
                            {
                                if (state != SearchState.PrivateDirty)
                                {
                                    continue;
                                }
                                state = SearchState.None;

                                if (resultString == null)
                                {
                                    ThrowOnNullString();
                                }

                                if (resultString.EndsWith(".voron") == false &&
                                    resultString.EndsWith(".buffers") == false)
                                {
                                    continue;
                                }

                                var djv = new DynamicJsonValue
                                {
                                    ["File"]              = resultString,
                                    ["Size"]              = Sizes.Humane(valSize),
                                    ["Rss"]               = Sizes.Humane(valRss),
                                    ["SharedClean"]       = Sizes.Humane(valSharedClean),
                                    ["SharedDirty"]       = Sizes.Humane(valSharedDirty),
                                    ["PrivateClean"]      = Sizes.Humane(valPrivateClean),
                                    ["PrivateDirty"]      = Sizes.Humane(valPrivateDirty),
                                    ["TotalClean"]        = valSharedClean + valPrivateClean,
                                    ["TotalCleanHumanly"] = Sizes.Humane(valSharedClean + valPrivateClean),
                                    ["TotalDirty"]        = valSharedDirty + valPrivateDirty,
                                    ["TotalDirtyHumanly"] = Sizes.Humane(valSharedDirty + valPrivateDirty)
                                };
                                dja.Add(djv);
                            }
                            else
                            {
                                throw new InvalidOperationException($"Reached unknown unhandled term: '{Encoding.UTF8.GetString(term)}'");
                            }
                        }


                        _currentBuffer = (_currentBuffer + 1) % 2;
                        if (switchBuffer == false)
                        {
                            read = ReadFromFile(fileStream, _currentBuffer);
                            if (read == 0)
                            {
                                break;
                            }
                        }
                    }

                    return(tmpRss, tmpSharedClean, tmpPrivateClean, dja);
                }
        }
Exemple #15
0
 public Airport(string name, string countryCode, Sizes size)
 {
     this.Name        = name;
     this.CountryCode = countryCode;
     this.size        = size;
 }
Exemple #16
0
 protected override void SetSize(Sizes size)
 {
     _mainPage.SetSize(size);
 }
Exemple #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Asteroid"/> class.
 /// This is the class where we can pass in values to create an asteroid.
 /// </summary>
 /// <param name="asteroidManager">The asteroid manager.</param>
 /// <param name="player">The player.</param>
 /// <param name="newSize">The new size.</param>
 public Asteroid(GameManager asteroidManager, Player player, Sizes newSize)
 {
     this.asteroidManager = asteroidManager;
     this.player = player;
     this.Size = newSize;
 }
Exemple #18
0
 public Clothing(Item item, Sizes size) : base(item.Name, item.Price)
 {
     Size = size;
 }
Exemple #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EnemyShip"/> class.
 /// </summary>
 /// <param name="entityManager">The entity manager.</param>
 /// <param name="position">The ship position.</param>
 /// <param name="speed">The ship speed.</param>
 /// <param name="size">The ship size.</param>
 /// <param name="player">The player.</param>
 public EnemyShip(EntityManager entityManager, Vector2 position, Vector2 speed, Sizes size, Player player)
 {
     this.entityManager = entityManager;
     random = new Random();
     Position = position;
     this.Size = size;
     this.speed = speed;
     this.player = player;
 }
 private void SerializeDocumentTable(BlobBuilder writer, Sizes sizes)
 {
     foreach (var row in _documentTable)
     {
         writer.WriteReference(MetadataTokens.GetHeapOffset(row.Name), isSmall: (sizes.BlobIndexSize == 2));
         writer.WriteReference(MetadataTokens.GetHeapOffset(row.HashAlgorithm), isSmall: (sizes.GuidIndexSize == 2));
         writer.WriteReference(MetadataTokens.GetHeapOffset(row.Hash), isSmall: (sizes.BlobIndexSize == 2));
     }
 }
Exemple #21
0
        public void EditObj()
        {
            string orderForCreating;

            if (!(cmbOrders.SelectedItem == null & (txtOrderId.Text.Length == 0 & txtDateOfOrder.Text.Length == 0)))
            {
                if (cmbOrders.SelectedItem != null)
                {
                    orderForCreating = (string)cmbOrders.SelectedItem;
                }
                else
                {
                    if (txtOrderId.Text.Length != 0 & txtDateOfOrder.Text.Length != 0)
                    {
                        orderForCreating = txtOrderId.Text + " : " + txtDateOfOrder.Text;
                    }
                    else
                    {
                        throw new Exception("Поля кода или даты заказа не должны быть пусты.");
                    }
                }
            }
            else
            {
                orderForCreating = mtrObj.OrderInfo;
            }

            string tableNameForCreating;

            if (cmbTables.SelectedItem != null)
            {
                tableNameForCreating = cmbTables.SelectedItem.ToString();
            }
            else
            {
                tableNameForCreating = mtrObj.TableName;
            }

            int lenghtForCreating, widthForCreating;

            if (!(cmbSizes.SelectedItem == null & (txtCustomLenght.Text.Length == 0 & txtCustomWidth.Text.Length == 0)))
            {
                if (cmbSizes.SelectedItem != null)
                {
                    Sizes tempSize = (Sizes)cmbSizes.SelectedItem;
                    lenghtForCreating = tempSize.lenght;
                    widthForCreating  = tempSize.width;
                }
                else
                {
                    if (txtCustomLenght.Text.Length != 0 & txtCustomWidth.Text.Length != 0)
                    {
                        lenghtForCreating = Convert.ToInt32(txtCustomLenght.Text);
                        widthForCreating  = Convert.ToInt32(txtCustomWidth.Text);
                    }
                    else
                    {
                        throw new Exception("Не указана длинна или ширина матраса.");
                    }
                }
            }
            else
            {
                lenghtForCreating = mtrObj.GetLenght();
                widthForCreating  = mtrObj.GetWidth();
            }

            int numbersForCreating;

            if (txtNumbers.Text.Length != 0)
            {
                numbersForCreating = Convert.ToInt32(txtNumbers.Text);
            }
            else
            {
                numbersForCreating = mtrObj.Numbers;
            }

            mainWindow.RemoveGlobalTypesListObject(mtrObj);
            mainWindow.AddObjectInGlobalTypesList(new MattressObjectV2(orderForCreating, tableNameForCreating, mtrObj.Mattresses, lenghtForCreating, widthForCreating, numbersForCreating));
        }
 public void SetSize(Sizes size)
 {
     Map.Sizes.SelectByIndex((int)size);
 }
Exemple #23
0
        private void cmbpbx_tyre_size_SelectedIndexChanged(object sender, EventArgs e)
        {
            lbl_diameter.Text = "Circumference = " + Sizes.bicycle(cmbpbx_tyre_size.Text) + "mm";

            PopulateData(false);
        }
Exemple #24
0
 static public void GenerateMap(ref AreaMap current_map, ref List <string> currMapTexNames, MapSets map_set, Sizes map_size,
                                ref List <int> dcRoomList)
 {
     areaMapType = new AreaMapType();
     LoadMapSet(map_set, ref areaMapType);
     MapGenHelper.MakeMap(ref current_map, ref areaMapType, ref currMapTexNames, map_size);
     MapGenHelper.GetMapData(ref dcRoomList);
 }
Exemple #25
0
 public Pricing(Companies company, Sizes size, decimal price)
 {
     Company = company;
     Size    = size;
     Price   = price;
 }
Exemple #26
0
 public override string ToString()
 {
     return($"Allocated {Sizes.Humane(Allocated)}, Used {Sizes.Humane(_used)}");
 }
Exemple #27
0
 /// <summary>
 /// Determines whether or not the given length of bytes is valid for a mystery gift.
 /// </summary>
 /// <param name="len">Length, in bytes, of the data of which to determine validity.</param>
 /// <returns>A boolean indicating whether or not the given length is valid for a mystery gift.</returns>
 public static bool IsMysteryGift(long len) => Sizes.Contains((int)len);
Exemple #28
0
 public Animal(Diets diet, Sizes size)
 {
     Diet = diet;
     Size = size;
 }
Exemple #29
0
 public void GetAspectRatioTest(Rectangle input, AspectRatio output)
 {
     Assert.AreEqual(output, Sizes.GetAspectRatio(input));
 }
        public static void SetFileLength(SafeFileHandle fileHandle, long length)
        {
            if (SetFilePointerEx(fileHandle, length, IntPtr.Zero, Win32NativeFileMoveMethod.Begin) == false)
            {
                var exception = new Win32Exception(Marshal.GetLastWin32Error());
                var filePath  = GetFilePath();

                throw new IOException($"Could not move the pointer of file {filePath}", exception);
            }

            if (SetEndOfFile(fileHandle) == false)
            {
                var lastError = Marshal.GetLastWin32Error();
                var filePath  = GetFilePath();

                if (lastError == (int)Win32NativeFileErrors.ERROR_DISK_FULL)
                {
                    var driveInfo = DiskSpaceChecker.GetDiskSpaceInfo(filePath);
                    throw new DiskFullException(filePath, length, driveInfo?.TotalFreeSpace.GetValue(SizeUnit.Bytes));
                }

                var exception = new Win32Exception(lastError);

                if (lastError == (int)Win32NativeFileErrors.ERROR_NOT_READY ||
                    lastError == (int)Win32NativeFileErrors.ERROR_FILE_NOT_FOUND)
                {
                    throw new IOException($"Could not set the size of file {filePath} because it is inaccessible.", exception);
                }

                throw new IOException($"Could not set the size of file {filePath} to {Sizes.Humane(length)}", exception);
            }

            string GetFilePath()
            {
                try
                {
                    return(DiskSpaceChecker.GetWindowsRealPathByHandle(fileHandle.DangerousGetHandle()));
                }
                catch
                {
                    return(null);
                }
            }
        }
Exemple #31
0
 public TextDrawingObject()
 {
     Size = Sizes.Medium;
 }
 public void Initialize()
 {
     _selectedSize = Sizes.First();
     _sizeLimit    = _selectedSize.MaxValue;
 }
 public BingMainPage SetSize(Sizes size)
 {
     this.Map.Sizes.SelectByIndex((int)size);
     return(this);
 }
Exemple #34
0
        /// <summary>
        /// Create asteroid explosion after an asteroid has been killed
        /// </summary>
        /// <param name="size"></param>
        /// <param name="position"></param>
        /// <param name="content"></param>
        /// <param name="graphicsDevice"></param>
        /// <returns></returns>
        private Explosion CreateExplosion(Sizes size, Vector2 position, ContentManager content, GraphicsDevice graphicsDevice)
        {
            Func<Sizes, String> fun = (explosionSize) =>
            {
                switch (explosionSize)
                {
                    case Sizes.Small:
                        return "asteroidSmall";
                    case Sizes.Medium:
                        return "asteroidMedium";
                    case Sizes.Large:
                        return "asteroidLarge";
                    default:
                        return "asteroidLarge";
                }
            };

            var texture = fun(size) + "_Animated_Trans1";
            var explosion = new Explosion(entityManager, texture);
            explosion.Initialize(content, graphicsDevice);
            explosion.Position = new Vector2(position.X, position.Y);

            return explosion;
        }
Exemple #35
0
 public static Binary From(long value, Sizes size = Binary.Sizes.Undefined)
 {
     return(new Binary(value, size));
 }
 public Picture getPicture(int id, Sizes size)
 {
     var pic =  _db.Pictures.SingleOrDefault(p => p.Id == id);
     if(pic == null)
     {
         return null;
     }
     else
     {
         CloudBlockBlob blockBlob = _container.GetBlockBlobReference(Enum.GetName(typeof(Sizes), size) + "/" + pic.Url);
         
         return new Picture
         {
             id = pic.Id,
             description = pic.Description,
             url = blockBlob.Uri.AbsoluteUri
         };
     }
 }
Exemple #37
0
    // Set names, sizes and radius on AWAKE
    private void SetSize(GameObject a, Sizes s)
    {
        switch(s){
        case Sizes.big:
            a.transform.localScale = bigSize;
            a.name = "BigAsteroid";
            a.audio.clip = bigSFX;
            a.audio.playOnAwake = false;
            break;

        case Sizes.medium:
            a.transform.localScale = medSize;
            a.name = "MediumAsteroid";
            a.audio.clip = medSFX;
            a.audio.playOnAwake = false;
            break;

        case Sizes.small:
            a.transform.localScale = smallSize;
            a.name = "SmallAsteroid";
            a.audio.clip = smallSFX;
            a.audio.playOnAwake = false;
            break;
        }
    }
        private void SerializeHeader(BlobBuilder writer, Sizes sizes)
        {
            // signature:
            writer.WriteByte((byte)'D');
            writer.WriteByte((byte)'A');
            writer.WriteByte((byte)'M');
            writer.WriteByte((byte)'D');

            // version: 0.2
            writer.WriteByte(0);
            writer.WriteByte(2);

            // table sizes:
            writer.WriteInt32(_documentTable.Count);
            writer.WriteInt32(_methodTable.Count);

            // blob heap sizes:
            writer.WriteInt32(sizes.GuidHeapSize);
            writer.WriteInt32(sizes.BlobHeapSize);
        }
		private void RadioButtonSizeCustomSize_Checked(object sender, RoutedEventArgs e)
		{
			_sizeOption = Sizes.SizeCustomPixels;
			CustomSizeDialog sizeDialog = new CustomSizeDialog();
			sizeDialog.ValuesSet += (snd, args) =>
			{
				_customSize = args;
				Trace.WriteLine(_customSize);
			};
			sizeDialog.ShowDialog();
		}
Exemple #40
0
 public static Binary From(int value, Sizes size = Binary.Sizes.Undefined)
 {
     return(Binary.From(System.Convert.ToString((uint)(Math.Abs(value))), size));
 }
        public void Apply(IUnitOfWork db,
                          IQuantityManager quantityManager,
                          ILogService log,
                          ICacheService cache,
                          ISystemActionService actionService,
                          DateTime when,
                          long?by)
        {
            log.Info("AddSealedBoxWizardViewModel.Apply, StyleId=" + StyleId);

            if (IncomeType == (int)BoxIncomePackType.PPK)
            {
                var box = new SealedBoxViewModel();
                box.StyleId     = StyleId;
                box.BoxBarcode  = BoxBarcode;
                box.BoxQuantity = BoxQuantity;
                box.Price       = Price ?? 0;

                box.Owned    = Owned;
                box.PolyBags = false;
                box.Printed  = Printed;

                box.CreateDate = CreateDate.HasValue ? DateHelper.ConvertUtcToApp(CreateDate.Value.ToUniversalTime()) : when;

                box.StyleItems = new StyleItemCollection()
                {
                    Items = Sizes.Select(s => new StyleItemViewModel()
                    {
                        Id        = s.Id,
                        Breakdown = s.Breakdown,
                    }).ToList()
                };

                box.Apply(db, quantityManager, when, by);
            }

            if (IncomeType == (int)BoxIncomePackType.PolyBagged)
            {
                foreach (var size in Sizes.Where(si => si.Quantity > 0))
                {
                    var box = new SealedBoxViewModel();
                    box.StyleId     = StyleId;
                    box.BoxBarcode  = BoxBarcode;
                    box.BoxQuantity = size.Quantity ?? 0;
                    box.Price       = Price ?? 0;

                    box.Owned    = Owned;
                    box.PolyBags = true;
                    box.Printed  = Printed;

                    box.CreateDate = CreateDate.HasValue ? DateHelper.ConvertUtcToApp(CreateDate.Value.ToUniversalTime()) : when;

                    box.StyleItems = new StyleItemCollection()
                    {
                        Items = new List <StyleItemViewModel>()
                        {
                            new StyleItemViewModel()
                            {
                                Id        = size.Id,
                                Breakdown = UnitsPerBox
                            }
                        }
                    };

                    box.Apply(db, quantityManager, when, by);
                }
            }

            if (IncomeType == (int)BoxIncomePackType.Other)
            {
                var box = new OpenBoxViewModel();
                box.StyleId     = StyleId;
                box.BoxBarcode  = BoxBarcode;
                box.BoxQuantity = 1;
                box.Price       = Price ?? 0;

                box.Owned    = Owned;
                box.PolyBags = false;
                box.Printed  = Printed;

                box.CreateDate = CreateDate.HasValue ? DateHelper.ConvertUtcToApp(CreateDate.Value.ToUniversalTime()) : when;

                box.StyleItems = new StyleItemCollection()
                {
                    Items = Sizes.Select(s => new StyleItemViewModel()
                    {
                        Id       = s.Id,
                        Quantity = s.Quantity,
                    }).ToList()
                };

                box.Apply(db, quantityManager, when, by);
            }

            foreach (var size in Sizes)
            {
                var styleItem = db.StyleItems.Get(size.Id);
                if (size.UseBoxQuantity &&
                    styleItem.Quantity.HasValue)
                {
                    log.Info("Switch to box quantity, styleItemId=" + size.Id);

                    var oldQuantity = styleItem.Quantity;

                    styleItem.Quantity        = null;
                    styleItem.QuantitySetBy   = null;
                    styleItem.QuantitySetDate = null;
                    styleItem.RestockDate     = null;

                    db.Commit();

                    quantityManager.LogStyleItemQuantity(db,
                                                         styleItem.Id,
                                                         null,
                                                         oldQuantity,
                                                         QuantityChangeSourceType.UseBoxQuantity,
                                                         null,
                                                         null,
                                                         BoxBarcode,
                                                         when,
                                                         by);
                }
            }

            cache.RequestStyleIdUpdates(db,
                                        new List <long>()
            {
                StyleId
            },
                                        UpdateCacheMode.IncludeChild,
                                        by);

            SystemActionHelper.RequestQuantityDistribution(db, actionService, StyleId, by);
        }
 public Popup Show(Sizes size, UIElement content = null)
 {
     var popup = Create(size, content);
     popup.IsOpen = true;
     return popup;
 }
Exemple #43
0
 private static Binary AdjustSize(long value, Sizes size)
 {
     return(new Binary(value & Mask(size), size));
 }
Exemple #44
0
 private static long Mask(Sizes size)
 {
     //return (Math.Pow(2, size)) - 1;
     return((long)Math.Round(Math.Pow(2.0, (double)size) - 1.0));
 }
Exemple #45
0
 public Binary()
 {
     Size = Sizes.Word;
 }
 private static string GetQualifier(Sizes size)
 {
     switch (size)
     {
         case Sizes.Kilo:
             return "Kb";
         case Sizes.Mega:
             return "Mb";
         case Sizes.Giga:
             return "Gb";
         case Sizes.Byte:
             return "b";
     }
     return "";
 }
		private void RadioButtonSize75_Checked(object sender, RoutedEventArgs e)
		{
			_sizeOption = Sizes.Size75;
		}