Beispiel #1
0
 void HandleDragLeave(object o, EventArgs args)
 {
     if (preview && Children.Length > 1)
     {
         sepBox.Hide();
         preview = false;
     }
     else if (preview && Children.Length == 1)
     {
         help.Show();
     }
 }
        public void FinishTestRun()
        {
            if (!Gtk.TreeIter.Zero.Equals(startMessageIter))
            {
                string msg = string.Format(GettextCatalog.GetString("Test results for <b>{0}</b> configuration <b>{1}</b>"), rootTest.Name, configuration);
                failuresStore.SetValue(startMessageIter, 1, msg);
                startMessageIter = Gtk.TreeIter.Zero;
            }
            infoCurrent.Text     = "";
            progressBar.Fraction = 1;
            progressBar.Text     = "";

            infoSep.Hide();
            infoCurrent.Hide();
            progressBar.Hide();
            resultLabel.Show();
            labels.Hide();
            buttonStop.Sensitive = false;
            buttonRun.Sensitive  = true;

            StringBuilder sb = new StringBuilder();

            sb.Append(GettextCatalog.GetString("<b>Tests</b>: {0}", testsRun)).Append("  ");
            sb.Append(GettextCatalog.GetString("<b>Failed</b>: {0}", testsFailed)).Append("  ");
            sb.Append(GettextCatalog.GetString("<b>Ignored</b>: {0}", testsIgnored));
            resultLabel.Markup = sb.ToString();

            Running = false;
        }
Beispiel #3
0
        void ClearWarnings()
        {
            warning.LabelProp = string.Empty;
            warningHBox.Hide();

            infoImage.Hide();
            warningImage.Hide();
        }
Beispiel #4
0
 void pathEntry_Changed(object sender, EventArgs e)
 {
     if (Uri.IsWellFormedUriString(pathEntry.Text, UriKind.RelativeOrAbsolute) && !string.IsNullOrEmpty(pathEntry.Text))
     {
         messageBox.Hide();
     }
     else
     {
         messageBox.Show();
     }
 }
Beispiel #5
0
        void UpdateWarning()
        {
            if (target.SupportedFrameworks.Count > 0)
            {
                warningHBox.Hide();
                return;
            }

            var moniker = target.Id.Profile == null ? TargetFrameworkMoniker.PORTABLE_4_0 : target.Id;

            warning.LabelProp = GettextCatalog.GetString("The {0} framework is not installed.", moniker);

            warningHBox.Show();
        }
		public void FinishTestRun ()
		{
			if (!Gtk.TreeIter.Zero.Equals (startMessageIter)) {
				string msg = string.Format (GettextCatalog.GetString ("Test results for <b>{0}</b> configuration <b>{1}</b>"), rootTest != null ? rootTest.Name : "null", configuration);
				failuresStore.SetValue (startMessageIter, 1, msg);
				startMessageIter = Gtk.TreeIter.Zero;
			}
			infoCurrent.Text = "";
			progressBar.Fraction = 1;
			progressBar.Text = "";
			
			infoSep.Hide ();
			infoCurrent.Hide ();
			progressBar.Hide ();
			resultLabel.Show ();
			labels.Hide ();
			buttonStop.Sensitive = false;
			buttonRun.Sensitive = true;
			
			resultLabel.Markup = GetResultsMarkup ();

			Running = false;
		}
Beispiel #7
0
        public void FinishTestRun()
        {
            infoCurrent.Text     = "";
            progressBar.Fraction = 1;
            progressBar.Text     = "";

            infoSep.Hide();
            infoCurrent.Hide();
            progressBar.Hide();
            resultLabel.Show();
            labels.Hide();
            buttonStop.Sensitive = false;
            buttonRun.Sensitive  = true;

            StringBuilder sb = new StringBuilder();

            sb.Append(GettextCatalog.GetString("<b>Tests</b>: {0}", testsRun)).Append("  ");
            sb.Append(GettextCatalog.GetString("<b>Failed</b>: {0}", testsFailed)).Append("  ");
            sb.Append(GettextCatalog.GetString("<b>Ignored</b>: {0}", testsIgnored));
            resultLabel.Markup = sb.ToString();

            Running = false;
        }
