static void AnimationCircle(StackView stackView) { var circleExample = new CircleView(); stackView.AddChild(circleExample); circleExample.Allocation = new Rectangle(0, 0, 100, 100); Task.Run(() => { bool positive = true; int addition = 5; while (true) { NSApplication.SharedApplication.InvokeOnMainThread(() => { if (circleExample.Allocation.Width <= 0) { return; } var circleWidth = circleExample.Width; if (positive) { circleWidth += addition; circleExample.Width = circleWidth; if (circleWidth > 150) { positive = false; } } else { circleWidth -= addition; circleExample.Width = circleWidth; if (circleWidth < 50) { positive = true; } } }); Thread.Sleep(50); } }); var rnd = new Random(); var button = new Button() { Text = "Press" }; stackView.AddChild(button); button.Clicked += (s, e) => { var randomColor = new NGraphics.Color(rnd.NextDouble(), rnd.NextDouble(), rnd.NextDouble(), 1); circleExample.Brush = new NGraphics.SolidBrush(randomColor); }; }
static void Main(string[] args) { FigmaApplication.Init(Environment.GetEnvironmentVariable("TOKEN")); NSApplication.Init(); NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Regular; var stackView = new StackView() { Orientation = LayoutOrientation.Vertical }; var frame = new Rectangle(0, 0, 800, 600); var mainWindow = new Window(frame) { Title = "Cocoa Figma Local File Sample", Content = stackView }; scrollView = new ScrollView(); stackView.AddChild(scrollView); var converters = FigmaSharp.AppContext.Current.GetFigmaConverters(); var storyboard = new FigmaStoryboard(converters); documentExample = new DocumentExample(scrollView, storyboard); mainWindow.Show(); NSApplication.SharedApplication.ActivateIgnoringOtherApps(true); NSApplication.SharedApplication.Run(); }
static void Main(string[] args) { FigmaApplication.Init(Environment.GetEnvironmentVariable("TOKEN")); NSApplication.Init(); NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Regular; var stackView = new StackView() { Orientation = LayoutOrientation.Vertical }; var mainWindow = new Window(new Rectangle(0, 0, 540, 800)) { Content = stackView }; mainWindow.Closing += delegate { NSRunningApplication.CurrentApplication.Terminate(); }; scrollView = new ScrollView(); stackView.AddChild(scrollView); manager = new ExampleViewManager(scrollView); mainWindow.Title = manager.WindowTitle; mainWindow.Show(); NSApplication.SharedApplication.ActivateIgnoringOtherApps(true); NSApplication.SharedApplication.Run(); }
static void Main(string[] args) { NSApplication.Init(); NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Regular; var mainWindow = new Window(new Rectangle(0, 0, 540, 800)) { Title = "Test Window", }; var stackView = new StackView() { Orientation = LayoutOrientation.Vertical }; mainWindow.Content = stackView; var path = System.IO.Path.GetDirectoryName(System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)); path = System.IO.Path.Combine(path, "Resources", "mydraw.svg"); var data = System.IO.File.ReadAllText(path); SvgShapeView shapeView = new SvgShapeView(); shapeView.Allocation = new Rectangle(0, 0, 100, 100); stackView.AddChild(shapeView); shapeView.Load(data); //AnimationCircle(stackView); mainWindow.Show(); //mainWindow.Closing += delegate { NSRunningApplication.CurrentApplication.Terminate(); }; NSApplication.SharedApplication.ActivateIgnoringOtherApps(true); NSApplication.SharedApplication.Run(); }
public MainSample() { mainWindow = new Window(new Rectangle(0, 0, 540, 800)) { Title = "Test Window", }; menuStackView = new StackView { Orientation = LayoutOrientation.Vertical, Padding = new Padding(10), Allocation = new Rectangle(0, 0, menuWidth, mainWindow.Content.Allocation.Height), BackgroundColor = Color.Green }; mainWindow.Content.AddChild(menuStackView); //contentView = new View() { // Allocation = new Rectangle(menuWidth, 0, mainWindow.Content.Allocation.Width - menuWidth, mainWindow.Content.Allocation.Height), // BackgroundColor = Color.Red //}; mainWindow.Resize += (s, e) => Refresh(); //examples foreach (var example in examples) { var example1Button = new Button() { Text = example.name }; menuStackView.AddChild(example1Button); example1Button.Clicked += (s, e) => Select(example.sample); } //mainWindow.Content.AddChild(contentView); mainWindow.Show(); }
static void Main(string[] args) { NSApplication.Init(); NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Regular; mainWindow = new Window(new Rectangle(0, 0, 567, 675)) { Title = "Test Window", Resizable = false, }; //mainWindow.Content.BackgroundColor = Color.Black; //mainWindow.Content.BackgroundColor = Color.Transparent; mainWindow.Center(); mainWindow.MovableByWindowBackground = mainWindow.Content.MovableByWindowBackground = true; //mainWindow.Borderless = true; //mainWindow.IsOpaque = false; //mainWindow.BackgroundColor = Color.Transparent; mainWindow.IsFullSizeContentView = true; buttonContentStackView = new StackView() { Orientation = LayoutOrientation.Horizontal, Allocation = new Rectangle(0, 0, mainWindow.Size.Width, 20), MovableByWindowBackground = true }; mainWindow.Content.AddChild(buttonContentStackView); actionContainerView = new OptionsPanelGradienContentView() { Allocation = new Rectangle(10, 25, mainWindow.Size.Width - 20, mainWindow.Size.Height - 35), MovableByWindowBackground = true }; mainWindow.Content.AddChild(actionContainerView); page1 = new Page1(actionContainerView); page2 = new Page2(actionContainerView); //page3 = new Page3(actionContainerView); var button = new Button() { Text = "Transformation" }; buttonContentStackView.AddChild(button); button.Clicked += (s, e) => SelectPage(page1); var button2 = new Button() { Text = "Svg" }; buttonContentStackView.AddChild(button2); button2.Clicked += (s, e) => SelectPage(page2); var button3 = new Button() { Text = "Shapes" }; buttonContentStackView.AddChild(button3); //button3.Clicked += (s, e) => SelectPage(page3); //scrollView.SetContentSize(800, 1000); mainWindow.Resize += (s, e) => Refresh(); SelectPage(page2); mainWindow.Show(); NSApplication.SharedApplication.ActivateIgnoringOtherApps(true); NSApplication.SharedApplication.Run(); }
public OptionsPanelGradienContentView() { //content of first optionContainer = new StackView { Orientation = LayoutOrientation.Vertical, Padding = new Padding(20) }; OperationsView.AddChild(optionContainer); //x var line1 = new StackView { Orientation = LayoutOrientation.Horizontal, Padding = new Padding(LinePadding), ItemSpacing = 20 }; optionContainer.AddChild(line1); line1.AddChild(new Label { Text = "X", ForegroundColor = Color.White }); sliderX = new Slider { MaxValue = maxValue, MinValue = 0, Value = midValue, Size = new Size(100, 20) }; line1.AddChild(sliderX); //y var line2 = new StackView { Orientation = LayoutOrientation.Horizontal, Padding = new Padding(LinePadding), ItemSpacing = 20 }; optionContainer.AddChild(line2); line2.AddChild(new Label { Text = "Y", ForegroundColor = Color.White }); sliderY = new Slider { MaxValue = maxValue, MinValue = 0, Value = midValue, Size = new Size(100, 20) }; line2.AddChild(sliderY); //rotate var line3 = new StackView { Orientation = LayoutOrientation.Horizontal, Padding = new Padding(LinePadding), ItemSpacing = 20 }; optionContainer.AddChild(line3); line3.AddChild(new Label { Text = "Scale", ForegroundColor = Color.White }); sliderScale = new Slider { MaxValue = 2, MinValue = 0, Value = 1, Size = new Size(100, 20) }; line3.AddChild(sliderScale); //rotate var line4 = new StackView { Orientation = LayoutOrientation.Horizontal, Padding = new Padding(LinePadding), ItemSpacing = 20 }; optionContainer.AddChild(line4); line4.AddChild(new Label { Text = "Rotate", ForegroundColor = Color.White }); sliderRotate = new Slider { MaxValue = 90, MinValue = 0, Value = 0, Size = new Size(100, 20) }; line4.AddChild(sliderRotate); sliderX.ValueChanged += (s, e) => view?.ApplyTransform(GetActualTranformation()); sliderY.ValueChanged += (s, e) => view?.ApplyTransform(GetActualTranformation()); sliderScale.ValueChanged += (s, e) => view?.ApplyTransform(GetActualTranformation()); sliderRotate.ValueChanged += (s, e) => view?.ApplyTransform(GetActualTranformation()); }