Ejemplo n.º 1
0
 public void Sort()
 {
     Items.Sort();
     store.Clear();
     foreach (object obj in Items)
     {
         store.AppendValues(obj);
     }
 }
Ejemplo n.º 2
0
        public FilteringWidget(Gtk.Window parent)
        {
            parentWindow = parent;
            this.Build();

            tvFilter.AppendColumn(MainClass.Languages.Translate("name"), new Gtk.CellRendererText(), "text", 0);
            tvMask.AppendColumn(MainClass.Languages.Translate("name"), new Gtk.CellRendererText(), "text", 0);


            tvFilter.Model = filterStore;
            tvMask.Model   = maskStore;

            if (MainClass.Settings == null)
            {
                return;
            }
            if (MainClass.Settings == null || MainClass.Settings.LogicalSort.Count < 1)
            {
                MainClass.Settings.LogicalSort = LogicalSystem.GetDefaultLogicalSystem();
            }

            this.conditions = new List <LogicalSystem>();

            conditions = MainClass.Tools.Clone(MainClass.Settings.LogicalSort);

            TreeIter ti = new TreeIter();

            foreach (LogicalSystem cd in conditions)
            {
                ti = filterStore.AppendValues(cd.Display, cd);
            }

            tvFilter.Selection.Changed += delegate(object sender, EventArgs e)
            {
                maskStore.Clear();
                LogicalSystem cd = GetSelected();
                if (cd == null)
                {
                    return;
                }

                if (cd.Mask == null)
                {
                    cd.Mask = new List <string>();
                }

                foreach (string rl in cd.Mask)
                {
                    maskStore.AppendValues(rl);
                }
            };
            if (conditions.Count > 0)
            {
                tvFilter.Selection.SelectIter(ti);
            }
        }
Ejemplo n.º 3
0
 public void Sort()
 {
     Items.Sort();
     store.Clear();
     //clear the checkboxes also
     checked_items.Clear();
     //add all values again
     foreach (object obj in Items)
     {
         store.AppendValues(false, obj);
     }
 }
Ejemplo n.º 4
0
 public void RemoveProjects(List <ProjectDescription> projects)
 {
     /* FIXME: to delete projects from the treeview we need to remove the filter
      * and clear everything, otherwise we have seen several crashes trying
      * to render cells with an invalid iter. It's not very performant, but
      * it's safe. */
     treeview.Model = projectsListStore;
     projectsListStore.Clear();
     foreach (ProjectDescription project in projects)
     {
         projectsList.Remove(project);
     }
     Fill(projectsList);
 }
Ejemplo n.º 5
0
    public void UpdatePath(string path)
    {
        if (String.IsNullOrEmpty(path))
        {
            return;
        }

        changesetListStore.Clear();
        changesetDetailView.Clear();
        changesetDiffView.Clear();

        bool        detailed   = false;
        IEnumerable changeSets = driver.VersionControlServer.QueryHistory(path, VersionSpec.Latest, 0, RecursionType.Full, null,
                                                                          null, null, stopAfter, detailed, false, false);

        foreach (Changeset changeSet in changeSets)
        {
            changesetListStore.AppendValues(changeSet.ChangesetId,
                                            changeSet.Owner,
                                            changeSet.CreationDate.ToString("d"),
                                            changeSet.Comment);
        }

        // this would be nice be seems to cause a segfault
        //changesetList.ColumnsAutosize();
    }
Ejemplo n.º 6
0
    public void UpdatePath(string path)
    {
        if (String.IsNullOrEmpty(path))
        {
            return;
        }
        directoryListStore.Clear();

        ExtendedItem[] items = driver.VersionControlServer.GetExtendedItems(path, DeletedState.NonDeleted, ItemType.Any);

        foreach (ExtendedItem item in items)
        {
            string latest = item.IsLatest ? "Yes" : "No";

            string status = item.LockStatus.ToString();
            if (status == "None")
            {
                status = String.Empty;
            }

            string shortPath = item.TargetServerItem.Substring(item.TargetServerItem.LastIndexOf('/') + 1);
            if (item.ItemType == ItemType.Folder)
            {
                shortPath += "/";
            }

            directoryListStore.AppendValues(shortPath, status, item.LockOwner, latest);
        }

        // this would be nice be seems to cause a segfault
        //changesetList.ColumnsAutosize();
    }
        void UpdateList()
        {
            if (displayedHashCode == ComponentManager.Localization.GetCurrentHashcode())
            {
                return;
            }
            displayedHashCode = ComponentManager.Localization.GetCurrentHashcode();
            listStore.Clear();

            Dictionary <string, Localization.Node> dn = ComponentManager.Localization.GetDefaultNodes();

            foreach (Localization.Node node in dn.Values)
            {
                Gtk.TreeIter iter = listStore.Append();
                listStore.SetValue(iter, nodeIndex, node);
                listStore.SetValue(iter, keyIndex, node.Key);
                listStore.SetValue(iter, usValueIndex, node.Value);

                Localization.Node ln = ComponentManager.Localization.FindCurrentNode(node.Key);
                if (ln != null)
                {
                    listStore.SetValue(iter, localValueIndex, ln.Value);
                }
            }
        }
Ejemplo n.º 8
0
        void RefreshKeyStore()
        {
            TreeIter iter;
            var      keys = Scheme.Keys.Cast <PListScheme.SchemaItem> ();

            if (treeview.Selection.GetSelected(out iter))
            {
                var currentObj = (PObject)treeStore.GetValue(iter, 1);
                if (treeStore.IterParent(out iter, iter))
                {
                    var obj = (PObject)treeStore.GetValue(iter, 1);
                    keys = PListScheme.AvailableKeys(obj, CurrentTree);
                }
            }

            keyStore.Clear();
            if (keys != null)
            {
                var sortedKeys = new List <PListScheme.SchemaItem> (keys);
                if (ShowDescriptions)
                {
                    sortedKeys.Sort((x, y) => StringComparer.CurrentCulture.Compare(x.Description, y.Description));
                }
                else
                {
                    sortedKeys.Sort((x, y) => StringComparer.CurrentCulture.Compare(x.Identifier, y.Identifier));
                }

                foreach (var key in sortedKeys)
                {
                    keyStore.AppendValues(ShowDescriptions ? key.Description : key.Identifier, key);
                }
            }
        }
Ejemplo n.º 9
0
        void PropRendererEditingStarted(object o, EditingStartedArgs args)
        {
            try {
                valueStore.Clear();

                TreeIter iter;
                if (!treeStore.GetIterFromString(out iter, args.Path))
                {
                    return;
                }

                var obj    = (PObject)treeStore.GetValue(iter, 1);
                var values = PListScheme.AvailableValues(obj, CurrentTree);
                if (values != null)
                {
                    var descr = new List <string> (values.Select(v => ShowDescriptions ? v.Description : v.Identifier));
                    descr.Sort();
                    foreach (var val in descr)
                    {
                        valueStore.AppendValues(val);
                    }
                }
            } catch (Exception ex) {
                GLib.ExceptionManager.RaiseUnhandledException(ex, false);
            }
        }
Ejemplo n.º 10
0
        //Table tblAtributes;
        public NewFileDialog()
        {
            this.TransientFor = MainClass.MainWindow;
            this.Build();
            notebook1.ShowTabs = false;
            btnBack.Sensitive  = false;
            //tvItem1.AppendColumn("", new Gtk.CellRendererPixbuf(), "pixbuf", 0);
            tvItem1.AppendColumn(MainClass.Languages.Translate("template"), new Gtk.CellRendererText(), "text", 0);
            tvItem1.AppendColumn(MainClass.Languages.Translate("description"), new Gtk.CellRendererText(), "text", 1);

            tvItem.Selection.Changed += delegate(object sender, EventArgs e) {
                fileListStore.Clear();
                if (Directory.Exists(MainClass.Paths.FileTemplateDir))
                {
                    string typeFile = GetSelectedTypFile();
                    typeFile = String.Format("*{0}", typeFile);
                    FileInfo[] fis = new DirectoryInfo(MainClass.Paths.FileTemplateDir).GetFiles(typeFile);

                    fileListStore.AppendValues(MainClass.Languages.Translate("empty_file"), MainClass.Languages.Translate("empty_file"), "", null);

                    foreach (FileInfo fi in fis)
                    {
                        FileTemplate t = new FileTemplate(fi, true);
                        //if (String.Compare(t.TemplateType, "moscrif source code", true) != 0) continue;
                        //templates.Items.Add(t);
                        fileListStore.AppendValues(t.Name, t.Description, fi.FullName, t);
                    }
                }
                tvItem1.Model = fileListStore;
                tvItem1.Selection.SelectPath(new TreePath("0"));
                //cbFileTemplates.Model = fileListStore;
                //cbFileTemplates.Active = 0;
            };
            FillType();
        }
Ejemplo n.º 11
0
    private void LoadRomsList()
    {
        LoadConfig();
        if (File.Exists("preferences.ini") && File.Exists("bios.txt"))
        {
            if (config.MameExe != "" && config.Roms != "")
            {
                romsListStore.Clear();
                List <string> filesToIgnore = new List <String> (File.ReadAllLines("bios.txt"));
                List <string> romsTitles    = new List <String> (File.ReadAllLines("mame_roms.txt"));
                List <Roms>   roms          = new List <Roms> ();
                List <Roms>   romTitle;
                string        file          = string.Empty;
                string        fileWithNoExt = string.Empty;

                foreach (string line in romsTitles)
                {
                    roms.Add(new Roms(line.Substring(0, 18).Trim(), line.Substring(19, line.Length - 20).Trim()));
                }

                foreach (string romFile in Directory.GetFiles(config.Roms))
                {
                    file          = System.IO.Path.GetFileName(romFile);
                    fileWithNoExt = System.IO.Path.GetFileNameWithoutExtension(romFile);
                    romTitle      = roms.FindAll(x => x.RomFile == fileWithNoExt);
                    if (!filesToIgnore.Contains(file))
                    {
                        romsListStore.AppendValues(fileWithNoExt, romTitle[0].RomTitle);
                    }
                }

                tvRoms.Model = romsListStore;
            }
        }
    }
Ejemplo n.º 12
0
		public ListCategoriaView ()
		{
			this.Build ();

			deleteAction.Sensitive = false;
			editAction.Sensitive = false;

			dbConnection = App.Instance.DbConnection;


			treeView.AppendColumn ("id", new CellRendererText (), "text", 0);
			treeView.AppendColumn ("nombre", new CellRendererText (), "text", 1);
			listStore = new ListStore (typeof(ulong), typeof(string));
			treeView.Model = listStore;

			fillListStore ();

			treeView.Selection.Changed += selectionChanged;

			refreshAction.Activated += delegate {
				listStore.Clear();
				fillListStore();
			};

		}
Ejemplo n.º 13
0
        private void updateList(string selectStatement = null)
        {
            //Update values to be passed to TreeView
            //Store cars "id_carro", "placa", "cor", "data".
            carrosListStore.Clear();
            List <Carro> listCarros = new List <Carro>();

            using (var conn = CreateConnection())
            {
                if (selectStatement != null)
                {
                    listCarros = ReadData(conn, selectStatement);
                }
                else
                {
                    listCarros = ReadData(conn);
                }
            }
            foreach (Carro carro in listCarros)
            {
                carrosListStore.AppendValues(carro.id_carro, carro.Placa, carro.Cor, carro.Data);
            }
            //carrosListStore.AppendValues(1, "FHF3838", "Branco", "2020-11-22");
            tree.Model = carrosListStore;
        }
