Ejemplo n.º 1
1
		public AppChooserDialog (Gtk.Window parent, Gtk.DialogFlags flags, GLib.IFile file) : base (IntPtr.Zero)
		{
			if (GetType () != typeof (AppChooserDialog)) {
				throw new InvalidOperationException ("Can't override this constructor.");
			}
			Raw = gtk_app_chooser_dialog_new(parent == null ? IntPtr.Zero : parent.Handle, (int) flags, file == null ? IntPtr.Zero : ((file is GLib.Object) ? (file as GLib.Object).Handle : (file as GLib.FileAdapter).Handle));
		}
			public TransactedTreeBuilder (ExtensibleTreeView tree, TransactedNodeStore tstore, Gtk.TreeIter it)
			{
				this.tree = tree;
				this.tstore = tstore;
				navigator = new TreeNodeNavigator (tree, it);
				CheckNode ();
			}
Ejemplo n.º 3
0
 public EntryDialog(string textEntry, string textLabel,Gtk.Window parent)
 {
     if (parent == null){
         parent =MainClass.MainWindow;
     }
     BuildControl(textEntry,textLabel,false,parent);
 }
Ejemplo n.º 4
0
		public static Gdk.Pixbuf LoadIcon (Gtk.Widget widget, string name, Gtk.IconSize size)
		{
			Gdk.Pixbuf res = widget.RenderIcon (name, size, null);
			if ((res != null)) {
				return res;
			} else {
				int sz;
				int sy;
				global::Gtk.Icon.SizeLookup (size, out  sz, out  sy);
				try {
					return Gtk.IconTheme.Default.LoadIcon (name, sz, 0);
				} catch (System.Exception) {
					if ((name != "gtk-missing-image")) {
						return Stetic.IconLoader.LoadIcon (widget, "gtk-missing-image", size);
					} else {
						Gdk.Pixmap pmap = new Gdk.Pixmap (Gdk.Screen.Default.RootWindow, sz, sz);
						Gdk.GC gc = new Gdk.GC (pmap);
						gc.RgbFgColor = new Gdk.Color (255, 255, 255);
						pmap.DrawRectangle (gc, true, 0, 0, sz, sz);
						gc.RgbFgColor = new Gdk.Color (0, 0, 0);
						pmap.DrawRectangle (gc, false, 0, 0, (sz - 1), (sz - 1));
						gc.SetLineAttributes (3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round);
						gc.RgbFgColor = new Gdk.Color (255, 0, 0);
						pmap.DrawLine (gc, (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)), ((sz - 1) - (sz / 4)));
						pmap.DrawLine (gc, ((sz - 1) - (sz / 4)), (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)));
						return Gdk.Pixbuf.FromDrawable (pmap, pmap.Colormap, 0, 0, 0, 0, sz, sz);
					}
				}
			}
		}
Ejemplo n.º 5
0
		internal static void Initialize(Gtk.Widget iconRenderer)
		{
			if ((Stetic.Gui.initialized == false))
			{
				Stetic.Gui.initialized = true;
			}
		}
Ejemplo n.º 6
0
        public ServerDialog(Gtk.Window parent, ServerModel server,
                            IList<string> supportedProtocols,
                            IList<string> networks)
            : base(null, parent, Gtk.DialogFlags.DestroyWithParent)
        {
            Trace.Call(parent, server, supportedProtocols, networks);

            if (parent == null) {
                throw new ArgumentNullException("parent");
            }
            if (supportedProtocols == null) {
                throw new ArgumentNullException("supportedProtocols");
            }
            if (networks == null) {
                throw new ArgumentNullException("networks");
            }

            Build();
            TransientFor = parent;

            f_Widget.InitProtocols(supportedProtocols);
            f_Widget.InitNetworks(networks);
            if (server != null) {
                try {
                    f_Widget.Load(server);
                } catch (Exception) {
                    Destroy();
                    throw;
                }
            }
        }
Ejemplo n.º 7
0
		AppResult GenerateChildrenForContainer (Gtk.Container container, List<AppResult> resultSet)
		{
			AppResult firstChild = null, lastChild = null;

			foreach (var child in container.Children) {
				AppResult node = new GtkWidgetResult (child) { SourceQuery = ToString () };
				resultSet.Add (node);

				// FIXME: Do we need to recreate the tree structure of the AppResults?
				if (firstChild == null) {
					firstChild = node;
					lastChild = node;
				} else {
					lastChild.NextSibling = node;
					node.PreviousSibling = lastChild;
					lastChild = node;
				}

				if (child is Gtk.Container) {
					AppResult children = GenerateChildrenForContainer ((Gtk.Container)child, resultSet);
					node.FirstChild = children;
				}
			}

			return firstChild;
		}
