Beispiel #1
0
	public static void Main(string[] args) {
		Opts options = new Opts();
		options.ProcessArgs(args);
		
		if (options.RemainingArguments.Length < 2) {
			options.DoHelp();
			return;
		}
		
		Application.Init ();
		
		Window win = new Window("NDiff");
		win.DeleteEvent += new DeleteEventHandler(Window_Delete);
		win.SetDefaultSize(800, 600);
		
		DiffWidget.Options dopts = new DiffWidget.Options();
		dopts.SideBySide = options.sidebyside;

		if (options.RemainingArguments.Length == 2) {
			dopts.LeftName = options.RemainingArguments[0];
			dopts.RightName = options.RemainingArguments[1];
			Diff diff = new Diff(options.RemainingArguments[0], options.RemainingArguments[1], options.caseinsensitive, true);
			win.Add(new DiffWidget(diff, dopts));
		} else {
			Diff[] diffs = new Diff[options.RemainingArguments.Length-1];
			for (int i = 0; i < options.RemainingArguments.Length-1; i++)
				diffs[i] = new Diff(options.RemainingArguments[0], options.RemainingArguments[i+1], options.caseinsensitive, true);
			Merge merge = new Merge(diffs);
			win.Add(new DiffWidget(merge, dopts));
		}		

		win.ShowAll();
		Application.Run();
	}
Beispiel #2
0
	public static int Main9 (string[] args)
	{
		Gtk.Application.Init ();
		Window win = new Window ("Custom Widget Test");
		win.DeleteEvent += new DeleteEventHandler (OnQuit);
		
		VPaned paned = new VPaned ();
		CustomWidget cw = new CustomWidget ();
		cw.Label = "This one contains a button";
		Button button = new Button ("Ordinary button");
		cw.Add (button);
		paned.Pack1 (cw, true, false);

		cw = new CustomWidget ();
		cw.Label = "And this one a TextView";
		cw.StockId = Stock.JustifyLeft;
		ScrolledWindow sw = new ScrolledWindow (null, null);
		sw.ShadowType = ShadowType.In;
		sw.HscrollbarPolicy = PolicyType.Automatic;
		sw.VscrollbarPolicy = PolicyType.Automatic;
		TextView textView = new TextView ();
		sw.Add (textView);
		cw.Add (sw);
		paned.Pack2 (cw, true, false);
		
		win.Add (paned);
		win.ShowAll ();
		Gtk.Application.Run ();
		return 0;
	}
Beispiel #3
0
    public static void Main()
    {
        BusG.Init ();
        Application.Init ();

        tv = new TextView ();
        ScrolledWindow sw = new ScrolledWindow ();
        sw.Add (tv);

        Button btn = new Button ("Click me");
        btn.Clicked += OnClick;

        Button btnq = new Button ("Click me (thread)");
        btnq.Clicked += OnClickQuit;

        VBox vb = new VBox (false, 2);
        vb.PackStart (sw, true, true, 0);
        vb.PackStart (btn, false, true, 0);
        vb.PackStart (btnq, false, true, 0);

        Window win = new Window ("D-Bus#");
        win.SetDefaultSize (640, 480);
        win.Add (vb);
        win.Destroyed += delegate {Application.Quit ();};
        win.ShowAll ();

        bus = Bus.Session.GetObject<IBus> ("org.freedesktop.DBus", new ObjectPath ("/org/freedesktop/DBus"));

        Application.Run ();
    }
Beispiel #4
0
    public TreeViewDemo()
    {
        Application.Init ();
        PopulateStore ();

        Window win = new Window ("TreeView demo");
        win.DeleteEvent += new DeleteEventHandler (DeleteCB);
        win.SetDefaultSize (640,480);

        ScrolledWindow sw = new ScrolledWindow ();
        win.Add (sw);

        TreeView tv = new TreeView (store);
        tv.EnableSearch = true;
        tv.HeadersVisible = true;
        tv.HeadersClickable = true;

        tv.AppendColumn ("Name", new CellRendererText (), "text", 0);
        tv.AppendColumn ("Type", new CellRendererText (), "text", 1);

        sw.Add (tv);

        dialog.Destroy ();
        dialog = null;

        win.ShowAll ();

        Application.Run ();
    }
Beispiel #5
0
    // Constructor
    public Gui()
    {
        Application.Init();

        ioh = new IoHandler();
        win = new Window("Drawing lines");
        darea = new  DrawingArea();
        painter = new DrawShape(DrawLine);
        listenOnMouse = false; // Við hlustum ekki á mús við núllstöðu.

        // Aukum viðburðasett teikniborðs með ,möskum'.
        darea.AddEvents(
                (int)Gdk.EventMask.PointerMotionMask
                | (int)Gdk.EventMask.ButtonPressMask
                | (int)Gdk.EventMask.ButtonReleaseMask);

        // Úthlutum virkni á viðburði.
        win.Hidden += delegate {Application.Quit();};
        win.KeyPressEvent += onKeyboardPressed;
        darea.ExposeEvent += onDrawingAreaExposed;
        darea.ButtonPressEvent += onMouseClicked;
        darea.ButtonReleaseEvent += onMouseReleased;
        darea.MotionNotifyEvent += onMouseMotion;

        // Grunnstillum stærð glugga.
        win.SetDefaultSize(500,500);

        // Lokasamantekt til að virkja glugga.
        win.Add(darea);
        win.ShowAll();
        Application.Run();
    }
Beispiel #6
0
    public static void Main(string[] args)
    {
        Application.Init();

        //Create the Window
        Window myWin = new Window("GtkSpell# Sample App");
        myWin.Resize(200,200);

        //Create a TextView
        TextView myTextView = new TextView();

        SpellCheck mySpellCheck;

        //Bind GtkSpell to our textview
        if (args.Length > 0)
          mySpellCheck = new SpellCheck(myTextView, args[0]);
        else
          mySpellCheck = new SpellCheck(myTextView, "en-us");

        //spellCheck.Detach();
        //spellCheck.();

        //Add the TextView to the form
        myWin.Add(myTextView);

        //Show Everything
        myWin.ShowAll();

        myWin.DeleteEvent += new DeleteEventHandler(delete);

        Application.Run();
    }
Beispiel #7
0
    public FilezooPanel(Filezoo fz)
        : base("Filezoo Panel")
    {
        Fz = fz;
        Decorated = false;
        Resizable = false;
        SkipPagerHint = true;
        SkipTaskbarHint = true;

        FilezooWindow = new Window ("Filezoo");
        Gdk.Colormap cm = FilezooWindow.Screen.RgbaColormap;
        if (cm != null && FilezooWindow.Screen.IsComposited) {
          Widget.DefaultColormap = cm;
          FilezooWindow.Colormap = cm;
        }
        FilezooWindow.Decorated = false;
        FilezooWindow.Add (Fz);
        byte r, g, b;
        r = (byte)(Fz.Renderer.BackgroundColor.R * 255);
        g = (byte)(Fz.Renderer.BackgroundColor.G * 255);
        b = (byte)(Fz.Renderer.BackgroundColor.B * 255);
        FilezooWindow.ModifyBg (StateType.Normal, new Gdk.Color(r,g,b));

        Controls = new FilezooPanelControls(Fz, FilezooWindow);

        Add (Controls);
        Stick ();

        Fz.Width = 400;
        Fz.Height = 1000;
    }
Beispiel #8
0
    public void Run(string[] args)
    {
        Application.Init ();
        PopulateStore ();
        store.SetSortColumnId(2, SortType.Ascending);

        Window win = new Window ("Gtk Widget Attributes");
        win.DeleteEvent += new DeleteEventHandler (DeleteCB);
        win.SetDefaultSize (640,480);

        ScrolledWindow sw = new ScrolledWindow ();
        win.Add (sw);

        TreeView tv = new TreeView (store);
        tv.HeadersVisible = true;

        tv.AppendColumn ("Name", new CellRendererText (), "markup", 0);
        tv.AppendColumn ("Type", new CellRendererText (), "text", 1);

        foreach(TreeViewColumn col in tv.Columns)
            col.Resizable = true;

        tv.SearchColumn = 2;

        sw.Add (tv);

        dialog.Destroy ();
        dialog = null;

        win.ShowAll ();

        Application.Run ();
    }
Beispiel #9
0
    public static void Main()
    {
        BusG.Init ();
        Application.Init ();

        btn = new Button ("Click me");
        btn.Clicked += OnClick;

        VBox vb = new VBox (false, 2);
        vb.PackStart (btn, false, true, 0);

        Window win = new Window ("D-Bus#");
        win.SetDefaultSize (640, 480);
        win.Add (vb);
        win.Destroyed += delegate {Application.Quit ();};
        win.ShowAll ();

        bus = Bus.Session;

        string bus_name = "org.ndesk.gtest";
        ObjectPath path = new ObjectPath ("/org/ndesk/btn");

        if (bus.RequestName (bus_name) == RequestNameReply.PrimaryOwner) {
            bus.Register (path, btn);
            rbtn = btn;
        } else {
            rbtn = bus.GetObject<Button> (bus_name, path);
        }

        //run the main loop
        Application.Run ();
    }
	static int Main (string [] args)
	{
		HTML html;
		Window win;
		Application.Init ();
		html = new HTML ();
		win = new Window ("Test");
		ScrolledWindow sw = new ScrolledWindow ();
		win.Add (sw);
		sw.Add (html);
		HTMLStream s = html.Begin ("text/html");

		if (args.Length > 0) {
			using (StreamReader r = File.OpenText (args [0]))
				s.Write (r.ReadToEnd ());
		} else {
			s.Write ("<html><body>");
			s.Write ("Hello world!");
		}
		
		html.End (s, HTMLStreamStatus.Ok);
		win.ShowAll ();
		Application.Run ();
		return 0;
	}
Beispiel #11
0
    public static void Main()
    {
        BusG.Init ();
        Application.Init ();

        Button btn = new Button ("Click me");
        btn.Clicked += OnClick;

        VBox vb = new VBox (false, 2);
        vb.PackStart (btn, false, true, 0);

        Window win = new Window ("D-Bus#");
        win.SetDefaultSize (640, 480);
        win.Add (vb);
        win.Destroyed += delegate {Application.Quit ();};
        win.ShowAll ();

        bus = Bus.Session;

        string bus_name = "org.ndesk.gtest";
        ObjectPath path = new ObjectPath ("/org/ndesk/test");

        if (bus.RequestName (bus_name) == RequestNameReply.PrimaryOwner) {
            //create a new instance of the object to be exported
            demo = new DemoObject ();
            bus.Register (path, demo);
        } else {
            //import a remote to a local proxy
            demo = bus.GetObject<DemoObject> (bus_name, path);
        }

        //run the main loop
        Application.Run ();
    }
Beispiel #12
0
    public static void Main()
    {
        Application.Init();

        //-- Crear el interfaz
        Window w = new Window("Prueba");
        Button b1 = new Button("Test 1");
        Button b2 = new Button("Test 2");
        HBox h= new HBox();
        w.DeleteEvent += new DeleteEventHandler(Window_Delete);
        b1.Clicked += new EventHandler(Button_Clicked);
        b2.Clicked += new EventHandler(Button2_Clicked);

        h.PackStart(b1,false,false,0);
        h.PackStart(b2,false,false,0);

        w.Add(h);
        w.SetDefaultSize(100,100);
        w.ShowAll();

        //-- Inicializar chronopic
        cp = new Chronopic("/dev/ttyUSB0");

        //-- Inicializar otras cosas
        Cola = new Queue();

        //-- Inicializar temporizador
        GLib.Timeout.Add(100, new GLib.TimeoutHandler(Time_Out));

        Application.Run();
    }
Beispiel #13
0
	static void Main (string [] args)
	{
		Application.Init ();

		if (args.Length <= 0) {
			Console.WriteLine ("\nUSAGE: ImageBrowser.exe <directory>\n");
			return;
		}
	
		string dir = args [0];

		Window window = new Window ("Image Browser");
		ScrolledWindow scroll = new ScrolledWindow ();//(new Adjustment (IntPtr.Zero), new Adjustment (IntPtr.Zero));

		ArrayList images = GetItemsFromDirectory (dir);
		
		Table table = PopulateTable (images);
		
		
		window.Title = String.Format ("{0}: {1} ({2} images)", window.Title, dir, images.Count);
		window.SetDefaultSize (300, 200);
		//window.DeleteEvent += Window_Delete;
		scroll.AddWithViewport (table);
		//scroll.SetPolicy (PolicyType.Automatic, PolicyType.Automatic);
		window.Add (scroll);
		window.ShowAll ();
		Application.Run ();
	}
Beispiel #14
0
	Knockout ()
	{
		Window win = new Window ("Cairo with Gtk#");
		win.SetDefaultSize (400, 400);
		win.DeleteEvent += new DeleteEventHandler (OnQuit);
		win.Add (this);
		win.ShowAll ();
	}
Beispiel #15
0
		public override void Initialize() {
			base.Initialize();

			mDialog = new Window(WindowManager);
			mDialog.Init();
			mDialog.Width = mWidth;
			mDialog.Height = mHeight;
			mDialog.Text = mTitle;
			mDialog.Visible = true;
			mDialog.Resizable = false;
			mDialog.Closed += new WindowClosedEventHandler(mDialog_Closed);

			Label lbl = new Label(WindowManager);
			lbl.Init();
			lbl.Width = mDialog.ClientWidth - 10;
			lbl.Height = mDialog.ClientHeight - 40;
			lbl.Left = 5;
			lbl.Top = 5;
			lbl.Text = mMessage;
			lbl.Alignment = EAlignment.TopCenter;
			mDialog.Add(lbl);

			Panel pnl = new Panel(WindowManager);
			pnl.Height = 40;
			pnl.Top = mDialog.ClientHeight - pnl.Height;
			pnl.BevelBorder = EBevelBorder.Top;
			pnl.BevelMargin = 1;
			pnl.BackColor = new Color(16, 16, 16);
			pnl.Anchor = EAnchors.Bottom | EAnchors.Horizontal;
			pnl.Width = mDialog.ClientWidth;
			mDialog.Add(pnl);

			/*
			 * wont work oO
			Button btnOK = new Button( WindowManager );
			btnOK.Init();
			//btnOK.Width = 20;
			btnOK.Height = 24;
			btnOK.Text = "OK";
			btnOK.Click += new WindowLibrary.Controls.EventHandler( btnOK_Click );
			pnl.Controls.Add( btnOK );
			*/

			AddWindow(mDialog);
		}
 SourceViewTest()
 {
     Window win = new Window ("SourceView test");
     win.SetDefaultSize (600, 400);
     win.WindowPosition = WindowPosition.Center;
     win.DeleteEvent += new DeleteEventHandler (OnWinDelete);
     win.Add (CreateView ());
     win.ShowAll ();
 }
 /// <summary>Returns SpriteViewWidget inserted in a window</summary>
 public static Window CreateWindow(Sprite sprite)
 {
     Gtk.Window window = new Window(WindowType.Popup);
     SpriteViewWidget widget = new SpriteViewWidget(sprite);
     window.SetSizeRequest( (int)sprite.Width, (int)sprite.Height);
     window.Add(widget);
     window.ShowAll();
     return window;
 }
Beispiel #18
0
        public static void Main(string[] args)
        {
            Application.Init ();
            //MainWindow win = new MainWindow ();
            //win.Show ();
            MoonlightRuntime.Init ();
            Window w = new Window ("mldsp");
            w.DefaultHeight = 520;
            w.DefaultWidth = 760;
            w.DeleteEvent += delegate { Application.Quit (); };

            var moon = new MoonlightHost ();
            var xappath = System.IO.Path.Combine (System.IO.Path.GetDirectoryName (new Uri (typeof (MainClass).Assembly.CodeBase).LocalPath), "mldsp.clr.xap");
            moon.LoadXap (xappath);
            if (args.Length > 0) {
                int device;
                if (int.TryParse (args [0], out device))
                    ((mldsp.App) moon.Application).OutputDeviceID = device;
                else {
                    Console.WriteLine ("WARNING: wrong device ID speficication. Specify an index.");
                    foreach (var dev in PortMidiSharp.MidiDeviceManager.AllDevices)
                        if (dev.IsOutput)
                            Console.WriteLine ("{0} {1}", dev.ID, dev.Name);
                }
            }

            var vbox = new VBox (false, 0);
            w.Add (vbox);
            var mainmenu = new MenuBar ();
            vbox.PackStart (mainmenu, false, true, 0);
            var optmi = new MenuItem ("_Options");
            mainmenu.Add (optmi);
            var devmi = new MenuItem ("Select Device");
            var optmenu = new Menu ();
            optmi.Submenu = optmenu;
            optmenu.Append (devmi);
            var devlist = new SList (IntPtr.Zero);
            var devmenu = new Menu ();
            devmi.Submenu = devmenu;
            foreach (var dev in PortMidiSharp.MidiDeviceManager.AllDevices) {
                if (dev.IsOutput) {
                    var mi = new RadioMenuItem (devlist, dev.Name);
                    mi.Data ["Device"] = dev.ID;
                    devlist = mi.Group;
                    int id = dev.ID;
                    mi.Activated += delegate {
                        ((mldsp.App) moon.Application).ResetDevice ((int) mi.Data ["Device"]);
                    };
                    devmenu.Append (mi);
                }
            }

            vbox.PackEnd (moon);

            w.ShowAll ();
            Application.Run ();
        }
