void HandleOnItemSelected (object sender, SettingCollection sc)
		{
			_current_sc = sc;
			foreach(Widget w in vbox3.AllChildren) {
				vbox3.Remove (w);
				w.Dispose();
			}

			Label title = new Label (sc.Heading + " settings");
			Pango.FontDescription tpf = new Pango.FontDescription ();
			tpf.Weight = Pango.Weight.Bold;
			title.ModifyFont (tpf);
			vbox3.Add (title);
			vbox3.Add (new HSeparator());

			for(int i = sc.Settings.Length -1;i > -1; i --)  {
				isettings_viewer v = _scf.get_control(sc.Settings[i].Type);
				v.set_setting(sc.Settings[i]);
				vbox3.Add((Widget)v);
				vbox3.Add (new HSeparator ());
			}
			HSeparator h = new HSeparator();
			h.HeightRequest = 300;
			vbox3.Add (h);
			vbox3.ShowAll ();
		}
Beispiel #2
0
		public Shell(MainWindow container) : base()
		{
			this.container = container;
			WrapMode = WrapMode.Word;
			CreateTags ();

			Pango.FontDescription font_description = new Pango.FontDescription();
			font_description.Family = "Monospace";
			ModifyFont(font_description);
			
			TextIter end = Buffer.EndIter;
			Buffer.InsertWithTagsByName (ref end, "Mono C# Shell, type 'help;' for help\n\nEnter statements or expressions below.\n", "Comment");
			ShowPrompt (false);
			
			Evaluator.Init (new string [0]);
			Evaluator.SetInteractiveBaseClass (typeof (InteractiveGraphicsBase));
			Evaluator.Run ("LoadAssembly (\"System.Drawing\");");
			Evaluator.Run ("using System; using System.Linq; using System.Collections; using System.Collections.Generic; using System.Drawing;");

			if (!MainClass.Debug){
				GuiStream error_stream = new GuiStream ("Error", (x, y) => Output (x, y));
				StreamWriter gui_output = new StreamWriter (error_stream);
				gui_output.AutoFlush = true;
				Console.SetError (gui_output);

				GuiStream stdout_stream = new GuiStream ("Stdout", (x, y) => Output (x, y));
				gui_output = new StreamWriter (stdout_stream);
				gui_output.AutoFlush = true;
				Console.SetOut (gui_output);
			}
		}
		public filter_file_array_viewer ()
		{
			this.Build ();
			this.nodeview1.AppendColumn("Condition Name",new CellRendererText(), delegate(TreeViewColumn tree_column, CellRenderer cell, ITreeNode node) {
				if(node == null)return;
				((CellRendererText)cell).Text = ((filter_file_node)node).ff.Name;
			});
			this.nodeview1.AppendColumn("File",new CellRendererText(), delegate(TreeViewColumn tree_column, CellRenderer cell, ITreeNode node) {
				if(node == null)return;
				((CellRendererText)cell).Text = ((filter_file_node)node).ff.target;
			});
			this.nodeview1.NodeStore = new Gtk.NodeStore (typeof(filter_file_node));

			MenuItem new_menu = new MenuItem("New");
			new_menu.ButtonPressEvent += handle_new;
			_cm.Add(new_menu);
			MenuItem delete_menu = new MenuItem("Delete");
			delete_menu.ButtonPressEvent += handle_delete;
			_cm.Add(delete_menu);
			_cm.ShowAll ();
			this.nodeview1.ButtonPressEvent += HandleButtonPressEvent;

			this.desc_label.SetSizeRequest (315, 100);
			this.desc_label.SetAlignment (0, 0);
			this.desc_label.LineWrap = true;
			this.desc_label.SingleLineMode = false;
			this.desc_label.SetPadding (10, 2);
			Pango.FontDescription pf2 = new Pango.FontDescription ();
			//pf2.Style = Pango.Style.Italic;
			pf2.Weight = Pango.Weight.Light;
			this.desc_label.ModifyFont (pf2);
		}
 /// <summary>
 /// Initializes a new instance of the CellStyle class with default settings
 /// </summary>
 public CellStyle()
 {
     this.backColor = new Color( 0, 0, 1 );
     this.foreColor = new Color( 0, 0, 1 );
     this.font      = null;
     this.padding   = CellPadding.Empty;
 }
		public CodeSegmentPreviewWindow (TextEditor editor, bool hideCodeSegmentPreviewInformString, ISegment segment, int width, int height) : base (Gtk.WindowType.Popup)
		{
			this.HideCodeSegmentPreviewInformString = hideCodeSegmentPreviewInformString;
			this.editor = editor;
			this.AppPaintable = true;
			layout = PangoUtil.CreateLayout (this);
			informLayout = PangoUtil.CreateLayout (this);
			informLayout.SetText (CodeSegmentPreviewInformString);
			
			fontDescription = Pango.FontDescription.FromString (editor.Options.FontName);
			fontDescription.Size = (int)(fontDescription.Size * 0.8f);
			layout.FontDescription = fontDescription;
			layout.Ellipsize = Pango.EllipsizeMode.End;
			// setting a max size for the segment (40 lines should be enough), 
			// no need to markup thousands of lines for a preview window
			int startLine = editor.Document.OffsetToLineNumber (segment.Offset);
			int endLine = editor.Document.OffsetToLineNumber (segment.EndOffset);
			const int maxLines = 40;
			bool pushedLineLimit = endLine - startLine > maxLines;
			if (pushedLineLimit)
				segment = new Segment (segment.Offset, editor.Document.GetLine (startLine + maxLines).Offset - segment.Offset);
			layout.Ellipsize = Pango.EllipsizeMode.End;
			layout.SetMarkup (editor.Document.SyntaxMode.GetMarkup (editor.Document,
			                                                        editor.Options,
			                                                        editor.ColorStyle,
			                                                        segment.Offset,
			                                                        segment.Length,
			                                                        true) + (pushedLineLimit ? Environment.NewLine + "..." : ""));
			CalculateSize ();
		}
 /// <summary>
 /// Initializes a new instance of the RowStyle class with default settings
 /// </summary>
 public RowStyle()
 {
     this.backColor = Color.Empty;
     this.foreColor = Color.Empty;
     this.font = null;
     this.alignment = RowAlignment.Center;
 }
 private void SetFonts()
 {
     Pango.FontDescription desc = new Pango.FontDescription();
     desc.Family = "Sans";
     desc.Size = (int)(20 * Pango.Scale.PangoScale);
     desc.Weight = Pango.Weight.Normal;
     label1.ModifyFont(desc);
 }
		public MessageBubbleCache (TextEditor editor)
		{
			this.editor = editor;
			errorPixbuf = ImageService.GetPixbuf (MonoDevelop.Ide.Gui.Stock.Error, Gtk.IconSize.Menu);
			warningPixbuf = ImageService.GetPixbuf (MonoDevelop.Ide.Gui.Stock.Warning, Gtk.IconSize.Menu);
			
			editor.EditorOptionsChanged += HandleEditorEditorOptionsChanged;
			fontDescription = FontService.GetFontDescription ("MessageBubbles");
		}
		protected override void OnDestroyed ()
		{
			isDisposed = true;
			DisposeLayout ();
			if (font != null) {
				font.Dispose ();
				font = null;
			}
			base.OnDestroyed ();
		}
Beispiel #10
0
		void HandleCustomOutputPadFontChanged (object sender, EventArgs e)
		{
			if (customFont != null) {
				customFont.Dispose ();
				customFont = null;
			}

			customFont = Pango.FontDescription.FromString (IdeApp.Preferences.CustomOutputPadFont);

			view.SetFont (customFont);
		}
Beispiel #11
0
        public TypeView(MainWindow container)
            : base()
        {
            WrapMode = Gtk.WrapMode.None;
            CreateTags ();

            Pango.FontDescription font_description = new Pango.FontDescription();
            font_description.Family = "Monospace";
            ModifyFont(font_description);
            this.container = container;
        }
		public MessageBubbleCache (TextEditor editor)
		{
			this.editor = editor;
			errorPixbuf = ImageService.GetPixbuf ("md-bubble-error", Gtk.IconSize.Menu);
			warningPixbuf = ImageService.GetPixbuf ("md-bubble-warning", Gtk.IconSize.Menu);
			
			editor.EditorOptionsChanged += HandleEditorEditorOptionsChanged;
			editor.LeaveNotifyEvent += HandleLeaveNotifyEvent;
			editor.MotionNotifyEvent += HandleMotionNotifyEvent;
			editor.TextArea.BeginHover += HandleBeginHover;
			fontDescription = FontService.GetFontDescription ("MessageBubbles");
		}
Beispiel #13
0
		public void Initialize (IPadWindow container)
		{
			customFont = Pango.FontDescription.FromString (IdeApp.Preferences.CustomOutputPadFont);

			view = new ConsoleView ();
			view.ConsoleInput += OnViewConsoleInput;
			view.SetFont (customFont);
			view.ShadowType = Gtk.ShadowType.None;
			view.ShowAll ();

			IdeApp.Preferences.CustomOutputPadFontChanged += HandleCustomOutputPadFontChanged;
		}
		public void Dispose ()
		{
			editor.EditorOptionsChanged -= HandleEditorEditorOptionsChanged;
			if (textWidthDictionary != null) {
				foreach (var l in textWidthDictionary.Values) {
					l.Layout.Dispose ();
				}
			}
			if (fontDescription != null) {
				fontDescription.Dispose ();
				fontDescription = null;
			}
		}
		public int_settings_viewer ()
		{
			this.Build ();
			this.desc_label.SetSizeRequest (315, 100);
			this.desc_label.SetAlignment (0, 0);
			this.desc_label.LineWrap = true;
			this.desc_label.SingleLineMode = false;
			this.desc_label.SetPadding (10, 2);
			Pango.FontDescription pf2 = new Pango.FontDescription ();
			//pf2.Style = Pango.Style.Italic;
			pf2.Weight = Pango.Weight.Light;
			this.desc_label.ModifyFont (pf2);
		}
		public MessageBubbleCache (MonoTextEditor editor)
		{
			this.editor = editor;
			
			editor.EditorOptionsChanged += HandleEditorEditorOptionsChanged;
			editor.TextArea.LeaveNotifyEvent += HandleLeaveNotifyEvent;
			editor.TextArea.MotionNotifyEvent += HandleMotionNotifyEvent;
			editor.TextArea.BeginHover += HandleBeginHover;
			editor.VAdjustment.ValueChanged += HandleValueChanged;
			editor.HAdjustment.ValueChanged += HandleValueChanged;
			fontDescription = FontService.GetFontDescription ("Pad");
			tooltipFontDescription = FontService.GetFontDescription ("Pad").CopyModified (weight: Pango.Weight.Bold);
			errorCountFontDescription = FontService.GetFontDescription ("Pad").CopyModified (weight: Pango.Weight.Bold);
		}
		public MessageBubbleCache (MonoTextEditor editor)
		{
			this.editor = editor;
			errorPixbuf = Xwt.Drawing.Image.FromResource ("gutter-error-15.png");
			warningPixbuf = Xwt.Drawing.Image.FromResource ("gutter-warning-15.png");
			
			editor.EditorOptionsChanged += HandleEditorEditorOptionsChanged;
			editor.TextArea.LeaveNotifyEvent += HandleLeaveNotifyEvent;
			editor.TextArea.MotionNotifyEvent += HandleMotionNotifyEvent;
			editor.TextArea.BeginHover += HandleBeginHover;
			editor.VAdjustment.ValueChanged += HandleValueChanged;
			editor.HAdjustment.ValueChanged += HandleValueChanged;
			fontDescription = FontService.GetFontDescription ("Pad");
			tooltipFontDescription = FontService.GetFontDescription ("Pad").CopyModified (weight: Pango.Weight.Bold);
			errorCountFontDescription = FontService.GetFontDescription ("Pad").CopyModified (weight: Pango.Weight.Bold);
		}
		public MessageBubbleCache (TextEditor editor)
		{
			this.editor = editor;
			errorPixbuf = Xwt.Drawing.Image.FromResource ("gutter-error-light-15.png");
			warningPixbuf = Xwt.Drawing.Image.FromResource ("gutter-warning-light-15.png");
			
			editor.EditorOptionsChanged += HandleEditorEditorOptionsChanged;
			editor.TextArea.LeaveNotifyEvent += HandleLeaveNotifyEvent;
			editor.TextArea.MotionNotifyEvent += HandleMotionNotifyEvent;
			editor.TextArea.BeginHover += HandleBeginHover;
			editor.VAdjustment.ValueChanged += HandleValueChanged;
			editor.HAdjustment.ValueChanged += HandleValueChanged;
			fontDescription = FontService.GetFontDescription ("MessageBubbles");
			tooltipFontDescription = FontService.GetFontDescription ("MessageBubbleTooltip");
			errorCountFontDescription = FontService.GetFontDescription ("MessageBubbleCounter");
		}
Beispiel #19
0
        public MoreMenu(FillIconViewDelegate fillIconView)
        {
            // Move all this to a new class, derived from Gtk.Menu

            this.ModifyBg(StateType.Normal, new Gdk.Color(255, 255, 255));

            Pango.FontDescription font = new Pango.FontDescription();
            //font.Family = "Arial";
            font.AbsoluteSize = 15 * Pango.Scale.PangoScale;

            MenuItem im = new MenuItem("Items");
            foreach(Widget w in im.AllChildren)
            {
                w.ModifyFg(StateType.Normal, new Gdk.Color(0, 0, 0));
                w.ModifyFont(font);
            }
            im.Activated += delegate(object sender, EventArgs e)
            {
                fillIconView("items");
            };
            this.Append(im);

            im = new MenuItem("Basic shapes");
            foreach(Widget w in im.AllChildren)
            {
                w.ModifyFg(StateType.Normal, new Gdk.Color(0, 0, 0));
                w.ModifyFont(font);
            }
            im.Activated += delegate(object sender, EventArgs e)
            {
                fillIconView("basic-shapes");
            };
            this.Append(im);

            im = new MenuItem("Custom");
            foreach(Widget w in im.AllChildren)
            {
                w.ModifyFg(StateType.Normal, new Gdk.Color(0, 0, 0));
                w.ModifyFont(font);
            }
            im.Activated += delegate(object sender, EventArgs e)
            {
                fillIconView("custom");
            };
            this.Append(im);
        }
        public StatusPanel(WizardDialog wizard)
        {
            smallFont  = Style.FontDescription;
            smallFont.Size = (int) (smallFont.Size * 0.75);
            //			normalFont = Style.FontDescription;
            boldFont   = Style.FontDescription;
            boldFont.Weight = Pango.Weight.Bold;

            this.wizard = wizard;
            SetSizeRequest (198, 400);

            bitmap = Runtime.Gui.Resources.GetBitmap ("GeneralWizardBackground");

            AddEvents ((int) (Gdk.EventMask.ExposureMask));
            ExposeEvent += new Gtk.ExposeEventHandler (OnPaint);
            Realized += new EventHandler (OnRealized);
        }
Beispiel #21
0
		public void Initialize (IPadWindow container)
		{
			var fontName = IdeApp.Preferences.CustomOutputPadFont;

			if (string.IsNullOrEmpty (fontName))
				fontName = DesktopService.DefaultMonospaceFont;

			customFont = Pango.FontDescription.FromString (fontName);

			view = new ConsoleView ();
			view.ConsoleInput += OnViewConsoleInput;
			view.SetFont (customFont);
			view.ShadowType = Gtk.ShadowType.None;
			view.ShowAll ();

			IdeApp.Preferences.CustomOutputPadFontChanged += HandleCustomOutputPadFontChanged;
		}
		public boolean_setting_viewer ()
		{
			this.Build ();
			this.SetSizeRequest (100, 150);
			this.checkbutton1.SetSizeRequest (100, 40);
			this.checkbutton1.ModifyBg (StateType.Prelight);
			this.checkbutton1.Clicked += HandleClicked;
			this.desc_label.SetSizeRequest (315, 100);
			this.desc_label.SetAlignment (0, 0);
			this.desc_label.LineWrap = true;
			this.desc_label.SingleLineMode = false;
			this.desc_label.SetPadding (10, 2);
			Pango.FontDescription pf2 = new Pango.FontDescription ();
			//pf2.Style = Pango.Style.Italic;
			pf2.Weight = Pango.Weight.Light;
			this.desc_label.ModifyFont (pf2);
		}
		public CodeSegmentPreviewWindow (TextEditor editor, bool hideCodeSegmentPreviewInformString, TextSegment segment, int width, int height, bool removeIndent = true) : base (Gtk.WindowType.Popup)
		{
			this.HideCodeSegmentPreviewInformString = hideCodeSegmentPreviewInformString;
			this.Segment = segment;
			this.editor = editor;
			this.AppPaintable = true;
			this.SkipPagerHint = this.SkipTaskbarHint = true;
			this.TypeHint = WindowTypeHint.Menu;
			layout = PangoUtil.CreateLayout (this);
			informLayout = PangoUtil.CreateLayout (this);
			informLayout.SetText (CodeSegmentPreviewInformString);
			
			fontDescription = Pango.FontDescription.FromString (editor.Options.FontName);
			fontDescription.Size = (int)(fontDescription.Size * 0.8f);
			layout.FontDescription = fontDescription;
			layout.Ellipsize = Pango.EllipsizeMode.End;
			// setting a max size for the segment (40 lines should be enough), 
			// no need to markup thousands of lines for a preview window
			SetSegment (segment, removeIndent);
			CalculateSize (width);
		}
