Beispiel #1
0
        void EnableDragFrom()
        {
            // we dont really want to offer the drag to anything, merely pretend to, so we set a mimetype nothing takes
            TargetEntry te = new TargetEntry("text/docky-uri-list", TargetFlags.App, 0);

            Gtk.Drag.SourceSet(Owner, Gdk.ModifierType.Button1Mask, new[] { te }, DragAction.Private);
        }
Beispiel #2
0
 private void LocalDetectChanges()
 {
     if (!Metadata.IsDependentToPrincipal())
     {
         TargetEntry?.DetectChanges();
     }
 }
        public async Task <TargetEntry> GetTarget(string name)
        {
            TargetEntry result = null;

            result = await Repository.GetTarget(name);

            return(result);
        }
Beispiel #4
0
        /// <summary>Default constructor for ExplorerView</summary>
        public ExplorerView(ViewBase owner) : base(owner)
        {
            Builder builder = BuilderFromResource("ApsimNG.Resources.Glade.ExplorerView.glade");

            vbox1                    = (VBox)builder.GetObject("vbox1");
            toolStrip                = (Toolbar)builder.GetObject("toolStrip");
            treeview1                = (TreeView)builder.GetObject("treeview1");
            RightHandView            = (Viewport)builder.GetObject("RightHandView");
            _mainWidget              = vbox1;
            RightHandView.ShadowType = ShadowType.EtchedOut;
            treeview1.Model          = treemodel;
            TreeViewColumn     column     = new TreeViewColumn();
            CellRendererPixbuf iconRender = new Gtk.CellRendererPixbuf();

            column.PackStart(iconRender, false);
            textRender                 = new Gtk.CellRendererText();
            textRender.Editable        = false;
            textRender.EditingStarted += OnBeforeLabelEdit;
            textRender.Edited         += OnAfterLabelEdit;
            column.PackStart(textRender, true);
            column.SetCellDataFunc(textRender, OnSetCellData);

            CellRendererText tickCell = new CellRendererText();

            tickCell.Editable = false;
            column.PackEnd(tickCell, false);
            column.SetAttributes(iconRender, "pixbuf", 1);
            column.SetAttributes(textRender, "text", 0);
            column.SetAttributes(tickCell, "text", 3);
            // column.SetCellDataFunc(textRender, treecelldatafunc);
            treeview1.AppendColumn(column);
            treeview1.TooltipColumn = 2;

            treeview1.CursorChanged      += OnAfterSelect;
            treeview1.ButtonReleaseEvent += OnButtonUp;
            treeview1.ButtonPressEvent   += OnButtonPress;
            treeview1.RowActivated       += OnRowActivated;

            TargetEntry[] target_table = new TargetEntry[] {
                new TargetEntry(modelMime, TargetFlags.App, 0)
            };

            Gdk.DragAction actions = Gdk.DragAction.Copy | Gdk.DragAction.Link | Gdk.DragAction.Move;
            // treeview1.EnableModelDragDest(target_table, actions);
            // treeview1.EnableModelDragSource(Gdk.ModifierType.Button1Mask, target_table, actions);
            Drag.SourceSet(treeview1, Gdk.ModifierType.Button1Mask, target_table, actions);
            Drag.DestSet(treeview1, 0, target_table, actions);
            treeview1.DragMotion       += OnDragOver;
            treeview1.DragDrop         += OnDragDrop;
            treeview1.DragBegin        += OnDragBegin;
            treeview1.DragDataGet      += OnDragDataGet;
            treeview1.DragDataReceived += OnDragDataReceived;
            treeview1.DragEnd          += OnDragEnd;
            treeview1.FocusInEvent     += Treeview1_FocusInEvent;
            treeview1.FocusOutEvent    += Treeview1_FocusOutEvent;
            timer.Elapsed         += Timer_Elapsed;
            _mainWidget.Destroyed += _mainWidget_Destroyed;
        }
Beispiel #5
0
 private void ScriptedAI_OnDestroy()
 {
     _stats    = null;
     _threat   = null;
     _tEntry   = null;
     _target   = null;
     _creature = null;
     _movement = null;
 }
Beispiel #6
0
 public SpellsManager()
     : base()
 {
     m_gcd       = 0;
     m_cast      = new SpellCast();
     m_target    = new TargetEntry();
     m_cooldowns = new CountdownList();
     m_cast_args = new SpellCastArgs();
 }