Beispiel #19
0
 static void Main()
 {
     Application.Init ();
     Window win = new Window ("Cairo with Gtk# 3");
     win.SetDefaultSize (400, 400);
     win.DeleteEvent += delegate { Application.Quit (); };
     win.Add (new CairoSample ());
     win.ShowAll ();
     Application.Run ();
 }
Beispiel #20
0
	static void SetUpGui ()
	{
		Window w = new Window ("Sign Up");
		w.BorderWidth = 10;
		
		Button b = new Button ("Testing");
		b.BorderWidth = 10;		
		w.Add (b);
		//w.SetDefaultSize (120, 120);
		w.ShowAll ();
	}
Beispiel #21
0
	   public static int Main (string[] args)
	   {
		   Application.Init ();
		   Window win = new Window ("Viewport Tester");
		   win.SetDefaultSize (180, 50);
		   //win.DeleteEvent += new DeleteEventHandler (Window_Delete);
		   ScrolledWindow scroller = CreateViewport();
		   win.Add (scroller);
		   win.ShowAll ();
		   Application.Run ();
                        return 0;
	   }
Beispiel #22
0
	static void SetUpGui ()
	{
		Window w = new Window ("Scale Test");
		
		HScale hscale = new HScale (1, 100, 10);
		hscale.ValueChanged += hscale_value_changed_cb;
		hscale.Value = 50;
		
		w.Add (hscale);
		w.SetDefaultSize (160, 120);
		w.ShowAll ();
	}
Beispiel #23
0
 private void OnVisibilityChanged(object sender, VisibilityChangedEventArgs e)
 {
     if (true == e.Visibility)
     {
         window?.Add(this);
         timer.Start();
     }
     else
     {
         window?.Remove(this);
     }
 }
Beispiel #24
0
    T()
    {
        Application.Init ();
        Window win = new Window ("FileBrowser test");
        win.SetDefaultSize (300, 250);
        win.DeleteEvent += new DeleteEventHandler (OnDelete);

        win.Add (new FileBrowser ());

        win.ShowAll ();
        Application.Run ();
    }
Beispiel #25
0
	static void SetUpGui ()
	{
		Window w = new Window ("Sign Up");
		
		firstname_entry = new Entry ();
		lastname_entry = new Entry ();
		email_entry = new Entry ();
		
		VBox outerv = new VBox ();
		outerv.BorderWidth = 12;
		outerv.Spacing = 12;
		w.Add (outerv);
		
		Label l = new Label ("Enter your name and preferred address");
		l.Xalign = 0;
		//l.UseMarkup = true;
		outerv.PackStart (l, false, false, 0);
		
		HBox h = new HBox ();
		//h.Spacing = 6;
		outerv.PackStart (h);
		
		VBox v = new VBox ();
		//v.Spacing = 6;
		h.PackStart (v, false, false, 0);
		
		Button l2;
		l2 = new Button ("First Name:");
		//l.Xalign = 0;
		v.PackStart (l2, true, false, 0);
		//l.MnemonicWidget = firstname_entry;
		
		l2 = new Button ("Last Name:");
		//l.Xalign = 0;
		v.PackStart (l2, true, false, 0);
		//l.MnemonicWidget = firstname_entry;
		
		l2 = new Button ("Email Address:");
		//l.Xalign = 0;
		v.PackStart (l2, true, false, 0);
		//l.MnemonicWidget = firstname_entry;

		v = new VBox ();
		//v.Spacing = 6;
		h.PackStart (v, true, true, 0);
		
		v.PackStart (firstname_entry, true, true, 0);
		v.PackStart (lastname_entry, true, true, 0);
		v.PackStart (email_entry, true, true, 0);
		
		w.ShowAll ();
	}
Beispiel #26
0
    // IO
    public Gui()
    {
        Application.Init();

        win = new Window("Drawing lines");
        darea = new  DrawingArea();

        win.Add(darea);

        win.ShowAll();

        Application.Run();
    }
Beispiel #27
0
	public static void Main (string[] args)
	{
		Application.Init ();
		Window w = new Window ("MonoSkel project");
		w.DefaultHeight = 200;
		w.DefaultWidth = 250;
		w.DeleteEvent += new DeleteEventHandler (OnDelete);
		Button b = new Button ("This is MonoSkel");
		b.Clicked += new EventHandler (OnClick);
		w.Add (b);
		w.ShowAll ();
		Application.Run ();
	}
Beispiel #28
0
 void HandleCreateWebView(object o, CreateWebViewArgs args)
 {
     Window info = new Window("");
     info.DefaultWidth = 1000;
     info.DefaultHeight = 700;
     VBox vbox2 = new VBox();
     WebView child = new WebView();
     child.NavigationRequested += HandleNavigationRequested1;
     vbox2.PackStart(child);
     info.Add (vbox2);
     info.ShowAll();
     args.RetVal = child;
 }
	static void Main ()
	{
		Gtk.Application.Init ();
		file = FileFactory.NewForUri (new Uri ("smb://[email protected]/myshare/test"));

		Window w = new Window ("test");
		operation = new Gtk.MountOperation (w);
		Button b = new Button ("Mount");
		b.Clicked += new System.EventHandler (HandleButtonClicked);
		b.Show ();
		w.Add (b);
		w.Show ();
		Gtk.Application.Run ();
	}
Beispiel #30
0
	static void SetUpGui ()
	{
		Window w = new Window ("Sign Up");
		
		Button b = new Button ("Testing");
		
		Frame f = new Frame ("My Frame");
		
		f.Add (b);
		
		w.Add (f);
		//w.SetDefaultSize (120, 120);
		w.ShowAll ();
	}
        /// <summary>
        /// Performs stage specific processing on the compiler context.
        /// </summary>
        public override void Run()
        {
            Window window = new Window(5);

            foreach (BasicBlock block in BasicBlocks)
                for (Context ctx = CreateContext(block); !ctx.EndOfInstruction; ctx.GotoNext())
                    if (ctx.Instruction != null && !ctx.Ignore)
                    {
                        window.Add(ctx);

                        //RemoveMultipleStores(window);
                        RemoveSingleLineJump(window);
                        ImproveBranchAndJump(window);
                    }
        }
Beispiel #32
0
        public void Activate()
        {
            Window window = NUIApplication.GetDefaultWindow();

            // Root layout.
            layout[0] = new View()
            {
                Size            = new Size(1920, 1080),
                BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f),
            };
            layout[0].Layout = new LinearLayout()
            {
                LinearOrientation = LinearLayout.Orientation.Vertical,
                LinearAlignment   = LinearLayout.Alignment.Center
            };
            window.Add(layout[0]);

            // Layout for progress parent layout.
            layout[1] = new View()
            {
                Size = new Size(1000, 730)
            };
            layout[1].Layout = new LinearLayout()
            {
                LinearOrientation = LinearLayout.Orientation.Horizontal,
                LinearAlignment   = LinearLayout.Alignment.Center
            };
            layout[0].Add(layout[1]);

            // Layout for progress layout which is created by properties.
            layout[2] = new View()
            {
                Size = new Size(450, 630)
            };
            layout[2].Layout = new LinearLayout()
            {
                LinearOrientation = LinearLayout.Orientation.Vertical,
                LinearAlignment   = LinearLayout.Alignment.CenterHorizontal,
                CellPadding       = new Size2D(50, 100)
            };
            layout[1].Add(layout[2]);

            // Layout for progress layout which is created by attributes.
            layout[3] = new View()
            {
                Size = new Size(450, 630)
            };
            layout[3].Layout = new LinearLayout()
            {
                LinearOrientation = LinearLayout.Orientation.Vertical,
                LinearAlignment   = LinearLayout.Alignment.CenterHorizontal,
                CellPadding       = new Size2D(50, 100)
            };
            layout[1].Add(layout[3]);

            CreatePropElements();
            CreateAttrElements();
            CreateIndeterminateProgress();
            layout[1].Add(layout[2]);
            layout[1].Add(layout[3]);

            board[0] = new TextLabel();
            board[0].WidthSpecification  = 900;
            board[0].HeightSpecification = 100;
            board[0].PointSize           = 30;
            board[0].HorizontalAlignment = HorizontalAlignment.Center;
            board[0].VerticalAlignment   = VerticalAlignment.Center;
            board[0].BackgroundColor     = Color.Magenta;
            board[0].Text = "log pad";
            layout[0].Add(board[0]);
            board[0].Focusable       = true;
            board[0].FocusGained    += Board_FocusGained;
            board[0].FocusLost      += Board_FocusLost;
            board[0].UpFocusableView = button[0];
            FocusManager.Instance.SetCurrentFocusView(button[0]);
        }
Beispiel #33
0
    //
    static void Editor()
    {
        Application.Init();

        var ntop = Application.Top;

        var text = new TextView()
        {
            X = 0, Y = 0, Width = Dim.Fill(), Height = Dim.Fill()
        };

        string fname = GetFileName();

        var win = new Window(fname ?? "Untitled")
        {
            X      = 0,
            Y      = 1,
            Width  = Dim.Fill(),
            Height = Dim.Fill()
        };

        ntop.Add(win);

        if (fname != null)
        {
            text.Text = System.IO.File.ReadAllText(fname);
        }
        win.Add(text);

        void Paste()
        {
            if (text != null)
            {
                text.Paste();
            }
        }

        void Cut()
        {
            if (text != null)
            {
                text.Cut();
            }
        }

        void Copy()
        {
            if (text != null)
            {
                text.Copy();
            }
        }

        var menu = new MenuBar(new MenuBarItem [] {
            new MenuBarItem("_File", new MenuItem [] {
                new MenuItem("_Close", "", () => { if (Quit())
                                                   {
                                                       running = MainApp; Application.RequestStop();
                                                   }
                             }, null, null, Key.AltMask | Key.Q),
            }),
            new MenuBarItem("_Edit", new MenuItem [] {
                new MenuItem("_Copy", "", Copy, null, null, Key.C | Key.CtrlMask),
                new MenuItem("C_ut", "", Cut, null, null, Key.X | Key.CtrlMask),
                new MenuItem("_Paste", "", Paste, null, null, Key.Y | Key.CtrlMask)
            }),
        });

        ntop.Add(menu);

        Application.Run(ntop);
    }
        public void ShowNcaInfo()
        {
            Window.RemoveAll();

            string  NcaPath = (string)Utils.FirmwareUtils.OpenNcaStorageByTitleName(Path, FwTui.NcaNames[FwTui.FirmwareListView.SelectedItem], true);
            NcaInfo ncaInfo = new NcaInfo(new LocalStorage(NcaPath, FileAccess.Read));

            List <string> NcaInfoLines = new List <string>();

            string FormattedTid  = $"{ncaInfo.Nca.Header.TitleId:X16}";
            string FormattedName = $"{ncaInfo.TitleName}";

            NcaInfoLines.Add($"Title ID: {FormattedTid}");

            if (FormattedName != FormattedTid)
            {
                NcaInfoLines.Add($"Title Name: {FormattedName}");
            }

            NcaInfoLines.Add($"Content Type: {ncaInfo.Nca.Header.ContentType}");

            string ncaID = NcaPath.Split("/").Last();

            if (ncaID == "00.nca")
            {
                ncaID = NcaPath.Split("/")[NcaPath.Split("/").Length - 2];
            }
            else
            {
                ncaID = ncaID.Replace(".nca", "");
            }

            NcaInfoLines.Add($"Nca ID: {ncaID}");

            for (NcaSectionType section = NcaSectionType.Code; section <= NcaSectionType.Logo; section++)
            {
                if (ncaInfo.Nca.SectionExists(section))
                {
                    NcaInfoLines.Add($"\n{section}");
                    try
                    {
                        using (PartitionFileSystem pfs = new PartitionFileSystem(ncaInfo.TryOpenStorageSection(section)))
                        {
                            foreach (DirectoryEntryEx dirEnt in pfs.EnumerateEntries())
                            {
                                NcaInfoLines.Add($"{dirEnt.Name} - {dirEnt.Size} bytes");
                            }
                        }
                    }
                    catch (LibHac.HorizonResultException) { }
                }
            }


            //Actually draw them
            int Y = 1;

            foreach (string content in NcaInfoLines)
            {
                int lines = System.Text.RegularExpressions.Regex.Matches(content, "\n").Count + 1;
                Window.Add(new Label(1, Y, content));
                Y += lines;
            }
        }
Beispiel #35
0
    static void SetUpGui()
    {
        Window w = new Window("Eap Editor");

        appname_entry  = new Entry();
        geninfo_entry  = new Entry();
        comments_entry = new Entry();
        exe_entry      = new Entry();
        winname_entry  = new Entry();
        winclass_entry = new Entry();

        VBox outerv = new VBox();

        outerv.BorderWidth = 12;
        outerv.Spacing     = 12;
        w.Add(outerv);

        HBox h = new HBox();

        outerv.PackStart(h, false, false, 0);

        Button b = new Button("Select Icon");

        h.PackStart(b, true, false, 0);

        h         = new HBox();
        h.Spacing = 6;
        outerv.PackStart(h);

        VBox v = new VBox();

        v.Spacing = 6;
        h.PackStart(v, false, false, 0);

        b = new Button("App name:");
        v.PackStart(b, true, false, 0);

        b = new Button("Generic Info:");
        v.PackStart(b, true, false, 0);

        b = new Button("Comments:");
        v.PackStart(b, true, false, 0);

        b = new Button("Executable:");
        v.PackStart(b, true, false, 0);

        b = new Button("Window Name:");
        v.PackStart(b, true, false, 0);

        b = new Button("Window Class:");
        v.PackStart(b, true, false, 0);

        b = new Button("Startup notify:");
        v.PackStart(b, true, false, 0);

        b = new Button("Wait Exit:");
        v.PackStart(b, true, false, 0);

        v         = new VBox();
        v.Spacing = 6;
        h.PackStart(v, true, true, 0);

        v.PackStart(appname_entry, true, true, 0);
        v.PackStart(geninfo_entry, true, true, 0);
        v.PackStart(comments_entry, true, true, 0);
        v.PackStart(exe_entry, true, true, 0);
        v.PackStart(winname_entry, true, true, 0);
        v.PackStart(winclass_entry, true, true, 0);
        //v.PackStart (new Entry(), true, true, 0);
        //v.PackStart (new Entry(), true, true, 0);

        CheckButton start_cbox = new CheckButton();

        v.PackStart(start_cbox);

        CheckButton wait_cbox = new CheckButton();

        v.PackStart(wait_cbox);

        h         = new HBox();
        h.Spacing = 0;
        outerv.PackStart(h);

        v = new VBox();
        b = new Button("Save");
        v.PackStart(b, true, false, 0);
        h.PackStart(v, true, false, 0);

        v = new VBox();
        b = new Button("Cancel");
        v.PackStart(b, true, false, 0);
        h.PackStart(v, true, false, 0);

        w.ShowAll();
    }