Ejemplo n.º 14
0
        public void Clear()
        {
            if (store != null)
            {
                store.Clear();
                store = null;
                //store = new ListStore ((int)TypeFundamentals.TypeString);
                store = new ListStore(GType.String);
            }
            else
            {
                //store = new ListStore ((int)TypeFundamentals.TypeString);
                store = new ListStore(GType.String);
            }

            if (gridColumns != null)
            {
                for (int c = 0; c < gridColumns.Length; c++)
                {
                    if (gridColumns[c] != null)
                    {
                        if (gridColumns[c].TreeViewColumn != null)
                        {
                            treeView.RemoveColumn(gridColumns[c].TreeViewColumn);
                            gridColumns[c].TreeViewColumn = null;
                        }
                        gridColumns[c] = null;
                    }
                }
                gridColumns = null;
            }
        }
Ejemplo n.º 15
0
		//This method is called everytime the System combobox selection is changed
		protected void SystemSelect (object sender, EventArgs e)
		{
			if(!isSetupFinished) return;

			selectedSystem = GameState.Instance.StarSystems [SystemList.Active];
			setSystemType (selectedSystem.Stars.Count);

			starDataShown.Clear ();
			int starCount = 0;
			foreach (Entities.Star aStar in selectedSystem.Stars) {
				starDataShown.AppendValues (aStar.Name, aStar.Class, aStar.Radius, aStar.Mass,
				                            aStar.Luminosity, aStar.Temperature, aStar.Life, aStar.SemiMajorAxis);

				planetList[starCount].Clear ();
				foreach (Entities.Planet aPlanet in aStar.Planets) {
					planetList[starCount].AppendValues (aPlanet.Name, aPlanet.PlanetTypeView, aPlanet.SurfaceTemperatureView, aPlanet.SurfaceGravityView,
					                                    aPlanet.MassOfGasInEarthMassesView, aPlanet.SemiMajorAxis, aPlanet.SurfacePressure, aPlanet.Radius);
				}

				switch(starCount)
				{
				case 0:
					StarA_Label.Text = aStar.Name;
					break;
				case 1:
					StarB_Label.Text = aStar.Name;
					break;
				case 2:
					StarC_Label.Text = aStar.Name;
					break;
				case 3:
					StarD_Label.Text = aStar.Name;
					break;
				}
					
				starCount++;
			} 

			for (; starCount<4; starCount++) {
				planetList[starCount].Clear ();
				switch(starCount)
				{
				case 0:
					StarA_Label.Text = "N/A";
					break;
				case 1:
					StarB_Label.Text = "N/A";
					break;
				case 2:
					StarC_Label.Text = "N/A";
					break;
				case 3:
					StarD_Label.Text = "N/A";
					break;
				}
			} 


		}
        private void PopulateList()
        {
            listStore.Clear();

//			foreach (IPEndPoint IPEndPoint in NodeCore.AddressManager.Instance.GetNetworkAddresses()) {
//				listStore.AppendValues (IPEndPoint.ToString (), "xx", "xx");// networkAddress.Time.ToString(), networkAddress.Ago.ToString());
//			}
        }
Ejemplo n.º 17
0
 void LoadList()
 {
     store.Clear();
     foreach (string s in SteticMain.SteticApp.GetWidgetLibraries())
     {
         AddLibrary(s);
     }
 }
Ejemplo n.º 18
0
        void Update()
        {
            needsUpdate = false;
            store.Clear();

            if (current_backtrace == null)
            {
                return;
            }

            for (int i = 0; i < current_backtrace.FrameCount; i++)
            {
                string icon;
                if (i == DebuggingService.CurrentFrameIndex)
                {
                    icon = Gtk.Stock.GoForward;
                }
                else
                {
                    icon = null;
                }

                StackFrame fr = current_backtrace.GetFrame(i);

                StringBuilder met  = new StringBuilder(fr.SourceLocation.MethodName);
                ObjectValue[] args = fr.GetParameters();
                if (args.Length != 0 || !fr.SourceLocation.MethodName.StartsWith("["))
                {
                    met.Append(" (");
                    for (int n = 0; n < args.Length; n++)
                    {
                        if (n > 0)
                        {
                            met.Append(", ");
                        }
                        met.Append(args[n].Name).Append("=").Append(args[n].Value);
                    }
                    met.Append(")");
                }

                string file;
                if (!string.IsNullOrEmpty(fr.SourceLocation.FileName))
                {
                    file = fr.SourceLocation.FileName;
                    if (fr.SourceLocation.Line != -1)
                    {
                        file += ":" + fr.SourceLocation.Line;
                    }
                }
                else
                {
                    file = string.Empty;
                }

                store.AppendValues(icon, met.ToString(), file, fr.Language, "0x" + fr.Address.ToString("x"), null,
                                   fr.IsExternalCode? Pango.Style.Italic : Pango.Style.Normal);
            }
        }
Ejemplo n.º 19
0
        private void PopulateList()
        {
            listStore.Clear();

            foreach (String address in JsonLoader <Network> .Instance.Value.Seeds)
            {
                listStore.AppendValues(address, "IP");
            }
        }
Ejemplo n.º 20
0
        void Update()
        {
            if (tree.IsRealized)
            {
                tree.ScrollToPoint(0, 0);
            }

            needsUpdate = false;
            store.Clear();

            if (current_backtrace == null)
            {
                return;
            }

            var options = DebuggingService.DebuggerSession.Options.EvaluationOptions;

            for (int i = 0; i < current_backtrace.FrameCount; i++)
            {
                string icon;
                if (i == DebuggingService.CurrentFrameIndex)
                {
                    icon = Gtk.Stock.GoForward;
                }
                else
                {
                    icon = null;
                }

                StackFrame frame = current_backtrace.GetFrame(i);
                if (frame.IsDebuggerHidden)
                {
                    continue;
                }

                var method = EvaluateMethodName(frame, options);

                string file;
                if (!string.IsNullOrEmpty(frame.SourceLocation.FileName))
                {
                    file = frame.SourceLocation.FileName;
                    if (frame.SourceLocation.Line != -1)
                    {
                        file += ":" + frame.SourceLocation.Line;
                    }
                }
                else
                {
                    file = string.Empty;
                }

                var style = frame.IsExternalCode ? Pango.Style.Italic : Pango.Style.Normal;

                store.AppendValues(icon, method, file, frame.Language, "0x" + frame.Address.ToString("x"), null,
                                   style, frame, !options.AllowDisplayStringEvaluation);
            }
        }
        public static void Copy(TreeModel tree, ListStore list)
        {
                list.Clear();

                TreeIter tree_iter;
                if (tree.IterChildren(out tree_iter)) {
                        Copy(tree, tree_iter, list, true);
                }
        }
Ejemplo n.º 22
0
    protected void Replace(object sender, EventArgs e)
    {
        array2.Clear();
        var sorted = Sort(ref F);

        for (int i = 0; i < sorted.Count; i++)
        {
            array2.InsertWithValues(i, $"P[{i}] = {F[i]}");
        }
    }
Ejemplo n.º 23
0
    protected void Sort(object sender, EventArgs e)
    {
        array2.Clear();
        BubbleSort(ref Array);

        for (int i = 0; i < 15; i++)
        {
            array2.InsertWithValues(i, $"Array[{i}] = {Array[i]}");
        }
    }
Ejemplo n.º 24
0
 private void fillListStore(ListStore listStore)
 {
     listStore.Clear ();
     IDbCommand dbCommand = App.Instace.DbConnection.CreateCommand ();
     dbCommand.CommandText = "select * from categoria order by id";
     IDataReader dataReader = dbCommand.ExecuteReader ();
     while (dataReader.read())
         listStore.AppendValues (dataReader ["id"], dataReader ["nombre"]);
     dataReader.close();
 }
Ejemplo n.º 25
0
    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();
        mySqlConnection.Open();
        MySqlCommand mySqlCommand=mySqlConnection.CreateCommand();
        mySqlCommand.CommandText= "select * from categoria";
        MySqlDataReader mysqlDataReader= mySqlCommand.ExecuteReader();
        int fieldcount=mysqlDataReader.FieldCount;

        creaColumnas(fieldcount,mysqlDataReader);
        ListStore listStore=new ListStore(creaTipos(fieldcount));
        rellenar(fieldcount,listStore,mysqlDataReader);
        mysqlDataReader.Close();

        removeAction.Sensitive=false;
        treeView.Model=listStore;
        TreeIter iter;

        treeView.Selection.Changed+=delegate{
            bool isSelected=treeView.Selection.GetSelected(out iter);
            if(isSelected)
                removeAction.Sensitive=true;
            else
                removeAction.Sensitive=false;
        };

        removeAction.Activated +=delegate{
            string nombre=listStore.GetValue(iter,1).ToString();
            MessageDialog md2 = new MessageDialog
                        (this, DialogFlags.Modal, MessageType.Warning, ButtonsType.YesNo,"¿Seguro que quieres borrarlo? \n Borrar: "+nombre);

            ResponseType result = (ResponseType)md2.Run ();
            string op=listStore.GetValue(iter,0).ToString();

            if (result == ResponseType.Yes){
                MySqlCommand delete=mySqlConnection.CreateCommand();
                delete.CommandText= "Delete from categoria where id="+op+"";
                delete.ExecuteNonQuery();
                md2.Destroy();

                for (int i=0;i<fieldcount;i++){//elimina columnas
                    treeView.RemoveColumn(treeView.GetColumn(0));
                }
                listStore.Clear();//vacia el modelo
                //volvemos a mostrar treview actualizado
                actualizar(mySqlCommand,listStore);

            }
            else{
                md2.Destroy();

            }
        };
    }
Ejemplo n.º 26
0
 protected void replace(object sender, EventArgs e)
 {
     array2.Clear();
     for (var i = 0; i < 18; i++)
     {
         if ((0.13 * Math.Pow(F[i], 3) - 2.5 * F[i] + 8) < 0)
         {
             array2.InsertWithValues(i, $"P[{i}] = {0.13 * Math.Pow(F[i], 3) - 2.5 * F[i] + 8}");
         }
     }
 }
Ejemplo n.º 27
0
    public void UpdateFiles()
    {
        filename_list.Clear();

        List <Note> notes = note_store.Notes();

        foreach (Note note in notes)
        {
            filename_list.AppendValues(note.Title, note.Filename, note.Created, note);
        }
    }
Ejemplo n.º 28
0
    protected void refresh(object sender, EventArgs e)
    {
        array1.Clear();
        var rand = new Random();

        for (var i = 0; i < 18; i++)
        {
            F[i] = rand.Next(-50, 50);
            array1.InsertWithValues(i, $"F[{i}] = {F[i]}");
        }
    }
Ejemplo n.º 29
0
        private void SetLogViewModel(LogViewModel logViewModel)
        {
            if (m_logViewModel != null)
            {
                //detach handlers
                ((INotifyCollectionChanged)m_logViewModel.Events).CollectionChanged -= EventsCollectionChanged;
                m_logStore.Clear();
            }

            m_logViewModel = logViewModel;

            // Load existing tasks
            foreach (LogInfo logInfo in m_logViewModel.Events)
            {
                AddEventUnit(logInfo);
            }

            //attach listener to Events collection, so that view is updated anytime there is new log message in the collection
            ((INotifyCollectionChanged)m_logViewModel.Events).CollectionChanged += EventsCollectionChanged;
        }