Beispiel #8
0
        public StatusArea()
        {
            theme     = new StatusAreaTheme();
            renderArg = new RenderArg();

            mainContext   = new MainStatusBarContextImpl(this);
            activeContext = mainContext;
            contexts.Add(mainContext);

            VisibleWindow = false;
            NoShowAll     = true;
            WidgetFlags  |= Gtk.WidgetFlags.AppPaintable;

            statusIconBox.BorderWidth = 0;
            statusIconBox.Spacing     = 3;

            Action <bool> animateProgressBar =
                showing => this.Animate("ProgressBarFade",
                                        val => renderArg.ProgressBarAlpha = val,
                                        renderArg.ProgressBarAlpha,
                                        showing ? 1.0f : 0.0f,
                                        easing: Easing.CubicInOut);

            ProgressBegin += delegate {
                renderArg.ShowProgressBar = true;
//				StartBuildAnimation ();
                renderArg.ProgressBarFraction = 0;
                QueueDraw();
                animateProgressBar(true);
            };

            ProgressEnd += delegate {
                renderArg.ShowProgressBar = false;
//				StopBuildAnimation ();
                QueueDraw();
                animateProgressBar(false);
            };

            ProgressFraction += delegate(object sender, FractionEventArgs e) {
                renderArg.ProgressBarFraction = (float)e.Work;
                QueueDraw();
            };

            contentBox.PackStart(messageBox, true, true, 0);
            contentBox.PackEnd(statusIconBox, false, false, 0);
            contentBox.PackEnd(statusIconSeparator = new StatusAreaSeparator(), false, false, 0);
            contentBox.PackEnd(buildResultWidget   = CreateBuildResultsWidget(Orientation.Horizontal), false, false, 0);

            HasTooltip    = true;
            QueryTooltip += messageBoxToolTip;

            mainAlign              = new Alignment(0, 0.5f, 1, 0);
            mainAlign.LeftPadding  = 12;
            mainAlign.RightPadding = 8;
            mainAlign.Add(contentBox);
            Add(mainAlign);

            mainAlign.ShowAll();
            statusIconBox.Hide();
            statusIconSeparator.Hide();
            buildResultWidget.Hide();
            Show();

            this.ButtonPressEvent += delegate {
                if (sourcePad != null)
                {
                    sourcePad.BringToFront(true);
                }
            };

            statusIconBox.Shown += delegate {
                UpdateSeparators();
            };

            statusIconBox.Hidden += delegate {
                UpdateSeparators();
            };

            messageQueue = new Queue <Message> ();

            tracker                 = new MouseTracker(this);
            tracker.MouseMoved     += (sender, e) => QueueDraw();
            tracker.HoveredChanged += (sender, e) => {
                this.Animate("Hovered",
                             x => renderArg.HoverProgress = x,
                             renderArg.HoverProgress,
                             tracker.Hovered ? 1.0f : 0.0f,
                             easing: Easing.SinInOut);
            };

            IdeApp.FocusIn += delegate {
                // If there was an error while the application didn't have the focus,
                // trigger the error animation again when it gains the focus
                if (errorAnimPending)
                {
                    errorAnimPending = false;
                    TriggerErrorAnimation();
                }
            };
        }