Beispiel #7
0
        public static void Main(string[] args)
        {
            ExceptionManager.UnhandledException += delegate(UnhandledExceptionArgs expArgs) {
                Console.WriteLine(expArgs.ExceptionObject.ToString());
                expArgs.ExitApplication = true;
            };

            Gtk.Application.Init();

            MainWindow = new Window("gsCNCViewer");
            MainWindow.SetDefaultSize(900, 600);
            MainWindow.SetPosition(WindowPosition.Center);
            MainWindow.DeleteEvent += delegate {
                Gtk.Application.Quit();
            };

            //DMesh3 part = StandardMeshReader.ReadMesh("../../../sample_files/hemisphere_h2p4.obj");
            //DMesh3 stock = StandardMeshReader.ReadMesh("../../../sample_files/stock_5x5x2p5.obj");

            DMesh3 part  = StandardMeshReader.ReadMesh("../../../sample_files/mechpart1.obj");
            DMesh3 stock = StandardMeshReader.ReadMesh("../../../sample_files/mechpart1_stock.obj");


            PrintMeshAssembly meshes = new PrintMeshAssembly();

            meshes.AddMesh(stock);
            meshes.AddMesh(part, PrintMeshOptions.Cavity());

            View = new SliceViewCanvas();
            MainWindow.Add(View);


            //DMesh3 tube_mesh = GenerateTubeMeshesForGCode("c:\\Users\\rms\\Downloads\\gear train.nc");
            //StandardMeshWriter.WriteMesh("../../../sample_output/tubes.obj", tube_mesh, WriteOptions.Defaults);

            string sPath = GenerateGCodeForMeshes(meshes);

            if (SHOW_RELOADED_GCODE_PATHS)
            {
                LoadGeneratedGCodeFile(sPath);
            }

            MainWindow.KeyReleaseEvent += Window_KeyReleaseEvent;

            // support drag-drop
            Gtk.TargetEntry[] target_table = new TargetEntry[] {
                new TargetEntry("text/uri-list", 0, 0),
            };
            Gtk.Drag.DestSet(MainWindow, DestDefaults.All, target_table, Gdk.DragAction.Copy);
            MainWindow.DragDataReceived += MainWindow_DragDataReceived;;


            MainWindow.ShowAll();

            Gtk.Application.Run();
        }
Beispiel #8
0
 private void ScriptedAI_OnInitialize()
 {
     _stats    = _parent.RequiredComponent <StatsMgr>();
     _threat   = _parent.RequiredComponent <ThreatMgr>();
     _movement = _parent.RequiredComponent <MovementGenerator>();
     _tEntry   = new TargetEntry()
     {
         SpellID = _stats.MeleeSkill, Upgrade = 0
     };
 }
Beispiel #9
0
    private void SetClipboard()
    {
        var targets = new TargetEntry[] {
            new TargetEntry("UTF8_STRING", TargetFlags.OtherApp, (uint)DataType.PlainText),
            new TargetEntry("application/x-copysharp-ignore", TargetFlags.OtherApp, (uint)DataType.Ignore),
        };

        GetClipboard().Clear();
        GetClipboard().SetWithData(targets, GetClipboardData, ClearClipboardData);
    }
Beispiel #10
0
        /// <summary>Default constructor for ExplorerView</summary>
        public ExplorerView(ViewBase owner) : base(owner)
        {
            Glade.XML gxml = new Glade.XML("ApsimNG.Resources.Glade.ExplorerView.glade", "vpaned1");
            gxml.Autoconnect(this);
            _mainWidget = vpaned1;

            progressbar1.Visible       = false;
            statusWindow.HeightRequest = 20;
            treeview1.Model            = treemodel;
            TreeViewColumn     column     = new TreeViewColumn();
            CellRendererPixbuf iconRender = new Gtk.CellRendererPixbuf();

            column.PackStart(iconRender, false);
            CellRendererText textRender = new Gtk.CellRendererText();

            textRender.Editable        = true;
            textRender.EditingStarted += OnBeforeLabelEdit;
            textRender.Edited         += OnAfterLabelEdit;
            column.PackStart(textRender, true);
            column.SetAttributes(iconRender, "pixbuf", 1);
            column.SetAttributes(textRender, "text", 0);
//            column.SetCellDataFunc(textRender, treecelldatafunc);
            treeview1.AppendColumn(column);

            treeview1.CursorChanged      += OnAfterSelect;
            treeview1.ButtonReleaseEvent += OnButtonUp;

            TargetEntry[] target_table = new TargetEntry[] {
                new TargetEntry("application/x-model-component", TargetFlags.App, 0)
            };

            Gdk.DragAction actions = Gdk.DragAction.Copy | Gdk.DragAction.Link | Gdk.DragAction.Move;
            //treeview1.EnableModelDragDest(target_table, actions);
            //treeview1.EnableModelDragSource(Gdk.ModifierType.Button1Mask, target_table, actions);
            Drag.SourceSet(treeview1, Gdk.ModifierType.Button1Mask, target_table, actions);
            Drag.DestSet(treeview1, 0, target_table, actions);
            treeview1.DragMotion       += OnDragOver;
            treeview1.DragDrop         += OnDragDrop;
            treeview1.DragBegin        += OnDragBegin;
            treeview1.DragDataGet      += OnDragDataGet;
            treeview1.DragDataReceived += OnDragDataReceived;
            treeview1.DragEnd          += OnDragEnd;
            treeview1.DragDataDelete   += OnDragDataDelete;

            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));
        }
Beispiel #11
0
        public static bool CanCast(CreatureObject creature, TargetEntry target)
        {
            DB_Spell spell; DB_SpellEffect main; CreatureObject targetCO;

            if (DataMgr.Select(target.SpellID, out spell) &&
                spell.Effects.TryGetValue(0, out main) &&
                creature.Stats.Energy >= main.Data01)
            {
                if (target.HasGuid)
                {
                    if (creature.Server.Objects.TryGetCreature((ushort)target.Guid, out targetCO) && !targetCO.IsDead)
                    {
                        if (Vector3.DistanceSquared(targetCO.Position, creature.Position) <= main.Data02 * main.Data02)
                        {
                            var isSelf = targetCO == creature;
                            if ((main.Target & SpellTarget.Creature) != 0)
                            {
                                if (targetCO.IsPlayer)
                                {
                                    if ((main.Target & SpellTarget.Self) != 0 && isSelf)
                                    {
                                        return(true);
                                    }
                                    else if ((main.Target & SpellTarget.Player) != 0)
                                    {
                                        return(targetCO.IsPlayer && !isSelf);
                                    }
                                }
                                else
                                {
                                    return(targetCO.HasStats);
                                }
                            }
                            else if ((main.Target & SpellTarget.Player) != 0)
                            {
                                if (isSelf)
                                {
                                    return((main.Target & SpellTarget.Self) != 0);
                                }
                                return(targetCO.IsPlayer);
                            }
                            else if ((main.Target & SpellTarget.Self) != 0)
                            {
                                return(isSelf);
                            }
                        }
                    }
                }
                else if ((main.Target & SpellTarget.Position) != 0)
                {
                    return(Vector3.DistanceSquared(target.Position, creature.Position) <= main.Data02 * main.Data02);
                }
            }
            return(false);
        }
