Gtk# application is not rendering TreeView Properly - c#

I am trying to develop a gtk application on mac using gtk#. I created a tree view just like in the tutorial but the arrows are not rendering properly as seem below, there are no arrows. I can click to open and close but the actual arrows aren't working.
I copy pasted the code from the tutorial and It did the same thing, but here is my code anywhere. I have also verified view.ShowExpanders is set to true
Application.Init();
Window window = new Window("Editor Window");
window.SetPosition(WindowPosition.Center);
window.HeightRequest = 800;
window.WidthRequest = 1200;
TreeView view = new TreeView();
view.WidthRequest = 500;
TreeViewColumn column = new TreeViewColumn();
column.Title = "Heirarchy";
CellRendererText cell = new CellRendererText();
column.PackStart(cell, true);
view.AppendColumn(column);
column.AddAttribute(cell, "text", 0);
TreeStore store = new TreeStore(typeof(string));
TreeIter i = store.AppendValues("Project");
i = store.AppendValues(i,"Room1");
i = store.AppendValues(i, "Item");
store.AppendValues(i, "Attribute");
store.AppendValues(i, "Attribute");
store.AppendValues(i, "Attribute");
view.ShowExpanders = true;
view.Model = store;
view.ShowExpanders = true;
window.Add(view);
window.DeleteEvent += ExitWindow;
window.ShowAll();
Application.Run();
Is there some sort of image asset that doesn't exist on my computer? How would I install that on mac? Thank you for any help you can provide.

As a comment suggested, using brew install adwaita-icon-theme fixed the problem

Related

WPF C# Circle Progress Bar WindowsFormsHost

