private void Test() { ControlSettings s = ControlSettings.Constructor(); for (byte i = 0; i < 32; i++) { s.TimeIntervals[i].Active = true; s.TimeIntervals[i].From.Hour = i; s.TimeIntervals[i].From.Minute = i; s.TimeIntervals[i].To.Hour = i; s.TimeIntervals[i].To.Minute = i; } communicator.SendCommandData("setsettings", s.ToByteArray()); var r = communicator.SendCommand("getsettings"); ControlSettings s2 = ControlSettings.FromByteArray(r); string str = ""; for (byte i = 0; i < 32; i++) { str += s2.TimeIntervals[i].From.Hour + "\n"; str += s2.TimeIntervals[i].From.Minute + "\n"; str += s2.TimeIntervals[i].To.Hour + "\n"; str += s2.TimeIntervals[i].To.Minute + "\n"; } Debug.WriteLine(str); Debug.Assert(s.Mode == s2.Mode); Debug.Assert(Enumerable.SequenceEqual(s.TimeIntervals, s2.TimeIntervals)); Debug.WriteLine(s2.TimeIntervals[5].To.Hour); }
internal void AddRecylableRow(DataGridRow row) { DiagnosticsDebug.Assert(!_recyclableRows.Contains(row), "Expected row parameter to be non-recyclable."); row.DetachFromDataGrid(true); _recyclableRows.Push(row); }
// Create a TypeSystem.MethodSignature object from a RuntimeSignature that isn't a NativeLayoutSignature private TypeSystem.MethodSignature TypeSystemSigFromRuntimeSignature(TypeSystemContext context, RuntimeSignature signature) { Debug.Assert(!signature.IsNativeLayoutSignature); ModuleInfo module = signature.GetModuleInfo(); #if ECMA_METADATA_SUPPORT if (module is NativeFormatModuleInfo) #endif { NativeFormatModuleInfo nativeFormatModule = (NativeFormatModuleInfo)module; var metadataReader = nativeFormatModule.MetadataReader; var methodHandle = signature.Token.AsHandle().ToMethodHandle(metadataReader); var metadataUnit = ((TypeLoaderTypeSystemContext)context).ResolveMetadataUnit(nativeFormatModule); var parser = new Internal.TypeSystem.NativeFormat.NativeFormatSignatureParser(metadataUnit, metadataReader.GetMethod(methodHandle).Signature, metadataReader); return(parser.ParseMethodSignature()); } #if ECMA_METADATA_SUPPORT else { EcmaModuleInfo ecmaModuleInfo = (EcmaModuleInfo)module; TypeSystem.Ecma.EcmaModule ecmaModule = context.ResolveEcmaModule(ecmaModuleInfo); var ecmaHandle = System.Reflection.Metadata.Ecma335.MetadataTokens.EntityHandle(signature.Token); MethodDesc ecmaMethod = ecmaModule.GetMethod(ecmaHandle); return(ecmaMethod.Signature); } #endif }
internal UIElement GetDisplayedElement(int slot) { DiagnosticsDebug.Assert(slot >= this.FirstScrollingSlot, "Expected slot greater than or equal to FirstScrollingSlot."); DiagnosticsDebug.Assert(slot <= this.LastScrollingSlot, "Expected slot less than or equal to LastScrollingSlot."); return(_scrollingElements[GetCircularListIndex(slot, true /*wrap*/)]); }
public override bool ApplyChanges() { object editableObject = GetEditableObject(); Debug.Assert(editableObject != null); if (editableObject == null) { return(true); } EnsureChildControls(); int count = Controls.Count; Debug.Assert(count > 0); if (count == 0) { return(true); } PropertyDescriptorCollection properties = GetEditableProperties(editableObject, true); for (int i = 0; i < properties.Count; i++) { PropertyDescriptor pd = properties[i]; Control editorControl = (Control)EditorControls[i]; try { object value = GetEditorControlValue(editorControl, pd); // If the property is a url, validate protocol (VSWhidbey 290418) if (pd.Attributes.Matches(urlPropertyAttribute) && CrossSiteScriptingValidation.IsDangerousUrl(value.ToString())) { _errorMessages[i] = SR.GetString(SR.EditorPart_ErrorBadUrl); } else { try { pd.SetValue(editableObject, value); } catch (Exception e) { _errorMessages[i] = CreateErrorMessage(e.Message); } } } catch { // If custom errors are enabled, we do not want to render the property type to the browser. // (VSWhidbey 381646) if (Context != null && Context.IsCustomErrorEnabled) { _errorMessages[i] = SR.GetString(SR.EditorPart_ErrorConvertingProperty); } else { _errorMessages[i] = SR.GetString(SR.EditorPart_ErrorConvertingPropertyWithType, pd.PropertyType.FullName); } } } return(!HasError); }
// Stops tracking the element at the given slot as a scrolling element internal void UnloadScrollingElement(int slot, bool updateSlotInformation, bool wasDeleted) { DiagnosticsDebug.Assert(_owner.IsSlotVisible(slot), "Expected slot is visible."); int elementIndex = GetCircularListIndex(slot, false /*wrap*/); if (elementIndex > _scrollingElements.Count) { // We need to wrap around from the top to the bottom of our circular list elementIndex -= _scrollingElements.Count; _headScrollingElements--; } _scrollingElements.RemoveAt(elementIndex); if (updateSlotInformation) { if (slot == this.FirstScrollingSlot && !wasDeleted) { this.FirstScrollingSlot = _owner.GetNextVisibleSlot(this.FirstScrollingSlot); } else { this.LastScrollingSlot = _owner.GetPreviousVisibleSlot(this.LastScrollingSlot); } if (this.LastScrollingSlot < this.FirstScrollingSlot) { ResetSlotIndexes(); } } }
private void Control_Disposed(object sender, EventArgs e) { Debug.Assert(sender == control); canRender = false; control.Disposed -= Control_Disposed; }
public void AddSort(IQuery evalQuery, IComparer comparer) { Debug.Assert(this.expressions.Length == this.comparers.Length); Debug.Assert(0 < this.expressions.Length); Debug.Assert(0 <= numSorts && numSorts <= this.expressions.Length); // Ajust array sizes if needed. if (numSorts == this.expressions.Length) { IQuery[] newExpressions = new IQuery[numSorts * 2]; IComparer[] newComparers = new IComparer[numSorts * 2]; for (int i = 0; i < numSorts; i++) { newExpressions[i] = this.expressions[i]; newComparers [i] = this.comparers[i]; } this.expressions = newExpressions; this.comparers = newComparers; } Debug.Assert(numSorts < this.expressions.Length); // Fixup expression to handle node-set resurn type: XPathResultType queryType = evalQuery.ReturnType(); if (queryType == XPathResultType.NodeSet || queryType == XPathResultType.Error || queryType == XPathResultType.Any) { ArrayList argList = new ArrayList(); argList.Add(evalQuery); evalQuery = new StringFunctions(argList, FT.FuncString); } this.expressions[numSorts] = evalQuery; this.comparers[numSorts] = comparer; numSorts++; }
private void AutomationThread() { try { AutomatedUninstallManager.UninstallNsisQuietly(UninstallTarget, AutomatizeStatusCallback); OnStatusUpdate(new UninstallHandlerUpdateArgs(UninstallHandlerUpdateKind.Succeeded, Localization.Message_Success)); } catch (AutomatedUninstallManager.AutomatedUninstallException ex) { Debug.Assert(ex.InnerException != null, "ex.InnerException != null"); OnStatusUpdate(new UninstallHandlerUpdateArgs(UninstallHandlerUpdateKind.Failed, string.Format(Localization.Message_UninstallFailed, ex.InnerException?.Message ?? ex.Message))); // todo grace period / move to window? if (ex.UninstallerProcess != null && KillOnFail) { try { ex.UninstallerProcess.Kill(true); } catch { // Ignore process errors, can't do anything about it } } Program.ReturnValue = ReturnValue.FunctionFailedCode; } }
public void Remove(object dataItem) { if (this.OwningGrid.SelectionMode == DataGridSelectionMode.Single) { throw DataGridError.DataGridSelectedItemsCollection.CannotChangeSelectedItemsCollectionInSingleMode(); } int itemIndex = this.OwningGrid.DataConnection.IndexOf(dataItem); if (itemIndex == -1) { return; } DiagnosticsDebug.Assert(itemIndex >= 0, "Expected positive itemIndex."); if (itemIndex == this.OwningGrid.CurrentSlot && !this.OwningGrid.CommitEdit(DataGridEditingUnit.Row, true /*exitEditing*/)) { // Edited value couldn't be committed or aborted return; } this.OwningGrid.SetRowSelection(itemIndex, false /*isSelected*/, false /*setAnchorSlot*/); }
public void RemoveAt(int index) { if (this.OwningGrid.SelectionMode == DataGridSelectionMode.Single) { throw DataGridError.DataGridSelectedItemsCollection.CannotChangeSelectedItemsCollectionInSingleMode(); } if (index < 0 || index >= _selectedSlotsTable.IndexCount) { throw DataGridError.DataGrid.ValueMustBeBetween("index", "Index", 0, true, _selectedSlotsTable.IndexCount, false); } int rowIndex = _selectedSlotsTable.GetNthIndex(index); DiagnosticsDebug.Assert(rowIndex > -1, "Expected positive itemIndex."); if (rowIndex == this.OwningGrid.CurrentSlot && !this.OwningGrid.CommitEdit(DataGridEditingUnit.Row, true /*exitEditing*/)) { // Edited value couldn't be committed or aborted return; } this.OwningGrid.SetRowSelection(rowIndex, false /*isSelected*/, false /*setAnchorSlot*/); }
protected internal override void RenderContents(HtmlTextWriter writer) { if (Page != null) { Page.VerifyRenderingInServerForm(this); } // HACK: Need this for child controls to be created at design-time when control is inside template EnsureChildControls(); string[] propertyDisplayNames = null; string[] propertyDescriptions = null; object editableObject = GetEditableObject(); if (editableObject != null) { PropertyDescriptorCollection propDescs = GetEditableProperties(editableObject, true); propertyDisplayNames = new string[propDescs.Count]; propertyDescriptions = new string[propDescs.Count]; for (int i = 0; i < propDescs.Count; i++) { propertyDisplayNames[i] = GetDisplayName(propDescs[i]); propertyDescriptions[i] = GetDescription(propDescs[i]); } } if (propertyDisplayNames != null) { WebControl[] editorControls = (WebControl[])EditorControls.ToArray(typeof(WebControl)); Debug.Assert(propertyDisplayNames.Length == editorControls.Length && propertyDisplayNames.Length == _errorMessages.Length); RenderPropertyEditors(writer, propertyDisplayNames, propertyDescriptions, editorControls, _errorMessages); } }
// Tracks the row at index rowIndex as a scrolling row internal void LoadScrollingSlot(int slot, UIElement element, bool updateSlotInformation) { if (_scrollingElements.Count == 0) { SetScrollingSlots(slot); _scrollingElements.Add(element); } else { // The slot should be adjacent to the other slots being displayed DiagnosticsDebug.Assert(slot >= _owner.GetPreviousVisibleSlot(this.FirstScrollingSlot), "Expected slot greater than or equal to _owner.GetPreviousVisibleSlot(this.FirstScrollingSlot)."); DiagnosticsDebug.Assert(slot <= _owner.GetNextVisibleSlot(this.LastScrollingSlot), "Expected slot smaller than or equal to _owner.GetNextVisibleSlot(this.LastScrollingSlot)."); if (updateSlotInformation) { if (slot < this.FirstScrollingSlot) { this.FirstScrollingSlot = slot; } else { this.LastScrollingSlot = _owner.GetNextVisibleSlot(this.LastScrollingSlot); } } int insertIndex = GetCircularListIndex(slot, false /*wrap*/); if (insertIndex > _scrollingElements.Count) { // We need to wrap around from the bottom to the top of our circular list; as a result the head of the list moves forward insertIndex -= _scrollingElements.Count; _headScrollingElements++; } _scrollingElements.Insert(insertIndex, element); } }
protected override async Task Process() { Debug.Assert(_BlocksCollection != null); if (_BlocksCollection.IsUniform && (_BlocksCollection.Value == BlockController.AirID)) { return; } _RuntimeStopwatch.Restart(); PrepareMeshing(); _RuntimeStopwatch.Stop(); _PreMeshingTimeSpan = _RuntimeStopwatch.Elapsed; _RuntimeStopwatch.Restart(); if (_AggressiveFaceMerging) { GenerateTraversalMesh(); } else { await BatchTasksAndAwaitAll().ConfigureAwait(false); } FinishMeshing(); _RuntimeStopwatch.Stop(); _MeshingTimeSpan = _RuntimeStopwatch.Elapsed; }
IRawElementProviderSimple IGridProvider.GetItem(int row, int column) { if (this.OwningDataGrid != null && this.OwningDataGrid.DataConnection != null && row >= 0 && row < this.OwningDataGrid.SlotCount && column >= 0 && column < this.OwningDataGrid.Columns.Count) { object item = null; if (!this.OwningDataGrid.IsSlotVisible(this.OwningDataGrid.SlotFromRowIndex(row))) { item = this.OwningDataGrid.DataConnection.GetDataItem(row); } this.OwningDataGrid.ScrollIntoView(item, this.OwningDataGrid.Columns[column]); DataGridRow dgr = this.OwningDataGrid.DisplayData.GetDisplayedRow(row); if (this.OwningDataGrid.ColumnsInternal.RowGroupSpacerColumn.IsRepresented) { column++; } DiagnosticsDebug.Assert(column >= 0, "Expected positive column value."); DiagnosticsDebug.Assert(column < this.OwningDataGrid.ColumnsItemsInternal.Count, "Expected smaller column value."); DataGridCell cell = dgr.Cells[column]; AutomationPeer peer = CreatePeerForElement(cell); if (peer != null) { return(ProviderFromPeer(peer)); } } return(null); }
/// <summary> /// Generates the mesh data. /// </summary> /// <remarks> /// The generated data is stored in the <see cref="MeshData" /> object <see cref="_MeshData" />. /// </remarks> private void GenerateTraversalMesh() { Debug.Assert(_MeshingBlocks.Length == GenerationConstants.CHUNK_SIZE_CUBED, $"{_MeshingBlocks} should be the same length as chunk data."); int index = 0; for (int y = 0; y < GenerationConstants.CHUNK_SIZE; y++) { for (int z = 0; z < GenerationConstants.CHUNK_SIZE; z++) { for (int x = 0; x < GenerationConstants.CHUNK_SIZE; x++, index++) { if (_CancellationToken.IsCancellationRequested) { return; } ushort currentBlockId = _MeshingBlocks[index].ID; if (currentBlockId == BlockController.AirID) { continue; } int localPosition = x | (y << GenerationConstants.CHUNK_SIZE_BIT_SHIFT) | (z << (GenerationConstants.CHUNK_SIZE_BIT_SHIFT * 2)); TraverseIndex(index, localPosition, currentBlockId, BlockController.Current.CheckBlockHasProperty(currentBlockId, BlockDefinition.Property.Transparent)); } } } }
// Makes important categories accessible directly through a property in the WorldState. private static void PutCategoriesIntoVariables(Dictionary <AttribsCategory, Attribs> stateVariables, WorldState state) { AttribsCategory journalist = (from x in stateVariables.Keys where x.Name == "Journalist" select x).First(); Debug.Assert(journalist != null, "The list of attributes does not contain the Journalist category."); state.JournalistState = stateVariables[journalist]; }
/// <summary> /// Initialize for on-screen rendering /// </summary> public void Initialize(IntPtr outputHandle) { Debug.Assert(Initialized == false); if (UseMsaa) { InitializeDevice().Dispose(); } _swapChainDescription = new SwapChainDescription { BufferCount = 2, ModeDescription = new ModeDescription(0, 0, new Rational(60, 1), Format.R8G8B8A8_UNorm), IsWindowed = true, OutputHandle = outputHandle, SampleDescription = SampleDescription, SwapEffect = SwapEffect.Discard, Usage = Usage.RenderTargetOutput }; Device device; Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, _swapChainDescription, out device, out _swapChain); SetDeviceContextHolder(new DeviceContextHolder(device)); using (var factory = _swapChain.GetParent <Factory>()) { factory.SetWindowAssociation(outputHandle, WindowAssociationFlags.IgnoreAll); } InitializeInner(); Initialized = true; }
public int Add(object dataItem) { if (this.OwningGrid.SelectionMode == DataGridSelectionMode.Single) { throw DataGridError.DataGridSelectedItemsCollection.CannotChangeSelectedItemsCollectionInSingleMode(); } int itemIndex = this.OwningGrid.DataConnection.IndexOf(dataItem); if (itemIndex == -1) { throw DataGridError.DataGrid.ItemIsNotContainedInTheItemsSource("dataItem"); } DiagnosticsDebug.Assert(itemIndex >= 0, "Expected positive itemIndex."); int slot = this.OwningGrid.SlotFromRowIndex(itemIndex); if (_selectedSlotsTable.RangeCount == 0) { this.OwningGrid.SelectedItem = dataItem; } else { this.OwningGrid.SetRowSelection(slot, true /*isSelected*/, false /*setAnchorSlot*/); } return(_selectedSlotsTable.IndexOf(slot)); }
/// <summary> /// Look up module containing given nativesignature and return the appropriate native parser. /// </summary> /// <param name="signature">Signature to look up</param> /// <returns>Native parser for the signature</param> internal static NativeParser GetNativeParserForSignature(RuntimeSignature signature) { Debug.Assert(signature.IsNativeLayoutSignature); NativeReader reader = TypeLoaderEnvironment.GetNativeReaderForBlob(signature.ModuleHandle, ReflectionMapBlob.NativeLayoutInfo); return(new NativeParser(reader, signature.NativeLayoutOffset)); }
/// <summary> /// Initialize for out-screen rendering /// </summary> public void Initialize() { Debug.Assert(Initialized == false); SetDeviceContextHolder(new DeviceContextHolder(InitializeDevice())); InitializeInner(); Initialized = true; }
static void PrimeJit() { var sphere1 = Sphere(1000, new Vector3(-500, 0, 0)); var sphere2 = Sphere(1000, new Vector3(500, 0, 0)); var sub = Difference(sphere1, sphere2); Debug.Assert(sub.Polygons.Count > 0); }
/// <summary> /// Non-critical assert, should only crash on debug, otherwise return bool of the condition /// </summary> /// <param name="condition"></param> /// <param name="text"></param> /// <returns></returns> public static bool SoftAssert(bool condition, string text) { if (Debugger.IsAttached) { Debug.Assert(condition, text); } return(condition); }
/// <summary> /// Look up module containing given nativesignature and return the appropriate native parser. /// </summary> /// <param name="signature">Signature to look up</param> /// <returns>Native parser for the signature</returns> internal static NativeParser GetNativeParserForSignature(RuntimeSignature signature) { Debug.Assert(signature.IsNativeLayoutSignature); NativeFormatModuleInfo module = ModuleList.Instance.GetModuleInfoByHandle(new TypeManagerHandle(signature.ModuleHandle)); NativeReader reader = TypeLoaderEnvironment.GetNativeReaderForBlob(module, ReflectionMapBlob.NativeLayoutInfo); return(new NativeParser(reader, signature.NativeLayoutOffset)); }
/// <summary> /// Initialize for out-screen rendering using exising holder /// </summary> public void Initialize(DeviceContextHolder existingHolder) { Debug.Assert(Initialized == false); _sharedHolder = true; SetDeviceContextHolder(existingHolder); InitializeInner(); Initialized = true; }
public static void Ref(params object[] references) { SDebug.Assert(references != null, "reference is null"); for (int i = 0; i < references.Length; i++) { SDebug.Assert(references[i] != null, $"reference {i} is null"); } }
internal void AddRecylableRowGroupHeader(DataGridRowGroupHeader groupHeader) { DiagnosticsDebug.Assert(!_recyclableGroupHeaders.Contains(groupHeader), "Expected groupHeader parameter to be non-recyclable."); groupHeader.PropertyName = null; groupHeader.PropertyValue = null; groupHeader.IsRecycled = true; _recyclableGroupHeaders.Push(groupHeader); }
private void StartLevel() { var go = new GameObject("TTLLevel"); _currentLevel = go.AddComponent <Level>(); Debug.Assert(_currentLevel != null); _currentLevel.Options = Options; _currentLevel.GameOptions = _currentSaveGameOptions; }
public void Process(Step step) { if (!IsGameMode) { return; } //Problem: // OnLevelLoaded happens after OnLoadData // OnLevelUnloading happens before OnSaveData // but: OnLoadData is called even for new maps // Order: // LoadData (always) // LevelLoaded (always) // // LevelUnloaded (always) // SaveData (when saving) DebugLog.Info($"{nameof(Process)}({step}): CurrentLevel={_currentLevel}, CurrentLevelOptions={_currentSaveGameOptions}"); // in order switch (step) { case Step.LoadData: //(always) Debug.Assert(_currentLevel == null); InitializeLevel(); Debug.Assert(_currentLevel == null); Debug.Assert(_currentSaveGameOptions != null); LoadLevel(Managers.serializableData); break; case Step.LevelLoaded: // (always) Debug.Assert(_currentLevel == null); Debug.Assert(_currentSaveGameOptions != null); StartLevel(); Debug.Assert(_currentLevel != null); break; case Step.LevelUnloaded: // (always) Debug.Assert(_currentLevel != null); Debug.Assert(_currentSaveGameOptions != null); EndLevel(); Debug.Assert(_currentLevel == null); Debug.Assert(_currentSaveGameOptions != null); break; case Step.SaveData: // (when saving) Debug.Assert(_currentSaveGameOptions != null); SaveLevel(Managers.serializableData); break; default: throw new ArgumentOutOfRangeException(nameof(step), step, null); } }
/// <summary> /// Arranges the content of the <see cref="T:System.Windows.Controls.Primitives.DataGridCellsPresenter"/>. /// </summary> /// <returns> /// The actual size used by the <see cref="T:System.Windows.Controls.Primitives.DataGridCellsPresenter"/>. /// </returns> /// <param name="finalSize"> /// The final area within the parent that this element should use to arrange itself and its children. /// </param> protected override Size ArrangeOverride(Size finalSize) { if (this.OwningGrid == null) { return(base.ArrangeOverride(finalSize)); } if (this.OwningGrid.AutoSizingColumns) { // When we initially load an auto-column, we have to wait for all the rows to be measured // before we know its final desired size. We need to trigger a new round of measures now // that the final sizes have been calculated. this.OwningGrid.AutoSizingColumns = false; return(base.ArrangeOverride(finalSize)); } double frozenLeftEdge = 0; double scrollingLeftEdge = -this.OwningGrid.HorizontalOffset; double cellLeftEdge; foreach (DataGridColumn column in this.OwningGrid.ColumnsInternal.GetVisibleColumns()) { DataGridCell cell = this.OwningRow.Cells[column.Index]; DiagnosticsDebug.Assert(cell.OwningColumn == column, "Expected column owner."); DiagnosticsDebug.Assert(column.IsVisible, "Expected visible column."); if (column.IsFrozen) { cellLeftEdge = frozenLeftEdge; // This can happen before or after clipping because frozen cells aren't clipped frozenLeftEdge += column.ActualWidth; } else { cellLeftEdge = scrollingLeftEdge; } if (cell.Visibility == Visibility.Visible) { cell.Arrange(new Rect(cellLeftEdge, 0, column.LayoutRoundedWidth, finalSize.Height)); EnsureCellClip(cell, column.ActualWidth, finalSize.Height, frozenLeftEdge, scrollingLeftEdge); } scrollingLeftEdge += column.ActualWidth; column.IsInitialDesiredWidthDetermined = true; } _fillerLeftEdge = scrollingLeftEdge; // FillerColumn.Width == 0 when the filler column is not active this.OwningRow.FillerCell.Arrange(new Rect(_fillerLeftEdge, 0, this.OwningGrid.ColumnsInternal.FillerColumn.FillerWidth, finalSize.Height)); return(finalSize); }