public void Flood(FloodMode mode) { int nexId = r.Next(this.contentList.Count); //Console.WriteLine(string.Format("{0}:{1}", nexId, this.contentList[nexId].Length)); switch (mode) { case FloodMode.TCP: this.botClient.ChatSystem.SendChatMessage(botClient.ChatSystem.AvailableGroupList[0], this.contentList[nexId]); break; case FloodMode.UDP: this.botClient.ChatSystem.SendUDPChatMessage(botClient.ChatSystem.AvailableGroupList[0], this.contentList[nexId]); break; case FloodMode.Both: this.botClient.ChatSystem.SendChatMessage(botClient.ChatSystem.AvailableGroupList[0], this.contentList[nexId]); this.botClient.ChatSystem.SendUDPChatMessage(botClient.ChatSystem.AvailableGroupList[0], this.contentList[nexId]); break; case FloodMode.None: break; } //if (this.contentList[nexId].Length > 128) //{ //} }
public void SetToDefaults() { this.antiAliasing = true; this.fontSmoothing = FontSmoothing.Smooth; this.primaryColor = ColorBgra.FromBgra(0, 0, 0, 255); this.secondaryColor = ColorBgra.FromBgra(255, 255, 255, 255); this.gradientInfo = new GradientInfo(GradientType.LinearClamped, false); this.penInfo = new PenInfo(PenInfo.DefaultDashStyle, 2.0f, PenInfo.DefaultLineCap, PenInfo.DefaultLineCap, PenInfo.DefaultCapScale); this.brushInfo = new BrushInfo(BrushType.Solid, HatchStyle.BackwardDiagonal); try { this.fontInfo = new FontInfo(new FontFamily("Arial"), 12, FontStyle.Regular); } catch (Exception) { this.fontInfo = new FontInfo(new FontFamily(GenericFontFamilies.SansSerif), 12, FontStyle.Regular); } this.textAlignment = TextAlignment.Left; this.shapeDrawType = ShapeDrawType.Outline; this.alphaBlending = true; this.tolerance = 0.5f; this.colorPickerClickBehavior = ColorPickerClickBehavior.NoToolSwitch; this.resamplingAlgorithm = ResamplingAlgorithm.Bilinear; this.selectionCombineMode = CombineMode.Replace; this.floodMode = FloodMode.Local; this.selectionDrawModeInfo = SelectionDrawModeInfo.CreateDefault(); }
public void LoadFrom(AppEnvironment appEnvironment) { this.textAlignment = appEnvironment.textAlignment; this.gradientInfo = appEnvironment.gradientInfo.Clone(); this.fontSmoothing = appEnvironment.fontSmoothing; this.fontInfo = appEnvironment.fontInfo.Clone(); this.penInfo = appEnvironment.penInfo.Clone(); this.brushInfo = appEnvironment.brushInfo.Clone(); this.primaryColor = appEnvironment.primaryColor; this.secondaryColor = appEnvironment.secondaryColor; this.alphaBlending = appEnvironment.alphaBlending; this.shapeDrawType = appEnvironment.shapeDrawType; this.colorPickerClickBehavior = appEnvironment.colorPickerClickBehavior; this.resamplingAlgorithm = appEnvironment.resamplingAlgorithm; this.tolerance = appEnvironment.tolerance; this.selectionCombineMode = appEnvironment.selectionCombineMode; this.floodMode = appEnvironment.floodMode; this.selectionDrawModeInfo = appEnvironment.selectionDrawModeInfo.Clone(); PerformAllChanged(); }
protected override GeometryList CreateSelectionGeometry(MagicWandToolChanges changes, AsyncSelectionToolCreateGeometryContext context, CancellationToken cancellationToken) { GeometryList list; Result <BitVector2D> lazyBaseStencil; IRenderer <ColorBgra> sampleSource = ((MagicWandToolCreateGeometryContext)context).SampleSource; byte x = (byte)Math.Round((double)(changes.Tolerance * 255.0), MidpointRounding.AwayFromZero); byte tolerance = ByteUtil.FastScale(x, x); PointInt32 pt = changes.OriginPointInt32; if (!sampleSource.Bounds <ColorBgra>().Contains(pt)) { switch (changes.SelectionCombineMode) { case SelectionCombineMode.Replace: case SelectionCombineMode.Intersect: return(new GeometryList()); case SelectionCombineMode.Union: case SelectionCombineMode.Exclude: case SelectionCombineMode.Xor: return(changes.BaseGeometry); } throw ExceptionUtil.InvalidEnumArgumentException <SelectionCombineMode>(changes.SelectionCombineMode, "changes.SelectionCombineMode"); } if (cancellationToken.IsCancellationRequested) { return(null); } Func <bool> isCancellationRequestedFn = () => cancellationToken.IsCancellationRequested; ColorBgra basis = sampleSource.GetPointSlow(pt); int width = ((sampleSource.Width + 0x1f) / 0x20) * 0x20; BitVector2D newStencil = new BitVector2D(width, sampleSource.Height); BitVector2DStruct newStencilWrapper = new BitVector2DStruct(newStencil); if (((changes.SelectionCombineMode != SelectionCombineMode.Replace) && sampleSource.Bounds <ColorBgra>().Contains(changes.BaseGeometry.Bounds.Int32Bound)) && changes.BaseGeometry.IsPixelated) { lazyBaseStencil = LazyResult.New <BitVector2D>(() => PixelatedGeometryListToBitVector2D(changes.BaseGeometry, newStencil.Width, newStencil.Height, cancellationToken), LazyThreadSafetyMode.ExecutionAndPublication, new SingleUseCriticalSection()); ThreadPool.QueueUserWorkItem(delegate(object _) { lazyBaseStencil.EnsureEvaluated(); }); } else { lazyBaseStencil = null; } FloodMode floodMode = changes.FloodMode; if (floodMode != FloodMode.Local) { if (floodMode != FloodMode.Global) { throw ExceptionUtil.InvalidEnumArgumentException <FloodMode>(changes.FloodMode, "changes.FloodMode"); } } else { RectInt32 num4; FloodFillAlgorithm.FillStencilFromPoint <BitVector2DStruct>(sampleSource, newStencilWrapper, pt, tolerance, isCancellationRequestedFn, out num4); goto Label_0293; } TileMathHelper tileMathHelper = new TileMathHelper(sampleSource.Width, sampleSource.Height, 7); Work.ParallelForEach <PointInt32>(WaitType.Pumping, tileMathHelper.EnumerateTileOffsets(), delegate(PointInt32 tileOffset) { if (!cancellationToken.IsCancellationRequested) { RectInt32 clipRect = tileMathHelper.GetTileSourceRect(tileOffset); FloodFillAlgorithm.FillStencilByColor <BitVector2DStruct>(sampleSource, newStencilWrapper, basis, tolerance, isCancellationRequestedFn, clipRect); } }, WorkItemQueuePriority.Normal, null); Label_0293: if (cancellationToken.IsCancellationRequested) { return(null); } if (changes.SelectionCombineMode == SelectionCombineMode.Replace) { list = GeometryList.FromStencil <BitVector2DStruct>(newStencilWrapper, cancellationToken); } else if (lazyBaseStencil == null) { GeometryList rhs = GeometryList.FromStencil <BitVector2DStruct>(newStencilWrapper, cancellationToken); if (cancellationToken.IsCancellationRequested) { return(null); } list = GeometryList.Combine(changes.BaseGeometry, changes.SelectionCombineMode.ToGeometryCombineMode(), rhs); } else { BitVector2D other = lazyBaseStencil.Value; if (cancellationToken.IsCancellationRequested) { return(null); } switch (changes.SelectionCombineMode) { case SelectionCombineMode.Replace: throw new InternalErrorException(); case SelectionCombineMode.Union: newStencil.Or(other); break; case SelectionCombineMode.Exclude: newStencil.Invert(); if (cancellationToken.IsCancellationRequested) { return(null); } newStencil.And(other); break; case SelectionCombineMode.Intersect: newStencil.And(other); break; case SelectionCombineMode.Xor: newStencil.Xor(other); break; default: throw ExceptionUtil.InvalidEnumArgumentException <SelectionCombineMode>(changes.SelectionCombineMode, "changes.SelectionCombineMode"); } if (cancellationToken.IsCancellationRequested) { return(null); } list = GeometryList.FromStencil <BitVector2DStruct>(newStencilWrapper, cancellationToken); } if (cancellationToken.IsCancellationRequested) { return(null); } list.Freeze(); return(list); }
private FloodMode CycleFloodMode(FloodMode mode) { FloodMode newMode; switch (mode) { default: throw new InvalidEnumArgumentException(); case FloodMode.Global: newMode = FloodMode.Local; break; case FloodMode.Local: newMode = FloodMode.Global; break; } return newMode; }
private void FloodModeSplitButton_DropDownOpening(object sender, EventArgs e) { this.floodModeSplitButton.DropDownItems.Clear(); foreach (FloodMode fm in new FloodMode[] { FloodMode.Local, FloodMode.Global }) { ToolStripMenuItem fmMI = new ToolStripMenuItem( PdnResources.GetString("ToolConfigStrip.FloodModeSplitButton." + fm.ToString() + ".Text"), GetFloodModeImage(fm).Reference, delegate(object sender2, EventArgs e2) { ToolStripMenuItem asTSMI = (ToolStripMenuItem)sender2; FloodMode newFM = (FloodMode)asTSMI.Tag; this.FloodMode = newFM; }); fmMI.Tag = fm; fmMI.Checked = (fm == FloodMode); this.floodModeSplitButton.DropDownItems.Add(fmMI); } }
private ImageResource GetFloodModeImage(FloodMode cm) { return PdnResources.GetImageResource("Icons.ToolConfigStrip.FloodMode." + cm.ToString() + ".png"); }
public void LoadFrom(AppEnvironment appEnvironment) { this.textAlignment = appEnvironment.textAlignment; this.gradientInfo = appEnvironment.gradientInfo.Clone(); this.fontSmoothing = appEnvironment.fontSmoothing; this.fontInfo = appEnvironment.fontInfo.Clone(); this.penInfo = appEnvironment.penInfo.Clone(); this.brushInfo = appEnvironment.brushInfo.Clone(); this.primaryColor = appEnvironment.primaryColor; this.secondaryColor = appEnvironment.secondaryColor; this.alphaBlending = appEnvironment.alphaBlending; this.shapeDrawType = appEnvironment.shapeDrawType; this.antiAliasing = appEnvironment.antiAliasing; this.colorPickerClickBehavior = appEnvironment.colorPickerClickBehavior; this.resamplingAlgorithm = appEnvironment.resamplingAlgorithm; this.tolerance = appEnvironment.tolerance; this.selectionCombineMode = appEnvironment.selectionCombineMode; this.floodMode = appEnvironment.floodMode; this.selectionDrawModeInfo = appEnvironment.selectionDrawModeInfo.Clone(); PerformAllChanged(); }