瀏覽代碼

Code cleanup

Nikita Tsukanov 9 年之前
父節點
當前提交
d1ac5a4002

+ 2 - 2
samples/ControlCatalog.Desktop/Program.cs

@@ -16,8 +16,8 @@ namespace ControlCatalog
 
             // TODO: Make this work with GTK/Skia/Cairo depending on command-line args
             // again.
-            AppBuilder.Configure<App>().UseGtk().UseCairo()
-                //.UsePlatformDetect()
+            AppBuilder.Configure<App>()
+                .UsePlatformDetect()
                 .Start<MainWindow>();
         }
 

+ 3 - 3
samples/ControlCatalog/ControlCatalog.csproj

@@ -38,7 +38,7 @@
     <EmbeddedResource Include="App.xaml">
       <SubType>Designer</SubType>
     </EmbeddedResource>
-    <EmbeddedResource Include="ControlCatalogControl.xaml">
+    <EmbeddedResource Include="MainView.xaml">
       <SubType>Designer</SubType>
     </EmbeddedResource>
     <EmbeddedResource Include="Pages\BorderPage.xaml">
@@ -88,8 +88,8 @@
     <Compile Include="App.xaml.cs">
       <DependentUpon>App.xaml</DependentUpon>
     </Compile>
-    <Compile Include="ControlCatalogControl.xaml.cs">
-      <DependentUpon>ControlCatalogControl.xaml</DependentUpon>
+    <Compile Include="MainView.xaml.cs">
+      <DependentUpon>MainView.xaml</DependentUpon>
     </Compile>
     <Compile Include="MainWindow.xaml.cs">
       <DependentUpon>MainWindow.xaml</DependentUpon>

+ 0 - 0
samples/ControlCatalog/ControlCatalogControl.xaml → samples/ControlCatalog/MainView.xaml


+ 2 - 2
samples/ControlCatalog/ControlCatalogControl.xaml.cs → samples/ControlCatalog/MainView.xaml.cs

@@ -4,9 +4,9 @@ using Avalonia.Markup.Xaml;
 
 namespace ControlCatalog
 {
-    public class ControlCatalogControl : UserControl
+    public class MainView : UserControl
     {
-        public ControlCatalogControl()
+        public MainView()
         {
             this.InitializeComponent();
         }

+ 1 - 1
samples/ControlCatalog/MainWindow.xaml

@@ -2,5 +2,5 @@
         Title="Avalonia Control Gallery"
         Icon="resm:ControlCatalog.Assets.test_icon.ico?assembly=ControlCatalog"
         xmlns:local="clr-namespace:ControlCatalog;assembly=ControlCatalog">
-    <local:ControlCatalogControl/>
+    <local:MainView/>
 </Window>

+ 2 - 0
samples/ControlCatalog/MainWindow.xaml.cs

@@ -20,6 +20,8 @@ namespace ControlCatalog
             var theme = new Avalonia.Themes.Default.DefaultTheme();
             theme.FindResource("Button");
             AvaloniaXamlLoader.Load(this);
+
+            PointerPressed += delegate { Measure(new Size(1, 1)); };
         }
     }
 }

+ 3 - 1
samples/interop/GtkInteropDemo/MainWindow.cs

@@ -19,7 +19,9 @@ namespace GtkInteropDemo
             left.Add(new Button("I'm GTK button"));
             left.Add(new Calendar());
             root.PackEnd(left, false, false, 0);
-            root.PackStart(new GtkAvaloniaControlHost() {Content = new ControlCatalogControl()}, true, true, 0);
+            var host = new GtkAvaloniaControlHost() {Content = new MainView()};
+            host.SetSizeRequest(600, 600);
+            root.PackStart(host, true, true, 0);
             Add(root);
             
             ShowAll();

+ 1 - 1
samples/interop/WindowsInteropTest/EmbedToWinFormsDemo.cs