So I'm getting a weird error... I followed some steps to create a CircularProgressBar in my WPF C# App. It works fine on my desktop, it doesn't on my laptop.
I create a WindowsFormsHost and make the Circular Progress Bar the Child. I then make it the children of a grid called ProgressGrid.
Anyway, The error just says "Unhandled exception has occured in a component in your application. If you click Continue, the application will ignore this error" It runs perfectly fine if I click continue mind you.
The error details say "System.ArgumentException: Parameter is not valid" it goes on to list pretty much everything I wrote. I thought it had something to do with Dispose()... Heres the Code:
var SelectAll =
(from a in dc.GetTable<SR>()
select a).ToList();
int all = SelectAll .Count();
var ByGroup =
(from a in dc.GetTable<SR>()
where a.GroupID == GroupID
orderby a.ID
select a).ToList();
int SelectedGroup = ByGroup .Count();
System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost();
CircularProgressBar.CircularProgressBar ProgressCircle = new CircularProgressBar.CircularProgressBar();
host.Child = ProgressCircle;
ProgressGrid.Children.Add(host);
if (ShallMarquee == 1 || FilterByThisDivision == TheEmployee.Division)
{
ProgressCircle.Style = System.Windows.Forms.ProgressBarStyle.Marquee;
}
else
{
ProgressCircle.Style = System.Windows.Forms.ProgressBarStyle.Blocks;
}
ProgressCircle.MarqueeAnimationSpeed = 4000;
ProgressCircle.Text = Convert.ToString(NumOf + "%");
ProgressCircle.SubscriptText = "";
ProgressCircle.SuperscriptText = "";
ProgressCircle.Font = new Font("Arial", 22);
ProgressCircle.ProgressWidth = 10;
ProgressCircle.SuperscriptColor = System.Drawing.Color.Black;
ProgressCircle.ProgressColor = System.Drawing.ColorTranslator.FromHtml(MainColor);
System.Windows.Media.Color StandardBackgroundBlue = (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString(BackgroundColor);
var drawingcolor = System.Drawing.Color.FromArgb(StandardBackgroundBlue.A, StandardBackgroundBlue.R, StandardBackgroundBlue.G, StandardBackgroundBlue.B);
ProgressCircle.BackColor = drawingcolor;
ProgressCircle.InnerColor = drawingcolor;
ProgressCircle.OuterColor = System.Drawing.Color.LightGray;
ProgressCircle.ForeColor = System.Drawing.Color.Black;
ProgressCircle.Value = NumOf;
ProgressCircle.Maximum = TotalNum;
//END CIRCLE
For now the gridjust displays a string as the number while I adjust things so you can ignore that. I also read something about GDI but I'm a bit lost.
P.S. I should note it also says "Invalid Parameter" which it most certainly is not.
P.P.S. I developed this on a Windows 7 64 bit. My laptop is a Windows 10 64bit. But it also doesn't work on my brothers Windows 7 64 bit. If that helps any...
Okay, so I was able to make it work. I'm not "exactly" sure why though. I loaded the grid that contains the WindowsFormsHost Grid with visibility set to false first and after it loaded I set it to true. For whatever reason, it works this way. If anyone could think of why that would be awesome. This way does work though!

Display a nsoutlineview programmatically

I want to display a simple nsoutlineview that will display a hierarchy.
When I did it via InterfaceBuilder, everything was fine, but now that I'm trying to it programmatically, I have some trouble.
Here the code I use to display the outline view, inside a nsscrollview :
this.OutlineView = new NSOutlineView();
this.OutlineView.IndentationPerLevel = 16.0f;
this.OutlineView.IndentationMarkerFollowsCell = true;
this.OutlineView.SelectionHighlightStyle = NSTableViewSelectionHighlightStyle.Regular;
this.OutlineView.HeaderView = null;
this.OutlineView.BackgroundColor = NSColor.FromDeviceRgba(225f/255f,228f/255f,232f/255f,1f);
this.OutlineView.DataSource = dataSource;
this.OutlineView.Delegate = aDelegate;
NSTableColumn tableColumn = new NSTableColumn("Name");
tableColumn.Editable = false;
tableColumn.MinWidth = 100f;
this.OutlineView.AddColumn(tableColumn);
this.DocumentView = this.OutlineView;
And this is what I get when I want to display the hierarchy of a root directory and a file inside this directory :
No arrow before root, no indentation of the file in the directory...
Ok found it after looking in the debugger how xCode construct the scroll view :S
In addition to adding the table column, you have to set the OutlineTableColumn, by adding this line :
this.OutlineView.OutlineTableColumn = tableColumn;

Result in Installed app differ from result during debug

I have a program where in I add column with buttons programmatically. When I'm in the visual studio it work accordingly but when I install it, The app crashed. When I remove the background image of the button it do work even in the installed app. here is my code in how I add a column with button in my datagrid.
///Here is the part where I declare the path of my image background
Image EditImage = new Image();
EditImage.Source = new BitmapImage(new Uri("../../Icons/pencil.png", UriKind.Relative));
ImageBrush imgEditBrush = new ImageBrush(EditImage.Source);
//Here is the part where I add my column
DataGridTemplateColumn Edit = new DataGridTemplateColumn();
Edit.Header = "Edit";
FrameworkElementFactory EditFactory = new FrameworkElementFactory(typeof(Button));
Binding b1 = new Binding("IsClicked");
b1.Mode = BindingMode.TwoWay;
EditFactory.SetValue(Button.BackgroundProperty, imgEditBrush);
EditFactory.SetValue(Button.WidthProperty, size);
EditFactory.AddHandler(Button.ClickEvent, new RoutedEventHandler(EditTransaction_Click));
DataTemplate CellEdit = new DataTemplate();
CellEdit.VisualTree = EditFactory;
Edit.CellTemplate = CellEdit;
dgDataGrid.Columns.Add(Edit);
What's wrong with my declaration of Button.BackgroundProperty? Can anyone help me out. Thank you in advance.

How to change window background color in mono (GTK)?

I have a window in gtk which includes a Build() function as follow:
protected virtual void Build()
{
global::Stetic.Gui.Initialize(this);
// Widget Client.Forms.Notification
this.Name = "Client.Forms.Notification";
this.Title = "Notification";
this.TypeHint = Gdk.WindowTypeHint.Normal;
//this.TypeHint = ((global::Gdk.WindowTypeHint)(4));
this.WindowPosition = ((global::Gtk.WindowPosition)(4));
// Container child Client.Forms.Notification.Gtk.Container+ContainerChild
this.vbox1 = new global::Gtk.VBox();
this.vbox1.Name = "vbox1";
this.vbox1.Spacing = 6;
// Container child vbox1.Gtk.Box+BoxChild
this.label1 = new global::Gtk.Label();
this.label1.HeightRequest = 20;
this.label1.Name = "label1";
this.label1.LabelProp = "Notification";
this.vbox1.Add(this.label1);
global::Gtk.Box.BoxChild w1 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.label1]));
w1.Position = 0;
w1.Expand = false;
w1.Fill = false;
// Container child vbox1.Gtk.Box+BoxChild
this.hbox1 = new global::Gtk.HBox();
this.hbox1.Name = "hbox1";
this.hbox1.Spacing = 6;
// Container child hbox1.Gtk.Box+BoxChild
this.image1 = new global::Gtk.Image();
this.image1.Name = "image1";
this.image1.Pixbuf = global::Gdk.Pixbuf.LoadFromResource("Client.Resources.icon.png");
this.hbox1.Add(this.image1);
global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.image1]));
w2.Position = 0;
w2.Expand = false;
w2.Fill = false;
// Container child hbox1.Gtk.Box+BoxChild
this.label2 = new global::Gtk.Label();
this.label2.Name = "label2";
this.label2.WidthRequest = 260;
this.label2.Wrap = true;
this.label2.LabelProp = "Description";
this.hbox1.Add(this.label2);
global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.label2]));
w3.Position = 1;
w3.Expand = false;
w3.Fill = false;
this.vbox1.Add(this.hbox1);
global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.hbox1]));
w4.Position = 1;
w4.Expand = false;
w4.Fill = false;
this.label1.ModifyBase(Gtk.StateType.Normal, Core.fromColor(System.Drawing.Color.Orange));
this.ModifyBase(Gtk.StateType.Normal, Core.fromColor(System.Drawing.Color.Orange));
this.vbox1.ModifyBase(Gtk.StateType.Normal, Core.fromColor(System.Drawing.Color.Orange));
root = new Gtk.EventBox();
root.Add(this.vbox1);
this.Decorated = false;
this.Add(root);
if ((this.Child != null))
{
this.Child.ShowAll();
}
this.DefaultWidth = 460;
this.DefaultHeight = 220;
}
(source code of this whole window: https://github.com/pidgeonproject/pidgeon/blob/master/Forms/Notification.cs)
As you can see it is calling
this.ModifyBase(Gtk.StateType.Normal, Core.fromColor(System.Drawing.Color.Orange));
which should change the background to orange, however it doesn't.
I tried to insert more similar functions on window elements, but it doesn't work either, does anyone know how to change the background color of the window?
What I want to do is create a small window with no decoration (so just a rectangle) of specific color and some text in it. This window is supposed to be transparent (that works now) and should have a picture and 2 labels with text and disappear on click - all this works now just I can't change the background from gray to some better color. I would be happy for answers that would let me do this using some other way (I can think of creating a small form just with drawing area and paint it with the color and then paint the text as well, but it sounds to me quite complicated for something so simple as I want to do).
NOTE: mono is using GTK 2, and the version of GTK# for .Net is using 2.12.20
Try to use Event Box. Seems to work
For GTK+2 you need to create a gtk resource like so:
char *my_custom_style = "style \"my-style-name\" { bg[NORMAL] = \"#339933\" }\nclass \"GtkWindow\" style \"my-style-name\"";
then load the resource when you start the program, after initialization:
gtk_rc_parse_string (my_custom_style);
Now any GtkWindow will use your custom style for it's background.
The C documentation for Gtk Resource Files
Edit:
If you only want to change one specific window, then you'd change the custom style string to something like
char *my_custom_style="style \"my-style-name\" { bg[NORMAL] = \"#339933\" }\nwidget \"my-custom-window\" style= \"my-style-name\"';
You then set the name of the window you want to change the background with
gtk_widget_set_name (GTK_WIDGET (my_window), "my-custom-window");
Edit 2:
Here's the documentation to the Gtk# Rc parsing function:
http://buttle.shangorilla.com/1.1/handlers/monodoc.ashx?link=M%3aGtk.Rc.Parse(System.String)
The documentation (for the C API) says that gtk_widget_modify_color() is deprecated, and that newly written code should use gtk_widget_override_background_color() instead, so try that.
Overriding themes in GTK+ is notoriously hard though, but the 3.0 API really sounds as if it's supporting what you want to do.
Can't test this myself at the moment, unfortunately.

Changing Contol Parent Removes Content

In my application, I have a DataGridView that moves from one Tab Control to another Tab Control.
I am doing this by changing its parent. This works with no problems on the first move from the origional Tab Control to the new one, but when changing the parent back to the origional, the DataGridView shows up (all the Columns are visible) but there is no data in the view.
I have tried to reload the data into the DataGridView, and refresh/Invalidate the control to make it redraw, but it still shows up empty. However, when the control goes back to the secondary parent, the data is back.
I am also using this exact code for another DataGridView and it works without any problems at all.
Any ideas would be greatly appreciated, and thanks in advance.
From Origional to Secondary
gvwRFIs.Parent = tabProcessingRFI; //Working
gvwConsentInfoMemos.Parent = tabProcessingMemos; //Working
From Secondary to Origional
gvwRFIs.Parent = tabConsentInfoRFI; //Empty Data
gvwConsentInfoMemos.Parent = tabConsentInfoMemos; //Working
RFI DataGridView Designer Code
//
// gvwRFIs
//
this.gvwRFIs.AllowUserToAddRows = false;
this.gvwRFIs.AllowUserToDeleteRows = false;
this.gvwRFIs.AllowUserToResizeRows = false;
this.gvwRFIs.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders;
this.gvwRFIs.BackgroundColor = System.Drawing.Color.White;
this.gvwRFIs.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.gvwRFIs.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.gvwID,
this.gvwType,
this.gvwSeq,
this.gvwCreated,
this.gvwProcessor,
this.gvwLetter,
this.gvwResponded,
this.gvwS,
this.gvwDetails});
this.gvwRFIs.Dock = System.Windows.Forms.DockStyle.Fill;
this.gvwRFIs.Location = new System.Drawing.Point(3, 3);
this.gvwRFIs.MultiSelect = false;
this.gvwRFIs.Name = "gvwRFIs";
this.gvwRFIs.ReadOnly = true;
this.gvwRFIs.RowHeadersVisible = false;
this.gvwRFIs.RowHeadersWidth = 4;
this.gvwRFIs.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.gvwRFIs.Size = new System.Drawing.Size(1078, 422);
this.gvwRFIs.TabIndex = 4;
this.gvwRFIs.DoubleClick += new System.EventHandler(this.gvwRFIs_DoubleClick);
Consent Tab Control Designer Code
//
// tabConsentInfoRFI
//
this.tabConsentInfoRFI.Controls.Add(this.gvwRFIs);
this.tabConsentInfoRFI.Controls.Add(this.lvwConsentInfoRFI);
this.tabConsentInfoRFI.Location = new System.Drawing.Point(4, 32);
this.tabConsentInfoRFI.Name = "tabConsentInfoRFI";
this.tabConsentInfoRFI.Padding = new System.Windows.Forms.Padding(3);
this.tabConsentInfoRFI.Size = new System.Drawing.Size(1084, 428);
this.tabConsentInfoRFI.TabIndex = 4;
this.tabConsentInfoRFI.Text = "RFI\'s";
this.tabConsentInfoRFI.UseVisualStyleBackColor = true;
Processing Tab Control Designer Code
//
// tabProcessingRFI
//
this.tabProcessingRFI.Location = new System.Drawing.Point(4, 36);
this.tabProcessingRFI.Name = "tabProcessingRFI";
this.tabProcessingRFI.Padding = new System.Windows.Forms.Padding(3);
this.tabProcessingRFI.Size = new System.Drawing.Size(868, 465);
this.tabProcessingRFI.TabIndex = 1;
this.tabProcessingRFI.Text = "RFI";
this.tabProcessingRFI.UseVisualStyleBackColor = true;
I found the issue,
The ListView that is in the consent designer code, is an old control that looks identical, but is no longer used. So when the control is parented back to the Origional tab, it is in the background of this control.
Once the control was removed (thought it already was) the code worked perfectly.
Thank you to LarsTech for getting me in the right direction. And akhisp for there answer.
You should remove the object from the Tab.Controls list of the tab that it's no longer in. So do something like:
tabProcessingRFI.Controls.Remove(gvwRFIs);
gvwRFIs.Parent = tabConsentInfoRFI

Categories