Ejemplo n.º 1
0
        List <Command> FindBindings(string accel)
        {
            List <Command> bindings = new List <Command> ();
            TreeModel      model    = (TreeModel)keyStore;
            TreeIter       iter;

            if (!model.GetIterFirst(out iter))
            {
                return(bindings);
            }
            do
            {
                TreeIter citer;
                model.IterChildren(out citer, iter);
                do
                {
                    string binding = (string)model.GetValue(citer, bindingCol);
                    if (Conflicts(binding, accel))
                    {
                        Command command = (Command)model.GetValue(citer, commandCol);
                        bindings.Add(command);
                    }
                } while (model.IterNext(ref citer));
            } while (model.IterNext(ref iter));
            return(bindings);
        }
Ejemplo n.º 2
0
        protected ICategory GetSelectedCategory()
        {
            ICategory foundCategory = null;

            string cat = Application.Preferences.Get(
                Preferences.SelectedCategoryKey);

            if (cat != null)
            {
                TreeIter  iter;
                TreeModel model = Application.Backend.Categories;

                if (model.GetIterFirst(out iter))
                {
                    do
                    {
                        ICategory category = model.GetValue(iter, 0) as ICategory;
                        if (category.Name.CompareTo(cat) == 0)
                        {
                            foundCategory = category;
                            break;
                        }
                    } while (model.IterNext(ref iter));
                }
            }

            return(foundCategory);
        }
Ejemplo n.º 3
0
        public CustomerSelectDialog(Gtk.Window parent, List <string> customerList, List <string> selectedCustomers)
        {
            this.Build();
            this.TransientFor = parent;
            this.SetPosition(WindowPosition.CenterAlways);
            m_customerList = customerList;

            treeview_customer_list.AppendColumn("图片", new CellRendererPixbuf(), "pixbuf", 0);
            treeview_customer_list.AppendColumn("名称", new CellRendererText(), "text", 1);
            treeview_customer_list.Selection.Mode = SelectionMode.Multiple;
            Utils.ShowCustomerList(m_customerList, treeview_customer_list);

            if (selectedCustomers != null && selectedCustomers.Count > 0)
            {
                TreeIter  iter;
                TreeModel model = treeview_customer_list.Model;
                if (model.GetIterFirst(out iter))
                {
                    do
                    {
                        if (selectedCustomers.Contains((string)model.GetValue(iter, 2)))
                        {
                            treeview_customer_list.Selection.SelectIter(iter);
                        }
                    } while (model.IterNext(ref iter));
                }
            }
        }
Ejemplo n.º 4
0
    public static void Copy(TreeModel tree, TreeIter tree_iter, ListStore list, bool first)
    {
        // Copy this iter's values to the list
        TreeIter list_iter = list.Append();

        for (int i = 0; i < list.NColumns; i++)
        {
            list.SetValue(list_iter, i, tree.GetValue(tree_iter, i));
            if (i == 1)
            {
                //Console.WriteLine("Copying {0}", list.GetValue(list_iter, i));
            }
        }

        // Copy the first child, which will trigger the copy if its siblings (and their children)
        TreeIter child_iter;

        if (tree.IterChildren(out child_iter, tree_iter))
        {
            Copy(tree, child_iter, list, true);
        }

        // Add siblings and their children if we are the first child, otherwise doing so would repeat
        if (first)
        {
            while (tree.IterNext(ref tree_iter))
            {
                Copy(tree, tree_iter, list, false);
            }
        }
    }
Ejemplo n.º 5
0
        /// <summary>
        /// Fill a list of events from a list of paths, if the first and unique path is an EventType the list
        /// is filled with al the child events in this EventType category.
        /// </summary>
        /// <param name = "model">Model.</param>
        /// <param name="events">Events.</param>
        /// <param name="paths">Paths.</param>
        public static List<TimelineEventLongoMatch> EventsListFromPaths(TreeModel model, TreePath[] paths)
        {
            List<TimelineEventLongoMatch> events = new List<TimelineEventLongoMatch> ();

            // If it's an EventType or a Player, traverse all children to fill the list
            if (paths.Length == 1 && !(model.GetValue (paths [0]) is TimelineEventLongoMatch)) {
                TreeIter parentIter;
                TreeIter child;
                bool hasChild;

                model.GetIter (out parentIter, paths [0]);
                hasChild = model.IterHasChild (parentIter);
                model.IterChildren (out child, parentIter);
                while (hasChild) {
                    TimelineEventLongoMatch evt = model.GetValue (child, 0) as TimelineEventLongoMatch;
                    if (evt != null) {
                        events.Add (evt);
                    }
                    hasChild = model.IterNext (ref child);
                }
            } else {
                foreach (var path in paths) {
                    TimelineEventLongoMatch evt = model.GetValue (path) as TimelineEventLongoMatch;
                    if (evt != null) {
                        events.Add (evt);
                    }
                }
            }
            return events;
        }