Beispiel #9
0
        protected void Initialize()
        {
            Title     = GettextCatalog.GetString("Publish to Folder");
            Resizable = false;
            mainVBox  = new VBox {
                Name    = "mainVBox",
                Spacing = 6
            };

            publishYourAppLabel = new Label {
                Name = "publishYourAppLabel",
                Text = GettextCatalog.GetString("Publish your app to a folder or a file share")
            };
            mainVBox.PackStart(publishYourAppLabel);
            browseVBox = new VBox {
                Name    = "browseVBox",
                Spacing = 6
            };
            browseVBox.MarginTop = 20;
            chooseLabel          = new Label {
                Name = "chooseLabel",
                Text = GettextCatalog.GetString("Choose a folder:")
            };
            browseVBox.PackStart(chooseLabel);
            browseEntryHBox = new HBox {
                Name    = "browseEntryHBox",
                Spacing = 4
            };
            var defaultDirectory = Path.Combine(BinBaseUri.ToString(),
                                                publishCommandItem.Project.TargetFramework.Id.GetShortFrameworkName(),
                                                DefaultConfiguration);

            //make it relative by default
            defaultDirectory = BinBaseUri.MakeRelativeUri(new Uri(defaultDirectory)).ToString();
            pathEntry        = new TextEntry {
                Name = "pathEntry",
                Text = defaultDirectory
            };
            pathEntry.Changed   += pathEntry_Changed;
            pathEntry.LostFocus += PathEntry_LostFocus;
            browseEntryHBox.PackStart(pathEntry, expand: true);
            browseButton = new Button {
                Name  = "browseButton",
                Label = GettextCatalog.GetString("Browse...")
            };
            browseButton.Clicked += browseButton_Clicked;
            browseEntryHBox.PackEnd(browseButton);
            browseVBox.PackStart(browseEntryHBox);

            messageBox = new HBox();
            messageBox.Hide();
            messageLabel      = new Label();
            messageIcon       = new ImageView();
            messageLabel.Text = GettextCatalog.GetString("The path provided is not a valid folder path.");
            messageIcon.Image = ImageService.GetIcon(Gtk.Stock.Cancel, Gtk.IconSize.Menu);
            messageBox.PackStart(messageIcon);
            messageBox.PackStart(messageLabel);
            mainVBox.PackStart(browseVBox);
            mainVBox.PackEnd(messageBox);

            publishButton = new DialogButton(GettextCatalog.GetString("Publish"), Command.Ok);
            cancelButton  = new DialogButton(GettextCatalog.GetString("Cancel"), Command.Close);

            Content = mainVBox;
            Buttons.Add(cancelButton);
            Buttons.Add(publishButton);
            this.DefaultCommand = publishButton.Command;

            Width      = 400;
            Height     = 120;
            Name       = "MainWindow";
            FullScreen = false;
            Resizable  = false;
        }
Beispiel #10
0
        public void ShowAddins(object[] data)
        {
            selectedEntry.Clear();
            selectedAddin.Clear();
            eboxButs.Visible = true;
            topHeaderBox.Hide();
            urlButton.Hide();

            if (titleIcon != null)
            {
                boxTitle.Remove(titleIcon);
                titleIcon.Destroy();
                titleIcon = null;
            }

            foreach (var img in previewImages)
            {
                ((Gtk.Container)img.Parent).Remove(img);
                img.Destroy();
            }
            previewImages.Clear();

            if (data.Length == 1)
            {
                headerBox.Show();
                ShowAddin(data[0]);
            }
            else if (data.Length > 1)
            {
                headerBox.Hide();
                StringBuilder sb = new StringBuilder();
                sb.Append(Catalog.GetString("Multiple selection:\n\n"));
                bool allowUpdate    = AllowInstall;
                bool allowInstall   = true;
                bool allowUninstall = AllowInstall;
                bool allowEnable    = true;
                bool allowDisable   = true;

                foreach (object o in data)
                {
                    Addin installed;
                    if (o is Addin)
                    {
                        Addin a = (Addin)o;
                        installed = a;
                        selectedAddin.Add(a);
                        sb.Append(a.Name);
                    }
                    else
                    {
                        AddinRepositoryEntry entry = (AddinRepositoryEntry)o;
                        selectedEntry.Add(entry);
                        sb.Append(entry.Addin.Name);
                        installed = AddinManager.Registry.GetAddin(Addin.GetIdName(entry.Addin.Id));
                    }
                    if (installed != null)
                    {
                        if (GetUpdate(installed) == null)
                        {
                            allowUpdate = false;
                        }
                        allowInstall = false;
                        if (installed.Enabled)
                        {
                            allowEnable = false;
                        }
                        else
                        {
                            allowDisable = false;
                        }
                    }
                    else
                    {
                        allowEnable = allowDisable = allowUninstall = allowUpdate = false;
                    }

                    sb.Append('\n');
                    labelDesc.Text = sb.ToString();

                    if (allowEnable)
                    {
                        btnDisable.Visible = true;
                        btnDisable.Label   = Catalog.GetString("Enable");
                    }
                    else if (allowDisable)
                    {
                        btnDisable.Visible = true;
                        btnDisable.Label   = Catalog.GetString("Disable");
                    }
                    else
                    {
                        btnDisable.Visible = false;
                    }
                    btnInstall.Visible   = allowInstall;
                    btnUninstall.Visible = allowUninstall;
                    btnUpdate.Visible    = allowUpdate;
                }
            }
            else
            {
                headerBox.Hide();
                btnDisable.Visible   = false;
                btnInstall.Visible   = false;
                btnUninstall.Visible = false;
                btnUpdate.Visible    = false;
                eboxButs.Visible     = false;
                labelDesc.Text       = Catalog.GetString("No selection");
            }
        }