Beispiel #12
0
        private void EnableDrop()
        {
            //init drag supported targets.
            TargetEntry[] targets = new TargetEntry[1] {
                new TargetEntry("text/uri-list", 0, 0)
            };

            // set up label as a drop target
            Gtk.Drag.DestSet(this.treeView, DestDefaults.All, targets, Gdk.DragAction.Copy);
            this.treeView.DragDataReceived += HandleDragDataReceived;
        }
        public GroupsPanel(bool multiSelect)
        {
            groupsTreeStore = new TreeStore(typeof(string), typeof(bool), typeof(T));
            groupsTree      = new TreeView(groupsTreeStore)
            {
                HeadersVisible = true, RulesHint = false, SearchColumn = -1
            };

            TargetEntry targetEntry = new TargetEntry {
                Flags = TargetFlags.Widget, Target = "application/x-hyena-data-model-selection"
            };

            groupsTree.EnableModelDragSource(ModifierType.Button1Mask | ModifierType.Button3Mask, new [] { targetEntry }, DragAction.Move);
            TargetEntry targetEntryTree = new TargetEntry("application/gtk_tree_model_row", TargetFlags.Widget, 0);

            groupsTree.EnableModelDragDest(new [] { targetEntry }, DragAction.Move);
            groupsTree.EnableModelDragDest(new [] { targetEntryTree }, DragAction.Move);
            groupsTree.DragMotion += GroupsTree_DragMotion;
            groupsTree.DragDrop   += GroupsTree_DragDrop;

            CellRendererText textCellRend = new CellRendererText {
                Editable = false
            };

            TreeViewColumn groupNameColumn = new TreeViewColumn {
                Title = Translator.GetString("Group"), Expand = true
            };

            groupNameColumn.PackStart(textCellRend, true);
            groupNameColumn.AddAttribute(textCellRend, "markup", 0);

            groupsTree.AppendColumn(groupNameColumn);

            CellRendererToggle toglCellRend = new CellRendererToggle {
                Activatable = true
            };

            toglCellRend.Toggled += toglCellRend_Toggled;

            TreeViewColumn groupSelColumn = new TreeViewColumn {
                Title = Translator.GetString("Selected"), Expand = true, Visible = multiSelect
            };

            groupSelColumn.PackStart(toglCellRend, true);
            groupSelColumn.AddAttribute(toglCellRend, "active", 1);

            groupsTree.AppendColumn(groupSelColumn);

            HscrollbarPolicy = PolicyType.Automatic;
            VscrollbarPolicy = PolicyType.Automatic;

            Add(groupsTree);
            groupsTree.Show();
        }
Beispiel #14
0
 public SkillsMgr(WO_Player parent)
     : base(parent)
 {
     _wPlayer          = parent;
     _mPlayer          = _wPlayer.Player;
     _entry            = new TargetEntry();
     _skills           = _wPlayer.Player.Data.Skills;
     _cooldown         = new Dictionary <int, CooldownReset>();
     parent.OnSpawn   += SkillsMgr_OnSpawn;
     parent.OnDestroy += SkillsMgr_OnDestroy;
 }
    private void OnCopyButtonClick(object obj, EventArgs args)
    {
        Console.WriteLine(_fileCopy.Uri);

        _source = _fileCopy.Uri;
        _action = _radioMove.Active ? "cut" : "copy";

        var target0 = new TargetEntry("x-special/gnome-copied-files", 0, 0);
        var target1 = new TargetEntry("text/uri-list", 0, 0);

        _clipBoard.SetWithData(new TargetEntry[] { target0, target1 }, ClearGet, ClearFunc);
    }
Beispiel #16
0
 public void TestConstructorNullTarget()
 {
     Assert.Throws<ArgumentNullException>(() =>
     {
         ProjectInstance project = CreateTestProject(true /* Returns enabled */);
         BuildRequestConfiguration config = new BuildRequestConfiguration(1, new BuildRequestData("foo", new Dictionary<string, string>(), "foo", new string[0], null), "2.0");
         BuildRequestEntry requestEntry = new BuildRequestEntry(CreateNewBuildRequest(1, new string[] { "foo" }), config);
         Lookup lookup = new Lookup(new ItemDictionary<ProjectItemInstance>(project.Items), new PropertyDictionary<ProjectPropertyInstance>(project.Properties), null);
         TargetEntry entry = new TargetEntry(requestEntry, this, null, lookup, null, _host, false);
     }
    );
 }
 /** Add a label to your project called lblPath **/
 public MainWindow() : base(Gtk.WindowType.Toplevel)
 {
     Build();
     //media type we'll accept
     Gtk.TargetEntry [] target_table =
         new TargetEntry [] {
         new TargetEntry("text/uri-list", 0, 0),
         new TargetEntry("application/x-monkey", 0, 1),
     };
     Gtk.Drag.DestSet(lblPath, DestDefaults.All, target_table, Gdk.DragAction.Copy);
     lblPath.DragDataReceived += new Gtk.DragDataReceivedHandler(OnLabelDragDataReceived);
 }