Ejemplo n.º 6
0
        public void SelecteWaypointByName(string code)
        {
            try
            {
                if (code == null)
                {
                    wptView.Selection.UnselectAll();
                    return;
                }

                TreeIter  itr;
                TreeModel model = wptView.Model;
                wptView.Model.GetIterFirst(out itr);
                do
                {
                    Waypoint pt = (Waypoint)model.GetValue(itr, 0);
                    if (pt.Name == code)
                    {
                        wptView.Selection.SelectIter(itr);
                        TreePath path = wptView.Model.GetPath(itr);
                        wptView.ScrollToCell(path, wptView.Columns[0], true, 0, 0);
                        return;
                    }
                }while (model.IterNext(ref itr));
            }
            catch (Exception e)
            {
                OCMApp.ShowException(e);
            }
        }
Ejemplo n.º 7
0
        private void FindItemRecursive(TreeIter iter, Stack <long> path)
        {
            TreeModel model        = tvItems.Model;
            bool      hasMoreIters = true;
            long      itemID       = path.Pop();

            while (hasMoreIters)
            {
                VolumeItem item = tvItems.GetItem(iter);

                if (item.ItemID == itemID)
                {
                    if (path.Count > 0)
                    {
                        tvItems.ExpandRow(model.GetPath(iter), false);
                        model.IterChildren(out iter, iter);
                        FindItemRecursive(iter, path);
                    }
                    else
                    {
                        tvItems.Selection.SelectIter(iter);
                        tvItems.ScrollToCell(model.GetPath(iter), null, false, .0f, .0f);
                    }
                    break;
                }

                hasMoreIters = model.IterNext(ref iter);
            }
        }
Ejemplo n.º 8
0
        private void BuildGroupButtonsView()
        {
            TreeIter iter;

            Logger.Debug("GroupWindow.BuildGroupButtonsView adding {0} groups",
                         groupTreeModel.IterNChildren());

            // Loop through the model, create buttons, and add them into the
            // groupButtonsVBox.
            if (groupTreeModel.GetIterFirst(out iter))
            {
                do
                {
                    PersonGroup group =
                        groupTreeModel.GetValue(iter, 0) as PersonGroup;
                    if (group == null)
                    {
                        continue;
                    }

                    AddGroupButton(new GroupButton(group),
                                   groupTreeModel.GetPath(iter));
                } while (groupTreeModel.IterNext(ref iter));
            }
        }
Ejemplo n.º 9
0
        public int AppendColumn(GridViewColumn col)
        {
            col.VisibilityChanged +=
                new EventHandler(OnColumnVisibilityChanged);

            if (col.Visible)
            {
                if (orientation == Orientation.Vertical)
                {
                    widths.Add(0);
                }
                else
                {
                    heights.Add(0);
                }

                visible.Add(col);

                TreeIter i;

                if (model != null && model.GetIterFirst(out i))
                {
                    do
                    {
                        TreePath path = model.GetPath(i);
                        MeasureCell(path, col);
                    } while (model.IterNext(ref i));
                }

                if (Visible)
                {
                    UpdateDrawingAreaSizeRequests();
                }
            }

            int ret = columns.Add(col);

            if (ColumnsChanged != null)
            {
                ColumnsChanged(this, EventArgs.Empty);
            }

            return(ret);
        }
