Ejemplo n.º 1
0
        public static void Play()
        {
            Application.Init();

            var provider = new CssProvider();

            provider.LoadFromPath(GetResource("playground.css"));
            StyleContext.AddProviderForScreen(Screen.Default, provider, 800);

            var buffer  = File.ReadAllText(GetResource("playground.glade"));
            var builder = new Builder();

            builder.AddFromString(buffer);

            var window    = (ApplicationWindow)builder.GetObject("window");
            var root      = (Box)builder.GetObject("root");
            var leftArea  = (Box)builder.GetObject("left-area");
            var rightArea = (Box)builder.GetObject("right-area");

            root.SizeAllocated += (o, args) =>
            {
                leftArea.Visible = args.Allocation.Width >= 700;
            };

            var app = new PlaygroundApp(window.Handle);

            builder.Autoconnect(app);

//      var scrollArea = (Box)builder.GetObject("scrolled-window");

            app.Init();
            app.Show();

            Application.Run();
        }
Ejemplo n.º 2
0
        private static void OpenGUI()
        {
            var appstate = new Application("org.AmongUsCapture.AmongUsCaptureUtil", GLib.ApplicationFlags.None);

            appstate.Register(GLib.Cancellable.Current);
            Application.Init();
            window = new UserForm(socket);
            appstate.AddWindow(window);
            Settings.form         = window;
            Settings.conInterface = new FormConsole(window);

            window.DeleteEvent += (object o, DeleteEventArgs e) =>
            {
                // Make sure that the IPC adapter has a chance to clean up after itself.
                IPCadapter.getInstance().Cancel().Wait();
                Application.Quit();
            };

            window.ShowAll();

            Application.Run();
            IPCadapter.getInstance().Cancel().Wait();

            Environment.Exit(0);
        }
Ejemplo n.º 3
0
        public static void Main(string[] args)
        {
            Application.Init();
            MainWindow win = new MainWindow();

            win.Show();
            Application.Run();
        }
Ejemplo n.º 4
0
        public static void Main(string[] args)
        {
            Application.Init();
            Application app = new Application("dev.simo-andreev.catabase", ApplicationFlags.None);

            app.Register(Cancellable.Current);

            Window window = new AppWindow("CataBase S");

            app.AddWindow(window);

            window.SetIconFromFile("res/images/C-Sharp.png");

            window.Show();
            Application.Run();
        }
Ejemplo n.º 5
0
        internal static void Main(string[] args)
        {
            Application.Init();

            _app = new Application("net.spectere.Threads.Player", GLib.ApplicationFlags.HandlesCommandLine);
            _app.Register(Cancellable.Current);

            _wnd = new MainWindow();
            _app.AddWindow(_wnd);

            var quitAction = new SimpleAction("quit", null);

            quitAction.Activated += Application_OnQuit;
            _app.AddAction(quitAction);

            _wnd.Destroyed += Application_OnQuit;

            _wnd.ShowAll();
            Application.Run();
        }