Ejemplo n.º 30
0
    protected void Refresh(object sender, EventArgs e)
    {
        array1.Clear();
        F.Clear();

        for (var i = 0; i < 18; i++)
        {
            F.Add(rand.Next(-50, 50));
            array1.InsertWithValues(i, $"F[{i}] = {F[i]}");
        }
    }
Ejemplo n.º 31
0
        private void PopulateFaceTable(TreeView tv, List <CardDefinitions.CardDefClass> faceDef)
        {
            Gtk.ListStore treemodel = (Gtk.ListStore)tv.Model;
            treemodel.Clear();

            foreach (CardDefinitions.CardDefClass item in faceDef)
            {
                String[] line = { item.COLUMNSOURCE, item.LANGUAGECODE, item.TYPE?"Voice":"Text" };
                treemodel.AppendValues(line);
            }
        }
Ejemplo n.º 32
0
 void Initialize()
 {
     lock (listStore)
     {
         listStore.Clear();
         JobInfo[] jobs = JobInfo.GetJobs();
         foreach (JobInfo job in jobs)
         {
             AddJob(job);
         }
     }
 }
Ejemplo n.º 33
0
        private void SetWorkspaceViewModel(ApplicationViewModel applicationViewModel)
        {
            if (m_workspaceViewModel != null)
            {
                //detach handlers
                ((INotifyCollectionChanged)m_workspaceViewModel.WorkspaceUnitCollection).CollectionChanged -= WorkspaceCollectionChanged;
                m_workspaceStore.Clear();
            }

            m_workspaceViewModel = applicationViewModel.WorkspaceViewModel;
            m_experimentId       = applicationViewModel.Experiment.ExperimentInfo.Id;

            // Load existing tasks
            foreach (WorkspaceUnit unit in m_workspaceViewModel.WorkspaceUnitCollection)
            {
                AddUnit(unit);
            }

            //attach listener to workspace collection
            ((INotifyCollectionChanged)m_workspaceViewModel.WorkspaceUnitCollection).CollectionChanged += WorkspaceCollectionChanged;
        }
Ejemplo n.º 34
0
        /// <summary>
        /// Builds the tags hierarchy of components
        /// and adds it to the tree view.
        /// </summary>
        private void BuildTagsHierarchy()
        {
            //assure list is clear
            m_componentsListModel.Clear();

            // currently view is a simple list
            //TODO: Create tree view from tags. (also check out TreeModelDemo in GtkSharp examples (in program files)
            foreach (MetadataDefinition component in m_componentsLibraryViewModel.ComponentsCollection)
            {
                TreeIter item = m_componentsListModel.AppendValues(component.Label, component);
            }
        }
Ejemplo n.º 35
0
        public static void refreshTreeView()
        {
            listStore =(ListStore) treeView.Model;
            listStore.Clear ();

            IEnumerable<IList> values = queryResult.Rows;

            foreach (IList k in values) {
                listStore.AppendValues (k);

            }
        }
Ejemplo n.º 36
0
    private void fillListStore(ListStore listStore)
    {
        listStore.Clear ();

        IDbCommand dbcommand = App.Instance.DbConnection.CreateCommand ();
        dbcommand.CommandText = "select * from categoria order by id";
        IDataReader dataReader = dbcommand.ExecuteReader ();
        while (dataReader.Read()) {
            //Console.WriteLine ("id={0} nombre={1}", dataReader ["id"], dataReader ["nombre"]);
            listStore.AppendValues (dataReader ["id"], dataReader ["nombre"]);
        }
        dataReader.Close ();
    }
Ejemplo n.º 37
0
		public ListArticuloView ()
		{
			this.Build ();
			deleteAction.Sensitive = false;
			editAction.Sensitive = false;

			dbConnection = App.Instance.DbConnection;

			treeView.AppendColumn ("id", new CellRendererText (), "text", 0);
			treeView.AppendColumn ("nombre", new CellRendererText (), "text", 1);
			treeView.AppendColumn ("categoria", new CellRendererText (), "text", 2);
			//articuloTreeView.AppendColumn ("precio", new CellRendererText (), "text", 3);

			treeView.AppendColumn ("precio", new CellRendererText (), 
			                               new TreeCellDataFunc (delegate(TreeViewColumn tree_column, CellRenderer cell, 
			                               TreeModel tree_model, TreeIter iter) {
				object value = tree_model.GetValue(iter, 3);
				((CellRendererText)cell).Text = value != DBNull.Value ? value.ToString() : "null";
			})
			                               );
			listStore = new ListStore (typeof(ulong), typeof(string), 
			                                   typeof(string), typeof(decimal));
			treeView.Model = listStore;

			fillListStore ();

			treeView.Selection.Changed += selectionChanged;

			refreshAction.Activated += delegate {
				listStore.Clear();
				fillListStore();
			};

			editAction.Activated += delegate {
				new ArticuloView();

			};

			//TODO resto de actions
		}