Ejemplo n.º 8
0
		protected override void ReplaceChild (Gtk.Widget oldChild, Gtk.Widget newChild)
		{
			if (oldChild == expander.LabelWidget)
				expander.LabelWidget = newChild;
			else
				base.ReplaceChild (oldChild, newChild);
		}
Ejemplo n.º 9
0
        public void BuildToolbar (Gtk.Toolbar tb)
        {
            if (selection_label == null)
                selection_label = new ToolBarLabel (Catalog.GetString (" Selection Mode: "));

            tb.AppendItem (selection_label);

            if (selection_combo_box == null)
            {
                selection_combo_box = new ToolBarComboBox (170, 0, false);

                selection_combo_box.ComboBox.Changed += (o, e) =>
                {
                    Gtk.TreeIter iter;
                    if (selection_combo_box.ComboBox.GetActiveIter (out iter))
                        selected_mode = (CombineMode)selection_combo_box.Model.GetValue (iter, 1);
                };

                foreach (var mode in combine_modes)
                    selection_combo_box.Model.AppendValues (mode.Value, mode.Key);

                selection_combo_box.ComboBox.Active = 0;
            }

            tb.AppendItem (selection_combo_box);
        }
Ejemplo n.º 10
0
 public Toolbar(Gtk.Box main_hbox, Gtk.Box framework_vbox)
 {
     this.main_hbox = main_hbox;
     this.framework_vbox = framework_vbox;
     ToolbarStyle = ToolbarStyle.Both;
     BuildToolBar ();
 }
Ejemplo n.º 11
0
        public static void MoveBy(Gtk.Window window, int x, int y)
        {
            int winX, winY;

            window.GetPosition(out winX, out winY);
            window.Move(winX + x, winY + y);
        }
Ejemplo n.º 12
0
		protected override void OnSizeRequested (ref Gtk.Requisition requisition)
		{
			if (image != null) {
				requisition.Width = (int)(image.Width * IconScale);
				requisition.Height = (int)(image.Height * IconScale);
			}
		}
Ejemplo n.º 13
0
 void OnPosition(Gtk.Menu menu, out int x, out int y, out bool pushIn)
 {
     this.ParentWindow.GetOrigin (out x, out y);
     x += this.Allocation.X;
     y += this.Allocation.Y + this.Allocation.Height;
     pushIn = true;
 }
Ejemplo n.º 14
0
        public static void ReplaceChild(Gtk.Widget oldWidget, Gtk.Widget newWidget)
        {
            Gtk.Container cont = oldWidget.Parent as Gtk.Container;
            if (cont == null)
                return;

            if (cont is IGtkContainer) {
                ((IGtkContainer)cont).ReplaceChild (oldWidget, newWidget);
            }
            else if (cont is Gtk.Notebook) {
                Gtk.Notebook notebook = (Gtk.Notebook) cont;
                Gtk.Notebook.NotebookChild nc = (Gtk.Notebook.NotebookChild) notebook[oldWidget];
                var detachable = nc.Detachable;
                var pos = nc.Position;
                var reorderable = nc.Reorderable;
                var tabExpand = nc.TabExpand;
                var tabFill = nc.TabFill;
                var label = notebook.GetTabLabel (oldWidget);
                notebook.Remove (oldWidget);
                notebook.InsertPage (newWidget, label, pos);

                nc = (Gtk.Notebook.NotebookChild) notebook[newWidget];
                nc.Detachable = detachable;
                nc.Reorderable = reorderable;
                nc.TabExpand = tabExpand;
                nc.TabFill = tabFill;
            }
            else if (cont is Gtk.Bin) {
                ((Gtk.Bin)cont).Remove (oldWidget);
                ((Gtk.Bin)cont).Child  = newWidget;
            }
        }