Beispiel #18
0
        private void CopyToClipboard()
        {
            var clipboard = Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false));

            clipboard.SetWithData(
                new[] { TargetEntry.New("UTF8_STRING", 0, 0) },
                (clipboard1, selectionData, info) => {
                selectionData.Text = textResult.Buffer.Text;
                clipboard1.Store();
            },
                clipboard1 => { }
                );
        }
        public async Task <TargetEntry> GetTarget(string name)
        {
            TargetEntry result = null;

            await Task.Run(() =>
            {
                var targets = db.GetCollection <TargetEntry>();

                result = targets?.FindById(name);
            });

            return(result);
        }
Beispiel #20
0
        protected override void Initialise(ViewBase ownerView, GLib.Object gtkControl)
        {
            treeview1       = (Gtk.TreeView)gtkControl;
            mainWidget      = treeview1;
            treeview1.Model = treemodel;
            TreeViewColumn     column     = new TreeViewColumn();
            CellRendererPixbuf iconRender = new Gtk.CellRendererPixbuf();

            iconRender.SetPadding(2, 1);
            column.PackStart(iconRender, false);
            textRender                 = new Gtk.CellRendererText();
            textRender.Editable        = false;
            textRender.EditingStarted += OnBeforeLabelEdit;
            textRender.Edited         += OnAfterLabelEdit;
            column.PackStart(textRender, true);
            column.SetCellDataFunc(textRender, OnSetCellData);

            CellRendererText tickCell = new CellRendererText();

            tickCell.Editable = false;
            column.PackEnd(tickCell, false);
            column.SetAttributes(iconRender, "pixbuf", 1);
            column.SetAttributes(textRender, "text", 0);
            column.SetAttributes(tickCell, "text", 3);
            treeview1.AppendColumn(column);
            treeview1.TooltipColumn = 2;

            treeview1.CursorChanged      += OnAfterSelect;
            treeview1.ButtonReleaseEvent += OnButtonUp;
            treeview1.ButtonPressEvent   += OnButtonPress;
            treeview1.RowActivated       += OnRowActivated;
            treeview1.FocusInEvent       += OnTreeGainFocus;
            treeview1.FocusOutEvent      += OnTreeLoseFocus;

            TargetEntry[] target_table = new TargetEntry[] {
                new TargetEntry(modelMime, TargetFlags.App, 0)
            };

            Gdk.DragAction actions = Gdk.DragAction.Copy | Gdk.DragAction.Link | Gdk.DragAction.Move;
            Drag.SourceSet(treeview1, Gdk.ModifierType.Button1Mask, target_table, actions);
            Drag.DestSet(treeview1, 0, target_table, actions);
            treeview1.DragMotion       += OnDragOver;
            treeview1.DragDrop         += OnDragDrop;
            treeview1.DragBegin        += OnDragBegin;
            treeview1.DragDataGet      += OnDragDataGet;
            treeview1.DragDataReceived += OnDragDataReceived;
            treeview1.DragEnd          += OnDragEnd;
            timer.Elapsed        += OnTimerElapsed;
            mainWidget.Destroyed += OnDestroyed;
        }
Beispiel #21
0
        public void Exec()
        {
            var cb = Clipboard.Get(Gdk.Selection.Clipboard);

            if (cb == null)
            {
                Log.Debug("Clipboard is null");
                return;
            }
            var target0 = new TargetEntry("x-special/gnome-copied-files", 0, 0);
            var target1 = new TargetEntry("text/uri-list", 0, 0);

            cb.SetWithData(new TargetEntry[] { target0, target1 }, ClearGet, ClearFunc);
        }
Beispiel #22
0
        /// <summary>Constructor</summary>
        public TreeView(ViewBase owner, Gtk.TreeView treeView) : base(owner)
        {
            treeview1       = treeView;
            treeview1.Model = treemodel;
            TreeViewColumn     column     = new TreeViewColumn();
            CellRendererPixbuf iconRender = new Gtk.CellRendererPixbuf();

            column.PackStart(iconRender, false);
            textRender                 = new Gtk.CellRendererText();
            textRender.Editable        = false;
            textRender.EditingStarted += OnBeforeLabelEdit;
            textRender.Edited         += OnAfterLabelEdit;
            column.PackStart(textRender, true);
            column.SetCellDataFunc(textRender, OnSetCellData);

            CellRendererText tickCell = new CellRendererText();

            tickCell.Editable = false;
            column.PackEnd(tickCell, false);
            column.SetAttributes(iconRender, "pixbuf", 1);
            column.SetAttributes(textRender, "text", 0);
            column.SetAttributes(tickCell, "text", 3);
            // column.SetCellDataFunc(textRender, treecelldatafunc);
            treeview1.AppendColumn(column);
            treeview1.TooltipColumn = 2;

            treeview1.CursorChanged      += OnAfterSelect;
            treeview1.ButtonReleaseEvent += OnButtonUp;
            treeview1.ButtonPressEvent   += OnButtonPress;
            treeview1.RowActivated       += OnRowActivated;
            treeview1.FocusInEvent       += OnTreeGainFocus;
            treeview1.FocusOutEvent      += OnTreeLoseFocus;

            TargetEntry[] target_table = new TargetEntry[] {
                new TargetEntry(modelMime, TargetFlags.App, 0)
            };

            Gdk.DragAction actions = Gdk.DragAction.Copy | Gdk.DragAction.Link | Gdk.DragAction.Move;
            // treeview1.EnableModelDragDest(target_table, actions);
            // treeview1.EnableModelDragSource(Gdk.ModifierType.Button1Mask, target_table, actions);
            Drag.SourceSet(treeview1, Gdk.ModifierType.Button1Mask, target_table, actions);
            Drag.DestSet(treeview1, 0, target_table, actions);
            treeview1.DragMotion       += OnDragOver;
            treeview1.DragDrop         += OnDragDrop;
            treeview1.DragBegin        += OnDragBegin;
            treeview1.DragDataGet      += OnDragDataGet;
            treeview1.DragDataReceived += OnDragDataReceived;
            treeview1.DragEnd          += OnDragEnd;
            timer.Elapsed += OnTimerElapsed;
        }