Ejemplo n.º 38
0
    protected void OnButton2Clicked(object sender, EventArgs e)
    {
        printed = false;
        varList.Clear ();
        consoletext.Buffer.Clear();

        string code = textview1.Buffer.Text;
        string[] codearray = code.Split ('\n');

        string hairegex = @"^\s*(I HAS A) ([a-zA-Z][a-zA-Z0-9]*) ?(ITZ)? ?(.+)?";
        string startregex = @"^\s*(HAI)\s*$";
        string visibleregex = @"\s*(VISIBLE) (.*)";
        string commentregex = @"\s*(OBTW)";
        string endregex = @"^\s*(KTHXBYE)\s*$";
        string endcommentregex = @"(TLDR)\s*$";
        string numvarwtfregex = @"(([a-zA-Z][a-zA-Z0-9]*), WTF?)|((-?[0-9]*\.?[0-9]+), WTF?)";

        string addregex = @"^\s*(SUM OF)";
        string subregex = @"^\s*(DIFF OF)";
        string mulregex = @"^\s*(PRODUKT OF)";
        string divregex = @"^\s*(QUOSHUNT OF)";
        string modregex = @"^\s*(MOD OF)";
        string biggrregex = @"^\s*(BIGGR OF)";
        string smallrregex = @"^\s*(SMALLR OF)";
        string scommentregex = "(BTW) (.*)";
        string bothofregex = @"^\s*(BOTH OF)";
        string eitherofregex = @"^\s*(EITHER OF)";
        string wonofregex = @"^\s*(WON OF)";
        string notregex = @"^\s*(NOT)";
        string allofregex = @"^\s*(ALL OF)";
        string anyofregex = @"^\s*(ANY OF)";
        string bothsaemregex = @"^\s*(BOTH SAEM)";
        string diffrintregex = @"^\s*(DIFFRINT)";
        string smooshregex = "(DIFF OF) (\")(.*)(\") (AN) (\")(.*)(\")";
        string gimmehregex = "(GIMMEH) ([a-zA-Z][a-zA-Z0-9]*)";
        string assregex = "([a-zA-Z][a-zA-Z0-9]*) (R) (.*)";
        string variregex = "([a-zA-Z][a-zA-Z0-9]*)";
        string numregex = @"(-?[0-9]*\.?[0-9]+)";
        string stringregex ="(\")(.*)(\")";
        string opsregex = "(SUM OF)|(DIFF OF)|(PRODUKT OF)|(QUOSHUNT OF)|(MOD OF)|(BIGGR OF)|(SMALLR OF)|(AN)";

        Gtk.ListStore lex = new Gtk.ListStore (typeof (string), typeof (string));
        Gtk.ListStore sym = new Gtk.ListStore (typeof (string), typeof (string));

        lex.Clear ();
        treeview1.Model = lex;
        sym.Clear ();
        symboltreeview.Model = sym;

        //Keyword regexes
        Regex start = new Regex (startregex, RegexOptions.IgnoreCase);
        Regex vardec = new Regex (hairegex, RegexOptions.IgnoreCase);
        Regex print = new Regex (visibleregex, RegexOptions.IgnoreCase);
        Regex comment = new Regex (commentregex, RegexOptions.IgnoreCase);
        Regex endcomment = new Regex (endcommentregex, RegexOptions.IgnoreCase);
        Regex end = new Regex (endregex, RegexOptions.IgnoreCase);
        Regex add = new Regex (addregex, RegexOptions.IgnoreCase);
        Regex sub = new Regex (subregex, RegexOptions.IgnoreCase);
        Regex mul = new Regex (mulregex, RegexOptions.IgnoreCase);
        Regex div = new Regex (divregex, RegexOptions.IgnoreCase);
        Regex mod = new Regex (modregex, RegexOptions.IgnoreCase);
        Regex big = new Regex (biggrregex, RegexOptions.IgnoreCase);
        Regex small = new Regex (smallrregex, RegexOptions.IgnoreCase);
        Regex both = new Regex (bothofregex, RegexOptions.IgnoreCase);
        Regex either = new Regex (eitherofregex, RegexOptions.IgnoreCase);
        Regex won = new Regex (wonofregex, RegexOptions.IgnoreCase);
        Regex not = new Regex (notregex, RegexOptions.IgnoreCase);
        Regex allof = new Regex (allofregex, RegexOptions.IgnoreCase);
        Regex anyof = new Regex (anyofregex, RegexOptions.IgnoreCase);
        Regex bothsaem = new Regex (bothsaemregex, RegexOptions.IgnoreCase);
        Regex diffrint = new Regex (diffrintregex, RegexOptions.IgnoreCase);

        //Data type regexes
        Regex numvarwtf = new Regex(numvarwtfregex, RegexOptions.IgnoreCase);
        Regex vari = new Regex (variregex, RegexOptions.IgnoreCase);
        Regex numb =new Regex (numregex, RegexOptions.IgnoreCase);
        Regex str =new Regex (stringregex);
        Regex gimmeh = new Regex (gimmehregex, RegexOptions.IgnoreCase);
        Regex ops = new Regex (opsregex, RegexOptions.IgnoreCase);
        Regex ass = new Regex (assregex, RegexOptions.IgnoreCase);

        HashSet <string> lexemeHash = new HashSet<string> (StringComparer.OrdinalIgnoreCase);

        //Initialize requirements
        Stack delimiter = new Stack();
        List<string> ifelse = new List<string> ();
        int linenumber = 0;
        int len = codearray.Length;
        int commentline = 0;
        bool satisfy = true;
        bool gtfo = false;
        int startpoint = 0;
        int endpoint = 0;
        int ifcaller = 0;
        int ifcounter = 0;
        int oiccounter = 0;
        int j = 0;
        string targetArray = "";

        for(int i = 0; i<codearray.Length; i++){
            linenumber++;

            Match m = vardec.Match (codearray[i]);
            Match startmatch = start.Match(codearray[i]);
            Match printmatch = print.Match (codearray[i]);
            Match commentmatch = comment.Match (codearray[i]);
            Match endcommentmatch = endcomment.Match (codearray[i]);
            Match endmatch = end.Match (codearray[i]);
            Match addmatch = add.Match (codearray[i]);
            Match submatch = sub.Match (codearray[i]);
            Match mulmatch = mul.Match (codearray[i]);
            Match divmatch = div.Match (codearray[i]);
            Match modmatch = mod.Match (codearray[i]);
            Match bigmatch = big.Match (codearray[i]);
            Match smallmatch = small.Match (codearray[i]);
            Match bothmatch = both.Match (codearray[i]);
            Match eithermatch = either.Match (codearray[i]);
            Match wonmatch = won.Match (codearray[i]);
            Match notmatch = not.Match (codearray[i]);
            Match allofmatch = allof.Match (codearray[i]);
            Match anyofmatch = anyof.Match (codearray[i]);
            Match bothsaemmatch = bothsaem.Match (codearray[i]);
            Match diffrintmatch = diffrint.Match (codearray[i]);
            Match numvarwtfmatch = numvarwtf.Match (codearray [i]);

            Match gimmehmatch = gimmeh.Match (codearray[i]);
            Match assmatch = ass.Match (codearray[i]);

            if (linenumber == 1) {//IF 1ST LINE cotains HAI
                if (startmatch.Success) {
                    lex.AppendValues (startmatch.Groups [1].ToString (), library ["HAI"]);
                    delimiter.Push ("HAI");
                    treeview1.Model = lex;
                } else {
                    consoletext.Buffer.InsertAtCursor ("Syntax Error: Expected \"HAI\".\n");
                    break;
                }
            } else if (linenumber == len) {	//checks if last line is KYHXBYE
                if (endmatch.Success) { //Matched KTHXBYE token
                    lex.AppendValues (endmatch.Groups [1].ToString (), library ["KTHXBYE"]);
                    treeview1.Model = lex;
                } else {
                    consoletext.Buffer.InsertAtCursor ("Syntax Error: Expected \"KTHXBYE\".\n");
                    break;
                }
            } else if (m.Success) { //Matched I HAS A token
                ihasa (m, codearray, i + 1, lex);

            } else if (assmatch.Success && !codearray [i].Contains ("MEBBE")) { //Assignment token
                if (satisfy) {
                    assignment (assmatch, codearray, i + 1, lex);
                }

            } else if (gimmehmatch.Success) {//Matched GIMMEH token
                if (satisfy) {
                    if (varList.ContainsKey (gimmehmatch.Groups [2].ToString ()) == false) {
                        consoletext.Buffer.InsertAtCursor ("Syntax Error: Variable Undefined\n");
                        treeview1.Model = lex;
                        break;
                    }
                    lexemeHash.Add (gimmehmatch.Groups [1].ToString ());
                    lex.AppendValues (gimmehmatch.Groups [1].ToString (), library ["GIMMEH"]);
                    treeview1.Model = lex;

                    stringholder = gimmehmatch.Groups [2].ToString ();
                    sample.inputDialog id = new sample.inputDialog ();

                    if (id.Run () == (int)ResponseType.Accept) {

                        sym.Clear ();
                        symboltreeview.Model = sym;
                        varList [gimmehmatch.Groups [2].ToString ()] = id.Text;
                        foreach (string key in varList.Keys) {
                            sym.AppendValues (key, varList [key]);
                        }
                        //symboltreeview.Model = sym;
                    }

                    id.Destroy ();
                }

            } else if (startmatch.Success) { //Matched HAI token
                if (linenumber != 1) {
                    consoletext.Buffer.InsertAtCursor ("Syntax Error: Unexpected \"HAI\".\n");
                    break;
                } else {
                    lex.AppendValues (startmatch.Groups [1].ToString (), library ["HAI"]);
                    delimiter.Push ("HAI");
                    treeview1.Model = lex;
                }
            } else if (printmatch.Success) { //Matched VISIBLE token
                if (satisfy) {
                    visible (printmatch, codearray, i + 1, lex);
                }

            } else if (commentmatch.Success) { //Matched Comment token
                lex.AppendValues (commentmatch.Groups [1].ToString (), library ["OBTW"]);
                commentline = i;
                try {
                    while (!endcommentmatch.Success) {
                        endcommentmatch = endcomment.Match (codearray [commentline]);
                        commentline++;

                    }
                } catch (Exception) {
                    syntaxError (commentline);
                    break;
                }

                i = commentline;

                lex.AppendValues ("TDLR", library ["TLDR"]);

                treeview1.Model = lex;

            } else if (endmatch.Success) { //Matched KTHXBYE token
                lex.AppendValues (endmatch.Groups [1].ToString (), library ["KTHXBYE"]);
                if (!delimiter.Contains ("HAI")) {
                    consoletext.Buffer.InsertAtCursor ("Syntax Error: Program lacks program initialization.\n");
                    return;
                }
                treeview1.Model = lex;

            } else if (codearray [i].Contains ("MEBBE")) {//Else if
                if (!satisfy) { //If satisfy is false which means previous conditions were denied, then execute

                    sym.Clear ();
                    symboltreeview.Model = sym;
                    varList ["IT"] = perform (codearray [i].ToString ().Replace ("MEBBE ", ""), i + 1, 0); //Evaluate if condition
                    foreach (string key in varList.Keys) {
                        sym.AppendValues (key, varList [key]);
                    }

                    if (varList ["IT"].Equals ("WIN") || isNumb (varList ["IT"].ToString (), numb)) {
                        satisfy = true;
                    } else {
                        satisfy = false;
                    }

                }

            } else if (addmatch.Success || submatch.Success || mulmatch.Success || divmatch.Success || modmatch.Success || bigmatch.Success || smallmatch.Success || bothmatch.Success || eithermatch.Success || wonmatch.Success || notmatch.Success || allofmatch.Success || anyofmatch.Success || bothsaemmatch.Success || diffrintmatch.Success || codearray [i].Contains ("WIN") || codearray [i].Contains ("FAIL")) { //Operations
                if (codearray [i].Contains ("O RLY?")) { //Testing for loop

                    sym.Clear ();
                    symboltreeview.Model = sym;
                    varList ["IT"] = perform (codearray [i].ToString ().Replace (", O RLY?", ""), i + 1, 0); //Evaluate if condition
                    foreach (string key in varList.Keys) {
                        sym.AppendValues (key, varList [key]);
                    }

                    if (varList ["IT"].Equals ("WIN") || isNumb (varList ["IT"].ToString (), numb)) {
                        satisfy = true;
                    } else {
                        satisfy = false;
                    }

                } else if (codearray [i].Contains ("WTF?")) { //Switch-case
                    sym.Clear ();
                    symboltreeview.Model = sym;
                    varList ["IT"] = perform (codearray [i].ToString ().Replace (", WTF?", ""), i + 1, 0); //Evaluate if condition
                    foreach (string key in varList.Keys) {
                        sym.AppendValues (key, varList [key]);
                    }

                    satisfy = false;

                } else {
                    sym.Clear ();
                    symboltreeview.Model = sym;
                    varList ["IT"] = perform (codearray [i], i + 1, 0).ToString ();
                    foreach (string key in varList.Keys) {
                        sym.AppendValues (key, varList [key]);
                    }

                }

            } else if (codearray [i].Contains ("OMGWTF")) { //Default Case
                if (!gtfo){
                    satisfy = true;

                }
            }

            else if (codearray [i].Contains ("OMG")) {//Cases

                if (varList ["IT"].ToString ().Equals (codearray [i].Replace ("OMG ", ""))) { //Equal value
                    satisfy = true;
                }

            } else if (codearray [i].Contains ("GTFO")) { //Break function
                satisfy = false;
                gtfo = true;
            }
            else if (codearray [i].Contains ("NO WAI")) {
                if (satisfy) {
                    satisfy = false; //If satisfy is true which means that YA RLY happened, switches off commands
                } else if (!satisfy) {
                    satisfy = true; //YA RLY hasn't happened so code under NO WAI has to happen
                }
            } else if (codearray [i].Contains ("OIC")) {
                satisfy = true;
            }

            else { //Syntax error
                if (codearray[i].ToString().Equals("") || codearray[i].ToString().Contains("OIC") || codearray[i].ToString().Contains("YA RLY")){ //Empty lines
                    continue;
                }
                syntaxError(linenumber);
                return;
            }

        }
    }
Ejemplo n.º 39
0
		public XmlSchemasPanelWidget ()
		{
			Build ();
			
			//set up tree view for default schemas
			var textRenderer = new CellRendererText ();
			registeredSchemasStore = new ListStore (typeof (XmlSchemaCompletionData));
			registeredSchemasView.Model = registeredSchemasStore;
			
			registeredSchemasView.AppendColumn (GettextCatalog.GetString ("Namespace"), textRenderer,
				(TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter) => {
					((CellRendererText)cell).Text = GetSchema (iter).NamespaceUri;
				}
			);
			
			registeredSchemasView.AppendColumn (GettextCatalog.GetString ("Type"), textRenderer,
				(TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter) => {
					((CellRendererText)cell).Text = GetSchema (iter).ReadOnly? 
						  GettextCatalog.GetString ("Built in") 
						: GettextCatalog.GetString ("User schema");
			});
			
			registeredSchemasStore.SetSortFunc (0, SortSchemas);
			
			registeredSchemasStore.SetSortColumnId (0, SortType.Ascending);
			
			//update state of "remove" button depending on whether schema is read-only and anything's slected
			registeredSchemasView.Selection.Changed += delegate {
				var data = GetSelectedSchema ();
				registeredSchemasRemoveButton.Sensitive = (data != null && !data.ReadOnly);
			};
			registeredSchemasRemoveButton.Sensitive = false;
			
			//set up cells for associations
			var extensionTextRenderer = new CellRendererText ();
			extensionTextRenderer.Editable = true;
			var prefixTextRenderer = new CellRendererText ();
			prefixTextRenderer.Editable = true;
			
			var comboEditor = new CellRendererCombo ();
			registeredSchemasComboModel = new ListStore (typeof (string));
			comboEditor.Model = registeredSchemasComboModel;
			comboEditor.Mode = CellRendererMode.Editable;
			comboEditor.TextColumn = 0;
			comboEditor.Editable = true;
			comboEditor.HasEntry = false;
			
			//rebuild combo's model from default schemas whenever editing starts
			comboEditor.EditingStarted += delegate (object sender, EditingStartedArgs args) {
				registeredSchemasComboModel.Clear ();
				registeredSchemasComboModel.AppendValues (string.Empty);
				foreach (TreeIter iter in WalkStore (registeredSchemasStore))
					registeredSchemasComboModel.AppendValues (
						GetSchema (iter).NamespaceUri
					);
				args.RetVal = true;
				registeredSchemasComboModel.SetSortColumnId (0, SortType.Ascending);
			};
			
			//set up tree view for associations
			defaultAssociationsStore = new ListStore (typeof (string), typeof (string), typeof (string), typeof (bool));
			defaultAssociationsView.Model = defaultAssociationsStore;
			defaultAssociationsView.AppendColumn (GettextCatalog.GetString ("File Extension"), extensionTextRenderer, "text", COL_EXT);
			defaultAssociationsView.AppendColumn (GettextCatalog.GetString ("Namespace"), comboEditor, "text", COL_NS);
			defaultAssociationsView.AppendColumn (GettextCatalog.GetString ("Prefix"), prefixTextRenderer, "text", COL_PREFIX);
			defaultAssociationsStore.SetSortColumnId (COL_EXT, SortType.Ascending);
			
			//editing handlers
			extensionTextRenderer.Edited += handleExtensionSet;
			comboEditor.Edited += (sender, args) => setAssocValAndMarkChanged (args.Path, COL_NS, args.NewText ?? "");
			prefixTextRenderer.Edited += delegate (object sender, EditedArgs args) {
				foreach (char c in args.NewText)
					if (!char.IsLetterOrDigit (c))
						//FIXME: give an error message?
						return;
				setAssocValAndMarkChanged (args.Path, COL_PREFIX, args.NewText);
			};
			
			//update state of "remove" button depending on whether anything's slected
			defaultAssociationsView.Selection.Changed += delegate {
				TreeIter iter;
				defaultAssociationsRemoveButton.Sensitive =
					defaultAssociationsView.Selection.GetSelected (out iter);
			};
			defaultAssociationsRemoveButton.Sensitive = false;
		}