Ejemplo n.º 6
0
        public static void Main()
        {
            Application.Init();
            var window = new Window("Sharp Test");

            window.Resize(600, 400);
            //window.SetIconFromFile("/home/hubert/SharpTest/SharpTest/images/icon.png");
            window.DeleteEvent += Window_Delete;
            //File choosing components
            var labelOsName = new Label("OS Version: " + OsVersion);

            var labelPyhtonVer = new Label("Python ver: " + PythonVer);

            var labelChoose = new Label("Choose python file.");

            var labelFileStatus = new Label {
                Markup = "<span color=\"red\">Wrong file.</span>"
            };

            var fileButton = new FileChooserButton("Choose file", FileChooserAction.Open);

            var scanButton = new Button("Scan file");

            scanButton.SetSizeRequest(100, 50);

            var boxStart = new VBox();

            boxStart.PackStart(labelOsName, false, false, 5);
            boxStart.PackStart(labelPyhtonVer, false, false, 5);
            boxStart.PackStart(labelChoose, false, false, 5);
            boxStart.PackStart(fileButton, false, false, 5);
            boxStart.PackStart(labelFileStatus, false, false, 5);
            boxStart.PackStart(scanButton, false, false, 100);

            //Scaning window components
            var labelTest = new Label("Error while scanning file");

            labelTest.SetPadding(5, 5);

            var scrolledWin = new ScrolledWindow();

            scrolledWin.SetPolicy(PolicyType.Automatic, PolicyType.Automatic);
            scrolledWin.Add(labelTest);

            var boxScan = new VBox();

            boxScan.PackStart(scrolledWin, true, true, 5);


            scanButton.Clicked += (sender, args) => {
                var result = ScanFile(fileButton.Filename);
                if (result == null)
                {
                    labelFileStatus.Show();
                }
                else
                {
                    labelFileStatus.Hide();
                    var structure = "";
                    var classes   = new List <string>(result.Keys);
                    //Add classes
                    foreach (var _class in classes)
                    {
                        structure += "Class: " + _class + "\n";
                        foreach (var method in result[_class])
                        {
                            //Add method name
                            structure += "|__ Method: " + method["name"] + "\n";
                            //Add params
                            var parameters = "";
                            int i          = 0;
                            foreach (var param in (IEnumerable)method["param"])
                            {
                                if (i > 0)
                                {
                                    parameters += ",";
                                }
                                parameters += " " + param;
                                i++;
                            }
                            structure += "|____ Params: " + parameters + "\n";
                            //Add return
                            structure += "|____ Return: " + method["return"] + "\n";
                        }

                        structure += "\n";
                    }

                    labelTest.Text = structure;
                    window.Remove(boxStart);
                    window.Add(boxScan);
                    window.ShowAll();
                }
            };

            window.Add(boxStart);
            window.ShowAll();
            //Hide some widgets

            labelFileStatus.Hide();
            Application.Run();
        }