Beispiel #36
0
        public override void Create()
        {
            Window window = Window.Instance;

            _view = new View()
            {
                Name                = "MessageExample",
                PositionY           = YOffset,
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = Window.Instance.Size.Height - YOffset,
            };

            var layout = new LinearLayout();

            layout.LinearOrientation = LinearLayout.Orientation.Vertical;
            _view.Layout             = layout;

            window.Add(_view);

            // Create compose toolbar

            // Create compose label
            TextLabel composeLabel = new TextLabel("Compose");

            composeLabel.Name = "composeLabel";
            composeLabel.HeightSpecification = LayoutParamPolicies.MatchParent;
            composeLabel.WidthSpecification  = LayoutParamPolicies.WrapContent;
            toolbarItems.Add(composeLabel);

            // Create attachment button
            Button attachmentButton = new Button();

            attachmentButton.Name = "attachmentButton";
            attachmentButton.HeightSpecification = LayoutParamPolicies.MatchParent;
            attachmentButton.WidthSpecification  = 80; // Could instead set the Weight to 1 along with sendButton

            var imageVisualAttachmentUnSelected = new ImageVisual();

            imageVisualAttachmentUnSelected.URL = "./res/images/paper-clip.png";
            //attachmentButton.UnselectedBackgroundVisual = imageVisualAttachmentUnSelected.OutputVisualMap;
            var imageVisualAttachmentSelected = new ImageVisual();

            imageVisualAttachmentSelected.URL = "./res/images/paper-clip-selected.png";
            //attachmentButton.SelectedBackgroundVisual = imageVisualAttachmentSelected.OutputVisualMap;
            toolbarItems.Add(attachmentButton);

            // Create send button
            Button sendButton = new Button();

            sendButton.Name = "sendButton";
            sendButton.HeightSpecification = LayoutParamPolicies.MatchParent;
            sendButton.WidthSpecification  = 120; // Could instead set the Weight to 2 along with attachmentButton

            var imageVisualSendSelected = new ImageVisual();

            imageVisualSendSelected.URL = "./res/images/send-email-selected.png";
            //sendButton.SelectedBackgroundVisual = imageVisualSendSelected.OutputVisualMap;
            var imageVisualSendUnselected = new ImageVisual();

            imageVisualSendUnselected.URL = "./res/images/send-email.png";
            //sendButton.UnselectedBackgroundVisual = imageVisualSendUnselected.OutputVisualMap;
            toolbarItems.Add(sendButton);

            View titleToolbar = CreateTitleToolbar("Compose", toolbarItems);

            titleToolbar.HeightSpecification = 40;

            _view.Add(titleToolbar);

            // Create "To" area
            TextField toArea = new TextField()
            {
                Name = "toLabel",
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.WrapContent,
                Margin               = new Extents(5, 0, 10, 0),
                PlaceholderText      = "To",
                PlaceholderTextColor = new Color(202.0f, 202.0f, 202.0f, 0.7f),
                EnableSelection      = false,
                BackgroundColor      = new Color(232.0f, 222.0f, 232.0f, 0.7f),
            };

            _view.Add(toArea);

            // Create "Subject" area
            TextField subjectArea = new TextField()
            {
                Name = "subjectArea",
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.WrapContent,
                Margin               = new Extents(5, 0, 10, 0),
                PlaceholderText      = "Subject",
                PlaceholderTextColor = new Color(202.0f, 202.0f, 202.0f, 0.7f),
                EnableSelection      = false,
                BackgroundColor      = new Color(232.0f, 222.0f, 232.0f, 0.7f),
            };

            _view.Add(subjectArea);

            // Create "Body" area
            TextField bodyArea = new TextField()
            {
                Name = "bodyArea",
                WidthSpecification   = LayoutParamPolicies.MatchParent,
                Margin               = new Extents(5, 0, 10, 10),
                Weight               = 1,
                PlaceholderText      = "Compose",
                PlaceholderTextColor = new Color(202.0f, 202.0f, 202.0f, 0.7f),
                EnableSelection      = false,
                BackgroundColor      = new Color(232.0f, 222.0f, 232.0f, 0.7f),
            };

            _view.Add(bodyArea);
        }
Beispiel #37
0
        public void Activate()
        {
            Window window = Window.Instance;

            root = new View()
            {
                Size2D = new Size2D(1920, 1080),
            };
            window.Add(root);

            ///////////////////////////////////////////////Create by Property//////////////////////////////////////////////////////////
            createText[0]            = new TextLabel();
            createText[0].Text       = "Create Switch just by properties";
            createText[0].Size2D     = new Size2D(500, 100);
            createText[0].Position2D = new Position2D(400, 100);
            root.Add(createText[0]);

            int num = 4;

            for (int i = 0; i < num; i++)
            {
                modeText[i]            = new TextLabel();
                modeText[i].Text       = mode[i];
                modeText[i].Size2D     = new Size2D(200, 48);
                modeText[i].Position2D = new Position2D(300 + 200 * i, 200);
                root.Add(modeText[i]);
            }

            for (int i = 0; i < num; i++)
            {
                utilitySwitch[i]                         = new Switch();
                utilitySwitch[i].Size2D                  = new Size2D(96, 60);
                utilitySwitch[i].Position2D              = new Position2D(300, 300 + i * 100);
                utilitySwitch[i].Style.Thumb.Size        = new Size(60, 60);
                utilitySwitch[i].Style.Track.ResourceUrl = new Selector <string>
                {
                    Normal           = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off.png",
                    Selected         = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_on.png",
                    Disabled         = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off_dim.png",
                    DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_on_dim.png",
                };
                utilitySwitch[i].Style.Thumb.ResourceUrl = new Selector <string>
                {
                    Normal           = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler.png",
                    Selected         = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler.png",
                    Disabled         = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png",
                    DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png",
                };

                ////////
                familySwitch[i]                         = new Switch();
                familySwitch[i].Size2D                  = new Size2D(96, 60);
                familySwitch[i].Position2D              = new Position2D(500, 300 + i * 100);
                familySwitch[i].Style.Thumb.Size        = new Size(60, 60);
                familySwitch[i].Style.Track.ResourceUrl = new Selector <string>
                {
                    Normal           = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off.png",
                    Selected         = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_switch_bg_on_24c447.png",
                    Disabled         = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off.png",
                    DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_switch_bg_on_dim_24c447.png",
                };
                familySwitch[i].Style.Thumb.ResourceUrl = new Selector <string>
                {
                    Normal           = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler.png",
                    Selected         = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler.png",
                    Disabled         = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png",
                    DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png",
                };
                /////////
                foodSwitch[i]                         = new Switch();
                foodSwitch[i].Size2D                  = new Size2D(96, 60);
                foodSwitch[i].Position2D              = new Position2D(700, 300 + i * 100);
                foodSwitch[i].Style.Thumb.Size        = new Size(60, 60);
                foodSwitch[i].Style.Track.ResourceUrl = new Selector <string>
                {
                    Normal           = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off.png",
                    Selected         = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_switch_bg_on_ec7510.png",
                    Disabled         = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off.png",
                    DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_switch_bg_on_dim_ec7510.png",
                };
                foodSwitch[i].Style.Thumb.ResourceUrl = new Selector <string>
                {
                    Normal           = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler.png",
                    Selected         = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler.png",
                    Disabled         = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png",
                    DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png",
                };

                ////////
                kitchenSwitch[i]                         = new Switch();
                kitchenSwitch[i].Size2D                  = new Size2D(96, 60);
                kitchenSwitch[i].Position2D              = new Position2D(900, 300 + i * 100);
                kitchenSwitch[i].Style.Thumb.Size        = new Size(60, 60);
                kitchenSwitch[i].Style.Track.ResourceUrl = new Selector <string>
                {
                    Normal           = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off.png",
                    Selected         = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_switch_bg_on_9762d9.png",
                    Disabled         = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off.png",
                    DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_switch_bg_on_dim_9762d9.png",
                };
                kitchenSwitch[i].Style.Thumb.ResourceUrl = new Selector <string>
                {
                    Normal           = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler.png",
                    Selected         = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler.png",
                    Disabled         = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png",
                    DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png",
                };

                root.Add(utilitySwitch[i]);
                root.Add(familySwitch[i]);
                root.Add(foodSwitch[i]);
                root.Add(kitchenSwitch[i]);
            }

            ///////////////////////////////////////////////Create by Attributes//////////////////////////////////////////////////////////
            createText[1]            = new TextLabel();
            createText[1].Text       = "Create Switch just by Attributes";
            createText[1].Size2D     = new Size2D(500, 100);
            createText[1].Position2D = new Position2D(1200, 100);
            root.Add(createText[1]);

            for (int i = 0; i < num; i++)
            {
                modeText2[i]            = new TextLabel();
                modeText2[i].Text       = mode[i];
                modeText2[i].Size2D     = new Size2D(200, 48);
                modeText2[i].Position2D = new Position2D(1100 + 200 * i, 200);
                root.Add(modeText2[i]);
            }

            SwitchStyle utilityAttrs = new SwitchStyle
            {
                IsSelectable = true,
                Track        = new ImageViewStyle
                {
                    ResourceUrl = new Selector <string>
                    {
                        Normal           = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off.png",
                        Selected         = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_on.png",
                        Disabled         = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off_dim.png",
                        DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_on_dim.png",
                    },
                },
                Thumb = new ImageViewStyle
                {
                    Size        = new Size(60, 60),
                    ResourceUrl = new Selector <string>
                    {
                        Normal           = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler.png",
                        Selected         = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler.png",
                        Disabled         = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png",
                        DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png",
                    },
                },
            };
            SwitchStyle familyAttrs = new SwitchStyle
            {
                IsSelectable = true,
                Track        = new ImageViewStyle
                {
                    ResourceUrl = new Selector <string>
                    {
                        Normal           = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off.png",
                        Selected         = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_switch_bg_on_24c447.png",
                        Disabled         = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off_dim.png",
                        DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_switch_bg_on_dim_24c447.png",
                    },
                },
                Thumb = new ImageViewStyle
                {
                    Size        = new Size(60, 60),
                    ResourceUrl = new Selector <string>
                    {
                        Normal           = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler.png",
                        Selected         = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler.png",
                        Disabled         = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png",
                        DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png",
                    },
                },
            };
            SwitchStyle foodAttrs = new SwitchStyle
            {
                IsSelectable = true,
                Track        = new ImageViewStyle
                {
                    ResourceUrl = new Selector <string>
                    {
                        Normal           = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off.png",
                        Selected         = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_switch_bg_on_ec7510.png",
                        Disabled         = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off_dim.png",
                        DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_switch_bg_on_dim_ec7510.png",
                    },
                },
                Thumb = new ImageViewStyle
                {
                    Size        = new Size(60, 60),
                    ResourceUrl = new Selector <string>
                    {
                        Normal           = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler.png",
                        Selected         = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler.png",
                        Disabled         = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png",
                        DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png",
                    },
                },
            };
            SwitchStyle kitchenAttrs = new SwitchStyle
            {
                IsSelectable = true,
                Track        = new ImageViewStyle
                {
                    ResourceUrl = new Selector <string>
                    {
                        Normal           = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off.png",
                        Selected         = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_switch_bg_on_9762d9.png",
                        Disabled         = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_bg_off_dim.png",
                        DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_switch_bg_on_dim_9762d9.png",
                    },
                },
                Thumb = new ImageViewStyle
                {
                    Size        = new Size(60, 60),
                    ResourceUrl = new Selector <string>
                    {
                        Normal           = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler.png",
                        Selected         = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler.png",
                        Disabled         = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png",
                        DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_switch_handler_dim.png",
                    },
                },
            };

            for (int i = 0; i < num; i++)
            {
                utilitySwitch2[i]            = new Switch(utilityAttrs);
                utilitySwitch2[i].Size2D     = new Size2D(96, 60);
                utilitySwitch2[i].Position2D = new Position2D(1100, 300 + i * 100);

                familySwitch2[i]            = new Switch(familyAttrs);
                familySwitch2[i].Size2D     = new Size2D(96, 60);
                familySwitch2[i].Position2D = new Position2D(1300, 300 + i * 100);

                foodSwitch2[i]            = new Switch(foodAttrs);
                foodSwitch2[i].Size2D     = new Size2D(96, 60);
                foodSwitch2[i].Position2D = new Position2D(1500, 300 + i * 100);

                kitchenSwitch2[i]            = new Switch(kitchenAttrs);
                kitchenSwitch2[i].Size2D     = new Size2D(96, 60);
                kitchenSwitch2[i].Position2D = new Position2D(1700, 300 + i * 100);

                root.Add(utilitySwitch2[i]);
                root.Add(familySwitch2[i]);
                root.Add(foodSwitch2[i]);
                root.Add(kitchenSwitch2[i]);
            }

            utilitySwitch[2].IsEnabled = false;
            familySwitch[2].IsEnabled  = false;
            foodSwitch[2].IsEnabled    = false;
            kitchenSwitch[2].IsEnabled = false;

            utilitySwitch2[2].IsEnabled = false;
            familySwitch2[2].IsEnabled  = false;
            foodSwitch2[2].IsEnabled    = false;
            kitchenSwitch2[2].IsEnabled = false;

            utilitySwitch[3].IsEnabled  = false;
            familySwitch[3].IsEnabled   = false;
            foodSwitch[3].IsEnabled     = false;
            kitchenSwitch[3].IsEnabled  = false;
            utilitySwitch[3].IsSelected = true;
            familySwitch[3].IsSelected  = true;
            foodSwitch[3].IsSelected    = true;
            kitchenSwitch[3].IsSelected = true;

            utilitySwitch2[3].IsEnabled  = false;
            familySwitch2[3].IsEnabled   = false;
            foodSwitch2[3].IsEnabled     = false;
            kitchenSwitch2[3].IsEnabled  = false;
            utilitySwitch2[3].IsSelected = true;
            familySwitch2[3].IsSelected  = true;
            foodSwitch2[3].IsSelected    = true;
            kitchenSwitch2[3].IsSelected = true;
        }
        public void Activate()
        {
            Window window = NUIApplication.GetDefaultWindow();

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
            /////////////////////////////////////// Symmetrical Circular Pagination ///////////////////////////////////////
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

            circular                   = new CircularPagination();
            circular.Position2D        = new Position2D(50, 20);
            circular.Size2D            = new Size2D(360, 360);
            circular.BackgroundColor   = new Color(0.2f, 0.2f, 0.2f, 0.6f);
            circular.IndicatorSize     = new Size(26, 26);
            circular.IndicatorImageURL = new Selector <string>()
            {
                Normal   = CommonResource.GetFHResourcePath() + "9. Controller/pagination_ic_nor.png",
                Selected = CommonResource.GetFHResourcePath() + "9. Controller/pagination_ic_sel.png",
            };

            circular.IndicatorCount = 19;

            //circular.SelectedIndex = 0;

            window.Add(circular);

            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            /////////////////////////////////////// Asymmetrical Circular Pagination ///////////////////////////////////////
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            homeCircular                 = new CircularPagination();
            homeCircular.Position2D      = new Position2D(50, 410);
            homeCircular.Size2D          = new Size2D(360, 360);
            homeCircular.BackgroundColor = new Color(0.7f, 0.7f, 0.7f, 0.6f);

            homeCircular.IndicatorSize     = new Size(26, 26);
            homeCircular.IndicatorImageURL = new Selector <string>()
            {
                Normal   = CommonResource.GetFHResourcePath() + "9. Controller/pagination_ic_nor.png",
                Selected = CommonResource.GetFHResourcePath() + "9. Controller/pagination_ic_sel.png",
            };

            // If you want to set the center indicator image differently from other indicators,
            // Use CenterIndicatorImageURL like below. (for example, home indicator clock picker)
            homeCircular.CenterIndicatorImageURL = new Selector <string>()
            {
                Normal   = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_slide_handler_press.png",
                Selected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_on.png",
            };

            homeCircular.IsSymmetrical       = false;
            homeCircular.RightIndicatorCount = 5;
            homeCircular.LeftIndicatorCount  = 2;

            //homeCircular.SetIndicatorPosition(0, new Position(111, 11));
            //homeCircular.SetIndicatorPosition(2, new Position(222, 73));

            //homeCircular.SelectedIndex = 0;

            window.Add(homeCircular);

            window.KeyEvent += Window_KeyEvent;
        }
        public void Activate()
        {
            Window window = NUIApplication.GetDefaultWindow();

            var myViewModelSource = new GalleryViewModel(itemCount);

            selMode = ItemSelectionMode.SingleSelection;
            DefaultTitleItem myTitle = new DefaultTitleItem();

            myTitle.Text = "Linear Sample Count[" + itemCount + "]";
            //Set Width Specification as MatchParent to fit the Item width with parent View.
            myTitle.WidthSpecification = LayoutParamPolicies.MatchParent;

            colView = new CollectionView()
            {
                ItemsSource   = myViewModelSource,
                ItemsLayouter = new LinearLayouter(),
                ItemTemplate  = new DataTemplate(() =>
                {
                    var rand = new Random();
                    DefaultLinearItem item = new DefaultLinearItem();
                    //Set Width Specification as MatchParent to fit the Item width with parent View.
                    item.WidthSpecification = LayoutParamPolicies.MatchParent;

                    //Decorate Label
                    item.Label.SetBinding(TextLabel.TextProperty, "ViewLabel");
                    item.Label.HorizontalAlignment = HorizontalAlignment.Begin;

                    //Decorate SubLabel
                    if ((rand.Next() % 2) == 0)
                    {
                        item.SubLabel.SetBinding(TextLabel.TextProperty, "Name");
                        item.SubLabel.HorizontalAlignment = HorizontalAlignment.Begin;
                    }

                    //Decorate Icon
                    item.Icon.SetBinding(ImageView.ResourceUrlProperty, "ImageUrl");
                    item.Icon.WidthSpecification  = 48;
                    item.Icon.HeightSpecification = 48;

                    //Decorate Extra RadioButton.
                    //[NOTE] This is sample of RadioButton usage in CollectionView.
                    // RadioButton change their selection by IsSelectedProperty bindings with
                    // SelectionChanged event with SingleSelection ItemSelectionMode of CollectionView.
                    // be aware of there are no RadioButtonGroup.
                    item.Extra = new RadioButton();
                    //FIXME : SetBinding in RadioButton crashed as Sensitive Property is disposed.
                    //item.Extra.SetBinding(RadioButton.IsSelectedProperty, "Selected");
                    item.Extra.WidthSpecification  = 48;
                    item.Extra.HeightSpecification = 48;

                    return(item);
                }),
                Header              = myTitle,
                ScrollingDirection  = ScrollableBase.Direction.Vertical,
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
                SelectionMode       = selMode
            };
            colView.SelectionChanged += SelectionEvt;

            window.Add(colView);
        }