Ejemplo n.º 15
0
		internal static void Initialize (Gtk.Widget iconRenderer)
		{
			if ((Stetic.Gui.initialized == false)) {
				Stetic.Gui.initialized = true;
				global::Gtk.IconFactory w1 = new global::Gtk.IconFactory ();
				global::Gtk.IconSet w2 = new global::Gtk.IconSet (global::Gdk.Pixbuf.LoadFromResource ("MyNesGTK.resources.MyNes.ico"));
				w1.Add ("MyNesIcon", w2);
				global::Gtk.IconSet w3 = new global::Gtk.IconSet (global::Gdk.Pixbuf.LoadFromResource ("MyNesGTK.resources.monitor.png"));
				w1.Add ("VideoSettings", w3);
				global::Gtk.IconSet w4 = new global::Gtk.IconSet (global::Gdk.Pixbuf.LoadFromResource ("MyNesGTK.resources.sound.png"));
				w1.Add ("Audio", w4);
				global::Gtk.IconSet w5 = new global::Gtk.IconSet (global::Gdk.Pixbuf.LoadFromResource ("MyNesGTK.resources.folder_wrench.png"));
				w1.Add ("Paths", w5);
				global::Gtk.IconSet w6 = new global::Gtk.IconSet (global::Gdk.Pixbuf.LoadFromResource ("MyNesGTK.resources.wrench.png"));
				w1.Add ("Preferences", w6);
				global::Gtk.IconSet w7 = new global::Gtk.IconSet (global::Gdk.Pixbuf.LoadFromResource ("MyNesGTK.resources.color_wheel.png"));
				w1.Add ("Palette", w7);
				global::Gtk.IconSet w8 = new global::Gtk.IconSet (global::Gdk.Pixbuf.LoadFromResource ("MyNesGTK.resources.controller.png"));
				w1.Add ("Input", w8);
				global::Gtk.IconSet w9 = new global::Gtk.IconSet (global::Gdk.Pixbuf.LoadFromResource ("MyNesGTK.resources.control_play.png"));
				w1.Add ("Play", w9);
				global::Gtk.IconSet w10 = new global::Gtk.IconSet (global::Gdk.Pixbuf.LoadFromResource ("MyNesGTK.resources.control_eject.png"));
				w1.Add ("Stop", w10);
				w1.AddDefault ();
			}
		}
Ejemplo n.º 16
0
		public Scrollbar (Gtk.Orientation orientation, Gtk.Adjustment adjustment) : base (IntPtr.Zero)
		{
			if (GetType () != typeof (Scrollbar)) {
				throw new InvalidOperationException ("Can't override this constructor.");
			}
			Raw = gtk_scrollbar_new((int) orientation, adjustment == null ? IntPtr.Zero : adjustment.Handle);
		}
Ejemplo n.º 17
0
 public void Replace(Gtk.Bin parent)
 {
     Gtk.Widget c = parent.Child;
     parent.Remove (c);
     Add (c);
     parent.Add (this);
 }
 public void Put(Gtk.Widget widget, int x, int y)
 {
     children.Add (new LayoutChild (widget, x, y));
     if (IsRealized)
         widget.ParentWindow = GdkWindow;
     widget.Parent = this;
 }
Ejemplo n.º 19
0
 internal static void Initialize(Gtk.Widget iconRenderer)
 {
     if ((Stetic.Gui.initialized == false)) {
         Stetic.Gui.initialized = true;
         global::Gtk.IconFactory w1 = new global::Gtk.IconFactory ();
         global::Gtk.IconSet w2 = new global::Gtk.IconSet (global::Gdk.Pixbuf.LoadFromResource ("DCPPacker.resources.page_white_add.png"));
         w1.Add ("page-white-add", w2);
         global::Gtk.IconSet w3 = new global::Gtk.IconSet (global::Gdk.Pixbuf.LoadFromResource ("DCPPacker.resources.folder_add.png"));
         w1.Add ("folder-add", w3);
         global::Gtk.IconSet w4 = new global::Gtk.IconSet (global::Gdk.Pixbuf.LoadFromResource ("DCPPacker.resources.page_white_delete.png"));
         w1.Add ("page-white-delete", w4);
         global::Gtk.IconSet w5 = new global::Gtk.IconSet (global::Gdk.Pixbuf.LoadFromResource ("DCPPacker.resources.page_white_copy.png"));
         w1.Add ("page-white-copy", w5);
         global::Gtk.IconSet w6 = new global::Gtk.IconSet (global::Gdk.Pixbuf.LoadFromResource ("DCPPacker.resources.folder_delete.png"));
         w1.Add ("folder-delete", w6);
         global::Gtk.IconSet w7 = new global::Gtk.IconSet (global::Gdk.Pixbuf.LoadFromResource ("DCPPacker.resources.page_white_zip.png"));
         w1.Add ("page-white-zip", w7);
         global::Gtk.IconSet w8 = new global::Gtk.IconSet (global::Gdk.Pixbuf.LoadFromResource ("DCPPacker.resources.page_white_stack.png"));
         w1.Add ("page-white-stack", w8);
         global::Gtk.IconSet w9 = new global::Gtk.IconSet (global::Gdk.Pixbuf.LoadFromResource ("DCPPacker.resources.package.png"));
         w1.Add ("package", w9);
         global::Gtk.IconSet w10 = new global::Gtk.IconSet (global::Gdk.Pixbuf.LoadFromResource ("DCPPacker.resources.package_add.png"));
         w1.Add ("package-add", w10);
         global::Gtk.IconSet w11 = new global::Gtk.IconSet (global::Gdk.Pixbuf.LoadFromResource ("DCPPacker.resources.package_delete.png"));
         w1.Add ("package-delete", w11);
         global::Gtk.IconSet w12 = new global::Gtk.IconSet (global::Gdk.Pixbuf.LoadFromResource ("DCPPacker.resources.folder.png"));
         w1.Add ("folder", w12);
         global::Gtk.IconSet w13 = new global::Gtk.IconSet (global::Gdk.Pixbuf.LoadFromResource ("DCPPacker.resources.disk.png"));
         w1.Add ("disk", w13);
         w1.AddDefault ();
     }
 }