Beispiel #24
0
        public MainWindow()
            : base(Gtk.WindowType.Toplevel)
        {
            // Prepare window
            this.Build();
            this.DeactivateGui();

            // Prepare tree views
            this.tvwDocument = new GtkUtil.TableTextView( this.tvDocument, HeaderDocumentEn.Count );
            this.tvwDocument.Headers = HeaderDocumentEn;
            this.tvDocument.ButtonReleaseEvent += (sender, e) => this.OnQuestionFocusChangedTo();
            this.tvwDocument.SetEditable( 1, false );
            this.tvwAnswers  = new GtkUtil.TableTextView( this.tvAnswers, HeaderDocumentEn.Count );
            this.tvwAnswers.Headers = HeaderAnswersEn;
            this.tvwAnswers.tableChanged += this.OnAnswerChanged;

            // Prepare the txtDocument TextView
            Pango.FontDescription font = new Pango.FontDescription();
            font.Family = "Monospace";
            this.txtDocument.ModifyFont( font );
        }
Beispiel #25
0
        public InfoDialog()
        {
            this.Build ();
            this.ModifyBg(Gtk.StateType.Normal, new Gdk.Color(255, 255, 255));

            Pango.FontDescription font = new Pango.FontDescription();
            font.Family = "DIN";
            font.AbsoluteSize = 25 * Pango.Scale.PangoScale;

            this.label3.ModifyFont(font);

            System.Version ver = Assembly.GetExecutingAssembly().GetName().Version;

            this.label1.LabelProp = "<b>Version</b>\n"+
                                    "\t"+ver.ToString()+"\n"+
                                    "<b>License</b>\n"+
                                    "\tReleased under the GNU General Public License.\n"+
                                    "<b>Copyright</b>\n"+
                                    "\tCopyright © 2010\n\n"+
                                    "The default components are from the MeeGo Project\n" +
                                    "\t\t\t<big><u>http://meego.com</u></big> ";
        }
		void DisposeFont ()
		{
			if (font != null) {
				font.Dispose ();
				font = null;
			}

			if (gutterFont != null) {
				gutterFont.Dispose ();
				gutterFont = null;
			}
		}
Beispiel #27
0
 public static void SetFont(this Gtk.Widget widget, Pango.FontDescription font)
 {
     widget.OverrideFont(font);
 }
 public void SetFont(Pango.FontDescription font)
 {
     textView.ModifyFont(font);
 }
Beispiel #29
0
 internal void SetCustomFont(Pango.FontDescription desc)
 {
     textRender.FontDesc = desc;
 }
Beispiel #30
0
        private void DrawString(PageText pt, Cairo.Context g, Cairo.Rectangle r)
        {
            StyleInfo si = pt.SI;
            string    s  = pt.Text;

            g.Save();

            layout = Pango.CairoHelper.CreateLayout(g);

//            Font drawFont = null;
//            StringFormat drawFormat = null;
//            Brush drawBrush = null;


            // STYLE
//                System.Drawing.FontStyle fs = 0;
//                if (si.FontStyle == FontStyleEnum.Italic)
//                    fs |= System.Drawing.FontStyle.Italic;
            //Pango fonts are scaled to 72dpi, Windows fonts uses 96dpi
            float fontsize = (si.FontSize * 72 / 96);
            var   font     = Pango.FontDescription.FromString(string.Format("{0} {1}", si.GetFontFamily().Name,
                                                                            fontsize * PixelsX(1)));

            if (si.FontStyle == FontStyleEnum.Italic)
            {
                font.Style = Pango.Style.Italic;
            }
//
//                switch (si.TextDecoration)
//                {
//                    case TextDecorationEnum.Underline:
//                        fs |= System.Drawing.FontStyle.Underline;
//                        break;
//                    case TextDecorationEnum.LineThrough:
//                        fs |= System.Drawing.FontStyle.Strikeout;
//                        break;
//                    case TextDecorationEnum.Overline:
//                    case TextDecorationEnum.None:
//                        break;
//                }


            // WEIGHT
//                switch (si.FontWeight)
//                {
//                    case FontWeightEnum.Bold:
//                    case FontWeightEnum.Bolder:
//                    case FontWeightEnum.W500:
//                    case FontWeightEnum.W600:
//                    case FontWeightEnum.W700:
//                    case FontWeightEnum.W800:
//                    case FontWeightEnum.W900:
//                        fs |= System.Drawing.FontStyle.Bold;
//                        break;
//                    default:
//                        break;
//                }
//                try
//                {
//                    drawFont = new Font(si.GetFontFamily(), si.FontSize, fs);   // si.FontSize already in points
//                }
//                catch (ArgumentException)
//                {
//                    drawFont = new Font("Arial", si.FontSize, fs);   // if this fails we'll let the error pass thru
//                }
            //font.AbsoluteSize = (int)(PixelsX (si.FontSize));

            switch (si.FontWeight)
            {
            case FontWeightEnum.Bold:
            case FontWeightEnum.Bolder:
            case FontWeightEnum.W500:
            case FontWeightEnum.W600:
            case FontWeightEnum.W700:
            case FontWeightEnum.W800:
            case FontWeightEnum.W900:
                font.Weight = Pango.Weight.Bold;
                break;
            }

            Pango.FontDescription oldfont = layout.FontDescription;
            layout.FontDescription = font;

            // ALIGNMENT
//                drawFormat = new StringFormat();
//                switch (si.TextAlign)
//                {
//                    case TextAlignEnum.Right:
//                        drawFormat.Alignment = StringAlignment.Far;
//                        break;
//                    case TextAlignEnum.Center:
//                        drawFormat.Alignment = StringAlignment.Center;
//                        break;
//                    case TextAlignEnum.Left:
//                    default:
//                        drawFormat.Alignment = StringAlignment.Near;
//                        break;
//                }

            switch (si.TextAlign)
            {
            case TextAlignEnum.Right:
                layout.Alignment = Pango.Alignment.Right;
                break;

            case TextAlignEnum.Center:
                layout.Alignment = Pango.Alignment.Center;
                break;

            case TextAlignEnum.Left:
            default:
                layout.Alignment = Pango.Alignment.Left;
                break;
            }

            layout.Width = Pango.Units.FromPixels((int)(r.Width - si.PaddingLeft - si.PaddingRight - 2));
//				layout.Width =  (int)Pango.Units.FromPixels((int)r.Width);

            layout.SetText(s);


//                if (pt.SI.WritingMode == WritingModeEnum.tb_rl)
//                {
//                    drawFormat.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
//                    drawFormat.FormatFlags |= StringFormatFlags.DirectionVertical;
//                }
//                switch (si.VerticalAlign)
//                {
//                    case VerticalAlignEnum.Bottom:
//                        drawFormat.LineAlignment = StringAlignment.Far;
//                        break;
//                    case VerticalAlignEnum.Middle:
//                        drawFormat.LineAlignment = StringAlignment.Center;
//                        break;
//                    case VerticalAlignEnum.Top:
//                    default:
//                        drawFormat.LineAlignment = StringAlignment.Near;
//                        break;
//                }
//
            Pango.Rectangle logical;
            Pango.Rectangle ink;
            layout.GetExtents(out ink, out logical);
            double height = logical.Height / Pango.Scale.PangoScale;
            double y      = 0;

            switch (si.VerticalAlign)
            {
            case VerticalAlignEnum.Top:
                y = r.Y + si.PaddingTop;
                break;

            case VerticalAlignEnum.Middle:
                y = r.Y + (r.Height - height) / 2;
                break;

            case VerticalAlignEnum.Bottom:
                y = r.Y + (r.Height - height) - si.PaddingBottom;
                break;
            }
            // draw the background
            DrawBackground(g, r, si);

            // adjust drawing rectangle based on padding
//                Cairo.Rectangle r2 = new Cairo.Rectangle(r.X + si.PaddingLeft,
//                                               r.Y + si.PaddingTop,
//                                               r.Width - si.PaddingLeft - si.PaddingRight,
//                                               r.Height - si.PaddingTop - si.PaddingBottom);
            Cairo.Rectangle box = new Cairo.Rectangle(
                r.X + si.PaddingLeft + 1,
                y,
                r.Width,
                r.Height);

            //drawBrush = new SolidBrush(si.Color);
            g.Color = si.Color.ToCairoColor();
//                if (pt.NoClip)   // request not to clip text
//                {
//                    g.DrawString(pt.Text, drawFont, drawBrush, new PointF(r.Left, r.Top), drawFormat);
//                    //HighlightString(g, pt, new RectangleF(r.Left, r.Top, float.MaxValue, float.MaxValue),drawFont, drawFormat);
//                }
//                else
//                {
//                    g.DrawString(pt.Text, drawFont, drawBrush, r2, drawFormat);
//                    //HighlightString(g, pt, r2, drawFont, drawFormat);
//                }

            g.MoveTo(box.X, box.Y);

            Pango.CairoHelper.ShowLayout(g, layout);

            layout.FontDescription = oldfont;
            g.Restore();
        }