Beispiel #40
0
        static void MainX(string[] args)
        {
            Application.Init();

            var top = Application.Top;

            var win = new Window(new Rect(0, 1, top.Frame.Width, top.Frame.Height - 1), "ACMETerm");

            top.Add(win);

            // Creates a menubar, the item "New" has a help menu.
            var menu = new MenuBar(new MenuBarItem[] {
                new MenuBarItem("_File", new MenuItem [] {
                    new MenuItem("_New Account", "Creates a new ACME registration Account", NewAccount),
                    new MenuItem("_Open Account", "Open an existing ACME registration Account", OpenAccount),
                    new MenuItem("_Close Account", "Close existing ACME registration Account", CloseAccount),
                    new MenuItem("_Quit", "", () => ClickQuit())
                }),
                new MenuBarItem("_Edit", new MenuItem [] {
                    new MenuItem("_Copy", "", null),
                    new MenuItem("C_ut", "", null),
                    new MenuItem("_Paste", "", null)
                })
            });

            top.Add(menu);

            // Add some controls
            var ml = new Label(new Rect(3, 17, 47, 1), "Mouse: ");

            _cwd = new Label(3, 20, "Current Dir Goes here");
            win.Add(
                new Label(3, 2, "Login: "******""),
                new Label(3, 4, "Password: "******"")
            {
                Secret = true
            },
                new CheckBox(3, 6, "Remember me"),
                new RadioGroup(3, 8, new[] { "_Personal", "_Company" }),
                new Button(3, 14, "Ok"),
                new Button(10, 14, "Cancel"),
                new Label(3, 18, "Press ESC and 9 to activate the menubar"),
                ml, _cwd);

            int count = 0;

            Application.RootMouseEvent += delegate(MouseEvent ev) {
                ml.Text = $"Mouse: ({ev.X},{ev.Y}) - {ev.Flags} {count++}";
            };

            Application.Run();

            void ClickQuit()
            {
                if (Quit())
                {
                    //top.Running = false;
                    Application.RequestStop();
                }
            }
        }
Beispiel #41
0
    static void Main()
    {
        if (Debugger.IsAttached)
        {
            CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.GetCultureInfo("en-US");
        }

        //Application.UseSystemConsole = true;

        Application.Init();

        var top = Application.Top;

        //Open ();
#if true
        int margin = 3;
        var win    = new Window("Hello")
        {
            X = 1,
            Y = 1,

            Width  = Dim.Fill() - margin,
            Height = Dim.Fill() - margin
        };
#else
        var tframe = top.Frame;

        var win = new Window(new Rect(0, 1, tframe.Width, tframe.Height - 1), "Hello");
#endif
        MenuItemDetails [] menuItems =
        {
            new MenuItemDetails("F_ind",              "", null),
            new MenuItemDetails("_Replace",           "", null),
            new MenuItemDetails("_Item1",             "", null),
            new MenuItemDetails("_Not From Sub Menu", "", null)
        };

        menuItems [0].Action = () => ShowMenuItem(menuItems [0]);
        menuItems [1].Action = () => ShowMenuItem(menuItems [1]);
        menuItems [2].Action = () => ShowMenuItem(menuItems [2]);
        menuItems [3].Action = () => ShowMenuItem(menuItems [3]);

        menu = new MenuBar(new MenuBarItem [] {
            new MenuBarItem("_File", new MenuItem [] {
                new MenuItem("Text _Editor Demo", "", () => { Editor(top); }),
                new MenuItem("_New", "Creates new file", NewFile),
                new MenuItem("_Open", "", Open),
                new MenuItem("_Hex", "", () => ShowHex(top)),
                new MenuItem("_Close", "", () => Close()),
                new MenuItem("_Disabled", "", () => { }, () => false),
                null,
                new MenuItem("_Quit", "", () => { if (Quit())
                                                  {
                                                      top.Running = false;
                                                  }
                             })
            }),
            new MenuBarItem("_Edit", new MenuItem [] {
                new MenuItem("_Copy", "", Copy),
                new MenuItem("C_ut", "", Cut),
                new MenuItem("_Paste", "", Paste),
                new MenuItem("_Find and Replace",
                             new MenuBarItem(new MenuItem[] { menuItems [0], menuItems [1] })),
                menuItems[3]
            }),
            new MenuBarItem("_List Demos", new MenuItem [] {
                new MenuItem("Select _Multiple Items", "", () => ListSelectionDemo(true)),
                new MenuItem("Select _Single Item", "", () => ListSelectionDemo(false)),
            }),
            new MenuBarItem("A_ssorted", new MenuItem [] {
                new MenuItem("_Show text alignments", "", () => ShowTextAlignments()),
                new MenuItem("_OnKeyDown/Up", "", () => OnKeyDownUpDemo())
            }),
            new MenuBarItem("_Test Menu and SubMenus", new MenuItem [] {
                new MenuItem("SubMenu1Item_1",
                             new MenuBarItem(new MenuItem[] {
                    new MenuItem("SubMenu2Item_1",
                                 new MenuBarItem(new MenuItem [] {
                        new MenuItem("SubMenu3Item_1",
                                     new MenuBarItem(new MenuItem [] { menuItems [2] })
                                     )
                    })
                                 )
                })
                             )
            }),
            new MenuBarItem("_About...", "Demonstrates top-level menu item", () => MessageBox.ErrorQuery(50, 7, "About Demo", "This is a demo app for gui.cs", "Ok")),
        });

        menuKeysStyle             = new CheckBox(3, 25, "UseKeysUpDownAsKeysLeftRight", true);
        menuKeysStyle.Toggled    += MenuKeysStyle_Toggled;
        menuAutoMouseNav          = new CheckBox(40, 25, "UseMenuAutoNavigation", true);
        menuAutoMouseNav.Toggled += MenuAutoMouseNav_Toggled;

        ShowEntries(win);

        int count = 0;
        ml = new Label(new Rect(3, 17, 47, 1), "Mouse: ");
        Application.RootMouseEvent += delegate(MouseEvent me) {
            ml.TextColor = Colors.TopLevel.Normal;
            ml.Text      = $"Mouse: ({me.X},{me.Y}) - {me.Flags} {count++}";
        };

        var test = new Label(3, 18, "Se iniciará el análisis");
        win.Add(test);
        win.Add(ml);

        var drag = new Label("Drag: ")
        {
            X = 70, Y = 24
        };
        var dragText = new TextField("")
        {
            X     = Pos.Right(drag),
            Y     = Pos.Top(drag),
            Width = 40
        };

        var statusBar = new StatusBar(new StatusItem [] {
            new StatusItem(Key.F1, "~F1~ Help", () => Help()),
            new StatusItem(Key.F2, "~F2~ Load", null),
            new StatusItem(Key.F3, "~F3~ Save", null),
            new StatusItem(Key.ControlX, "~^X~ Quit", () => { if (Quit())
                                                              {
                                                                  top.Running = false;
                                                              }
                           }),
        })
        {
            Parent = null,
        };

        win.Add(drag, dragText);
#if true
        // FIXED: This currently causes a stack overflow, because it is referencing a window that has not had its size allocated yet

        var bottom = new Label("This should go on the bottom of the same top-level!");
        win.Add(bottom);
        var bottom2 = new Label("This should go on the bottom of another top-level!");
        top.Add(bottom2);

        Application.OnLoad = () => {
            bottom.X  = win.X;
            bottom.Y  = Pos.Bottom(win) - Pos.Top(win) - margin;
            bottom2.X = Pos.Left(win);
            bottom2.Y = Pos.Bottom(win);
        };
#endif


        top.Add(win);
        //top.Add (menu);
        top.Add(menu, statusBar);
        Application.Run();
    }
Beispiel #42
0
 public static void RegisterPlatform()
 {
     Window.Add(new GlfwPlatform());
     InputWindowExtensions.Add(new GlfwInputPlatform());
 }
Beispiel #43
0
        public MainDemograftSim()
        {
            window              = new Window("HDemografiSim");
            window.DeleteEvent += (o, eargs) => {
                Application.Quit();
                eargs.RetVal = true;
            };
            window.ModifyBg(StateType.Normal, new Gdk.Color(130, 130, 160));

            ageDistribution = new HIndexedChartLine("Age Distribution", new DColor(250, 100, 255));
            ageDistribution.AddPoints();
            ageDistributionChart = new HChart("Age chart", ageDistribution);
            AddDefaultToAgeDist();

            populationLine  = new HIndexedChartLine("Population", new DColor(200, 140, 255));
            populationChart = new HChart("Population chart", populationLine);
            RecalculatePopulation();

            birthRate = new HIndexedChartLine("Birth rate", new DColor(100, 140, 255));
            deathRate = new HIndexedChartLine("Death rate", new DColor(55, 80, 180));
            rateChart = new HChart("Rates Chart", birthRate, deathRate);
            //RecalculateRates (0, 2, 1000);
            //RecalculateRates (0, 2, 1000);

            chanceOfDeath = new HStandardChartLine("Chance of death", new DColor(255, 80, 180));
            chanceOfDeath.AddPoint(0, 0.003f);
            chanceOfDeath.AddPoint(4, 0.001f);
            chanceOfDeath.AddPoint(8, 0.0005f);
            chanceOfDeath.AddPoint(16, 0.001f);
            chanceOfDeath.AddPoint(25, 0.0005f);
            chanceOfDeath.AddPoint(60, 0.003f);
            chanceOfDeath.AddPoint(80, 0.01f);
            chanceOfDeath.AddPoint(90, 0.03f);
            chanceOfDeath.AddPoint(119, 0.4f);
            chanceOfDeath.AddPoint(120, 0f);
            how1000PeopleDie   = new HIndexedChartLine("How 1000 people die", new DColor(255, 20, 40));
            chanceOfDeathChart = new HDoubleChart("Death Chart", new HChartLine[] { how1000PeopleDie }, chanceOfDeath);
            OnChanceOfDeathUpdated();

            var charts = new Table(2, 2, true);

            charts.SetRowSpacing(0, 10);
            charts.SetColSpacing(0, 10);
            charts.Attach(ageDistributionChart, 0, 1, 0, 1);
            charts.Attach(populationChart, 1, 2, 0, 1);
            charts.Attach(chanceOfDeathChart, 0, 1, 1, 2);
            charts.Attach(rateChart, 1, 2, 1, 2);

            var prevYear = new Button("Prev Year");

            prevYear.Clicked += (sender, e) => PrevYear();
            var nextYear = new Button("Next Year");

            nextYear.Clicked += (sender, e) => NextYear();
            var clearHistory = new Button("Halv history");

            clearHistory.Clicked += (sender, e) => ClearHistory();
            var traceCharts = new Button("Tace age distribution");

            traceCharts.Clicked += (sender, e) => TraceCharts();
            var shrinkCharts = new Button("Shrink Charts");

            shrinkCharts.Clicked += (sender, e) => ShrinkCharts();
            var fertilityRateLabel = new Label("Fertility rate:");

            fertilityRateLabel.ModifyFont(Pango.FontDescription.FromString("Sans 12"));
            fertilitySpinner             = new SpinButton(0, 100, 0.01f);
            fertilitySpinner.Value       = 2.1f;
            fertilitySpinner.SnapToTicks = false;

            var fertilitySettings = new HBox(false, 1);

            fertilitySettings.SetSizeRequest(10, -1);
            fertilitySpinner.ModifyBg(StateType.Normal, new Gdk.Color(150, 190, 200));
            fertilitySettings.Add(fertilityRateLabel);
            fertilitySettings.Add(fertilitySpinner);

            var bottomBar = new Table(1, 8, false);

            bottomBar.SetSizeRequest(-1, 30);
            bottomBar.Attach(prevYear, 0, 1, 0, 1);
            bottomBar.Attach(nextYear, 1, 2, 0, 1);
            bottomBar.Attach(clearHistory, 2, 3, 0, 1);
            bottomBar.Attach(traceCharts, 3, 4, 0, 1);
            bottomBar.Attach(shrinkCharts, 4, 5, 0, 1);
            bottomBar.Attach(fertilitySettings, 5, 8, 0, 1);

            var everythingBox = new VBox(false, 1);

            everythingBox.PackStart(charts, true, true, 0);
            everythingBox.PackStart(bottomBar, false, false, 0);

            window.Add(everythingBox);
            window.ShowAll();
        }