Ejemplo n.º 20
0
        private void BankNumber_Edited(object o, Gtk.EditedArgs args)
        {
            // Set and Get data
            Gtk.TreeIter iter;
            Gtk.TreePath treepath = new Gtk.TreePath (args.Path);
            Gtk.CellRendererText nextCell = (Gtk.CellRendererText)checktableview.columnList [(int)ColumnType.BRANCH_NUMBER].Cell;
            Gtk.TreeViewColumn nextColumn = checktableview.columnList [(int)ColumnType.BRANCH_NUMBER].Column;
            string text = args.NewText;

            checkPropsList.GetIter (out iter, treepath);

            BL.CheckClass check = (BL.CheckClass)checkPropsList.GetValue (iter, 0);
            String formattedNumber = BL.Formatter.ZeroPad (text, BL.Constants.LENGTH_NUM_BANK);

            if (formattedNumber != null) {
                check.BankNumber = formattedNumber;
                // Move to next cell
                checktableview.SetCursorOnCell (treepath, nextColumn, nextCell, true);
            } else if (!text.Equals ("")) {
                Gtk.MessageDialog dialog = InvalidEntryDialog ("Número de banco inválido!");
                Gtk.ResponseType result = (Gtk.ResponseType)dialog.Run ();
                if (result == Gtk.ResponseType.Ok)
                    dialog.Destroy ();
            }
        }
Ejemplo n.º 21
0
		public AutoHideBox (DockFrame frame, DockItem item, Gtk.PositionType pos, int size)
		{
			this.position = pos;
			this.frame = frame;
			this.targetSize = size;
			horiz = pos == PositionType.Left || pos == PositionType.Right;
			startPos = pos == PositionType.Top || pos == PositionType.Left;
			Events = Events | Gdk.EventMask.EnterNotifyMask | Gdk.EventMask.LeaveNotifyMask;
			
			Box fr;
			CustomFrame cframe = new CustomFrame ();
			switch (pos) {
				case PositionType.Left: cframe.SetMargins (1, 1, 0, 1); break;
				case PositionType.Right: cframe.SetMargins (1, 1, 1, 0); break;
				case PositionType.Top: cframe.SetMargins (0, 1, 1, 1); break;
				case PositionType.Bottom: cframe.SetMargins (1, 0, 1, 1); break;
			}
			EventBox sepBox = new EventBox ();
			cframe.Add (sepBox);
			
			if (horiz) {
				fr = new HBox ();
				sepBox.Realized += delegate { sepBox.GdkWindow.Cursor = resizeCursorW; };
				sepBox.WidthRequest = gripSize;
			} else {
				fr = new VBox ();
				sepBox.Realized += delegate { sepBox.GdkWindow.Cursor = resizeCursorH; };
				sepBox.HeightRequest = gripSize;
			}
			
			sepBox.Events = EventMask.AllEventsMask;
			
			if (pos == PositionType.Left || pos == PositionType.Top)
				fr.PackEnd (cframe, false, false, 0);
			else
				fr.PackStart (cframe, false, false, 0);

			Add (fr);
			ShowAll ();
			Hide ();
			
			scrollable = new ScrollableContainer ();
			scrollable.ScrollMode = false;
			scrollable.Show ();

			if (item.Widget.Parent != null) {
				((Gtk.Container)item.Widget.Parent).Remove (item.Widget);
			}

			item.Widget.Show ();
			scrollable.Add (item.Widget);
			fr.PackStart (scrollable, true, true, 0);
			
			sepBox.ButtonPressEvent += OnSizeButtonPress;
			sepBox.ButtonReleaseEvent += OnSizeButtonRelease;
			sepBox.MotionNotifyEvent += OnSizeMotion;
			sepBox.ExposeEvent += OnGripExpose;
			sepBox.EnterNotifyEvent += delegate { insideGrip = true; sepBox.QueueDraw (); };
			sepBox.LeaveNotifyEvent += delegate { insideGrip = false; sepBox.QueueDraw (); };
		}