@@ -17,7 +17,7 @@ namespace WindowsInteropTest
         public EmbedToWinFormsDemo()
         {
             InitializeComponent();
-            avaloniaHost.Content = new ControlCatalogControl();
+            avaloniaHost.Content = new MainView();
         }
     }
 }

+ 1 - 1
samples/interop/WindowsInteropTest/EmbedToWpfDemo.xaml.cs

@@ -25,7 +25,7 @@ namespace WindowsInteropTest
         public EmbedToWpfDemo()
         {
             InitializeComponent();
-            Host.Content =  new ControlCatalogControl();
+            Host.Content =  new MainView();
         }
     }
 }

+ 1 - 1
src/Avalonia.Controls/Avalonia.Controls.csproj

@@ -56,7 +56,7 @@
     <Compile Include="HotkeyManager.cs" />
     <Compile Include="IApplicationLifecycle.cs" />
     <Compile Include="IScrollable.cs" />
-    <Compile Include="EmbeddableControlRoot.cs" />
+    <Compile Include="Embedding\EmbeddableControlRoot.cs" />
     <Compile Include="Platform\IEmbeddableWindowImpl.cs" />
     <Compile Include="WindowIcon.cs" />
     <Compile Include="IPseudoClasses.cs" />

+ 1 - 6
src/Avalonia.Controls/EmbeddableControlRoot.cs → src/Avalonia.Controls/Embedding/EmbeddableControlRoot.cs

@@ -1,15 +1,11 @@
 using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 using Avalonia.Controls.Platform;
 using Avalonia.Input;
 using Avalonia.Layout;
 using Avalonia.Platform;
 using Avalonia.Styling;
 