Beispiel #44
0
        void Initialize()
        {
            //NUILog.Debug("### SvgTest => OnCreate()!");

            Window window = Window.Instance;

            window.BackgroundColor = Color.White;
            //NUILog.Debug($"### window.Dpi={window.Dpi}");

            Vector2 dpi = new Vector2();

            dpi = window.Dpi;
            //NUILog.Debug($"### window.Dpi x={dpi.X}, y={dpi.Y}");

            textField[0]                 = new TextField();
            textField[0].Size2D          = new Size2D(300 * resol, 64 * resol);
            textField[0].Position2D      = new Position2D(10 * resol, 600 * resol);
            textField[0].PivotPoint      = PivotPoint.TopLeft;
            textField[0].BackgroundColor = Color.White;
            textField[0].PointSize       = iPointSize * resol;
            textField[0].PlaceholderText = "imageview setsize X";
            textField[0].TextColor       = Color.Red;

            textField[1]                 = new TextField();
            textField[1].Size2D          = new Size2D(350 * resol, 64 * resol);
            textField[1].Position2D      = new Position2D(400 * resol, 600 * resol);
            textField[1].PivotPoint      = PivotPoint.TopLeft;
            textField[1].BackgroundColor = Color.White;
            textField[1].PointSize       = iPointSize * resol;
            textField[1].PlaceholderText = "imageview setsize 200,400";
            textField[1].TextColor       = Color.Red;

            textField[2]                 = new TextField();
            textField[2].Size2D          = new Size2D(350 * resol, 64 * resol);
            textField[2].Position2D      = new Position2D(750 * resol, 600 * resol);
            textField[2].PivotPoint      = PivotPoint.TopLeft;
            textField[2].BackgroundColor = Color.White;
            textField[2].PointSize       = iPointSize * resol;
            textField[2].PlaceholderText = "imageview setsize 300,300";
            textField[2].TextColor       = Color.Red;

            textField[3]                 = new TextField();
            textField[3].Size2D          = new Size2D(350 * resol, 64 * resol);
            textField[3].Position2D      = new Position2D(1100 * resol, 600 * resol);
            textField[3].PivotPoint      = PivotPoint.TopLeft;
            textField[3].BackgroundColor = Color.White;
            textField[3].PointSize       = iPointSize * resol;
            textField[3].PlaceholderText = "imageview setsize 500,500";
            textField[3].TextColor       = Color.Red;

            window.Add(textField[0]);
            window.Add(textField[1]);
            window.Add(textField[2]);
            window.Add(textField[3]);

            PropertyMap map0 = new PropertyMap();

            map0.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
            string test_url0 = "/home/owner/apps_rw/org.tizen.example.NUITemplate3/res/images/test-image.png";

            map0.Add(ImageVisualProperty.URL, new PropertyValue(test_url0));
            map0.Add(ImageVisualProperty.CropToMask + 3, new PropertyValue(true));
            imageView[0]                 = new ImageView();
            imageView[0].Position2D      = new Position2D(10 * resol, 20 * resol);
            imageView[0].PivotPoint      = PivotPoint.TopLeft;
            imageView[0].ParentOrigin    = ParentOrigin.TopLeft;
            imageView[0].ImageMap        = map0;
            imageView[0].BackgroundColor = Color.Black;
            window.Add(imageView[0]);

            return;

            PropertyMap map1 = new PropertyMap();

            map1.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.SVG));
            //map1.Add(ImageVisualProperty.URL, new PropertyValue(IMAGE_PATH[iSVGimage]));
            map1.Add(ImageVisualProperty.URL, new PropertyValue(test_url));
            map1.Add((int)Visual.Property.MixColor, new PropertyValue(new Color(0.7f, 0.0f, 0.0f, 1.0f)));
            imageView[1]                 = new ImageView();
            imageView[1].Size2D          = new Size2D(200 * resol, 400 * resol);
            imageView[1].Position2D      = new Position2D(400 * resol, 20 * resol);
            imageView[1].PivotPoint      = PivotPoint.TopLeft;
            imageView[1].ParentOrigin    = ParentOrigin.TopLeft;
            imageView[1].Image           = map1;
            imageView[1].BackgroundColor = Color.Black;
            //            ConnectSignal(imageView[1]);

            PropertyMap map2 = new PropertyMap();

            map2.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.SVG));
            //map2.Add(ImageVisualProperty.URL, new PropertyValue(IMAGE_PATH[iSVGimage]));
            map2.Add(ImageVisualProperty.URL, new PropertyValue(test_url));
            imageView[2]                 = new ImageView();
            imageView[2].Size2D          = new Size2D(300 * resol, 300 * resol);
            imageView[2].Position2D      = new Position2D(700 * resol, 20 * resol);
            imageView[2].PivotPoint      = PivotPoint.TopLeft;
            imageView[2].ParentOrigin    = ParentOrigin.TopLeft;
            imageView[2].Image           = map2;
            imageView[2].BackgroundColor = Color.Black;
            //            ConnectSignal(imageView[2]);

            PropertyMap map3 = new PropertyMap();

            map3.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.SVG));
            //map3.Add(ImageVisualProperty.URL, new PropertyValue(IMAGE_PATH[iSVGimage]));
            map3.Add(ImageVisualProperty.URL, new PropertyValue(test_url));
            imageView[3]                 = new ImageView();
            imageView[3].Size2D          = new Size2D(500 * resol, 500 * resol);
            imageView[3].Position2D      = new Position2D(1100 * resol, 20 * resol);
            imageView[3].PivotPoint      = PivotPoint.TopLeft;
            imageView[3].ParentOrigin    = ParentOrigin.TopLeft;
            imageView[3].Image           = map3;
            imageView[3].BackgroundColor = Color.Black;
            //            ConnectSignal(imageView[3]);



            window.Add(imageView[1]);
            window.Add(imageView[2]);
            window.Add(imageView[3]);
        }
Beispiel #45
0
        public void Initialize()
        {
            DowncastTest();

            NavigationPropertiesTests();

            OperatorTests();

            CustomViewPropertyTest();

            VisibilityChangeTest();

            ResourceReadyTest();

            ViewFocusTest();

            WindowDevelPropertyTest();

            Animatable handle          = new Animatable();
            int        myPropertyIndex = handle.RegisterProperty("myProperty", new PropertyValue(10.0f), PropertyAccessMode.ReadWrite);
            float      myProperty      = 0.0f;

            handle.GetProperty(myPropertyIndex).Get(out myProperty);
            Tizen.Log.Debug("NUI", "myProperty value: " + myProperty);

            int    myPropertyIndex2 = handle.RegisterProperty("myProperty2", new PropertyValue(new Size(5.0f, 5.0f, 0.0f)), PropertyAccessMode.ReadWrite);
            Size2D myProperty2      = new Size2D(0, 0);

            handle.GetProperty(myPropertyIndex2).Get(myProperty2);
            Tizen.Log.Debug("NUI", "myProperty2 value: " + myProperty2.Width + ", " + myProperty2.Height);

            View view = new View();

            view.Size2D = new Size2D(200, 200);
            view.Name   = "MyView";
            //view.MixColor = new Color(1.0f, 0.0f, 1.0f, 0.8f);
            Tizen.Log.Debug("NUI", "View size: " + view.Size2D.Width + ", " + view.Size2D.Height);
            Tizen.Log.Debug("NUI", "View name: " + view.Name);

            Window window = Window.Instance;

            window.BackgroundColor = Color.White;
            Size windowSize = new Size(window.Size.Width, window.Size.Height, 0.0f);

            Tizen.Log.Debug("NUI", "Window size: " + windowSize.Width + ", " + windowSize.Height);
            window.Add(view);

            TextLabel text = new TextLabel("Hello Mono World");

            text.ParentOrigin        = ParentOrigin.Center;
            text.PivotPoint          = PivotPoint.Center;
            text.HorizontalAlignment = HorizontalAlignment.Center;
            window.Add(text);

            Tizen.Log.Debug("NUI", "Text label text:  " + text.Text);

            Tizen.Log.Debug("NUI", "Text label point size:  " + text.PointSize);
            text.PointSize = 32.0f;
            Tizen.Log.Debug("NUI", "Text label new point size:  " + text.PointSize);

            RectanglePaddingClassTest();

            Tizen.Log.Debug("NUI", " *************************");
            Size Size = new Size(100, 50, 0);

            Tizen.Log.Debug("NUI", "    Created " + Size);
            Tizen.Log.Debug("NUI", "    Size x =  " + Size.Width + ", y = " + Size.Height);
            Size += new Size(20, 20, 0);
            Tizen.Log.Debug("NUI", "    Size x =  " + Size.Width + ", y = " + Size.Height);
            Size.Width  += 10;
            Size.Height += 10;
            Tizen.Log.Debug("NUI", "    Size width =  " + Size.Width + ", height = " + Size.Height);

            Tizen.Log.Debug("NUI", " *************************");
            Position Position = new Position(20, 100, 50);

            Tizen.Log.Debug("NUI", "    Created " + Position);
            Tizen.Log.Debug("NUI", "    Position x =  " + Position.X + ", y = " + Position.Y + ", z = " + Position.Z);
            Position += new Position(20, 20, 20);
            Tizen.Log.Debug("NUI", "    Position x =  " + Position.X + ", y = " + Position.Y + ", z = " + Position.Z);
            Position.X += 10;
            Position.Y += 10;
            Position.Z += 10;
            Tizen.Log.Debug("NUI", "    Position width =  " + Position.X + ", height = " + Position.Y + ", depth = " + Position.Z);

            Tizen.Log.Debug("NUI", " *************************");
            Color color = new Color(20, 100, 50, 200);

            Tizen.Log.Debug("NUI", "    Created " + color);
            Tizen.Log.Debug("NUI", "    Color R =  " + color.R + ", G = " + color.G + ", B = " + color.B + ", A = " + color.A);
            color += new Color(20, 20, 20, 20);
            Tizen.Log.Debug("NUI", "    Color R =  " + color.R + ", G = " + color.G + ", B = " + color.B + ", A = " + color.A);
            color.R += 10;
            color.G += 10;
            color.B += 10;
            color.A += 10;
            Tizen.Log.Debug("NUI", "    Color r =  " + color.R + ", g = " + color.G + ", b = " + color.B + ", a = " + color.A);

            ViewDownCastTest();
        }
Beispiel #46
0
        private static void Main()
        {
            Application.Init();
            var top = Application.Top;

            // Creates the top-level window to show
            var win = new Window("MyApp")
            {
                X = 0,
                Y = 1, // Leave one row for the toplevel menu

                // By using Dim.Fill(), it will automatically resize without manual intervention
                Width  = Dim.Fill(),
                Height = Dim.Fill(),
            };

            top.Add(win);

            // Creates a menubar, the item "New" has a help menu.
            var menu = new MenuBar(new[]
            {
                new MenuBarItem("_File", new[]
                {
                    new MenuItem("_New", "Creates new file", NewFile),
                    new MenuItem("_Close", "", () => Close()),
                    new MenuItem("_Quit", "", () =>
                    {
                        if (Quit())
                        {
                            top.Running = false;
                        }
                    })
                }),
                new MenuBarItem("_Edit", new[]
                {
                    new MenuItem("_Copy", "", null),
                    new MenuItem("C_ut", "", null),
                    new MenuItem("_Paste", "", null)
                })
            });

            top.Add(menu);

            var login = new Label("Login: "******"Password: "******"")
            {
                X     = Pos.Right(password),
                Y     = Pos.Top(login),
                Width = 40
            };
            var passText = new TextField("")
            {
                Secret = true,
                X      = Pos.Left(loginText),
                Y      = Pos.Top(password),
                Width  = Dim.Width(loginText)
            };

            // Add some controls,
            win.Add(
                // The ones with my favorite layout system
                login, password, loginText, passText,

                // The ones laid out like an australopithecus, with absolute positions:
                new CheckBox(3, 6, "Remember me"),
                new RadioGroup(3, 8, new[] { "_Personal", "_Company" }),
                new Button(3, 14, "Ok"),
                new Button(10, 14, "Cancel"),
                new Label(3, 18, "Press F9 or ESC plus 9 to activate the menubar"));

            Application.Run();
        }
Beispiel #47
0
            private void _buttonSetPosition_Click(object sender, EventArgs e)
            {
                var window = new Window(16, 7);

                window.Title         = "Set Position";
                window.CloseOnEscKey = true;
                TextBox widthBox;
                TextBox heightBox;

                var label = CreateLabel("X: ", new Point(1, 2));

                widthBox              = new TextBox(4);
                widthBox.Position     = new Point(label.Bounds.Right + 3, label.Bounds.Top);
                widthBox.IsNumeric    = true;
                widthBox.AllowDecimal = false;
                widthBox.Text         = ((ConsoleListboxItem)_listConsoles.SelectedItem).Console.Position.X.ToString();
                window.Add(widthBox);

                label                  = CreateLabel("Y: ", new Point(1, 3));
                heightBox              = new TextBox(4);
                heightBox.Position     = new Point(label.Bounds.Right + 3, label.Bounds.Top);
                heightBox.IsNumeric    = true;
                heightBox.AllowDecimal = false;
                heightBox.Text         = ((ConsoleListboxItem)_listConsoles.SelectedItem).Console.Position.Y.ToString();
                window.Add(heightBox);

                var buttonSave = new Button(4, 1)
                {
                    Text     = "Save",
                    Position = new Point(1, window.Height - 2),
                    Theme    = new Themes.ButtonTheme()
                    {
                        ShowEnds = false
                    }
                };

                buttonSave.Click += (s, e2) =>
                {
                    ((ConsoleListboxItem)_listConsoles.SelectedItem).Console.Position = new Point(int.Parse(widthBox.Text), int.Parse(heightBox.Text));
                    _labelConsolePosition.DisplayText = $"{((ConsoleListboxItem)_listConsoles.SelectedItem).Console.Position.X},{((ConsoleListboxItem)_listConsoles.SelectedItem).Console.Position.Y}";
                    window.Hide();
                };
                window.Add(buttonSave);

                var buttonCancel = new Button(6, 1)
                {
                    Text     = "Cancel",
                    Position = new Point(window.Width - 1 - 6, window.Height - 2),
                    Theme    = new Themes.ButtonTheme()
                    {
                        ShowEnds = false
                    }
                };

                buttonCancel.Click += (s, e2) =>
                {
                    window.Hide();
                };
                window.Add(buttonCancel);

                window.Center();
                window.Show(true);

                Label CreateLabel(string text, Point position)
                {
                    var labelTemp = new Label(text)
                    {
                        Position = position, TextColor = Theme.Colors.TitleText
                    };

                    window.Add(labelTemp);
                    return(labelTemp);
                }
            }