Ejemplo n.º 10
0
 bool System.Collections.IEnumerator.MoveNext()
 {
     if (mModel == null)
     {
         return(false);
     }
     return(mIter.Equals(TreeIter.Zero)
        ? mModel.GetIterFirst(out mIter)
        : mModel.IterNext(ref mIter));
 }
        public override List <AppResult> NextSiblings()
        {
            if (!resultIter.HasValue)
            {
                return(null);
            }

            List <AppResult> newList     = new List <AppResult> ();
            TreeIter         currentIter = (TreeIter)resultIter;

            while (TModel.IterNext(ref currentIter))
            {
                newList.Add(new GtkTreeModelResult(ParentWidget, TModel, Column, currentIter)
                {
                    SourceQuery = this.SourceQuery
                });
            }

            return(newList);
        }
Ejemplo n.º 12
0
        IEnumerable <TreeIter> WalkStore(TreeModel model)
        {
            TreeIter iter;
            bool     valid = model.GetIterFirst(out iter);

            while (valid)
            {
                yield return(iter);

                valid = model.IterNext(ref iter);
            }
        }
Ejemplo n.º 13
0
        public static bool GetIterLast(this TreeModel model, out TreeIter iter)
        {
            iter = TreeIter.Zero;
            TreeIter result;

            if (!model.GetIterFirst(out result))
            {
                return(false);
            }
            iter = result;
            while (model.IterNext(ref result))
            {
                iter = result;
            }
            return(true);
        }
Ejemplo n.º 14
0
        // finds the specified item:
        // - select owner volume
        // - expand the treeview path to the item
        //   and select the item
        public void FindItem(VolumeItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            // get path of volume ids to item
            Stack <long> path = new Stack <long>();
            VolumeItem   tmp  = item;

            while (tmp.ItemID != 1)               // skip root item
            {
                path.Push(tmp.ItemID);
                tmp = database.GetVolumeItem(tmp.VolumeID, tmp.ParentID);
            }

            // find and select volume of specified item
            TreeModel model = tvVolumes.Model;
            TreeIter  iter;
            long      volumeID     = item.VolumeID;
            bool      hasMoreIters = true;

            model.GetIterFirst(out iter);

            while (hasMoreIters)
            {
                Volume vol = tvVolumes.GetVolume(iter);

                if (vol.VolumeID == volumeID)
                {
                    // select owner volume
                    tvVolumes.Selection.SelectIter(iter);
                    tvVolumes.ScrollToCell(model.GetPath(iter), null, false, .0f, .0f);

                    if (path.Count > 0)
                    {
                        // find and select specified item
                        tvItems.Model.GetIterFirst(out iter);
                        FindItemRecursive(iter, path);
                    }                     // else : specified item is the root item so select nothing
                    break;
                }

                hasMoreIters = model.IterNext(ref iter);
            }
        }
Ejemplo n.º 15
0
        private void PopulatePersonView()
        {
            List <Widget> children = new List <Widget> (vbox.Children);

            foreach (Widget child in children)
            {
                vbox.Remove(child);
                try {
                    child.Destroy();
                } catch {}
            }

            // personCardMap.Clear ();

            if (model == null)
            {
                Logger.Debug("PersonView.PopulatePersonView returning since the model is null.");
                return;
            }

            TreeIter iter;

            // Loop through the model, create the PersonCard objects and add
            // them into the vbox.
            if (model.GetIterFirst(out iter))
            {
                do
                {
                    Person person = model.GetValue(iter, 0) as Person;
                    if (person == null)
                    {
                        continue;
                    }

                    TreePath   path = model.GetPath(iter);
                    PersonCard card = new PersonCard(person);
                    card.Size = personCardSize;
                    card.ShowAll();
                    vbox.PackStart(card, false, false, 0);
                    vbox.ReorderChild(card, path.Indices [0]);
                    // personCardMap[iter] = card;
                } while (model.IterNext(ref iter));
            }
        }
Ejemplo n.º 16
0
        public override List <AppResult> NextSiblings()
        {
            if (!resultIter.HasValue)
            {
                return(null);
            }

            return((List <AppResult>)AutoTestService.CurrentSession.UnsafeSync(() => {
                List <AppResult> newList = new List <AppResult> ();
                TreeIter currentIter = (TreeIter)resultIter;

                while (TModel.IterNext(ref currentIter))
                {
                    newList.Add(new GtkTreeModelResult(TView, TModel, Column, currentIter));
                }

                return newList;
            }));
        }
