/// <summary> /// Constructs a <see cref="MainTitleIconControlVWG"/> /// </summary> public MainTitleIconControlVWG(IControlFactory controlFactory) { if (controlFactory == null) throw new ArgumentNullException("controlFactory"); _controlFactory = controlFactory; _panel = _controlFactory.CreatePanel(); ((PanelVWG)_panel).BackgroundImage = @"Images.headergradient.png"; _panel.BackColor = Color.Transparent; _panel.Dock = Habanero.Faces.Base.DockStyle.Top; _panel.Height = 23; this.Size = new Size(_panel.Width,_panel.Height); _icon = _controlFactory.CreateLabel(); ((LabelVWG)_icon).BackgroundImage = ""; _icon.BackColor = Color.Transparent; ((LabelVWG)_icon).BackgroundImageLayout = ImageLayout.Center; _icon.Dock = Habanero.Faces.Base.DockStyle.Left; _icon.Size = new Size(20, 20); _title = _controlFactory.CreateLabel(); _title.Font = new Font("Verdana", 10); _title.Dock = Habanero.Faces.Base.DockStyle.Fill; _title.BackColor = Color.Transparent; _title.TextAlign = ContentAlignment.MiddleLeft; _title.ForeColor = Color.White; _panel.Controls.Add(_title); _panel.Controls.Add(_icon); this.Dock = DockStyleVWG.GetDockStyle(DockStyle.Top); this.Controls.Add((PanelVWG)_panel); this.Height = 23; }
public override void Start() { base.Start(); IStack stack = Platform.Current.Create<IStack>(); cmdShow = Platform.Current.Create<IButton>(); cmdShow.Text = "Show/Hide"; cmdShow.Click += CmdShow_Click; cmdShow.BackgroundColor = new Color(1, 255, 0, 0); cmdShow.FontColor = new Color(1, 255, 255, 255); stack.Children.Add(cmdShow); lbltext = Platform.Current.Create<ILabel>(); lbltext.Text = "I'm visible, i want an ice-cream"; lbltext.Visible = false; stack.Children.Add(lbltext); IButton cmdClose = Platform.Current.Create<IButton>(); cmdClose.Text = "Close"; cmdClose.Click += CmdClose_Click; stack.Children.Add(cmdClose); Platform.Current.Page.Title = "Test label"; Platform.Current.Page.Content = stack; }
public override void Start() { base.Start(); IStack stack = Platform.Current.Create<IStack>(); lblLabel = Platform.Current.Create<ILabel>(); lblLabel.Text = "Select 1 day"; lblLabel.Height = 30; stack.Children.Add(lblLabel); calendar = Platform.Current.Create<ICalendar>(); calendar.Name = "calendar"; //calendar.BackgroundColor = new Color(1,0,0,255); calendar.Bold = true; stack.Children.Add(calendar); IButton cmdChange = Platform.Current.Create<IButton>(); cmdChange.Text = "Change"; cmdChange.Click += CmdChange_Click; stack.Children.Add(cmdChange); IButton cmdClose = Platform.Current.Create<IButton>(); cmdClose.Text = "Close"; cmdClose.Click += CmdClose_Click; stack.Children.Add(cmdClose); Platform.Current.Page.Title = "Test label"; Platform.Current.Page.Content = stack; }
/// <summary> /// Learns from the given example. /// </summary> /// <param name="example">The example to learn.</param> /// <param name="label">The label for this <paramref name="example"/>.</param> public void Learn(object example, ILabel label) { using (var ex = GetOrCreateSerializer(example.GetType()).Serialize(example, label)) { this.vw.Learn(ex); } }
///<summary> /// Constructor for <see cref="CollapsiblePanelManager"/> ///</summary> ///<param name="collapsiblePanel"></param> ///<param name="controlFactory"></param> public CollapsiblePanelManager(ICollapsiblePanel collapsiblePanel, IControlFactory controlFactory) { _controlFactory = controlFactory; _collapsiblePanel = collapsiblePanel; _collapseButton = _controlFactory.CreateButtonCollapsibleStyle(); _collapseButton.Click += delegate { Collapsed = !Collapsed; }; _pinLabel = controlFactory.CreateLabelPinOffStyle(); _pinLabel.Click += delegate { Pinned = !Pinned; }; IPanel buttonPanel = _controlFactory.CreatePanel(); BorderLayoutManager buttonLayoutManager = _controlFactory.CreateBorderLayoutManager(buttonPanel); buttonPanel.Height = _collapseButton.Height; buttonLayoutManager.AddControl(_collapseButton, BorderLayoutManager.Position.Centre); buttonLayoutManager.AddControl(_pinLabel, BorderLayoutManager.Position.East); _layoutManager = _controlFactory.CreateBorderLayoutManager(collapsiblePanel); _layoutManager.AddControl(buttonPanel, BorderLayoutManager.Position.North); _collapseButton.BackColor = System.Drawing.Color.Transparent; _collapseButton.ForeColor = System.Drawing.Color.Transparent; }
/// <summary> /// Start this instance. /// <para xml:lang="es"> /// Inicia la instancia del boton. /// </para> /// </summary> public override void Start() { base.Start(); // Create an stack IStack stack = Platform.Current.Create<IStack>(); // Creates the button with text, size and specific color, with the event also click and adds it to the stack cmdShow = Platform.Current.Create<IButton>(); cmdShow.Text = "Show/Hide"; cmdShow.Click += CmdShow_Click; cmdShow.BackgroundColor = new Color(1, 255, 0, 0); cmdShow.FontColor = new Color(1, 255, 255, 255); stack.Children.Add(cmdShow); // Create an Label with text specific, not visible and adds it to the stack lbltext = Platform.Current.Create<ILabel>(); lbltext.Text = "I'm visible, i want an ice-cream"; lbltext.Visible = false; stack.Children.Add(lbltext); // Create another button with a specific text with your event click and adds it to the stack IButton cmdClose = Platform.Current.Create<IButton>(); cmdClose.Text = "Close"; cmdClose.Click += CmdClose_Click; stack.Children.Add(cmdClose); // Establishes the content and title of the page Platform.Current.Page.Title = "Test label"; Platform.Current.Page.Content = stack; }
/// <summary> /// Start this instance. /// <para xml:lang="es"> /// Inicia la instancia del objeto Calendar. /// </para> /// </summary> public override void Start() { base.Start(); // Create an Stack IStack stack = Platform.Current.Create<IStack>(); // Creates an Label with text and a specific size and adds it to the stack. lblLabel = Platform.Current.Create<ILabel>(); lblLabel.Text = "Select 1 day"; lblLabel.Height = 30; stack.Children.Add(lblLabel); // Creates an Calendar with text specific and adds it to the stack. calendar = Platform.Current.Create<ICalendar>(); calendar.Name = "calendar"; calendar.Bold = true; stack.Children.Add(calendar); // Creates the Button cmdChange with text specific, with the event also click and adds it to the stack. IButton cmdChange = Platform.Current.Create<IButton>(); cmdChange.Text = "Change"; cmdChange.Click += CmdChange_Click; stack.Children.Add(cmdChange); // Creates the Button cmdClose with text specific, with the event also click and adds it to the stack. IButton cmdClose = Platform.Current.Create<IButton>(); cmdClose.Text = "Close"; cmdClose.Click += CmdClose_Click; stack.Children.Add(cmdClose); // Establishes the content and title of the page Platform.Current.Page.Title = "Test label"; Platform.Current.Page.Content = stack; }
/// <summary> /// Learns from the given example. /// </summary> /// <param name="example">The example to learn.</param> /// <param name="label">The optional label for this <paramref name="example"/>.</param> /// <param name="index">The optional index of the example, the <paramref name="label"/> should be attributed to.</param> public void Learn(object example, ILabel label = null, int? index = null) { using (var ex = GetOrCreateSerializer(example.GetType()).Serialize(example, label, index)) { ex.Learn(); } }
/// <summary> /// Start this instance. /// <para xml:lang="es"> /// Inicia la instancia del objeto CheckBox. /// </para> /// </summary> public override void Start() { base.Start(); // Create a Stack IStack stack = Platform.Current.Create<IStack>(); // Creates an Label with text and a specific size and adds it to the stack. lblLabel = Platform.Current.Create<ILabel>(); lblLabel.Text = "Click on the checkbox"; lblLabel.Height = 30; stack.Children.Add(lblLabel); // Creates an CheckBox selected with the event also click and adds it to the stack. checkBox = Platform.Current.Create<ICheckBox>(); checkBox.Value = true; checkBox.ValueChanged += checkBox_ValueChanged; stack.Children.Add(checkBox); // Creates the Button cmdClose with text specific, with the event also click and adds it to the stack. IButton cmdClose = Platform.Current.Create<IButton>(); cmdClose.Text = "Close"; cmdClose.Click += CmdClose_Click; stack.Children.Add(cmdClose); // Establishes the content and title of the page Platform.Current.Page.Title = "Test checkbox"; Platform.Current.Page.Content = stack; }
public UnnamedConcreteDependency(ILabel regent, int regentIndex, ILabel dependent, int dependentIndex) : base(regent, dependent) { headIndex = regentIndex; depIndex = dependentIndex; }
/// <summary> /// Constructs a <see cref="MainTitleIconControlWin"/> /// </summary> public MainTitleIconControlWin(IControlFactory controlFactory) { if (controlFactory == null) throw new ArgumentNullException("controlFactory"); _controlFactory = controlFactory; _panel = _controlFactory.CreatePanel(); ((PanelWin)_panel).BackgroundImage = CollapsiblePanelResource.headergradient; _panel.BackColor = Color.Transparent; _panel.Dock = Habanero.Faces.Base.DockStyle.Top; _panel.Height = 23; _icon = _controlFactory.CreateLabel(); ((LabelWin)_icon).BackgroundImage = CollapsiblePanelResource.headergradient; _icon.BackColor = Color.Transparent; ((LabelWin)_icon).BackgroundImageLayout = ImageLayout.Center; _icon.Dock = Habanero.Faces.Base.DockStyle.Left; _icon.Size = new Size(20, 20); _title = _controlFactory.CreateLabel(); _title.Dock = Habanero.Faces.Base.DockStyle.Fill; _title.BackColor = Color.Transparent; _title.TextAlign = ContentAlignment.MiddleLeft; _title.ForeColor = Color.White; _panel.Controls.Add(_title); _panel.Controls.Add(_icon); _panel.MaximumSize = new Size(2000, 23); this.Dock = DockStyleWin.GetDockStyle(DockStyle.Top); this.Controls.Add((PanelWin)_panel); this.Height = 23; }
public LabelShape() { mRectShapes = new List<RectShape>(); mPullPoint = new Point2I(default(int), default(int)); mLabelStream = null; mLabel = null; }
/// <summary> /// Parses the example. /// </summary> /// <param name="json">The example to parse.</param> /// <param name="label"> /// Optional label, taking precedence over "_label" property found in <paramref name="json"/>. /// If null, <paramref name="json"/> will be inspected and the "_label" property used as label. /// </param> /// <returns>The VowpalWabbit native example.</returns> public VowpalWabbitExample Parse(string json, ILabel label = null) { using (var textReader = new JsonTextReader(new StringReader(json))) { return this.Parse(textReader, label); } }
public override void Start() { base.Start(); IStack stack = Platform.Current.Create<IStack>(); lblLabel = Platform.Current.Create<ILabel>(); lblLabel.Text = "This is a label"; lblLabel.Height = 30; stack.Children.Add(lblLabel); cbxColor = Platform.Current.Create<ICheckBox>(); cbxColor.Name = "color"; cbxColor.Value = true; stack.Children.Add(cbxColor); IButton cmdChange = Platform.Current.Create<IButton>(); cmdChange.Text = "Change"; cmdChange.Click += CmdChange_Click; stack.Children.Add(cmdChange); IButton cmdClose = Platform.Current.Create<IButton>(); cmdClose.Text = "Close"; cmdClose.Click += CmdClose_Click; stack.Children.Add(cmdClose); Platform.Current.Page.Title = "Test label"; Platform.Current.Page.Content = stack; }
/// <summary> /// Create a new <code>TaggedWord</code>. /// </summary> /// <param name="oldLabel"> /// A Label. If it implements the HasWord and/or HasTag interface, then the corresponding value will be set /// </param> public TaggedWord(ILabel oldLabel) : base(oldLabel.Value()) { if (oldLabel is IHasTag) { this.vTag = ((IHasTag) oldLabel).Tag(); } }
public LabelState(ILabel label) { Point = label.Point; Position = label.Position; Size = label.Size; IsVisible = label.IsVisible; IsMovable = label.IsMovable; PlotCenter = label.PlotCenter; if (label is LabelState) Energy = ((LabelState)label).Energy; }
public void Validate(string line, string json, IVowpalWabbitLabelComparator labelComparator = null, ILabel label = null) { using (var jsonSerializer = new VowpalWabbitJsonSerializer(this.vw)) using (var jsonExample = jsonSerializer.ParseAndCreate(json, label)) { this.Validate(line, jsonExample, labelComparator, label); } }
public HotspotLabel(IGame game, ILabel label) { _label = label; _events = game.Events; _input = game.Input; _state = game.State; _game = game; }
public LabelShape() { mRectShapes = new List<RectShape>(); mPullPoint = new Point2I(default(int), default(int)); mPullState = PullState_.mNone_; mMoveState = MoveState_.mNone_; mLabelStream = null; mLabel = null; }
internal static bool Intersect(ILabel label1, ILabel label2) { var rect1 = label1.RectFromLabel(); var rect2 = label2.RectFromLabel(); rect1.Intersect(rect2); return (!rect1.IsEmpty); }
public LabelViewModel(ILabel model, MainViewModel main) : base(main) { if (model == null) throw new ArgumentNullException("model"); this.model = model; main.RegisterViewModel(model, this); LoadViewModels(); }
/// <summary> /// Create a new <code>StringLabel</code> with the /// <code>value()</code> of another label as its label. /// </summary> /// <param name="label">The other label</param> public StringLabel(ILabel label) { this.str = label.Value(); if (label is IHasOffset) { var ofs = (IHasOffset) label; SetBeginPosition(ofs.BeginPosition()); SetEndPosition(ofs.EndPosition()); } }
public GenericGridFilterControlWin(IGridBase grid) { var ds = grid.DataSource as DataView; if (ds != null) this._originalView = ds; (grid as DataGridView).DataSourceChanged += this.DataSourceChanged; this._lastForcedEvents = DateTime.Now; this.Grid = grid; this._timer = new Timer() { Enabled = true, Interval = 500, }; this._timer.Tick += (sender, e) => { if ((this._filterRequired) && (this._lastFilterChanged.AddMilliseconds(this._timer.Interval) < DateTime.Now)) { if (this._inFilter) this._cancelCurrentFilter = true; this._filterRequired = false; this.DoFilter(); } }; var factory = new ControlFactoryWin(); this._filterLabel = factory.CreateLabel("Filter:"); this._filterTextBox = factory.CreateTextBox(); var txt = this._filterTextBox as TextBox; txt.TextChanged += (sender, e) => { if (txt.Text == this._lastFilterText) return; this._lastFilterChanged = DateTime.Now; this._filterRequired = true; }; var manager = factory.CreateBorderLayoutManager(this); manager.AddControl(this._filterLabel, BorderLayoutManager.Position.West); manager.AddControl(this._filterTextBox, BorderLayoutManager.Position.Centre); var vgap = manager.VerticalGapSize + manager.BorderSize; this.Height = this._filterTextBox.Height + 2 * vgap; this.FilterStarted += (sender, e) => { this.SetUIState(true); }; this.FilterCompleted += (sender, e) => { this.SetUIState(false); }; var wingrid = Grid as DataGridView; if (wingrid != null) { this._gridOriginalAlternatingStyle = wingrid.AlternatingRowsDefaultCellStyle; wingrid.AlternatingRowsDefaultCellStyleChanged += this.RecordGridAltStyle; } }
public virtual ILabel NewLabel(ILabel oldLabel) { if (oldLabel is IHasTag) { return new WordTag(oldLabel.Value(), ((IHasTag)oldLabel).Tag()); } else { return new WordTag(oldLabel.Value()); } }
public LabelViewModel GetViewModel(ILabel model) { LabelViewModel vm; if (labelViewModels.ContainsKey(model.ID)) { vm = labelViewModels[model.ID]; vm.Model = model; } else { vm = new LabelViewModel(model, this); } return vm; }
public void Validate(string line, string json, IVowpalWabbitLabelComparator labelComparator = null, ILabel label = null) { using (var strExample = this.vw.ParseLine(line)) using (var jsonSerializer = new VowpalWabbitJsonSerializer(this.vw)) using (var jsonExample = (VowpalWabbitSingleLineExampleCollection)jsonSerializer.ParseAndCreate(json, label)) using (var strJsonExample = this.vw.ParseLine(jsonExample.Example.VowpalWabbitString)) { var diff = strExample.Diff(this.vw, jsonExample.Example, labelComparator); Assert.IsNull(diff, diff + " generated string: '" + jsonExample.Example.VowpalWabbitString + "'"); diff = strExample.Diff(this.vw, strJsonExample, labelComparator); Assert.IsNull(diff, diff); } }
//Parameter names for speakOption and showOnce are used in the factory, changing the names requires factory code change as well public AGSDialogOption(IDialogActions actions, ICharacter player, ILabel label, bool exitDialogOnFinish = false, bool speakOption = true, bool showOnce = false, ITextConfig hoverConfig = null, ITextConfig hasBeenChosenConfig = null) { _actions = actions; _player = player; Label = label; _normalConfig = label.TextConfig; HoverConfig = hoverConfig; HasBeenChosenConfig = hasBeenChosenConfig; ExitDialogWhenFinished = exitDialogOnFinish; SpeakOption = speakOption; ShowOnce = showOnce; label.MouseEnter.Subscribe(onMouseEnter); label.MouseLeave.Subscribe(onMouseLeave); }
public void Validate(string[] lines, string json, IVowpalWabbitLabelComparator labelComparator = null, ILabel label = null, int? index = null, VowpalWabbitJsonExtension extension = null) { VowpalWabbitExample[] strExamples = new VowpalWabbitExample[lines.Count()]; try { for (int i = 0; i < lines.Length; i++) strExamples[i] = this.vw.ParseLine(lines[i]); using (var jsonSerializer = new VowpalWabbitJsonSerializer(this.vw)) { if (extension != null) jsonSerializer.RegisterExtension(extension); using (var jsonExample = (VowpalWabbitMultiLineExampleCollection)jsonSerializer.ParseAndCreate(json, label, index)) { var jsonExamples = new List<VowpalWabbitExample>(); if (jsonExample.SharedExample != null) jsonExamples.Add(jsonExample.SharedExample); jsonExamples.AddRange(jsonExample.Examples); Assert.AreEqual(strExamples.Length, jsonExamples.Count); for (int i = 0; i < strExamples.Length; i++) { using (var strJsonExample = this.vw.ParseLine(jsonExamples[i].VowpalWabbitString)) { var diff = strExamples[i].Diff(this.vw, jsonExamples[i], labelComparator); Assert.IsNull(diff, diff + " generated string: '" + jsonExamples[i].VowpalWabbitString + "'"); diff = strExamples[i].Diff(this.vw, strJsonExample, labelComparator); Assert.IsNull(diff, diff); } } } } } finally { foreach (var ex in strExamples) if (ex != null) ex.Dispose(); } }
public void Validate(string line, VowpalWabbitExampleCollection example, IVowpalWabbitLabelComparator labelComparator = null, ILabel label = null) { Assert.IsNotNull(example); var jsonExample = example as VowpalWabbitSingleLineExampleCollection; Assert.IsNotNull(jsonExample); using (var strExample = this.vw.ParseLine(line)) using (var strJsonExample = this.vw.ParseLine(jsonExample.Example.VowpalWabbitString)) { var diff = strExample.Diff(this.vw, jsonExample.Example, labelComparator); Assert.IsNull(diff, diff + " generated string: '" + jsonExample.VowpalWabbitString + "'"); diff = strExample.Diff(this.vw, strJsonExample, labelComparator); Assert.IsNull(diff, diff); } }
public override void Init(IEntity entity) { base.Init(entity); _textComponent = entity.GetComponent<ITextComponent>(); _imageComponent = entity.GetComponent<IImageComponent>(); _uiEvents = entity.GetComponent<IUIEvents>(); _tree = entity.GetComponent<IInObjectTree>(); _room = entity.GetComponent<IHasRoom>(); _caretFlashCounter = (int)CaretFlashDelay; _withCaret = _game.Factory.UI.GetLabel(entity.ID + " Caret", "|", 1f, 1f, 0f, 0f, new AGSTextConfig(autoFit: AutoFit.LabelShouldFitText)); _withCaret.Anchor = new PointF(0f, 0f); _game.Events.OnBeforeRender.Subscribe(onBeforeRender); _uiEvents.MouseDown.Subscribe(onMouseDown); _uiEvents.LostFocus.Subscribe(onMouseDownOutside); }
/// <summary> /// Create a new <code>Dependency</code>. /// </summary> public IDependency <ILabel, ILabel, Object> NewDependency(ILabel regent, ILabel dependent) { return(NewDependency(regent, dependent, null)); }
/// <inheritdoc /> protected override bool IsHit(IInputModeContext context, PointD location, ILabel label) { return(Style.Renderer.GetHitTestable(label, Style).IsHit(context, location)); }
/// <summary> /// Create a new <code>Dependency</code>. /// </summary> public IDependency <ILabel, ILabel, Object> NewDependency(ILabel regent, ILabel dependent, Object name) { return(new UnnamedDependency(regent, dependent)); }
public static void UpdatePadding(this TextBlock nativeControl, ILabel label) => nativeControl.UpdateProperty(TextBlock.PaddingProperty, label.Padding.ToNative());
public Constituent NewConstituent(int start, int end, ILabel label, double score) { return(new SimpleConstituent(start, end)); }
/// <inheritdoc /> protected override Visual UpdateVisual(IRenderContext context, Visual oldVisual, ILabel label) { return(Style.Renderer.GetVisualCreator(label, Style).UpdateVisual(context, oldVisual)); }
/// <inheritdoc /> protected override Visual CreateVisual(IRenderContext context, ILabel label) { return(Style.Renderer.GetVisualCreator(label, Style).CreateVisual(context)); }
protected override SizeD GetPreferredSize(ILabel label) { // delegate preferred size calculation to wrapped renderer return(wrapped.Renderer.GetPreferredSize(label, wrapped)); }
protected override RectD GetBounds(ICanvasContext context, ILabel label) { return(wrapped.Renderer.GetBoundsProvider(label, wrapped).GetBounds(context)); }
/// <summary> /// Create a new leaf node with the given label /// </summary> /// <param name="label">the label for the leaf node</param> /// <returns>A new tree leaf</returns> public override Tree NewLeaf(ILabel label) { return(new LabeledScoredTreeNode(_lf.NewLabel(label))); }
/// <summary> /// Create a new non-leaf tree node with the given label /// </summary> /// <param name="parentLabel">The label for the node</param> /// <param name="children"> /// A <code>List</code> of the children of this node, /// each of which should itself be a <code>LabeledScoredTree</code> /// </param> /// <returns>A new internal tree node</returns> public override Tree NewTreeNode(ILabel parentLabel, List <Tree> children) { return(new LabeledScoredTreeNode(_lf.NewLabel(parentLabel), children)); }
public User(ILabel label) { Name = label.Name; UserImages = new HashSet <UserImage>(); }
/// <summary> /// Adds <see cref="IOptionItem"/>s that are bound to the label's <see cref="ILabel.LayoutParameter"/> /// and the associated <see cref="ILabelModelParameter.Model"/>. /// property to the builder. /// </summary> /// <param name="context">The context to use for building.</param> /// <param name="label">The current label instance.</param> protected virtual void AddLabelLayoutParameterItems(IOptionBuilderContext context, ILabel label) { if (label.LayoutParameter != null) { IOptionBuilder modelBuilder = GetLabelModelOptionBuilder(context, label.LayoutParameter.Model); if (modelBuilder != null) { modelBuilder.AddItems(context.CreateChildContext("Model"), label.LayoutParameter.Model.GetType(), label.LayoutParameter.Model); } } }
/// <summary> /// Calculates the preferred size for the given label if this style is used for the rendering. /// </summary> /// <remarks> /// The size is calculated from the label's text. /// </remarks> protected override SizeD GetPreferredSize(ILabel label) { return(new SizeD(80, 15)); }
public PageHeaderEditLabelHelper(SimpleLabel label, ICanvasObject labelCanvasObject) { this.label = label; this.labelCanvasObject = labelCanvasObject; }
protected override bool IsVisible(ICanvasContext context, RectD rectangle, ILabel label) { return(wrapped.Renderer.GetVisibilityTestable(label, wrapped).IsVisible(context, rectangle)); }
public PageHeaderVisualCreator(ILabel label) { this.label = label; }
public static Rect RectFromLabel(this ILabel label) { return(new Rect(label.Position, label.Size)); }
private void ConfigureTextEditorInputMode(IInputModeContext context, TextEditorInputMode mode, ILabel label) { var oldBackground = mode.TextBox.BackColor; var oldVisual = labelCanvasObject.Visible; // We know that this label helper is only used once this demo is properly set up. var graphEditorInputMode = (GraphEditorInputMode)context.CanvasControl.InputMode; var textEditorInputMode = ((LabelEditingForm.DemoTextEditorInputMode)graphEditorInputMode.TextEditorInputMode); mode.TextBox.BackColor = Color.White; var oldFont = mode.TextBox.Font; mode.TextBox.Font = new Font(oldFont.FontFamily, 20, oldFont.Style); // Make sure that the text box location matches the one of the zoom invariant page header label textEditorInputMode.ShowInViewCoordinates = true; mode.Location = new DynamicViewPoint((GraphControl)context.CanvasControl, 5, 35); mode.Anchor = new PointD(0, 1); // Hide this label during editing if the corresponding setting is enabled. // This is only necessary since this label is not part of the graph. if (graphEditorInputMode.HideLabelDuringEditing) { labelCanvasObject.Visible = false; context.CanvasControl.Invalidate(); } // Restore after editing EventHandler <TextEventArgs> afterEditing = null; afterEditing = delegate { labelCanvasObject.Visible = oldVisual; mode.TextBox.BackColor = oldBackground; mode.TextBox.Font = oldFont; context.CanvasControl.Invalidate(); mode.TextEdited -= afterEditing; mode.EditingCanceled -= afterEditing; }; mode.TextEdited += afterEditing; mode.EditingCanceled += afterEditing; }
protected override VisualGroup UpdateVisual(IRenderContext context, VisualGroup oldVisual, ILabel label) { var labelLayout = label.GetLayout(); var container = oldVisual; // update wrapped visual var wrappedVisual = wrapped.Renderer.GetVisualCreator(label, wrapped).UpdateVisual(context, container.Children[0]); // set new child only if wrapped visual instance has been switched if (container.Children[0] != wrappedVisual) { container.Children[0] = wrappedVisual; } VisualGroup innerContainer = (VisualGroup)container.Children[1]; // update visual decorators Line decorator1 = (Line)innerContainer.Children[0]; Line decorator2 = (Line)innerContainer.Children[1]; decorator1.X2 = labelLayout.Width; decorator2.Y1 = labelLayout.Height; decorator2.X2 = labelLayout.Width; decorator2.Y2 = labelLayout.Height; // arrange inner container ArrangeByLayout(context, innerContainer, labelLayout, false); return(container); }
public static void UpdateCharacterSpacing(this TextBlock nativeControl, ILabel label) { nativeControl.CharacterSpacing = label.CharacterSpacing.ToEm(); }
protected override object Lookup(ILabel label, Type type) { return(wrapped.Renderer.GetContext(label, wrapped).Lookup(type)); }
/// <summary>Create a new <code>TaggedWord</code>.</summary> /// <param name="word">This word is passed to the supertype constructor</param> /// <param name="tag"> /// The <code>value()</code> of this label is set as the /// tag of this Label /// </param> public TaggedWord(ILabel word, ILabel tag) : base(word) { this.tag = tag.Value(); }
/// <summary> /// Re-renders the label using the old visual for performance reasons. /// </summary> protected override VisualGroup UpdateVisual(IRenderContext context, VisualGroup oldVisual, ILabel label) { // get the data with which the old visual was created RenderDataCache oldCache = oldVisual.GetRenderDataCache <RenderDataCache>(); // get the data for the new visual RenderDataCache newCache = CreateRenderDataCache(context, label, Typeface); var labelLayout = label.GetLayout(); if (!oldCache.Equals(newCache)) { // something changed - re-render the visual oldVisual.Children.Clear(); Render(context, label, oldVisual, labelLayout, newCache); } // nothing changed, return the old visual // arrange because the layout might have changed ArrangeByLayout(context, oldVisual, labelLayout, true); return(oldVisual); }
/// <inheritdoc /> protected override RectD GetBounds(ICanvasContext context, ILabel label) { return(Style.Renderer.GetBoundsProvider(label, Style).GetBounds(context)); }
protected override SizeD GetPreferredSize(ILabel label) { return(label.PreferredSize); }
protected override IVisual CreateVisual(IRenderContext context, ILabel label) { return(new ButtonVisual(label, Button, Icon, BackgroundColor, ForegroundColor)); }
/// <inheritdoc /> protected override SizeD GetPreferredSize(ILabel label) { return(Style.Renderer.GetPreferredSize(label, Style)); }
/// <inheritdoc /> protected override bool IsInBox(IInputModeContext context, RectD rectangle, ILabel label) { return(Style.Renderer.GetMarqueeTestable(label, Style).IsInBox(context, rectangle)); }
/// <summary> /// Creates the visual appearance of a label /// </summary> private void Render(IRenderContext context, ILabel label, VisualGroup container, IOrientedRectangle labelLayout, RenderDataCache cache) { // store information with the visual on how we created it container.SetRenderDataCache(cache); // background rectangle System.Windows.Shapes.Rectangle rect = new System.Windows.Shapes.Rectangle { Width = labelLayout.Width, Height = labelLayout.Height, RadiusX = labelLayout.Width / 10, RadiusY = labelLayout.Height / 10, Stroke = Brushes.SkyBlue, Fill = fillBrush, StrokeThickness = 1 }; container.Add(rect); // TextBlock with label text TextBlock textBlock = new TextBlock { Text = cache.LabelText, FontFamily = cache.Typeface.FontFamily, FontStretch = cache.Typeface.Stretch, FontStyle = cache.Typeface.Style, FontWeight = cache.Typeface.Weight, Foreground = Brushes.Black, }; textBlock.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); // if edit button is visible align left, otherwise center double textPositionLeft = cache.ButtonVisibility == Visibility.Visible ? HorizontalInset : (labelLayout.Width - textBlock.DesiredSize.Width) / 2; textBlock.SetCanvasArrangeRect(new Rect(textPositionLeft, (labelLayout.Height - textBlock.DesiredSize.Height) / 2, textBlock.DesiredSize.Width, textBlock.DesiredSize.Height )); container.Add(textBlock); if (cache.ButtonVisibility == Visibility.Visible) { // get style for edit button from XAML resources // create edit button Button editLabelButton = new Button { Style = editButtonStyle }; editLabelButton.SetCanvasArrangeRect(new Rect(labelLayout.Width - HorizontalInset - ButtonSize, VerticalInset, ButtonSize, ButtonSize)); // set button command editLabelButton.Command = GraphCommands.EditLabel; editLabelButton.CommandParameter = label; editLabelButton.CommandTarget = context.CanvasControl; container.Add(editLabelButton); } }