Beispiel #48
0
        public void Show(Toplevel top, User user)
        {
            Controller.LoggedUser = user;
            Vehicle vehicle = Controller.LoggedUser.UsingVehicle;

            int margin        = 2;
            int padding       = 1;
            int contentHeight = 8;

            Window win = new Window($"Tankowanie")
            {
                X      = margin,
                Y      = margin,
                Width  = Dim.Fill(margin),
                Height = 30,
            };

            win.ColorScheme = Colors.Dialog;



            var window1 = new FrameView("Dystrybutory")
            {
                X           = Pos.Percent(0),
                Y           = 0,
                Width       = Dim.Percent(100),
                Height      = Dim.Percent(100),
                ColorScheme = Colors.Base,
            };

            win.Add(window1);


            var listWin          = new List <View>();
            var btnList          = new List <Button>();
            var dystrybutorNames = new List <ustring>();
            var dispensersList   = new List <Dystrybutor>();

            foreach (var dispenser in Controller.Config.Dispensers)
            {
                var dystrybutorName = $"Dystrybutor {dispenser.Number}";
                dystrybutorNames.Add(dystrybutorName);
                Dystrybutor dystrybutor = new Dystrybutor()
                {
                    Title         = dystrybutorName,
                    X             = dispenser.Number > 1 ? Pos.Right(listWin[dispenser.Number - 2]) + margin : margin,
                    Y             = (margin),
                    Width         = Dim.Percent(65 / 3),
                    Height        = contentHeight,
                    PracownikEdit = false,
                    FuelList      = dispenser.FuelList,
                    SelectedFuel  = _selectedDispenser == dispenser.Number ? _selectedFuel : -1
                };

                dispensersList.Add(dystrybutor);
                Window subWin = dystrybutor.GetWindow(top);
                window1.Add(subWin);
                listWin.Add(subWin);

                string btnText      = dispenser.Number == 1 ? $"• Zaznacz •" : "Zaznacz";
                var    selectButton = new Button(btnText)
                {
                    ColorScheme = Colors.Base,
                    //X = Pos.Right (prev) + 2,
                    X = dispenser.Number > 1 ? Pos.Right(listWin[dispenser.Number - 2]) + margin + 6 : margin + 6,
                    Y = Pos.Bottom(subWin) + 1,
                };
                window1.Add(selectButton);
                btnList.Add(selectButton);
            }



            var window2 = new FrameView("Napełnij bak")
            {
                X           = Pos.Percent(70),
                Y           = 0,
                Width       = Dim.Percent(100),
                Height      = Dim.Percent(50),
                ColorScheme = Colors.Base,
            };

            var labelRodzaj = new Label()
            {
                TextAlignment = TextAlignment.Left,
                X             = 0,
                Width         = Dim.Fill(),
                Height        = 2,
                ColorScheme   = Colors.Base,
                Text          = $"Wybierz rodzaj paliwa który\nchesz zatankować z Dystrybutora {_selectedDispenser}"
                                //Text = "a Newline\nin the Label"
            };

            window2.Add(labelRodzaj);



            var rodzaje = Controller.Config.Dispensers.Where(
                (dispenser) => dispenser.Number == _selectedDispenser
                ).Select(d => d.FuelList.Select(d1 => (ustring)d1.Symbol)).SelectMany(d => d).ToArray();

            var rodzajRadioGroup = new RadioGroup(rodzaje)
            {
                X            = 3,
                Y            = 3,
                SelectedItem = 0,
            };

            window2.Add(rodzajRadioGroup);


            var fillButton = new Button("Tankuj")
            {
                ColorScheme = Colors.Base,
                //X = Pos.Right (prev) + 2,
                X = 6,
                Y = Pos.Bottom(rodzajRadioGroup) + 2,
            };

            window2.Add(fillButton);


            win.Add(window2);


            rodzajRadioGroup.SelectedItemChanged += (args) =>
            {
                _selectedFuel = args.SelectedItem;
                _applyNewPrice(dispensersList[_selectedDispenser - 1]);
            };


            fillButton.KeyDown += (args) =>
            {
                if (args.KeyEvent.Key == Terminal.Gui.Key.ControlJ)
                {
                    double delta;
                    var    slowDownSpeedAt = vehicle.TankCapacity * 0.97;

                    if (dispensersList[_selectedDispenser - 1].ActualQuantity >= slowDownSpeedAt)
                    {
                        delta = 0.03;
                    }
                    else
                    {
                        delta = 0.23;
                    }

                    if (dispensersList[_selectedDispenser - 1].FuelList[_selectedFuel].Quantity <= 0)
                    {
                        dispensersList[_selectedDispenser - 1].FuelList[_selectedFuel].Quantity = 0;
                        Controller.UpdateConfigFile(Controller.Config);
                        MessageBox.ErrorQuery("Exception", "Brak paliwa w dystrybutorze", "Ok");
                    }

                    if (dispensersList[_selectedDispenser - 1].ActualQuantity < vehicle.TankCapacity)
                    {
                        var price = dispensersList[_selectedDispenser - 1].FuelList[_selectedFuel].Price;
                        dispensersList[_selectedDispenser - 1].ActualQuantity = dispensersList[_selectedDispenser - 1].ActualQuantity + delta;
                        dispensersList[_selectedDispenser - 1].DispenserScreens["quantity"].Text = dispensersList[_selectedDispenser - 1].getActualQuantity();

                        var actualPrice = (dispensersList[_selectedDispenser - 1].ActualQuantity * (float)dispensersList[_selectedDispenser - 1].PricePerUnit);
                        dispensersList[_selectedDispenser - 1].ActualPrice = (int)actualPrice;
                        dispensersList[_selectedDispenser - 1].DispenserScreens["price"].Text = dispensersList[_selectedDispenser - 1].getActualPrice();
                    }
                    else
                    {
                        MessageBox.ErrorQuery("Exception", "Zbiornik jest pełny", "Ok");
                    }



                    dispensersList[_selectedDispenser - 1].FuelList[_selectedFuel].Quantity -= delta;
                    Controller.UpdateConfigFile(Controller.Config);


                    Thread.Sleep(50);
                }
            };



            for (int i = 0; i < btnList.Count; i++)
            {
                var b   = btnList[i];
                var sel = i + 1;
                b.Clicked += () => {
                    _unselectBtn(btnList);
                    _resetPrice(dispensersList);
                    b.Text = $"• {b.Text} •";

                    _selectedDispenser = sel;
                    _selectedFuel      = 0;
                    _applyNewPrice(dispensersList[_selectedDispenser - 1]);

                    labelRodzaj.Text = $"Wybierz rodzaj paliwa który\nchesz zatankować z Dystrybutora {sel}";
                };
            }



            var window3 = new FrameView("Dane pojazdu")
            {
                X           = Pos.Percent(70),
                Y           = Pos.Percent(50),
                Width       = Dim.Percent(100),
                Height      = Dim.Percent(50),
                ColorScheme = Colors.Base,
            };

            var label = new Label($"Marka: {vehicle.Make}")
            {
                X      = 0,
                Y      = 0,
                Width  = 15,
                Height = 1,
            };

            window3.Add(label);

            label = new Label($"Model: {vehicle.Model}")
            {
                X      = 0,
                Y      = Pos.Bottom(label) + 1,
                Width  = 15,
                Height = 1,
            };
            window3.Add(label);



            win.Add(window3);



            top.Add(win);
        }
Beispiel #49
0
        public void Activate()
        {
            Window window = NUIApplication.GetDefaultWindow();

            root = new View()
            {
                Size                   = window.Size,
                ParentOrigin           = ParentOrigin.Center,
                PivotPoint             = PivotPoint.Center,
                PositionUsesPivotPoint = true,
            };
            window.Add(root);

            canvasView = new CanvasView(window.Size)
            {
                Size                   = window.Size,
                ParentOrigin           = ParentOrigin.Center,
                PivotPoint             = PivotPoint.Center,
                PositionUsesPivotPoint = true,
            };

            roundedRectShape = new Shape()
            {
                FillColor   = new Color(0.5f, 1.0f, 0.0f, 1.0f),
                StrokeColor = new Color(0.5f, 0.0f, 0.0f, 0.5f),
                StrokeWidth = 10.0f,
            };
            roundedRectShape.Translate(100.0f, 100.0f);
            roundedRectShape.Scale(1.2f);
            roundedRectShape.Rotate(45.0f);
            roundedRectShape.AddRect(-50.0f, -50.0f, 100.0f, 100.0f, 0.0f, 0.0f);

            circleShape = new Shape()
            {
                Opacity     = 0.5f,
                FillColor   = new Color(0.0f, 0.0f, 1.0f, 1.0f),
                StrokeColor = new Color(1.0f, 1.0f, 0.0f, 1.0f),
                StrokeWidth = 10.0f,
                StrokeDash  = new List <float>()
                {
                    15.0f, 30.0f
                }.AsReadOnly(),
            };
            circleShape.AddCircle(0.0f, 0.0f, 150.0f, 100.0f);
            circleShape.Transform(new float[] { 0.6f, 0.0f, 350.0f, 0.0f, 0.6f, 100.0f, 0.0f, 0.0f, 1.0f });

            arcShape = new Shape()
            {
                StrokeColor = new Color(0.0f, 0.5f, 0.0f, 0.5f),
                StrokeWidth = 10.0f,
                StrokeJoin  = Shape.StrokeJoinType.Round,
            };
            arcShape.AddArc(0.0f, 0.0f, 80.0f, 0.0f, 0.0f, true);
            arcShape.Translate(100.0f, 300.0f);

            Shape shape = new Shape()
            {
                Opacity     = 0.5f,
                FillColor   = new Color(0.0f, 0.5f, 0.0f, 0.5f),
                StrokeColor = new Color(0.5f, 0.0f, 0.5f, 0.5f),
                StrokeWidth = 30.0f,
                FillRule    = Shape.FillRuleType.EvenOdd,
                StrokeJoin  = Shape.StrokeJoinType.Round,
            };

            shape.Scale(0.5f);
            shape.Translate(350.0f, 300.0f);
            shape.AddMoveTo(0.0f, -160.0f);
            shape.AddLineTo(125.0f, 160.0f);
            shape.AddLineTo(-180.0f, -45.0f);
            shape.AddLineTo(180.0f, -45.0f);
            shape.AddLineTo(-125.0f, 160.0f);
            shape.Close();

            canvasView.AddDrawable(shape);

            starShape = new Shape()
            {
                Opacity     = 0.5f,
                FillColor   = new Color(0.0f, 1.0f, 1.0f, 1.0f),
                StrokeColor = new Color(0.5f, 1.0f, 0.5f, 1.0f),
                StrokeWidth = 30.0f,
                StrokeCap   = Shape.StrokeCapType.Round,
            };
            starShape.Translate(250.0f, 550.0f);
            starShape.Scale(0.5f);
            starShape.AddMoveTo(-1.0f, -165.0f);
            starShape.AddLineTo(53.0f, -56.0f);
            starShape.AddLineTo(174.0f, -39.0f);
            starShape.AddLineTo(87.0f, 45.0f);
            starShape.AddLineTo(107.0f, 166.0f);
            starShape.AddLineTo(-1.0f, 110.0f);
            starShape.AddLineTo(-103.0f, 166.0f);
            starShape.AddLineTo(-88.0f, 46.0f);
            starShape.AddLineTo(-174.0f, -38.0f);
            starShape.AddLineTo(-54.0f, -56.0f);
            starShape.Close();

            canvasView.AddDrawable(starShape);


            group1 = new DrawableGroup();
            group1.AddDrawable(roundedRectShape);
            group1.AddDrawable(arcShape);

            group2 = new DrawableGroup();
            group2.AddDrawable(group1);
            group2.AddDrawable(circleShape);
            canvasView.AddDrawable(group2);

            // Test Getter
            log.Debug(tag, "circleShape Color : " + circleShape.FillColor.R + " " + circleShape.FillColor.G + " " + circleShape.FillColor.B + " " + circleShape.FillColor.A + "\n");
            log.Debug(tag, "circleShape StrokeColor : " + circleShape.StrokeColor.R + " " + circleShape.StrokeColor.G + " " + circleShape.StrokeColor.B + " " + circleShape.StrokeColor.A + "\n");

            log.Debug(tag, "arcShape StrokeCap : " + arcShape.StrokeCap + "\n");

            log.Debug(tag, "shape2 FillRule : " + shape.FillRule + "\n");
            log.Debug(tag, "shape2 StrokeWidth : " + shape.StrokeWidth + "\n");
            log.Debug(tag, "shape2 StrokeJoin : " + shape.StrokeJoin + "\n");
            log.Debug(tag, "shape2 Opacity : " + shape.Opacity + "\n");

            for (int i = 0; i < circleShape.StrokeDash.Count; i++)
            {
                log.Debug(tag, "shape2 StrokeDash : " + circleShape.StrokeDash[i] + "\n");
            }

            // Exception test.
            try
            {
                circleShape.Transform(new float[] { 0.6f, 0.0f });
            }
            catch (ArgumentException e)
            {
                log.Debug(tag, "Transform : " + e.Message + "\n");
            }
            try
            {
                circleShape.Transform(null);
            }
            catch (ArgumentException e)
            {
                log.Debug(tag, "Transform : " + e.Message + "\n");
            }
            try
            {
                circleShape.StrokeDash = null;
            }
            catch (ArgumentException e)
            {
                log.Debug(tag, "StrokeDash setter : " + e.Message + "\n");
            }

            root.Add(canvasView);

            timer       = new Timer(1000 / 32);
            timer.Tick += onTick;
            timer.Start();
        }
Beispiel #50
0
        public MainWindow()
            : base("CAS.NET")
        {
            DeleteEvent += (o, a) => Gtk.Application.Quit();



            textviews = new TextViewList(user, Eval, this);
            DefBox    = new DefinitionBox(Eval);

            // Initiating menu elements
            server        = new ServerMenuItem();
            login         = new LoginMenuItem(user, menu);
            logout        = new LogoutMenuItem(user, menu);
            stdGetAsmList = new StudentGetAssignmentListMenuItem(user, textviews);
            teaAddAsm     = new TeacherAddAssignmentMenuItem(user, textviews);
            teaGetAsmList = new TeacherGetAssignmentListMenuItem(user, textviews);

            taskGenSubMenu      = new TaskGenMenuItem(textviews);
            taskGenMenuAlgItem  = new TaskGenAritMenuItem(textviews);
            taskGenMenuUnitItem = new TaskGenUnitMenuItem(textviews);

            geometMenuItem = new GeometMenuItem(textviews);

            // Adding elements to menu
            server.Submenu = menu;
            menu.Append(login);
            menu.Append(logout);
            menu.Append(stdGetAsmList);
            menu.Append(teaAddAsm);
            menu.Append(teaGetAsmList);

            taskGenSubMenu.Submenu = taskgenMenu;
            taskgenMenu.Append(taskGenMenuAlgItem);
            taskgenMenu.Append(taskGenMenuUnitItem);

            geometMenuItem.Submenu = geometMenu;

            menubar.Append(server);
            menubar.Append(taskGenSubMenu);
            menubar.Append(geometMenuItem);

            open = new OpenToolButton(textviews, ref user);
            save = new SaveToolButton(textviews);
            neo  = new NewToolButton(textviews);

            SeparatorToolItem separator1 = new SeparatorToolItem();

            bold      = new BoldToolButton(ref textviews);
            italic    = new ItalicToolButton(ref textviews);
            underline = new UnderlineToolButton(ref textviews);

            SeparatorToolItem separator2 = new SeparatorToolItem();

            movabletextview      = new MovableTextViewToolButton(ref textviews);
            movablecalcview      = new MovableCalcViewToolButton(ref textviews);
            movablecalcmultiline = new MovableCasCalcMultilineToolButton(ref textviews);
            movabledrawcanvas    = new MovableDrawCanvasToolButton(ref textviews);
            movablecasresult     = new MovableResultToolButton(ref textviews);

            toolbar.Add(open);
            toolbar.Add(save);
            toolbar.Add(neo);
            toolbar.Add(separator1);
            toolbar.Add(bold);
            toolbar.Add(italic);
            toolbar.Add(underline);
            toolbar.Add(separator2);
            toolbar.Add(movabletextview);
            toolbar.Add(movablecalcview);
            toolbar.Add(movablecalcmultiline);
            //toolbar.Add(movabledrawcanvas);
            toolbar.Add(movablecasresult);

            VBox vbox = new VBox();

            ScrolledWindow scrolleddefbox = new ScrolledWindow();

            scrolleddefbox.Add(DefBox);
            scrolleddefbox.HeightRequest = 100;

            vbox.PackStart(menubar, false, false, 2);
            vbox.PackStart(toolbar, false, false, 2);
            scrolledWindow.Add(textviews);
            vbox.Add(scrolledWindow);
            //vbox.PackEnd(scrolleddefbox, false, false, 2);

            Window defWin = new Window("Definitions");

            defWin.WidthRequest  = 300;
            defWin.HeightRequest = 450;
            defWin.Add(scrolleddefbox);
            defWin.ShowAll();

            Add(vbox);
            SetSizeRequest(600, 600);
            ShowAll();

            // Rehiding elements not ment to be shown at start, as the
            // user is currently not logged in.
            foreach (Widget w in menu)
            {
                if (w.GetType() == typeof(StudentGetAssignmentListMenuItem) ||
                    w.GetType() == typeof(TeacherAddAssignmentMenuItem) ||
                    w.GetType() == typeof(TeacherGetAssignmentListMenuItem) ||
                    w.GetType() == typeof(LogoutMenuItem))
                {
                    w.Hide();
                }
                else if (w.GetType() == typeof(LoginMenuItem))
                {
                    w.Show();
                }
            }

            GLib.Timeout.Add(2000, new GLib.TimeoutHandler(DefBoxUpdate));
        }
Beispiel #51
0
        public MyWindow(string conn)
        {
            singleton = this;
            // File.CreateText("Log");
            this.conn = conn;
            string[] split = conn.Split(':');
            client = new TcpClient();
            client.Connect(split[split.Length - 2], int.TryParse(split[split.Length - 1], out int port) ? port : 8701);
            stream = client.GetStream();
            reader = new BinaryReader(stream, Encoding.Unicode);
            writer = new BinaryWriter(stream, Encoding.Unicode);

            tcpThread = new Thread(new ThreadStart(MyThread));
            tcpThread.IsBackground = true;
            tcpThread.Start();
            // Application.UseSystemConsole = true; // we don't need mouse support
            Application.Init();
            Toplevel top = Application.Top;

            window = new Window("Server Console")
            {
                X      = 0,
                Y      = 1,
                Width  = Dim.Fill(),
                Height = Dim.Fill(),
            };
            top.Add(window);
            MenuBar bar = new MenuBar(new MenuBarItem[]
            {
                new MenuBarItem("_View", new MenuItem[]
                {
                    new MenuItem("_Console", "Text-based Console", ConsoleTab),
                    new MenuItem("_Exit", "Exit the console", () => { Environment.Exit(0); })
                })
            });

            top.Add(bar);
            scroll = new ScrollView()
            {
                X           = 0,
                Y           = 0,
                Width       = Dim.Fill(),
                Height      = Dim.Fill() - 2,
                ColorScheme = new ColorScheme()
                {
                    Normal = Terminal.Gui.Attribute.Make(Color.Green, Color.Black)
                },
                ContentSize                   = new Size(0, 0),
                AutoHideScrollBars            = false,
                ShowHorizontalScrollIndicator = true,
                ShowVerticalScrollIndicator   = true,
            };
            label = new Label()
            {
                X      = 0,
                Y      = 0,
                Width  = Dim.Fill(),
                Height = Dim.Fill(),
            };
            scroll.Add(label);

            /*scroll.DrawContent += (r) =>
             * {
             *  Size s = filler.Frame.Size;
             *  Rect rect = filler.Bounds;
             *  rect.Width = s.Width;
             *  rect.Height = s.Height;
             *  filler.Bounds = rect;
             *  scroll.ContentSize = s;
             * };*/
            input = new TextField()
            {
                X      = 0,
                Y      = Pos.AnchorEnd() - 2,
                Width  = Dim.Fill(),
                Height = 2
            };
            input.KeyUp += (k) =>
            {
                if (k.KeyEvent.Key == Key.Enter)
                {
                    SendMsg(input.Text.ToString());
                    input.Text = string.Empty;
                }
            };
            window.Add(scroll, input);
            Application.Run();
            client.Close();
        }