Ejemplo n.º 22
0
		public MainWindow(Gtk.NodeStore noteStore)
			: base(Gtk.WindowType.Toplevel)
		{
			Build();
			this.noteStore = noteStore;
			SetupUi();
		}
Ejemplo n.º 23
0
        public RatingFilterDialog(FSpot.PhotoQuery query, Gtk.Window parent_window)
            : base("RatingFilterDialog.ui", "rating_filter_dialog")
        {
            this.query = query;
            this.parent_window = parent_window;
            TransientFor = parent_window;
            DefaultResponse = ResponseType.Ok;
            ok_button.GrabFocus ();

            if (query.RatingRange != null) {
                minrating_value = (int) query.RatingRange.MinRating;
                maxrating_value = (int) query.RatingRange.MaxRating;
            }
            minrating = new Rating (minrating_value);
            maxrating = new Rating (maxrating_value);
            minrating_hbox.PackStart (minrating, false, false, 0);
            maxrating_hbox.PackStart (maxrating, false, false, 0);

            ResponseType response = (ResponseType) Run ();

            if (response == ResponseType.Ok) {
                query.RatingRange = new RatingRange ((uint) minrating.Value, (uint) maxrating.Value);
            }

            Destroy ();
        }
Ejemplo n.º 24
0
 public GtkListTreeView(Gtk.TreeView tree)
     : base()
 {
     Tree = tree;
     SkipFirstChildrow = false;
     Tree.WidgetEventAfter += HandleWidgetEventAfter;
 }
Ejemplo n.º 25
0
        protected void on_new_key_release(System.Object sender, Gtk.KeyReleaseEventArgs e)
        {
            VoidFunction<Widget> on_element_found = null;

            if (e.Event.Key == Gdk.Key.Escape) // cancel
            {
                on_element_found = delegate(Widget w) { w.Destroy(); };
            }
            else if (e.Event.Key == Gdk.Key.Return || e.Event.Key == Gdk.Key.KP_Enter) // ok
            {
                on_element_found = delegate(Widget w) {
                    if (w.Name == "new_label") {
                        string text = ((Gtk.Entry)w).Text;

                        if (category.exists(text))
                            return;

                        category.add_label(text);
                    }
                };
            }

            if (on_element_found != null) // do it
                foreach (Gtk.Widget w in representation)
                    if (w.Name == "new_label") {
                        on_element_found(w);
                        break;
                    }
        }
Ejemplo n.º 26
0
		protected override void OnSizeRequested (ref Gtk.Requisition requisition)
		{
			base.OnSizeRequested (ref requisition);
			int totalWidth = 1;
			int totalHeight = yBorder * 2 + 1;
			
			int width, height;
			layout.SetText (TitleText);
			layout.GetPixelSize (out width, out height);
			totalHeight += height;
			xSpacer = 0;
			foreach (var pair in Items) {
				int w1, w2;
				layout.SetMarkup (pair.Key);
				layout.GetPixelSize (out w1, out height);

				layout.SetMarkup (pair.Value);
				layout.GetPixelSize (out w2, out height);
				totalWidth = System.Math.Max (totalWidth, w1 + w2 + xBorder * 4 + 1);
				xSpacer = System.Math.Max (xSpacer, w1 + xBorder * 2 + 1);
				
				totalHeight += height;
			}
			
			requisition.Width = totalWidth;
			requisition.Height = totalHeight;
		}
