Esempio n. 1
0
        /// <summary>
        /// Constructor
        /// </summary>
        public MainView(ViewBase owner = null) : base(owner)
        {
            MasterView      = this;
            numberOfButtons = 0;
            if ((uint)Environment.OSVersion.Platform <= 3)
            {
                Rc.Parse(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                                      ".gtkrc"));
            }
            baseFont        = Rc.GetStyle(new Label()).FontDescription.Copy();
            defaultBaseSize = baseFont.Size / Pango.Scale.PangoScale;
            FontSize        = Utility.Configuration.Settings.BaseFontSize;
            Builder builder = BuilderFromResource("ApsimNG.Resources.Glade.MainView.glade");

            window1         = (Window)builder.GetObject("window1");
            progressBar     = (ProgressBar)builder.GetObject("progressBar");
            StatusWindow    = (TextView)builder.GetObject("StatusWindow");
            stopButton      = (Button)builder.GetObject("stopButton");
            notebook1       = (Notebook)builder.GetObject("notebook1");
            notebook2       = (Notebook)builder.GetObject("notebook2");
            vbox1           = (VBox)builder.GetObject("vbox1");
            vbox2           = (VBox)builder.GetObject("vbox2");
            hpaned1         = (HPaned)builder.GetObject("hpaned1");
            hbox1           = (HBox)builder.GetObject("hbox1");
            _mainWidget     = window1;
            window1.Icon    = new Gdk.Pixbuf(null, "ApsimNG.Resources.apsim logo32.png");
            listButtonView1 = new ListButtonView(this);
            listButtonView1.ButtonsAreToolbar = true;

            EventBox labelBox = new EventBox();
            Label    label    = new Label("NOTE: This version of APSIM writes .apsimx files as JSON, not XML. These files cannot be opened with older versions of APSIM.");

            labelBox.Add(label);
            labelBox.ModifyBg(StateType.Normal, new Gdk.Color(0xff, 0xff, 0x00)); // yellow
            vbox1.PackStart(labelBox, false, true, 0);
            vbox1.PackEnd(listButtonView1.MainWidget, true, true, 0);
            listButtonView2 = new ListButtonView(this);
            listButtonView2.ButtonsAreToolbar = true;
            vbox2.PackEnd(listButtonView2.MainWidget, true, true, 0);
            hpaned1.PositionSet = true;
            hpaned1.Child2.Hide();
            hpaned1.Child2.NoShowAll = true;
            notebook1.SetMenuLabel(vbox1, new Label(indexTabText));
            notebook2.SetMenuLabel(vbox2, new Label(indexTabText));
            hbox1.HeightRequest = 20;


            TextTag tag = new TextTag("error");

            tag.Foreground = "red";
            StatusWindow.Buffer.TagTable.Add(tag);
            tag            = new TextTag("warning");
            tag.Foreground = "brown";
            StatusWindow.Buffer.TagTable.Add(tag);
            tag            = new TextTag("normal");
            tag.Foreground = "blue";
            StatusWindow.ModifyBase(StateType.Normal, new Gdk.Color(0xff, 0xff, 0xf0));
            StatusWindow.Visible     = false;
            stopButton.Image         = new Gtk.Image(new Gdk.Pixbuf(null, "ApsimNG.Resources.MenuImages.Delete.png", 12, 12));
            stopButton.ImagePosition = PositionType.Right;
            stopButton.Image.Visible = true;
            stopButton.Clicked      += OnStopClicked;
            window1.DeleteEvent     += OnClosing;
            listButtonView1.ListView.MainWidget.ScrollEvent   += ListView_ScrollEvent;
            listButtonView2.ListView.MainWidget.ScrollEvent   += ListView_ScrollEvent;
            listButtonView1.ListView.MainWidget.KeyPressEvent += ListView_KeyPressEvent;
            listButtonView2.ListView.MainWidget.KeyPressEvent += ListView_KeyPressEvent;
            //window1.ShowAll();
            if (ProcessUtilities.CurrentOS.IsMac)
            {
                InitMac();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Constructor
        /// </summary>
        public MainView(ViewBase owner = null) : base(owner)
        {
            MasterView      = this;
            numberOfButtons = 0;
            Builder builder = BuilderFromResource("ApsimNG.Resources.Glade.MainView.glade");

            window1         = (Window)builder.GetObject("window1");
            progressBar     = (ProgressBar)builder.GetObject("progressBar");
            statusWindow    = (TextView)builder.GetObject("StatusWindow");
            stopButton      = (Button)builder.GetObject("stopButton");
            notebook1       = (Notebook)builder.GetObject("notebook1");
            notebook2       = (Notebook)builder.GetObject("notebook2");
            vbox1           = (VBox)builder.GetObject("vbox1");
            vbox2           = (VBox)builder.GetObject("vbox2");
            hpaned1         = (HPaned)builder.GetObject("hpaned1");
            hbox1           = (HBox)builder.GetObject("hbox1");
            mainWidget      = window1;
            window1.Icon    = new Gdk.Pixbuf(null, "ApsimNG.Resources.apsim logo32.png");
            listButtonView1 = new ListButtonView(this);
            listButtonView1.ButtonsAreToolbar = true;

            vbox1.PackEnd(listButtonView1.MainWidget, true, true, 0);
            listButtonView2 = new ListButtonView(this);
            listButtonView2.ButtonsAreToolbar = true;
            vbox2.PackEnd(listButtonView2.MainWidget, true, true, 0);
            hpaned1.PositionSet = true;
            hpaned1.Child2.Hide();
            hpaned1.Child2.NoShowAll = true;

            notebook1.SetMenuLabel(vbox1, LabelWithIcon(indexTabText, "go-home"));
            notebook2.SetMenuLabel(vbox2, LabelWithIcon(indexTabText, "go-home"));

            notebook1.SwitchPage += OnChangeTab;
            notebook2.SwitchPage += OnChangeTab;

            notebook1.GetTabLabel(notebook1.Children[0]).Name = "selected-tab";

            hbox1.HeightRequest = 20;

            TextTag tag = new TextTag("error");

            // Make errors orange-ish in dark mode.
            if (Utility.Configuration.Settings.DarkTheme)
            {
                tag.ForegroundGdk = Utility.Colour.ToGdk(ColourUtilities.ChooseColour(1));
            }
            else
            {
                tag.Foreground = "red";
            }
            statusWindow.Buffer.TagTable.Add(tag);
            tag = new TextTag("warning");
            // Make warnings yellow in dark mode.
            if (Utility.Configuration.Settings.DarkTheme)
            {
                tag.ForegroundGdk = Utility.Colour.ToGdk(ColourUtilities.ChooseColour(7));
            }
            else
            {
                tag.Foreground = "brown";
            }
            statusWindow.Buffer.TagTable.Add(tag);
            tag                      = new TextTag("normal");
            tag.Foreground           = "blue";
            statusWindow.Visible     = false;
            stopButton.Image         = new Gtk.Image(new Gdk.Pixbuf(null, "ApsimNG.Resources.MenuImages.Delete.png", 12, 12));
            stopButton.ImagePosition = PositionType.Right;
            stopButton.Image.Visible = true;
            stopButton.Clicked      += OnStopClicked;
            window1.DeleteEvent     += OnClosing;

            // If font is null, or font family is null, or font size is 0, fallback
            // to the default font (on windows only).
            Pango.FontDescription f = null;
            if (!string.IsNullOrEmpty(Utility.Configuration.Settings.FontName))
            {
                f = Pango.FontDescription.FromString(Utility.Configuration.Settings.FontName);
            }
            if (ProcessUtilities.CurrentOS.IsWindows && (string.IsNullOrEmpty(Utility.Configuration.Settings.FontName) ||
                                                         f.Family == null ||
                                                         f.Size == 0))
            {
                // Default font on Windows is Segoe UI. Will fallback to sans if unavailable.
                Utility.Configuration.Settings.FontName = Pango.FontDescription.FromString("Segoe UI 11").ToString();
            }

            // Can't set font until widgets are initialised.
            if (!string.IsNullOrEmpty(Utility.Configuration.Settings.FontName))
            {
                Pango.FontDescription font = Pango.FontDescription.FromString(Utility.Configuration.Settings.FontName);
                ChangeFont(font);
            }

            //window1.ShowAll();
            if (ProcessUtilities.CurrentOS.IsMac)
            {
                InitMac();
                //Utility.Configuration.Settings.DarkTheme = Utility.MacUtilities.DarkThemeEnabled();
            }

            if (!ProcessUtilities.CurrentOS.IsLinux)
            {
                RefreshTheme();
            }

#if NETCOREAPP
            LoadStylesheets();
#endif
        }
Esempio n. 3
0
        /// <summary>
        /// Constructor
        /// </summary>
        public MainView(ViewBase owner = null) : base(owner)
        {
            MasterView      = this;
            numberOfButtons = 0;
            Builder builder = BuilderFromResource("ApsimNG.Resources.Glade.MainView.glade");

            window1         = (Window)builder.GetObject("window1");
            progressBar     = (ProgressBar)builder.GetObject("progressBar");
            statusWindow    = (TextView)builder.GetObject("StatusWindow");
            stopButton      = (Button)builder.GetObject("stopButton");
            notebook1       = (Notebook)builder.GetObject("notebook1");
            notebook2       = (Notebook)builder.GetObject("notebook2");
            vbox1           = (VBox)builder.GetObject("vbox1");
            vbox2           = (VBox)builder.GetObject("vbox2");
            hpaned1         = (HPaned)builder.GetObject("hpaned1");
            hbox1           = (HBox)builder.GetObject("hbox1");
            mainWidget      = window1;
            window1.Icon    = new Gdk.Pixbuf(null, "ApsimNG.Resources.apsim logo32.png");
            listButtonView1 = new ListButtonView(this);
            listButtonView1.ButtonsAreToolbar = true;

            vbox1.PackEnd(listButtonView1.MainWidget, true, true, 0);
            listButtonView2 = new ListButtonView(this);
            listButtonView2.ButtonsAreToolbar = true;
            vbox2.PackEnd(listButtonView2.MainWidget, true, true, 0);
            hpaned1.PositionSet = true;
            hpaned1.Child2.Hide();
            hpaned1.Child2.NoShowAll = true;

            notebook1.SetMenuLabel(vbox1, LabelWithIcon(indexTabText, "go-home"));
            notebook2.SetMenuLabel(vbox2, LabelWithIcon(indexTabText, "go-home"));
            hbox1.HeightRequest = 20;

            TextTag tag = new TextTag("error");

            tag.Foreground = "red";
            statusWindow.Buffer.TagTable.Add(tag);
            tag            = new TextTag("warning");
            tag.Foreground = "brown";
            statusWindow.Buffer.TagTable.Add(tag);
            tag                      = new TextTag("normal");
            tag.Foreground           = "blue";
            statusWindow.Visible     = false;
            stopButton.Image         = new Gtk.Image(new Gdk.Pixbuf(null, "ApsimNG.Resources.MenuImages.Delete.png", 12, 12));
            stopButton.ImagePosition = PositionType.Right;
            stopButton.Image.Visible = true;
            stopButton.Clicked      += OnStopClicked;
            window1.DeleteEvent     += OnClosing;

            if (ProcessUtilities.CurrentOS.IsWindows && Utility.Configuration.Settings.Font == null)
            {
                // Default font on Windows is Segoe UI. Will fallback to sans if unavailable.
                Utility.Configuration.Settings.Font = Pango.FontDescription.FromString("Segoe UI 11");
            }

            // Can't set font until widgets are initialised.
            if (Utility.Configuration.Settings.Font != null)
            {
                ChangeFont(Utility.Configuration.Settings.Font);
            }

            //window1.ShowAll();
            if (ProcessUtilities.CurrentOS.IsMac)
            {
                InitMac();
                //Utility.Configuration.Settings.DarkTheme = Utility.MacUtilities.DarkThemeEnabled();
            }

            if (!ProcessUtilities.CurrentOS.IsLinux)
            {
                RefreshTheme();
            }
        }