Beispiel #11
0
        private void AddWidgetsAndShow(EditorMode editorMode)
        {
            /* Set a handler for delete_event that immediately
             * exits GTK. */
            DeleteEvent += delete_event;

            if (null != TopLevelHBox)
            {
                TopLevelHBox.Hide();
                TopLevelHBox.Destroy();
                TopLevelHBox = null;
            }

            CurrentMode = editorMode;


            EditorWidget = null;

            switch (editorMode)
            {
            case EditorMode.Level:
                EditorWidget = new LevelEditLayout();
                ((LevelEditLayout)EditorWidget).TreeRefreshNeeded += TreeRefreshNeeded_Event;
                break;

            case EditorMode.Turret:
                EditorWidget = new TurretEditLayout();
                ((TurretEditLayout)EditorWidget).TreeRefreshNeeded += TreeRefreshNeeded_Event;
                break;

            case EditorMode.Enemy:
                EditorWidget = new EnemyEditLayout();
                ((EnemyEditLayout)EditorWidget).TreeRefreshNeeded += TreeRefreshNeeded_Event;
                break;

            case EditorMode.Projectile:
                EditorWidget = new ProjectileEditLayout();
                ((ProjectileEditLayout)EditorWidget).TreeRefreshNeeded += TreeRefreshNeeded_Event;
                break;

            case EditorMode.Analysis:
                EditorWidget = new LevelAnalysisLayout();
                ((LevelAnalysisLayout)EditorWidget).TreeRefreshNeeded += TreeRefreshNeeded_Event;
                break;
            }

            TopLevelHBox = new HBox(false, 0);
            Add(TopLevelHBox);
            TopLevelHBox.Show();

            //
            // Lefthand column
            //

            VBox vbox = new VBox(false, 0);

            TopLevelHBox.PackStart(vbox, false, true, 5);
            vbox.SetSizeRequest(100, -1);
            vbox.Show();

            Button addLevelButton = new Button("+");

            addLevelButton.Clicked += AddButton_Clicked;
            vbox.PackStart(addLevelButton, false, false, 5);
            addLevelButton.Show();

            Button removeLevelButton = new Button("-");

            removeLevelButton.Clicked += RemoveButton_Clicked;
            vbox.PackStart(removeLevelButton, false, false, 5);
            removeLevelButton.Show();

            tree = new TreeView();
            vbox.PackStart(tree, true, true, 0);

            // Create a column for the artist name
            TreeViewColumn   levelColumn       = new TreeViewColumn();
            CellRendererText levelCellRenderer = new CellRendererText();

            levelColumn.PackStart(levelCellRenderer, true);
            levelColumn.AddAttribute(levelCellRenderer, "text", 0);
            tree.AppendColumn(levelColumn);
            ListModel               = new ListStore(typeof(string));
            tree.Model              = ListModel;
            tree.Selection.Mode     = SelectionMode.Single;
            tree.Selection.Changed += TreeSelection_Changed;

            switch (editorMode)
            {
            case EditorMode.Level:
                levelColumn.Title = "Levels";
                PopulateTreeWithLevels();
                break;

            case EditorMode.Turret:
                levelColumn.Title = "Turrets";
                PopulateTreeWithTurrets();
                break;

            case EditorMode.Enemy:
                levelColumn.Title = "Enemies";
                PopulateTreeWithEnemies();
                break;

            case EditorMode.Projectile:
                levelColumn.Title = "Projectiles";
                PopulateTreeWithProjectilees();
                break;

            case EditorMode.Analysis:
                levelColumn.Title = "Analysis";
                PopulateTreeWithLevels();
                break;
            }

            tree.Show();


            //
            // Righthand column
            //

            vbox = new VBox(false, 0);
            TopLevelHBox.PackStart(vbox, true, true, 5);
            vbox.Show();

            HBox modeHbox = new HBox(true, 0);

            vbox.PackStart(modeHbox, false, true, 0);
            modeHbox.Show();

            Button modeButton = new Button("Level");

            modeButton.Show();
            modeButton.Clicked += level_clicked_event;
            modeHbox.PackStart(modeButton, false, false, 5);

            modeButton = new Button("Turret");
            modeButton.Show();
            modeButton.Clicked += turret_clicked_event;
            modeHbox.PackStart(modeButton, false, false, 5);

            modeButton = new Button("Enemy");
            modeButton.Show();
            modeButton.Clicked += enemy_clicked_event;
            modeHbox.PackStart(modeButton, false, false, 5);

            modeButton = new Button("Projectile");
            modeButton.Show();
            modeButton.Clicked += projectile_clicked_event;
            modeHbox.PackStart(modeButton, false, false, 5);

            modeButton = new Button("Analysis");
            modeButton.Show();
            modeButton.Clicked += analysis_clicked_event;
            modeHbox.PackStart(modeButton, false, false, 5);

            vbox.PackStart(EditorWidget, true, true, 5);
            EditorWidget.Show();


            ShowAll();

            LevelManager.WriteAssetDirectory();
        }