Beispiel #52
0
        public static void Main(string[] args)
        {
            //start window
            timeSpan = TimeSpan.FromSeconds(0);
            Application.Init();
            window = new Window("Editor Window");
            window.SetPosition(WindowPosition.Center);
            window.HeightRequest = 600;
            window.WidthRequest  = 900;

            //new TreeView
            view = new TreeView();
            view.WidthRequest = 900;

            TreeViewColumn column = new TreeViewColumn();

            column.Title = "Please, hire me!!";

            //init labels and buttons
            searchTimeLabel = new Label("Search time: ");
            searchFileLast  = new Label("Last file: ".PadRight(60));
            searchFileLast.SetAlignment(0, 0.65f);

            searchDirCurrent = new Label("Searching dir: ".PadRight(60));
            searchDirCurrent.SetAlignment(0.1f, 0.65f);

            start           = new Button("Start");
            start.Clicked  += new EventHandler(Start);
            pause           = new Button("Pause");
            pause.Sensitive = false;
            pause.Clicked  += new EventHandler(Pause);
            stop            = new Button("Stop");
            stop.Sensitive  = false;
            stop.Clicked   += new EventHandler(Stop);
            dir             = new Entry("enter the directory");
            reg             = new Entry("enter the regex");
            ScrolledWindow scroller = new ScrolledWindow();

            scroller.BorderWidth = 5;
            scroller.ShadowType  = ShadowType.In;

            CellRendererText cell = new CellRendererText();

            column.PackStart(cell, true);

            view.AppendColumn(column);

            column.AddAttribute(cell, "text", 0);

            store = new TreeStore(typeof(string));
            TreeIter treeIter = store.AppendValues("SearchResult");

            view.Model         = store;
            view.ShowExpanders = true;

            //set labels and buttons
            hb.PackStart(start, false, false, 5);
            hb.PackStart(pause, false, false, 5);
            hb.PackStart(stop, false, false, 5);
            hb.Add(dir);
            hb.Add(reg);
            searchTimeLabel.SetAlignment(0.2f, 0.65f);
            hb.Add(searchTimeLabel);

            hbinfo.Add(searchDirCurrent);
            hbinfo.Add(searchFileLast);

            vb.PackStart(hb, false, false, 5);
            vb.PackStart(hbinfo, false, false, 5);

            scroller.Add(view);
            vb.Add(scroller);
            GLib.Timeout.Add(1, updateTimeLabel);
            GLib.Timeout.Add(1, updateLastFileLabel);
            GLib.Timeout.Add(1, updateCurrentDir);

            window.Add(vb);

            window.Destroyed += new EventHandler(onClosed);

            window.ShowAll();

            //show all items in window
            Application.Run();
        }
Beispiel #53
0
        public static Gtk.Window Create()
        {
            window = new Window("Menus");

            AccelGroup accel_group = new AccelGroup();

            window.AddAccelGroup(accel_group);

            VBox box1 = new VBox(false, 0);

            window.Add(box1);

            MenuBar menubar = new MenuBar();

            box1.PackStart(menubar, false, false, 0);

            Menu     menu     = Create_Menu(2, true);
            MenuItem menuitem = new MenuItem("foo");

            menuitem.Submenu = menu;
            menubar.Append(menuitem);

            menuitem         = new MenuItem("bar");
            menuitem.Submenu = Create_Menu(3, true);
            menubar.Append(menuitem);

            Image image = new Image(Stock.Help, IconSize.Menu);

            menuitem = new ImageMenuItem("Help");
            ((ImageMenuItem)menuitem).Image = image;
            menuitem.Submenu        = Create_Menu(4, true);
            menuitem.RightJustified = true;
            menubar.Append(menuitem);

            menubar = new MenuBar();
            box1.PackStart(menubar, false, true, 0);

            menu = Create_Menu(2, true);

            menuitem         = new MenuItem("Second menu bar");
            menuitem.Submenu = menu;
            menubar.Append(menuitem);

            VBox box2 = new VBox(false, 10);

            box2.BorderWidth = 10;
            box1.PackStart(box2, true, true, 0);

            menu            = Create_Menu(1, false);
            menu.AccelGroup = accel_group;

            menu.Append(new SeparatorMenuItem());

            menuitem = new CheckMenuItem("Accelerate Me");
            menu.Append(menuitem);
            menuitem.AddAccelerator("activate", accel_group, 0xFFBE, 0, AccelFlags.Visible);

            menuitem = new CheckMenuItem("Accelerator locked");
            menu.Append(menuitem);
            menuitem.AddAccelerator("activate", accel_group, 0xFFBF, 0, AccelFlags.Visible | AccelFlags.Locked);

            menuitem = new CheckMenuItem("Accelerator Frozen");
            menu.Append(menuitem);
            menuitem.AddAccelerator("activate", accel_group, 0xFFBF, 0, AccelFlags.Visible);
            menuitem.AddAccelerator("activate", accel_group, 0xFFC0, 0, AccelFlags.Visible);

            OptionMenu option_menu = new OptionMenu();

            option_menu.Menu = menu;
            option_menu.SetHistory(3);
            box2.PackStart(option_menu, true, true, 0);

            box1.PackStart(new HSeparator(), false, false, 0);

            box2             = new VBox(false, 10);
            box2.BorderWidth = 10;
            box1.PackStart(box2, false, true, 0);

            Button close_button = new Button(Stock.Close);

            close_button.Clicked += new EventHandler(Close_Button);
            box2.PackStart(close_button, true, true, 0);

            close_button.CanDefault = true;
            close_button.GrabDefault();

            window.ShowAll();
            return(window);
        }
Beispiel #54
0
        public MainWindow()
        {
            ToolItem        spacerItem;
            FileSearchEntry searchEntry;
            ToolItem        searchEntryItem;
            Alignment       searchEntryBox;

            object[] attrs = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), true);
            AssemblyTitleAttribute attr    = (AssemblyTitleAttribute)attrs[0];
            AssemblyName           asmName = Assembly.GetExecutingAssembly().GetName();

            string title = String.Format("{0} (BETA) {1} (Protocol Version: {2})",
                                         attr.Title, asmName.Version,
                                         Core.ProtocolVersion);

            // Create the interface
            window = new Window(title);
            window.SetDefaultSize(850, 550);
            window.DeleteEvent    += on_win_delete;
            window.ConfigureEvent += on_MainWindow_configure_event;
            window.FocusInEvent   += window_FocusInEvent;

            ((ToggleAction)Runtime.BuiltinActions["ToggleMainToolbar"]).Active = Gui.Settings.ShowToolbar;
            Runtime.BuiltinActions["ToggleMainToolbar"].Activated += ToggleMainToolbar_Activated;

            ((ToggleAction)Runtime.BuiltinActions["ToggleMainStatusbar"]).Active = Gui.Settings.ShowStatusBar;
            Runtime.BuiltinActions["ToggleMainStatusbar"].Activated += ToggleMainStatusbar_Activated;
            window.AddAccelGroup(Runtime.UIManager.AccelGroup);

            mainVBox = new VBox();
            window.Add(mainVBox);
            mainVBox.Show();

            if (Common.OSName == "Darwin")
            {
                MenuBar menubar = (MenuBar)Runtime.UIManager.GetWidget("/OSXAppMenu");

                Imendio.MacIntegration.Menu.SetMenuBar(menubar);

                MenuItem preferencesItem = (MenuItem)Runtime.UIManager.GetWidget("/OSXAppMenu/NetworkMenu/Preferences");
                MenuItem aboutItem       = (MenuItem)Runtime.UIManager.GetWidget("/OSXAppMenu/NetworkMenu/About");

                IntPtr group = Imendio.MacIntegration.Menu.AddAppMenuGroup();

                Imendio.MacIntegration.Menu.AddAppMenuItem(group, aboutItem, "About Meshwork");

                group = Imendio.MacIntegration.Menu.AddAppMenuGroup();

                Imendio.MacIntegration.Menu.AddAppMenuItem(group, preferencesItem, "Preferences");

                MenuItem quitItem = (MenuItem)Runtime.UIManager.GetWidget("/OSXAppMenu/NetworkMenu/Quit");
                Imendio.MacIntegration.Menu.SetQuitMenuItem(quitItem);
            }
            else
            {
                MenuBar menubar = (MenuBar)Runtime.UIManager.GetWidget("/MainWindowMenuBar");
                mainVBox.PackStart(menubar, false, false, 0);
                menubar.Show();
            }

            toolbar = (Toolbar)Runtime.UIManager.GetWidget("/MainWindowToolbar");
            toolbar.ToolbarStyle = ToolbarStyle.BothHoriz;
            toolbar.IconSize     = IconSize.LargeToolbar;

            spacerItem        = new ToolItem();
            spacerItem.Expand = true;
            toolbar.Insert(spacerItem, -1);
            spacerItem.Show();

            searchEntry = new FileSearchEntry();

            searchEntryBox              = new Alignment(0.5f, 0.5f, 0, 0);
            searchEntryBox.LeftPadding  = 4;
            searchEntryBox.RightPadding = 1;
            searchEntryBox.Add(searchEntry);

            searchEntryItem = new ToolItem();
            searchEntryItem.Add(searchEntryBox);

            toolbar.Insert(searchEntryItem, -1);
            searchEntryItem.ShowAll();

            mainVBox.PackStart(toolbar, false, false, 0);

            mainPaned         = new HPaned();
            mainPaned.Mapped += delegate(object sender, EventArgs args) {
                // XXX: Remember the user's last setting instead
                mainPaned.Position = 190;

                // Set some colors
                //infoBoxSeparator.ModifyBg(StateType.Normal, GtkHelper.DarkenColor (mainbar.Style.Background(StateType.Normal), 2));
                //infoSwitcherTree.ModifyBase(StateType.Normal, infoSwitcherTree.Style.Base(StateType.Active));
                //infoSwitcherTree.ModifyBase(StateType.Active, infoBoxSeparator.Style.Base(StateType.Selected));
            };
            mainPaned.Show();
            mainVBox.PackStart(mainPaned, true, true, 0);

            // Create page notebook
            pageNotebook            = new Notebook();
            pageNotebook.ShowTabs   = false;
            pageNotebook.ShowBorder = false;
            mainPaned.Pack2(pageNotebook, true, true);
            pageNotebook.ShowAll();

            // Create sidebar
            sidebar                      = new MainSidebar();
            sidebar.ItemAdded           += sidebar_ItemAdded;
            sidebar.SelectedItemChanged += sidebar_SelectedItemChanged;
            sidebar.AddBuiltinItems();

            mainPaned.Pack1(sidebar, false, false);
            sidebar.ShowAll();

            CreateStatusbar();

            // Apply "view" settings
            toolbar.Visible   = Gui.Settings.ShowToolbar;
            statusBar.Visible = Gui.Settings.ShowStatusBar;

            // Hook up Core events
            Core.ShareBuilder.StartedIndexing    += (EventHandler)DispatchService.GuiDispatch(new EventHandler(sb_StartedIndexing));
            Core.ShareBuilder.FinishedIndexing   += (EventHandler)DispatchService.GuiDispatch(new EventHandler(sb_FinishedIndexing));
            Core.ShareBuilder.StoppedIndexing    += (EventHandler)DispatchService.GuiDispatch(new EventHandler(sb_StoppedIndexing));
            Core.ShareBuilder.ErrorIndexing      += (EventHandler <ErrorEventArgs>)DispatchService.GuiDispatch(new EventHandler <ErrorEventArgs>(sb_ErrorIndexing));
            Core.ShareHasher.StartedHashingFile  += (EventHandler <FilenameEventArgs>)DispatchService.GuiDispatch(new EventHandler <FilenameEventArgs>(sh_StartedFinished));
            Core.ShareHasher.FinishedHashingFile += (EventHandler <FilenameEventArgs>)DispatchService.GuiDispatch(new EventHandler <FilenameEventArgs>(sh_StartedFinished));
            Core.ShareHasher.QueueChanged        += (EventHandler)DispatchService.GuiDispatch(new EventHandler(sh_QueueChanged));

            Core.FileSearchManager.SearchAdded   += (EventHandler <FileSearchEventArgs>)DispatchService.GuiDispatch(new EventHandler <FileSearchEventArgs>(FileSearchManager_SearchAdded));
            Core.FileSearchManager.SearchRemoved += (EventHandler <FileSearchEventArgs>)DispatchService.GuiDispatch(new EventHandler <FileSearchEventArgs>(FileSearchManager_SearchRemoved));

            window.Resize(Gui.Settings.WindowSize.Width, Gui.Settings.WindowSize.Height);
            window.Move(Gui.Settings.WindowPosition.X, Gui.Settings.WindowPosition.Y);

            SelectedPage = NetworkOverviewPage.Instance;
        }