Ejemplo n.º 7
0
        public WindowBuilder()
        {
            _columnFilter = 0;
            _textToFilter = "";

            _processIdToKill = new List <int>();
            _listStore       = new ListStore(typeof(string), typeof(string), typeof(string), typeof(string),
                                             typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string));

            Application.Init();

            _window = new Window("Label sample");
            _window.Resize(1300, 600);
            _window.Title = "Process Watch";
            _window.SetIconFromFile("icons/processIconSmall.png");
            _window.BorderWidth  = 5;
            _window.DeleteEvent += OnWindowClose;

            var aboutButton = new Button();
            var aboutIcon   = new Image();

            aboutIcon.Pixbuf        = new Pixbuf("icons/information.png");
            aboutButton.Image       = aboutIcon;
            aboutButton.TooltipText = "About Process Watch";
            aboutButton.Clicked    += (sender, args) =>
            {
                _aboutDialog.Show();
            };

            _aboutDialog = CreateAboutDialog();

            var filterButton = new Button();

            filterButton.Image       = new Image(Stock.Find, IconSize.Button);
            filterButton.TooltipText = "Filtration utilities";
            filterButton.Clicked    += (sender, args) =>
            {
                if (_filtrationHBox.IsVisible)
                {
                    _filtrationHBox.Hide();
                }
                else
                {
                    _filtrationHBox.ShowAll();
                }
            };

            var windowHBox = new HBox(false, 5);

            windowHBox.PackEnd(aboutButton, false, false, 0);
            windowHBox.PackEnd(filterButton, false, false, 0);

            _processNameEntry          = new Entry();
            _processNameEntry.Changed += OnChanged;

            _processIdEntry               = new Entry();
            _processIdEntry.Changed      += OnChanged;
            _processIdEntry.TextInserted += OnlyNumerical;

            // String values for the combobox - filtration direction
            _filtrationDirectionOptions = new[]
            {
                ">",
                "≥",
                "=",
                "≤",
                "<"
            };

            // String values for the combobox - memory usage units
            _memoryFiltrationDirectionUnits = new[]
            {
                "B",
                "KB",
                "MB",
                "GB"
            };


            _memoryFiltrationEntry = new Entry();
            _memoryFiltrationEntry.MaxWidthChars = 7;
            _memoryFiltrationEntry.WidthChars    = 7;
            _memoryFiltrationEntry.Changed      += OnChanged;
            _memoryFiltrationEntry.TextInserted += OnlyNumerical;

            _memoryFiltrationDirectionComboBox          = new ComboBox(_filtrationDirectionOptions);
            _memoryFiltrationDirectionComboBox.Changed += OnChanged;

            _memoryFiltrationUnitsComboBox          = new ComboBox(_memoryFiltrationDirectionUnits);
            _memoryFiltrationUnitsComboBox.Changed += OnChanged;

            _memoryFiltrationHbox = new HBox();
            _memoryFiltrationHbox.PackStart(_memoryFiltrationDirectionComboBox, false, false, 0);
            _memoryFiltrationHbox.PackStart(_memoryFiltrationEntry, false, false, 0);
            _memoryFiltrationHbox.PackStart(_memoryFiltrationUnitsComboBox, false, false, 0);


            _cpuFiltrationEntry = new Entry();
            _cpuFiltrationEntry.MaxWidthChars = 7;
            _cpuFiltrationEntry.WidthChars    = 7;
            _cpuFiltrationEntry.Changed      += OnChanged;
            _cpuFiltrationEntry.TextInserted += OnlyNumerical;

            _cpuFiltrationDirectionComboBox          = new ComboBox(_filtrationDirectionOptions);
            _cpuFiltrationDirectionComboBox.Changed += OnChanged;

            var cpuFiltrationLabel = new Label("%");

            _cpuFiltrationHbox = new HBox();
            _cpuFiltrationHbox.PackStart(_cpuFiltrationDirectionComboBox, false, false, 0);
            _cpuFiltrationHbox.PackStart(_cpuFiltrationEntry, false, false, 0);
            _cpuFiltrationHbox.PackStart(cpuFiltrationLabel, false, false, 0);


            _filtrationOptions = new[]
            {
                "All processes",
                "Filter by PID",
                "Filter by Process Name",
                "Filter by Memory Usage",
                "Filter by CPU usage",
            };

            var filtrationCombo = new ComboBox(_filtrationOptions);

            filtrationCombo.Changed += ComboOnChanged;

            _filtrationHBox = new HBox(false, 5);
            _filtrationHBox.PackStart(filtrationCombo, false, false, 0);


            string[] columnLabels =
            {
                "PID",
                "Process name",
                "Memory usage",
                "Priority",
                "User CPU Time",
                "Privileged CPU Time",
                "Total CPU Time",
                "CPU usage",
                "Threads",
                "Start Time"
            };


            _treeModelFilter             = new TreeModelFilter(_listStore, null);
            _treeModelFilter.VisibleFunc = Filter;

            var treeModelSort = new TreeModelSort(_treeModelFilter);

            treeModelSort.SetSortFunc(0, WindowBuilderHelper.IdSortFunc);
            treeModelSort.SetSortFunc(1, WindowBuilderHelper.ProcessNameSortFunc);
            treeModelSort.SetSortFunc(2, WindowBuilderHelper.MemoryUsageSortFunc);
            treeModelSort.SetSortFunc(3, WindowBuilderHelper.PrioritySortFunc);
            treeModelSort.SetSortFunc(4, WindowBuilderHelper.UserCpuTimeSortFunc);
            treeModelSort.SetSortFunc(5, WindowBuilderHelper.PrivilegedCpuTimeSortFunc);
            treeModelSort.SetSortFunc(6, WindowBuilderHelper.TotalCpuTimeSortFunc);
            treeModelSort.SetSortFunc(7, WindowBuilderHelper.CpuUsageSortFunc);
            treeModelSort.SetSortFunc(8, WindowBuilderHelper.ThreadCountSortFunc);
            treeModelSort.SetSortFunc(9, WindowBuilderHelper.StartTimeSortFunc);

            var treeView = new TreeView();

            treeView.Model              = treeModelSort;
            treeView.Selection.Mode     = SelectionMode.Multiple;
            treeView.Selection.Changed += OnSelectionChanged;
            treeView.TooltipColumn      = 1;

            // Create a scrollable window
            var scrolledWindow = new ScrolledWindow();

            scrolledWindow.Add(treeView);

            // Create a CellRendererText responsible for proper rendering cell data
            var cellRendererText = new CellRendererText();

            cellRendererText.Alignment = Pango.Alignment.Right;
            cellRendererText.Xalign    = 0.5f;

            // Load the _treeView with TreeViewColumns
            for (int i = 0; i < 10; i++)
            {
                var treeViewColumn = new TreeViewColumn();
                treeViewColumn.Clickable     = true;
                treeViewColumn.Resizable     = true;
                treeViewColumn.Title         = columnLabels[i];
                treeViewColumn.SortIndicator = true;
                treeViewColumn.Alignment     = 0.5f;
                treeViewColumn.Expand        = true;
                treeViewColumn.SortColumnId  = i;
                treeViewColumn.PackStart(cellRendererText, true);
                treeViewColumn.AddAttribute(cellRendererText, "text", i);

                switch (i)
                {
                case 0:
                    break;

                case 1:
                    _window.GetSize(out int width, out int height);
                    treeViewColumn.MaxWidth = Math.Abs(width / 2);
                    break;

                case 2:
                    treeViewColumn.SetCellDataFunc(cellRendererText, WindowBuilderHelper.MemoryUsageFormatter);
                    break;

                case 3:
                    break;

                case 4:
                    treeViewColumn.SetCellDataFunc(cellRendererText, WindowBuilderHelper.UserCpuTimeFormatter);
                    break;

                case 5:
                    treeViewColumn.SetCellDataFunc(cellRendererText, WindowBuilderHelper.PrivilegedCpuTimeFormatter);
                    break;

                case 6:
                    treeViewColumn.SetCellDataFunc(cellRendererText, WindowBuilderHelper.TotalCpuTimeFormatter);
                    break;

                case 7:
                    treeViewColumn.SetCellDataFunc(cellRendererText, WindowBuilderHelper.CpuUsageFormatter);
                    break;

                case 8:
                    break;

                case 9:
                    treeViewColumn.SetCellDataFunc(cellRendererText, WindowBuilderHelper.StartTimeFormatter);
                    break;
                }

                treeView.AppendColumn(treeViewColumn);
            }

            var killButton = new Button("Kill process");

            killButton.Clicked += KillProcess;

            var windowVBox = new VBox(false, 5);

            windowVBox.PackStart(windowHBox, false, false, 0);
            windowVBox.PackStart(_filtrationHBox, false, false, 0);
            windowVBox.PackStart(scrolledWindow, true, true, 0);
            windowVBox.PackStart(killButton, false, false, 0);

            _window.Add(windowVBox);

            // Create an instance of the object Updater
            _processGrabber = new ProcessGrabber();
            // Add a callback executed when _processGrabber takes process data.
            // The callback clears the _treeView content and loads new data
            // Before clearing the _treeView content the callback saves the current scroll position
            _processGrabber.OnResult += (sender, processList) =>
            {
                Application.Invoke(delegate
                {
                    _currentScrollPosition = treeView.Vadjustment.Value;
                    StoreClear();
                    LoadStore(processList);

                    treeView.ShowAll();
                });
            };

            // Add a callback executed after 'Changed' event raised after changing the position of the _treeView
            // When the _treeView content is reloaded the previous scroll position is updated
            treeView.Vadjustment.Changed += (sender, args) =>
            {
                treeView.Vadjustment.Value = _currentScrollPosition;
            };

            // Start the Timer process responsible for grabbing process data periodically
            _processGrabber.Run();

            treeView.ShowAll();
            _window.ShowAll();

            // Hide widgets related to process filtration
            _filtrationHBox.Hide();
        }
