void SetBorders(Border ccw, Border cw) { ccwBorder = ccw; cwBorder = cw; this.enabled = true; this.Start(); }
public static void Run() { // ExStart:AddTextBoxField // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Forms(); // Open document Document pdfDocument = new Document(dataDir + "TextField.pdf"); // Create a field TextBoxField textBoxField = new TextBoxField(pdfDocument.Pages[1], new Aspose.Pdf.Rectangle(100, 200, 300, 300)); textBoxField.PartialName = "textbox1"; textBoxField.Value = "Text Box"; // TextBoxField.Border = new Border( Border border = new Border(textBoxField); border.Width = 5; border.Dash = new Dash(1, 1); textBoxField.Border = border; textBoxField.Color = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Green); // Add field to the document pdfDocument.Form.Add(textBoxField, 1); dataDir = dataDir + "TextBox_out.pdf"; // Save modified PDF pdfDocument.Save(dataDir); // ExEnd:AddTextBoxField Console.WriteLine("\nTextbox field added successfully.\nFile saved at " + dataDir); }
public static void Run() { // ExStart:AddAnnotation // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Annotations(); // Open document Document pdfDocument = new Document(dataDir + "AddAnnotation.pdf"); // Create annotation TextAnnotation textAnnotation = new TextAnnotation(pdfDocument.Pages[1], new Aspose.Pdf.Rectangle(200, 400, 400, 600)); textAnnotation.Title = "Sample Annotation Title"; textAnnotation.Subject = "Sample Subject"; textAnnotation.State = AnnotationState.Accepted; textAnnotation.Contents = "Sample contents for the annotation"; textAnnotation.Open = true; textAnnotation.Icon = TextIcon.Key; Border border = new Border(textAnnotation); border.Width = 5; border.Dash = new Dash(1, 1); textAnnotation.Border = border; textAnnotation.Rect = new Aspose.Pdf.Rectangle(200, 400, 400, 600); // Add annotation in the annotations collection of the page pdfDocument.Pages[1].Annotations.Add(textAnnotation); dataDir = dataDir + "AddAnnotation_out.pdf"; // Save output file pdfDocument.Save(dataDir); // ExEnd:AddAnnotation Console.WriteLine("\nAnnotation added successfully.\nFile saved at " + dataDir); }
public void BringDescendentIntoView_Should_Handle_Child_Margin() { Border border; var target = new ScrollContentPresenter { Width = 100, Height = 100, Content = new Decorator { Margin = new Thickness(50), Child = border = new Border { Width = 200, Height = 200, } } }; target.UpdateChild(); target.Measure(Size.Infinity); target.Arrange(new Rect(0, 0, 100, 100)); target.BringDescendentIntoView(border, new Rect(200, 200, 0, 0)); Assert.Equal(new Vector(150, 150), target.Offset); }
public static void Main(string[] args) { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); //Open document Document pdfDocument = new Document(dataDir + "input.pdf"); //Create a field TextBoxField textBoxField = new TextBoxField(pdfDocument.Pages[1], new Aspose.Pdf.Rectangle(100, 200, 300, 300)); textBoxField.PartialName = "textbox1"; textBoxField.Value = "Text Box"; //textBoxField.Border = new Border( Border border = new Border(textBoxField); border.Width = 5; border.Dash = new Dash(1, 1); textBoxField.Border = border; textBoxField.Color = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Green); //Add field to the document pdfDocument.Form.Add(textBoxField, 1); //Save modified PDF pdfDocument.Save(dataDir + "output.pdf"); }
/// <summary> /// merges two borders together /// the ccwBorder is kept, all connections to the cwBorder are re-set /// </summary> /// <param name="ccwBorder">the ccw border of the merge, this border remains</param> /// <param name="cwBorder">the cw border of the merge, this border is knocked out</param> public void MergeBorders(Border ccwBorder, Border cwBorder) { Debug.Log("MERGING: " + ccwBorder.transform + " and " + cwBorder.transform); // set to the angle between the merged borders ccwBorder.SetAngle(ccwBorder.currentAngle - ((ccwBorder.currentAngle - cwBorder.currentAngle) / 2)); // update screen border for missing one foreach (Screen screen in allScreens) { if (screen.ccwBorder == cwBorder) { screen.ccwBorder = ccwBorder; } } // update border list allBorders.Remove(cwBorder); // fix border neighbors for the one that's been merged ccwBorder.cwBorder = cwBorder.cwBorder; cwBorder.cwBorder.ccwBorder = ccwBorder; // turn off merged border cwBorder.gameObject.SetActive(false); }
private static UIElement r_11_dtMethod(UIElement parent) { // e_69 element Border e_69 = new Border(); e_69.Parent = parent; e_69.Name = "e_69"; e_69.Background = new SolidColorBrush(new ColorW(0, 0, 255, 255)); // e_70 element StackPanel e_70 = new StackPanel(); e_69.Child = e_70; e_70.Name = "e_70"; // e_71 element TextBlock e_71 = new TextBlock(); e_70.Children.Add(e_71); e_71.Name = "e_71"; e_71.HorizontalAlignment = HorizontalAlignment.Center; e_71.VerticalAlignment = VerticalAlignment.Center; Binding binding_e_71_Text = new Binding("TextData"); e_71.SetBinding(TextBlock.TextProperty, binding_e_71_Text); // e_72 element Button e_72 = new Button(); e_70.Children.Add(e_72); e_72.Name = "e_72"; e_72.Content = "Hide Window"; Binding binding_e_72_Command = new Binding("HideCommand"); e_72.SetBinding(Button.CommandProperty, binding_e_72_Command); return e_69; }
public void AttachedToLogicalParent_Should_Be_Called_When_Added_To_Tree() { var root = new TestRoot(); var parent = new Border(); var child = new Border(); var grandchild = new Border(); var parentRaised = false; var childRaised = false; var grandchildRaised = false; parent.AttachedToLogicalTree += (s, e) => parentRaised = true; child.AttachedToLogicalTree += (s, e) => childRaised = true; grandchild.AttachedToLogicalTree += (s, e) => grandchildRaised = true; parent.Child = child; child.Child = grandchild; Assert.False(parentRaised); Assert.False(childRaised); Assert.False(grandchildRaised); root.Child = parent; Assert.True(parentRaised); Assert.True(childRaised); Assert.True(grandchildRaised); }
public static void Run() { // ExStart:AddlnkAnnotation // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Annotations(); Document doc = new Document(); Page pdfPage = doc.Pages.Add(); System.Drawing.Rectangle drect = new System.Drawing.Rectangle(); drect.Height = (int)pdfPage.Rect.Height; drect.Width = (int)pdfPage.Rect.Width; drect.X = 0; drect.Y = 0; Aspose.Pdf.Rectangle arect = Aspose.Pdf.Rectangle.FromRect(drect); ArrayList inkList = new ArrayList(); Aspose.Pdf.Point[] arrpt = new Aspose.Pdf.Point[3]; inkList.Add(arrpt); arrpt[0] = new Aspose.Pdf.Point(100, 800); arrpt[1] = new Aspose.Pdf.Point(200, 800); arrpt[2] = new Aspose.Pdf.Point(200, 700); InkAnnotation ia = new InkAnnotation(pdfPage, arect, inkList); ia.Title = "XXX"; ia.Color = Aspose.Pdf.Color.LightBlue; // (GetColorFromString(stroke.InkColor)); ia.CapStyle = CapStyle.Rounded; Border border = new Border(ia); border.Width = 25; ia.Opacity = 0.5; pdfPage.Annotations.Add(ia); dataDir = dataDir + "AddlnkAnnotation_out.pdf"; // Save output file doc.Save(dataDir); // ExEnd:AddlnkAnnotation Console.WriteLine("\nlnk annotation added successfully.\nFile saved at " + dataDir); }
private static UIElement r_2_ctMethod(UIElement parent) { // e_0 element Grid e_0 = new Grid(); e_0.Parent = parent; e_0.Name = "e_0"; RowDefinition row_e_0_0 = new RowDefinition(); row_e_0_0.Height = new GridLength(20F, GridUnitType.Pixel); e_0.RowDefinitions.Add(row_e_0_0); RowDefinition row_e_0_1 = new RowDefinition(); e_0.RowDefinitions.Add(row_e_0_1); // PART_WindowTitleBorder element Border PART_WindowTitleBorder = new Border(); e_0.Children.Add(PART_WindowTitleBorder); PART_WindowTitleBorder.Name = "PART_WindowTitleBorder"; PART_WindowTitleBorder.Background = new SolidColorBrush(new ColorW(255, 255, 255, 255)); // e_1 element ContentPresenter e_1 = new ContentPresenter(); e_0.Children.Add(e_1); e_1.Name = "e_1"; Grid.SetRow(e_1, 1); Binding binding_e_1_Content = new Binding(); e_1.SetBinding(ContentPresenter.ContentProperty, binding_e_1_Content); return e_0; }
public ToolbarToggleButton (String text_one, String text_two, bool auto_toggle, StyleSheet scheme, Border borders, uint width, uint height) : base (text_one, scheme, borders, width, height) { toggle = auto_toggle; CairoTexture texture = new CairoTexture (width, height); StyleSheet s = scheme; s.Foreground = scheme.Background; s.Background = scheme.Foreground; s.Standard = new Font () { Family = scheme.Standard.Family, Slant = scheme.Standard.Slant, Weight = scheme.Standard.Weight, Size = scheme.Standard.Size, Color = scheme.Background }; s.Border = scheme.Foreground; Style = s; Text = text_two; Draw (texture); Style = scheme; Text = text_one; textures.Add (texture); texture.Hide (); this.Add (texture); InitializeHandlers (); }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager) { tile = factory.GetTexture2D("Textures/tile"); FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld; ///border border = new Border(fworld, factory, GraphicInfo, factory.CreateTexture2DColor(1, 1, Color.Red)); ///from texture { Texture2D tex = factory.GetTexture2D("Textures//goo"); tex = factory.GetScaledTexture(tex, new Vector2(4)); IModelo2D model = new SpriteFarseer(tex); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, model); I2DObject o = new I2DObject(fs, mat, model); o.OnHasMoved += new PloobsEngine.SceneControl._2DScene.OnHasMoved(o_OnHasMoved); this.World.AddObject(o); } ///camera this.World.Camera2D = new Camera2D(GraphicInfo); ///Create the Particle System DPFSParticleSystem ps = new DPFSParticleSystem("TESTE", new SpriteParticleSystem(null)); this.World.ParticleManager.AddAndInitializeParticleSystem(ps); ///updateable JointUpdateable ju = new JointUpdateable(this, fworld, this.World.Camera2D); base.LoadContent(GraphicInfo, factory, contentManager); }
public ToolbarButton (String text, StyleSheet scheme, Border borders, uint width, uint height) : base (scheme, width, height) { Text = text; Borders = borders; base.Initialize (); }
internal MenuManager(Game game, Score score, int screenWidth, int screenHeight) : base(game) { _score = score; _screenHeight = screenHeight; _screenWidth = screenWidth; Border = new Border(base.Game, _screenWidth - 45, _screenHeight - 95); }
private static void DetermineTextWidthAndHeightWindows8(out double textWidth, out double textHeight, Border border, TextBlock textblock) { const int bigEnough = 10000; border.Measure(new XamlSize(double.PositiveInfinity, double.PositiveInfinity)); border.Arrange(new Rect(0, 0, bigEnough, bigEnough)); textWidth = textblock.ActualWidth; textHeight = textblock.ActualHeight; }
public void OnCountryBorderStay(Border border, Agent agent) { if(agent == null){ Debug.Log (string.Format ("Agent {0} stays on {1} border!", null, border.GetCountry())); return; } Debug.Log (string.Format ("Agent {0} stays on {1} border!", agent, border.GetCountry())); }
/// <summary> /// Copy the border's settings into the target border. /// </summary> /// <param name="border">The border to copy settings from.</param> /// <param name="target">The border to copy settings to.</param> public static void CopyTo(this Border border, Border target) { target.Color = border.Color; target.DistanceFromText = border.DistanceFromText; //other.IsVisible = self.IsVisible; target.LineStyle = border.LineStyle; target.LineWidth = border.LineWidth; target.Shadow = border.Shadow; }
public void Should_Set_Childs_Parent_To_Itself_Outside_Template() { var content = new Border(); var target = new ContentPresenter { Content = content }; target.UpdateChild(); Assert.Same(target, content.Parent); }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager) { tile = factory.GetTexture2D("Textures/tile"); FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld; ///border border = new Border(fworld, factory, GraphicInfo, factory.CreateTexture2DColor(1, 1, Color.Red)); ///from texture, scale usage sample { Texture2D tex = factory.GetTexture2D("Textures//goo"); tex = factory.GetScaledTexture(tex, new Vector2(3)); IModelo2D model = new SpriteFarseer(tex); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, tex); fs.Position = new Vector2(0, 50); partobj = new I2DObject(fs, mat, model); partobj.OnHasMoved += new PloobsEngine.SceneControl._2DScene.OnHasMoved(o_OnHasMoved); this.World.AddObject(partobj); } Vertices verts = PolygonTools.CreateRectangle(150, 150); { IModelo2D model = new SpriteFarseer(factory, verts, Color.Green); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, model, 1, BodyType.Dynamic); I2DObject o = new I2DObject(fs, mat, model); ///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen ///We need to translate it a bit down o.PhysicObject.Position = new Vector2(100, 100); this.World.AddObject(o); } //circle verts = PolygonTools.CreateCircle(150, 150); { IModelo2D model = new SpriteFarseer(factory, verts, Color.Orange); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, model, 1, BodyType.Dynamic); I2DObject o = new I2DObject(fs, mat, model); o.PhysicObject.Position = new Vector2(-100, -100); this.World.AddObject(o); } ///camera this.World.Camera2D = new Camera2D(GraphicInfo); DPFSParticleSystem ps = new DPFSParticleSystem("TESTE", new SpriteParticleSystem(null)); this.World.ParticleManager.AddAndInitializeParticleSystem(ps); ///updateable ju = new JointUpdateable(this, fworld, this.World.Camera2D); base.LoadContent(GraphicInfo, factory, contentManager); }
public void Content_Control_Should_Appear_In_LogicalChildren() { var target = new Border(); var child = new Control(); target.Content = child; Assert.Equal(new[] { child }, ((ILogical)target).LogicalChildren.ToList()); }
private void InitializeComponent() { // rect element this.rect = new Border(); this.Content = this.rect; this.rect.Name = "rect"; this.rect.SnapsToDevicePixels = true; this.rect.BorderBrush = new SolidColorBrush(new ColorW(255, 255, 255, 255)); this.rect.BorderThickness = new Thickness(1F, 1F, 0F, 0F); }
private static Border CreateNoBorder() { var border = new Border(); border.LeftBorder = new LeftBorder(); border.RightBorder = new RightBorder(); border.TopBorder = new TopBorder(); border.BottomBorder = new BottomBorder(); border.DiagonalBorder = new DiagonalBorder(); return border; }
public void Clearing_Content_Should_Remove_From_LogicalChildren() { var target = new Border(); var child = new Control(); target.Content = child; target.Content = null; Assert.Equal(new ILogical[0], ((ILogical)target).LogicalChildren.ToList()); }
public TextBlock() : base() { Border = new Border() {WidthAll = 0, Color = new Color(0,0,0)}; FontName = "Helvetica"; FontColor = new Color(0,0,0); FontSize = 12; FieldName = String.Empty; Padding = new Thickness(1,1,1,1); CanGrow = true; }
// Use this for initialization void Awake() { blockMisplay = false; gravity = "down"; blockIndex = 0; blocksToPlace = new string[4] { "blue", "red", "yellow", "green"}; gravitySpeed = 2f; spawnCtr = GameObject.Find("SpawnController").GetComponent<SpawnController>(); border = GameObject.Find("Border").GetComponent<Border>(); spawnCtr.beginSpawn(); }
public void Setting_Content_To_Control_Should_Set_Child() { var target = new ContentPresenter(); var child = new Border(); target.Content = child; Assert.Null(target.Child); target.UpdateChild(); Assert.Equal(child, target.Child); }
public void Clearing_Content_Should_Clear_Child_Controls_Parent() { var target = new Border(); var child = new Control(); target.Content = child; target.Content = null; Assert.Null(child.Parent); Assert.Null(((ILogical)child).LogicalParent); }
public void Content_Should_Have_TemplatedParent_Set_To_Null() { var target = new ContentControl(); var child = new Border(); target.Template = GetTemplate(); target.Content = child; target.ApplyTemplate(); Assert.Null(child.TemplatedParent); }
public void Measure_Should_Return_BorderThickness_Plus_Padding_When_No_Child_Present() { var target = new Border { Padding = new Thickness(6), BorderThickness = 4, }; target.Measure(new Size(100, 100)); Assert.Equal(new Size(20, 20), target.DesiredSize); }
public void ContentPresenter_Should_Have_TemplatedParent_Set() { var target = new ContentControl(); var child = new Border(); target.Template = GetTemplate(); target.Content = child; target.ApplyTemplate(); var contentPresenter = child.GetVisualParent<ContentPresenter>(); Assert.Equal(target, contentPresenter.TemplatedParent); }
/// <summary> /// Update the visual state of the control when its template is changed. /// </summary> protected override void OnApplyTemplate() { if (_minThumb != null) { _minThumb.DragCompleted -= Thumb_DragCompleted; _minThumb.DragDelta -= MinThumb_DragDelta; _minThumb.DragStarted -= MinThumb_DragStarted; _minThumb.KeyDown -= MinThumb_KeyDown; } if (_maxThumb != null) { _maxThumb.DragCompleted -= Thumb_DragCompleted; _maxThumb.DragDelta -= MaxThumb_DragDelta; _maxThumb.DragStarted -= MaxThumb_DragStarted; _maxThumb.KeyDown -= MaxThumb_KeyDown; } if (_containerCanvas != null) { _containerCanvas.SizeChanged -= ContainerCanvas_SizeChanged; _containerCanvas.PointerPressed -= ContainerCanvas_PointerPressed; _containerCanvas.PointerMoved -= ContainerCanvas_PointerMoved; _containerCanvas.PointerReleased -= ContainerCanvas_PointerReleased; _containerCanvas.PointerExited -= ContainerCanvas_PointerExited; } IsEnabledChanged -= RangeSelector_IsEnabledChanged; // Need to make sure the values can be set in XAML and don't overwrite each other VerifyValues(); _valuesAssigned = true; _outOfRangeContentContainer = GetTemplateChild("OutOfRangeContentContainer") as Border; _activeRectangle = GetTemplateChild("ActiveRectangle") as Rectangle; _minThumb = GetTemplateChild("MinThumb") as Thumb; _maxThumb = GetTemplateChild("MaxThumb") as Thumb; _containerCanvas = GetTemplateChild("ContainerCanvas") as Canvas; _controlGrid = GetTemplateChild("ControlGrid") as Grid; _toolTip = GetTemplateChild("ToolTip") as Grid; _toolTipText = GetTemplateChild("ToolTipText") as TextBlock; if (_minThumb != null) { _minThumb.DragCompleted += Thumb_DragCompleted; _minThumb.DragDelta += MinThumb_DragDelta; _minThumb.DragStarted += MinThumb_DragStarted; _minThumb.KeyDown += MinThumb_KeyDown; _minThumb.KeyUp += Thumb_KeyUp; } if (_maxThumb != null) { _maxThumb.DragCompleted += Thumb_DragCompleted; _maxThumb.DragDelta += MaxThumb_DragDelta; _maxThumb.DragStarted += MaxThumb_DragStarted; _maxThumb.KeyDown += MaxThumb_KeyDown; _maxThumb.KeyUp += Thumb_KeyUp; } if (_containerCanvas != null) { _containerCanvas.SizeChanged += ContainerCanvas_SizeChanged; _containerCanvas.PointerEntered += ContainerCanvas_PointerEntered; _containerCanvas.PointerPressed += ContainerCanvas_PointerPressed; _containerCanvas.PointerMoved += ContainerCanvas_PointerMoved; _containerCanvas.PointerReleased += ContainerCanvas_PointerReleased; _containerCanvas.PointerExited += ContainerCanvas_PointerExited; } VisualStateManager.GoToState(this, IsEnabled ? "Normal" : "Disabled", false); IsEnabledChanged += RangeSelector_IsEnabledChanged; // Measure our min/max text longest value so we can avoid the length of the scrolling reason shifting in size during use. var tb = new TextBlock { Text = Maximum.ToString() }; tb.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); base.OnApplyTemplate(); }
/// <summary> /// Makes a border path for rounded borders.<br/> /// To support rounded dotted/dashed borders we need to use arc in the border path.<br/> /// Return null if the border is not rounded.<br/> /// </summary> /// <param name="border">Desired border</param> /// <param name="b">Box which the border corresponds</param> /// <param name="r">the rectangle the border is enclosing</param> /// <returns>Beveled border path, null if there is no rounded corners</returns> private static GraphicsPath GetRoundedBorderPath(Border border, CssBox b, RectangleF r) { GraphicsPath path = null; switch (border) { case Border.Top: if (b.ActualCornerNW > 0 || b.ActualCornerNE > 0) { path = new GraphicsPath(); if (b.ActualCornerNW > 0) { path.AddArc(r.Left + b.ActualBorderLeftWidth / 2, r.Top + b.ActualBorderTopWidth / 2, b.ActualCornerNW * 2, b.ActualCornerNW * 2, 180f, 90f); } else { path.AddLine(r.Left + b.ActualBorderLeftWidth / 2, r.Top + b.ActualBorderTopWidth / 2, r.Left + b.ActualBorderLeftWidth, r.Top + b.ActualBorderTopWidth / 2); } if (b.ActualCornerNE > 0) { path.AddArc(r.Right - b.ActualCornerNE * 2 - b.ActualBorderRightWidth / 2, r.Top + b.ActualBorderTopWidth / 2, b.ActualCornerNE * 2, b.ActualCornerNE * 2, 270f, 90f); } else { path.AddLine(r.Right - b.ActualCornerNE * 2 - b.ActualBorderRightWidth, r.Top + b.ActualBorderTopWidth / 2, r.Right - b.ActualBorderRightWidth / 2, r.Top + b.ActualBorderTopWidth / 2); } } break; case Border.Bottom: if (b.ActualCornerSW > 0 || b.ActualCornerSE > 0) { path = new GraphicsPath(); if (b.ActualCornerSE > 0) { path.AddArc(r.Right - b.ActualCornerNE * 2 - b.ActualBorderRightWidth / 2, r.Bottom - b.ActualCornerSE * 2 - b.ActualBorderBottomWidth / 2, b.ActualCornerSE * 2, b.ActualCornerSE * 2, 0f, 90f); } else { path.AddLine(r.Right - b.ActualBorderRightWidth / 2, r.Bottom - b.ActualBorderBottomWidth / 2, r.Right - b.ActualBorderRightWidth / 2, r.Bottom - b.ActualBorderBottomWidth / 2 - .1f); } if (b.ActualCornerSW > 0) { path.AddArc(r.Left + b.ActualBorderLeftWidth / 2, r.Bottom - b.ActualCornerSW * 2 - b.ActualBorderBottomWidth / 2, b.ActualCornerSW * 2, b.ActualCornerSW * 2, 90f, 90f); } else { path.AddLine(r.Left + b.ActualBorderLeftWidth / 2 + .1f, r.Bottom - b.ActualBorderBottomWidth / 2, r.Left + b.ActualBorderLeftWidth / 2, r.Bottom - b.ActualBorderBottomWidth / 2); } } break; case Border.Right: if (b.ActualCornerNE > 0 || b.ActualCornerSE > 0) { path = new GraphicsPath(); if (b.ActualCornerNE > 0 && (b.BorderTopStyle == CssConstants.None || b.BorderTopStyle == CssConstants.Hidden)) { path.AddArc(r.Right - b.ActualCornerNE * 2 - b.ActualBorderRightWidth / 2, r.Top + b.ActualBorderTopWidth / 2, b.ActualCornerNE * 2, b.ActualCornerNE * 2, 270f, 90f); } else { path.AddLine(r.Right - b.ActualBorderRightWidth / 2, r.Top + b.ActualCornerNE + b.ActualBorderTopWidth / 2, r.Right - b.ActualBorderRightWidth / 2, r.Top + b.ActualCornerNE + b.ActualBorderTopWidth / 2 + .1f); } if (b.ActualCornerSE > 0 && (b.BorderBottomStyle == CssConstants.None || b.BorderBottomStyle == CssConstants.Hidden)) { path.AddArc(r.Right - b.ActualCornerSE * 2 - b.ActualBorderRightWidth / 2, r.Bottom - b.ActualCornerSE * 2 - b.ActualBorderBottomWidth / 2, b.ActualCornerSE * 2, b.ActualCornerSE * 2, 0f, 90f); } else { path.AddLine(r.Right - b.ActualBorderRightWidth / 2, r.Bottom - b.ActualCornerSE - b.ActualBorderBottomWidth / 2 - .1f, r.Right - b.ActualBorderRightWidth / 2, r.Bottom - b.ActualCornerSE - b.ActualBorderBottomWidth / 2); } } break; case Border.Left: if (b.ActualCornerNW > 0 || b.ActualCornerSW > 0) { path = new GraphicsPath(); if (b.ActualCornerSW > 0 && (b.BorderTopStyle == CssConstants.None || b.BorderTopStyle == CssConstants.Hidden)) { path.AddArc(r.Left + b.ActualBorderLeftWidth / 2, r.Bottom - b.ActualCornerSW * 2 - b.ActualBorderBottomWidth / 2, b.ActualCornerSW * 2, b.ActualCornerSW * 2, 90f, 90f); } else { path.AddLine(r.Left + b.ActualBorderLeftWidth / 2, r.Bottom - b.ActualCornerSW - b.ActualBorderBottomWidth / 2, r.Left + b.ActualBorderLeftWidth / 2, r.Bottom - b.ActualCornerSW - b.ActualBorderBottomWidth / 2 - .1f); } if (b.ActualCornerNW > 0 && (b.BorderBottomStyle == CssConstants.None || b.BorderBottomStyle == CssConstants.Hidden)) { path.AddArc(r.Left + b.ActualBorderLeftWidth / 2, r.Top + b.ActualBorderTopWidth / 2, b.ActualCornerNW * 2, b.ActualCornerNW * 2, 180f, 90f); } else { path.AddLine(r.Left + b.ActualBorderLeftWidth / 2, r.Top + b.ActualCornerNW + b.ActualBorderTopWidth / 2 + .1f, r.Left + b.ActualBorderLeftWidth / 2, r.Top + b.ActualCornerNW + b.ActualBorderTopWidth / 2); } } break; } return(path); }
private void layoutOptionFive(List<String> _temporary) { mbordercontrol = new PaperBorderControl(); mBorders = new List<Border>(); mImagecontrol = new PaperImageControl(); vImages = new List<Image>(); cutLine(); cut_line.Width = 660 + 180; //分割线加长 imageleft = 130 - 85; borderleft = 120 - 85; // 载入选项 for (int i = 0; i < _temporary.Count; i++)// 8 是选项 ps:在内部就可以显示border 放外部循环就不行 { //border b = mbordercontrol.GenBorder(102, 94); mBorders.Add(b); PapertestCanvas.Children.Add(b); //image im = new Image(); im.Stretch = Stretch.Fill; System.Drawing.Image picc = System.Drawing.Image.FromFile("Paper\\PaperRes\\Test\\PaS\\" + _temporary[i] + ".bmp"); System.Drawing.Bitmap bmpc = new System.Drawing.Bitmap(picc); IntPtr hBitmapc = bmpc.GetHbitmap(); System.Windows.Media.ImageSource WpfBitmapc = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmapc, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(82, 74));//FromEmptyOptions() 源图像大小 im.Source = WpfBitmapc; //im = mImagecontrol.GetImage(82, 74); //BitmapImage bitim = new BitmapImage(); //bitim.BeginInit(); //bitim.UriSource = new Uri("\\PCAT;component\\Images\\" + _temporary[i] + ".bmp", UriKind.Relative); //bitim.EndInit(); //im.Stretch = Stretch.Fill; //im.Source = bitim; vImages.Add(im); PapertestCanvas.Children.Add(im); //Event im.MouseDown += new MouseButtonEventHandler(im_MouseDown); im.MouseEnter += new MouseEventHandler(im_MouseEnter); im.MouseLeave += new MouseEventHandler(im_MouseLeave); Canvas.SetTop(b, actual_y + bordertop);// Canvas.SetLeft(b, actual_x + borderleft);// borderleft = borderleft + borderadd; Canvas.SetTop(im, actual_y + imagetop);// Canvas.SetLeft(im, actual_x + imageleft);// imageleft = imageleft + imageadd; }//---for }
protected override void ChangeCursor(Border DisplayArea) { DisplayArea.Cursor = Cursors.SizeNESW; }
void LoadContent() { // 背景 SetBinding(BackgroundProperty, new Binding { Path = new PropertyPath("Background") }); // 展开/折叠按钮 ContentPresenter pre = new ContentPresenter { Width = _btnWidth }; pre.SetBinding(ContentPresenter.ContentProperty, new Binding { Path = new PropertyPath("ExpandedUI") }); Children.Add(pre); // 多选框 if (_owner.SelectionMode == SelectionMode.Multiple) { var tbCheck = new TextBlock { VerticalAlignment = VerticalAlignment.Center, FontFamily = Res.IconFont }; tbCheck.SetBinding(TextBlock.TextProperty, new Binding { Path = new PropertyPath("IsSelected"), Converter = new IsSelectedIconConverter(), }); Children.Add(tbCheck); } // 内容 UIElement ui = null; if (_owner.View is DataTemplate template) { ui = template.LoadContent() as UIElement; } else if (_owner.View is DataTemplateSelector selector && _row != null) { // 模板选择器 var temp = selector.SelectTemplate(_row); if (temp != null) { ui = temp.LoadContent() as UIElement; } } if (ui != null) { Children.Add(ui); } // 上下文菜单 Menu menu = Ex.GetMenu(_owner); if (menu != null) { AttachContextMenu(menu); } // 分割线及选择背景 Border bd; if (_owner.ShowRowLine) { bd = new Border { BorderThickness = new Thickness(0, 0, 0, 1), BorderBrush = Res.浅灰边框, IsHitTestVisible = false } } ; else { bd = new Border { IsHitTestVisible = false } }; if (_owner.SelectionMode != SelectionMode.None) { bd.SetBinding(Border.BackgroundProperty, new Binding { Path = new PropertyPath("IsSelected"), Converter = new SelectedBackgroundConverter(), }); } Children.Add(bd); // 交互背景 _rcPointer = new Rectangle { IsHitTestVisible = false }; Children.Add(_rcPointer); // 附加交互事件,iOS暂不支持Tapped事件! PointerPressed += OnPointerPressed; PointerMoved += OnPointerMoved; PointerReleased += OnPointerReleased; PointerEntered += OnPointerEntered; PointerExited += OnPointerExited; DoubleTapped += (s, e) => _row.OnDoubleTapped(); // android上快速滑动时未触发PointerMoved! #if ANDROID _owner.Scroll.ViewChanged += (s, e) => _rcPointer.Fill = null; #endif } void OnPointerPressed(object sender, PointerRoutedEventArgs e) { // 右键无效 if (e.IsRightButton()) { return; } _rcPointer.Fill = _owner.PressedBrush; if (CapturePointer(e.Pointer)) { e.Handled = true; _pointerID = e.Pointer.PointerId; _ptLast = e.GetCurrentPoint(null).Position; } } void OnPointerMoved(object sender, PointerRoutedEventArgs e) { if (_pointerID != e.Pointer.PointerId) { return; } // 允许有短距离移动 e.Handled = true; Point cur = e.GetCurrentPoint(null).Position; if (Math.Abs(cur.X - _ptLast.X) > 4 || Math.Abs(cur.Y - _ptLast.Y) > 4) { ReleasePointerCapture(e.Pointer); _pointerID = null; if (e.IsTouch()) { _rcPointer.Fill = null; } } } void OnPointerReleased(object sender, PointerRoutedEventArgs e) { if (_pointerID != e.Pointer.PointerId) { return; } e.Handled = true; _rcPointer.Fill = null; ReleasePointerCapture(e.Pointer); _pointerID = null; _row.OnClick(); } void OnPointerEntered(object sender, PointerRoutedEventArgs e) { if (!_menuOpened && e.IsMouse() && _row.IsSelected.HasValue && !_row.IsSelected.Value) { _rcPointer.Fill = _owner.EnteredBrush; } } void OnPointerExited(object sender, PointerRoutedEventArgs e) { if (!_menuOpened) { _rcPointer.Fill = null; } } /// <summary> /// 缩进不同时必须重新布局,不然有时不对! /// </summary> /// <param name="p_indent"></param> void SetIndent(double p_indent) { if (p_indent != _indent) { _indent = p_indent; InvalidateArrange(); } } void OnValueChanged() { DataContext = null; DataContext = _row; } /// <summary> /// 滚动时异步设置DataContext,提高流畅性 /// </summary> async void SetDataContextAsync() { await Dispatcher.RunAsync(CoreDispatcherPriority.Low, new DispatchedHandler(() => DataContext = _row)); } #region 文菜单 /// <summary> /// 附加上下文菜单触发事件 /// </summary> /// <param name="p_menu"></param> void AttachContextMenu(Menu p_menu) { if (p_menu.TriggerEvent == TriggerEvent.RightTapped) { RightTapped += (s, e) => OpenContextMenu(e.GetPosition(null)); } else if (p_menu.TriggerEvent == TriggerEvent.LeftTapped) { Tapped += (s, e) => OpenContextMenu(e.GetPosition(null)); } else { CreateMenuButton(p_menu); } } /// <summary> /// 显示上下文菜单 /// </summary> /// <param name="p_pos"></param> /// <param name="p_tgt"></param> async void OpenContextMenu(Point p_pos, FrameworkElement p_tgt = null) { Menu menu = Ex.GetMenu(_owner); if (menu == null) { return; } menu.TargetData = _row.Data; menu.Closed += OnMenuClosed; if (await menu.OpenContextMenu(p_pos, p_tgt)) { _menuOpened = true; _rcPointer.Fill = Res.深黄遮罩; } } void CreateMenuButton(Menu p_menu) { // 自定义按钮触发 _btnMenu = new Button { Content = "\uE03F", Style = Res.字符按钮, Foreground = Res.深灰边框 }; _btnMenu.Click += (s, e) => OpenContextMenu(new Point(), (Button)s); if (!Kit.IsPhoneUI) { p_menu.Placement = MenuPosition.OuterLeftTop; } Children.Add(_btnMenu); } void OnMenuClosed(object sender, EventArgs e) { // 关闭上下文菜单时移除行醒目颜色 ((Menu)sender).Closed -= OnMenuClosed; _rcPointer.Fill = null; _menuOpened = false; } #endregion }
public OpacityMaskExample() { // // Create a GeometryDrawing. // // Define the drawing's contents. PathFigure pLineFigure = new PathFigure(); pLineFigure.StartPoint = new Point(25, 25); PolyLineSegment pLineSegment = new PolyLineSegment(); pLineSegment.Points.Add(new Point(0, 50)); pLineSegment.Points.Add(new Point(25, 75)); pLineSegment.Points.Add(new Point(50, 50)); pLineSegment.Points.Add(new Point(25, 25)); pLineSegment.Points.Add(new Point(25, 0)); pLineFigure.Segments.Add(pLineSegment); PathGeometry pGeometry = new PathGeometry(); pGeometry.Figures.Add(pLineFigure); GeometryDrawing drawing1 = new GeometryDrawing( Brushes.Lime, new Pen(Brushes.Black, 10), pGeometry ); // // Create another GeometryDrawing. // GeometryDrawing drawing2 = new GeometryDrawing( Brushes.Lime, new Pen(Brushes.Black, 2), new EllipseGeometry(new Point(10, 10), 5, 5) ); // Create the DrawingGroup and add the // geometry drawings. DrawingGroup aDrawingGroup = new DrawingGroup(); aDrawingGroup.Children.Add(drawing1); aDrawingGroup.Children.Add(drawing2); // // Define an opacity mask and apply it to the // drawing group. // RadialGradientBrush opacityMask = new RadialGradientBrush(); opacityMask.GradientStops.Add(new GradientStop(Color.FromArgb(255, 0, 0, 0), 0.0)); opacityMask.GradientStops.Add(new GradientStop(Color.FromArgb(0, 0, 0, 0), 0.55)); opacityMask.GradientStops.Add(new GradientStop(Color.FromArgb(255, 0, 0, 0), 0.65)); opacityMask.GradientStops.Add(new GradientStop(Color.FromArgb(0, 0, 0, 0), 0.75)); opacityMask.GradientStops.Add(new GradientStop(Color.FromArgb(255, 0, 0, 0), 0.80)); opacityMask.GradientStops.Add(new GradientStop(Color.FromArgb(0, 0, 0, 0), 0.90)); opacityMask.GradientStops.Add(new GradientStop(Color.FromArgb(255, 0, 0, 0), 1.0)); aDrawingGroup.OpacityMask = opacityMask; // Use an Image control and a DrawingImage to // display the drawing. DrawingImage aDrawingImage = new DrawingImage(aDrawingGroup); // Freeze the DrawingImage for performance benefits. aDrawingImage.Freeze(); Image anImage = new Image(); anImage.Source = aDrawingImage; anImage.Stretch = Stretch.None; anImage.HorizontalAlignment = HorizontalAlignment.Left; // Create a border around the images and add it to the // page. Border imageBorder = new Border(); imageBorder.BorderBrush = Brushes.Gray; imageBorder.BorderThickness = new Thickness(1); imageBorder.VerticalAlignment = VerticalAlignment.Top; imageBorder.HorizontalAlignment = HorizontalAlignment.Left; imageBorder.Margin = new Thickness(20); imageBorder.Child = anImage; this.Background = Brushes.White; this.Margin = new Thickness(20); this.Content = imageBorder; }
public CreateUniverseScreen(ScreenComponent manager) : base(manager) { Manager = manager; settings = manager.Game.Settings; Padding = new Border(0, 0, 0, 0); Title = Languages.OctoClient.CreateUniverse; SetDefaultBackground(); Panel panel = new Panel(manager); panel.VerticalAlignment = VerticalAlignment.Stretch; panel.HorizontalAlignment = HorizontalAlignment.Stretch; panel.Margin = Border.All(50); panel.Background = new BorderBrush(Color.White * 0.5f); panel.Padding = Border.All(10); Controls.Add(panel); Grid grid = new Grid(manager); grid.VerticalAlignment = VerticalAlignment.Stretch; grid.HorizontalAlignment = HorizontalAlignment.Stretch; panel.Controls.Add(grid); grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Auto }); grid.Columns.Add(new ColumnDefinition() { Width = 1, ResizeMode = ResizeMode.Parts }); nameInput = GetTextbox(); nameInput.TextChanged += (s, e) => { createButton.Visible = !string.IsNullOrEmpty(e.NewValue); }; AddLabeledControl(grid, string.Format("{0}: ", Languages.OctoClient.Name), nameInput); seedInput = GetTextbox(); AddLabeledControl(grid, string.Format("{0}: ", Languages.OctoClient.Seed), seedInput); createButton = Button.TextButton(manager, Languages.OctoClient.Create); createButton.HorizontalAlignment = HorizontalAlignment.Right; createButton.VerticalAlignment = VerticalAlignment.Bottom; createButton.Visible = false; createButton.LeftMouseClick += (s, e) => { if (string.IsNullOrEmpty(nameInput.Text)) { return; } int?seed = null; int textseed; if (int.TryParse(seedInput.Text, out textseed)) { seed = textseed; } manager.Player.RemovePlayer(); Guid guid = Manager.Game.Simulation.NewGame(nameInput.Text, seed); settings.Set("LastUniverse", guid.ToString()); manager.Game.Player.InsertPlayer(); manager.NavigateToScreen(new GameScreen(manager)); }; panel.Controls.Add(createButton); }
private void AddAnchorProperty(int AnchorId, out TextBox Tbx, out CheckBox Cbx) { Border newBorder = new Border(); newBorder.VerticalAlignment = VerticalAlignment.Top; newBorder.BorderThickness = new Thickness(1, 1, 1, 1); newBorder.Background = GetColor(55); newBorder.BorderBrush = Brushes.Gainsboro; newBorder.Margin = new Thickness(10, 0, 10, 0); newBorder.Height = 55; Grid newGrid = new Grid(); newGrid.Width = Double.NaN; newGrid.Margin = new Thickness(0, 0, 0, 0); newBorder.Child = newGrid; newBorder.BorderBrush = GetColor(146); ColumnDefinition c1 = new ColumnDefinition(); c1.Width = new GridLength(113, GridUnitType.Star); ColumnDefinition c2 = new ColumnDefinition(); c2.Width = new GridLength(114, GridUnitType.Star); newGrid.ColumnDefinitions.Add(c1); newGrid.ColumnDefinitions.Add(c2); StackPanel sp = new StackPanel(); Grid.SetColumn(sp, 0); sp.Orientation = Orientation.Horizontal; sp.VerticalAlignment = VerticalAlignment.Center; sp.Height = 30; sp.Margin = new Thickness(0, 2, 0, 0); newGrid.Children.Add(sp); Label lbl = new Label(); lbl.Content = "Num. textures"; lbl.VerticalContentAlignment = VerticalAlignment.Center; lbl.Foreground = GetColor(146); sp.Children.Add(lbl); TextBox tbx = new TextBox(); tbx.HorizontalAlignment = HorizontalAlignment.Left; tbx.Height = 26; tbx.TextWrapping = TextWrapping.Wrap; tbx.Text = "1"; tbx.Background = GetColor(146); tbx.BorderBrush = GetColor(100); sp.VerticalAlignment = VerticalAlignment.Center; tbx.Width = 89; tbx.PreviewTextInput += NumberValidationTextBox; tbx.TextChanged += edAnchorNumTex_TextChanged; sp.Children.Add(tbx); StackPanel sp2 = new StackPanel(); Grid.SetColumn(sp2, 1); sp2.Orientation = Orientation.Horizontal; sp2.VerticalAlignment = VerticalAlignment.Center; sp2.HorizontalAlignment = HorizontalAlignment.Right; sp2.Height = 20; sp2.Width = 108; sp2.Margin = new Thickness(0, 15, 0, 0); newGrid.Children.Add(sp2); CheckBox cbx = new CheckBox(); cbx.Content = "PRF__ALPHA"; cbx.Foreground = GetColor(146); cbx.Click += chkRenderFlag_Click; sp2.HorizontalAlignment = HorizontalAlignment.Right; sp2.Height = 20; sp2.Width = 108; cbx.Background = GetColor(146); sp2.VerticalAlignment = VerticalAlignment.Center; sp2.Children.Add(cbx); newBorder.Child = newGrid; StackPanel Parent = getAnchorParentByID(AnchorId); if (Parent != null) { Parent.Children.Insert(Parent.Children.Count - 1, newBorder); } Tbx = tbx; Cbx = cbx; }
void AddDrawable(StackPanel MainPanel, int DrawableIndex, out TextBox tbNumTex, out TextBox tbMask, out ComboBox cbxTextId) { MainPanel.Background = GetColor(55); Border newBorder = new Border(); newBorder.VerticalAlignment = VerticalAlignment.Top; newBorder.Margin = new Thickness(10, 0, 10, 0); newBorder.Background = GetColor(50); newBorder.BorderBrush = GetColor(146); newBorder.BorderThickness = new Thickness(1); Grid newGrid = new Grid(); newGrid.Height = 70; newGrid.Width = Double.NaN; newGrid.Background = GetColor(50); newGrid.RowDefinitions.Add(new RowDefinition()); newGrid.RowDefinitions.Add(new RowDefinition()); ColumnDefinition c1 = new ColumnDefinition(); c1.Width = new GridLength(184, GridUnitType.Star); ColumnDefinition c2 = new ColumnDefinition(); c2.Width = new GridLength(103, GridUnitType.Star); ColumnDefinition c3 = new ColumnDefinition(); c3.Width = new GridLength(166, GridUnitType.Star); newGrid.ColumnDefinitions.Add(c1); newGrid.ColumnDefinitions.Add(c2); newGrid.ColumnDefinitions.Add(c3); Label lbl = new Label(); Grid.SetRow(lbl, 0); Grid.SetColumn(lbl, 0); lbl.FontSize = 14; lbl.Content = "Drawable" + DrawableIndex.ToString(); lbl.Foreground = GetColor(200); newGrid.Children.Add(lbl); StackPanel sp = new StackPanel(); Grid.SetRow(sp, 1); Grid.SetColumn(sp, 0); sp.Orientation = Orientation.Horizontal; sp.VerticalAlignment = VerticalAlignment.Center; sp.Width = Double.NaN; sp.Height = 30; sp.Margin = new Thickness(0, 3, 0, 2); newGrid.Children.Add(sp); Label lbl1 = new Label(); lbl1.Content = "Num. textures"; lbl1.Foreground = GetColor(146); sp.Children.Add(lbl1); TextBox tbx = new TextBox(); tbx.HorizontalAlignment = HorizontalAlignment.Left; tbx.VerticalAlignment = VerticalAlignment.Top; tbx.Height = 26; tbx.Width = 60; tbx.TextWrapping = TextWrapping.Wrap; tbx.Text = "1"; tbx.BorderBrush = GetColor(100); tbx.Background = GetColor(146); tbx.PreviewTextInput += NumberValidationTextBox; tbx.TextChanged += edNumTextures_TextChanged; tbNumTex = tbx; sp.Children.Add(tbx); StackPanel sp2 = new StackPanel(); Grid.SetRow(sp2, 1); Grid.SetColumn(sp2, 1); sp2.Orientation = Orientation.Horizontal; sp2.VerticalAlignment = VerticalAlignment.Center; sp2.Height = 30; sp2.HorizontalAlignment = HorizontalAlignment.Right; sp2.Margin = new Thickness(0, 3, 0, 2); newGrid.Children.Add(sp2); Label lbl2 = new Label(); lbl2.Content = "Mask"; lbl2.Foreground = GetColor(146); sp2.Children.Add(lbl2); TextBox tbx2 = new TextBox(); tbx2.HorizontalAlignment = HorizontalAlignment.Left; tbx2.VerticalAlignment = VerticalAlignment.Top; tbx2.Height = 26; tbx2.Width = 60; tbx2.TextWrapping = TextWrapping.Wrap; tbx2.Text = "1"; tbx2.BorderBrush = GetColor(100); tbx2.Background = GetColor(146); tbx2.PreviewTextInput += NumberValidationTextBox; tbx2.TextChanged += edMask_TextChanged; tbMask = tbx2; sp2.Children.Add(tbx2); StackPanel sp3 = new StackPanel(); Grid.SetRow(sp3, 1); Grid.SetColumn(sp3, 2); sp3.Orientation = Orientation.Horizontal; sp3.VerticalAlignment = VerticalAlignment.Center; sp3.Height = 30; sp3.HorizontalAlignment = HorizontalAlignment.Right; sp3.Margin = new Thickness(32, 3, 0, 2); newGrid.Children.Add(sp3); Label lbl3 = new Label(); lbl3.Width = 41; lbl3.Content = "TexId"; lbl3.Foreground = GetColor(146); sp3.Children.Add(lbl3); ComboBox cbx = new ComboBox(); cbx.Width = 87; cbx.Margin = new Thickness(0, 0, 5, 0); cbx.VerticalAlignment = VerticalAlignment.Top; cbx.Height = 26; cbx.ItemsSource = new List <string> { "0", "1", "2", "3", "4", "5", "6", "7" }; cbx.SelectionChanged += cbxHeadTextId_SelectionChanged; cbxTextId = cbx; sp3.Children.Add(cbx); newBorder.Child = newGrid; MainPanel.Children.Insert(MainPanel.Children.Count - 1, newBorder); }
private int AddAnchor(string AnchorName) { Border newBorder = new Border(); newBorder.Background = GetColor(50); newBorder.BorderBrush = GetColor(146); newBorder.VerticalAlignment = VerticalAlignment.Top; //newBorder.Background = Brushes.GhostWhite; //newBorder.BorderBrush = Brushes.Gainsboro; newBorder.Margin = new Thickness(10, 10, 10, 0); newBorder.BorderThickness = new Thickness(1, 1, 1, 1); newBorder.Height = Double.NaN; brdAnchors.Children.Add(newBorder); StackPanel sp = new StackPanel(); sp.Height = Double.NaN; sp.VerticalAlignment = VerticalAlignment.Top; newBorder.Child = sp; StackPanel sp2 = new StackPanel(); sp2.Orientation = Orientation.Horizontal; sp2.VerticalAlignment = VerticalAlignment.Center; sp2.Height = 30; sp2.Margin = new Thickness(0, 5, 0, 0); sp.Children.Add(sp2); Label lbl = new Label(); lbl.FontSize = 14; lbl.Content = "Anchor:"; lbl.Foreground = GetColor(146); sp2.Children.Add(lbl); ComboBox cbx = new ComboBox(); cbx.Width = 145; cbx.Margin = new Thickness(0, 0, 5, 0); cbx.VerticalAlignment = VerticalAlignment.Top; cbx.Height = 26; cbx.ItemsSource = new List <string> { "HEAD", "EYES", "EARS", "MOUTH", "LEFT_HAND", "RIGHT_HAND", "LEFT_WRIST", "RIGHT_WRIST", "HIP", "LEFT_FOOT", "RIGHT_FOOT", "UNK_604819740", "UNK_2358626934" }; cbx.SelectionChanged += cbxAnchorId_SelectionChanged; sp2.Children.Add(cbx); Button btn3 = new Button(); btn3.Width = 110; btn3.Margin = new Thickness(0, 0, 0, 0); btn3.VerticalAlignment = VerticalAlignment.Top; btn3.Height = 26; btn3.Content = "Delete Anchor"; btn3.Background = GetColor(64); btn3.Foreground = GetColor(146); btn3.BorderBrush = GetColor(137); btn3.HorizontalContentAlignment = HorizontalAlignment.Center; btn3.Click += AnchorPanelRemoveClick; sp2.Children.Add(btn3); Grid newGrid = new Grid(); newGrid.Height = 40; newGrid.Width = Double.NaN; sp.Children.Add(newGrid); ColumnDefinition c1 = new ColumnDefinition(); c1.Width = new GridLength(48, GridUnitType.Star); ColumnDefinition c2 = new ColumnDefinition(); c2.Width = new GridLength(71, GridUnitType.Star); newGrid.ColumnDefinitions.Add(c1); newGrid.ColumnDefinitions.Add(c2); Button btn = new Button(); btn.Content = "Add prop"; btn.HorizontalAlignment = HorizontalAlignment.Right; btn.Margin = new Thickness(0, 5, 114, 5); btn.Width = 90; btn.Background = GetColor(64); btn.Foreground = GetColor(146); btn.BorderBrush = GetColor(137); btn.Click += AddAnchorPropertyClick; Grid.SetColumn(btn, 1); newGrid.Children.Add(btn); Button btn2 = new Button(); btn2.Content = "Remove"; btn2.HorizontalAlignment = HorizontalAlignment.Right; btn2.Margin = new Thickness(0, 5, 10, 5); btn2.Width = 90; btn2.Background = GetColor(64); btn2.Foreground = GetColor(146); btn2.BorderBrush = GetColor(137); btn2.Click += RemoveAnchorPropertyClick; Grid.SetColumn(btn2, 1); newGrid.Children.Add(btn2); CheckRemoveAnchorPropertyButton(btn2, false); newBorder.Child = sp; return(brdAnchors.Children.Count - 1); }
private void CreateAndShowMainWindow() { // <Snippet1> // Create the application's main window mainWindow = new Window(); mainWindow.Title = "DockPanel Sample"; // Create the DockPanel DockPanel myDockPanel = new DockPanel(); myDockPanel.LastChildFill = true; // Define the child content Border myBorder1 = new Border(); myBorder1.Height = 25; myBorder1.Background = Brushes.SkyBlue; myBorder1.BorderBrush = Brushes.Black; myBorder1.BorderThickness = new Thickness(1); DockPanel.SetDock(myBorder1, Dock.Top); TextBlock myTextBlock1 = new TextBlock(); myTextBlock1.Foreground = Brushes.Black; myTextBlock1.Text = "Dock = Top"; myBorder1.Child = myTextBlock1; Border myBorder2 = new Border(); myBorder2.Height = 25; myBorder2.Background = Brushes.SkyBlue; myBorder2.BorderBrush = Brushes.Black; myBorder2.BorderThickness = new Thickness(1); DockPanel.SetDock(myBorder2, Dock.Top); TextBlock myTextBlock2 = new TextBlock(); myTextBlock2.Foreground = Brushes.Black; myTextBlock2.Text = "Dock = Top"; myBorder2.Child = myTextBlock2; Border myBorder3 = new Border(); myBorder3.Height = 25; myBorder3.Background = Brushes.LemonChiffon; myBorder3.BorderBrush = Brushes.Black; myBorder3.BorderThickness = new Thickness(1); DockPanel.SetDock(myBorder3, Dock.Bottom); TextBlock myTextBlock3 = new TextBlock(); myTextBlock3.Foreground = Brushes.Black; myTextBlock3.Text = "Dock = Bottom"; myBorder3.Child = myTextBlock3; Border myBorder4 = new Border(); myBorder4.Width = 200; myBorder4.Background = Brushes.PaleGreen; myBorder4.BorderBrush = Brushes.Black; myBorder4.BorderThickness = new Thickness(1); DockPanel.SetDock(myBorder4, Dock.Left); TextBlock myTextBlock4 = new TextBlock(); myTextBlock4.Foreground = Brushes.Black; myTextBlock4.Text = "Dock = Left"; myBorder4.Child = myTextBlock4; Border myBorder5 = new Border(); myBorder5.Background = Brushes.White; myBorder5.BorderBrush = Brushes.Black; myBorder5.BorderThickness = new Thickness(1); TextBlock myTextBlock5 = new TextBlock(); myTextBlock5.Foreground = Brushes.Black; myTextBlock5.Text = "This content will Fill the remaining space"; myBorder5.Child = myTextBlock5; // Add child elements to the DockPanel Children collection myDockPanel.Children.Add(myBorder1); myDockPanel.Children.Add(myBorder2); myDockPanel.Children.Add(myBorder3); myDockPanel.Children.Add(myBorder4); myDockPanel.Children.Add(myBorder5); // Add the parent Canvas as the Content of the Window Object mainWindow.Content = myDockPanel; mainWindow.Show(); //</Snippet1> }
private Stylesheet CreateStyleSheet() { var stylesheet = new Stylesheet(); var fontNameRobotoRegular = "Roboto Regular"; var fontSize10D = 10D; var fontColorBlue = "FF099cce"; var fontColorBlack = "FF000000"; var fontColorLightGrey = "FF404040"; var fontBold = new Bold(); #region Font 0 settings (10px, "RobotoRegular", "LightGrey") (RowsHeadersValuesEntity) var font0 = new Font(); font0.Append(new FontSize { Val = fontSize10D }); font0.Append(new FontName { Val = fontNameRobotoRegular }); font0.Append(new Color { Rgb = HexBinaryValue.FromString(fontColorLightGrey) }); #endregion #region Font 1 settings (10px, "RobotoRegular", "Blue") (RowHeaderNameTotalFor + RowHeaderNameTotal + RowHeaderNameGroupByDefault ) var font1 = new Font(); font1.Append(new FontSize { Val = fontSize10D }); font1.Append(new FontName { Val = fontNameRobotoRegular }); font1.Append(new Color { Rgb = HexBinaryValue.FromString(fontColorBlue) }); #endregion #region Font 2 settings (10px, "RobotoRegular", "Black") (Row period date) var font2 = new Font(); font2.Append(new Bold()); font2.Append(new FontSize { Val = fontSize10D }); font2.Append(new FontName { Val = fontNameRobotoRegular }); font2.Append(new Color { Rgb = HexBinaryValue.FromString(fontColorBlack) }); #endregion #region Font 3 settings (10px, "RobotoRegular", "Black", bold) (Row entity headers names + Row total HeaderValue + Row totalFor HeaderValue) var font3 = new Font(); //font3.Append(fontBold); font3.Append(new FontSize { Val = fontSize10D }); font3.Append(new FontName { Val = fontNameRobotoRegular }); font3.Append(new Color { Rgb = HexBinaryValue.FromString(fontColorBlack) }); #endregion #region Add fonts, fills, borders. // Add Fonts. var fonts = new Fonts(); fonts.Append(font0); fonts.Append(font1); fonts.Append(font2); fonts.Append(font3); // Add fills. var fill0 = new Fill(); var fill1 = new Fill(); // var fill2 = new Fill(); // var fill3 = new Fill(); // var fill4 = new Fill(); // var fills = new Fills(); fills.Append(fill0); fills.Append(fill1); fills.Append(fill2); fills.Append(fill3); fills.Append(fill4); #region (Nested headers) Fill 3 (grey) var backgroundColorLightGray = "FFf1f1f1"; //#f1f1f1 var solidlightBlue = new PatternFill { PatternType = PatternValues.Solid, ForegroundColor = new ForegroundColor { Rgb = HexBinaryValue.FromString(backgroundColorLightGray) } }; //solidlightBlue.ForegroundColor = new ForegroundColor { Rgb = HexBinaryValue.FromString("FF099cce") }; //solidlightBlue.BackgroundColor = new BackgroundColor { Indexed = 64 }; fill3.PatternFill = solidlightBlue; #endregion #region (Nested rows) Fill 4 (white) var solidWhite = new PatternFill { //PatternType = PatternValues.Solid ForegroundColor = new ForegroundColor { Rgb = HexBinaryValue.FromString("FFFFFFFF") } }; //solidWhite.ForegroundColor = new ForegroundColor { Rgb = HexBinaryValue.FromString("FFFFFFFF") }; //solidWhite.BackgroundColor = new BackgroundColor { Indexed = 64 }; fill4.PatternFill = solidWhite; #endregion //#region (Nested headers) Fill 3 (blue) ////#f1f1f1 //var solidlightBlue = new PatternFill //{ // PatternType = PatternValues.Solid, // ForegroundColor = new ForegroundColor // { // Rgb = HexBinaryValue.FromString("FF099cce") // } //}; ////solidlightBlue.ForegroundColor = new ForegroundColor { Rgb = HexBinaryValue.FromString("FF099cce") }; ////solidlightBlue.BackgroundColor = new BackgroundColor { Indexed = 64 }; //fill3.PatternFill = solidlightBlue; //#endregion // Add Borders. var border0 = new Border(); var borders = new Borders(); borders.Append(border0); #endregion var verticalAligmentTop = new EnumValue <VerticalAlignmentValues>(VerticalAlignmentValues.Top); var verticalAligmentCenter = new EnumValue <VerticalAlignmentValues>(VerticalAlignmentValues.Center); var verticalAligmentBottom = new EnumValue <VerticalAlignmentValues>(VerticalAlignmentValues.Bottom); // CellFormats. var cellformat0 = new CellFormat { FontId = 0, Alignment = new Alignment { WrapText = true, Vertical = verticalAligmentCenter }, /*FillId = 0,*/ }; // RowHeaderNameGroupByDefault + RowHeaderNameTotal + RowHeaderNameTotalFor var cellformat1 = new CellFormat { FontId = 1, Alignment = new Alignment { WrapText = true, Vertical = verticalAligmentCenter } }; // RowHeaderValueTotal + RowHeaderValueTotalFor var cellformat2 = new CellFormat { FontId = 2, Alignment = new Alignment { WrapText = true, Vertical = verticalAligmentCenter }, FillId = 3, }; // RowHeaderNamesEntity var cellformat3 = new CellFormat { FontId = 2, Alignment = new Alignment { WrapText = true, Vertical = verticalAligmentCenter } }; // RowsHeadersValuesEntity var cellformat4 = new CellFormat { FontId = 0, Alignment = new Alignment { WrapText = true, Vertical = verticalAligmentCenter } }; var cellformat5 = new CellFormat { FontId = 0, Alignment = new Alignment { WrapText = true, Vertical = verticalAligmentCenter, Horizontal = HorizontalAlignmentValues.Left, } }; // (Nested rows, columns: Estimated, Actual) var cellformat6 = new CellFormat { FontId = 3, Alignment = new Alignment { WrapText = true, Vertical = verticalAligmentCenter, Horizontal = HorizontalAlignmentValues.Left, } }; // RowTotal HeaderValue + TotalFor HeaderValue // Add CellFormats. var cellformats = new CellFormats(); cellformats.Append(cellformat0); cellformats.Append(cellformat1); cellformats.Append(cellformat2); cellformats.Append(cellformat3); cellformats.Append(cellformat4); cellformats.Append(cellformat5); cellformats.Append(cellformat6); // Add FONTS, FILLS, BORDERS & CellFormats to stylesheet. (Preserve the ORDER) stylesheet.Append(fonts); stylesheet.Append(fills); stylesheet.Append(borders); stylesheet.Append(cellformats); return(stylesheet); }
public FillBehaviorExample() { // Create a name scope for the page. NameScope.SetNameScope(this, new NameScope()); WindowTitle = "FillBehavior Example"; StackPanel myStackPanel = new StackPanel(); myStackPanel.Margin = new Thickness(20); Border myBorder = new Border(); SolidColorBrush mySolidColorBrush = new SolidColorBrush(Color.FromArgb(153, 255, 255, 255)); myBorder.Background = mySolidColorBrush; TextBlock myTextBlock = new TextBlock(); myTextBlock.Text = "This example shows how the FillBehavior property determines how an "; myTextBlock.Text += "animation behaves after it reaches the end of its duration."; myTextBlock.Margin = new Thickness(20); myBorder.Child = myTextBlock; myStackPanel.Children.Add(myBorder); myTextBlock = new TextBlock(); myTextBlock.Text = "FillBehavior = \"Deactivate\""; myStackPanel.Children.Add(myTextBlock); // // Create the first rectangle to animate. // Rectangle deactivateAnimationRectangle = new Rectangle(); deactivateAnimationRectangle.Name = "deactivateAnimationRectangle"; this.RegisterName(deactivateAnimationRectangle.Name, deactivateAnimationRectangle); deactivateAnimationRectangle.Width = 20; deactivateAnimationRectangle.Height = 20; mySolidColorBrush = new SolidColorBrush(Color.FromArgb(170, 51, 51, 255)); deactivateAnimationRectangle.Fill = mySolidColorBrush; deactivateAnimationRectangle.HorizontalAlignment = HorizontalAlignment.Left; myStackPanel.Children.Add(deactivateAnimationRectangle); myTextBlock = new TextBlock(); myTextBlock.Text = "\nFillBehavior = \"HoldEnd\""; myStackPanel.Children.Add(myTextBlock); // // Create the second rectangle to animate. // Rectangle holdEndAnimationRectangle = new Rectangle(); holdEndAnimationRectangle.Name = "holdEndAnimationRectangle"; this.RegisterName(holdEndAnimationRectangle.Name, holdEndAnimationRectangle); holdEndAnimationRectangle.Width = 20; holdEndAnimationRectangle.Height = 20; mySolidColorBrush = new SolidColorBrush(Color.FromArgb(170, 51, 51, 255)); holdEndAnimationRectangle.Fill = mySolidColorBrush; holdEndAnimationRectangle.HorizontalAlignment = HorizontalAlignment.Left; myStackPanel.Children.Add(holdEndAnimationRectangle); // // Create an animation which reverts the width of the rectangle // back to its non-animated value. // DoubleAnimation myStopDoubleAnimation = new DoubleAnimation(); Storyboard.SetTargetName(myStopDoubleAnimation, deactivateAnimationRectangle.Name); Storyboard.SetTargetProperty(myStopDoubleAnimation, new PropertyPath(Rectangle.WidthProperty)); myStopDoubleAnimation.From = 100; myStopDoubleAnimation.To = 400; myStopDoubleAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(2000)); myStopDoubleAnimation.FillBehavior = FillBehavior.Stop; // // Create an animation which maintains the width of the rectangle at the completion of the animation. // DoubleAnimation myHoldEndDoubleAnimation = new DoubleAnimation(); Storyboard.SetTargetName(myHoldEndDoubleAnimation, holdEndAnimationRectangle.Name); Storyboard.SetTargetProperty(myHoldEndDoubleAnimation, new PropertyPath(Rectangle.WidthProperty)); myHoldEndDoubleAnimation.From = 100; myHoldEndDoubleAnimation.To = 400; myHoldEndDoubleAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(2000)); myHoldEndDoubleAnimation.FillBehavior = FillBehavior.HoldEnd; // // Create a Storyboard to contain the animations and add the animations to the Storyboard // Storyboard myStoryboard = new Storyboard(); myStoryboard.Children.Add(myStopDoubleAnimation); myStoryboard.Children.Add(myHoldEndDoubleAnimation); // // Create the button to start the animation // Button myButton = new Button(); myButton.Name = "myButton"; this.RegisterName(myButton.Name, myButton); myButton.Margin = new Thickness(0, 30, 0, 0); myButton.Content = "Restart Animations"; myButton.HorizontalAlignment = HorizontalAlignment.Left; myStackPanel.Children.Add(myButton); // // Create an EventTrigger and a BeginStoryboard action to start // the storyboard. // BeginStoryboard myBeginStoryboard = new BeginStoryboard(); myBeginStoryboard.Storyboard = myStoryboard; EventTrigger myEventTrigger = new EventTrigger(); myEventTrigger.RoutedEvent = Button.ClickEvent; myEventTrigger.SourceName = myButton.Name; myEventTrigger.Actions.Add(myBeginStoryboard); myStackPanel.Triggers.Add(myEventTrigger); this.Content = myStackPanel; }
public override DocumentPage GetPage(int pageNumber) { DocumentPage page = null; List <object> itemsSource = new List <object>(); ICollectionView viewSource = CollectionViewSource.GetDefaultView(_documentSource.ItemsSource); if (viewSource != null) { AllClientBillingReportViewModel temp = new AllClientBillingReportViewModel(); temp.Name = "=================="; temp.FileNo = "========"; temp.GenAccountTotal = "==========="; temp.TrustAccountTotal = "==========="; temp.AssignedAttorney = "============="; itemsSource.Add(temp); foreach (object item in viewSource) { itemsSource.Add(item); } } if (itemsSource != null) { int rowIndex = 1; int startPos = pageNumber * _rowsPerPage; int endPos = startPos + _rowsPerPage; //Create a new grid Grid tableGrid = CreateTable(true) as Grid; for (int index = startPos; index < endPos && index < itemsSource.Count; index++) { Console.WriteLine("Adding: " + index); if (rowIndex > 0) { object item = itemsSource[index]; int columnIndex = 0; if (_documentSource.Columns != null) { foreach (DataGridColumn column in _documentSource.Columns) { if (column.Visibility == Visibility.Visible) { AddTableCell(tableGrid, column, item, columnIndex, rowIndex); columnIndex++; } } } if (this.AlternatingRowBorderStyle != null && rowIndex % 2 == 0) { Border alernatingRowBorder = new Border(); alernatingRowBorder.Style = this.AlternatingRowBorderStyle; alernatingRowBorder.SetValue(Grid.RowProperty, rowIndex); alernatingRowBorder.SetValue(Grid.ColumnSpanProperty, columnIndex); alernatingRowBorder.SetValue(Grid.ZIndexProperty, -1); tableGrid.Children.Add(alernatingRowBorder); } } rowIndex++; } page = ConstructPage(tableGrid, pageNumber); } return(page); }
public void fromvariableCreateDocument(GenericDocumentParameters in_documentArgs, String obtainedPath) { //prepare important days list MainXMLprocessor importantDaysProcessor = new MainXMLprocessor(); importantdays alldaysListRaw = importantDaysProcessor.loadImportantDaysListFromFile(obtainedPath); Dictionary <System.DateTime, List <importantday> > importantDaysProcessed = importantDaysProcessor.getDictionaryForProcessing(alldaysListRaw); //========= DocX document = DocX.Create(in_documentArgs.documentName); // https://stackoverflow.com/a/90699/ ConsoleAppCalendar.Properties.Resources.sunrise1f305.Save("sunrisetmp.png"); ConsoleAppCalendar.Properties.Resources.sunset1f307.Save("sunsettmp.png"); // https://xceed.com/wp-content/documentation/xceed-words-for-net/Xceed.Words.NET~Xceed.Words.NET.DocX~AddImage(Stream,String).html Xceed.Words.NET.Image imgSunrise = document.AddImage("sunrisetmp.png"); Xceed.Words.NET.Picture picSunrise = imgSunrise.CreatePicture(); picSunrise.Height = (int)Math.Round(picSunrise.Height * 0.32); picSunrise.Width = (int)Math.Round(picSunrise.Width * 0.32); Xceed.Words.NET.Image imgSunset = document.AddImage("sunsettmp.png"); Xceed.Words.NET.Picture picSunset = imgSunset.CreatePicture(); picSunset.Height = (int)Math.Round(picSunset.Height * 0.38); picSunset.Width = (int)Math.Round(picSunset.Width * 0.38); System.DateTime theCurrentDate = date1; do { document.PageHeight = in_documentArgs.pageHeight; document.PageWidth = in_documentArgs.pageWidth; float btmMargin = 1.0f; float topMargin = 1.0f; float leftMargin = 1.0f; float rightMargin = 1.0f; document.MarginBottom = cmToPoints(btmMargin); document.MarginTop = cmToPoints(topMargin); document.MarginLeft = cmToPoints(leftMargin); document.MarginRight = cmToPoints(rightMargin); Table insertedTable = document.InsertTable(in_documentArgs.numrowsTable, in_documentArgs.numcolsTable); Border b = new Border(BorderStyle.Tcbs_single, BorderSize.one, 0, Color.Blue); //calculate each column width float bestColumnWidth = cmToPixels(((float)in_documentArgs.pageWidth - (float)(leftMargin + rightMargin)) / (float)(in_documentArgs.numcolsTable)); float bestRowHeightPt = (((float)in_documentArgs.pageHeight - (float)(topMargin + btmMargin)) / (float)(in_documentArgs.numrowsTable)); // Set the tables Top, Bottom, Left and Right Borders to b. insertedTable.SetBorder(TableBorderType.Top, b); insertedTable.SetBorder(TableBorderType.Bottom, b); insertedTable.SetBorder(TableBorderType.Left, b); insertedTable.SetBorder(TableBorderType.Right, b); insertedTable.SetBorder(TableBorderType.InsideH, b); insertedTable.SetBorder(TableBorderType.InsideV, b); byte currentRow = 0; byte currentCol = 0; while ((currentRow < in_documentArgs.numrowsTable) && (currentCol < in_documentArgs.numcolsTable) && (theCurrentDate <= date2)) { Table internalTable1 = insertedTable.Rows[currentRow].Cells[currentCol].InsertTable(1, 2); internalTable1.SetWidthsPercentage(new float[] { 30.0f, 70.0f }, 100.0f); /* * Paragraph yearMonthP = insertedTable.Rows[currentRow].Cells[currentCol].InsertParagraph(String.Format("{0:yyyy, MMMM}", theCurrentDate)); * Paragraph dayNumberP = insertedTable.Rows[currentRow].Cells[currentCol].InsertParagraph(String.Format("{0:dd}", theCurrentDate)); * Paragraph weekdayP = insertedTable.Rows[currentRow].Cells[currentCol].InsertParagraph(String.Format("{0:dddd}", theCurrentDate)); */ Paragraph yearMonthP = internalTable1.Rows[0].Cells[1].InsertParagraph(String.Format("{0:yyyy, MMMM}", theCurrentDate)); Paragraph dayNumberP = internalTable1.Rows[0].Cells[1].InsertParagraph(String.Format("{0:dd}", theCurrentDate)); Paragraph weekdayP = internalTable1.Rows[0].Cells[1].InsertParagraph(String.Format("{0:dddd}", theCurrentDate)); yearMonthP.Alignment = Alignment.center; yearMonthP.Font("Courier New"); dayNumberP.Alignment = Alignment.center; dayNumberP.Font("Courier New"); dayNumberP.FontSize(15); dayNumberP.Bold(); weekdayP.Alignment = Alignment.center; weekdayP.Font("Courier New"); Tuple <string, string> sunTimes = getSunsetAndSunRise(true, 2, theCurrentDate, 49.4444, 32.0597); Paragraph sunriseParagraph = internalTable1.Rows[0].Cells[0].InsertParagraph(String.Format("{0}", sunTimes.Item1)); // https://xceed.com/wp-content/documentation/xceed-words-for-net/webframe.html#Xceed.Words.NET~Xceed.Words.NET.Paragraph~InsertPicture.html sunriseParagraph.InsertPicture(picSunrise); Paragraph sunsetParagraph = internalTable1.Rows[0].Cells[0].InsertParagraph(String.Format("{0}", sunTimes.Item2)); sunsetParagraph.InsertPicture(picSunset); internalTable1.Rows[0].Cells[1].Paragraphs[0].Remove(false); internalTable1.Rows[0].Cells[0].Paragraphs[0].Remove(false); insertedTable.Rows[currentRow].Cells[currentCol].Paragraphs[0].Remove(false); insertedTable.SetColumnWidth(currentCol, bestColumnWidth); // 100*2/3pt -> 3.53 cm // x px -> bestRowHeightCm if (importantDaysProcessed.ContainsKey(theCurrentDate)) { List <importantday> eventsForCurrentDate = importantDaysProcessed[theCurrentDate]; bool holidayDisplayed = false; foreach (importantday specialevent in eventsForCurrentDate) { Paragraph eventParagraph = insertedTable.Rows[currentRow].Cells[currentCol].InsertParagraph("\u25EF " + specialevent.description); eventParagraph.Font("Courier New"); if ((specialevent.typeOfDay == "holiday") && (holidayDisplayed == false)) { holidayDisplayed = true; Paragraph officialWeekendParagraph = internalTable1.Rows[0].Cells[1].InsertParagraph("/вихідний/"); officialWeekendParagraph.Alignment = Alignment.center; officialWeekendParagraph.Font("Courier New"); officialWeekendParagraph.FontSize(7.0); officialWeekendParagraph.Bold(); } } } insertedTable.Rows[currentRow].Height = Math.Round(bestRowHeightPt * 0.88); theCurrentDate = theCurrentDate.AddDays(1.0); currentCol++; if ((currentCol >= in_documentArgs.numcolsTable) && (currentRow < in_documentArgs.numrowsTable - 1)) { currentCol = 0; currentRow++; } } if (theCurrentDate <= date2) { //document.InsertSectionPageBreak(); insertedTable.InsertPageBreakAfterSelf(); } } while (theCurrentDate <= date2); //document.InsertTable(in_documentArgs.numrowsTable, in_documentArgs.numcolsTable); document.Save(); System.IO.File.Delete("sunsettmp.png"); System.IO.File.Delete("sunrise.png"); }
private void Layout(Panel Container, ReportedReference ReportedReference, DataForm Form) { if (Form.Records.Length == 0 || Form.Header.Length == 0) { return; } Dictionary <string, int> VarIndex = new Dictionary <string, int>(); ColumnDefinition ColumnDefinition; RowDefinition RowDefinition; TextBlock TextBlock; int i, j; Brush BorderBrush = new SolidColorBrush(Colors.Gray); Brush Bg1 = new SolidColorBrush(Color.FromArgb(0x20, 0x40, 0x40, 0x40)); Brush Bg2 = new SolidColorBrush(Color.FromArgb(0x10, 0x80, 0x80, 0x80)); Border Border; Grid Grid = new Grid(); Container.Children.Add(Grid); i = 0; foreach (Field Field in Form.Header) { ColumnDefinition = new ColumnDefinition() { Width = GridLength.Auto }; Grid.ColumnDefinitions.Add(ColumnDefinition); VarIndex[Field.Var] = i++; } RowDefinition = new System.Windows.Controls.RowDefinition() { Height = GridLength.Auto }; Grid.RowDefinitions.Add(RowDefinition); foreach (Field[] Row in Form.Records) { RowDefinition = new RowDefinition() { Height = GridLength.Auto }; Grid.RowDefinitions.Add(RowDefinition); } foreach (Field Field in Form.Header) { if (!VarIndex.TryGetValue(Field.Var, out i)) { continue; } Border = new Border(); Grid.Children.Add(Border); Grid.SetColumn(Border, i); Grid.SetRow(Border, 0); Border.BorderBrush = BorderBrush; Border.BorderThickness = new Thickness(1); Border.Padding = new Thickness(5, 1, 5, 1); Border.Background = Bg1; TextBlock = new TextBlock() { FontWeight = FontWeights.Bold, Text = Field.Label }; Border.Child = TextBlock; } j = 0; foreach (Field[] Row in Form.Records) { j++; foreach (Field Field in Row) { if (!VarIndex.TryGetValue(Field.Var, out i)) { continue; } Border = new Border(); Grid.Children.Add(Border); Grid.SetColumn(Border, i); Grid.SetRow(Border, j); Border.BorderBrush = BorderBrush; Border.BorderThickness = new Thickness(1); Border.Padding = new Thickness(5, 1, 5, 1); if ((j & 1) == 1) { Border.Background = Bg2; } else { Border.Background = Bg1; } TextBlock = new TextBlock() { Text = Field.ValueString }; Border.Child = TextBlock; } } }
public override void ChangeScope(Border DisplayArea) { Mouse.OverrideCursor = DisplayArea.Cursor; }
private void ShowResizerOverlayWindow(LayoutGridResizerControl splitter) { _resizerGhost = new Border() { Background = splitter.BackgroundWhileDragging, Opacity = splitter.OpacityWhileDragging }; int indexOfResizer = InternalChildren.IndexOf(splitter); var prevChild = InternalChildren[indexOfResizer - 1] as FrameworkElement; var nextChild = GetNextVisibleChild(indexOfResizer); var prevChildActualSize = prevChild.TransformActualSizeToAncestor(); var nextChildActualSize = nextChild.TransformActualSizeToAncestor(); var prevChildModel = ( ILayoutPositionableElement )(prevChild as ILayoutControl).Model; var nextChildModel = ( ILayoutPositionableElement )(nextChild as ILayoutControl).Model; Point ptTopLeftScreen = prevChild.PointToScreenDPIWithoutFlowDirection(new Point()); Size actualSize; if (Orientation == System.Windows.Controls.Orientation.Horizontal) { actualSize = new Size( prevChildActualSize.Width - prevChildModel.CalculatedDockMinWidth() + splitter.ActualWidth + nextChildActualSize.Width - nextChildModel.CalculatedDockMinWidth(), nextChildActualSize.Height); _resizerGhost.Width = splitter.ActualWidth; _resizerGhost.Height = actualSize.Height; ptTopLeftScreen.Offset(prevChildModel.CalculatedDockMinWidth(), 0.0); } else { actualSize = new Size( prevChildActualSize.Width, prevChildActualSize.Height - prevChildModel.CalculatedDockMinHeight() + splitter.ActualHeight + nextChildActualSize.Height - nextChildModel.CalculatedDockMinHeight()); _resizerGhost.Height = splitter.ActualHeight; _resizerGhost.Width = actualSize.Width; ptTopLeftScreen.Offset(0.0, prevChildModel.CalculatedDockMinHeight()); } _initialStartPoint = splitter.PointToScreenDPIWithoutFlowDirection(new Point()) - ptTopLeftScreen; if (Orientation == System.Windows.Controls.Orientation.Horizontal) { Canvas.SetLeft(_resizerGhost, _initialStartPoint.X); } else { Canvas.SetTop(_resizerGhost, _initialStartPoint.Y); } Canvas panelHostResizer = new Canvas() { HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch, VerticalAlignment = System.Windows.VerticalAlignment.Stretch }; panelHostResizer.Children.Add(_resizerGhost); _resizerWindowHost = new Window() { SizeToContent = System.Windows.SizeToContent.Manual, ResizeMode = ResizeMode.NoResize, WindowStyle = System.Windows.WindowStyle.None, ShowInTaskbar = false, AllowsTransparency = true, Background = null, Width = actualSize.Width, Height = actualSize.Height, Left = ptTopLeftScreen.X, Top = ptTopLeftScreen.Y, ShowActivated = false, //Owner = Window.GetWindow(this), Content = panelHostResizer }; _resizerWindowHost.Loaded += (s, e) => { _resizerWindowHost.SetParentToMainWindowOf(this); }; _resizerWindowHost.Show(); }
private void im_MouseDown(object sender, MouseButtonEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { mPagePaper._Control_press = true; for (int i = 0; i < vImages.Count; i++) { if (vImages[i].Equals(sender)) { if (mPagePaper.line_num_count < 6 ) //前五道题答案提示 { //mPagePaper.t_Display.Stop(); mPagePaper.tip_display.Visibility = System.Windows.Visibility.Visible; if (_full != null) _full.Visibility = Visibility.Hidden; _full = mBorders[i]; mBorders[i].Visibility = Visibility.Visible; //显示通用 _control = true; //显示通用 opt = (i + 1).ToString();//被试选择答案 PapertestCanvas.IsEnabled = false; if (mPagePaper.correct_ans != opt ) { mPagePaper.tip_display.Foreground = Brushes.Red; mPagePaper.tip_display.Content = "选择错误,正确答案为:" + mPagePaper.correct_ans; if (mPagePaper.re_count_num<2) mPagePaper.recede_control = true; } else { //mPagePaper.t_Display.Stop(); mPagePaper.tip_display.Foreground = new SolidColorBrush(Color.FromRgb(0, 255, 0)); mPagePaper.tip_display.Content = "正 确"; } //mPagePaper.t_Display.Stop(); //mPagePaper._flash_Display.Stop(); } else if (mPagePaper.line_num_count >= 6) { mPagePaper.tip_display.Foreground = Brushes.Black; //mPagePaper.t_Display.Stop(); mPagePaper.tip_display.Foreground = Brushes.Red; /*******************用于选择多次****************************/ if (_full != null) _full.Visibility = Visibility.Hidden; _full = mBorders[i]; /***********************************************/ mBorders[i].Visibility = Visibility.Visible; //显示通用 _control = true; //显示通用 /******************************用于写文件*********************************/ opt = (i + 1).ToString(); /*************************************************************************/ ///////////////////////////实验开始///////////// //if (mPagePaper.correct_ans != opt) //{ // mPagePaper.tip_display.Content = "选择错误,正确答案为:" + mPagePaper.correct_ans; // if (mPagePaper.re_count_num < 2) mPagePaper.recede_control = true; //} //else //{ // mPagePaper.tip_display.Content = "恭喜你,答对了!"; //} ////////////////////实验结束////////////// } } } } }
private void LinkList_DragEnter_1(object sender, DragEventArgs e) { if (!e.Data.GetDataPresent(typeof(DragInfo))) { return; } DragInfo data = e.Data.GetData(typeof(DragInfo)) as DragInfo; if (data == null) { return; } if (data.PanelID != PanelID) { return; } Border panel = GetBorderFromMousePos(e); if (panel == null) { return; } if (panel != null && PanelID == data.PanelID) { //清理之前的 if (_DragOverItem != null) { _DragOverItem.BorderThickness = new Thickness(0); } _DragOverItem = panel; if (_LinkList.Items[_LinkList.Items.Count - 1] == panel.DataContext) { Point point = e.GetPosition(panel); if (point.Y < panel.ActualHeight * 0.5d) { _IsButtom = false; panel.BorderThickness = new Thickness(0, 5, 0, 0); } else { _IsButtom = true; panel.BorderThickness = new Thickness(0, 0, 0, 5); } } else { _IsButtom = false; panel.BorderThickness = new Thickness(0, 5, 0, 0); } } else { //e.Effects = DragDropEffects.None; } //是否需要滚动 Point panelPos = e.GetPosition(_ListPanel); if (panelPos.Y < panel.ActualHeight) { _ScrollViewer.ScrollToVerticalOffset(_ScrollViewer.VerticalOffset - panel.ActualHeight); } else if (panelPos.Y > (this.ActualHeight - panel.ActualHeight)) { _ScrollViewer.ScrollToVerticalOffset(_ScrollViewer.VerticalOffset + panel.ActualHeight); } }
private void layoutOption(List<String> _temporary)//选项 8个 { mbordercontrol = new PaperBorderControl(); mBorders = new List<Border>(); mImagecontrol = new PaperImageControl(); vImages = new List<Image>(); cutLine(); // 载入选项 for (int i = 0; i < _temporary.Count; i++)// 8 是选项 ps:在内部就可以显示border 放外部循环就不行 { //border b = mbordercontrol.GenBorder(102, 94); mBorders.Add(b); PapertestCanvas.Children.Add(b); //image im = new Image(); im = mImagecontrol.GetImage(82, 74); BitmapImage bitim = new BitmapImage(); bitim.BeginInit(); // bitim.UriSource = new Uri("\\PCAT;component\\Images\\" + _temporary[i] + ".bmp", UriKind.Relative); bitim.EndInit(); im.Stretch = Stretch.Fill; im.Source = bitim; vImages.Add(im); PapertestCanvas.Children.Add(im); //Event im.MouseDown += new MouseButtonEventHandler(im_MouseDown); im.MouseEnter += new MouseEventHandler(im_MouseEnter); im.MouseLeave += new MouseEventHandler(im_MouseLeave); if (i < (_temporary.Count / 2)) { Canvas.SetTop(b, actual_y + bordertop);// Canvas.SetLeft(b, actual_x + borderleft);// borderleft = borderleft + borderadd; Canvas.SetTop(im, actual_y + imagetop);// Canvas.SetLeft(im, actual_x + imageleft);// imageleft = imageleft + imageadd; } else { Canvas.SetTop(b, actual_y + bordertop2);// Canvas.SetLeft(b, actual_x + borderleft2);// borderleft2 = borderleft2 + borderadd; Canvas.SetTop(im, actual_y + imagetop2);// Canvas.SetLeft(im, actual_x + imageleft2);// imageleft2 = imageleft2 + imageadd; } }//---for }
private static FrameworkElement CreateElement( ImmutableArray <TaggedText> taggedTexts, IWpfTextView textView, TextFormattingRunProperties format, IClassificationFormatMap formatMap, ClassificationTypeMap typeMap, bool classify) { // Constructs the hint block which gets assigned parameter name and fontstyles according to the options // page. Calculates a inline tag that will be 3/4s the size of a normal line. This shrink size tends to work // well with VS at any zoom level or font size. var block = new TextBlock { FontFamily = format.Typeface.FontFamily, FontSize = 0.75 * format.FontRenderingEmSize, FontStyle = FontStyles.Normal, Foreground = format.ForegroundBrush, // Adds a little bit of padding to the left of the text relative to the border to make the text seem // more balanced in the border Padding = new Thickness(left: 2, top: 0, right: 2, bottom: 0) }; var(trimmedTexts, leftPadding, rightPadding) = Trim(taggedTexts); foreach (var taggedText in trimmedTexts) { var run = new Run(taggedText.ToVisibleDisplayString(includeLeftToRightMarker: true)); if (classify && taggedText.Tag != TextTags.Text) { var properties = formatMap.GetTextProperties(typeMap.GetClassificationType(taggedText.Tag.ToClassificationTypeName())); var brush = properties.ForegroundBrush.Clone(); run.Foreground = brush; } block.Inlines.Add(run); } block.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); // Encapsulates the textblock within a border. Gets foreground/background colors from the options menu. // If the tag is started or followed by a space, we trim that off but represent the space as buffer on hte // left or right side. var left = leftPadding * 5; var right = rightPadding * 5; var border = new Border { Background = format.BackgroundBrush, Child = block, CornerRadius = new CornerRadius(2), VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(left, top: 0, right, bottom: 0), }; // gets pixel distance of baseline to top of the font height var dockPanelHeight = format.Typeface.FontFamily.Baseline * format.FontRenderingEmSize; var dockPanel = new DockPanel { Height = dockPanelHeight, LastChildFill = false, // VerticalAlignment is set to Top because it will rest to the top relative to the stackpanel VerticalAlignment = VerticalAlignment.Top }; dockPanel.Children.Add(border); DockPanel.SetDock(border, Dock.Bottom); var stackPanel = new StackPanel { // Height set to align the baseline of the text within the TextBlock with the baseline of text in the editor Height = dockPanelHeight + (block.DesiredSize.Height - (block.FontFamily.Baseline * block.FontSize)), Orientation = Orientation.Vertical }; stackPanel.Children.Add(dockPanel); // Need to set these properties to avoid unnecessary reformatting because some dependancy properties // affect layout TextOptions.SetTextFormattingMode(stackPanel, TextOptions.GetTextFormattingMode(textView.VisualElement)); TextOptions.SetTextHintingMode(stackPanel, TextOptions.GetTextHintingMode(textView.VisualElement)); TextOptions.SetTextRenderingMode(stackPanel, TextOptions.GetTextRenderingMode(textView.VisualElement)); return(stackPanel); }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager) { tile = factory.GetTexture2D("Textures/tile"); FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld; ///border border = new Border(fworld, factory, GraphicInfo, factory.CreateTexture2DColor(1, 1, Color.Red)); ///from texture { Texture2D tex = factory.GetTexture2D("Textures//goo"); IModelo2D model = new SpriteFarseer(tex); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, model); I2DObject o = new I2DObject(fs, mat, model); o.PhysicObject.Position = new Vector2(200, 0); this.World.AddObject(o); } ///from texture, scale usage sample { Texture2D tex = factory.GetTexture2D("Textures//goo"); tex = factory.GetScaledTexture(tex, new Vector2(2)); IModelo2D model = new SpriteFarseer(tex); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, model); I2DObject o = new I2DObject(fs, mat, model); o.OnHasMoved += new PloobsEngine.SceneControl._2DScene.OnHasMoved(o_OnHasMoved); this.World.AddObject(o); } ///rectangle Vertices verts = PolygonTools.CreateRectangle(50, 50); { IModelo2D model = new SpriteFarseer(factory, verts, Color.Orange); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, model); I2DObject o = new I2DObject(fs, mat, model); o.PhysicObject.Position = new Vector2(-200, 0); this.World.AddObject(o); } ///circle CircleShape circle = new CircleShape(50, 1); { IModelo2D model = new SpriteFarseer(factory, circle, Color.Orange); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, model); I2DObject o = new I2DObject(fs, mat, model); o.PhysicObject.Position = new Vector2(200, -100); this.World.AddObject(o); } ///animated sprite { Texture2D tex = factory.GetTexture2D("Textures//DudeSheet"); SpriteAnimated sa = new SpriteAnimated(tex, 8, 2); sa.AddAnimation("ANIM1", 1, 8, 0); sa.AddAnimation("ANIM2", 2, 4, MathHelper.PiOver2); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); Texture2D frame = factory.GetTexturePart(tex, sa.GetFrameRectangle("ANIM1", 0)); FarseerObject fs = new FarseerObject(fworld, frame); //GhostObject fs = new GhostObject(Vector2.Zero); sheet = new I2DObject(fs, mat, sa); sheet.PhysicObject.Position = new Vector2(500, 0); this.World.AddObject(sheet); } { PointLight2D l = new PointLight2D(new Vector2(-GraphicInfo.BackBufferWidth / 4, -GraphicInfo.BackBufferWidth / 4), Color.Red, 1); this.World.AddLight(l); } { SpotLight2D l = new SpotLight2D(new Vector2(+GraphicInfo.BackBufferWidth / 4, -GraphicInfo.BackBufferWidth / 4), Color.Blue, new Vector2(0, 1), MathHelper.ToRadians(45)); this.World.AddLight(l); } { SimpleConcreteKeyboardInputPlayable sc = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.Space); sc.KeyStateChange += new KeyStateChange(sc_KeyStateChange); this.BindInput(sc); } ///camera this.World.Camera2D = new Camera2D(GraphicInfo); DPFSParticleSystem ps = new DPFSParticleSystem("TESTE", new SpriteParticleSystem(null)); this.World.ParticleManager.AddAndInitializeParticleSystem(ps); ///add a post effect =P //this.RenderTechnic.AddPostEffect(new WigglePostEffect()); ///updateable JointUpdateable ju = new JointUpdateable(this, fworld, this.World.Camera2D); base.LoadContent(GraphicInfo, factory, contentManager); { NeoforceGui guiManager = this.Gui as NeoforceGui; System.Diagnostics.Debug.Assert(guiManager != null); // Create and setup Window control. Window window = new Window(guiManager.Manager); window.Init(); window.Text = "Getting Started"; window.Width = 480; window.Height = 200; window.Center(); window.Visible = true; // Create Button control and set the previous window as its parent. Button button = new Button(guiManager.Manager); button.Init(); button.Text = "OK"; button.Width = 72; button.Height = 24; button.Left = (window.ClientWidth / 2) - (button.Width / 2); button.Top = window.ClientHeight - button.Height - 8; button.Anchor = Anchors.Bottom; button.Parent = window; // Add the window control to the manager processing queue. guiManager.Manager.Add(window); } }
private void doRender() { chapterGrid.Children.Clear(); chapterGrid.ColumnDefinitions.Clear(); int gridCol = 0; double totalWordCount = 0; foreach (var chap in _chapters) { totalWordCount += chap.GetWordCount(); } foreach (var chap in _chapters) { ColumnDefinition cd = new ColumnDefinition(); cd.Width = new GridLength(chap.GetWordCount(), GridUnitType.Star); chapterGrid.ColumnDefinitions.Add(cd); Border b = new Border(); chapterGrid.Children.Add(b); Grid.SetColumn(b, gridCol); b.BorderBrush = new SolidColorBrush(Colors.Black); b.BorderThickness = new Thickness(2); Grid g = new Grid(); b.Child = g; g.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) }); g.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }); TextBlock t = new TextBlock(); g.Children.Add(t); t.Text = string.Format("{0}\n{1} scenes\n{2} words\n{3:p1} of story", chap.Model.Name, chap.Scenes.Count(), chap.GetWordCount(), chap.GetWordCount() / totalWordCount); t.Margin = new Thickness(1); ToolTipService.SetToolTip(t, t.Text); Grid.SetRow(t, 1); Grid sceneGrid = new Grid(); g.Children.Add(sceneGrid); int sceneCol = 0; foreach (var scene in chap.Scenes) { cd = new ColumnDefinition(); cd.Width = new GridLength(scene.GetWordCount(), GridUnitType.Star); sceneGrid.ColumnDefinitions.Add(cd); b = new Border(); sceneGrid.Children.Add(b); Grid.SetColumn(b, sceneCol); b.BorderBrush = new SolidColorBrush(Colors.DarkSlateBlue); b.BorderThickness = new Thickness(1); b.Background = new SolidColorBrush(getNextSceneColor()); t = new TextBlock(); b.Child = t; t.Text = string.Format("{0}\n{1} words\n{2:p1} of chapter", scene.Model.Name, scene.GetWordCount(), scene.GetWordCount() / (double)chap.GetWordCount()); ToolTipService.SetToolTip(b, t.Text); t.Margin = new Thickness(1); t.LayoutTransform = new RotateTransform(270); t.VerticalAlignment = VerticalAlignment.Bottom; t.HorizontalAlignment = HorizontalAlignment.Left; TextOptions.SetTextFormattingMode(t, TextFormattingMode.Display); sceneCol++; } gridCol++; } }
private void SwitchButtonOn(StackPanel buttonActive) { Border ButtonBorder = (Border)buttonActive.Children[0]; ButtonBorder.SetValue(BorderThicknessProperty, new Thickness(4, 0, 0, 0)); }
/// <summary> /// Draw simple border. /// </summary> /// <param name="border">Desired border</param> /// <param name="g">the device to draw to</param> /// <param name="box">Box which the border corresponds</param> /// <param name="brush">the brush to use</param> /// <param name="rectangle">the bounding rectangle to draw in</param> /// <returns>Beveled border path, null if there is no rounded corners</returns> public static void DrawBorder(Border border, IGraphics g, CssBox box, Brush brush, RectangleF rectangle) { SetInOutsetRectanglePoints(border, box, rectangle, true, true); g.FillPolygon(brush, _borderPts); }
/// <summary> /// Draw specific border (top/bottom/left/right) with the box data (style/width/rounded).<br/> /// </summary> /// <param name="border">desired border to draw</param> /// <param name="box">the box to draw its borders, contain the borders data</param> /// <param name="g">the device to draw into</param> /// <param name="rect">the rectangle the border is enclosing</param> /// <param name="isLineStart">Specifies if the border is for a starting line (no bevel on left)</param> /// <param name="isLineEnd">Specifies if the border is for an ending line (no bevel on right)</param> private static void DrawBorder(Border border, CssBox box, IGraphics g, RectangleF rect, bool isLineStart, bool isLineEnd) { string style = GetStyle(border, box); Color color = GetColor(border, box, style); GraphicsPath borderPath = GetRoundedBorderPath(border, box, rect); if (borderPath != null) { // rounded border need special path SmoothingMode smooth = g.SmoothingMode; if (box.HtmlContainer != null && !box.HtmlContainer.AvoidGeometryAntialias && box.IsRounded) { g.SmoothingMode = SmoothingMode.AntiAlias; } Pen pen = GetPen(style, color, GetWidth(border, box)); using (borderPath) g.DrawPath(pen, borderPath); g.SmoothingMode = smooth; } else { // non rounded border if (style == CssConstants.Inset || style == CssConstants.Outset) { // inset/outset border needs special rectangle SetInOutsetRectanglePoints(border, box, rect, isLineStart, isLineEnd); g.FillPolygon(RenderUtils.GetSolidBrush(color), _borderPts); } else { // solid/dotted/dashed border draw as simple line Pen pen = GetPen(style, color, GetWidth(border, box)); switch (border) { case Border.Top: g.DrawLine(pen, (float)Math.Ceiling(rect.Left), rect.Top + box.ActualBorderTopWidth / 2, rect.Right - 1, rect.Top + box.ActualBorderTopWidth / 2); break; case Border.Left: g.DrawLine(pen, rect.Left + box.ActualBorderLeftWidth / 2, (float)Math.Ceiling(rect.Top), rect.Left + box.ActualBorderLeftWidth / 2, (float)Math.Floor(rect.Bottom)); break; case Border.Bottom: g.DrawLine(pen, (float)Math.Ceiling(rect.Left), rect.Bottom - box.ActualBorderBottomWidth / 2, rect.Right - 1, rect.Bottom - box.ActualBorderBottomWidth / 2); break; case Border.Right: g.DrawLine(pen, rect.Right - box.ActualBorderRightWidth / 2, (float)Math.Ceiling(rect.Top), rect.Right - box.ActualBorderRightWidth / 2, (float)Math.Floor(rect.Bottom)); break; } } } }
private async void Border_MouseUp(object sender, MouseButtonEventArgs e) { if (!IsEnabled) { return; } Border b = sender as Border; var square = b.DataContext as ChessSquare; var vm = FindResource("vm") as ChessViewModel; // If a square is not already selected by the player if (vm.SelectedSquare == null) { // If the square clicked has a piece that belongs to the current player if (square.Player.Player == vm.CurrentPlayer && vm.PossibleStartMoves.Contains(square.Position)) { square.IsSelected = true; square.IsHighlighted = true; vm.SelectedSquare = square; vm.SelectedState = true; } } // Else if a square is already selected else { // If the user clicks on the square they just selected, it will deselect the square if (vm.SelectedSquare == square) { square.IsSelected = false; square.IsHighlighted = false; vm.SelectedSquare = null; vm.SelectedState = false; } // Else if a starting square is selected by the player, the player can select another square if it is a // possible end move of the starting square else { if (vm.GetPossMovesFromPos(vm.SelectedSquare.Position).Contains(square.Position)) { square.IsGreenHighlighted = false; vm.GetSquareAtPos(vm.SelectedSquare.Position).IsSelected = false; IsEnabled = false; await vm.ApplyMove(square.Position); IsEnabled = true; square.IsHighlighted = false; //vm.GetSquareAtPos(vm.SelectedSquare.Position).IsSelected = false; vm.SelectedSquare = null; } else { foreach (var sq in vm.Squares) { sq.IsSelected = false; vm.SelectedSquare = null; } } } } }
/// <summary>Initializes a new instance of the <see cref="VisualTextBox" /> class.</summary> public VisualTextBox() { SetStyle(ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true); // Contains another control SetStyle(ControlStyles.ContainerControl, true); // Cannot select this control, only the child and does not generate a click event SetStyle(ControlStyles.Selectable | ControlStyles.StandardClick, false); _borderButton = new BorderEdge { Visible = false }; _borderImage = new BorderEdge { Visible = false }; _textWidth = GetTextBoxWidth(); _border = new Border(); ThemeManager = new StyleManager(Settings.DefaultValue.DefaultStyle); _backColorState = new ColorState { Enabled = ThemeManager.Theme.ColorPalette.ControlEnabled }; _textBox = new TextBoxExtended { Size = new Size(125, 25), Location = new Point(_border.BorderCurve, _border.BorderCurve), Text = string.Empty, BorderStyle = BorderStyle.None, TextAlign = HorizontalAlignment.Left, Font = Font, ForeColor = ForeColor, BackColor = _backColorState.Enabled, Multiline = false }; _imageWidth = 35; _buttonFont = Font; _buttonIndent = 3; _buttontext = "visualButton"; _image = null; _imageSize = new Size(16, 16); _watermark = new Watermark(); _buttonBorder = new Border(); _textBox.KeyDown += TextBox_KeyDown; _textBox.Leave += OnLeave; _textBox.Enter += OnEnter; _textBox.GotFocus += OnEnter; _textBox.LostFocus += OnLeave; _textBox.MouseLeave += OnLeave; _textBox.TextChanged += TextBox_TextChanged; _textBox.SizeChanged += TextBox_SizeChanged; Controls.Add(_textBox); Controls.Add(_borderButton); Controls.Add(_borderImage); _waterMarkContainer = null; Size = new Size(135, 25); if (_watermark.Visible) { DrawWaterMark(); } UpdateTheme(ThemeManager.Theme); }
private void InitComponents(WindowConfig markup) { if (markup == null) { throw new Exception("Window cannot be initialized"); } #region Window initialization this.WindowStyle = WindowStyle.None; this.ResizeMode = ResizeMode.NoResize; this.Background = new SolidColorBrush(Colors.Transparent); this.AllowsTransparency = true; this.ShowInTaskbar = false; this.Topmost = true; this.Focusable = false; this.Loaded += Window_Loaded; this.MaxWidth = 300; this.Width = markup.Width; this.Height = markup.Height; if (markup.AutoHeight) { this.SizeToContent = SizeToContent.Height; } #endregion #region Controlls initialization _Border = new Border { BorderThickness = new Thickness(1), CornerRadius = markup.CornerRadius, BorderBrush = markup.ForegroundColor, Background = markup.BackgroundColor, }; _HeaderBlock = new TextBlock { Margin = new Thickness(10), Foreground = markup.ForegroundColor, FontSize = 25 }; _DividingLine = new StackPanel { Background = markup.ForegroundColor, Height = 1, }; _TextBlock = new TextBlock { Margin = new Thickness(10), Foreground = markup.ForegroundColor, FontSize = 15, TextWrapping = TextWrapping.Wrap }; _StackPanel = new StackPanel { Orientation = Orientation.Vertical }; IAddChild container = _StackPanel; container.AddChild(_HeaderBlock); container.AddChild(_DividingLine); container.AddChild(_TextBlock); container = _Border; container.AddChild(_StackPanel); container = this; container.AddChild(_Border); #endregion }