Beispiel #23
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="holder">iFolder Holder</param>
        /// <param name="group">iFolderViewGroup</param>
        public iFolderViewItem(iFolderHolder holder, iFolderViewGroup group, TreeIter iter, int maxWidth)
        {
            this.holder   = holder;
            this.group    = group;
            this.iter     = iter;
            this.maxWidth = maxWidth;

            this.CanFocus = true;

            this.bSelected        = false;
            this.bMouseIsHovering = false;

            this.ModifyBg(StateType.Normal, this.Style.Base(StateType.Normal));
            this.ModifyBase(StateType.Normal, this.Style.Base(StateType.Normal));

            currentName     = "";
            currentLocation = "";
            currentStatus   = "";

//			domainController = DomainController.GetDomainController();

            LoadImages();
            SetPixbufs();

            this.Add(CreateWidgets());

            this.WidthRequest = this.maxWidth;

            this.Realized +=
                new EventHandler(OnWidgetRealized);

// FIXME: Fix things up so that if the user changes the theme, our icons will refresh too
//			if (!registeredForThemeChangeEvent)
//			{
//				IconTheme.Changed += new EventHandler(OnGtkIconThemeChanged);
//			}
            ///
            /// Set up drag and drop
            ///
            TargetEntry[] targets =
                new TargetEntry[]
            {
                new TargetEntry("text/ifolder-id", 0, (uint)iFolderWindow.DragTargetType.iFolderID)
            };

            this.DragDataGet += new DragDataGetHandler(HandleDragDataGet);
            Drag.SourceSet(this, Gdk.ModifierType.Button1Mask, targets, Gdk.DragAction.Move);
        }
Beispiel #24
0
        /// <summary>Default constructor for ExplorerView</summary>
        public ExplorerView(ViewBase owner) : base(owner)
        {
            Glade.XML gxml = new Glade.XML("ApsimNG.Resources.Glade.ExplorerView.glade", "vbox1");
            gxml.Autoconnect(this);
            _mainWidget = vbox1;
            RightHandView.ShadowType = ShadowType.EtchedOut;

            treeview1.Model = treemodel;
            TreeViewColumn     column     = new TreeViewColumn();
            CellRendererPixbuf iconRender = new Gtk.CellRendererPixbuf();

            column.PackStart(iconRender, false);
            textRender                 = new Gtk.CellRendererText();
            textRender.Editable        = true;
            textRender.EditingStarted += OnBeforeLabelEdit;
            textRender.Edited         += OnAfterLabelEdit;
            column.PackStart(textRender, true);
            column.SetAttributes(iconRender, "pixbuf", 1);
            column.SetAttributes(textRender, "text", 0);
            // column.SetCellDataFunc(textRender, treecelldatafunc);
            treeview1.AppendColumn(column);
            treeview1.TooltipColumn = 2;

            treeview1.CursorChanged      += OnAfterSelect;
            treeview1.ButtonReleaseEvent += OnButtonUp;

            TargetEntry[] target_table = new TargetEntry[] {
                new TargetEntry("application/x-model-component", TargetFlags.App, 0)
            };

            Gdk.DragAction actions = Gdk.DragAction.Copy | Gdk.DragAction.Link | Gdk.DragAction.Move;
            // treeview1.EnableModelDragDest(target_table, actions);
            // treeview1.EnableModelDragSource(Gdk.ModifierType.Button1Mask, target_table, actions);
            Drag.SourceSet(treeview1, Gdk.ModifierType.Button1Mask, target_table, actions);
            Drag.DestSet(treeview1, 0, target_table, actions);
            treeview1.DragMotion       += OnDragOver;
            treeview1.DragDrop         += OnDragDrop;
            treeview1.DragBegin        += OnDragBegin;
            treeview1.DragDataGet      += OnDragDataGet;
            treeview1.DragDataReceived += OnDragDataReceived;
            treeview1.DragEnd          += OnDragEnd;
            treeview1.DragDataDelete   += OnDragDataDelete;
            treeview1.FocusInEvent     += Treeview1_FocusInEvent;
            treeview1.FocusOutEvent    += Treeview1_FocusOutEvent;
            _mainWidget.Destroyed      += _mainWidget_Destroyed;
        }
Beispiel #25
0
        public static void Register(TTarget target, string toString) // scope
        {
            var id = _generator.GetId(target, out var firstTime);

            var events = new TEvents {
                Id = id, _toString = toString
            };
            var targetEntry = new TargetEntry(events);

            if (firstTime)
            {
                LastId = id;
                _Registry.Add(id, targetEntry);
            }
            else // pooled
            {
                _Registry[id] = targetEntry;
            }
        }