Ejemplo n.º 17
0
        List <String> GetConfigFromTreeview(TreeView tv)
        {
            TreeIter      iter;
            List <String> config = new List <string> ();

            try {
                TreeModel model = tv.Model;
                model.GetIterFirst(out iter);
                do
                {
                    config.Add(model.GetValue(iter, 0).ToString());
                } while (model.IterNext(ref iter));
                return(config);
            } catch (Exception ex) {
                MainClass.log.Error("Load config from treeview failed");
                MainClass.log.Debug(ex.Message);
                MainClass.log.Debug(ex.StackTrace);
                return(config = new List <string> ());
            }
        }
Ejemplo n.º 18
0
        void DoTheExport(MiscHelpers.TemplateType type)
        {
            TreeModel model = treeDebaters.Model;
            TreeIter  iter;

            if (model.GetIterFirst(out iter))
            {
                try {
                    ITemplate  tmpl         = MiscHelpers.GetTemplate("debaters", type);
                    ITmplBlock tmplDebaters = tmpl.ParseBlock("DEBATERS");
                    int        n            = 0;
                    do
                    {
                        n++;
                        TreeIter        storeIter = ConvertModelIterToStoreIter(iter);
                        EditableDebater d         = (EditableDebater)store.GetValue(storeIter, 0);
                        tmplDebaters.Assign("NUM", n.ToString());
                        tmplDebaters.Assign("NAME", d.Name.ToString());
                        tmplDebaters.Assign("CLUB", d.Club.ToString());
                        tmplDebaters.Assign("AGE", d.Age.ToString());
                        tmplDebaters.Assign("ROLE", EscapeString(d.Role.ToString(), type));
                        tmplDebaters.Assign("BLACKLIST", EscapeString(d.BlackList.ToString(), type));
                        tmplDebaters.Assign("WHITELIST", EscapeString(d.WhiteList.ToString(), type));
                        tmplDebaters.Assign("EXTRAINFO", EscapeString(d.ExtraInfo.ToString(), type));
                        tmplDebaters.Out();
                    }while(model.IterNext(ref iter));
                    MiscHelpers.AskShowTemplate(this,
                                                "Debaters successfully generated, see " +
                                                "pdfs/debaters.(pdf|csv)",
                                                MiscHelpers.MakeExportFromTemplate()
                                                );
                }
                catch (Exception ex) {
                    MiscHelpers.ShowMessage(this, "Could not export Debaters: " + ex.Message, MessageType.Error);
                }
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Fill a list of events from a list of paths, if the first and unique path is an EventType the list
        /// is filled with al the child events in this EventType category.
        /// </summary>
        /// <param name = "model">Model.</param>
        /// <param name="events">Events.</param>
        /// <param name="paths">Paths.</param>
        public static List <LMTimelineEvent> EventsListFromPaths(TreeModel model, TreePath[] paths)
        {
            List <LMTimelineEvent> events = new List <LMTimelineEvent> ();

            // If it's an EventType or a Player, traverse all children to fill the list
            if (paths.Length == 1 && !(model.GetValue(paths [0]) is LMTimelineEvent))
            {
                TreeIter parentIter;
                TreeIter child;
                bool     hasChild;

                model.GetIter(out parentIter, paths [0]);
                hasChild = model.IterHasChild(parentIter);
                model.IterChildren(out child, parentIter);
                while (hasChild)
                {
                    LMTimelineEvent evt = model.GetValue(child, 0) as LMTimelineEvent;
                    if (evt != null)
                    {
                        events.Add(evt);
                    }
                    hasChild = model.IterNext(ref child);
                }
            }
            else
            {
                foreach (var path in paths)
                {
                    LMTimelineEvent evt = model.GetValue(path) as LMTimelineEvent;
                    if (evt != null)
                    {
                        events.Add(evt);
                    }
                }
            }
            return(events);
        }
Ejemplo n.º 20
0
        public void SelectCacheByName(string code)
        {
            if (code == null)
            {
                cacheListTree.Selection.UnselectAll();
                return;
            }

            TreeIter  itr;
            TreeModel model = cacheListTree.Model;

            cacheListTree.Model.GetIterFirst(out itr);
            do
            {
                Geocache cache = (Geocache)model.GetValue(itr, 0);
                if (cache.Name == code)
                {
                    cacheListTree.Selection.SelectIter(itr);
                    TreePath path = cacheListTree.Model.GetPath(itr);
                    cacheListTree.ScrollToCell(path, cacheListTree.Columns[0], true, 0, 0);
                    return;
                }
            }while (model.IterNext(ref itr));
        }
    public static void Copy(TreeModel tree, TreeIter tree_iter, ListStore list, bool first)
    {
        // Copy this iter's values to the list
                TreeIter list_iter = list.Append();
                for (int i = 0; i < list.NColumns; i++) {
                        list.SetValue(list_iter, i, tree.GetValue(tree_iter, i));
                        if (i == 1) {
                                //Console.WriteLine("Copying {0}", list.GetValue(list_iter, i));
                        }
                }

                // Copy the first child, which will trigger the copy if its siblings (and their children)
                TreeIter child_iter;
                if (tree.IterChildren(out child_iter, tree_iter)) {
                        Copy(tree, child_iter, list, true);
                }

                // Add siblings and their children if we are the first child, otherwise doing so would repeat
                if (first) {
                        while (tree.IterNext(ref tree_iter)) {
                                Copy(tree, tree_iter, list, false);
                        }
                }
    }
Ejemplo n.º 22
0
        private void FocusHelper(bool move_next)
        {
            if (focused_path == null)
            {
                return;
            }

            TreeIter focused_iter;

            if (!model.GetIter(out focused_iter, focused_path))
            {
                return;
            }

            int focus_x, focus_y;

            GetPlotPoint(focused_iter, out focus_x, out focus_y);

            // we can't just do focused_path.Prev () since there is
            // a disconnect between the order in the model and
            // where the axis has us place points.  besides, we
            // need to clamp the focus region to the zoom rect.
            TreeIter iter;

            if (!model.GetIterFirst(out iter))
            {
                return;
            }

            int total_height = (Allocation.Y + Allocation.Height);

            TreePath min_path    = null;
            int      min_x_delta = Int32.MaxValue;
            int      min_y_delta = Int32.MaxValue;

            do
            {
                TreePath path = model.GetPath(iter);

                // don't try to focus the same point again
                if (path.Compare(focused_path) == 0)
                {
                    continue;
                }

                int x, y;
                GetPlotPoint(iter, out x, out y);

                // if its out of bounds, throw it out
                if (IsBarOutOfBounds(x, y))
                {
                    continue;
                }

                int x_delta = 0, y_delta = 0;
                if (move_next)
                {
                    // find the bar with the smallest positive x
                    // delta, and smallest y, or if there
                    // is a tie, the one that's larger on the y
                    // axis
                    x_delta = x - focus_x;
                    y_delta = (focus_x != x) ? total_height - y : focus_y - y;
                }
                else
                {
                    // find the bar with the smallest positive x
                    // delta, and largest y, or if there
                    // is a tie, the one that's larger on the y
                    // axis
                    x_delta = focus_x - x;
                    y_delta = (focus_x != x) ? y : y - focus_y;
                }

                // don't go backward, and don't pick a bigger
                // delta than we already have
                if (x_delta < 0 ||
                    x_delta > min_x_delta)
                {
                    continue;
                }

                if (x_delta == min_x_delta &&
                    y_delta >= min_y_delta)
                {
                    continue;
                }

                // if we're at the same X value, make sure
                // we're moving forward in the y direction so
                // we don't get stuck in loops
                if (x_delta == 0 &&
                    y_delta < 0)
                {
                    continue;
                }

                min_x_delta = x_delta;
                min_y_delta = y_delta;
                min_path    = path;
            } while (model.IterNext(ref iter));

            if (min_path != null)
            {
                focused_path = min_path;
            }
            else
            {
                if (move_next)
                {
                    focused_path = TreePath.NewFirst();
                }
                else
                {
                    focused_path = new TreePath(new int[] {
                        model.IterNChildren() - 1
                    });
                }
            }

            if (Changed != null)
            {
                Changed(this, new EventArgs());
            }
        }
Ejemplo n.º 23
0
            private static bool UpdateGameInModel(PGNChessGame
							       game,
							       PGNChessGame
							       replace,
							       TreeModel
							       model)
            {
                TreeIter iter;
                bool ret;
                for (ret = model.GetIterFirst (out iter); ret;
                     ret = model.IterNext (ref iter))
                  {
                      PGNChessGame g =
                          (PGNChessGame) model.
                          GetValue (iter, 0);
                      if (g.Equals (game))
                        {
                            model.SetValue (iter, 0,
                                    replace);
                            return true;
                        }
                  }

                return false;
            }
Ejemplo n.º 24
0
		private bool DoesSiblingLocationNeedToBeDisplayed(TreeModel model, TreeIter node, string key){	
			bool retVal = false;
			
			do {
				if((model.GetValue(node,0) as Location).Item.MatchesKey(key)){
					retVal = true;
					break;
				}
				else {
					TreeIter child;
					if(model.IterChildren(out child,node)){
						if(DoesSiblingLocationNeedToBeDisplayed(model,child,key) == true){
							retVal = true;
							break;
						}
					}
				}
			} while(model.IterNext(ref node));
			
			return retVal;
		}
Ejemplo n.º 25
0
    void ShowMarketGroupItems(TreeModel model, TreeIter iter)
    {
        // Clear the VBox
        while (vbbMarketGroups.Children.Length > 0)
        {
            vbbMarketGroups.Remove(vbbMarketGroups.Children[0]);
        }

        TreeIter childIter;
        // get children iterator
        if (model.IterChildren(out childIter, iter))
        {
            do
            {
                long ID = Convert.ToInt64(model.GetValue(childIter, 2));
                ECM.EveItem item = ECM.ItemDatabase.Items[ID];

                AddItemToCurrentMarketGroup(item, model, childIter);
            }
            while (model.IterNext(ref childIter));

            ntbMarketDetails.CurrentPage = 1;
        }
    }
Ejemplo n.º 26
0
        private void Redraw(Cairo.Context cr)
        {
            // Clear the background
            cr.Rectangle(0, 0, Allocation.Width, Allocation.Height);
            Gdk.CairoHelper.SetSourceColor(cr, Style.Base(State));
            cr.Fill();

            if (model == null)
            {
                if (hadj != null)
                {
                    hadj.Upper = hadj.Lower = 0;
                    hadj.Change();
                }

                if (vadj != null)
                {
                    vadj.Upper = 0;
                    vadj.Change();
                }
                return;
            }

            if (rows == 0 || cols == 0)
            {
                return;
            }

            Gdk.Rectangle background_area = cell_size;
            background_area.Width  += padding;
            background_area.Height += padding;

            TreeIter iter;

            if (model.GetIterFirst(out iter))
            {
                do
                {
                    TreePath path = model.GetPath(iter);

                    int x, y;
                    GetCellPosition(path.Indices[0], out x, out y);

                    if (hadj != null &&
                        (x + cell_size.Width < hadj.Value ||
                         x > hadj.Value + hadj.PageSize))
                    {
                        continue;
                    }

                    if (vadj != null &&
                        (y + cell_size.Height < vadj.Value ||
                         y > vadj.Value + vadj.PageSize))
                    {
                        continue;
                    }

                    if (data_func != null)
                    {
                        data_func(this, renderer, model, iter);
                    }

                    cell_size.X = x;
                    cell_size.Y = y;

                    if (hadj != null)
                    {
                        cell_size.X -= (int)hadj.Value;
                    }

                    if (vadj != null)
                    {
                        cell_size.Y -= (int)vadj.Value;
                    }

                    background_area.X = cell_size.X - (padding / 2);
                    background_area.Y = cell_size.Y - (padding / 2);

                    cr.Rectangle(background_area.X, background_area.Y,
                                 background_area.Width, background_area.Height);
                    cr.Clip();

                    renderer.Render(cr, this, background_area,
                                    cell_size, GetCellState(path));

                    cr.ResetClip();
                } while (model.IterNext(ref iter));
            }

            if (have_rubberband_selection)
            {
                int hadj_val = (hadj != null) ? (int)hadj.Value : 0;
                int vadj_val = (vadj != null) ? (int)vadj.Value : 0;

                cr.Rectangle(sel_rect.X - hadj_val + 0.5f, sel_rect.Y - vadj_val + 0.5f,
                             sel_rect.Width, sel_rect.Height);

                Cairo.Color sel_cairo_color = CairoHelper.GetCairoColor(Style.Background(StateType.Selected));



                //cr.Color = sel_cairo_color;
                cr.SetSourceRGBA(sel_cairo_color.R, sel_cairo_color.G, sel_cairo_color.B, sel_cairo_color.A);

                cr.LineWidth = 1.0f;
                cr.StrokePreserve();

                sel_cairo_color.A = 0.3f;
                //cr.Color = sel_cairo_color;
                cr.SetSourceRGBA(sel_cairo_color.R, sel_cairo_color.G, sel_cairo_color.B, sel_cairo_color.A);

                cr.Fill();
            }
        }
Ejemplo n.º 27
0
		IEnumerable<TreeIter> WalkStore (TreeModel model)
		{
			TreeIter iter;
			bool valid = model.GetIterFirst (out iter);
			while (valid) {
				yield return iter;
				valid = model.IterNext (ref iter);
			}
		}
Ejemplo n.º 28
0
        protected void OnButton45Clicked(object sender, EventArgs e)
        {
            TcpClient client                  = new TcpClient(ServerIp, Int32.Parse(TcpPort));
            object    content                 = AssignmentChange;
            Type      contentType             = AssignmentChange.GetType();
            Protocol  submitAssignmentChanges = new Protocol(client, ConstValues.PROTOCOL_FN_SAVE_ASSIGNMENT, contentType, content);

            submitAssignmentChanges.Start();
            if ((String)submitAssignmentChanges.ResultObject == "True")
            {
                List <Dictionary <String, String> > assignmentList = new List <Dictionary <string, string> > ();
                TreeIter  iter;
                TreeModel model    = treeview6.Model;
                string    agent_id = combobox2.ActiveText.Split(':') [1];
                if (model.GetIterFirst(out iter))
                {
                    do
                    {
                        Dictionary <String, String> gpuAssign = new Dictionary <string, string> ();
                        gpuAssign.Add("agent_id", agent_id);
                        gpuAssign.Add("resource_ip", model.GetValue(iter, 0).ToString());
                        gpuAssign.Add("gpu_id", model.GetValue(iter, 1).ToString());
                        assignmentList.Add(gpuAssign);
                    } while(model.IterNext(ref iter));
                }
                List <String> rCudaClientRuntimeConfig = Configuration.GenerateRcudaClientRuntimeConfig(assignmentList);
                TcpClient     client2                   = new TcpClient(ServerIp, Int32.Parse(TcpPort));
                object        contentConfig             = rCudaClientRuntimeConfig;
                Type          contentTypeConfig         = rCudaClientRuntimeConfig.GetType();
                Protocol      uploadRuntimeClientConfig = new Protocol(client2, ConstValues.PROTOCOL_FN_SAVE_RCUDA_CLIENT_CONFIG, contentTypeConfig, contentConfig);
                uploadRuntimeClientConfig.Start();
                if ((String)uploadRuntimeClientConfig.ResultObject == "True")
                {
                    MessageDialog msg = new MessageDialog(null, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, "Resource assignment and Runtime Config has been saved");
                    msg.Response += (o, args) => {
                        if (args.ResponseId == ResponseType.Ok)
                        {
                            combobox2.Sensitive = true;
                            button48.Sensitive  = true;
                            button43.Sensitive  = false;
                            button44.Sensitive  = false;
                            button45.Sensitive  = false;
                            button46.Sensitive  = false;
                            gpuAssignView       = null;
                            AssignmentInProcess = false;
                            combobox2.Active    = -1;
                            foreach (var column in treeview6.Columns)
                            {
                                treeview6.RemoveColumn(column);
                            }
                            LoadAllGpuList();
                            msg.Destroy();
                        }
                    };
                    msg.Show();
                }
                else
                {
                    MessageDialog msg = new MessageDialog(null, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, "Save Runtime Config Failed");
                    msg.Response += (o, args) => {
                        if (args.ResponseId == ResponseType.Ok)
                        {
                            msg.Destroy();
                        }
                    };
                    msg.Show();
                }
            }
            else
            {
                MessageDialog msg = new MessageDialog(null, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, "Updating Resource Assignment Failed");
                msg.Response += (o, args) => {
                    if (args.ResponseId == ResponseType.Ok)
                    {
                        msg.Destroy();
                    }
                };
                msg.Show();
            }
        }