Ejemplo n.º 27
0
    //comes from gui/stats.cs
    public StatType(string statisticType, string statisticSubType, string statisticApplyTo, Gtk.TreeView treeview_stats,
			ArrayList sendSelectedSessions, bool sex_active, int statsJumpsType, int limit, 
			ArrayList markedRows, int evolution_mark_consecutives, GraphROptions gRO,
			bool graph, bool toReport, Preferences preferences)
    {
        //some of this will disappear when we use myStatTypeStruct in all classes:
        this.statisticType = statisticType;
        this.statisticSubType = statisticSubType;
        this.statisticApplyTo = statisticApplyTo;
        this.treeview_stats = treeview_stats ;

        this.markedRows = markedRows;

        this.evolution_mark_consecutives = evolution_mark_consecutives;

        this.graph = graph;
        this.toReport = toReport;

        myStatTypeStruct = new StatTypeStruct (
                statisticApplyTo,
                sendSelectedSessions, sex_active,
                statsJumpsType, limit,
                markedRows, gRO,
                toReport, preferences);

        myStat = new Stat(); //create an instance of myStat

        fakeButtonRowCheckedUnchecked = new Gtk.Button();
        fakeButtonRowsSelected = new Gtk.Button();
        fakeButtonNoRowsSelected = new Gtk.Button();
    }
Ejemplo n.º 28
0
        public static void Shake(Gtk.Window window, int times)
        {
            int winX, winY;

            Gtk.Application.Invoke(delegate {
                window.GetPosition(out winX, out winY);

                for (int i=10; i > 0; i--) {
                    for (int j=times; j > 0; j--) {
                        MoveBy(window, 0, i);
                        TimeUtils.Sleep(5);

                        MoveBy(window, i, 0);
                        TimeUtils.Sleep(5);

                        MoveBy(window, 0, -i);
                        TimeUtils.Sleep(5);

                        MoveBy(window, -i, 0);
                        TimeUtils.Sleep(5);
                    }
                }

                window.Move(winX, winY);
            });
        }
Ejemplo n.º 29
0
		public object GetValue (Gtk.TreeIter iter, int column) {
			GLib.Value val = GLib.Value.Empty;
			GetValue (iter, column, ref val);
			object ret = val.Val;
			val.Dispose ();
			return ret;
		}
Ejemplo n.º 30
0
		protected override void OnParentSet (Gtk.Widget parent)
		{
			base.OnParentSet (parent);
			if (Parent == null) return;

			((ICommandUserItem)this).Update (new CommandTargetRoute ());
		}
Ejemplo n.º 31
0
 public void Exit()
 {
     if (!hasExited)
     {
         hasExited = true;
         Gtk.Quit();
     }
 }
Ejemplo n.º 32
0
        private static void Init()
        {
            var argv = IntPtr.Zero;
            int argc = 0;

            if (!Gtk.Init(ref argc, ref argv))
            {
                throw new InvalidOperationException("Could not initialize GTK+");
            }
        }