Beispiel #26
0
        public Preview(Dialog dialog, VariableSet variables)
        {
            _dialog = dialog;

            Realized    += OnRealized;
            ExposeEvent += OnExposed;

            var targets = new TargetEntry[] {
                new TargetEntry("image/jpeg", 0, 0),
                new TargetEntry("image/png", 0, 0),
                new TargetEntry("text/plain", 0, 1),
                new TargetEntry("STRING", 0, 2)
            };

            Gtk.Drag.DestSet(this, DestDefaults.All, targets,
                             DragAction.Copy | DragAction.Move);

            Events = EventMask.ButtonPressMask;
        }
Beispiel #27
0
        /// <summary>
        /// Assigns a new key to this entry -
        /// creates a new source entry if the assignment is completely new.
        /// </summary>
        /// <param name="key"></param>
        internal void SetKey(string key)
        {
            if (IsTargetSet == false && IsSourceSet == false)
            {
                SourceEntry = new Entry(TargetEntry.KeyString, string.Empty, string.Empty);
                Diff        = TypeOfDiff.SourceOnly;
            }
            else
            {
                if (IsTargetSet == true)
                {
                    TargetEntry.SetKey(key);
                }

                if (IsSourceSet == true)
                {
                    SourceEntry.SetKey(key);
                }
            }
        }
        public void Should_call_Update_on_DataProvider()
        {
            // arrange
            var targetEntry = new TargetEntry
            {
                Name      = "NewTarget",
                TableName = "new_Target"
            };
            var mockDataProvider = new Mock <IDataProvider>();

            mockDataProvider
            .Setup(p => p.Update(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <IEnumerable <KeyValuePair <string, object> > >()))
            .Returns(34);
            var repository = new TargetEntryRepository(mockDataProvider.Object);

            // act
            var result = repository.Update(targetEntry);

            // assert
            Assert.That(result, Is.EqualTo(34));
            mockDataProvider.Verify(p => p.Update(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <IEnumerable <KeyValuePair <string, object> > >()));
        }
        public void Should_call_Get_on_DataProvider()
        {
            // arrange
            var targetEntry = new TargetEntry
            {
                Id        = 34,
                Name      = "NewTarget",
                TableName = "new_Target"
            };
            var mockDataProvider = new Mock <IDataProvider>();

            mockDataProvider
            .Setup(p => p.Get(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <Func <IDataRecord, TargetEntry> >()))
            .Returns(targetEntry);
            var repository = new TargetEntryRepository(mockDataProvider.Object);

            // act
            var result = repository.Get(34);

            // assert
            Assert.That(result.Id, Is.EqualTo(34));
            mockDataProvider.Verify(p => p.Get(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <Func <IDataRecord, TargetEntry> >()));
        }
