protected override Size MeasureOverride(Size available) { return(FT800Device.MeasureText( this._text, this.GetActualFont() )); }
protected override Size MeasureOverride(Size available) { var font = this.GetActualFont(); var size = FT800Device.MeasureText(this._text, font); size.Width += 16; size.Height += 8; return(size); }
internal virtual bool Navigator(FT800Device dc) { if (this._nextIndex == this._currentIndex) { return(false); } bool proceed = true; if (this._currentIndex >= 0) { var args = new NavigationLeaveArgs(); args.GoingBack = this._nextIndex < this._currentIndex; ((Page)this.Content).InvokeBeforeLeave(dc, args); if (args.Cancel) { proceed = false; } } if (proceed) { if (this._nextIndex > this._currentIndex) { int len = this._navigationStack.Length; if (this._nextPageGen != null) { if (this._nextIndex >= len) { var array = new PageCreationDelegate[len + 4]; this._navigationStack.CopyTo(array, 0); this._navigationStack = array; } this._navigationStack[++this._currentIndex] = this._nextPageGen; } else if (this._nextIndex < len) { this._currentIndex = this._nextIndex; } } else { this._currentIndex = this._nextIndex; } Page current; this.Content = current = this._navigationStack[this._currentIndex](); current.InvokeEnter(dc); current.Invalidate(true); this._nextPageGen = null; } return(proceed); }
public void Clock(FT800Device dc) { if (this._nextIndex != this._currentIndex) { bool proceed = true; if (this._currentIndex >= 0) { var args = new NavigationLeaveArgs(); args.GoingBack = this._nextIndex < this._currentIndex; this.CurrentPage.InvokeBeforeLeave(dc, args); if (args.Cancel) { proceed = false; } } if (proceed) { if (this._nextIndex > this._currentIndex) { if (this._nextPage != null) { for (int i = this._pageStack.Count - 1; i > this._currentIndex; i--) { this._pageStack.RemoveAt(i); } this._pageStack.Add(this._nextPage); this._currentIndex++; this._nextPage.InvokeCreate(dc); } else if (this._nextIndex < this._pageStack.Count) { this._currentIndex = this._nextIndex; } } else { this._currentIndex = this._nextIndex; } this.CurrentPage.InvokeEnter(dc); this.CurrentPage.Invalidate(true); this._nextPage = null; } } else if (this._currentIndex < 0) { return; } this.CurrentPage.Render(dc); }
public override void HitTest(FT800Device device, int value) { if (value >= 0 && this._value_old != value && this.Min < this.Max) { this._value_old = value; this.Value = this.Min + (this.Max - this.Min) * value / RawMax; this.OnValueChanged(); } }
internal override bool Navigator(FT800Device dc) { if (this._status == 1 && dc.WaitCommandBufferIdle(blocking: false)) { this._status = 2; this.OnCompleted(); this.Close(); return(true); } return(false); }
protected override Size MeasureOverride(Size available) { var font = this.GetActualFont(); var szoff = FT800Device.MeasureText(this._labelOff, font); var szon = FT800Device.MeasureText(this._labelOn, font); var h = (float)System.Math.Max(szoff.Height, szon.Height) * 20f / 16; return(new Size( (float)System.Math.Max(szoff.Width, szon.Width) + 1.5f * h, h )); }
public override void HitTest(FT800Device device, int value) { if (this.IsChecked) { if (value < 0) { this.IsChecked = false; } } else if (value >= 0) { this.IsChecked = true; this.OnClick(); //this.IsChecked = false; } }
public override void HitTest(FT800Device device, int value) { if (value >= 0 && value != this._value_old && this.Min < this.Max) { //Debug.Print(value.ToString()); this._value_old = value; float raw = value / RawMax; if (this.MinAngle < this.MaxAngle) { raw = (raw - this.MinAngle) / (this.MaxAngle - this.MinAngle); } this.Value = this.Min + (this.Max - this.Min) * raw; this.OnValueChanged(); } }
public override void HitTest(FT800Device device, int value) { if (this._isHit) { if (value < 0) { this._isHit = false; this.Invalidate(false); } } else if (value >= 0) { this._isHit = true; this.IsChecked = !this.IsChecked; this.OnClick(); } }
internal void InvokeBeforeLeave(FT800Device dc, NavigationLeaveArgs args) { this.OnBeforeLeave(dc, args); }
internal void InvokeEnter(FT800Device dc) { this.OnEnter(dc); }
protected virtual void OnBeforeLeave(FT800Device dc, NavigationLeaveArgs args) { }
protected virtual void OnEnter(FT800Device dc) { }
public static void Main() { //define and open the CS output port _pd = new OutputPort(Pins.GPIO_PIN_D8, false); //setup the SPI configuration SPI.Configuration config = new SPI.Configuration( SPI_mod: SPI.SPI_module.SPI1, ChipSelect_Port: Pins.GPIO_PIN_D10, ChipSelect_ActiveState: false, ChipSelect_SetupTime: 0, ChipSelect_HoldTime: 0, Clock_IdleState: false, Clock_Edge: true, Clock_RateKHz: 10000 ); //open the SPI port using (SPI spi = new SPI(config)) { //create and init the FT800 device context var context = new FT800Device(spi, _pd); context.Init(); //create a new window to fit the entire screen area var w = new Window(); w.Width = context.ScreenWidth; w.Height = context.ScreenHeight; //set the background shading w.Background = Colors.DimGray; //provide a thin border w.BorderColor = Colors.Gainsboro; w.BorderThickness = new Thickness(1); //set the window as main WindowService.Instance.MainWindow = w; #if BasicSetup //do nothing #elif HelloWorld var tb = new TextBlock(); tb.Text = "Hello world!"; tb.Foreground = Colors.Fuchsia; tb.Font = 28; tb.HorizontalAlignment = HorizontalAlignment.Center; tb.VerticalAlignment = VerticalAlignment.Center; w.Content = tb; #elif TouchCalib //show the calibration overlayed "dialog" new CalibrationWindow().ShowDialog(); #elif PushButton //invoke the navigation to the demo page //(NOTE: the argument is a delegate, not the actual content) w.Navigate(PushButtonDemo.Create); //show the calibration overlayed "dialog" //(will be closed once the calibration is done) new CalibrationWindow().ShowDialog(); #elif ToggleSwitch //invoke the navigation to the demo page //(NOTE: the argument is a delegate, not the actual content) w.Navigate(ToggleSwitchDemo.Create); //show the calibration overlayed "dialog" //(will be closed once the calibration is done) new CalibrationWindow().ShowDialog(); #elif Slider //invoke the navigation to the demo page //(NOTE: the argument is a delegate, not the actual content) w.Navigate(SliderDemo.Create); //show the calibration overlayed "dialog" //(will be closed once the calibration is done) new CalibrationWindow().ShowDialog(); #elif DialKnob //invoke the navigation to the demo page //(NOTE: the argument is a delegate, not the actual content) w.Navigate(DialKnobDemo.Create); //show the calibration overlayed "dialog" //(will be closed once the calibration is done) new CalibrationWindow().ShowDialog(); #elif StackPanel //invoke the navigation to the demo page //(NOTE: the argument is a delegate, not the actual content) w.Navigate(StackPanelDemo.Create); #elif ContentControl //invoke the navigation to the demo page //(NOTE: the argument is a delegate, not the actual content) w.Navigate(ContentControlDemo.Create); #elif GridSingle //invoke the navigation to the demo page //(NOTE: the argument is a delegate, not the actual content) w.Navigate(Grid1Demo.Create); #elif GridRowCol //invoke the navigation to the demo page //(NOTE: the argument is a delegate, not the actual content) w.Navigate(GridRowColDemo.Create); #elif GridSpanning //invoke the navigation to the demo page //(NOTE: the argument is a delegate, not the actual content) w.Navigate(GridSpanningDemo.Create); #elif Windowing //invoke the navigation to the demo page //(NOTE: the argument is a delegate, not the actual content) w.Navigate(WindowingDemo.Create); //show the calibration overlayed "dialog" //(will be closed once the calibration is done) new CalibrationWindow().ShowDialog(); #elif Navigation //invoke the navigation to the demo page //(NOTE: the argument is a delegate, not the actual content) w.Navigate(NavigationDemo.Create); //show the calibration overlayed "dialog" //(will be closed once the calibration is done) new CalibrationWindow().ShowDialog(); #elif Font //invoke the navigation to the demo page //(NOTE: the argument is a delegate, not the actual content) w.Navigate(FontDemo.Create); #elif CustomWidget #endif //loop endlessly for the framework heartbeating while (true) { WindowService.Instance.Clock(context); Thread.Sleep(100); //recommended delay } } }