Ejemplo n.º 33
0
        /// <summary>
        /// 点赞
        /// </summary>
        /// <param name="scrapingBrowser"></param>
        /// <param name="htmlStr"></param>
        private void Praise(ScrapingBrowser scrapingBrowser, string htmlStr)
        {
            var cookie = scrapingBrowser.GetCookie(new Uri(IndexPage), "skey");

            if (cookie == null)
            {
                RunStatus = RunStatus.Fail;
                QqProvider.Instance.UpdateRunStatus(Id, RunStatus.Fail);

                CodeStatus = CodeStatus.NeedCode;
                QqProvider.Instance.UpdateCodeStatus(Id, CodeStatus.NeedCode);

                Log4Logger.Error(UserName + ":skey为空了");
                QqMsgLogger.LogError(UserName + ":skey为空了");
                return;
            }
            var gtk = Gtk.GetGtk(cookie.Value);

            PraiseUrl = string.Format(PraiseUrl, gtk);

            var document = new HtmlDocument();

            document.LoadHtml(htmlStr);

            var list = document.DocumentNode.CssSelect("li.f-single");

            if (!list.Any())
            {
                QqMsgLogger.LogInfo(UserName + " :li.f-single 找不到点赞的模块");
                Log4Logger.Info(UserName + " :li.f-single 找不到点赞的模块.\r\n" + htmlStr);
                if (document.DocumentNode.CssSelect("i.ico_login").Any())
                {
                    RunStatus = RunStatus.Fail;
                    QqProvider.Instance.UpdateRunStatus(Id, RunStatus.Fail);

                    CodeStatus = CodeStatus.NeedCode;
                    QqProvider.Instance.UpdateCodeStatus(Id, CodeStatus.NeedCode);
                }
                return;
            }
            else
            {
                var isContinue = htmlStr.Contains("g_ic_fpfeedsType='friend',");
                if (!isContinue)
                {
                    //其它角色对用户进行点赞评论后会跳转到与我相关页面,这时候再请求一次
                    //QqMsgLogger.LogInfo(UserName + " 有人关注,需要重新定位到主页.");
                    //_miniBrowser.DownloadString(IndexPage, Praise);
                    return;
                }
            }
            foreach (var htmlNode in list)
            {
                if (htmlNode == null || string.IsNullOrWhiteSpace(htmlNode.InnerHtml))
                {
                    continue;
                }
                try
                {
                    var nameNode   = htmlNode.CssSelect("a.f-name");
                    var praiseNode = htmlNode.CssSelect("a.qz_like_btn_v3").FirstOrDefault();
                    if (praiseNode != null && praiseNode.Attributes["data-clicklog"] != null &&
                        praiseNode.Attributes["data-clicklog"].Value == "like")
                    {
                        Thread.Sleep(1000);
                        Log4Logger.Info(UserName + "为《" + nameNode.First().InnerHtml + "》点赞!");
                        var unikey   = praiseNode.Attributes["data-unikey"].Value;
                        var curkey   = praiseNode.Attributes["data-curkey"].Value;
                        var postForm = new NameValueCollection();
                        postForm["qzreferrer"] = IndexPage;
                        postForm["opuin"]      = UserName;
                        postForm["unikey"]     = unikey;
                        postForm["curkey"]     = curkey;
                        postForm["from"]       = "1";
                        postForm["appid"]      = "311";
                        postForm["typeid"]     = "0";
                        postForm["abstime"]    = "1423372434";
                        postForm["fid"]        = "3611d32392f0d654e5a20900";
                        postForm["active"]     = "0";
                        postForm["fupdate"]    = "1";
                        scrapingBrowser.NavigateTo(PraiseUrl, postForm, Success, HttpVerb.Post);
                    }
                    else if (praiseNode == null)
                    {
                        QqMsgLogger.LogInfo(UserName + " :a.qz_like_btn_v3 没有找到点赞的按钮");
                        //Log4Logger.Info(UserName + " :a.qz_like_btn_v3 没有找到点赞的按钮.\r\n" + htmlStr);
                    }
                    else if (praiseNode.Attributes["data-clicklog"] == null)
                    {
                        QqMsgLogger.LogInfo(UserName + " :data-clicklog 没有找到点赞的按钮");
                        Log4Logger.Info(UserName + " :data-clicklog 没有找到点赞的按钮.\r\n" + htmlStr);
                    }
                }
                catch (Exception ex)
                {
                    Log4Logger.Error(UserName + " 点赞失败!\r\n" + htmlStr, ex);
                    QqMsgLogger.LogError(UserName + " 点赞失败!" + ex.Message, ex);
                }
            }
            RunStatus = RunStatus.Sucess;
            QqProvider.Instance.UpdateRunStatus(Id, RunStatus.Sucess);
        }