Beispiel #30
0
        /// <summary>
        /// Pushes the list of targets specified onto the target stack in reverse order specified, so that
        /// they will be built in the order specified.
        /// </summary>
        /// <param name="targets">List of targets to build.</param>
        /// <param name="parentTargetEntry">The target which should be considered the parent of these targets.</param>
        /// <param name="baseLookup">The lookup to be used to build these targets.</param>
        /// <param name="addAsErrorTarget">True if this should be considered an error target.</param>
        /// <param name="stopProcessingOnCompletion">True if target stack processing should terminate when the last target in the list is processed.</param>
        /// <returns>True if we actually pushed any targets, false otherwise.</returns>
        private async Task<bool> PushTargets(IList<TargetSpecification> targets, TargetEntry parentTargetEntry, Lookup baseLookup, bool addAsErrorTarget, bool stopProcessingOnCompletion, TargetPushType pushType)
        {
            List<TargetEntry> targetsToPush = new List<TargetEntry>(targets.Count);

            // Iterate the list in reverse order so that the first target in the list is the last pushed, and thus the first to be executed.
            for (int i = targets.Count - 1; i >= 0; i--)
            {
                TargetSpecification targetSpecification = targets[i];

                if (pushType != TargetPushType.Normal)
                {
                    // Don't build any Before or After targets for which we already have results.  Unlike other targets, 
                    // we don't explicitly log a skipped-with-results message because it is not interesting.
                    if (_buildResult.HasResultsForTarget(targetSpecification.TargetName))
                    {
                        if (_buildResult[targetSpecification.TargetName].ResultCode != TargetResultCode.Skipped)
                        {
                            continue;
                        }
                    }
                }

                ElementLocation targetLocation = targetSpecification.ReferenceLocation;

                // See if this target is already building under a different build request.  If so, we need to wait.
                int idOfAlreadyBuildingRequest = BuildRequest.InvalidGlobalRequestId;
                if (_requestEntry.RequestConfiguration.ActivelyBuildingTargets.TryGetValue(targetSpecification.TargetName, out idOfAlreadyBuildingRequest))
                {
                    if (idOfAlreadyBuildingRequest != _requestEntry.Request.GlobalRequestId)
                    {
                        // Another request elsewhere is building it.  We need to wait.
                        await _requestBuilderCallback.BlockOnTargetInProgress(idOfAlreadyBuildingRequest, targetSpecification.TargetName);

                        // If we come out of here and the target is *still* active, it means the scheduler detected a circular dependency and told us to
                        // continue so we could throw the exception.
                        if (_requestEntry.RequestConfiguration.ActivelyBuildingTargets.ContainsKey(targetSpecification.TargetName))
                        {
                            ProjectErrorUtilities.ThrowInvalidProject(targetLocation, "CircularDependency", targetSpecification.TargetName);
                        }
                    }
                    else
                    {
                        if (pushType == TargetPushType.AfterTargets)
                        {
                            // If the target we are pushing is supposed to run after the current target and it is already set to run after us then skip adding it now.
                            continue;
                        }

                        // We are already building this target on this request. That's a circular dependency.
                        ProjectErrorUtilities.ThrowInvalidProject(targetLocation, "CircularDependency", targetSpecification.TargetName);
                    }
                }
                else
                {
                    // Does this target exist in our direct parent chain, if it is a before target (since these can cause circular dependency issues)
                    if (pushType == TargetPushType.BeforeTargets || pushType == TargetPushType.Normal)
                    {
                        TargetEntry currentParent = parentTargetEntry;
                        while (currentParent != null)
                        {
                            if (String.Equals(currentParent.Name, targetSpecification.TargetName, StringComparison.OrdinalIgnoreCase))
                            {
                                // We are already building this target on this request. That's a circular dependency.
                                ProjectErrorUtilities.ThrowInvalidProject(targetLocation, "CircularDependency", targetSpecification.TargetName);
                            }

                            currentParent = currentParent.ParentEntry;
                        }
                    }
                    else
                    {
                        // For an after target, if it is already ANYWHERE on the stack, we don't need to push it because it is already going to run
                        // after whatever target is causing it to be pushed now.
                        bool alreadyPushed = false;
                        foreach (TargetEntry entry in _targetsToBuild)
                        {
                            if (String.Equals(entry.Name, targetSpecification.TargetName, StringComparison.OrdinalIgnoreCase))
                            {
                                alreadyPushed = true;
                                break;
                            }
                        }

                        if (alreadyPushed)
                        {
                            continue;
                        }
                    }
                }

                // Add to the list of targets to push.  We don't actually put it on the stack here because we could run into a circular dependency
                // during this loop, in which case the target stack would be out of whack.
                TargetEntry newEntry = new TargetEntry(_requestEntry, this as ITargetBuilderCallback, targetSpecification, baseLookup, parentTargetEntry, _componentHost, stopProcessingOnCompletion);
                newEntry.ErrorTarget = addAsErrorTarget;
                targetsToPush.Add(newEntry);
                stopProcessingOnCompletion = false; // The first target on the stack (the last one to be run) always inherits the stopProcessing flag.
            }

            // Now push the targets since this operation cannot fail.
            foreach (TargetEntry targetToPush in targetsToPush)
            {
                _targetsToBuild.Push(targetToPush);
            }

            bool pushedTargets = (targetsToPush.Count > 0);
            return pushedTargets;
        }
Beispiel #31
0
 public static void AddTargetEntry(this TargetList targetList, TargetEntry entry)
 {
     targetList.Add(entry.Target, (uint)entry.Flags, (uint)entry.Info);
 }
Beispiel #32
0
        /// <summary>
        /// Creates a TargetEntry from a project and the specified target name.
        /// </summary>
        /// <param name="project">The project object.</param>
        /// <param name="targetName">The name of a target within the specified project.</param>
        /// <returns>The new target entry</returns>
        private TargetEntry CreateStandardTargetEntry(ProjectInstance project, string targetName)
        {
            BuildRequestConfiguration config = new BuildRequestConfiguration(1, new BuildRequestData("foo", new Dictionary<string, string>(), "foo", new string[0], null), "2.0");
            config.Project = project;
            BuildRequestEntry requestEntry = new BuildRequestEntry(CreateNewBuildRequest(1, new string[] { "foo" }), config);

            Lookup lookup = new Lookup(new ItemDictionary<ProjectItemInstance>(project.Items), new PropertyDictionary<ProjectPropertyInstance>(project.Properties), null);
            TargetEntry entry = new TargetEntry(requestEntry, this, new TargetSpecification(targetName, project.Targets[targetName].Location), lookup, null, _host, false);
            return entry;
        }
Beispiel #33
0
        /// <summary>
        /// Executes the specified entry with the specified project.
        /// </summary>
        private void ExecuteEntry(ProjectInstance project, TargetEntry entry)
        {
            ITaskBuilder taskBuilder = _host.GetComponent(BuildComponentType.TaskBuilder) as ITaskBuilder;

            // GetAwaiter().GetResult() will flatten any AggregateException throw by the task.
            entry.ExecuteTarget(taskBuilder, entry.RequestEntry, GetProjectLoggingContext(entry.RequestEntry), CancellationToken.None).GetAwaiter().GetResult();
            ((IBuildComponent)taskBuilder).ShutdownComponent();
        }