Ejemplo n.º 40
0
    protected void assignment(Match assmatch, String[] codearray, int linenumber, ListStore lex)
    {
        int caller;
        Gtk.ListStore sym = new Gtk.ListStore (typeof (string), typeof (string));
        string variregex = "([a-zA-Z][a-zA-Z0-9]*)";
        string numregex = @"(-?[0-9]*\.?[0-9]+)";
        string stringregex ="(\")(.*)(\")";
        string opsregex = "(SUM OF)|(DIFF OF)|(PRODUKT OF)|(QUOSHUNT OF)|(MOD OF)|(BIGGR OF)|(SMALLR OF)|(AN)";
        Regex vari = new Regex (variregex, RegexOptions.IgnoreCase);
        Regex numb =new Regex (numregex, RegexOptions.IgnoreCase);
        Regex str = new Regex (stringregex, RegexOptions.IgnoreCase);
        Regex ops = new Regex (opsregex, RegexOptions.IgnoreCase);
        string[] splitarray;

        if (isNumb (assmatch.Groups [3].ToString (), numb) && !isVar (assmatch.Groups [3].ToString (), vari) && !isOps (assmatch.Groups [3].ToString (), ops) && !isComparison(assmatch.Groups[3].ToString())) { //Assign a number
            sym.Clear ();

            symboltreeview.Model = sym;
            varList [assmatch.Groups [1].ToString ()] = assmatch.Groups[3].ToString();
            lex.AppendValues (assmatch.Groups [1].ToString (), "Variable");
            lex.AppendValues (assmatch.Groups [2].ToString (), "Assignment indicator");
            lex.AppendValues (assmatch.Groups [3].ToString (), "Number Literal");
            foreach (string key in varList.Keys) {
                sym.AppendValues (key, varList [key]);
            }
            treeview1.Model = lex;

        } else if (isVar (assmatch.Groups [3].ToString (), vari) && !isString (assmatch.Groups [3].ToString (), str) && !isOps (assmatch.Groups [3].ToString (), ops) && !assmatch.Groups [3].ToString ().Equals ("WIN") && !assmatch.Groups [3].ToString ().Equals ("FAIL") && !isBool (assmatch.Groups [3].ToString ()) && !isAnyAll (assmatch.Groups [3].ToString ()) && !isComparison (assmatch.Groups [3].ToString ())) { //Assign the value of an existing variable.
            //Check whether the source variable exists
            if (!varList.Contains (assmatch.Groups [3].ToString ())) {//No variable
                consoletext.Buffer.InsertAtCursor (library ["noVariable"] + assmatch.Groups [3].ToString () + " at line " + linenumber + ".");
                return;
            }
            //Check whether the destination variable exists
            if (!varList.Contains(assmatch.Groups[1].ToString())){ //No variable
                consoletext.Buffer.InsertAtCursor (library ["noVariable"] + assmatch.Groups [3].ToString () + " at line " + linenumber + ".");
                return;
            }
            sym.Clear ();
            symboltreeview.Model = sym;
            varList [assmatch.Groups [1].ToString ()] = varList[assmatch.Groups[3].ToString()].ToString();
            foreach (string key in varList.Keys) {
                sym.AppendValues (key, varList [key]);
            }

            lex.AppendValues (assmatch.Groups [1].ToString (), "Variable");
            lex.AppendValues (assmatch.Groups [2].ToString (), "Assignment indicator");
            lex.AppendValues (assmatch.Groups [3].ToString (), "Variable");
            treeview1.Model = lex;
        } else if (isString (assmatch.Groups [3].ToString (), str) && !isOps (assmatch.Groups [3].ToString (), ops)) { //Assigns a string to the destination variable
            //Check whether the destination variable exists
            if (!varList.Contains(assmatch.Groups[1].ToString())){ //No variable
                consoletext.Buffer.InsertAtCursor (library ["noVariable"] + assmatch.Groups [1].ToString () + " at line " + linenumber + ".");
                return;
            }

            Match isStr = str.Match (assmatch.Groups [3].ToString ());
            lex.AppendValues (assmatch.Groups [1].ToString (), "Variable");
            lex.AppendValues (assmatch.Groups [2].ToString (), "Assignment indicator");
            lex.AppendValues (isStr.Groups [1].ToString (), "String Delimiter");
            lex.AppendValues (isStr.Groups [2].ToString (), "String Literal");
            lex.AppendValues (isStr.Groups [3].ToString (), "String Delimiter");
            treeview1.Model = lex;

            sym.Clear ();
            symboltreeview.Model = sym;
            varList [assmatch.Groups [1].ToString ()] = isStr.Groups[2].ToString();
            foreach (string key in varList.Keys) {
                sym.AppendValues (key, varList [key]);
            }

        } else if (assmatch.Groups [3].ToString ().Equals ("WIN") || assmatch.Groups [3].ToString ().Equals ("FAIL")) { //Boolean
            //Check whether the destination variable exists
            if (!varList.Contains(assmatch.Groups[1].ToString())){ //No variable
                consoletext.Buffer.InsertAtCursor (library ["noVariable"] + assmatch.Groups [1].ToString () + " at line " + linenumber + ".");
                return;
            }
            sym.Clear ();
            symboltreeview.Model = sym;
            varList [assmatch.Groups [1].ToString ()] = assmatch.Groups[3].ToString();
            lex.AppendValues (assmatch.Groups [1].ToString (), "Variable");
            lex.AppendValues (assmatch.Groups [2].ToString (), "Assignment indicator");
            lex.AppendValues (assmatch.Groups [3].ToString (), "Boolean Literal");
            foreach (string key in varList.Keys) {
                sym.AppendValues (key, varList [key]);
            }
            treeview1.Model = lex;

        } else if (isComparison(assmatch.Groups[3].ToString())) { //Comparisons
            caller = 2;
            sym.Clear ();
            symboltreeview.Model = sym;
            varList [assmatch.Groups [1].ToString ()] = perform (codearray [linenumber - 1], linenumber, caller).ToString ();
            lex.AppendValues (assmatch.Groups [1].ToString (), "Variable");
            lex.AppendValues (assmatch.Groups [2].ToString (), "Assignment indicator");
            foreach (string key in varList.Keys) {
                sym.AppendValues (key, varList [key]);
            }

        } else if (isAnyAll(assmatch.Groups[3].ToString())) { //ANY ALL & AND ALL Boolean operations

            label1.Text = "isanyall";
            caller = 2;
            sym.Clear ();
            symboltreeview.Model = sym;
            varList [assmatch.Groups [1].ToString ()] = perform (codearray [linenumber - 1], linenumber, caller).ToString ();
            lex.AppendValues (assmatch.Groups [1].ToString (), "Variable");
            lex.AppendValues (assmatch.Groups [2].ToString (), "Assignment indicator");
            foreach (string key in varList.Keys) {
                sym.AppendValues (key, varList [key]);
            }

        } else if (isBool(assmatch.Groups[3].ToString())) { //Boolean operations
            caller = 2;

            sym.Clear ();
            symboltreeview.Model = sym;
            varList [assmatch.Groups [1].ToString ()] = perform (codearray [linenumber - 1], linenumber, caller).ToString ();
            lex.AppendValues (assmatch.Groups [1].ToString (), "Variable");
            lex.AppendValues (assmatch.Groups [2].ToString (), "Assignment indicator");
            foreach (string key in varList.Keys) {
                sym.AppendValues (key, varList [key]);
            }

            //Add to the lexemes table
            splitarray = codearray [linenumber - 1].Split (' ');
            for (int i = 2; i < splitarray.Length; i++) { //Add to lexemes table
                if (splitarray [i].Equals ("BOTH") || splitarray [i].Equals ("EITHER") && splitarray [i + 1].Equals ("OF")) {
                    lex.AppendValues (splitarray [i], library[splitarray[i] + " " + splitarray[i+1]]);
                } else if (splitarray[i].Equals("NOT")) {

                    lex.AppendValues (splitarray [i], "Negation Operator");

                } else if (splitarray [i].Equals ("AN")) {
                    lex.AppendValues ("AN", "Value Conjunction");
                } else if (splitarray [i].Equals ("OF")) {
                } else if (isNumb (splitarray [i], numb) && !isVar (splitarray [i], vari)) {
                    lex.AppendValues(splitarray[i], library["number"]);

                } else if (isVar (splitarray [i], vari)) {
                    lex.AppendValues(splitarray[i], library["variable"]);

                }

            }
            treeview1.Model = lex;

        } else { //Arithmetic Operations

            caller = 2;

            sym.Clear ();
            symboltreeview.Model = sym;
            varList [assmatch.Groups [1].ToString ()] = perform (codearray [linenumber - 1], linenumber, caller).ToString ();
            lex.AppendValues (assmatch.Groups [1].ToString (), "Variable");
            lex.AppendValues (assmatch.Groups [2].ToString (), "Assignment indicator");
            foreach (string key in varList.Keys) {
                sym.AppendValues (key, varList [key]);
            }

            splitarray = codearray [linenumber - 1].Split (' ');
            for (int i = 2; i < splitarray.Length; i++) { //Add to lexemes table
                if (splitarray [i].Equals ("SUM") || splitarray [i].Equals ("DIFF") || splitarray [i].Equals ("PRODUKT") || splitarray [i].Equals ("QUOSHUNT") || splitarray [i].Equals ("MOD") || splitarray [i].Equals ("BIGGR") || splitarray [i].Equals ("SMALLR") && splitarray [i + 1].Equals ("OF")) {
                    lex.AppendValues (splitarray [i]+" "+splitarray[i+1], library [splitarray [i]+" "+splitarray[i+1]]);
                } else if (splitarray [i].Equals ("AN")) {
                    lex.AppendValues ("AN", "Value Conjunction");
                } else if (splitarray [i].Equals ("OF")) {
                } else if (isNumb (splitarray [i], numb) && !isVar (splitarray [i], vari)) {
                    lex.AppendValues(splitarray[i], library["number"]);

                } else if (isVar (splitarray [i], vari)) {
                    lex.AppendValues(splitarray[i], library["variable"]);

                }

            }
            treeview1.Model = lex;
        }
    }
        /// <summary>
        /// Creates the input mapping column with combo box.
        /// TODO improve the input mapping combo box:
        /// 1. it doesn't set values until combo box loses focus within table view confirm change - Edited event is raised only then
        /// 2. there is no indication that the field can be modified - render combo box always, OR show some icon that it can be modified
        /// </summary>
        /// <returns>
        /// The input mapping column with combo box.
        /// </returns>
        /// <param name='inputStore'>
        /// Input store.
        /// </param>
        private TreeViewColumn CreateInputMappingColumnWithComboBox(NodeStore inputStore, string columntTitle)
        {
            Gtk.CellRendererCombo comboRenderer = new Gtk.CellRendererCombo();
            
            comboRenderer.HasEntry = false;
            comboRenderer.Mode = CellRendererMode.Editable;
            comboRenderer.TextColumn = 0;
            comboRenderer.Editable = true;

            ListStore comboBoxStore = new ListStore (typeof(string));
            comboRenderer.Model = comboBoxStore;

            //when user activates combo box, refresh combobox store with available input mapping per node
            comboRenderer.EditingStarted += delegate (object o, EditingStartedArgs args) 
            {
                comboBoxStore.Clear ();
                IOItemNode currentItem = (IOItemNode)inputStore.GetNode (new TreePath (args.Path));
                ExperimentNode currentNode = m_component.ExperimentNode;
                string currentType = currentItem.Type;
                InputMappings availableInputMappingsPerNode = new InputMappings (currentNode.Owner);
                if (currentNode != null && availableInputMappingsPerNode.ContainsMappingsForNode (currentNode)) {
                    foreach (string incomingOutput in availableInputMappingsPerNode [currentNode].Keys) {
                        if (string.Equals (currentType, availableInputMappingsPerNode [currentNode] [incomingOutput])) {
                            comboBoxStore.AppendValues (Mono.Unix.Catalog.GetString (incomingOutput));
                        }
                    }
                }
            };

            //when edition has been completed set current item node with proper mapping
            comboRenderer.Edited += delegate (object o, EditedArgs args) {
                IOItemNode n = (IOItemNode)inputStore.GetNode (new TreePath (args.Path));
                n.MappedTo = args.NewText;
                RefreshIOHighlightInExperiment(n.MappedTo);
            };

            //finally create the column with above combo renderer
            var mappedToColumn = new TreeViewColumn ();
            mappedToColumn.Title = columntTitle;
            mappedToColumn.PackStart (comboRenderer, true);

            //this method sets the text view to current mapping, when combo box is not active
            mappedToColumn.SetCellDataFunc (comboRenderer, delegate (TreeViewColumn tree_column, CellRenderer cell, ITreeNode node) {
                IOItemNode currentItem = (IOItemNode)node;
                comboRenderer.Text = currentItem.MappedTo;
            });

            return mappedToColumn;
        }