Beispiel #31
0
        private void InitUI()
        {
            //Init Local Vars
            GlobalApp.boScreenSize = Utils.GetScreenSize();
            uint borderWidth = 5;

            System.Drawing.Size sizeIconDashboard = new System.Drawing.Size(30, 30);
            System.Drawing.Size sizeIcon          = new System.Drawing.Size(20, 20);
            System.Drawing.Size sizeIconQuit      = new System.Drawing.Size(20, 20);
            System.Drawing.Size sizeButton        = new System.Drawing.Size(20, 20);
            String fontPosBackOfficeParent        = GlobalFramework.Settings["fontPosBackOfficeParent"];
            String fontDescriptionParentLowRes    = GlobalFramework.Settings["fontDescriptionParentLowRes"];
            String fontDescription = GlobalFramework.Settings["fontDescriptionParentLowRes"];

            //Settings
            //Redimensionar Botões do accordion para 1024
            fontDescription = fontPosBackOfficeParent;
            if (GlobalApp.boScreenSize.Height <= 800)
            {
                _widthAccordion   = 208;
                sizeIcon          = new System.Drawing.Size(20, 20);
                sizeButton        = new System.Drawing.Size(15, 15);
                sizeIconQuit      = new System.Drawing.Size(20, 20);
                sizeIconDashboard = new System.Drawing.Size(20, 20);
                _heightAccordion  = 25;
                fontDescription   = fontDescriptionParentLowRes;
            }
            //IN009296 BackOffice - Mudar a língua da aplicação
            try
            {
                string sql = string.Format("UPDATE cfg_configurationpreferenceparameter SET value = '{0}' WHERE token = 'CULTURE'", GlobalFramework.Settings["customCultureResourceDefinition"]);
                GlobalFramework.SessionXpo.ExecuteScalar(sql);
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }
            /* IN006045 */
            //_clockFormat = GlobalFramework.Settings["dateTimeFormatStatusBar"];
            _clockFormat = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "backoffice_datetime_format_status_bar");

            string fontBackOfficeStatusBar     = GlobalFramework.Settings["fontPosStatusBar"];
            string fileImageBackOfficeLogoLong = FrameworkUtils.OSSlash(GlobalFramework.Path["themes"] + @"Default\Images\logo_backoffice_long.png");
            string fileImageBackOfficeLogo     = Utils.GetThemeFileLocation(GlobalFramework.Settings["fileImageBackOfficeLogo"]);

            //Colors
            System.Drawing.Color colorBackOfficeContentBackground         = FrameworkUtils.StringToColor(GlobalFramework.Settings["colorBackOfficeContentBackground"]);
            System.Drawing.Color colorBackOfficeStatusBarBackground       = FrameworkUtils.StringToColor(GlobalFramework.Settings["colorBackOfficeStatusBarBackground"]);
            System.Drawing.Color colorBackOfficeAccordionFixBackground    = FrameworkUtils.StringToColor(GlobalFramework.Settings["colorBackOfficeAccordionFixBackground"]);
            System.Drawing.Color colorBackOfficeStatusBarFont             = FrameworkUtils.StringToColor(GlobalFramework.Settings["colorBackOfficeStatusBarFont"]);
            System.Drawing.Color colorBackOfficeStatusBarBottomBackground = FrameworkUtils.StringToColor(GlobalFramework.Settings["colorBackOfficeStatusBarBottomBackground"]);
            System.Drawing.Color colorLabelReseller = System.Drawing.Color.White;
            ModifyBg(StateType.Normal, Utils.ColorToGdkColor(colorBackOfficeContentBackground));

            //Icon
            string fileImageAppIcon = FrameworkUtils.OSSlash(string.Format("{0}{1}", GlobalFramework.Path["images"], SettingsApp.AppIcon));

            if (File.Exists(fileImageAppIcon))
            {
                Icon = Utils.ImageToPixbuf(System.Drawing.Image.FromFile(fileImageAppIcon));
            }

            //Start Pack UI

            //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
            //StatusBar
            EventBox eventBoxStatusBar = new EventBox()
            {
                HeightRequest = 38
            };

            eventBoxStatusBar.ModifyBg(StateType.Normal, Utils.ColorToGdkColor(colorBackOfficeStatusBarBackground));

            //Reseller
            _reseller      = new Label();
            _reseller.Text = string.Format(" Brough by {0}", GlobalFramework.LicenceReseller);
            _reseller.ModifyFont(Pango.FontDescription.FromString("Trebuchet MS 8 Bold"));
            _reseller.ModifyFg(StateType.Normal, Utils.ColorToGdkColor(colorBackOfficeStatusBarFont));
            _reseller.Justify = Justification.Left;

            //Logo
            try
            {
                if (GlobalFramework.LicenceReseller != "LogicPulse")
                {
                    _imageLogo = new Image(fileImageBackOfficeLogo);
                }
                else
                {
                    _imageLogo = new Image(fileImageBackOfficeLogoLong);
                }
                //_imageLogo.WidthRequest = _widthAccordion + Convert.ToInt16(borderWidth) * 3;
                //_imageLogo.SetAlignment(0.0F, 0.5F);
            }
            catch (Exception ex)
            {
                _log.Error(string.Format("InitUI(): Image [{0}] not found: {1}", fileImageBackOfficeLogo, ex.Message), ex);
            }

            //Style StatusBarFont
            Pango.FontDescription fontDescriptionStatusBar = Pango.FontDescription.FromString(fontBackOfficeStatusBar);
            String _dashboardIcon = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\BackOffice\icon_dashboard.png");
            String _updateIcon    = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\BackOffice\icon_update.png");
            String _exitIcon      = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\BackOffice\icon_pos_close_backoffice.png");
            String _backPOSIcon   = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\BackOffice\icon_pos_front_office.png");
            String _iconDashBoard = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\BackOffice\icon_other_tables.png");

            //Active Content
            _labelActiveContent = new Label()
            {
                WidthRequest = 300
            };
            _labelActiveContent.ModifyFont(fontDescriptionStatusBar);
            _labelActiveContent.ModifyFg(StateType.Normal, Utils.ColorToGdkColor(colorBackOfficeStatusBarFont));
            _labelActiveContent.SetAlignment(0.0F, 0.5F);

            //TerminalInfo : Terminal : User
            _labelTerminalInfo = new Label(string.Format("{0} : {1}", GlobalFramework.LoggedTerminal.Designation, GlobalFramework.LoggedUser.Name));
            _labelTerminalInfo.ModifyFont(fontDescriptionStatusBar);
            _labelTerminalInfo.ModifyFg(StateType.Normal, Utils.ColorToGdkColor(colorBackOfficeStatusBarFont));
            _labelTerminalInfo.SetAlignment(0.5F, 0.5F);

            //Clock
            _labelClock = new Label(FrameworkUtils.CurrentDateTime(_clockFormat));
            _labelClock.ModifyFont(fontDescriptionStatusBar);
            _labelClock.ModifyFg(StateType.Normal, Utils.ColorToGdkColor(colorBackOfficeStatusBarFont));
            _labelClock.SetAlignment(1.0F, 0.5F);

            //Pack HBox StatusBar
            _hboxStatusBar = new HBox(false, 0)
            {
                BorderWidth = borderWidth
            };
            _hboxStatusBar.PackStart(_imageLogo, false, false, 0);
            if (GlobalFramework.LicenceReseller != "LogicPulse")
            {
                _hboxStatusBar.PackStart(_reseller, false, false, 0);
            }
            _hboxStatusBar.PackStart(_labelActiveContent, false, false, 0);
            _hboxStatusBar.PackStart(_labelTerminalInfo, true, true, 0);


            //TODO:THEME
            if (GlobalApp.boScreenSize.Width < 1024 || GlobalApp.boScreenSize.Height < 768)
            {
                _labelTerminalInfo.SetAlignment(1.0F, 0.5F);
            }
            else
            {
                _hboxStatusBar.PackStart(_labelClock, false, false, 0);
            }

            if (GlobalFramework.AppUseBackOfficeMode)
            {
                EventBox eventBoxMinimize = Utils.GetMinimizeEventBox();
                eventBoxMinimize.ButtonReleaseEvent += delegate {
                    Iconify();
                };
                _hboxStatusBar.PackStart(eventBoxMinimize, false, false, 0);
                //fix.Put(eventBoxMinimize, GlobalApp.ScreenSize.Width - 27 - 10, 10);
            }

            _imageLogo.Dispose();
            _dashboardButton = new TouchButtonIconWithText("DASHBOARD_ICON", FrameworkUtils.StringToColor("168, 204, 79"), "Dashboard", fontDescription, FrameworkUtils.StringToColor("61, 61, 61"), _dashboardIcon, sizeIconDashboard, _widthAccordion, _heightAccordion, true);
            _exitButton      = new TouchButtonIconWithText("EXIT_BUTTON", FrameworkUtils.StringToColor("201, 102, 88"), resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_quit"), fontDescription, FrameworkUtils.StringToColor("255, 255, 255"), _exitIcon, sizeButton, _widthAccordion, _heightAccordion, true);
            _backPOS         = new TouchButtonIconWithText("POS", FrameworkUtils.StringToColor("168, 204, 79"), "Logicpos", fontDescription, FrameworkUtils.StringToColor("61, 61, 61"), _backPOSIcon, sizeButton, _widthAccordion, _heightAccordion, true);
            _NewVersion      = new TouchButtonIconWithText("Update_Button", FrameworkUtils.StringToColor("168, 204, 79"), resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_update_pos"), fontDescription, FrameworkUtils.StringToColor("61, 61, 61"), _updateIcon, sizeButton, _widthAccordion, _heightAccordion, true);
            _labelClock.ModifyFont(fontDescriptionStatusBar);
            //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
            //StatusBar
            //Fixed fixStatusBarBottom = new Fixed() { HasWindow = true, BorderWidth = borderWidth, HeightRequest = 38 };
            //fixStatusBarBottom.ModifyBg(StateType.Normal, Utils.ColorToGdkColor(colorBackOfficeStatusBarBottomBackground));

            //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
            //Hbox Accordion + Content
            _hboxContent = new HBox(false, (int)borderWidth)
            {
                BorderWidth = borderWidth
            };
            //_accordion = new Accordion() { WidthRequest = _widthAccordion };

            //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
            //Accordion and HouseFix
            _fixAccordion = new Fixed()
            {
                HasWindow = true, BorderWidth = borderWidth
            };
            _fixAccordion.ModifyBg(StateType.Normal, Utils.ColorToGdkColor(colorBackOfficeAccordionFixBackground));
            _fixAccordion.Put(_dashboardButton, 0, 0);
            _fixAccordion.Add(_dashboardButton);

            //Redimensionar Botões do Backoffice para 1024x768
            if (!GlobalFramework.AppUseBackOfficeMode)
            {
                if (GlobalApp.boScreenSize.Height <= 800)
                {
                    _fixAccordion.Put(_backPOS, 0, GlobalApp.boScreenSize.Height - 112);
                    _fixAccordion.Add(_backPOS);
                }
                else
                {
                    _fixAccordion.Put(_backPOS, 0, GlobalApp.boScreenSize.Height - 135);
                    _fixAccordion.Add(_backPOS);
                }
            }
            //Redimensionar Botões do Backoffice para 1024x768
            if (GlobalApp.boScreenSize.Height <= 800)
            {
                _fixAccordion.Put(_exitButton, 0, GlobalApp.boScreenSize.Height - 85);
                _fixAccordion.Add(_exitButton);
            }
            else
            {
                _fixAccordion.Put(_exitButton, 0, GlobalApp.boScreenSize.Height - 95);
                _fixAccordion.Add(_exitButton);
            }

            //TK016248 - BackOffice - Check New Version
            string appVersion = FrameworkUtils.ProductVersion.Replace("v", "");

            bool needToUpdate = false;

            GlobalFramework.ServerVersion = "1.3.0000";
            if (GlobalFramework.ServerVersion != null)
            {
                try
                {
                    string[] tmpNew    = appVersion.Split('.');
                    long     tmpNewVer = int.Parse(tmpNew[0]) * 10000000 + int.Parse(tmpNew[1]) * 10000 + int.Parse(tmpNew[2]);

                    string[] tmpOld    = GlobalFramework.ServerVersion.ToString().Split('.');
                    long     tmpOldVer = int.Parse(tmpOld[0]) * 10000000 + int.Parse(tmpOld[1]) * 10000 + int.Parse(tmpOld[2]);

                    if (tmpNewVer < tmpOldVer)
                    {
                        needToUpdate = true;
                    }
                }
                catch /*(Exception ex)*/
                {
                    //log.Error(ex.Message, ex);
                }

                if (needToUpdate)
                {
                    if (GlobalFramework.AppUseBackOfficeMode)
                    {
                        if (GlobalApp.boScreenSize.Height <= 800)
                        {
                            _labelUpdate = new Label(string.Format(string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_new_version"), GlobalFramework.ServerVersion.ToString())));
                            _labelUpdate.ModifyFont(fontDescriptionStatusBar);
                            _labelUpdate.ModifyFg(StateType.Normal, Utils.ColorToGdkColor(FrameworkUtils.StringToColor("61, 61, 61")));
                            _labelUpdate.SetAlignment(1.0F, 0.5F);
                            _fixAccordion.Put(_labelUpdate, 5, GlobalApp.boScreenSize.Height - 165);
                            _fixAccordion.Add(_labelUpdate);
                            _fixAccordion.Put(_NewVersion, 0, GlobalApp.boScreenSize.Height - 140);
                            _fixAccordion.Add(_NewVersion);
                        }
                        else
                        {
                            _labelUpdate = new Label(string.Format(string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_new_version"), GlobalFramework.ServerVersion.ToString())));
                            _labelUpdate.ModifyFont(fontDescriptionStatusBar);
                            _labelUpdate.ModifyFg(StateType.Normal, Utils.ColorToGdkColor(FrameworkUtils.StringToColor("61, 61, 61")));
                            _labelUpdate.SetAlignment(1.0F, 0.5F);
                            _fixAccordion.Put(_labelUpdate, 5, GlobalApp.boScreenSize.Height - 200);
                            _fixAccordion.Add(_labelUpdate);
                            _fixAccordion.Put(_NewVersion, 0, GlobalApp.boScreenSize.Height - 175);
                            _fixAccordion.Add(_NewVersion);
                        }
                    }
                    else
                    {
                        if (GlobalApp.boScreenSize.Height <= 800)
                        {
                            _labelUpdate = new Label(string.Format(string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_new_version"), GlobalFramework.ServerVersion.ToString())));
                            _labelUpdate.ModifyFont(fontDescriptionStatusBar);
                            _labelUpdate.ModifyFg(StateType.Normal, Utils.ColorToGdkColor(FrameworkUtils.StringToColor("61, 61, 61")));
                            _labelUpdate.SetAlignment(1.0F, 0.5F);
                            _fixAccordion.Put(_labelUpdate, 5, GlobalApp.boScreenSize.Height - 165);
                            _fixAccordion.Add(_labelUpdate);
                            _fixAccordion.Put(_NewVersion, 0, GlobalApp.boScreenSize.Height - 140);
                            _fixAccordion.Add(_NewVersion);
                        }
                        else
                        {
                            _labelUpdate = new Label(string.Format(string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_new_version"), GlobalFramework.ServerVersion.ToString())));
                            _labelUpdate.ModifyFont(fontDescriptionStatusBar);
                            _labelUpdate.ModifyFg(StateType.Normal, Utils.ColorToGdkColor(FrameworkUtils.StringToColor("61, 61, 61")));
                            _labelUpdate.SetAlignment(1.0F, 0.5F);
                            _fixAccordion.Put(_labelUpdate, 5, GlobalApp.boScreenSize.Height - 200);
                            _fixAccordion.Add(_labelUpdate);
                            _fixAccordion.Put(_NewVersion, 0, GlobalApp.boScreenSize.Height - 175);
                            _fixAccordion.Add(_NewVersion);
                        }
                    }
                }
            }
            //TK016248 End

            //Pack hboxContent
            _hboxContent.PackStart(_fixAccordion, false, false, 0);
            VBox vboxContent = new VBox(false, 0);

            eventBoxStatusBar.Add(_hboxStatusBar);

            vboxContent.PackStart(eventBoxStatusBar, false, false, 0);

            vboxContent.PackStart(_hboxContent);
            //vboxContent.PackStart(fixStatusBarBottom, false, false, 0);

            this.HeightRequest = 50;
            //Final Pack
            Add(vboxContent);

            //Clock
            StartClock();
        }
Beispiel #32
0
        private void _Load()
        {
            Trace.Call();

            // root
            string startup_commands = String.Join("\n", (string[])Frontend.UserConfig["OnStartupCommands"]);
            ((Gtk.TextView)_Glade["OnStartupCommandsTextView"]).Buffer.Text  = startup_commands;

            // Connection
            string nicknames = String.Join(" ", (string[])Frontend.UserConfig["Connection/Nicknames"]);
            ((Gtk.Entry)_Glade["ConnectionNicknamesEntry"]).Text  = nicknames;
            ((Gtk.Entry)_Glade["ConnectionUsernameEntry"]).Text  = (string)Frontend.UserConfig["Connection/Username"];
            ((Gtk.Entry)_Glade["ConnectionRealnameEntry"]).Text  = (string)Frontend.UserConfig["Connection/Realname"];
            string connect_commands = String.Join("\n", (string[])Frontend.UserConfig["Connection/OnConnectCommands"]);
            ((Gtk.TextView)_Glade["OnConnectCommandsTextView"]).Buffer.Text = connect_commands;

            string encoding = (string)Frontend.UserConfig["Connection/Encoding"];
            encoding = encoding.ToUpper();

            Gtk.ComboBox cb = (Gtk.ComboBox)_Glade["EncodingComboBox"];
            // glade might initialize it already!
            cb.Clear();
            Gtk.CellRendererText cell = new Gtk.CellRendererText();
            cb.PackStart(cell, false);
            cb.AddAttribute(cell, "text", 0);
            Gtk.ListStore store = new Gtk.ListStore(typeof(string), typeof(string));
            store.AppendValues(String.Format("<{0}>", _("System Default")), String.Empty);
            ArrayList encodingList = new ArrayList();
            ArrayList bodyNameList = new ArrayList();
            foreach (EncodingInfo encInfo in Encoding.GetEncodings()) {
                try {
                    Encoding enc = Encoding.GetEncoding(encInfo.CodePage);
                    string encodingName = enc.EncodingName.ToUpper();

                    if (!enc.IsSingleByte && enc != Encoding.UTF8) {
                        // ignore multi byte encodings except UTF-8
                        continue;
                    }

                    // filter noise and duplicates
                    if (encodingName.IndexOf("DOS") != -1 ||
                        encodingName.IndexOf("MAC") != -1 ||
                        encodingName.IndexOf("EBCDIC") != -1 ||
                        encodingName.IndexOf("ISCII") != -1 ||
                        encodingList.Contains(encodingName) ||
                        bodyNameList.Contains(enc.BodyName)) {
                        continue;
                    }
            #if LOG4NET
                    _Logger.Debug("_Load(): adding encoding: " + enc.BodyName);
            #endif
                    encodingList.Add(encodingName);
                    bodyNameList.Add(enc.BodyName);

                    encodingName = enc.EncodingName;
                    // remove all (DOS)  / (Windows) / (Mac) crap from the encoding name
                    if (enc.EncodingName.Contains(" (")) {
                        encodingName = encodingName.Substring(0, enc.EncodingName.IndexOf(" ("));
                    }
                    store.AppendValues(enc.BodyName.ToUpper() + " - " + encodingName, enc.BodyName.ToUpper());
                } catch (NotSupportedException) {
                }
            }
            cb.Model = store;
            cb.Active = 0;
            store.SetSortColumnId(0, Gtk.SortType.Ascending);
            int j = 0;
            foreach (object[] row in store) {
                string encodingName = (string) row[1];
                if (encodingName == encoding) {
                    cb.Active = j;
                    break;
                }
                j++;
            }

            // Connection - Proxy
            Gtk.ComboBox proxyTypeComboBox = ((Gtk.ComboBox)_Glade["ProxyTypeComboBox"]);
            ProxyType proxyType = (ProxyType) Enum.Parse(
                typeof(ProxyType),
                (string) Frontend.UserConfig["Connection/ProxyType"]
            );
            int i = 0;
            foreach (object[] row in  (Gtk.ListStore) proxyTypeComboBox.Model) {
                if (((ProxyType) row[0]) == proxyType) {
                    proxyTypeComboBox.Active = i;
                    break;
                }
                i++;
            }
            ((Gtk.Entry) _Glade["ProxyHostEntry"]).Text =
                (string) Frontend.UserConfig["Connection/ProxyHostname"];
            int proxyPort = (int) Frontend.UserConfig["Connection/ProxyPort"];
            if (proxyPort == -1) {
                proxyPort = 0;
            }
            ((Gtk.SpinButton) _Glade["ProxyPortSpinButton"]).Value = proxyPort;
            ((Gtk.Entry) _Glade["ProxyUsernameEntry"]).Text =
                (string) Frontend.UserConfig["Connection/ProxyUsername"];
            ((Gtk.Entry) _Glade["ProxyPasswordEntry"]).Text =
                (string) Frontend.UserConfig["Connection/ProxyPassword"];
            CheckProxyShowPasswordCheckButton();

            // MessageBuffer
            if (Frontend.EngineVersion >= new Version("0.8.1")) {
                // feature introduced in >= 0.8.1
                Gtk.ComboBox persistencyTypeComboBox =
                    ((Gtk.ComboBox)_Glade["PersistencyTypeComboBox"]);
                try {
                    var persistencyType = (MessageBufferPersistencyType) Enum.Parse(
                        typeof(MessageBufferPersistencyType),
                        (string) Frontend.UserConfig["MessageBuffer/PersistencyType"]
                    );
                    i = 0;
                    foreach (object[] row in (Gtk.ListStore) persistencyTypeComboBox.Model) {
                        if (((MessageBufferPersistencyType) row[0]) == persistencyType) {
                            persistencyTypeComboBox.Active = i;
                            break;
                        }
                        i++;
                    }
                } catch (ArgumentException) {
                    // for forward compatibility with newer engines
                    persistencyTypeComboBox.Active = -1;
                }
                ((Gtk.SpinButton)_Glade["VolatileMaxCapacitySpinButton"]).Value =
                    (double)(int)Frontend.UserConfig["MessageBuffer/Volatile/MaxCapacity"];
                ((Gtk.SpinButton)_Glade["PersistentMaxCapacitySpinButton"]).Value =
                    (double)(int)Frontend.UserConfig["MessageBuffer/Persistent/MaxCapacity"];
            }

            // Interface
            ((Gtk.CheckButton) _Glade["ShowAdvancedSettingsCheckButton"]).Active =
                (bool) Frontend.UserConfig["Interface/ShowAdvancedSettings"];
            CheckShowAdvancedSettingsCheckButton();

            // Interface/Notebook
            ((Gtk.Entry)_Glade["TimestampFormatEntry"]).Text =
                (string)Frontend.UserConfig["Interface/Notebook/TimestampFormat"];
            ((Gtk.SpinButton)_Glade["BufferLinesSpinButton"]).Value =
                (double)(int)Frontend.UserConfig["Interface/Notebook/BufferLines"];
            ((Gtk.SpinButton)_Glade["EngineBufferLinesSpinButton"]).Value =
                (double)(int)Frontend.UserConfig["Interface/Notebook/EngineBufferLines"];
            ((Gtk.CheckButton)_Glade["StripColorsCheckButton"]).Active =
                (bool)Frontend.UserConfig["Interface/Notebook/StripColors"];
            ((Gtk.CheckButton)_Glade["StripFormattingsCheckButton"]).Active =
                (bool)Frontend.UserConfig["Interface/Notebook/StripFormattings"];
            switch ((string)Frontend.UserConfig["Interface/Notebook/TabPosition"]) {
                case "top":
                    ((Gtk.RadioButton)_Glade["TabPositionRadioButtonTop"]).Active = true;
                break;
                case "bottom":
                    ((Gtk.RadioButton)_Glade["TabPositionRadioButtonBottom"]).Active = true;
                break;
                case "left":
                    ((Gtk.RadioButton)_Glade["TabPositionRadioButtonLeft"]).Active = true;
                break;
                case "right":
                    ((Gtk.RadioButton)_Glade["TabPositionRadioButtonRight"]).Active = true;
                break;
                case "none":
                    ((Gtk.RadioButton)_Glade["TabPositionRadioButtonNone"]).Active = true;
                break;
            }
            if (Frontend.UserConfig["Interface/Notebook/AutoSwitchPersonChats"] != null) {
                ((Gtk.CheckButton) _Glade["AutoSwitchPersonChatsCheckButton"]).Active =
                    (bool) Frontend.UserConfig["Interface/Notebook/AutoSwitchPersonChats"];
            }
            if (Frontend.UserConfig["Interface/Notebook/AutoSwitchGroupChats"] != null) {
                ((Gtk.CheckButton) _Glade["AutoSwitchGroupChatsCheckButton"]).Active =
                    (bool) Frontend.UserConfig["Interface/Notebook/AutoSwitchGroupChats"];
            }

            // Interface/Notebook/Channel
            switch ((string)Frontend.UserConfig["Interface/Notebook/Channel/UserListPosition"]) {
                case "left":
                    ((Gtk.RadioButton)_Glade["UserListPositionRadioButtonLeft"]).Active = true;
                break;
                case "right":
                    ((Gtk.RadioButton)_Glade["UserListPositionRadioButtonRight"]).Active = true;
                break;
                case "none":
                    ((Gtk.RadioButton)_Glade["UserListPositionRadioButtonNone"]).Active = true;
                break;
            }
            switch ((string)Frontend.UserConfig["Interface/Notebook/Channel/TopicPosition"]) {
                case "top":
                    ((Gtk.RadioButton)_Glade["TopicPositionRadioButtonTop"]).Active = true;
                break;
                case "bottom":
                    ((Gtk.RadioButton)_Glade["TopicPositionRadioButtonBottom"]).Active = true;
                break;
                case "none":
                    ((Gtk.RadioButton)_Glade["TopicPositionRadioButtonNone"]).Active = true;
                break;
            }
            ((Gtk.CheckButton) _Glade["NickColorsCheckButton"]).Active =
                (bool) Frontend.UserConfig["Interface/Notebook/Channel/NickColors"];

            // Interface/Notebook/Tab
            Gtk.ColorButton colorButton;
            string colorHexCode;

            colorButton = (Gtk.ColorButton)_Glade["NoActivityColorButton"];
            colorHexCode = (string)Frontend.UserConfig["Interface/Notebook/Tab/NoActivityColor"];
            colorButton.Color = ColorConverter.GetGdkColor(colorHexCode);

            colorButton = (Gtk.ColorButton)_Glade["ActivityColorButton"];
            colorHexCode = (string)Frontend.UserConfig["Interface/Notebook/Tab/ActivityColor"];
            colorButton.Color = ColorConverter.GetGdkColor(colorHexCode);

            colorButton = (Gtk.ColorButton)_Glade["ModeColorButton"];
            colorHexCode = (string)Frontend.UserConfig["Interface/Notebook/Tab/EventColor"];
            colorButton.Color = ColorConverter.GetGdkColor(colorHexCode);

            colorButton = (Gtk.ColorButton)_Glade["HighlightColorButton"];
            colorHexCode = (string)Frontend.UserConfig["Interface/Notebook/Tab/HighlightColor"];
            colorButton.Color = ColorConverter.GetGdkColor(colorHexCode);

            // Interface/Chat
            colorButton = (Gtk.ColorButton)_Glade["ForegroundColorButton"];
            colorHexCode = (string)Frontend.UserConfig["Interface/Chat/ForegroundColor"];
            if (String.IsNullOrEmpty(colorHexCode)) {
                ((Gtk.CheckButton)_Glade["OverrideForegroundColorCheckButton"]).Active = false;
            } else {
                ((Gtk.CheckButton)_Glade["OverrideForegroundColorCheckButton"]).Active = true;
                colorButton.Color = ColorConverter.GetGdkColor(colorHexCode);
            }

            colorButton = (Gtk.ColorButton)_Glade["BackgroundColorButton"];
            colorHexCode = (string)Frontend.UserConfig["Interface/Chat/BackgroundColor"];
            if (String.IsNullOrEmpty(colorHexCode)) {
                ((Gtk.CheckButton)_Glade["OverrideBackgroundColorCheckButton"]).Active = false;
            } else {
                ((Gtk.CheckButton)_Glade["OverrideBackgroundColorCheckButton"]).Active = true;
                colorButton.Color = ColorConverter.GetGdkColor(colorHexCode);
            }

            Gtk.FontButton fontButton = (Gtk.FontButton)_Glade["FontButton"];
            string fontFamily = (string)Frontend.UserConfig["Interface/Chat/FontFamily"];
            string fontStyle = (string)Frontend.UserConfig["Interface/Chat/FontStyle"];
            int fontSize = 0;
            if (Frontend.UserConfig["Interface/Chat/FontSize"] != null) {
                fontSize = (int) Frontend.UserConfig["Interface/Chat/FontSize"];
            }
            if (String.IsNullOrEmpty(fontFamily) &&
                String.IsNullOrEmpty(fontStyle) &&
                fontSize == 0) {
                ((Gtk.CheckButton)_Glade["OverrideFontCheckButton"]).Active = false;
            } else {
                ((Gtk.CheckButton)_Glade["OverrideFontCheckButton"]).Active = true;
                Pango.FontDescription fontDescription = new Pango.FontDescription();
                fontDescription.Family = fontFamily;
                string frontWeigth = null;
                if (fontStyle.Contains(" ")) {
                    int pos = fontStyle.IndexOf(" ");
                    frontWeigth = fontStyle.Substring(0, pos);
                    fontStyle = fontStyle.Substring(pos + 1);
                }
                fontDescription.Style = (Pango.Style) Enum.Parse(typeof(Pango.Style), fontStyle);
                if (frontWeigth != null) {
                    fontDescription.Weight = (Pango.Weight) Enum.Parse(typeof(Pango.Weight), frontWeigth);
                }
                fontDescription.Size = fontSize * 1024;
                fontButton.FontName = fontDescription.ToString();
            }

            Gtk.ComboBox wrapModeComboBox = ((Gtk.ComboBox)_Glade["WrapModeComboBox"]);
            Gtk.WrapMode wrapMode = (Gtk.WrapMode) Enum.Parse(
                typeof(Gtk.WrapMode),
                (string) Frontend.UserConfig["Interface/Chat/WrapMode"]
            );
            if (wrapMode == Gtk.WrapMode.Word) {
                wrapMode = Gtk.WrapMode.WordChar;
            }
            i = 0;
            foreach (object[] row in  (Gtk.ListStore) wrapModeComboBox.Model) {
                if (((Gtk.WrapMode) row[0]) == wrapMode) {
                    wrapModeComboBox.Active = i;
                    break;
                }
                i++;
            }

            // Interface/Entry
            ((Gtk.Entry)_Glade["CompletionCharacterEntry"]).Text =
                (string)Frontend.UserConfig["Interface/Entry/CompletionCharacter"];
            ((Gtk.Entry)_Glade["CommandCharacterEntry"]).Text =
                (string)Frontend.UserConfig["Interface/Entry/CommandCharacter"];
            ((Gtk.CheckButton)_Glade["BashStyleCompletionCheckButton"]).Active =
                (bool)Frontend.UserConfig["Interface/Entry/BashStyleCompletion"];
            ((Gtk.SpinButton)_Glade["CommandHistorySizeSpinButton"]).Value =
                (double)(int)Frontend.UserConfig["Interface/Entry/CommandHistorySize"];

            var highlight_words =
                (string[]) Frontend.UserConfig["Interface/Chat/HighlightWords"];
            // backwards compatibility with 0.7.x servers
            if (highlight_words == null) {
                highlight_words = new string[] {};
            }
            ((Gtk.TextView)_Glade["HighlightWordsTextView"]).Buffer.Text  =
                    String.Join("\n", highlight_words);

            ((Gtk.CheckButton)_Glade["BeepOnHighlightCheckButton"]).Active =
                (bool)Frontend.UserConfig["Sound/BeepOnHighlight"];

            // Interface/Notification
            string modeStr = (string) Frontend.UserConfig["Interface/Notification/NotificationAreaIconMode"];
            NotificationAreaIconMode mode = (NotificationAreaIconMode) Enum.Parse(
                typeof(NotificationAreaIconMode),
                modeStr
            );
            switch (mode) {
                case NotificationAreaIconMode.Never:
                    ((Gtk.CheckButton) _Glade["NotificationAreaIconCheckButton"]).Active = false;
                    ((Gtk.RadioButton) _Glade["NotificationAreaIconRadioButtonClosed"]).Active = true;

                    // the toggle event is not raised as the checkbox is already unchecked by default
                    // thus we have to disable the radio buttons by hand
                    ((Gtk.RadioButton) _Glade["NotificationAreaIconRadioButtonAlways"]).Sensitive = false;
                    ((Gtk.RadioButton) _Glade["NotificationAreaIconRadioButtonMinimized"]).Sensitive = false;
                    ((Gtk.RadioButton) _Glade["NotificationAreaIconRadioButtonClosed"]).Sensitive = false;
                    break;
                case NotificationAreaIconMode.Always:
                    ((Gtk.CheckButton) _Glade["NotificationAreaIconCheckButton"]).Active = true;
                    ((Gtk.RadioButton) _Glade["NotificationAreaIconRadioButtonAlways"]).Active = true;
                    break;
                case NotificationAreaIconMode.Minimized:
                    // can't support this for now, see: http://projects.qnetp.net/issues/show/158
                    goto case NotificationAreaIconMode.Never;
                    /*
                    ((Gtk.CheckButton) _Glade["NotificationAreaIconCheckButton"]).Active = true;
                    ((Gtk.RadioButton) _Glade["NotificationAreaIconRadioButtonMinimized"]).Active = true;
                    break;
                    */
                case NotificationAreaIconMode.Closed:
                    ((Gtk.CheckButton) _Glade["NotificationAreaIconCheckButton"]).Active = true;
                    ((Gtk.RadioButton) _Glade["NotificationAreaIconRadioButtonClosed"]).Active = true;
                    break;
            }
            ((Gtk.CheckButton) _Glade["MessagingMenuCheckButton"]).Active =
                (bool) Frontend.UserConfig["Interface/Notification/MessagingMenuEnabled"];
            ((Gtk.CheckButton) _Glade["NotificationPopupsCheckButton"]).Active =
                (bool) Frontend.UserConfig["Interface/Notification/PopupsEnabled"];

            // Filters
            _FilterListWidget.InitProtocols(Frontend.Session.GetSupportedProtocols());
            _FilterListWidget.Load();

            // Servers
            _ServerListView.Load();

            // Logging
            ((Gtk.Button) _Glade["LoggingOpenButton"]).Visible = false;
            if (Frontend.UserConfig["Logging/Enabled"] != null) {
                ((Gtk.CheckButton) _Glade["LoggingEnabledCheckButton"]).Active =
                    (bool) Frontend.UserConfig["Logging/Enabled"];
                if (Frontend.IsLocalEngine) {
                    ((Gtk.Button) _Glade["LoggingOpenButton"]).Visible = true;
                }
            }
            if (Frontend.UserConfig["Logging/LogFilteredMessages"] != null) {
                ((Gtk.CheckButton) _Glade["LoggingLogFilteredMessagesCheckButton"]).Active =
                    (bool) Frontend.UserConfig["Logging/LogFilteredMessages"];
            }

            ((Gtk.Button)_Glade["ApplyButton"]).Sensitive = false;
        }
Beispiel #33
0
        public static Rectangle DrawText(this Context g, PointD p, string family, Cairo.FontSlant slant, Cairo.FontWeight weight, double size, Cairo.Color color, double width, string text)
        {
            g.Save ();
            g.MoveTo (p.X, p.Y);
            g.Color = color;
            Pango.Layout layout = Pango.CairoHelper.CreateLayout (g);
            layout.Wrap = Pango.WrapMode.Char;
            layout.Width = (int)(width * Pango.Scale.PangoScale);
            Pango.FontDescription fd = new Pango.FontDescription ();
            fd.Family = family;

            fd.Style = CairoToPangoSlant (slant);
            fd.Weight = CairoToPangoWeight (weight);

            fd.AbsoluteSize = size * Pango.Scale.PangoScale;
            layout.FontDescription = fd;

            layout.Spacing = 0;
            layout.Alignment = Pango.Alignment.Left;
            layout.SetText (text);

            Pango.Rectangle unused = Pango.Rectangle.Zero;
            Pango.Rectangle te = Pango.Rectangle.Zero;
            layout.GetExtents (out unused, out te);
            Pango.CairoHelper.ShowLayout(g, layout);

            layout.GetExtents (out unused, out te);

            (layout as IDisposable).Dispose();

            g.Restore ();

            return new Rectangle( p.X + unused.X / Pango.Scale.PangoScale, p.Y + unused.Y / Pango.Scale.PangoScale, (unused.Width / Pango.Scale.PangoScale) , (unused.Height/ Pango.Scale.PangoScale) );
        }
Beispiel #34
0
        public void DrawText(int x, int y, String text, TextAlign align)
        {
            Pango.FontDescription fd = Pango.FontDescription.FromString(FontFamily);
            fd.Size = Pango.Units.FromPixels(FontSize);
            if ((FontStyle & FontStyle.Bold) != 0)
            {
                fd.Weight = Pango.Weight.Bold;
            }
            if ((FontStyle & FontStyle.Italic) != 0)
            {
                fd.Style = Pango.Style.Italic;
            }

            Pango.Font        font    = parent.PangoContext.LoadFont(fd);
            Pango.Language    lang    = Pango.Language.FromString("en");
            Pango.FontMetrics metrics = font.GetMetrics(lang);
            int estWidth = text.Length * metrics.ApproximateCharWidth * 3 / 2;

            Pango.Context pango  = parent.PangoContext;
            Pango.Layout  layout = new Pango.Layout(pango)
            {
                Width           = estWidth,
                Wrap            = Pango.WrapMode.Word, Alignment = Pango.Alignment.Left,
                FontDescription = fd
            };
            int    color  = this.Color;
            ushort cRed   = (ushort)((color >> 16) & 0xFF);
            ushort cGreen = (ushort)((color >> 8) & 0xFF);
            ushort cBlue  = (ushort)(color & 0xFF);

            layout.Attributes = new Pango.AttrList();
            layout.Attributes.Insert(new Pango.AttrForeground(cRed, cGreen, cBlue));
            layout.SetText(text);

            double x0;
            double y0;
            double scale = 1.0 / Pango.Scale.PangoScale;

            Pango.Rectangle dummy;
            Pango.Rectangle extents;
            layout.GetExtents(out dummy, out extents);
            switch ((TextAlign)((int)align & 7))
            {
            case TextAlign.Right:
                x0 = x - scale * extents.Width;
                break;

            case TextAlign.Center:
                x0 = x - 0.5 * scale * extents.Width;
                break;

            default:
                x0 = x;
                break;
            }
            switch ((TextAlign)((int)align & ~7))
            {
            case TextAlign.Top:
                y0 = y;
                break;

            case TextAlign.Bottom:
                y0 = y - scale * (metrics.Ascent + metrics.Descent);
                break;

            case TextAlign.VCenter:
                y0 = y - 0.5 * scale * metrics.Ascent;
                break;

            default:
                y0 = y - scale * metrics.Ascent;
                break;
            }

            Matrix srcM = Context.Matrix;

            Pango.Matrix dstM;
            dstM.X0 = 0.0;
            dstM.Xx = srcM.Xx;
            dstM.Xy = srcM.Xy;
            dstM.Y0 = 0.0;
            dstM.Yx = srcM.Yx;
            dstM.Yy = srcM.Yy;
            parent.PangoContext.Matrix = dstM;
            srcM.TransformPoint(ref x0, ref y0);
            parent.GdkWindow.DrawLayout(parent.Style.TextGC(StateType.Normal),
                                        (int)(0.5 + x0), (int)(0.5 + y0), layout);
            dstM.Xx = 1.0;
            dstM.Yy = 1.0;
            parent.PangoContext.Matrix = dstM;
        }
Beispiel #35
0
 public void ModifyLabelFont(Pango.FontDescription font)
 {
     label.ModifyFont(font);
 }
Beispiel #36
0
 public static void SetFont(this Gtk.Widget widget, Pango.FontDescription font)
 {
     widget.ModifyFont(font);
 }
Beispiel #37
0
        private void InitUI()
        {
            //Files
            string fileAppBanner = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Licence\licence.png");
            //Init
            int padding = 5;

            //Init Fonts
            Pango.FontDescription fontBig = new Pango.FontDescription();
            fontBig.Size   = 18;
            fontBig.Weight = Pango.Weight.Bold;

            //MockData
            bool   useMockData      = false;
            string mockName         = (useMockData) ? "Carlos Fernandes" : string.Empty;
            string mockCompany      = (useMockData) ? "LogicPulse" : string.Empty;
            string mockFiscalNumber = (useMockData) ? "503218820" : string.Empty;
            string mockAddress      = (useMockData) ? "Rua Capitão Salgueiro Maia, nº7, 3080-245 Figueira da Foz" : string.Empty;
            string mockPhone        = (useMockData) ? "+351 233 042 347" : string.Empty;
            string mockEmail        = (useMockData) ? "*****@*****.**" : string.Empty;

            //Init Content
            _hboxMain = new HBox(false, 0)
            {
                BorderWidth = (uint)padding
            };
            //Inner
            Image appBanner = new Image(fileAppBanner)
            {
                WidthRequest = 200
            };
            VBox vboxMain = new VBox(false, padding);

            _hboxMain.PackStart(appBanner, false, false, (uint)padding);
            _hboxMain.PackStart(vboxMain, true, true, (uint)padding);

            //Pack VBoxMain : Welcome
            Label labelWelcome = new Label(Resx.window_license_label_welcome);

            labelWelcome.SetAlignment(0.0F, 0.0F);
            labelWelcome.ModifyFont(fontBig);
            vboxMain.PackStart(labelWelcome, false, false, (uint)padding);
            //Pack VBoxMain : Info
            Label lableInfo = new Label(Resx.window_license_label_info);

            lableInfo.WidthRequest = 500;
            lableInfo.Wrap         = true;
            lableInfo.SetAlignment(0.0F, 0.0F);
            vboxMain.PackStart(lableInfo, true, true, (uint)padding);

            //Pack hboxInner
            HBox hboxInner = new HBox(false, 0);

            vboxMain.PackStart(hboxInner, false, false, 0);
            //Pack VBoxMain : HBoxInner
            VBox vboxInnerLeft  = new VBox(false, 0);
            VBox vboxInnerRight = new VBox(false, 0);

            hboxInner.PackStart(vboxInnerLeft, true, true, 0);
            hboxInner.PackStart(vboxInnerRight, false, false, (uint)padding * 2);

            //VBoxInnerLeft
            Label labelInternetRegistration = new Label(Resx.window_license_label_internet_registration);

            labelInternetRegistration.SetAlignment(0.0F, 0.0F);
            labelInternetRegistration.ModifyFont(fontBig);
            vboxInnerLeft.PackStart(labelInternetRegistration, false, false, 0);

            //EntryBoxName
            _entryBoxName = new EntryBoxValidation(this, Resx.global_name, KeyboardMode.AlfaNumeric, SettingsApp.RegexAlfaNumericExtended, true);
            _entryBoxName.EntryValidation.ModifyFont(fontBig);
            _entryBoxName.EntryValidation.Text     = mockName;
            _entryBoxName.EntryValidation.Changed += delegate { Validate(); };
            vboxInnerLeft.PackStart(_entryBoxName, false, false, 0);

            //EntryBoxCompany
            _entryBoxCompany = new EntryBoxValidation(this, Resx.global_company, KeyboardMode.AlfaNumeric, SettingsApp.RegexAlfaNumericExtended, true);
            _entryBoxCompany.EntryValidation.ModifyFont(fontBig);
            _entryBoxCompany.EntryValidation.Text     = mockCompany;
            _entryBoxCompany.EntryValidation.Changed += delegate { Validate(); };
            vboxInnerLeft.PackStart(_entryBoxCompany, false, false, 0);

            //EntryFiscalNumber
            _entryBoxFiscalNumber = new EntryBoxValidation(this, Resx.global_fiscal_number, KeyboardMode.Numeric, SettingsApp.RegexIntegerGreaterThanZero, true);
            _entryBoxFiscalNumber.EntryValidation.ModifyFont(fontBig);
            _entryBoxFiscalNumber.EntryValidation.Text     = mockFiscalNumber;
            _entryBoxFiscalNumber.EntryValidation.Changed += delegate { Validate(); };
            vboxInnerLeft.PackStart(_entryBoxFiscalNumber, false, false, 0);

            //EntryBoxAddress
            _entryBoxAddress = new EntryBoxValidation(this, Resx.global_address, KeyboardMode.AlfaNumeric, SettingsApp.RegexAlfaNumericExtended, true);
            _entryBoxAddress.EntryValidation.ModifyFont(fontBig);
            _entryBoxAddress.EntryValidation.Text     = mockAddress;
            _entryBoxAddress.EntryValidation.Changed += delegate { Validate(); };
            vboxInnerLeft.PackStart(_entryBoxAddress, false, false, 0);

            //EntryBoxEmail
            _entryBoxEmail = new EntryBoxValidation(this, Resx.global_email, KeyboardMode.AlfaNumeric, SettingsApp.RegexEmail, true);
            _entryBoxEmail.EntryValidation.ModifyFont(fontBig);
            _entryBoxEmail.EntryValidation.Text     = mockEmail;
            _entryBoxEmail.EntryValidation.Changed += delegate { Validate(); };
            vboxInnerLeft.PackStart(_entryBoxEmail, false, false, 0);

            //EntryBoxPhone
            _entryBoxPhone = new EntryBoxValidation(this, Resx.global_phone, KeyboardMode.AlfaNumeric, SettingsApp.RegexAlfaNumericExtended, true);
            _entryBoxPhone.EntryValidation.ModifyFont(fontBig);
            _entryBoxPhone.EntryValidation.Text     = mockPhone;
            _entryBoxPhone.EntryValidation.Changed += delegate { Validate(); };
            vboxInnerLeft.PackStart(_entryBoxPhone, false, false, 0);

            //EntryBoxHardwareId
            _entryBoxHardwareId = new EntryBoxValidation(this, Resx.global_hardware_id, KeyboardMode.None, SettingsApp.RegexAlfaNumericExtended, true);
            _entryBoxHardwareId.EntryValidation.ModifyFont(fontBig);
            _entryBoxHardwareId.EntryValidation.Text      = _hardwareId;
            _entryBoxHardwareId.EntryValidation.Sensitive = false;
            vboxInnerLeft.PackStart(_entryBoxHardwareId, false, false, 0);

            //VBoxInnerRight
            Label labelWithoutInternetRegistration = new Label(Resx.window_license_label_without_internet_registration);

            labelWithoutInternetRegistration.SetAlignment(0.0F, 0.0F);
            labelWithoutInternetRegistration.ModifyFont(fontBig);
            vboxInnerRight.PackStart(labelWithoutInternetRegistration, false, false, 0);

            //Info
            Label labelWithoutInternetContactInfo = new Label(Resx.window_license_label_without_internet_contact_info);

            labelWithoutInternetContactInfo.Wrap = true;
            labelWithoutInternetContactInfo.SetAlignment(0.0F, 0.0F);
            vboxInnerRight.PackStart(labelWithoutInternetContactInfo, false, false, 0);

            //Company
            Label labelWithoutInternetContactCompanyNameLabel = new Label(Resx.global_company);

            labelWithoutInternetContactCompanyNameLabel.SetAlignment(0.0F, 0.0F);
            vboxInnerRight.PackStart(labelWithoutInternetContactCompanyNameLabel, false, false, (uint)padding * 2);
            Label labelWithoutInternetContactCompanyNameValue = new Label(SettingsApp.AppCompanyName);

            labelWithoutInternetContactCompanyNameValue.SetAlignment(0.0F, 0.0F);
            labelWithoutInternetContactCompanyNameValue.ModifyFont(fontBig);
            vboxInnerRight.PackStart(labelWithoutInternetContactCompanyNameValue, false, false, 0);

            //Phone
            string[] primaryPhones = SettingsApp.AppCompanyPhone.Split(new string[] { " / " }, StringSplitOptions.None);
            Label    labelWithoutInternetContactCompanyPhoneLabel = new Label(Resx.global_phone);

            labelWithoutInternetContactCompanyPhoneLabel.SetAlignment(0.0F, 0.0F);
            vboxInnerRight.PackStart(labelWithoutInternetContactCompanyPhoneLabel, false, false, (uint)padding * 2);
            Label labelWithoutInternetContactCompanyPhoneValue = new Label(primaryPhones[0]);

            labelWithoutInternetContactCompanyPhoneValue.SetAlignment(0.0F, 0.0F);
            labelWithoutInternetContactCompanyPhoneValue.ModifyFont(fontBig);
            vboxInnerRight.PackStart(labelWithoutInternetContactCompanyPhoneValue, false, false, 0);

            //Email
            Label labelWithoutInternetContactCompanyEmailLabel = new Label(Resx.global_phone);

            labelWithoutInternetContactCompanyEmailLabel.SetAlignment(0.0F, 0.0F);
            vboxInnerRight.PackStart(labelWithoutInternetContactCompanyEmailLabel, false, false, (uint)padding * 2);
            Label labelWithoutInternetContactCompanyEmailValue = new Label(SettingsApp.AppCompanyEmail);

            labelWithoutInternetContactCompanyEmailValue.SetAlignment(0.0F, 0.0F);
            labelWithoutInternetContactCompanyEmailValue.ModifyFont(fontBig);
            vboxInnerRight.PackStart(labelWithoutInternetContactCompanyEmailValue, false, false, 0);

            //Email
            Label labelWithoutInternetContactCompanyWebLabel = new Label(Resx.global_phone);

            labelWithoutInternetContactCompanyWebLabel.SetAlignment(0.0F, 0.0F);
            vboxInnerRight.PackStart(labelWithoutInternetContactCompanyWebLabel, false, false, (uint)padding * 2);
            Label labelWithoutInternetContactCompanyWebValue = new Label(SettingsApp.AppCompanyWeb);

            labelWithoutInternetContactCompanyWebValue.SetAlignment(0.0F, 0.0F);
            labelWithoutInternetContactCompanyWebValue.ModifyFont(fontBig);
            vboxInnerRight.PackStart(labelWithoutInternetContactCompanyWebValue, false, false, 0);
        }
Beispiel #38
0
 private void UpdateFont()
 {
     Pango.FontDescription fontDescription = Helpers.FontDescriptionHelper.CreateFontDescription(
         Element.FontSize, Element.FontFamily, Element.FontAttributes);
     Control.SetFont(fontDescription);
 }
 public CellRendererDiff()
 {
     font = Pango.FontDescription.FromString(DesktopService.DefaultMonospaceFont);
 }
Beispiel #40
0
        /// <summary>Constructor</summary>
        public MainView(ViewBase owner = null) : base(owner)
        {
            numberOfButtons = 0;
            if ((uint)Environment.OSVersion.Platform <= 3)
            {
                Gtk.Rc.Parse(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                                          ".gtkrc"));
            }
            baseFont        = Gtk.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;
            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 (APSIM.Shared.Utilities.ProcessUtilities.CurrentOS.IsMac)
            {
                InitMac();
            }
        }
Beispiel #41
0
        protected void InitObject(Dictionary <string, AccordionNode> pAccordionDefinition, string pNodePrivilegesTokenFormat)
        {
            String fontPosBackOfficeParent = GlobalFramework.Settings["fontPosBackOfficeParent"];
            String fontPosBackOfficeChild  = GlobalFramework.Settings["fontPosBackOfficeChild"];

            //Parameters
            _accordionDefinition = pAccordionDefinition;
            //Local Vars
            bool   isFirstButton = true;
            string currentNodePrivilegesToken;

            VBox vboxOuter = new VBox(false, 2);
            AccordionParentButton accordionParentButton;
            AccordionChildButton  accordionChildButton;

            if (_accordionDefinition != null && _accordionDefinition.Count > 0)
            {
                foreach (var parentLevel in _accordionDefinition)
                {
                    if (parentLevel.Value.GroupIcon != null)
                    {
                        HBox hboxParent = new HBox(false, 0);
                        hboxParent.PackStart(parentLevel.Value.GroupIcon, false, false, 3);
                        Label label = new Label(parentLevel.Value.Label);

                        //Pango.FontDescription tmpFont = new Pango.FontDescription();
                        Pango.FontDescription fontDescriptionParent = Pango.FontDescription.FromString(fontPosBackOfficeParent);
                        //tmpFont.Weight = Pango.Weight.Bold;
                        //tmpFont.Size = 2;
                        label.ModifyFont(fontDescriptionParent);
                        label.SetAlignment(0.0f, 0.5f);
                        hboxParent.PackStart(label, true, true, 0);
                        accordionParentButton = new AccordionParentButton(hboxParent)
                        {
                            Name = parentLevel.Key
                        };
                    }
                    else
                    {
                        accordionParentButton = new AccordionParentButton(parentLevel.Value.Label)
                        {
                            Name = parentLevel.Key
                        };
                        //First Parent Node is Assigned has currentParentButton
                        if (_currentParentButton == null)
                        {
                            _currentParentButton = accordionParentButton;
                        }
                    }

                    accordionParentButton.Active = isFirstButton;
                    if (isFirstButton)
                    {
                        isFirstButton = false;
                    }

                    //Add a Button Widget Reference to NodeWidget AccordionDefinition
                    parentLevel.Value.NodeButton = accordionParentButton;
                    //Click Event
                    accordionParentButton.Clicked += accordionParentButton_Clicked;
                    vboxOuter.PackStart(accordionParentButton, false, false, 0);

                    //_log.Debug(string.Format("Accordion(): parentLevel.Value.Label [{0}]", parentLevel.Value.Label));
                    if (parentLevel.Value.Childs.Count > 0)
                    {
                        foreach (var childLevel in parentLevel.Value.Childs)
                        {
                            //Init ChildButton
                            accordionChildButton = new AccordionChildButton(childLevel.Value.Label)
                            {
                                Name = childLevel.Key, Content = childLevel.Value.Content
                            };
                            //Add a Button Widget Reference to NodeWidget AccordionDefinition
                            childLevel.Value.NodeButton = accordionChildButton;

                            //Privileges
                            currentNodePrivilegesToken = string.Format(pNodePrivilegesTokenFormat, childLevel.Key.ToUpper());
                            //_log.Debug(string.Format("currentNodePrivilegesToken: [{0}]", currentNodePrivilegesToken));

                            //First Child Node is Assigned has currentChildButton
                            //if (childLevel.Value.Active)
                            if (_currentChildButton == null)
                            {
                                _currentChildButton = accordionChildButton;
                                //Assign Current Active Button with content
                                _currentChildButtonContent = accordionChildButton;
                            }

                            accordionParentButton.ChildBox.PackStart(accordionChildButton, false, false, 2);

                            //If have (Content | Events | ExternalApp) & Privileges or the Button is Enabled, Else is Disabled
                            accordionChildButton.Sensitive = (FrameworkUtils.HasPermissionTo(currentNodePrivilegesToken) && (childLevel.Value.Content != null || childLevel.Value.Clicked != null || childLevel.Value.ExternalAppFileName != null));

                            //EventHandler, Redirected to public Clicked, this way we have ouside Access
                            accordionChildButton.Clicked += accordionChildButton_Clicked;
                            //ExternalAppFileName
                            if (childLevel.Value.ExternalAppFileName != null)
                            {
                                accordionChildButton.ExternalAppFileName = childLevel.Value.ExternalAppFileName;
                            }

                            //Process AccordionDefinition Clicked Events
                            if (childLevel.Value.Clicked != null)
                            {
                                accordionChildButton.Clicked += childLevel.Value.Clicked;
                            }
                        }
                        vboxOuter.PackStart(accordionParentButton.ChildBox, false, false, 0);
                    }
                }
            }
            PackStart(vboxOuter);
        }
Beispiel #42
0
 /// <summary>
 /// Invoked when the user clicks OK or Apply in the font selection
 /// dialog. Changes the font on all widgets and saves the new font
 /// in the config file.
 /// </summary>
 /// <param name="sender">Sender object.</param>
 /// <param name="args">Event arguments.</param>
 private void OnChangeFont(object sender, EventArgs args)
 {
     Pango.FontDescription newFont = Pango.FontDescription.FromString(fontDialog.FontName);
     Utility.Configuration.Settings.Font = newFont;
     ChangeFont(newFont);
 }
 /// <summary>Sets font with bold and italic if applicable.</summary>
 private void SetFont(SubLib.Core.Domain.Style style)
 {
     Pango.FontDescription font = Pango.FontDescription.FromString(this.textFont + (style.Bold ? " bold" : String.Empty) + (style.Italic ? " italic" : String.Empty) + " " + this.textFontSize);
     this.textView.OverrideFont(font);
 }
Beispiel #44
0
 public void SetCustomFont(Pango.FontDescription desc)
 {
     text_render.FontDesc = desc;
 }
Beispiel #45
0
        //Constructor
        public KeyboardPadKey(VirtualKey virtualKey)
            : base("")
        {
            //Always Store full VirtualKey Properties in KeyBoardKey
            this.Properties = virtualKey;

            //Key Labels
            if (virtualKey.L1 != null)
            {
                _l1LabelText = virtualKey.L1.Glyph;
            }
            else
            {
                _l1LabelText = "";
            };
            if (virtualKey.L2 != null)
            {
                _l2LabelText = virtualKey.L2.Glyph;
            }
            else
            {
                _l2LabelText = "";
            };

            //Init Local Vars
            Size   sizeKeyboardPadDefaultKey   = Utils.StringToSize(GlobalFramework.Settings["sizeKeyboardPadDefaultKey"]);
            String fontKeyboardPadPrimaryKey   = GlobalFramework.Settings["fontKeyboardPadPrimaryKey"];
            String fontKeyboardPadSecondaryKey = GlobalFramework.Settings["fontKeyboardPadSecondaryKey"];

            //ByPass Defaults
            if (virtualKey.L1.KeyWidth > 0)
            {
                sizeKeyboardPadDefaultKey.Width = virtualKey.L1.KeyWidth;
            }
            ;

            //Defaults
            //Prepare Pango Fonts
            if (virtualKey.L1.IsBold)
            {
                fontKeyboardPadPrimaryKey = "Bold " + fontKeyboardPadPrimaryKey;
            }
            ;
            Pango.FontDescription fontDescriptionPrimaryKey   = Pango.FontDescription.FromString(fontKeyboardPadPrimaryKey);
            Pango.FontDescription fontDescriptionSecondaryKey = Pango.FontDescription.FromString(fontKeyboardPadSecondaryKey);

            //Vbox
            VBox vbox = new VBox(true, 0);

            vbox.BorderWidth = 2;
            //Labels
            _labelL1      = new Label();
            _labelL1.Text = _l1LabelText;
            //Align
            switch (virtualKey.L1.HAlign)
            {
            case "left":
                _labelL1.SetAlignment(0.00F, 0.5F);
                break;

            case "right":
                _labelL1.SetAlignment(1.00F, 0.5F);
                break;
            }
            _labelL1.ModifyFg(StateType.Normal, Utils.ColorToGdkColor(_colorKeyboardPadKeyDefaultFont));
            _labelL1.ModifyFont(fontDescriptionPrimaryKey);
            vbox.PackEnd(_labelL1);
            //HideL2 dont show L2
            if (_l2LabelText != string.Empty && !virtualKey.L1.HideL2)
            {
                _labelL2      = new Label();
                _labelL2.Text = _l2LabelText;
                _labelL1.ModifyFg(StateType.Normal, Utils.ColorToGdkColor(_colorKeyboardPadKeyDefaultFont));
                _labelL2.ModifyFg(StateType.Normal, Utils.ColorToGdkColor(_colorKeyboardPadKeySecondaryFont));
                _labelL1.ModifyFont(fontDescriptionSecondaryKey);
                _labelL2.ModifyFont(fontDescriptionSecondaryKey);
                _labelL1.SetAlignment(0.60F, 0.50F);
                _labelL2.SetAlignment(0.40F, 0.50F);
                vbox.PackStart(_labelL2);
            }
            ;

            //InitObject("", _colorKeyboardPadKeyBackground, vbox, sizeKeyboardPadDefaultKey.Width, sizeKeyboardPadDefaultKey.Height);

            //Changed for theme
            this.BorderWidth = 1;
            InitObject("", Color.Transparent, vbox, sizeKeyboardPadDefaultKey.Width, sizeKeyboardPadDefaultKey.Height);
        }
Beispiel #46
0
        public ThemeSettings(UserConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            string bgStr = (string)config["Interface/Chat/BackgroundColor"];

            if (!String.IsNullOrEmpty(bgStr))
            {
                Gdk.Color bgColor = Gdk.Color.Zero;
                if (Gdk.Color.Parse(bgStr, ref bgColor))
                {
                    f_BackgroundColor = bgColor;
                }
            }
            else
            {
                f_BackgroundColor = null;
            }

            string fgStr = (string)config["Interface/Chat/ForegroundColor"];

            if (!String.IsNullOrEmpty(fgStr))
            {
                Gdk.Color fgColor = Gdk.Color.Zero;
                if (Gdk.Color.Parse(fgStr, ref fgColor))
                {
                    f_ForegroundColor = fgColor;
                }
            }
            else
            {
                f_ForegroundColor = null;
            }

            string colorStr;

            Gdk.Color color;
            colorStr = (string)config["Interface/Notebook/Tab/HighlightColor"];
            color    = Gdk.Color.Zero;
            if (Gdk.Color.Parse(colorStr, ref color))
            {
                f_HighlightColor = color;
            }

            colorStr = (string)config["Interface/Notebook/Tab/ActivityColor"];
            color    = Gdk.Color.Zero;
            if (Gdk.Color.Parse(colorStr, ref color))
            {
                f_ActivityColor = color;
            }

            colorStr = (string)config["Interface/Notebook/Tab/NoActivityColor"];
            color    = Gdk.Color.Zero;
            if (Gdk.Color.Parse(colorStr, ref color))
            {
                f_NoActivityColor = color;
            }

            colorStr = (string)config["Interface/Notebook/Tab/EventColor"];
            color    = Gdk.Color.Zero;
            if (Gdk.Color.Parse(colorStr, ref color))
            {
                f_EventColor = color;
            }

            string fontFamily = (string)config["Interface/Chat/FontFamily"];
            string fontStyle  = (string)config["Interface/Chat/FontStyle"];
            int    fontSize   = 0;

            if (config["Interface/Chat/FontSize"] != null)
            {
                fontSize = (int)config["Interface/Chat/FontSize"];
            }
            Pango.FontDescription fontDescription = new Pango.FontDescription();
            if (String.IsNullOrEmpty(fontFamily))
            {
                // HACK: use Consolas or Fixed-Sys on Windows by default
                if (Environment.OSVersion.Platform == PlatformID.Win32NT)
                {
                    var osVersion   = Environment.OSVersion.Version;
                    var isWinXp     = osVersion.Major == 5 && osVersion.Minor > 0;
                    var hasConsolas = false;
                    using (var context = Frontend.MainWindow.CreatePangoContext()) {
                        hasConsolas = context.Families.Any(
                            family => family.Name == "Consolas"
                            );
                    }
                    if (hasConsolas && !isWinXp)
                    {
                        // this system has Consolas available and is not WinXP,
                        // let's use it!
                        fontDescription.Family = "Consolas, monospace";
                        // Consolas only looks good in size 11
                        fontDescription.Size   = 11 * 1024;
                        fontDescription.Weight = Pango.Weight.Normal;
                        fontDescription.Style  = Pango.Style.Normal;
                    }
                    else
                    {
                        // too bad, fallback to FixedSys then
                        fontDescription.Family = "FixedsysTTF, monospace";
                        // FixedSys only looks good in size 11
                        fontDescription.Size   = 11 * 1024;
                        fontDescription.Weight = Pango.Weight.Bold;
                        fontDescription.Style  = Pango.Style.Normal;
                    }
                }
                else if (Frontend.IsMacOSX)
                {
                    // HACK: family font description with font fallbacks is not
                    // working on OS X, thus we have to probe and decide ourself
                    var ctx      = Frontend.MainWindow.CreatePangoContext();
                    var families = ctx.Families;
                    if (families.Any(family =>
                                     family.Name == "Menlo"))
                    {
                        fontDescription.Family = "Menlo";
                    }
                    else if (families.Any(family =>
                                          family.Name == "Monaco"))
                    {
                        fontDescription.Family = "Monaco";
                    }
                    else
                    {
                        fontDescription.Family = "monospace";
                    }
                }
                else
                {
                    // use Monospace and Bold by default
                    fontDescription.Family = "monospace";
                    // black bold font on white background looks odd
                    //fontDescription.Weight = Pango.Weight.Bold;
                }
            }
            else
            {
                fontDescription.Family = fontFamily;
                string frontWeigth = null;
                if (fontStyle.Contains(" "))
                {
                    int pos = fontStyle.IndexOf(" ");
                    frontWeigth = fontStyle.Substring(0, pos);
                    fontStyle   = fontStyle.Substring(pos + 1);
                }
                fontDescription.Style = (Pango.Style)Enum.Parse(typeof(Pango.Style), fontStyle);
                if (frontWeigth != null)
                {
                    fontDescription.Weight = (Pango.Weight)Enum.Parse(typeof(Pango.Weight), frontWeigth);
                }
                fontDescription.Size = fontSize * 1024;
            }
            f_FontDescription = fontDescription;
        }
Beispiel #47
0
 /// <summary>
 /// Change Apsim's default font, and apply the new font to all existing
 /// widgets.
 /// </summary>
 /// <param name="font">The new default font.</param>
 private void ChangeFont(Pango.FontDescription font)
 {
     SetWidgetFont(mainWidget, font);
     Settings.Default.SetStringProperty($"gtk-font-name", font.ToString(), "");
     //Rc.ParseString($"gtk-font-name = \"{font}\"");
 }
Beispiel #48
0
        public ModelDetailsWrapperView(ViewBase owner) : base(owner)
        {
            vbox1 = new VBox();

            modelTypeLabel = new Label
            {
                Xalign = 0.0f,
                Xpad   = 3
            };
            Pango.FontDescription font = new Pango.FontDescription
            {
                Size   = Convert.ToInt32(16 * Pango.Scale.PangoScale),
                Weight = Pango.Weight.Semibold
            };
            modelTypeLabel.ModifyFont(font);

            modelDescriptionLabel = new Label()
            {
                Xalign = 0.0f,
                Xpad   = 4
            };
            modelDescriptionLabel.LineWrapMode = Pango.WrapMode.Word;
            modelDescriptionLabel.Wrap         = true;
            modelDescriptionLabel.ModifyBg(StateType.Normal, new Gdk.Color(131, 0, 131));

            modelHelpLinkLabel = new LinkButton("", "more information")
            {
                Xalign = 0.0f,
            };
            modelHelpLinkLabel.Clicked += ModelHelpLinkLabel_Clicked;
            modelHelpLinkLabel.ModifyBase(StateType.Normal, new Gdk.Color(131, 0, 131));
            modelHelpLinkLabel.Visible = false;

            modelVersionLabel = new Label()
            {
                Xalign = 0.0f,
                Xpad   = 4
            };
            font = new Pango.FontDescription
            {
                Size   = Convert.ToInt32(8 * Pango.Scale.PangoScale),
                Weight = Pango.Weight.Normal,
            };
            modelVersionLabel.ModifyFont(font);
            modelVersionLabel.ModifyFg(StateType.Normal, new Gdk.Color(150, 150, 150));
            modelVersionLabel.LineWrapMode = Pango.WrapMode.Word;
            modelVersionLabel.Wrap         = true;
            modelVersionLabel.ModifyBg(StateType.Normal, new Gdk.Color(131, 0, 131));

            bottomView = new Viewport
            {
                ShadowType = ShadowType.None
            };

            vbox1.PackStart(modelTypeLabel, false, true, 0);
            vbox1.PackStart(modelDescriptionLabel, false, true, 0);
            vbox1.PackStart(modelVersionLabel, false, true, 4);
            vbox1.PackStart(modelHelpLinkLabel, false, true, 0);
            vbox1.Add(bottomView);
            vbox1.SizeAllocated += Vbox1_SizeAllocated;

            _mainWidget            = vbox1;
            _mainWidget.Destroyed += _mainWidget_Destroyed;
        }
Beispiel #49
0
        private void InitUI()
        {
            //Init Local Vars
            uint borderWidth = 5;

            //Settings
            _clockFormat = GlobalFramework.Settings["dateTimeFormatStatusBar"];
            string fontBackOfficeStatusBar = GlobalFramework.Settings["fontPosStatusBar"];
            string fileImageBackOfficeLogo = Utils.GetThemeFileLocation(GlobalFramework.Settings["fileImageBackOfficeLogo"]);

            //Colors
            System.Drawing.Color colorBackOfficeContentBackground         = FrameworkUtils.StringToColor(GlobalFramework.Settings["colorBackOfficeContentBackground"]);
            System.Drawing.Color colorBackOfficeStatusBarBackground       = FrameworkUtils.StringToColor(GlobalFramework.Settings["colorBackOfficeStatusBarBackground"]);
            System.Drawing.Color colorBackOfficeAccordionFixBackground    = FrameworkUtils.StringToColor(GlobalFramework.Settings["colorBackOfficeAccordionFixBackground"]);
            System.Drawing.Color colorBackOfficeStatusBarFont             = FrameworkUtils.StringToColor(GlobalFramework.Settings["colorBackOfficeStatusBarFont"]);
            System.Drawing.Color colorBackOfficeStatusBarBottomBackground = FrameworkUtils.StringToColor(GlobalFramework.Settings["colorBackOfficeStatusBarBottomBackground"]);

            ModifyBg(StateType.Normal, Utils.ColorToGdkColor(colorBackOfficeContentBackground));

            //Icon
            string fileImageAppIcon = FrameworkUtils.OSSlash(string.Format("{0}{1}", GlobalFramework.Path["images"], SettingsApp.AppIcon));

            if (File.Exists(fileImageAppIcon))
            {
                Icon = Utils.ImageToPixbuf(System.Drawing.Image.FromFile(fileImageAppIcon));
            }

            //Start Pack UI

            //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
            //StatusBar
            EventBox eventBoxStatusBar = new EventBox()
            {
                HeightRequest = 38
            };

            eventBoxStatusBar.ModifyBg(StateType.Normal, Utils.ColorToGdkColor(colorBackOfficeStatusBarBackground));

            //Logo
            try
            {
                _imageLogo = new Image(fileImageBackOfficeLogo);
                _imageLogo.WidthRequest = _widthAccordion + Convert.ToInt16(borderWidth) * 3;
                _imageLogo.SetAlignment(0.0F, 0.5F);
            }
            catch (Exception ex)
            {
                _log.Error(string.Format("InitUI(): Image [{0}] not found: {1}", fileImageBackOfficeLogo, ex.Message), ex);
            }

            //Style StatusBarFont
            Pango.FontDescription fontDescriptionStatusBar = Pango.FontDescription.FromString(fontBackOfficeStatusBar);

            //Active Content
            _labelActiveContent = new Label()
            {
                WidthRequest = 300
            };
            _labelActiveContent.ModifyFont(fontDescriptionStatusBar);
            _labelActiveContent.ModifyFg(StateType.Normal, Utils.ColorToGdkColor(colorBackOfficeStatusBarFont));
            _labelActiveContent.SetAlignment(0.0F, 0.5F);

            //TerminalInfo : Terminal : User
            _labelTerminalInfo = new Label(string.Format("{0} : {1}", GlobalFramework.LoggedTerminal.Designation, GlobalFramework.LoggedUser.Name));
            _labelTerminalInfo.ModifyFont(fontDescriptionStatusBar);
            _labelTerminalInfo.ModifyFg(StateType.Normal, Utils.ColorToGdkColor(colorBackOfficeStatusBarFont));
            _labelTerminalInfo.SetAlignment(0.5F, 0.5F);

            //Clock
            _labelClock = new Label(FrameworkUtils.CurrentDateTime(_clockFormat));
            _labelClock.ModifyFont(fontDescriptionStatusBar);
            _labelClock.ModifyFg(StateType.Normal, Utils.ColorToGdkColor(colorBackOfficeStatusBarFont));
            _labelClock.SetAlignment(1.0F, 0.5F);

            //Pack HBox StatusBar
            _hboxStatusBar = new HBox(false, 0)
            {
                BorderWidth = borderWidth
            };
            _hboxStatusBar.PackStart(_imageLogo, false, false, 0);
            _hboxStatusBar.PackStart(_labelActiveContent, false, false, 0);
            _hboxStatusBar.PackStart(_labelTerminalInfo, true, true, 0);

            //TODO:THEME
            if (GlobalApp.ScreenSize.Width == 800 && GlobalApp.ScreenSize.Height == 600)
            {
                _labelTerminalInfo.SetAlignment(1.0F, 0.5F);
            }
            else
            {
                _hboxStatusBar.PackStart(_labelClock, false, false, 0);
            }

            _imageLogo.Dispose();

            //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
            //StatusBar
            //Fixed fixStatusBarBottom = new Fixed() { HasWindow = true, BorderWidth = borderWidth, HeightRequest = 38 };
            //fixStatusBarBottom.ModifyBg(StateType.Normal, Utils.ColorToGdkColor(colorBackOfficeStatusBarBottomBackground));

            //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
            //Hbox Accordion + Content
            _hboxContent = new HBox(false, (int)borderWidth)
            {
                BorderWidth = borderWidth
            };
            //_accordion = new Accordion() { WidthRequest = _widthAccordion };

            //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
            //Accordion and HouseFix
            _fixAccordion = new Fixed()
            {
                HasWindow = true, BorderWidth = borderWidth
            };
            _fixAccordion.ModifyBg(StateType.Normal, Utils.ColorToGdkColor(colorBackOfficeAccordionFixBackground));
            //fixAccordion.Add(_accordion);

            //Pack hboxContent
            _hboxContent.PackStart(_fixAccordion, false, false, 0);

            VBox vboxContent = new VBox(false, 0);

            eventBoxStatusBar.Add(_hboxStatusBar);

            vboxContent.PackStart(eventBoxStatusBar, false, false, 0);
            vboxContent.PackStart(_hboxContent);
            // vboxContent.PackStart(fixStatusBarBottom, false, false, 0);

            //Final Pack
            Add(vboxContent);

            //Clock
            StartClock();
        }
Beispiel #50
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
        }
Beispiel #51
0
        public void InitObject(String pName, Color pColor, String pLabelText, String pFont, TableStatus pTableStatus, decimal pTotal, DateTime pDateOpen, DateTime pDateClosed)
        {
            //Init Parameters
            _buttonColor = pColor;
            _tableStatus = pTableStatus;

            //Settings
            _colorPosTablePadTableTableStatusOpenButtonBackground     = FrameworkUtils.StringToColor(GlobalFramework.Settings["colorPosTablePadTableTableStatusOpenButtonBackground"]);
            _colorPosTablePadTableTableStatusReservedButtonBackground = FrameworkUtils.StringToColor(GlobalFramework.Settings["colorPosTablePadTableTableStatusReservedButtonBackground"]);

            //Initialize UI Components
            VBox vbox = new VBox(true, 5)
            {
                BorderWidth = 5
            };

            //Button base Label
            _label = new Label(pLabelText);
            SetFont(string.Format("Bold {0}", pFont));
            //Label for Date
            Label labelDateTableOpenOrClosed = new Label(string.Empty);

            Pango.FontDescription fontDescDateTableOpenOrClosed = Pango.FontDescription.FromString("7");
            labelDateTableOpenOrClosed.ModifyFont(fontDescDateTableOpenOrClosed);
            //Label for Total or Status
            _labelTotalOrStatus    = new Label(string.Empty);
            _eventBoxTotalOrStatus = new EventBox();
            _eventBoxTotalOrStatus.Add(_labelTotalOrStatus);
            //_eventBoxTotalOrStatus.CanFocus = false;
            //If click in EventBox call button Click Event
            _eventBoxTotalOrStatus.ButtonPressEvent += delegate { Click(); };

            //Pack VBox
            vbox.PackStart(_label);
            vbox.PackStart(labelDateTableOpenOrClosed);
            vbox.PackStart(_eventBoxTotalOrStatus);
            //Pack Final Widget
            _widget = vbox;

            //_log.Debug(string.Format("pLabelText:[{0}], _tableStatus: [{1}]", pLabelText, _tableStatus));
            switch (_tableStatus)
            {
            case TableStatus.Free:
                SetBackgroundColor(_buttonColor, _eventBoxTotalOrStatus);
                break;

            case TableStatus.Open:
                _labelTotalOrStatus.Text = FrameworkUtils.DecimalToStringCurrency(pTotal);
                if (pDateOpen != null)
                {
                    labelDateTableOpenOrClosed.Text = string.Format(Resx.pos_button_label_table_open_at, pDateOpen.ToString(SettingsApp.DateTimeFormatHour));
                }
                SetBackgroundColor(_colorPosTablePadTableTableStatusOpenButtonBackground, _eventBoxTotalOrStatus);
                break;

            case TableStatus.Reserved:
                _labelTotalOrStatus.Text = Resx.global_reserved_table;
                SetBackgroundColor(_colorPosTablePadTableTableStatusReservedButtonBackground, _eventBoxTotalOrStatus);
                break;

            default:
                break;
            }
        }
        void Build()
        {
            BorderWidth   = 0;
            DefaultWidth  = 901;
            DefaultHeight = 632;

            Name           = "wizard_dialog";
            Title          = GettextCatalog.GetString("New Project");
            WindowPosition = WindowPosition.CenterOnParent;
            TransientFor   = IdeApp.Workbench.RootWindow;

            projectConfigurationWidget      = new GtkProjectConfigurationWidget();
            projectConfigurationWidget.Name = "projectConfigurationWidget";

            // Top banner of dialog.
            var topLabelEventBox = new EventBox();

            topLabelEventBox.Accessible.SetShouldIgnore(true);
            topLabelEventBox.Name          = "topLabelEventBox";
            topLabelEventBox.HeightRequest = 52;
            topLabelEventBox.ModifyBg(StateType.Normal, bannerBackgroundColor);
            topLabelEventBox.ModifyFg(StateType.Normal, whiteColor);
            topLabelEventBox.BorderWidth = 0;

            var topBannerTopEdgeLineEventBox = new EventBox();

            topBannerTopEdgeLineEventBox.Accessible.SetShouldIgnore(true);
            topBannerTopEdgeLineEventBox.Name          = "topBannerTopEdgeLineEventBox";
            topBannerTopEdgeLineEventBox.HeightRequest = 1;
            topBannerTopEdgeLineEventBox.ModifyBg(StateType.Normal, bannerLineColor);
            topBannerTopEdgeLineEventBox.BorderWidth = 0;

            var topBannerBottomEdgeLineEventBox = new EventBox();

            topBannerBottomEdgeLineEventBox.Accessible.SetShouldIgnore(true);
            topBannerBottomEdgeLineEventBox.Name          = "topBannerBottomEdgeLineEventBox";
            topBannerBottomEdgeLineEventBox.HeightRequest = 1;
            topBannerBottomEdgeLineEventBox.ModifyBg(StateType.Normal, bannerLineColor);
            topBannerBottomEdgeLineEventBox.BorderWidth = 0;

            topBannerLabel                 = new Label();
            topBannerLabel.Name            = "topBannerLabel";
            topBannerLabel.Accessible.Name = "topBannerLabel";
            Pango.FontDescription font = topBannerLabel.Style.FontDescription.Copy();              // UNDONE: VV: Use FontService?
            font.Size = (int)(font.Size * 1.8);
            topBannerLabel.ModifyFont(font);
            topBannerLabel.ModifyFg(StateType.Normal, whiteColor);
            var topLabelHBox = new HBox();

            topLabelHBox.Accessible.SetShouldIgnore(true);
            topLabelHBox.Name = "topLabelHBox";
            topLabelHBox.PackStart(topBannerLabel, false, false, 20);
            topLabelEventBox.Add(topLabelHBox);

            VBox.PackStart(topBannerTopEdgeLineEventBox, false, false, 0);
            VBox.PackStart(topLabelEventBox, false, false, 0);
            VBox.PackStart(topBannerBottomEdgeLineEventBox, false, false, 0);

            // Main templates section.
            centreVBox = new VBox();
            centreVBox.Accessible.SetShouldIgnore(true);
            centreVBox.Name = "centreVBox";
            VBox.PackStart(centreVBox, true, true, 0);
            templatesHBox = new HBox();
            templatesHBox.Accessible.SetShouldIgnore(true);
            templatesHBox.Name = "templatesHBox";
            centreVBox.PackEnd(templatesHBox, true, true, 0);

            // Template categories.
            var templateCategoriesBgBox = new EventBox();

            templateCategoriesBgBox.Accessible.SetShouldIgnore(true);
            templateCategoriesBgBox.Name        = "templateCategoriesVBox";
            templateCategoriesBgBox.BorderWidth = 0;
            templateCategoriesBgBox.ModifyBg(StateType.Normal, categoriesBackgroundColor);
            templateCategoriesBgBox.WidthRequest = 220;
            var templateCategoriesScrolledWindow = new ScrolledWindow();

            templateCategoriesScrolledWindow.Name             = "templateCategoriesScrolledWindow";
            templateCategoriesScrolledWindow.HscrollbarPolicy = PolicyType.Never;

            // Template categories tree view.
            templateCategoriesTreeView                 = new TreeView();
            templateCategoriesTreeView.Name            = "templateCategoriesTreeView";
            templateCategoriesTreeView.Accessible.Name = "templateCategoriesTreeView";
            templateCategoriesTreeView.Accessible.SetTitle(GettextCatalog.GetString("Project Categories"));
            templateCategoriesTreeView.Accessible.Description = GettextCatalog.GetString("Select the project category to see all possible project templates");
            templateCategoriesTreeView.BorderWidth            = 0;
            templateCategoriesTreeView.HeadersVisible         = false;
            templateCategoriesTreeView.Model        = templateCategoriesListStore;
            templateCategoriesTreeView.SearchColumn = -1;             // disable the interactive search
            templateCategoriesTreeView.AppendColumn(CreateTemplateCategoriesTreeViewColumn());
            templateCategoriesScrolledWindow.Add(templateCategoriesTreeView);
            templateCategoriesBgBox.Add(templateCategoriesScrolledWindow);
            templatesHBox.PackStart(templateCategoriesBgBox, false, false, 0);

            // Templates.
            var templatesBgBox = new EventBox();

            templatesBgBox.Accessible.SetShouldIgnore(true);
            templatesBgBox.ModifyBg(StateType.Normal, templateListBackgroundColor);
            templatesBgBox.Name         = "templatesVBox";
            templatesBgBox.WidthRequest = 400;
            templatesHBox.PackStart(templatesBgBox, false, false, 0);
            var templatesScrolledWindow = new ScrolledWindow();

            templatesScrolledWindow.Name             = "templatesScrolledWindow";
            templatesScrolledWindow.HscrollbarPolicy = PolicyType.Never;

            // Templates tree view.
            templatesTreeView                 = new TreeView();
            templatesTreeView.Name            = "templatesTreeView";
            templatesTreeView.Accessible.Name = "templatesTreeView";
            templatesTreeView.Accessible.SetTitle(GettextCatalog.GetString("Project Templates"));
            templatesTreeView.Accessible.Description = GettextCatalog.GetString("Select the project template");
            templatesTreeView.HeadersVisible         = false;
            templatesTreeView.Model        = templatesListStore;
            templatesTreeView.SearchColumn = -1;             // disable the interactive search
            templatesTreeView.AppendColumn(CreateTemplateListTreeViewColumn());
            templatesScrolledWindow.Add(templatesTreeView);
            templatesBgBox.Add(templatesScrolledWindow);

            // Accessibilityy
            templateCategoriesTreeView.Accessible.AddLinkedUIElement(templatesTreeView.Accessible);

            // Template
            var templateEventBox = new EventBox();

            templateEventBox.Accessible.SetShouldIgnore(true);
            templateEventBox.Name = "templateEventBox";
            templateEventBox.ModifyBg(StateType.Normal, templateBackgroundColor);
            templatesHBox.PackStart(templateEventBox, true, true, 0);
            templateVBox = new VBox();
            templateVBox.Accessible.SetShouldIgnore(true);
            templateVBox.Visible     = false;
            templateVBox.BorderWidth = 20;
            templateVBox.Spacing     = 10;
            templateEventBox.Add(templateVBox);

            // Template large image.
            templateImage = new ImageView();
            templateImage.Accessible.SetShouldIgnore(true);
            templateImage.Name          = "templateImage";
            templateImage.HeightRequest = 140;
            templateImage.WidthRequest  = 240;
            templateVBox.PackStart(templateImage, false, false, 10);

            // Template description.
            templateNameLabel                        = new Label();
            templateNameLabel.Name                   = "templateNameLabel";
            templateNameLabel.Accessible.Name        = "templateNameLabel";
            templateNameLabel.Accessible.Description = GettextCatalog.GetString("The name of the selected template");
            templateNameLabel.WidthRequest           = 240;
            templateNameLabel.Wrap                   = true;
            templateNameLabel.Xalign                 = 0;
            templateNameLabel.Markup                 = MarkupTemplateName("TemplateName");
            templateVBox.PackStart(templateNameLabel, false, false, 0);
            templateDescriptionLabel                 = new Label();
            templateDescriptionLabel.Name            = "templateDescriptionLabel";
            templateDescriptionLabel.Accessible.Name = "templateDescriptionLabel";
            templateDescriptionLabel.Accessible.SetLabel(GettextCatalog.GetString("The description of the selected template"));
            templateDescriptionLabel.WidthRequest = 240;
            templateDescriptionLabel.Wrap         = true;
            templateDescriptionLabel.Xalign       = 0;
            templateVBox.PackStart(templateDescriptionLabel, false, false, 0);

            var tempLabel = new Label();

            tempLabel.Accessible.SetShouldIgnore(true);
            templateVBox.PackStart(tempLabel, true, true, 0);

            templatesTreeView.Accessible.AddLinkedUIElement(templateNameLabel.Accessible);
            templatesTreeView.Accessible.AddLinkedUIElement(templateDescriptionLabel.Accessible);

            // Template - button separator.
            var templateSectionSeparatorEventBox = new EventBox();

            templateSectionSeparatorEventBox.Accessible.SetShouldIgnore(true);
            templateSectionSeparatorEventBox.Name          = "templateSectionSeparatorEventBox";
            templateSectionSeparatorEventBox.HeightRequest = 1;
            templateSectionSeparatorEventBox.ModifyBg(StateType.Normal, templateSectionSeparatorColor);
            VBox.PackStart(templateSectionSeparatorEventBox, false, false, 0);

            // Buttons at bottom of dialog.
            var bottomHBox = new HBox();

            bottomHBox.Accessible.SetShouldIgnore(true);
            bottomHBox.Name = "bottomHBox";
            VBox.PackStart(bottomHBox, false, false, 0);

            // Cancel button - bottom left.
            var cancelButtonBox = new HButtonBox();

            cancelButtonBox.Accessible.SetShouldIgnore(true);
            cancelButtonBox.Name        = "cancelButtonBox";
            cancelButtonBox.BorderWidth = 16;
            cancelButton                        = new Button();
            cancelButton.Name                   = "cancelButton";
            cancelButton.Accessible.Name        = "cancelButton";
            cancelButton.Accessible.Description = GettextCatalog.GetString("Cancel the dialog");
            cancelButton.Label                  = GettextCatalog.GetString("Cancel");
            cancelButton.UseStock               = true;
            cancelButtonBox.PackStart(cancelButton, false, false, 0);
            bottomHBox.PackStart(cancelButtonBox, false, false, 0);

            // Previous button - bottom right.
            var previousNextButtonBox = new HButtonBox();

            previousNextButtonBox.Accessible.SetShouldIgnore(true);
            previousNextButtonBox.Name        = "previousNextButtonBox";
            previousNextButtonBox.BorderWidth = 16;
            previousNextButtonBox.Spacing     = 9;
            bottomHBox.PackStart(previousNextButtonBox);
            previousNextButtonBox.Layout = ButtonBoxStyle.End;

            previousButton                        = new Button();
            previousButton.Name                   = "previousButton";
            previousButton.Accessible.Name        = "previousButton";
            previousButton.Accessible.Description = GettextCatalog.GetString("Return to the previous page");
            previousButton.Label                  = GettextCatalog.GetString("Previous");
            previousButton.Sensitive              = false;
            previousNextButtonBox.PackEnd(previousButton);

            // Next button - bottom right.
            nextButton                        = new Button();
            nextButton.Name                   = "nextButton";
            nextButton.Accessible.Name        = "nextButton";
            nextButton.Accessible.Description = GettextCatalog.GetString("Move to the next page");
            nextButton.Label                  = GettextCatalog.GetString("Next");
            previousNextButtonBox.PackEnd(nextButton);

            // Remove default button action area.
            VBox.Remove(ActionArea);

            if (Child != null)
            {
                Child.ShowAll();
            }

            Show();

            templatesTreeView.HasFocus = true;
            Resizable = false;
        }
Beispiel #53
0
 public void AddFontAttribute(Pango.FontDescription font, uint start, uint end)
 {
     Add(pango_attr_font_desc_new(font.Handle), start, end);
 }
        public ModelDetailsWrapperView(ViewBase owner) : base(owner)
        {
            hbox  = new HBox();
            vbox1 = new VBox();

            modelTypeLabel = new Label
            {
                Xalign = 0.0f,
                Xpad   = 3
            };
            Pango.FontDescription font = new Pango.FontDescription
            {
                Size   = Convert.ToInt32(16 * Pango.Scale.PangoScale),
                Weight = Pango.Weight.Semibold
            };
            modelTypeLabel.ModifyFont(font);

            modelDescriptionLabel = new Label()
            {
                Xalign = 0.0f,
                Xpad   = 4
            };
            modelDescriptionLabel.LineWrapMode = Pango.WrapMode.Word;
            modelDescriptionLabel.Wrap         = true;
            modelDescriptionLabel.ModifyBg(StateType.Normal, new Gdk.Color(131, 0, 131));

            modelHelpLinkLabel = new LinkButton("", "")
            {
                Xalign = 0.0f,
            };
            modelHelpLinkLabel.Clicked += ModelHelpLinkLabel_Clicked;
            modelHelpLinkLabel.ModifyBase(StateType.Normal, new Gdk.Color(131, 0, 131));
            modelHelpLinkLabel.Visible = false;

            Gtk.CellRendererPixbuf pixbufRender = new CellRendererPixbuf();
            pixbufRender.Pixbuf = new Gdk.Pixbuf(null, "ApsimNG.Resources.MenuImages.Help.png");
            pixbufRender.Xalign = 0.5f;
            Gtk.Image img = new Image(pixbufRender.Pixbuf);
            modelHelpLinkLabel.Image         = img;
            modelHelpLinkLabel.Image.Visible = true;

            modelVersionLabel = new Label()
            {
                Xalign = 0.0f,
                Xpad   = 4
            };
            font = new Pango.FontDescription
            {
                Size   = Convert.ToInt32(8 * Pango.Scale.PangoScale),
                Weight = Pango.Weight.Normal,
            };
            modelVersionLabel.ModifyFont(font);
            modelVersionLabel.ModifyFg(StateType.Normal, new Gdk.Color(150, 150, 150));
            modelVersionLabel.LineWrapMode = Pango.WrapMode.Word;
            modelVersionLabel.Wrap         = true;
            modelVersionLabel.ModifyBg(StateType.Normal, new Gdk.Color(131, 0, 131));

            bottomView = new Viewport
            {
                ShadowType = ShadowType.None
            };

            hbox.PackStart(modelTypeLabel, false, true, 0);
            hbox.PackStart(modelHelpLinkLabel, false, false, 0);

            vbox1.PackStart(hbox, false, true, 0);
            vbox1.PackStart(modelTypeLabel, false, true, 0);
            vbox1.PackStart(modelDescriptionLabel, false, true, 0);
            vbox1.PackStart(modelVersionLabel, false, true, 4);
            vbox1.Add(bottomView);
            vbox1.SizeAllocated += Vbox1_SizeAllocated;

            _mainWidget            = vbox1;
            _mainWidget.Destroyed += _mainWidget_Destroyed;
        }
Beispiel #55
0
 public static Font ToEto(this Pango.FontDescription fontDesc, string familyName = null)
 {
     return(fontDesc == null ? null : new Font(new FontHandler(fontDesc, familyName)));
 }
Beispiel #56
0
        private void BuildTile()
        {
            BorderWidth   = 5;
            RowSpacing    = 1;
            ColumnSpacing = 5;

            Image image = new Image();

            image.IconName = "package-x-generic";
            image.IconSize = (int)IconSize.Dnd;
            image.Yalign   = 0.0f;
            image.Show();
            Attach(image, 0, 1, 0, 3, AttachOptions.Shrink, AttachOptions.Fill | AttachOptions.Expand, 0, 0);

            title = new Label();
            SetLabelStyle(title);
            title.Show();
            title.Xalign = 0.0f;
            title.Markup = String.Format("<b>{0}</b>", GLib.Markup.EscapeText(addin.Name));

            Attach(title, 1, 3, 0, 1,
                   AttachOptions.Expand | AttachOptions.Fill,
                   AttachOptions.Expand | AttachOptions.Fill, 0, 0);

            description = new WrapLabel();
            SetLabelStyle(description);
            description.Show();
            description.Text = addin.Description.Description;
            description.Wrap = false;

            Attach(description, 1, 3, 1, 2,
                   AttachOptions.Expand | AttachOptions.Fill,
                   AttachOptions.Expand | AttachOptions.Fill, 0, 0);

            authors = new WrapLabel();
            SetLabelStyle(authors);
            authors.Markup = String.Format(
                "<small><b>{0}</b> <i>{1}</i></small>",
                Catalog.GetString("Authors:"),
                GLib.Markup.EscapeText(addin.Description.Author)
                );

            Attach(authors, 1, 2, 2, 3,
                   AttachOptions.Expand | AttachOptions.Fill,
                   AttachOptions.Expand | AttachOptions.Fill, 0, 4);

            button_box = new VBox();
            HBox box = new HBox();

            box.Spacing = 3;

            button_box.PackEnd(box, false, false, 0);

            Pango.FontDescription font = PangoContext.FontDescription.Copy();
            font.Size = (int)(font.Size * Pango.Scale.Small);

            Label label = new Label("Details");

            label.ModifyFont(font);
            details_button = new Button();
            details_button.Add(label);
            details_button.Clicked += OnDetailsClicked;
            box.PackStart(details_button, false, false, 0);

            label = new Label();
            label.ModifyFont(font);
            activate_button = new Button();
            activate_button.Add(label);
            activate_button.Clicked += OnActivateClicked;
            box.PackStart(activate_button, false, false, 0);

            Attach(button_box, 2, 3, 2, 3, AttachOptions.Shrink, AttachOptions.Expand | AttachOptions.Fill, 0, 0);

            Show();

            UpdateState();
        }
Beispiel #57
0
        static Pango.Layout createLayoutFromTextBlock(Context g, TextBlock tb)
        {
            double leftRightSpan = tb.Padding.Left + tb.Padding.Right;
            Pango.Layout layout = Pango.CairoHelper.CreateLayout (g);

            layout.Wrap = Pango.WrapMode.Word;
            layout.Width = (int)((tb.Width - leftRightSpan) * Pango.Scale.PangoScale);
            Pango.FontDescription fd = new Pango.FontDescription ();
            fd.Family = tb.FontName;

            fd.Style = ReportToPangoSlant (tb.FontSlant);
            fd.Weight = ReportToPangoWeight (tb.FontWeight);

            fd.AbsoluteSize = tb.FontSize * Pango.Scale.PangoScale;
            layout.FontDescription = fd;

            layout.Spacing = (int)(tb.LineSpan * Pango.Scale.PangoScale);
            //layout.Indent = (int)(0 * Pango.Scale.PangoScale);
            layout.Alignment = ReportToPangoAlignment (tb.HorizontalAlignment);
            layout.SetText (tb.Text);
            return layout;
        }
Beispiel #58
0
 private double GetHtmlFontSize(Pango.FontDescription font)
 {
     return(1.5 * font.Size / Pango.Scale.PangoScale);
 }
Beispiel #59
0
        private void _Load()
        {
            Trace.Call();

            // root
            string startup_commands = String.Join("\n", (string[])Frontend.UserConfig["OnStartupCommands"]);
            ((Gtk.TextView)_Glade["OnStartupCommandsTextView"]).Buffer.Text  = startup_commands;

            // Connection
            string nicknames = String.Join(" ", (string[])Frontend.UserConfig["Connection/Nicknames"]);
            ((Gtk.Entry)_Glade["ConnectionNicknamesEntry"]).Text  = nicknames;
            ((Gtk.Entry)_Glade["ConnectionUsernameEntry"]).Text  = (string)Frontend.UserConfig["Connection/Username"];
            ((Gtk.Entry)_Glade["ConnectionRealnameEntry"]).Text  = (string)Frontend.UserConfig["Connection/Realname"];
            string connect_commands = String.Join("\n", (string[])Frontend.UserConfig["Connection/OnConnectCommands"]);
            ((Gtk.TextView)_Glade["OnConnectCommandsTextView"]).Buffer.Text = connect_commands;

            string encoding = (string)Frontend.UserConfig["Connection/Encoding"];
            encoding = encoding.ToUpper();

            Gtk.ComboBox cb = (Gtk.ComboBox)_Glade["EncodingComboBox"];
            // glade might initialize it already!
            cb.Clear();
            Gtk.CellRendererText cell = new Gtk.CellRendererText();
            cb.PackStart(cell, false);
            cb.AddAttribute(cell, "text", 0);
            Gtk.ListStore store = new Gtk.ListStore(typeof(string), typeof(string));
            store.AppendValues(String.Format("<{0}>", _("System Default")), String.Empty);
            ArrayList encodingList = new ArrayList();
            ArrayList bodyNameList = new ArrayList();
            foreach (EncodingInfo encInfo in Encoding.GetEncodings()) {
                try {
                    Encoding enc = Encoding.GetEncoding(encInfo.CodePage);
                    string encodingName = enc.EncodingName.ToUpper();

                    // filter noise and duplicates
                    if (encodingName.IndexOf("DOS") != -1 ||
                        encodingName.IndexOf("MAC") != -1 ||
                        encodingName.IndexOf("EBCDIC") != -1 ||
                        encodingName.IndexOf("ISCII") != -1 ||
                        encodingList.Contains(encodingName) ||
                        bodyNameList.Contains(enc.BodyName)) {
                        continue;
                    }
            #if LOG4NET
                    _Logger.Debug("_Load(): adding encoding: " + enc.BodyName);
            #endif
                    encodingList.Add(encodingName);
                    bodyNameList.Add(enc.BodyName);

                    encodingName = enc.EncodingName;
                    // remove all (DOS)  / (Windows) / (Mac) crap from the encoding name
                    if (enc.EncodingName.Contains(" (")) {
                        encodingName = encodingName.Substring(0, enc.EncodingName.IndexOf(" ("));
                    }
                    store.AppendValues(enc.BodyName.ToUpper() + " - " + encodingName, enc.BodyName.ToUpper());
                } catch (NotSupportedException) {
                }
            }
            cb.Model = store;
            cb.Active = 0;
            store.SetSortColumnId(0, Gtk.SortType.Ascending);
            int j = 0;
            foreach (object[] row in store) {
                string encodingName = (string) row[1];
                if (encodingName == encoding) {
                    cb.Active = j;
                    break;
                }
                j++;
            }

            // Interface
            ((Gtk.Entry)_Glade["TimestampFormatEntry"]).Text =
                (string)Frontend.UserConfig["Interface/Notebook/TimestampFormat"];

            // Interface/Notebook
            ((Gtk.SpinButton)_Glade["BufferLinesSpinButton"]).Value =
                (double)(int)Frontend.UserConfig["Interface/Notebook/BufferLines"];
            ((Gtk.SpinButton)_Glade["EngineBufferLinesSpinButton"]).Value =
                (double)(int)Frontend.UserConfig["Interface/Notebook/EngineBufferLines"];
            ((Gtk.CheckButton)_Glade["StripColorsCheckButton"]).Active =
                (bool)Frontend.UserConfig["Interface/Notebook/StripColors"];
            ((Gtk.CheckButton)_Glade["StripFormattingsCheckButton"]).Active =
                (bool)Frontend.UserConfig["Interface/Notebook/StripFormattings"];
            switch ((string)Frontend.UserConfig["Interface/Notebook/TabPosition"]) {
                case "top":
                    ((Gtk.RadioButton)_Glade["TabPositionRadioButtonTop"]).Active = true;
                break;
                case "bottom":
                    ((Gtk.RadioButton)_Glade["TabPositionRadioButtonBottom"]).Active = true;
                break;
                case "left":
                    ((Gtk.RadioButton)_Glade["TabPositionRadioButtonLeft"]).Active = true;
                break;
                case "right":
                    ((Gtk.RadioButton)_Glade["TabPositionRadioButtonRight"]).Active = true;
                break;
                case "none":
                    ((Gtk.RadioButton)_Glade["TabPositionRadioButtonNone"]).Active = true;
                break;
            }

            // Interface/Notebook/Channel
            switch ((string)Frontend.UserConfig["Interface/Notebook/Channel/UserListPosition"]) {
                case "left":
                    ((Gtk.RadioButton)_Glade["UserListPositionRadioButtonLeft"]).Active = true;
                break;
                case "right":
                    ((Gtk.RadioButton)_Glade["UserListPositionRadioButtonRight"]).Active = true;
                break;
                case "none":
                    ((Gtk.RadioButton)_Glade["UserListPositionRadioButtonNone"]).Active = true;
                break;
            }
            switch ((string)Frontend.UserConfig["Interface/Notebook/Channel/TopicPosition"]) {
                case "top":
                    ((Gtk.RadioButton)_Glade["TopicPositionRadioButtonTop"]).Active = true;
                break;
                case "bottom":
                    ((Gtk.RadioButton)_Glade["TopicPositionRadioButtonBottom"]).Active = true;
                break;
                case "none":
                    ((Gtk.RadioButton)_Glade["TopicPositionRadioButtonNone"]).Active = true;
                break;
            }
            ((Gtk.CheckButton) _Glade["NickColorsCheckButton"]).Active =
                (bool) Frontend.UserConfig["Interface/Notebook/Channel/NickColors"];

            // Interface/Notebook/Tab
            Gtk.ColorButton colorButton;
            string colorHexCode;

            colorButton = (Gtk.ColorButton)_Glade["NoActivityColorButton"];
            colorHexCode = (string)Frontend.UserConfig["Interface/Notebook/Tab/NoActivityColor"];
            colorButton.Color = ColorTools.GetGdkColor(colorHexCode);

            colorButton = (Gtk.ColorButton)_Glade["ActivityColorButton"];
            colorHexCode = (string)Frontend.UserConfig["Interface/Notebook/Tab/ActivityColor"];
            colorButton.Color = ColorTools.GetGdkColor(colorHexCode);

            colorButton = (Gtk.ColorButton)_Glade["ModeColorButton"];
            colorHexCode = (string)Frontend.UserConfig["Interface/Notebook/Tab/EventColor"];
            colorButton.Color = ColorTools.GetGdkColor(colorHexCode);

            colorButton = (Gtk.ColorButton)_Glade["HighlightColorButton"];
            colorHexCode = (string)Frontend.UserConfig["Interface/Notebook/Tab/HighlightColor"];
            colorButton.Color = ColorTools.GetGdkColor(colorHexCode);

            // Interface/Chat
            colorButton = (Gtk.ColorButton)_Glade["ForegroundColorButton"];
            colorHexCode = (string)Frontend.UserConfig["Interface/Chat/ForegroundColor"];
            if (String.IsNullOrEmpty(colorHexCode)) {
                ((Gtk.CheckButton)_Glade["OverrideForegroundColorCheckButton"]).Active = false;
            } else {
                ((Gtk.CheckButton)_Glade["OverrideForegroundColorCheckButton"]).Active = true;
                colorButton.Color = ColorTools.GetGdkColor(colorHexCode);
            }

            colorButton = (Gtk.ColorButton)_Glade["BackgroundColorButton"];
            colorHexCode = (string)Frontend.UserConfig["Interface/Chat/BackgroundColor"];
            if (String.IsNullOrEmpty(colorHexCode)) {
                ((Gtk.CheckButton)_Glade["OverrideBackgroundColorCheckButton"]).Active = false;
            } else {
                ((Gtk.CheckButton)_Glade["OverrideBackgroundColorCheckButton"]).Active = true;
                colorButton.Color = ColorTools.GetGdkColor(colorHexCode);
            }

            Gtk.FontButton fontButton = (Gtk.FontButton)_Glade["FontButton"];
            string fontFamily = (string)Frontend.UserConfig["Interface/Chat/FontFamily"];
            string fontStyle = (string)Frontend.UserConfig["Interface/Chat/FontStyle"];
            int fontSize = 0;
            if (Frontend.UserConfig["Interface/Chat/FontSize"] != null) {
                fontSize = (int) Frontend.UserConfig["Interface/Chat/FontSize"];
            }
            if (String.IsNullOrEmpty(fontFamily) &&
                String.IsNullOrEmpty(fontStyle) &&
                fontSize == 0) {
                ((Gtk.CheckButton)_Glade["OverrideFontCheckButton"]).Active = false;
            } else {
                ((Gtk.CheckButton)_Glade["OverrideFontCheckButton"]).Active = true;
                Pango.FontDescription fontDescription = new Pango.FontDescription();
                fontDescription.Family = fontFamily;
                string frontWeigth = null;
                if (fontStyle.Contains(" ")) {
                    int pos = fontStyle.IndexOf(" ");
                    frontWeigth = fontStyle.Substring(0, pos);
                    fontStyle = fontStyle.Substring(pos + 1);
                }
                fontDescription.Style = (Pango.Style) Enum.Parse(typeof(Pango.Style), fontStyle);
                if (frontWeigth != null) {
                    fontDescription.Weight = (Pango.Weight) Enum.Parse(typeof(Pango.Weight), frontWeigth);
                }
                fontDescription.Size = fontSize * 1024;
                fontButton.FontName = fontDescription.ToString();
            }

            Gtk.ComboBox wrapModeComboBox = ((Gtk.ComboBox)_Glade["WrapModeComboBox"]);
            Gtk.WrapMode wrapMode = (Gtk.WrapMode) Enum.Parse(
                typeof(Gtk.WrapMode),
                (string) Frontend.UserConfig["Interface/Chat/WrapMode"]
            );
            int i = 0;
            foreach (object[] row in  (Gtk.ListStore) wrapModeComboBox.Model) {
                if (((Gtk.WrapMode) row[0]) == wrapMode) {
                    wrapModeComboBox.Active = i;
                    break;
                }
                i++;
            }

            // Interface/Entry
            ((Gtk.Entry)_Glade["CompletionCharacterEntry"]).Text =
                (string)Frontend.UserConfig["Interface/Entry/CompletionCharacter"];
            ((Gtk.Entry)_Glade["CommandCharacterEntry"]).Text =
                (string)Frontend.UserConfig["Interface/Entry/CommandCharacter"];
            ((Gtk.CheckButton)_Glade["BashStyleCompletionCheckButton"]).Active =
                (bool)Frontend.UserConfig["Interface/Entry/BashStyleCompletion"];
            ((Gtk.SpinButton)_Glade["CommandHistorySizeSpinButton"]).Value =
                (double)(int)Frontend.UserConfig["Interface/Entry/CommandHistorySize"];

            ((Gtk.CheckButton)_Glade["BeepOnHighlightCheckButton"]).Active =
                (bool)Frontend.UserConfig["Sound/BeepOnHighlight"];

            // Interface/Notification
            string modeStr = (string) Frontend.UserConfig["Interface/Notification/NotificationAreaIconMode"];
            NotificationAreaIconMode mode = (NotificationAreaIconMode) Enum.Parse(
                typeof(NotificationAreaIconMode),
                modeStr
            );
            switch (mode) {
                case NotificationAreaIconMode.Never:
                    ((Gtk.CheckButton) _Glade["NotificationAreaIconCheckButton"]).Active = false;
                    ((Gtk.RadioButton) _Glade["NotificationAreaIconRadioButtonMinimized"]).Active = true;
                    break;
                case NotificationAreaIconMode.Always:
                    ((Gtk.CheckButton) _Glade["NotificationAreaIconCheckButton"]).Active = true;
                    ((Gtk.RadioButton) _Glade["NotificationAreaIconRadioButtonAlways"]).Active = true;
                    break;
                case NotificationAreaIconMode.Minimized:
                    ((Gtk.CheckButton) _Glade["NotificationAreaIconCheckButton"]).Active = true;
                    ((Gtk.RadioButton) _Glade["NotificationAreaIconRadioButtonMinimized"]).Active = true;
                    break;
                case NotificationAreaIconMode.Closed:
                    ((Gtk.CheckButton) _Glade["NotificationAreaIconCheckButton"]).Active = true;
                    ((Gtk.RadioButton) _Glade["NotificationAreaIconRadioButtonClosed"]).Active = true;
                    break;
            }

            // Filters
            _ChannelFilterListView.Load();

            // Servers
            _ServerListView.Load();

            ((Gtk.Button)_Glade["ApplyButton"]).Sensitive = false;
        }
        internal static VBox CreateCategory(string categoryName, string categoryContentMarkup, Cairo.Color foreColor, Pango.FontDescription font)
        {
            var vbox = new VBox();

            vbox.Spacing = 8;

            if (categoryName != null)
            {
                var catLabel = new FixedWidthWrapLabel();
                catLabel.Markup = categoryName;
                catLabel.ModifyFg(StateType.Normal, foreColor.ToGdkColor());
                catLabel.FontDescription        = font.Copy();
                catLabel.FontDescription.Weight = Pango.Weight.Bold;
                catLabel.FontDescription.Size   = catLabel.FontDescription.Size + (int)(1 * Pango.Scale.PangoScale);
                vbox.PackStart(catLabel, false, true, 0);
            }

            var  contentLabel = new FixedWidthWrapLabel();
            HBox hbox         = new HBox();

            // hbox.PackStart (new Label(), false, true, 10);


            contentLabel.Wrap               = Pango.WrapMode.WordChar;
            contentLabel.Spacing            = 1;
            contentLabel.BreakOnCamelCasing = false;
            contentLabel.BreakOnPunctuation = false;
            contentLabel.MaxWidth           = 400;
            contentLabel.Markup             = categoryContentMarkup.Trim();
            contentLabel.ModifyFg(StateType.Normal, foreColor.ToGdkColor());
            contentLabel.FontDescription = font;

            hbox.PackStart(contentLabel, true, true, 0);
            vbox.PackStart(hbox, true, true, 0);

            return(vbox);
        }