Ejemplo n.º 8
0
    static int LoadXap(string file, List <string> args)
    {
        string [] test = { "" };

        if (sync)
        {
            test [0] = "--sync";
        }

        Application.Init("mopen", ref test);
        MoonlightRuntime.Init();
        window = new Gtk.Window(file);
        window.SetDefaultSize(400, 400);

        if (transparent)
        {
            CompositeHelper.SetRgbaColormap(window);
            window.AppPaintable = true;
            window.ExposeEvent += HandleExposeEvent;
        }

        if (desklet)
        {
            ConfigureDeskletWindow(window);
        }

        window.DeleteEvent += delegate {
            Application.Quit();
        };

        moon_host = new MoonlightHost();

        try {
            moon_host.LoadXap(file);
        } catch (Exception e) {
            Console.Error.WriteLine("mopen: Could not load xaml: {0}", e.Message);
            return(1);
        }

        System.Windows.Application app = moon_host.Application;
        FrameworkElement           top = (FrameworkElement)app.RootVisual;

        if (top is Moon.Windows.Desktop.Window)
        {
            var moonwindow = ((Moon.Windows.Desktop.Window)top);
            /* special window handling mode */
            moonwindow.IsActive = window.IsActive;

            Wnck.Screen.Default.ActiveWindowChanged += delegate {
                moonwindow.IsActive = window.IsActive;
            };

            moonwindow.PositionChanged += delegate {
                window.Move((int)moonwindow.Position.X, (int)moonwindow.Position.Y);
            };

            moonwindow.SizeChanged += delegate {
                window.Resize((int)moonwindow.Size.Width, (int)moonwindow.Size.Height);
            };

            moonwindow.WindowOpacityChanged += delegate {
                moon_host.QueueDraw();
            };

            if (!transparent)
            {
                CompositeHelper.SetRgbaColormap(window);
                window.AppPaintable = true;
                window.ExposeEvent += HandleExposeEvent;

                moon_host.AppPaintable = true;
                moon_host.Transparent  = true;
            }
        }

        if (parse_only)
        {
            return(0);
        }

        if (width == -1)
        {
            width = (int)top.Width;
        }
        if (height == -1)
        {
            height = (int)top.Height;
        }

        if (width > 0 && height > 0)
        {
            moon_host.SetSizeRequest(width, height);
            window.Resize(width, height);
        }

        if (transparent)
        {
            moon_host.AppPaintable = true;
            moon_host.Transparent  = true;
        }

        if (desklet)
        {
            top.MouseLeftButtonDown += new MouseButtonEventHandler(HandleMouseLeftButtonDown);
            top.MouseLeftButtonUp   += new MouseButtonEventHandler(HandleMouseLeftButtonUp);
            top.MouseMove           += new MouseEventHandler(HandleMouseMove);
        }

        window.Add(moon_host);

        window.ShowAll();

        if (story_names != null)
        {
            storyboards = new List <Storyboard> ();

            foreach (string story in story_names)
            {
                object     o  = top.FindName(story);
                Storyboard sb = o as Storyboard;

                if (sb == null)
                {
                    Console.Error.WriteLine("mopen: there is no Storyboard object named {0} in the XAML file", story);
                    return(1);
                }
                sb.Completed += delegate {
                    window.Title = String.Format("Storyboard {0} completed", current_storyboard - 1);
                };

                storyboards.Add(sb);
            }
            ;

            top.MouseLeftButtonUp += delegate {
                if (current_storyboard == storyboards.Count)
                {
                    current_storyboard = 0;
                }
                if (current_storyboard == storyboards.Count)
                {
                    return;
                }

                window.Title = String.Format("Storyboard {0} running", current_storyboard);
                storyboards [current_storyboard++].Begin();
            };
        }

        if (timeout > 0)
        {
            GLib.Timeout.Add((uint)(timeout * 1000), new TimeoutHandler(Quit));
        }

        Application.Run();
        return(0);
    }