Пример #1
0
        public void Render()
        {
            bool   enableProxy = GetValue <bool>("enable_proxy");
            string httpProxy   = GetValue <string>("http_proxy");
            string port        = GetValue <string>("port");

            if (enableProxy)
            {
                Gimp.RcSet("update-enable-proxy", (enableProxy) ? "true" : "false");
                Gimp.RcSet("update-http-proxy", httpProxy);
                Gimp.RcSet("update-port", port);
            }

            var assembly = Assembly.GetAssembly(typeof(Plugin));

            Console.WriteLine(assembly.GetName().Version);

            var doc = new XmlDocument();

            try
            {
                var myRequest = (HttpWebRequest)
                                WebRequest.Create("http://gimp-sharp.sourceforge.net/version.xml");

                // Create a proxy object, needed for mono behind a firewall?!
                if (enableProxy)
                {
                    var myProxy = new WebProxy()
                    {
                        Address = new Uri(httpProxy + ":" + port)
                    };
                    myRequest.Proxy = myProxy;
                }

                var requestState = new RequestState(myRequest);

                // Start the asynchronous request.
                IAsyncResult result = (IAsyncResult)myRequest.BeginGetResponse
                                          (new AsyncCallback(RespCallback), requestState);

                // this line implements the timeout, if there is a timeout,
                // the callback fires and the request becomes aborted
                ThreadPool.RegisterWaitForSingleObject
                    (result.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback),
                    myRequest, DefaultTimeout, true);

                // The response came in the allowed time. The work processing will
                // happen in the callback function.
                allDone.WaitOne();

                // Release the HttpWebResponse resource.
                requestState.Response.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception!");
                Console.WriteLine(e.StackTrace);
                return;
            }
        }
Пример #2
0
        void StopServer()
        {
            AppHost.Stop();
            Gimp.Quit();

            Console.WriteLine("Before stop 1");

            _thread.Abort();
            Console.WriteLine("Before stop 2");
            _thread.Join();

            Console.WriteLine("Stopped!");

            _statusLabel.Text = "Server stopped";
        }
Пример #3
0
        /// <summary>
        /// Lancio GIMP e gli passo l'elenco delle foto indicate
        /// </summary>
        /// <param name="fotografie"></param>
        public Fotografia [] modificaConProgrammaEsterno(Fotografia [] fotografie)
        {
            LanciatoreEditor lanciatore = new LanciatoreEditor(fotografie);

            lanciatore.lancia();

            List <Fotografia> modificate = lanciatore.applicaImmaginiModificate();
            Gimp correzioneGimp          = new Gimp();

            foreach (Fotografia foto in modificate)
            {
                // Ora idrato l'immagine risultante
                AiutanteFoto.idrataImmaginiFoto(foto, IdrataTarget.Risultante);

                addCorrezione(foto, correzioneGimp, false);
            }

            return(modificate.ToArray());
        }
Пример #4
0
        public Dialog(Image image, Drawable drawable, VariableSet variables) :
            base("Photoshop Actions", variables)
        {
            _image    = image;
            _drawable = drawable;

            var vbox = new VBox(false, 12)
            {
                BorderWidth = 12
            };

            VBox.PackStart(vbox, true, true, 0);

            var store = CreateActionTree();

            var sw = new ScrolledWindow()
            {
                HeightRequest = 400
            };

            vbox.PackStart(sw, true, true, 0);

            var view = new TreeView(store);

            sw.Add(view);

            var activeRenderer = new CellRendererToggle()
            {
                Activatable = true
            };
            var columnOne = view.AppendColumn("Enabled", activeRenderer,
                                              new TreeCellDataFunc(RenderActive));

            activeRenderer.Toggled += delegate(object o, ToggledArgs args)
            {
                TreeIter iter;
                var      path = new TreePath(args.Path);
                if (store.GetIter(out iter, path))
                {
                    var executable = store.GetValue(iter, 1) as IExecutable;
                    executable.IsEnabled = !executable.IsEnabled;

                    path.Down();
                    while (store.GetIter(out iter, path))
                    {
                        store.EmitRowChanged(path, iter);
                        path.Next();
                    }
                }
            };

            var textRenderer = new CellRendererText();
            var column       = view.AppendColumn("Set Name", textRenderer,
                                                 new TreeCellDataFunc(RenderText));

            var hbox = new HBox();

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

            var play = new Button(Stock.Execute);

            play.Clicked += delegate
            {
                RenameToBackground();

                var paths = view.Selection.GetSelectedRows();
                var path  = paths[0]; // Assume only 1 is selected

                var indices = path.Indices;

                var actions = _set[indices[0]];

                if (indices.Length > 2)
                {
                    actions.Execute(indices[1], indices[2]);
                    path.Next();
                    view.Selection.SelectPath(path);
                }
                else
                {
                    actions.Execute(indices[1]);
                }
                Gimp.DisplaysFlush();
            };
            hbox.PackStart(play, false, true, 0);

            view.Selection.Changed += delegate
            {
                var paths   = view.Selection.GetSelectedRows();
                var indices = paths[0].Indices;

                play.Sensitive = (indices.Length > 1);
            };

            view.Selection.SetSelectFunction(delegate(TreeSelection selection,
                                                      TreeModel model,
                                                      TreePath path,
                                                      bool path_currently_selected)
            {
                return(path.Indices.Length <= 3);
            },
                                             IntPtr.Zero, null);

            ActionEvent.ActionSetCollection = _set;
        }
Пример #5
0
        public Dialog(VariableSet variables) : base(_("UpdateCheck"), variables)
        {
            var vbox = new VBox(false, 12)
            {
                BorderWidth = 12
            };

            VBox.PackStart(vbox, true, true, 0);

            var table = new GimpTable(4, 3)
            {
                ColumnSpacing = 6, RowSpacing = 6
            };

            vbox.PackStart(table, true, true, 0);

            table.Attach(new GimpCheckButton(_("Check _GIMP"),
                                             GetVariable <bool>("check_gimp")),
                         0, 1, 0, 1);

            table.Attach(new GimpCheckButton(_("Check G_IMP#"),
                                             GetVariable <bool>("check_gimp_sharp")),
                         0, 1, 1, 2);

            table.Attach(new GimpCheckButton(_("Check _Unstable Releases"),
                                             GetVariable <bool>("check_unstable")),
                         0, 1, 2, 3);

            var enableProxy = GetVariable <bool>("enable_proxy");
            var httpProxy   = GetVariable <string>("http_proxy");
            var port        = GetVariable <string>("port");

            string tmp = Gimp.RcQuery("update-enable-proxy");

            enableProxy.Value = (tmp != null || tmp == "true");
            httpProxy.Value   = Gimp.RcQuery("update-http-proxy") ?? "";
            port.Value        = Gimp.RcQuery("update-port") ?? "";

            var expander = new Expander(_("Proxy settings"));
            var proxyBox = new VBox(false, 12);

            proxyBox.Add(new GimpCheckButton(_("Manual proxy configuration"),
                                             enableProxy));

            var hbox = new HBox(false, 12)
            {
                Sensitive = enableProxy.Value
            };

            proxyBox.Add(hbox);

            hbox.Add(new Label(_("HTTP Proxy:")));
            hbox.Add(new GimpEntry(httpProxy));

            hbox.Add(new Label(_("Port:")));
            hbox.Add(new GimpEntry(port)
            {
                WidthChars = 4
            });

            enableProxy.ValueChanged += delegate
            {
                hbox.Sensitive = enableProxy.Value;
            };

            expander.Add(proxyBox);
            table.Attach(expander, 0, 1, 3, 4);
        }