Beispiel #34
0
        /// <summary>
        /// Determines if the current target should be skipped, and logs the appropriate message.
        /// </summary>
        /// <returns>True to skip the target, false otherwise.</returns>
        private bool CheckSkipTarget(ref bool stopProcessingStack, TargetEntry currentTargetEntry)
        {
            if (_buildResult.HasResultsForTarget(currentTargetEntry.Name))
            {
                TargetResult targetResult = _buildResult[currentTargetEntry.Name] as TargetResult;
                ErrorUtilities.VerifyThrowInternalNull(targetResult, "targetResult");

                if (targetResult.ResultCode != TargetResultCode.Skipped)
                {
                    // If we've already dealt with this target and it didn't skip, let's log appropriately
                    // Otherwise we don't want anything more to do with it.
                    _projectLoggingContext.LogComment
                        (
                        Microsoft.Build.Framework.MessageImportance.Low,
                        targetResult.ResultCode == TargetResultCode.Success ? "TargetAlreadyCompleteSuccess" : "TargetAlreadyCompleteFailure",
                        currentTargetEntry.Name
                        );

                    if (currentTargetEntry.StopProcessingOnCompletion)
                    {
                        stopProcessingStack = true;
                    }

                    if (targetResult.ResultCode == TargetResultCode.Success)
                    {
                        _targetsToBuild.Peek().LeaveLegacyCallTargetScopes();
                        _targetsToBuild.Pop();
                    }
                    else
                    {
                        TargetEntry topEntry = _targetsToBuild.Pop();

                        // If this is a skip because of target failure, we should behave in the same way as we 
                        // would if this target actually failed -- remove all its dependencies from the stack as 
                        // well.  Otherwise, we could encounter a situation where a failure target happens in the 
                        // middle of execution once, then exits, then a request comes through to build the same
                        // targets, reaches that target, skips-already-failed, and then continues building. 
                        PopDependencyTargetsOnTargetFailure(topEntry, targetResult, ref stopProcessingStack);
                    }

                    return true;
                }
            }

            return false;
        }
Beispiel #35
0
        /// <summary>
        /// When a target build fails, we don't just stop building that target; we also pop all of the other dependency targets of its 
        /// parent target off the stack. Extract that logic into a standalone method so that it can be used when dealing with targets that 
        /// are skipped-unsuccessful as well as first-time failures. 
        /// </summary>
        private void PopDependencyTargetsOnTargetFailure(TargetEntry topEntry, TargetResult targetResult, ref bool stopProcessingStack)
        {
            if (targetResult.WorkUnitResult.ActionCode == WorkUnitActionCode.Stop)
            {
                // Pop down to our parent, since any other dependencies our parent had should no longer
                // execute.  If we encounter an error target on the way down, also stop since the failure
                // of one error target in a set declared in OnError should not cause the others to stop running.
                while ((!_targetsToBuild.IsEmpty) && (_targetsToBuild.Peek() != topEntry.ParentEntry) && !_targetsToBuild.Peek().ErrorTarget)
                {
                    TargetEntry entry = _targetsToBuild.Pop();
                    entry.LeaveLegacyCallTargetScopes();

                    // This target is no longer actively building (if it was).
                    _requestEntry.RequestConfiguration.ActivelyBuildingTargets.Remove(topEntry.Name);

                    // If we come across an entry which requires us to stop processing (for instance, an aftertarget of the original
                    // CallTarget target) then we need to use that flag, not the one from the top entry.
                    if (entry.StopProcessingOnCompletion)
                    {
                        stopProcessingStack = true;
                    }
                }

                // Mark our parent for error execution
                if (topEntry.ParentEntry != null && topEntry.ParentEntry.State != TargetEntryState.Completed)
                {
                    topEntry.ParentEntry.MarkForError();
                }
            }
        }
Beispiel #36
0
        public void TestConstructorNullHost()
        {
            ProjectInstance project = CreateTestProject(true /* Returns enabled */);
            BuildRequestConfiguration config = new BuildRequestConfiguration(1, new BuildRequestData("foo", new Dictionary<string, string>(), "foo", new string[0], null), "2.0");
            BuildRequestEntry requestEntry = new BuildRequestEntry(CreateNewBuildRequest(1, new string[] { "foo" }), config);

            Lookup lookup = new Lookup(new ItemDictionary<ProjectItemInstance>(project.Items), new PropertyDictionary<ProjectPropertyInstance>(project.Properties), null);
            TargetEntry entry = new TargetEntry(requestEntry, this, new TargetSpecification("Empty", null), lookup, null, null, false);
        }
Beispiel #37
0
 /// <summary>
 /// Creates a target entry object.
 /// </summary>
 /// <param name="project">The project object</param>
 /// <param name="target">The target object</param>
 /// <param name="baseEntry">The parent entry.</param>
 /// <returns>The new target entry</returns>
 private TargetEntry CreateStandardTargetEntry(ProjectInstance project, string target, TargetEntry baseEntry)
 {
     BuildRequestConfiguration config = new BuildRequestConfiguration(1, new BuildRequestData("foo", new Dictionary<string, string>(), "foo", new string[0], null), "2.0");
     config.Project = project;
     BuildRequestEntry requestEntry = new BuildRequestEntry(CreateNewBuildRequest(1, new string[1] { "foo" }), config);
     TargetEntry entry = new TargetEntry(requestEntry, this, new TargetSpecification(target, project.Targets[target].Location), baseEntry.Lookup, baseEntry, _host, false);
     return entry;
 }
 public static void PerformSkill(this PNetR.NetworkView view, TargetEntry target)
 {
     view.Rpc(5, 61, RpcMode.AllOrdered, target);
 }
Beispiel #39
0
 public void TestConstructorNullLookup()
 {
     ProjectInstance project = CreateTestProject(true /* Returns enabled */);
     BuildRequestConfiguration config = new BuildRequestConfiguration(1, new BuildRequestData("foo", new Dictionary<string, string>(), "foo", new string[0], null), "2.0");
     BuildRequestEntry requestEntry = new BuildRequestEntry(CreateNewBuildRequest(1, new string[] { "foo" }), config);
     TargetEntry entry = new TargetEntry(requestEntry, this, new TargetSpecification("Empty", null), null, null, _host, false);
 }