public void move() { if (collidesWithX()) { xDelta *= -1; currentRotationAngle *= -1; if (xDelta >= 0) { flowDirection = FlowDirection.LeftToRight; } else { flowDirection = FlowDirection.RightToLeft; } } if (collidesWithY()) { yDelta *= -1; currentRotationAngle *= -1; } adaptAngle(); currentX += xDelta * getXModifier(); currentY += yDelta * getYModifier(); speedUpFly(70); }
public Fly(Random random, FlowDirection flowDirection, double canvasWidth, double canvasHeight, double imageWidth, double imageHeight) { this.random = random; this.flowDirection = flowDirection; this.canvasWidth = canvasWidth; this.canvasHeight = canvasHeight; this.imageWidth = imageWidth; this.imageHeight = imageHeight; }
// The OnFlowDirectionChange method translates a // Windows Presentation Foundation FlowDirection value // to a Windows Forms RightToLeft value and assigns // the result to the hosted control's RightToLeft property. private void OnFlowDirectionChange(object h, String propertyName, object value) { WindowsFormsHost host = h as WindowsFormsHost; System.Windows.FlowDirection fd = (System.Windows.FlowDirection)value; System.Windows.Forms.CheckBox cb = host.Child as System.Windows.Forms.CheckBox; cb.RightToLeft = (fd == System.Windows.FlowDirection.RightToLeft) ? RightToLeft.Yes : RightToLeft.No; }
/// <summary> /// Translator for RightToLeft /// </summary> private static void RightToLeftPropertyTranslator(object host, string propertyName, object value) { ElementHost elementHost = host as ElementHost; if (elementHost != null) { AvalonAdapter adapter = elementHost.HostContainerInternal; if (adapter != null && value is SWF.RightToLeft) { SWF.RightToLeft fromRTL = (SWF.RightToLeft)value; SW.FlowDirection toFlowDirection = ((fromRTL == SWF.RightToLeft.Yes) ? SW.FlowDirection.RightToLeft : SW.FlowDirection.LeftToRight); adapter.FlowDirection = toFlowDirection; } } }
protected void ShowTooltip(DrawingContext drawingContext) { if (PopUp || MouseOver) { Typeface tf = new Typeface("GenericSansSerif"); System.Windows.FlowDirection fd = new System.Windows.FlowDirection(); FormattedText ft = new FormattedText(_buoy.Name + " " + _buoy.Time + "(UTC)", CultureInfo.CurrentUICulture, fd, tf, 18, Brushes.Red); drawingContext.DrawText(ft, new Point(40, -40)); string latlngstr = "经度:" + _buoy.gps.Longitude.ToString("F06") + "\r纬度:" + _buoy.gps.Latitude.ToString("F06"); ft = new FormattedText(latlngstr, CultureInfo.CurrentUICulture, fd, tf, 16, Brushes.White); drawingContext.DrawText(ft, new Point(40, -20)); ft = new FormattedText("测距1:" + _buoy.Range1.ToString("F02"), CultureInfo.CurrentUICulture, fd, tf, 16, Brushes.White); drawingContext.DrawText(ft, new Point(40, 20)); ft = new FormattedText("测距2:" + _buoy.Range2.ToString("F02"), CultureInfo.CurrentUICulture, fd, tf, 16, Brushes.White); drawingContext.DrawText(ft, new Point(40, 40)); } }
// Initialize the app's font and flow direction as defined in its localized resource strings. // // To ensure that the font of your application is aligned with its supported languages and that the // FlowDirection for each of those languages follows its traditional direction, ResourceLanguage // and ResourceFlowDirection should be initialized in each resx file to match these values with that // file's culture. For example: // // AppResources.es-ES.resx // ResourceLanguage's value should be "es-ES" // ResourceFlowDirection's value should be "LeftToRight" // // AppResources.ar-SA.resx // ResourceLanguage's value should be "ar-SA" // ResourceFlowDirection's value should be "RightToLeft" // // For more info on localizing Windows Phone apps see http://go.microsoft.com/fwlink/?LinkId=262072. // void InitializeLanguage() { try { // Set the font to match the display language defined by the // ResourceLanguage resource string for each supported language. // // Fall back to the font of the neutral language if the Display // language of the phone is not supported. // // If a compiler error is hit then ResourceLanguage is missing from // the resource file. RootFrame.Language = XmlLanguage.GetLanguage(AppResources.ResourceLanguage); // Set the FlowDirection of all elements under the root frame based // on the ResourceFlowDirection resource string for each // supported language. // // If a compiler error is hit then ResourceFlowDirection is missing from // the resource file. System.Windows.FlowDirection flow = (System.Windows.FlowDirection)Enum.Parse(typeof(System.Windows.FlowDirection), AppResources.ResourceFlowDirection); RootFrame.FlowDirection = flow; } catch { // If an exception is caught here it is most likely due to either // ResourceLangauge not being correctly set to a supported language // code or ResourceFlowDirection is set to a value other than LeftToRight // or RightToLeft. if (Debugger.IsAttached) { Debugger.Break(); } throw; } }