Ejemplo n.º 34
0
        static int Main()
        {
            var app = Application.New("de.uriegel.test");

            if (Environment.CurrentDirectory.Contains("netcoreapp"))
            {
                Environment.CurrentDirectory = Path.Combine(Environment.CurrentDirectory, "../../../");
            }

            Application.AddActions(app, new [] {
                new GtkAction("destroy", () => Application.Quit(app), "<Ctrl>Q"),
                new GtkAction("menuopen", () => {
                    var dialog = Dialog.NewFileChooser("Datei öffnen", window, Dialog.FileChooserAction.Open,
                                                       "_Abbrechen", Dialog.ResponseId.Cancel, "_Öffnen", Dialog.ResponseId.Ok, IntPtr.Zero);
                    var res = Dialog.Run(dialog);
                    if (res == Dialog.ResponseId.Ok)
                    {
                        var ptr     = Dialog.FileChooserGetFileName(dialog);
                        string file = Marshal.PtrToStringUTF8(ptr);
                        Console.WriteLine(file);
                        GObject.Free(ptr);
                    }
                    Widget.Destroy(dialog);
                }),
                new GtkAction("test", () => Console.WriteLine("Ein Test"), "F6"),
                new GtkAction("test2", () => Console.WriteLine("Ein Test 2")),
                new GtkAction("test3", () => HeaderBar.SetSubtitle(headerBar, "Das ist der neue Subtitle"), "F5"),
                new GtkAction("showhidden", true,
                              (a, s) =>
                {
                    var state = GtkAction.HandleBoolState(a, s);
                    Console.WriteLine(state);
                }, "<Ctrl>H"),
                new GtkAction("theme", "yaru",
                              (a, s) =>
                {
                    var state = GtkAction.HandleStringState(a, s);
                    Console.WriteLine(state);
                })
            });

            var ret = Application.Run(app, () => {
                var type  = Gtk.GuessContentType("/home/uwe/Dokumente/hypovereinsbank.pdf");
                var type1 = Gtk.GuessContentType("x.fs");
                var type2 = Gtk.GuessContentType("x.cs");
                type      = Gtk.GuessContentType("x.pdf");
                var icon  = Icon.Get(type);
                var theme = Theme.GetDefault();
                var names = Icon.GetNames(icon);
                // GTK_ICON_LOOKUP_FORCE_SVG
                var iconInfo = Theme.ChooseIcon(theme, names, 48, IconInfo.Flags.ForceSvg);
                var filename = IconInfo.GetFileName(iconInfo);
                var text     = Marshal.PtrToStringUTF8(filename);
                GObject.Unref(icon);

                var builder = Builder.New();
                var res     = Builder.AddFromFile(builder, "glade", IntPtr.Zero);
                window      = Builder.GetObject(builder, "window");
                headerBar   = Builder.GetObject(builder, "headerbar");
                Builder.ConnectSignals(builder, (IntPtr builder, IntPtr obj, string signal, string handleName, IntPtr connectObj, int flags) =>
                {
                    switch (handleName)
                    {
                    case "app.delete":
                        Gtk.SignalConnectObject <BoolFunc>(obj, signal, () => {
                            return(false);
                        }, connectObj);
                        break;
                    }
                });
                GObject.Unref(builder);

                Application.AddWindow(app, window);

                Window.SetTitle(window, "Web View 😎😎👌");
                Window.SetDefaultSize(window, 300, 300);
                Widget.SetSizeRequest(window, 200, 100);
                Window.Move(window, 2900, 456);

                var webView  = WebKit.New();
                var settings = WebKit.GetSettings(webView);
                GObject.SetBool(settings, "enable-developer-extras", true);
                Container.Add(window, webView);

                var target = TargetEntry.New("text/plain", TargetEntry.Flags.OtherApp, 0);
                DragDrop.UnSet(webView);
                DragDrop.SetDestination(window, DragDrop.DefaultDestination.Drop | DragDrop.DefaultDestination.Highlight | DragDrop.DefaultDestination.Motion,
                                        target, 1, DragDrop.DragActions.Move);
                TargetEntry.Free(target);
                Gtk.SignalConnect <DragDataReceivedFunc>(window, "drag-data-received",
                                                         (w, context, x, y, data) =>
                {
                    var text = SelectionData.GetText(data);
                    Console.WriteLine(text);
                }
                                                         );

                Gtk.SignalConnect <DragMotionFunc>(window, "drag-motion",
                                                   (w, context, x, y) =>
                {
                    Console.WriteLine("motion");
                }
                                                   );

                Gtk.SignalConnect <BoolFunc>(window, "delete_event", () => false);// true cancels the destroy request!
                Gtk.SignalConnect <ConfigureEventFunc>(window, "configure_event", (w, e) => {
                    var evt = Marshal.PtrToStructure <ConfigureEvent>(e);
                    Console.WriteLine("Configure " + evt.Width.ToString() + " " + evt.Height.ToString());

                    Window.GetSize(window, out var ww, out var hh);
                    Console.WriteLine("Configure- " + ww.ToString() + " " + hh.ToString());

                    return(false);
                });

                ScriptDialogFunc scripDialogFunc = (_, dialog) => {
                    var ptr  = WebKit.ScriptDialogGetMessage(dialog);
                    var text = Marshal.PtrToStringUTF8(ptr);
                    switch (text)
                    {
                    case "anfang":
                        WebKit.RunJavascript(webView, "var affe = 'Ein Äffchen'");
                        break;

                    case "devTools":
                        var inspector = WebKit.GetInspector(webView);
                        WebKit.InspectorShow(inspector);
                        break;

                    default:
                        Console.WriteLine($"---ALERT--- {text}");
                        break;
                    }
                    return(true);
                };
                Gtk.SignalConnect(webView, "script-dialog", scripDialogFunc);
                Gtk.SignalConnect <BoolFunc>(webView, "context-menu", () => true);
                Widget.ShowAll(window);

                //WebKit.LoadUri(webView, "https://google.de");
                WebKit.LoadUri(webView, "http://localhost:3000/");
                // WebKit.LoadUri(webView, $"file://{System.IO.Directory.GetCurrentDirectory()}/../webroot/index.html");
            });
Ejemplo n.º 35
0
 static partial void ExitImpl()
 {
     Gtk.Quit();
 }
Ejemplo n.º 36
0
 static partial void RunImpl()
 {
     Gtk.Main();
 }
Ejemplo n.º 37
0
 public void Run()
 {
     Gtk.Main();
 }