-namespace Avalonia.Controls
+namespace Avalonia.Controls.Embedding
 {
     public class EmbeddableControlRoot : TopLevel, IStyleable, IFocusScope, INameScope, IDisposable
     {
@@ -33,7 +29,6 @@ namespace Avalonia.Controls
             LayoutManager.Instance.ExecuteInitialLayoutPass(this);
         }
 
-
         private void EnsureInitialized()
         {
             if (!this.IsInitialized)

+ 1 - 0
src/Avalonia.Controls/Properties/AssemblyInfo.cs

@@ -11,6 +11,7 @@ using Avalonia.Metadata;
 
 [assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia")]
 [assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Controls")]
+[assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Controls.Embedding")]
 [assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Controls.Presenters")]
 [assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Controls.Primitives")]
 [assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Controls.Shapes")]

+ 5 - 4
src/Gtk/Avalonia.Cairo/RenderTarget.cs

@@ -49,17 +49,18 @@ namespace Avalonia.Cairo
         /// </summary>
         /// <returns>A surface wrapped in an <see cref="Avalonia.Media.DrawingContext"/>.</returns>
         public DrawingContext CreateDrawingContext() => new DrawingContext(CreateMediaDrawingContext());
+
         public IDrawingContextImpl CreateMediaDrawingContext()
         {
-            if(_window!=null)
+            if (_window != null)
                 return new Media.DrawingContext(_window.GdkWindow);
             if (_surface != null)
                 return new Media.DrawingContext(_surface);
-            if(_area!=null)
+            if (_area != null)
                 return new Media.DrawingContext(_area.GdkWindow);
-            throw new InvalidOperationException();
+            throw new InvalidOperationException("Unspecified render target");
         }
-        
+
         public void Dispose() => _surface?.Dispose();
     }
 }

+ 2 - 11
src/Gtk/Avalonia.Gtk/EmbeddableImpl.cs

@@ -24,7 +24,6 @@ namespace Avalonia.Gtk
 
         public EmbeddableImpl() : this(new PlatformHandleAwareDrawingArea())
         {
-            
         }
 
         private void Plug_SizeAllocated(object o, SizeAllocatedArgs args)
@@ -35,45 +34,37 @@ namespace Avalonia.Gtk
         public override Size ClientSize
         {
             get { return new Size(Widget.Allocation.Width, Widget.Allocation.Height); }
-            set { }
+            set {}
         }
 
 
         //Stubs are needed for future GTK designer embedding support
         public override void SetTitle(string title)
         {
-            
         }
 
         public override IDisposable ShowDialog() => Disposable.Create(() => { });
 
         public override void SetSystemDecorations(bool enabled)
         {
-            
         }
 
         public override void SetIcon(IWindowIconImpl icon)
         {
-            
         }
 
         public override void BeginMoveDrag()
         {
-            
         }
 
         public override void BeginResizeDrag(WindowEdge edge)
         {
-            
         }
 
         public override Point Position
         {
             get { return new Point(); } 
-            set
-            {
-                
-            }
+            set {}
         }
     }
 }

+ 1 - 8
src/Gtk/Avalonia.Gtk/Embedding/GtkAvaloniaControlHost.cs

@@ -4,6 +4,7 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using Avalonia.Controls;
+using Avalonia.Controls.Embedding;
 using Avalonia.Diagnostics;
 using Avalonia.Layout;
 using Avalonia.Platform;
@@ -38,14 +39,6 @@ namespace Avalonia.Gtk.Embedding
             }
         }
 
-        protected override void OnSizeRequested(ref Requisition requisition)
-        {
-            requisition.Width = 700;
-            requisition.Height = 500;
-           
-        }
-
-
         IntPtr IPlatformHandle.Handle => PlatformHandleAwareWindow.GetNativeWindow(GdkWindow);
 
         string IPlatformHandle.HandleDescriptor => "HWND";

+ 0 - 13
src/Gtk/Avalonia.Gtk/WindowImplBase.cs

@@ -29,8 +29,6 @@ namespace Avalonia.Gtk
         private uint _lastKeyEventTimestamp;
 
         private static readonly Gdk.Cursor DefaultCursor = new Gdk.Cursor(CursorType.LeftPtr);
-        
-
 
         protected WindowImplBase(Gtk.Widget window)
         {
@@ -113,10 +111,6 @@ namespace Avalonia.Gtk
 
         public double Scaling => 1;
 
-
-
-
-
         public Action Activated { get; set; }
 
         public Action Closed { get; set; }
@@ -155,7 +149,6 @@ namespace Avalonia.Gtk
         {
             int x, y;
             _window.GdkWindow.GetDeskrelativeOrigin(out x, out y);
-
             return new Point(point.X + x, point.Y + y);
         }
 
@@ -182,7 +175,6 @@ namespace Avalonia.Gtk
         public abstract void BeginResizeDrag(WindowEdge edge);
         public abstract Point Position { get; set; }
 
-
         void ITopLevelImpl.Activate()
         {
             _window.Activate();
@@ -251,8 +243,6 @@ namespace Avalonia.Gtk
             Input(e);
         }
 
-
-
         void OnDestroyed(object sender, EventArgs eventArgs)
         {
             Closed();
@@ -278,7 +268,6 @@ namespace Avalonia.Gtk
             ProcessKeyEvent(args.Event);
         }
 
-
         void OnKeyReleaseEvent(object o, Gtk.KeyReleaseEventArgs args)
         {
             args.RetVal = true;
@@ -313,8 +302,6 @@ namespace Avalonia.Gtk
             args.RetVal = true;
         }
 
-
-
         public void Dispose()
         {
             _window.Dispose();

+ 1 - 0
src/Windows/Avalonia.Win32/Embedding/WinFormsAvaloniaControlHost.cs

@@ -2,6 +2,7 @@
 using System.ComponentModel;
 using System.Windows.Forms;
 using Avalonia.Controls;
+using Avalonia.Controls.Embedding;
 using Avalonia.Input;
 using Avalonia.VisualTree;
 using Avalonia.Win32.Interop;