Ejemplo n.º 42
0
Archivo: gui.cs Proyecto: horga83/gfax
        public Gfax(string fname, string[] args)
            : base(APPNAME, VERSION, Modules.UI, args, new object [0])
        {
            //Phonebook[] pb;  delete me

             			// Set the program icon
             			Gtk.Window.DefaultIconName = "gfax";

            Application.Init ();

            // check to see if we've run before, if so gfax will be there
            if ( Settings.RunSetupAtStart ) {
                Settings.RunSetupAtStart = false;

                MessageDialog md;
                md = new MessageDialog (
                    null,
                    DialogFlags.DestroyWithParent,
                    MessageType.Info,
                    ButtonsType.Ok,
                    Catalog.GetString(
                        @"
            This is the first time you have run Gfax.
            You should set your MODEM TYPE and PORT under preferences.

            Gfax is initially setup to use Efax, you may change it use
            Hylafax if you prefer or require connection to a network
            facsimile server.")
                );
                md.Run ();
                md.Destroy();
            }

            if (!Directory.Exists(gfax.SpoolDirectory)) {
                G_Message gm = new G_Message(Catalog.GetString(
                    @"Your spool directory is missing!

            Please login as the root user and create the "
            + gfax.SpoolDirectory +
            " directory.\n\nAll users should be able to write to it.\n"));
                return;
            }
            if (!Directory.Exists(gfax.SpoolDirectory + "/doneq")) {
                G_Message gm = new G_Message(Catalog.GetString(
                    @"The doneq directory is missing in your spool directory!

            Please login as the root user and create the "
            + gfax.SpoolDirectory + "/doneq" +
            " directory.\n\nAll users should be able to write to it.\n"));
                return;
            }
            if (!Directory.Exists(gfax.SpoolDirectory + "/recq")) {
                G_Message gm = new G_Message(Catalog.GetString(
                    @"The recq directory is missing in your spool directory!

            Please login as the root user and create the "
            + gfax.SpoolDirectory + "/recq" +
            " directory.\n\nAll users should be able to write to it.\n"));
                return;
            }

            gxml = new Glade.XML (null, "gfax.glade", "GfaxWindow", null);
            gxml.Autoconnect (this);

            // Set initial gui state as per preferences
            // GConf.PropertyEditors.EditorShell doesn't handle
            // checkmenuitems;
            eventsEnabled = false;
             	if (Settings.TransmitAgent == "hylafax") {
                AutoQRefreshCheckMenuItem.Active = Settings.RefreshQueueEnabled;
                EmailNotificationCheckMenuItem.Active = Settings.EmailNotify;
                HiResolutionModeCheckMenuItem.Active = Settings.HiResolution;
                LogEnabledCheckMenuItem.Active = Settings.LogEnabled;
            }
            if (Settings.TransmitAgent == "efax") {
                AutoQRefreshCheckMenuItem.Active = Settings.RefreshQueueEnabled;
                AutoQRefreshCheckMenuItem.Sensitive = false;
                EmailNotificationCheckMenuItem.Active = false;
                EmailNotificationCheckMenuItem.Sensitive = false;
                HiResolutionModeCheckMenuItem.Active = Settings.HiResolution;
                LogEnabledCheckMenuItem.Visible = false;
            }

            FaxTracingCheckMenuItem.Active = Settings.Faxtracing;

            eventsEnabled = true;

            StatusText.Editable = false;
            StatusText.CanFocus = false;
            StatusText.Buffer = StatusTextBuffer;

            // Set the program icon
            Gdk.Pixbuf Icon = new Gdk.Pixbuf(null, "gfax.png");

            gfax.MainWindow = GfaxWindow;

             			// Setup listview icons
             			InitListViewIcons();

            StatusStore = new ListStore(
             						typeof (Gdk.Pixbuf),
                        typeof (string),
                        typeof (string),
                        typeof (string),
                        typeof (string),
                        typeof (string),
                        typeof (string),
             						typeof (DateTime),
                        typeof (string));

            RecvStore = new ListStore(
             						typeof (Gdk.Pixbuf),
                        typeof (string),
                        typeof (string),
                        typeof (string),
             						typeof (DateTime),
                        typeof (string));

            lv = new G_ListView(StatusList, StatusStore);
             			lv.AddColumnIcon(Gtk.Stock.Info, 0);
             			lv.AddColumnTitle(Catalog.GetString("Jobid"),	1, 1);
             			lv.AddColumnTitle(Catalog.GetString("Number"),	2, 2);
             			lv.AddColumnTitle(Catalog.GetString("Status"),	3, 3);
             			lv.AddColumnTitle(Catalog.GetString("Owner"),	4, 4);
             			lv.AddColumnTitle(Catalog.GetString("Pages"),	5, 5);
             			lv.AddColumnTitle(Catalog.GetString("Dials"),	6, 6);
             			lv.AddColumnDateTime(Catalog.GetString("Send At"), "G",	7, 7);
             			lv.AddColumnTitle(Catalog.GetString("Information"),	8, 8);

            // List view for completed jobs tab
            jobsCompletedView = new G_ListView(JobsCompleteList, StatusStore);
             			jobsCompletedView.AddColumnIcon(Gtk.Stock.Info, 0);
             			jobsCompletedView.AddColumnTitle(Catalog.GetString("Jobid"),	1, 1);
             			jobsCompletedView.AddColumnTitle(Catalog.GetString("Number"),	2, 2);
             			jobsCompletedView.AddColumnTitle(Catalog.GetString("Status"),	3, 3);
             			jobsCompletedView.AddColumnTitle(Catalog.GetString("Owner"),	4, 4);
             			jobsCompletedView.AddColumnTitle(Catalog.GetString("Pages"),	5, 5);
             			jobsCompletedView.AddColumnTitle(Catalog.GetString("Dials"),	6, 6);
             			jobsCompletedView.AddColumnDateTime(Catalog.GetString("Send At"), "G",	7, 7);
             			jobsCompletedView.AddColumnTitle(Catalog.GetString("Information"),	8, 8);

            jobsReceivedView = new G_ListView(JobsReceivedList, RecvStore);
             			jobsReceivedView.AddColumnIcon(Gtk.Stock.Info, 0);
             			jobsReceivedView.AddColumnTitle(Catalog.GetString("Sender"),	1, 1);
             			jobsReceivedView.AddColumnTitle(Catalog.GetString("Status"),	2, 2);
             			jobsReceivedView.AddColumnTitle(Catalog.GetString("Pages  "),	3, 3);
             			jobsReceivedView.AddColumnDateTime(Catalog.GetString("Arrived"), "G",	4, 4);
             			jobsReceivedView.AddColumnTitle(Catalog.GetString("Filename"),	5, 5);

            StatusList.Selection.Changed +=
                new EventHandler(on_StatusList_selection);
            StatusList.Selection.Mode = SelectionMode.Multiple;
            StatusList.HeadersVisible = true;

            JobsCompleteList.Selection.Changed +=
                new EventHandler(on_JobsCompleteList_selection);
            JobsCompleteList.Selection.Mode = SelectionMode.Multiple;
            JobsCompleteList.HeadersVisible = true;

            JobsReceivedList.Selection.Changed +=
                new EventHandler(on_JobsReceivedList_selection);
            JobsReceivedList.Selection.Mode = SelectionMode.Multiple;
            JobsReceivedList.HeadersVisible = true;

            // Make sure headers are visible
            lv.AddTextToRow(null,"","","","","","",null,"");
            jobsCompletedView.AddTextToRow(null,"","","","","","",null,"");
            jobsReceivedView.AddTextToRow(null,"","","",null,"");
            StatusStore.Clear();
            RecvStore.Clear();

            DeleteJobButton.Sensitive = false;
            if (Settings.TransmitAgent == "hylafax")
                ModifyJobButton.Sensitive = false;
            else
                ModifyJobButton.Visible = false;
            ViewPrintButton.Sensitive = false;

            // Setup some global variables
            gfax.MainProgressBar = Appbar.Progress;
            gfax.GStatusTextBuffer = StatusTextBuffer;
            gfax.GAppbar = Appbar;

            gfax.Pulser = new Pulser();
            gfax.Status = new Status(StatusText, StatusTextBuffer);

            if (Settings.RefreshQueueEnabled)
                GLib.Timeout.Add((uint)(Settings.RefreshQueueInterval * 1000),
                    new TimeoutHandler (queue_refresh));

            async_update_status();

            if (Settings.TransmitAgent == "hylafax" ) {
                while (gfax.activeNetwork)
                    System.Threading.Thread.Sleep(100);

                async_net_read_finished();
            }

            activeQ = ActiveQ.send;
            async_update_queue_status("sendq");

            StatusIcon sicon = new StatusIcon(Icon);
            sicon.Activate += new EventHandler (OnImageClick);
            sicon.Tooltip = "Gfax Facsimile Sender";
            // showing the trayicon
            sicon.Visible = true;
            // setup system tray icon
            gfax.MainWindow.SkipTaskbarHint = true;
            gfax.MainWindow.Iconify();

            Application.Run ();
        }
        /// <summary>
        /// Mettre le choix de termes, donc le nombre de 
        /// d'année que le contrat va durée (Mois dans le cas qui nous intérresse).
        /// </summary>
        /// <param name="termes">Termes.</param>
        protected void PopulateTermeLocation(DataSet termes)
        {
            ListStore model = new ListStore (typeof(string));
            CellRendererText cellrenderer = new CellRendererText ();

            termeBox.Model = model;
            termeBox.PackStart (cellrenderer, true);

            model.Clear ();

            for (int i = 0; i < termes.Tables [0].Rows.Count; i++) {
                StringBuilder sb = new StringBuilder ();
                sb.Append (termes.Tables [0].Rows [i].ItemArray [0].ToString () + " mois");

                termesList.Add (termes.Tables [0].Rows [i].ItemArray [0].ToString ());

                clientBox.AddAttribute (cellrenderer, "text", 0);

                model.AppendValues (sb.ToString ());

            }
        }
		public XmlSchemasPanelWidget()
		{
			this.Build();
			
			//set up tree view for default schemas
			CellRendererText textRenderer = new CellRendererText ();
			registeredSchemasStore = new ListStore (typeof (XmlSchemaCompletionData));
			registeredSchemasView.Model = registeredSchemasStore;
			
			registeredSchemasView.AppendColumn (GettextCatalog.GetString ("Namespace"), textRenderer,
			    delegate (TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter) {
				((Gtk.CellRendererText)cell).Text = ((MonoDevelop.XmlEditor.Completion.XmlSchemaCompletionData)model.GetValue (iter, 0)).NamespaceUri;
			});
			
			registeredSchemasView.AppendColumn (GettextCatalog.GetString ("Type"), textRenderer,
			    delegate (TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter) {
				bool builtIn = ((MonoDevelop.XmlEditor.Completion.XmlSchemaCompletionData)model.GetValue (iter, 0)).ReadOnly;
				((Gtk.CellRendererText)cell).Text = builtIn? 
					  GettextCatalog.GetString ("Built in") 
					: GettextCatalog.GetString ("User schema");
			});
			
			registeredSchemasStore.SetSortFunc (0, 
			    delegate (TreeModel model, TreeIter a, TreeIter b) {
				return string.Compare (
				    ((MonoDevelop.XmlEditor.Completion.XmlSchemaCompletionData) model.GetValue (a, 0)).NamespaceUri,
				    ((MonoDevelop.XmlEditor.Completion.XmlSchemaCompletionData) model.GetValue (b, 0)).NamespaceUri
				);
			});
			registeredSchemasStore.SetSortColumnId (0, SortType.Ascending);
			
			//update state of "remove" button depending on whether schema is read-only and anything's slected
			registeredSchemasView.Selection.Changed += delegate {
				MonoDevelop.XmlEditor.Completion.XmlSchemaCompletionData data = GetSelectedSchema ();
				registeredSchemasRemoveButton.Sensitive = (data != null && !data.ReadOnly);
			};
			registeredSchemasRemoveButton.Sensitive = false;
			
			//set up cells for associations
			CellRendererText extensionTextRenderer = new CellRendererText ();
			extensionTextRenderer.Editable = true;
			CellRendererText prefixTextRenderer = new CellRendererText ();
			prefixTextRenderer.Editable = true;
			
			CellRendererCombo comboEditor = new CellRendererCombo ();
			registeredSchemasComboModel = new ListStore (typeof (string));
			comboEditor.Model = registeredSchemasComboModel;
			comboEditor.Mode = CellRendererMode.Editable;
			comboEditor.TextColumn = 0;
			comboEditor.Editable = true;
			comboEditor.HasEntry = false;
			
			//rebuild combo's model from default schemas whenever editing starts
			comboEditor.EditingStarted += delegate (object sender, EditingStartedArgs args) {
				registeredSchemasComboModel.Clear ();
				registeredSchemasComboModel.AppendValues (string.Empty);
				foreach (Gtk.TreeIter iter in WalkStore (registeredSchemasStore))
					registeredSchemasComboModel.AppendValues (
					    ((MonoDevelop.XmlEditor.Completion.XmlSchemaCompletionData)registeredSchemasStore.GetValue (iter, 0)).NamespaceUri
					);
				args.RetVal = true;
				registeredSchemasComboModel.SetSortColumnId (0, Gtk.SortType.Ascending);
			};
			
			//set up tree view for associations
			defaultAssociationsStore = new ListStore (typeof (string), typeof (string), typeof (string), typeof (bool));
			defaultAssociationsView.Model = defaultAssociationsStore;
			defaultAssociationsView.AppendColumn (GettextCatalog.GetString ("File Extension"), extensionTextRenderer, "text", DACols.Extension);
			defaultAssociationsView.AppendColumn (GettextCatalog.GetString ("Namespace"), comboEditor, "text", DACols.Namespace);
			defaultAssociationsView.AppendColumn (GettextCatalog.GetString ("Prefix"), prefixTextRenderer, "text", DACols.Prefix);
			defaultAssociationsStore.SetSortColumnId ((int)DACols.Extension, SortType.Ascending);
			
			//editing handlers
			extensionTextRenderer.Edited += handleExtensionSet;
			comboEditor.Edited += delegate (object sender, EditedArgs args) {
				setAssocValAndMarkChanged (args.Path, DACols.Namespace, args.NewText);
			};
			prefixTextRenderer.Edited += delegate (object sender, EditedArgs args) {
				foreach (char c in args.NewText)
					if (!char.IsLetterOrDigit (c))
						//FIXME: give an error message?
						return;
				setAssocValAndMarkChanged (args.Path, DACols.Prefix, args.NewText);
			};
			
			//update state of "remove" button depending on whether anything's slected
			defaultAssociationsView.Selection.Changed += delegate {
				Gtk.TreeIter iter;
				defaultAssociationsRemoveButton.Sensitive =
					defaultAssociationsView.Selection.GetSelected (out iter);
			};
			defaultAssociationsRemoveButton.Sensitive = false;
		}
Ejemplo n.º 45
0
        private void SetupWidgets()
        {
            histogram_expander = new Expander (Catalog.GetString ("Histogram"));
            histogram_expander.Activated += delegate(object sender, EventArgs e) {
                ContextSwitchStrategy.SetHistogramVisible (Context, histogram_expander.Expanded);
                UpdateHistogram ();
            };
            histogram_expander.StyleSet += delegate(object sender, StyleSetArgs args) {
                Gdk.Color c = this.Toplevel.Style.Backgrounds[(int)Gtk.StateType.Active];
                histogram.RedColorHint = (byte)(c.Red / 0xff);
                histogram.GreenColorHint = (byte)(c.Green / 0xff);
                histogram.BlueColorHint = (byte)(c.Blue / 0xff);
                histogram.BackgroundColorHint = 0xff;
                UpdateHistogram ();
            };
            histogram_image = new Gtk.Image ();
            histogram = new Histogram ();
            histogram_expander.Add (histogram_image);

            Add (histogram_expander);

            info_expander = new Expander (Catalog.GetString ("Image Information"));
            info_expander.Activated += (sender, e) => {
                ContextSwitchStrategy.SetInfoBoxVisible (Context, info_expander.Expanded);
            };

            info_table = new Table (head_rows, 2, false) { BorderWidth = 0 };

            AddLabelEntry (null, null, null, null,
                           photos => { return String.Format (Catalog.GetString ("{0} Photos"), photos.Length); });

            AddLabelEntry (null, Catalog.GetString ("Name"), null,
                           (photo, file) => { return photo.Name ?? String.Empty; }, null);

            version_list = new ListStore (typeof(IPhotoVersion), typeof(string), typeof(bool));
            version_combo = new ComboBox ();
            CellRendererText version_name_cell = new CellRendererText ();
            version_name_cell.Ellipsize = Pango.EllipsizeMode.End;
            version_combo.PackStart (version_name_cell, true);
            version_combo.SetCellDataFunc (version_name_cell, new CellLayoutDataFunc (VersionNameCellFunc));
            version_combo.Model = version_list;
            version_combo.Changed += OnVersionComboChanged;

            AddEntry (null, Catalog.GetString ("Version"), null, version_combo, 0.5f,
                      (widget, photo, file) => {
                            version_list.Clear ();
                            version_combo.Changed -= OnVersionComboChanged;

                            int count = 0;
                            foreach (IPhotoVersion version in photo.Versions) {
                                version_list.AppendValues (version, version.Name, true);
                                if (version == photo.DefaultVersion)
                                    version_combo.Active = count;
                                count++;
                            }

                            if (count <= 1) {
                                version_combo.Sensitive = false;
                                version_combo.TooltipText = Catalog.GetString ("(No Edits)");
                            } else {
                                version_combo.Sensitive = true;
                                version_combo.TooltipText =
                                    String.Format (Catalog.GetPluralString ("(One Edit)", "({0} Edits)", count - 1),
                                                   count - 1);
                            }
                            version_combo.Changed += OnVersionComboChanged;
                       }, null);

            AddLabelEntry ("date", Catalog.GetString ("Date"), Catalog.GetString ("Show Date"),
                           (photo, file) => {
                               return String.Format ("{0}{2}{1}",
                                                     photo.Time.ToShortDateString (),
                                                     photo.Time.ToShortTimeString (),
                                                     Environment.NewLine); },
                           photos => {
                                IPhoto first = photos[photos.Length - 1];
                                IPhoto last = photos[0];
                                if (first.Time.Date == last.Time.Date) {
                                    //Note for translators: {0} is a date, {1} and {2} are times.
                                    return String.Format (Catalog.GetString ("On {0} between \n{1} and {2}"),
                                                          first.Time.ToShortDateString (),
                                                          first.Time.ToShortTimeString (),
                                                          last.Time.ToShortTimeString ());
                                } else {
                                    return String.Format (Catalog.GetString ("Between {0} \nand {1}"),
                                                          first.Time.ToShortDateString (),
                                                          last.Time.ToShortDateString ());
                                }
                           });

            AddLabelEntry ("size", Catalog.GetString ("Size"), Catalog.GetString ("Show Size"),
                           (photo, metadata) => {
                                int width = metadata.Properties.PhotoWidth;
                                int height = metadata.Properties.PhotoHeight;

                                if (width != 0 && height != 0)
                                    return String.Format ("{0}x{1}", width, height);
                                else
                                    return Catalog.GetString ("(Unknown)");
                           }, null);

            AddLabelEntry ("exposure", Catalog.GetString ("Exposure"), Catalog.GetString ("Show Exposure"),
                           (photo, metadata) => {
                                var fnumber = metadata.ImageTag.FNumber;
                                var exposure_time = metadata.ImageTag.ExposureTime;
                                var iso_speed = metadata.ImageTag.ISOSpeedRatings;

                                string info = String.Empty;

                                if (fnumber.HasValue && fnumber.Value != 0.0) {
                                    info += String.Format ("f/{0:.0} ", fnumber.Value);
                                }

                                if (exposure_time.HasValue) {
                                    if (Math.Abs (exposure_time.Value) >= 1.0) {
                                        info += String.Format ("{0} sec ", exposure_time.Value);
                                    } else {
                                        info += String.Format ("1/{0} sec ", (int)(1 / exposure_time.Value));
                                    }
                                }

                                if (iso_speed.HasValue) {
                                    info += String.Format ("{0}ISO {1}", Environment.NewLine, iso_speed.Value);
                                }

                                var exif = metadata.ImageTag.Exif;
                                if (exif != null) {
                                    var flash = exif.ExifIFD.GetLongValue (0, (ushort)TagLib.IFD.Tags.ExifEntryTag.Flash);

                                    if (flash.HasValue) {
                                        if ((flash.Value & 0x01) == 0x01)
                                            info += String.Format (", {0}", Catalog.GetString ("flash fired"));
                                        else
                                            info += String.Format (", {0}", Catalog.GetString ("flash didn't fire"));
                                    }
                                }

                                if (info == String.Empty)
                                    return Catalog.GetString ("(None)");

                                return info;
                           }, null);

            AddLabelEntry ("focal_length", Catalog.GetString ("Focal Length"), Catalog.GetString ("Show Focal Length"),
                           false, (photo, metadata) => {
                                var focal_length = metadata.ImageTag.FocalLength;

                                if (focal_length == null)
                                    return Catalog.GetString ("(Unknown)");
                                else
                                    return String.Format ("{0} mm", focal_length.Value);
                            }, null);

            AddLabelEntry ("camera", Catalog.GetString ("Camera"), Catalog.GetString ("Show Camera"), false,
                           (photo, metadata) => { return metadata.ImageTag.Model ?? Catalog.GetString ("(Unknown)"); },
                           null);

            AddLabelEntry ("creator", Catalog.GetString ("Creator"), Catalog.GetString ("Show Creator"),
                           (photo, metadata) => { return metadata.ImageTag.Creator ?? Catalog.GetString ("(Unknown)"); },
                           null);

            AddLabelEntry ("file_size", Catalog.GetString ("File Size"), Catalog.GetString ("Show File Size"), false,
                           (photo, metadata) => {
                                try {
                                    GFile file = FileFactory.NewForUri (photo.DefaultVersion.Uri);
                                    GFileInfo file_info = file.QueryInfo ("standard::size", FileQueryInfoFlags.None, null);
                                    return Format.SizeForDisplay (file_info.Size);
                                } catch (GLib.GException e) {
                                    Hyena.Log.DebugException (e);
                                    return Catalog.GetString ("(File read error)");
                                }
                            }, null);

            var rating_entry = new RatingEntry { HasFrame = false, AlwaysShowEmptyStars = true };
            rating_entry.Changed += HandleRatingChanged;
            var rating_align = new Gtk.Alignment (0, 0, 0, 0);
            rating_align.Add (rating_entry);
            AddEntry ("rating", Catalog.GetString ("Rating"), Catalog.GetString ("Show Rating"), rating_align, false,
                      (widget, photo, metadata) => { ((widget as Alignment).Child as RatingEntry).Value = (int) photo.Rating; },
                      null);

            AddEntry ("tag", null, Catalog.GetString ("Show Tags"), new TagView (), false,
                      (widget, photo, metadata) => { (widget as TagView).Current = photo; }, null);

            UpdateTable ();

            EventBox eb = new EventBox ();
            eb.Add (info_table);
            info_expander.Add (eb);
            eb.ButtonPressEvent += HandleButtonPressEvent;

            Add (info_expander);
        }
Ejemplo n.º 46
0
        /// <summary>
        /// Remplir le combo box à la voler avec l'information donnée.
        /// </summary>
        /// <param name="clients">Clients.</param>
        protected void RePopulateClient(DataSet clients)
        {
            ListStore model = new ListStore (typeof(string));
            CellRendererText cellrenderer = new CellRendererText ();

            clientBox.Model = model;
            clientBox.PackStart (cellrenderer, true);
            iDClient.Clear ();
            ClientPhone.Clear ();
            model.Clear ();

            for (int i = 0; i < clients.Tables [0].Rows.Count; i++) {
                StringBuilder sb = new StringBuilder ();
                sb.Append (clients.Tables [0].Rows [i].ItemArray [1].ToString () + " ");
                sb.Append (clients.Tables [0].Rows [i].ItemArray [2].ToString () + " ");
                sb.Append (clients.Tables [0].Rows [i].ItemArray [3].ToString () + " ");

                iDClient.Add (clients.Tables [0].Rows [i].ItemArray [0].ToString ());
                ClientPhone.Add (clients.Tables [0].Rows [i].ItemArray [3].ToString ());

                clientBox.AddAttribute (cellrenderer, "text", 0);

                model.AppendValues (sb.ToString ());

            }
            clientBox.Active = 0;
            clientSelectionne.Sensitive = true;
        }
Ejemplo n.º 47
0
    private void fillListStore(ListStore listStore, IDataReader dataReader)
    {
        listStore.Clear();

        while (dataReader.Read()){
            List<string> values = new List<string>();
            for (int i = 0; i < dataReader.FieldCount; i++)
                values.Add (dataReader.GetValue (i).ToString());
            listStore.AppendValues (values.ToArray());
        }
    }
Ejemplo n.º 48
0
    private void fillListStore(ListStore listStore, IDataReader dataReader)
    {
        listStore.Clear();

        while (dataReader.Read()){
            listStore.AppendValues(dataReader["id"].ToString(),dataReader["nombre"].ToString(),
                                   dataReader["categoria"].ToString(), dataReader["precio"].ToString());
        }
    }
Ejemplo n.º 49
0
    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();
        InfoAction.Sensitive=false;
        addAction.Sensitive=true;
        deleteAction.Sensitive=false;
        refreshAction.Sensitive=true;
        mySqlConnection.Open();
        string sql="Select * from categoria";
        string sql2="Select * from articulo";
        if(notebook1.GetTabLabelText(notebook1.GetNthPage(0)).Equals("Categoria")){

            tree1=new TreeViewHelper(treeview2,mySqlConnection,sql);

        }
        if(notebook1.GetTabLabelText(notebook1.GetNthPage(1)).Equals("Articulo")){

            tree2=new TreeViewHelper(treeview1,mySqlConnection,sql2);

        }

        InfoAction.Activated +=delegate{

                listStore=creaListStore();
                string op=listStore.GetValue(iter,1).ToString();

                    MessageDialog md = new MessageDialog
                        (this, DialogFlags.Modal, MessageType.Info, ButtonsType.Close,op);
                    md.Run();
                    md.Destroy();
        };

        addAction.Activated +=delegate{

                win = new Window ("Test");
                win.SetDefaultSize (300, 100);
                win.SetPosition(WindowPosition.Center);
                hbox=new HBox(false,0);
                vbox=new VBox(false,0);
                vbox2=new VBox(false,0);

                win.Add(hbox);
                hbox.PackStart(vbox,false,false,0);

                //hbox.PackStart(vbox2,false,false,0);
            if(esCategoria()){

                creaVentanaCategoria();

            }
            else{
                win.SetDefaultSize (300, 200);
                creaVentanaArticulo();
            }
        };

        deleteAction.Activated +=delegate{
            if(esCategoria()){
                listStore=creaListStore();
                string nombre=listStore.GetValue(iter,1).ToString();
                MessageDialog md2 = new MessageDialog
                        (this, DialogFlags.Modal, MessageType.Warning, ButtonsType.YesNo,"¿Seguro que quieres borrarlo? \n Borrar: "+nombre);

            ResponseType result = (ResponseType)md2.Run ();
            string op=listStore.GetValue(iter,0).ToString();

            if (result == ResponseType.Yes){
                MySqlCommand delete=mySqlConnection.CreateCommand();
                delete.CommandText= "Delete from categoria where id="+op+"";
                delete.ExecuteNonQuery();
                md2.Destroy();
            }
            else{
                md2.Destroy();

            }
            }
            else{

                listStore=creaListStore();
                string nombre=listStore.GetValue(iter,1).ToString();
                MessageDialog md2 = new MessageDialog
                        (this, DialogFlags.Modal, MessageType.Warning, ButtonsType.YesNo,"¿Seguro que quieres borrarlo? \n Borrar: "+nombre);

                ResponseType result = (ResponseType)md2.Run ();
                string op=listStore.GetValue(iter,0).ToString();

                if (result == ResponseType.Yes){
                    MySqlCommand delete=mySqlConnection.CreateCommand();
                    delete.CommandText= "Delete from articulo where id="+op+"";
                    delete.ExecuteNonQuery();
                    md2.Destroy();
                }
                else{
                md2.Destroy();

                }
            }
        };

        notebook1.SwitchPage+=delegate{
            if(esCategoria()){
                    bool isSelected=treeview2.Selection.GetSelected(out iter);
                    if(isSelected){
                        InfoAction.Sensitive=true;
                        addAction.Sensitive=true;
                        deleteAction.Sensitive=true;
                        refreshAction.Sensitive=true;
                    }
                    else{
                        InfoAction.Sensitive=false;
                        //addAction.Sensitive=false;
                        deleteAction.Sensitive=false;
                        //refreshAction.Sensitive=false;
                }
            }
            else{
                bool isSelected=treeview1.Selection.GetSelected(out iter);
                if(isSelected){
                    InfoAction.Sensitive=true;
                    addAction.Sensitive=true;
                    deleteAction.Sensitive=true;
                    refreshAction.Sensitive=true;
                }
                else{
                    InfoAction.Sensitive=false;
                    //addAction.Sensitive=false;
                    deleteAction.Sensitive=false;
                    //refreshAction.Sensitive=false;
                }
            }
        };
        treeview1.Selection.Changed +=delegate{

            if(!esCategoria()){
                bool isSelected=treeview1.Selection.GetSelected(out iter);
                if(isSelected){
                    InfoAction.Sensitive=true;
                    //addAction.Sensitive=true;
                    deleteAction.Sensitive=true;
                    refreshAction.Sensitive=true;
                }
                else{
                    InfoAction.Sensitive=false;
                    //addAction.Sensitive=false;
                    deleteAction.Sensitive=false;
                    //refreshAction.Sensitive=false;
                }
            }
        };

            treeview2.Selection.Changed +=delegate{

                if(esCategoria()){
                    bool isSelected=treeview2.Selection.GetSelected(out iter);
                    if(isSelected){
                        InfoAction.Sensitive=true;
                        //addAction.Sensitive=true;
                        deleteAction.Sensitive=true;
                        refreshAction.Sensitive=true;
                    }
                    else{
                        InfoAction.Sensitive=false;
                        //addAction.Sensitive=false;
                        deleteAction.Sensitive=false;
                        //refreshAction.Sensitive=false;
                }
            }
        };

        refreshAction.Activated +=delegate{
            if(esCategoria()){
                listStore=tree1.ListStore;
                fielCountCategoria=tree1.getFieldCount();
                for (int i=0;i<fielCountCategoria;i++){//elimina columnas
                    treeview2.RemoveColumn(treeview2.GetColumn(0));
                }
                listStore.Clear();
                listStore=tree1.ListStore;
                tree1.actualizar(dbCommand,listStore);

            }
            else{
                listStore=tree2.ListStore;
                fieldCountArticulo=tree2.getFieldCount();
                for (int i=0;i<fieldCountArticulo;i++){//elimina columnas
                    treeview1.RemoveColumn(treeview1.GetColumn(0));
                }
                listStore.Clear();
                listStore=tree2.ListStore;
                tree2.actualizar(dbCommand,listStore);
            }
        };
    }
Ejemplo n.º 50
0
		public static void Refresh(ListStore listStore){
			listStore.Clear ();
		}
    public void PopulateLibrary(ListStore list)
    {
        list.Clear ();
        if (Directory.Exists (AppDomain.CurrentDomain.BaseDirectory + "/Games")) {
            //If the Games directory exists, start iterating through each subdirectory
            string[] dirs = Directory.GetDirectories(AppDomain.CurrentDomain.BaseDirectory + "/Games");
            //If the games directory actually HAS games, add 'em to the library.
            if (dirs.Length > 0) {
                foreach (string dir in dirs) {
                    if (File.Exists (dir + "/metadata.json")) {
                        DirectoryInfo dirinf = new DirectoryInfo (dir);
                        string metadatajson = File.ReadAllText (dir + "/metadata.json");
                        GameInfo game = Newtonsoft.Json.JsonConvert.DeserializeObject<GameInfo> (metadatajson);
                        list.AppendValues (game.Name, game, dirinf.Name);

                    }
                }
                //If not, tell the user they don't have any.
            } else {
                list.AppendValues ("No games installed yet.");
            }
        } else {
            //If not, create the directory.
            Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "/Games");
            list.AppendValues ("No games installed yet.");
        }
    }