Beispiel #12
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();
        }
Beispiel #13
0
        static void OnQIConfirm(object sender, EventArgs e)
        {
            var input = QI_Input.Text;
            var name  = input.ToUpper();

            MenuBoxInput.Hide();
            if (!QIValidName(name))
            {
                QuickGTK.Error("Invalid record name!\n\nRecord names may only contain letters, numbers and underscores!"); return;
            }
            if (MyDataBase.Record.ContainsKey(name))
            {
                if (!QuickGTK.Confirm($"A record named {name} already exists!\n\nIf you continue the old record will be destroyed and replaced by the new one!\n\nAre you sure?"))
                {
                    return;
                }
            }
            switch (want)
            {
            case "NEW":
                var newrec = new MyRecord();
                MyDataBase.Record[name] = newrec;
                foreach (string k in MyDataBase.fields.Keys)
                {
                    var uk = k.ToUpper();
                    newrec.value[k] = "";
                    switch (MyDataBase.fields[k])
                    {
                    case "int":
                    case "double":
                        newrec.value[k] = "0";
                        break;

                    case "bool":
                        newrec.value[k] = "FALSE";
                        break;

                    case "date":
                        newrec.value[k] = "19/6/1975";
                        break;

                    case "time":
                        newrec.value[k] = "00:00:00";
                        break;
                    }
                    if (MyDataBase.defaults.ContainsKey(uk))
                    {
                        newrec.value[k] = MyDataBase.defaults[uk];
                    }
                    Console.WriteLine($"Field: {MyDataBase.fields[k]} {k} = {newrec.value[k]}");
                }
                newrec.MODIFIED = true;
                MyDataBase.UpdateRecView();
                // TODO: New record should add default values if set.
                QuickGTK.Info($"Record {name} has been created!");
                break;

            case "DUPE":
                var rec = MyDataBase.Record[sc_rec];
                newrec = new MyRecord();
                MyDataBase.Record[name] = newrec;
                foreach (string k in MyDataBase.fields.Keys)
                {
                    newrec.value[k] = rec.value[k];
                }
                newrec.MODIFIED = true;
                MyDataBase.UpdateRecView();
                QuickGTK.Info($"Record {sc_rec} has been duplicated into {name}");
                break;

            case "RENAME":
                var crec = MyDataBase.Record[sc_rec];
                MyDataBase.Record.Remove(sc_rec);
                MyDataBase.Record[name] = crec;
                crec.MODIFIED           = true;
                MyDataBase.UpdateRecView();
                QuickGTK.Info($"Record {sc_rec} has been renamed to {name}\n\nWARNING!\nIf you've set MyData to record-by-record export files with the old name will remain!");
                break;

            default:
                QuickGTK.Error($"Internal error!\n\n\nInvalid input request --> {want}!");
                break;
            }
        }