Beispiel #55
0
        public override void Setup()
        {
            var statusBar = new StatusBar(new StatusItem [] {
                new StatusItem(Key.CtrlMask | Key.Q, "~^Q~ Quit", () => Quit()),
                new StatusItem(Key.F2, "~F2~ Toggle Frame Ruler", () => {
                    ConsoleDriver.Diagnostics ^= ConsoleDriver.DiagnosticFlags.FrameRuler;
                    Top.SetNeedsDisplay();
                }),
                new StatusItem(Key.F3, "~F3~ Toggle Frame Padding", () => {
                    ConsoleDriver.Diagnostics ^= ConsoleDriver.DiagnosticFlags.FramePadding;
                    Top.SetNeedsDisplay();
                }),
            });

            Top.Add(statusBar);

            _viewClasses = GetAllViewClassesCollection()
                           .OrderBy(t => t.Name)
                           .Select(t => new KeyValuePair <string, Type> (t.Name, t))
                           .ToDictionary(t => t.Key, t => t.Value);

            _leftPane = new Window("Classes")
            {
                X           = 0,
                Y           = 0,
                Width       = 15,
                Height      = Dim.Fill(1),             // for status bar
                CanFocus    = false,
                ColorScheme = Colors.TopLevel,
            };

            _classListView = new ListView(_viewClasses.Keys.ToList())
            {
                X             = 0,
                Y             = 0,
                Width         = Dim.Fill(0),
                Height        = Dim.Fill(0),
                AllowsMarking = false,
                ColorScheme   = Colors.TopLevel,
            };
            _classListView.OpenSelectedItem += (a) => {
                _settingsPane.SetFocus();
            };
            _classListView.SelectedItemChanged += (args) => {
                ClearClass(_curView);
                _curView = CreateClass(_viewClasses.Values.ToArray() [_classListView.SelectedItem]);
            };
            _leftPane.Add(_classListView);

            _settingsPane = new FrameView("Settings")
            {
                X           = Pos.Right(_leftPane),
                Y           = 0,       // for menu
                Width       = Dim.Fill(),
                Height      = 10,
                CanFocus    = false,
                ColorScheme = Colors.TopLevel,
            };
            _computedCheckBox = new CheckBox("Computed Layout", true)
            {
                X = 0, Y = 0
            };
            _computedCheckBox.Toggled += (previousState) => {
                if (_curView != null)
                {
                    _curView.LayoutStyle = previousState ? LayoutStyle.Absolute : LayoutStyle.Computed;
                    _hostPane.LayoutSubviews();
                }
            };
            _settingsPane.Add(_computedCheckBox);

            var radioItems = new ustring [] { "Percent(x)", "AnchorEnd(x)", "Center", "At(x)" };

            _locationFrame = new FrameView("Location (Pos)")
            {
                X      = Pos.Left(_computedCheckBox),
                Y      = Pos.Bottom(_computedCheckBox),
                Height = 3 + radioItems.Length,
                Width  = 36,
            };
            _settingsPane.Add(_locationFrame);

            var label = new Label("x:")
            {
                X = 0, Y = 0
            };

            _locationFrame.Add(label);
            _xRadioGroup = new RadioGroup(radioItems)
            {
                X = 0,
                Y = Pos.Bottom(label),
            };
            _xRadioGroup.SelectedItemChanged += (selected) => DimPosChanged(_curView);
            _xText = new TextField($"{_xVal}")
            {
                X = Pos.Right(label) + 1, Y = 0, Width = 4
            };
            _xText.TextChanged += (args) => {
                try {
                    _xVal = int.Parse(_xText.Text.ToString());
                    DimPosChanged(_curView);
                } catch {
                }
            };
            _locationFrame.Add(_xText);

            _locationFrame.Add(_xRadioGroup);

            radioItems = new ustring [] { "Percent(y)", "AnchorEnd(y)", "Center", "At(y)" };
            label      = new Label("y:")
            {
                X = Pos.Right(_xRadioGroup) + 1, Y = 0
            };
            _locationFrame.Add(label);
            _yText = new TextField($"{_yVal}")
            {
                X = Pos.Right(label) + 1, Y = 0, Width = 4
            };
            _yText.TextChanged += (args) => {
                try {
                    _yVal = int.Parse(_yText.Text.ToString());
                    DimPosChanged(_curView);
                } catch {
                }
            };
            _locationFrame.Add(_yText);
            _yRadioGroup = new RadioGroup(radioItems)
            {
                X = Pos.X(label),
                Y = Pos.Bottom(label),
            };
            _yRadioGroup.SelectedItemChanged += (selected) => DimPosChanged(_curView);
            _locationFrame.Add(_yRadioGroup);

            _sizeFrame = new FrameView("Size (Dim)")
            {
                X      = Pos.Right(_locationFrame),
                Y      = Pos.Y(_locationFrame),
                Height = 3 + radioItems.Length,
                Width  = 40,
            };

            radioItems = new ustring [] { "Percent(width)", "Fill(width)", "Sized(width)" };
            label      = new Label("width:")
            {
                X = 0, Y = 0
            };
            _sizeFrame.Add(label);
            _wRadioGroup = new RadioGroup(radioItems)
            {
                X = 0,
                Y = Pos.Bottom(label),
            };
            _wRadioGroup.SelectedItemChanged += (selected) => DimPosChanged(_curView);
            _wText = new TextField($"{_wVal}")
            {
                X = Pos.Right(label) + 1, Y = 0, Width = 4
            };
            _wText.TextChanged += (args) => {
                try {
                    _wVal = int.Parse(_wText.Text.ToString());
                    DimPosChanged(_curView);
                } catch {
                }
            };
            _sizeFrame.Add(_wText);
            _sizeFrame.Add(_wRadioGroup);

            radioItems = new ustring [] { "Percent(height)", "Fill(height)", "Sized(height)" };
            label      = new Label("height:")
            {
                X = Pos.Right(_wRadioGroup) + 1, Y = 0
            };
            _sizeFrame.Add(label);
            _hText = new TextField($"{_hVal}")
            {
                X = Pos.Right(label) + 1, Y = 0, Width = 4
            };
            _hText.TextChanged += (args) => {
                try {
                    _hVal = int.Parse(_hText.Text.ToString());
                    DimPosChanged(_curView);
                } catch {
                }
            };
            _sizeFrame.Add(_hText);

            _hRadioGroup = new RadioGroup(radioItems)
            {
                X = Pos.X(label),
                Y = Pos.Bottom(label),
            };
            _hRadioGroup.SelectedItemChanged += (selected) => DimPosChanged(_curView);
            _sizeFrame.Add(_hRadioGroup);

            _settingsPane.Add(_sizeFrame);

            _hostPane = new FrameView("")
            {
                X           = Pos.Right(_leftPane),
                Y           = Pos.Bottom(_settingsPane),
                Width       = Dim.Fill(),
                Height      = Dim.Fill(1),             // + 1 for status bar
                ColorScheme = Colors.Dialog,
            };

            Top.Add(_leftPane, _settingsPane, _hostPane);

            Top.LayoutSubviews();

            _curView = CreateClass(_viewClasses.First().Value);
        }
Beispiel #56
0
    public AddEntityDialog(Entity entity)
    {
        _entity = entity;

        var rect = CalculateRect(entity.Size);
        var win  = new Window(rect, $"Insert {entity.Name}");

        Add(win);

        var previewSize = PreviewRect(entity.Size);
        var demoFrame   = new FrameView(previewSize, "Preview");

        _demoBoard       = new BoardView(0, 0, previewSize.Width - 2, previewSize.Height - 2);
        _demoBoard.Focus = new Point(2, 2);
        demoFrame.Add(_demoBoard);

        var closeBtn = new Button(3, rect.Height - 3, "Add", true);

        closeBtn.Clicked += Close;

        var cancelBtn = new Button(closeBtn.Frame.Right + 3, rect.Height - 3, "Cancel");

        cancelBtn.Clicked += Cancel;

        var rotationLabel = new Label(1, 1, "Rotation");

        _rotationChooser          = new RotationChooser(rotationLabel.Frame.Right + 3, 1, entity);
        _rotationChooser.Changed += Redraw;

        var invertLabel = new Label(1, 3, "Inversion");

        _invertChooser          = new InversionChooser(invertLabel.Frame.Right + 2, 3, entity);
        _invertChooser.Changed += Redraw;

        var nameLabel = new Label(1, 5, $"Name: {entity.Name}");

        var descOffset = 7;

        if (!string.IsNullOrEmpty(entity.FullName) && !entity.FullName.Equals(entity.Name))
        {
            descOffset = 9;
            var fullNameLabel = new Label(1, 7, $"Full Name: {entity.FullName}");
            win.Add(fullNameLabel);
        }

        var descSize = previewSize.X - 1;
        var labels   =
            SplitLines(descSize, entity.Description)
            .Select((text, lineNum) => new Label(1, descOffset + lineNum, text));

        win.Add(rotationLabel);
        win.Add(_rotationChooser);
        win.Add(invertLabel);
        win.Add(_invertChooser);
        win.Add(nameLabel);
        foreach (var label in labels)
        {
            win.Add(label);
        }
        win.Add(demoFrame);
        win.Add(closeBtn);
        win.Add(cancelBtn);

        Redraw();
    }
Beispiel #57
0
        private void Initialize()
        {
            Log.Debug(LogTag, "Application initialize started...");
            // Change the background color of Window to White & respond to key events
            Window window = Window.Instance;

            window.BackgroundColor = Color.White;
            window.KeyEvent       += OnKeyEvent;

            //Create background
            Log.Debug(LogTag, "Creating background...");
            ImageView im = new ImageView(DirectoryInfo.Resource + "/images/bg.png");

            im.Size2D = new Size2D(window.Size.Width, window.Size.Height);
            window.Add(im);

            //Create Linear Layout
            Log.Debug(LogTag, "Creating linear layout...");
            LinearLayout linearLayout = new LinearLayout();

            linearLayout.LinearOrientation = LinearLayout.Orientation.Vertical;
            linearLayout.CellPadding       = new Size2D(20, 20);

            //Create main view
            View mainView = new View();

            mainView.Size2D = new Size2D(window.Size.Width, window.Size.Height);
            mainView.Layout = linearLayout;

            //Create custom items and add it to view
            for (int i = 0; i < 4; i++)
            {
                //Create item base view.
                View itemView = new View();
                itemView.BackgroundColor = new Color(0.47f, 0.47f, 0.47f, 0.5f);
                itemView.Name            = "ItemView_" + i.ToString();

                //Create item layout responsible for positioning in each item
                ItemLayout itemLayout = new ItemLayout();
                itemView.Layout = itemLayout;

                //Crate item icon
                ImageView icon = new ImageView(DirectoryInfo.Resource + ListItems[i].GetIconPath());
                icon.Size2D = new Size2D(100, 100);
                icon.Name   = ItemContentNameIcon;
                itemView.Add(icon);

                PropertyMap titleStyle = new PropertyMap();
                titleStyle.Add("weight", new PropertyValue(600));

                //Create item title
                TextLabel title = new TextLabel(ListItems[i].GetLabel());
                title.Size2D    = new Size2D(400, 50);
                title.FontStyle = titleStyle;
                title.Name      = ItemContentNameTitle;
                itemView.Add(title);

                string strDescription = ListItems[i].GetDescription();
                if (strDescription != null)
                {
                    TextLabel description = new TextLabel(strDescription);
                    description.Size2D    = new Size2D(500, 50);
                    description.Name      = ItemContentNameDescription;
                    description.PixelSize = 24.0f;
                    itemView.Add(description);
                }

                mainView.Add(itemView);
            }

            window.Add(mainView);
        }
Beispiel #58
0
        public void LeftTopBottomRight_Win_ShouldNotThrow()
        {
            // Setup Fake driver
            (Window win, Button button) setup()
            {
                Application.Init(new FakeDriver(), new FakeMainLoop(() => FakeConsole.ReadKey(true)));
                Application.Iteration = () => {
                    Application.RequestStop();
                };
                var win = new Window("window")
                {
                    X      = 0,
                    Y      = 0,
                    Width  = Dim.Fill(),
                    Height = Dim.Fill(),
                };

                Application.Top.Add(win);

                var button = new Button("button")
                {
                    X = Pos.Center(),
                };

                win.Add(button);

                return(win, button);
            }

            Application.RunState rs;

            void cleanup(Application.RunState rs)
            {
                // Cleanup
                Application.End(rs);
                // Shutdown must be called to safely clean up Application if Init has been called
                Application.Shutdown();
            }

            // Test cases:
            var app = setup();

            app.button.Y = Pos.Left(app.win);
            rs           = Application.Begin(Application.Top);
            // If Application.RunState is used then we must use Application.RunLoop with the rs parameter
            Application.RunLoop(rs);
            cleanup(rs);

            app          = setup();
            app.button.Y = Pos.X(app.win);
            rs           = Application.Begin(Application.Top);
            // If Application.RunState is used then we must use Application.RunLoop with the rs parameter
            Application.RunLoop(rs);
            cleanup(rs);

            app          = setup();
            app.button.Y = Pos.Top(app.win);
            rs           = Application.Begin(Application.Top);
            // If Application.RunState is used then we must use Application.RunLoop with the rs parameter
            Application.RunLoop(rs);
            cleanup(rs);

            app          = setup();
            app.button.Y = Pos.Y(app.win);
            rs           = Application.Begin(Application.Top);
            // If Application.RunState is used then we must use Application.RunLoop with the rs parameter
            Application.RunLoop(rs);
            cleanup(rs);

            app          = setup();
            app.button.Y = Pos.Bottom(app.win);
            rs           = Application.Begin(Application.Top);
            // If Application.RunState is used then we must use Application.RunLoop with the rs parameter
            Application.RunLoop(rs);
            cleanup(rs);

            app          = setup();
            app.button.Y = Pos.Right(app.win);
            rs           = Application.Begin(Application.Top);
            // If Application.RunState is used then we must use Application.RunLoop with the rs parameter
            Application.RunLoop(rs);
            cleanup(rs);
        }
Beispiel #59
0
        private void Initialize()
        {
            Console.WriteLine("Initialize()!");
            Window window = Window.Instance;

            window.BackgroundColor = Color.Green;

            rootLayoutView = new View();
            rootLayoutView.WidthSpecificationFixed  = 1900;
            rootLayoutView.HeightSpecificationFixed = 1000;
            rootLayoutView.Position        = new Position(0, 0, 0);
            rootLayoutView.BackgroundColor = Color.Green;
            //window.Add(rootLayoutView);

            linearContainer = new View();
            linearContainer.PositionUsesPivotPoint = true;
            linearContainer.PivotPoint             = PivotPoint.Center;
            linearContainer.ParentOrigin           = ParentOrigin.Center;
            linearContainer.BackgroundColor        = Color.Yellow;
            linearContainer.KeyEvent += OnKeyEvent;
            linearContainer.Focusable = true;

            for (int index = 0; index < MAX_CHILDREN - 3; index++)
            {
                imageViews[index] = new ImageView(Images.s_images[index]);
                imageViews[index].WidthSpecificationFixed  = 150;
                imageViews[index].HeightSpecificationFixed = 100;
                linearContainer.Add(imageViews[index]);
            }
            for (int index = MAX_CHILDREN - 3; index < MAX_CHILDREN; index++)
            {
                imageViews[index] = new ImageView(Images.s_images[index]);
                imageViews[index].WidthSpecificationFixed  = 150;
                imageViews[index].HeightSpecificationFixed = 100;
                imageViews[index].Name = "t_image" + (index - 3);
                //test!
                //imageViews[index].WidthSpecification = ChildLayoutData.MatchParent;
                //imageViews[index].HeightSpecification = ChildLayoutData.MatchParent;
            }

            layoutsize = new LayoutSize(50, 50);
            Console.WriteLine($"## layoutsize width={layoutsize.Width}, height={layoutsize.Height}");

            linearlayout = new LinearLayout();
            linearlayout.LayoutAnimate     = true;
            linearlayout.LinearOrientation = LinearLayout.Orientation.Vertical;

            Console.WriteLine($"## TP1");
            //Console.WriteLine($"linearlayout p=0x{LinearLayout.getCPtr(linearlayout).Handle.ToInt64():X},  layoutsize p=0x{LayoutSize.getCPtr(layoutsize).Handle.ToInt64():X}");

            linearlayout.CellPadding = layoutsize;
            Console.WriteLine($"## TP2");
            linearContainer.WidthSpecification  = ChildLayoutData.WrapContent;
            linearContainer.HeightSpecification = ChildLayoutData.WrapContent;
            Console.WriteLine($"## TP3");
            linearContainer.Layout = linearlayout;
            Console.WriteLine($"## TP4");

            //var __layout = linearContainer.Layout as LinearLayout;
            var __layout = linearlayout;

            Console.WriteLine($"##  layout orientation={__layout.LinearOrientation}");
            var __cellpadding = __layout.CellPadding;

            Console.WriteLine($"##  layout cellpadding width={__cellpadding.Width}, height={ __cellpadding.Height}");

            //var rootLayout = new AbsoluteLayout();
            //rootLayoutView.Layout = rootLayout;
            //rootLayoutView.Add(linearContainer);

            window.Add(linearContainer);
            FocusManager.Instance.SetCurrentFocusView(linearContainer);
        }
        public static void View(Customer newCustomer)
        {
            List <Booking> bookings = Read.UserBookings(newCustomer.CustomerId);

            Application.Init();
            var top = Application.Top;

            var win = new Window(new Rect(0, 0, top.Frame.Width, top.Frame.Height), "Show Customers");

            top.Add(win);

            var bookingNumberField = new TextField(20, 1, 17, "");
            var continueButton     = new Button(1, 1, "Continue")
            {
                Clicked = () =>
                {
                    Application.RequestStop();
                }
            };
            var editButton = new Button(45, 1, "Edit Booking")
            {
                Clicked = () =>
                {
                    if (Utilities.CheckBookingNumber(bookingNumberField, newCustomer, out int bookingNumber))
                    {
                        Application.RequestStop();
                        UdateBooking.View(newCustomer.CustomerId, bookingNumber);
                    }
                    else
                    {
                        win.Add(new Label(20, 3, "Invalid input..."));
                    }
                }
            };

            win.Add(
                new Label(20, 0, "Booking (Number)"),
                new Label(2, 3, "Booking"),
                new Label(12, 3, "Mail"),
                new Label(35, 3, "Movie Title"),
                new Label(80, 3, "Quantity"),
                new Label(95, 3, "Total Price"),
                bookingNumberField,
                editButton,
                continueButton
                );


            int y = 4;

            for (int i = 0; i < bookings.Count; i++)
            {
                Booking b = bookings[i];
                win.Add(
                    new Label(2, y, $"{b.BookingNumber}"),
                    new Label(12, y, $"{newCustomer.Mail}"),
                    new Label(35, y, $"{Read.SpecificMovie((int)b.MovieId).Title}"),
                    new Label(80, y, $"{b.Quantity}"),
                    new Label(95, y, $"{Read.SpecificMovie((int)b.MovieId).Price * b.Quantity:C0}")
                    );
                y++;
            }
            ;
            Application.Run();
        }
    }