Example #1
0
        void RenameCurrentPreset(string newName)
        {
            if (configuration == null)
            {
                CreateNewPreset(newName);
                return;
            }

            if (configuration.Vendor == newName || !CanUseNewName(newName))
            {
                return;
            }

            // If default compiler affected, update the default compiler's name, too
            if (defaultCompilerVendor == configuration.Vendor)
            {
                defaultCompilerVendor = newName;
            }

            // Apply new name to the cfg object
            configuration.Vendor = newName;

            // + to the compiler store model
            compilerStore.Foreach((TreeModel tree, TreePath path, TreeIter iter) =>
            {
                if (compilerStore.GetValue(iter, 1) == configuration)
                {
                    compilerStore.SetValue(iter, 0, configuration.Vendor);
                    return(true);
                }

                return(false);
            });
        }
Example #2
0
    private void saveConfig()
    {
        int port;

        softwareKey.SetValue("ip_address", entry_address.Text);
        softwareKey.SetValue("scroll_speed", led_matrix.scroll_speed);
        softwareKey.SetValue("winamp_address", entry_winamp_address.Text);
        int.TryParse(entry_winamp_port.Text, out port);
        softwareKey.SetValue("winamp_port", port);
        softwareKey.SetValue("winamp_pass", entry_winamp_pass.Text);
        softwareKey.DeleteSubKeyTree("lines");
        treeview_lines_store.Foreach(treemode_foreach_func);
    }
Example #3
0
        //table1
        public DevicesOptionsWidget(Gtk.Window parent)
        {
            parentWindow = parent;
            this.Build();
            //ComboBox cbResolution = new ComboBox();

            //table1.Attach(cbResolution,1,2,0,1);
            CellRendererText textRenderer = new CellRendererText();

            //cbResolution.PackStart(textRenderer, true);

            cbResolution.AddAttribute(textRenderer, "text", 0);

            cbResolution.Model = resolStore;

            tvFiles.AppendColumn(MainClass.Languages.Translate("file"), new Gtk.CellRendererText(), "text", 0);
            tvFiles.AppendColumn(MainClass.Languages.Translate("path"), new Gtk.CellRendererText(), "text", 1);

            string[] listFi = Directory.GetFiles(MainClass.Paths.DisplayDir, "*.ini");
            foreach (string fi in listFi)
            {
                EmulatorDisplay dd = new EmulatorDisplay(fi);
                if (dd.Load())
                {
                    fileListStore.AppendValues(System.IO.Path.GetFileName(fi), fi, dd);
                }
            }

            foreach (Rule rl in MainClass.Settings.Resolution.Rules)
            {
                resolStore.AppendValues(String.Format("{0} ({1}x{2})", rl.Name, rl.Width, rl.Height), rl.Id, rl.Name, rl.Specific, rl);
            }

            tvFiles.Model = fileListStore;

            tvFiles.Selection.Changed += delegate(object sender, EventArgs e)
            {
                if (isChange)
                {
                    Save(true);
                }

                selectedResolDisplay = GetSelectedDevicesDisplay();
                if (selectedResolDisplay == null)
                {
                    return;
                }

                sbHeight.Value = selectedResolDisplay.Height;
                sbWidth.Value  = selectedResolDisplay.Width;

                entTitle.Text    = selectedResolDisplay.Title;
                entAuthor.Text   = selectedResolDisplay.Author;
                entUrl.Text      = selectedResolDisplay.Url;
                chbTablet.Active = selectedResolDisplay.Tablet;

                Rule rlr = MainClass.Settings.Resolution.Rules.Find(x => x.Height == selectedResolDisplay.Height && x.Width == selectedResolDisplay.Width);

                if (rlr != null)
                {
                    TreeIter ti     = new TreeIter();
                    bool     isFind = false;
                    resolStore.Foreach((model, path, iterr) => {
                        Rule ruleIter = (Rule)resolStore.GetValue(iterr, 4);

                        if (ruleIter == rlr)
                        {
                            ti     = iterr;
                            isFind = true;
                            return(true);
                        }
                        return(false);
                    });
                    if (isFind)
                    {
                        cbResolution.SetActiveIter(ti);
                    }
                    else
                    {
                        cbResolution.Active = 0;
                    }
                }
                isChange = false;
            };
            cbResolution.Changed += delegate(object sender, EventArgs e) {
                TreeIter ti = new TreeIter();
                if (cbResolution.GetActiveIter(out ti))
                {
                    Rule ruleIter = (Rule)resolStore.GetValue(ti, 4);
                    sbHeight.Value = ruleIter.Height;
                    sbWidth.Value  = ruleIter.Width;
                }
            };
        }
    OSDArray ListStoreToOSD(ListStore list)
    {
        OSDArray ret = new OSDArray();
        list.Foreach((model, path, iter) =>
        {
            var item = model.GetValue(iter, 0) as FilterItem;
            if (null != item)
            {
                ret.Add(item.ToOSD());
            }

            return false;
        });
        return ret;
    }
Example #5
0
        private void GenerateNotebookPages()
        {
            string platformName = MainClass.Settings.Platform.Name;

            foreach(Rule rl in MainClass.Settings.Platform.Rules){

                bool iOsNoMac = false;

                if( (rl.Tag == -1 ) && !MainClass.Settings.ShowUnsupportedDevices) continue;
                if( (rl.Tag == -2 ) && !MainClass.Settings.ShowDebugDevices) continue;

                bool validDevice = true;

                if(!Device.CheckDevice(rl.Specific) ){
                    Tool.Logger.Debug("Invalid Device " + rl.Specific);
                    validDevice = false;
                }

                ScrolledWindow sw= new ScrolledWindow();
                sw.ShadowType = ShadowType.EtchedOut;

                TreeView tvList = new TreeView();

                List<CombinePublish> lcp =  project.ProjectUserSetting.CombinePublish.FindAll(x=> x.combineRule.FindIndex(y=>y.ConditionName==platformName && y.RuleId == rl.Id) >-1);
                List<CombinePublish> lcpDennied = new List<CombinePublish>();
                string deviceName = rl.Name;
                int deviceTyp = rl.Id;

                ListStore ls = new ListStore(typeof(bool),typeof(string),typeof(CombinePublish),typeof(string),typeof(bool));

                string ico="empty.png";
                switch (deviceTyp) {
                case (int)DeviceType.Android_1_6:{
                    ico = "android.png";
                    break;}
                case (int)DeviceType.Android_2_2:{
                    ico = "android.png";
                    break;}
                case (int)DeviceType.Bada_1_0:
                case (int)DeviceType.Bada_1_1:
                case (int)DeviceType.Bada_1_2:
                case (int)DeviceType.Bada_2_0:{
                    ico = "bada.png";
                    break;}
                case (int)DeviceType.Symbian_9_4:{
                    ico = "symbian.png";
                    break;}
                case (int)DeviceType.iOS_5_0:{
                    ico = "apple.png";
                    if(!MainClass.Platform.IsMac){
                        iOsNoMac = true;
                    }

                    break;
                }
                case (int)DeviceType.PocketPC_2003SE:
                case (int)DeviceType.WindowsMobile_5:
                case (int)DeviceType.WindowsMobile_6:{
                    ico = "windows.png";
                    break;}
                case (int)DeviceType.Windows:{
                    ico = "win32.png";
                    break;}
                case (int)DeviceType.MacOs:{
                    ico = "macos.png";
                    break;}
                }

                List<CombinePublish> tmp =  lcp.FindAll(x=>x.IsSelected == true);

                NotebookLabel nl = new NotebookLabel(ico,String.Format("{0} ({1})",deviceName,tmp.Count ));
                nl.Tag=deviceTyp;

                if(iOsNoMac){
                    Label lbl=new Label(MainClass.Languages.Translate("ios_available_Mac"));

                    Pango.FontDescription customFont =  Pango.FontDescription.FromString(MainClass.Settings.ConsoleTaskFont);
                    customFont.Weight = Pango.Weight.Bold;
                    lbl.ModifyFont(customFont);

                    notebook.AppendPage(lbl, nl);
                    continue;
                }
                if(!validDevice){
                    Label lbl=new Label(MainClass.Languages.Translate("publish_tool_missing"));

                    Pango.FontDescription customFont =  Pango.FontDescription.FromString(MainClass.Settings.ConsoleTaskFont);
                    customFont.Weight = Pango.Weight.Bold;
                    lbl.ModifyFont(customFont);

                    notebook.AppendPage(lbl, nl);
                    continue;
                }

                ;
                CellRendererToggle crt = new CellRendererToggle();
                crt.Activatable = true;
                crt.Sensitive = true;
                tvList.AppendColumn ("", crt, "active", 0);

                Gtk.CellRendererText fileNameRenderer = new Gtk.CellRendererText();
                Gtk.CellRendererText collumnResolRenderer = new Gtk.CellRendererText();

                tvList.AppendColumn(MainClass.Languages.Translate("file_name"),fileNameRenderer, "text", 1);
                tvList.AppendColumn(MainClass.Languages.Translate("resolution_f1"), collumnResolRenderer, "text", 1);

                tvList.Columns[1].SetCellDataFunc(fileNameRenderer, new Gtk.TreeCellDataFunc(RenderCombine));
                tvList.Columns[2].SetCellDataFunc(collumnResolRenderer, new Gtk.TreeCellDataFunc(RenderResolution));

                // povolene resolution pre danu platformu
                PlatformResolution listPR = MainClass.Settings.PlatformResolutions.Find(x=>x.IdPlatform ==deviceTyp);

                Device dvc  = project.DevicesSettings.Find(x=>x.TargetPlatformId ==deviceTyp);

                string stringTheme = "";
                List<System.IO.DirectoryInfo> themeResolution = new List<System.IO.DirectoryInfo>(); // resolution z adresara themes po novom

                if((project.NewSkin) && (dvc != null)){
                    Skin skin =dvc.Includes.Skin;
                    if((skin != null) && ( !String.IsNullOrEmpty(skin.Name)) && (!String.IsNullOrEmpty(skin.Theme)) ){
                        string skinDir = System.IO.Path.Combine(MainClass.Workspace.RootDirectory,  MainClass.Settings.SkinDir);
                        stringTheme = System.IO.Path.Combine(skinDir,skin.Name);
                        stringTheme = System.IO.Path.Combine(stringTheme, "themes");
                        stringTheme = System.IO.Path.Combine(stringTheme, skin.Theme);

                        if (System.IO.Directory.Exists(stringTheme)){
                            System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(stringTheme);
                            themeResolution = new List<System.IO.DirectoryInfo>(di.GetDirectories());
                        }
                    }
                }

                crt.Toggled += delegate(object o, ToggledArgs args) {
                    if((deviceTyp == (int)DeviceType.Windows)||(deviceTyp == (int)DeviceType.MacOs)){
                        if(!MainClass.LicencesSystem.CheckFunction("windowsandmac",this)){
                            return;
                        }
                    }

                    TreeIter iter;
                    if (ls.GetIter (out iter, new TreePath(args.Path))) {
                        bool old = (bool) ls.GetValue(iter,0);
                        CombinePublish cp =(CombinePublish) ls.GetValue(iter,2);
                        cp.IsSelected = !old;
                        ls.SetValue(iter,0,!old);

                        List<CombinePublish> tmp2 =  lcp.FindAll(x=>x.IsSelected == true);
                        nl.SetLabel (String.Format("{0} ({1})",deviceName,tmp2.Count ));

                        //if(dvc == null) return;
                        //if(dvc.Includes == null) return;
                        if(dvc.Includes.Skin == null) return;
                        if(String.IsNullOrEmpty(dvc.Includes.Skin.Name) || String.IsNullOrEmpty(dvc.Includes.Skin.Theme)) return;

                        if(cp.IsSelected){
                            // Najdem ake je rozlisenie v danej combinacii
                            CombineCondition cc = cp.combineRule.Find(x=>x.ConditionId == MainClass.Settings.Resolution.Id);

                            if(cc == null) return; /// nema ziadne rozlisenie v combinacii

                            int indxResol = themeResolution.FindIndex(x=>x.Name.ToLower() == cc.RuleName.ToLower());
                            if(indxResol<0){
                                // theme chyba prislusne rozlisenie
                                string error =String.Format("Invalid {0} Skin and {1} Theme, using in {2}. Missing resolutions: {3}. ",dvc.Includes.Skin.Name,dvc.Includes.Skin.Theme,deviceName,cc.RuleName.ToLower());
                                MainClass.MainWindow.OutputConsole.WriteError(error+"\n");
                                List<string> lst = new List<string>();
                                lst.Add(error);
                                MainClass.MainWindow.ErrorWritte("","",lst);
                            }
                        }
                    }
                };

                int cntOfAdded = 0;
                foreach (CombinePublish cp in lcp){
                    bool isValid = cp.IsSelected;

                    if (!validDevice) isValid = false;

                    // Najdem ake je rozlisenie v danej combinacii
                    CombineCondition cc = cp.combineRule.Find(x=>x.ConditionId == MainClass.Settings.Resolution.Id);

                    if(cc == null) continue; /// nema ziadne rozlisenie v combinacii

                    int indx = MainClass.Settings.Resolution.Rules.FindIndex(x=> x.Id == cc.RuleId );
                    if(indx<0) continue; /// rozlisenie pouzite v danej combinacii nexistuje

                    if(cc!= null){
                        bool isValidResolution = false;

                        //ak nema definovane ziadne povolenia, tak povolene su vsetky
                        if((listPR==null) || (listPR.AllowResolution == null) ||
                           (listPR.AllowResolution.Count<1)){
                            isValidResolution = true;
                        } else {
                            isValidResolution = listPR.IsValidResolution(cc.RuleId);
                        }

                        if(isValidResolution){
                            // po novom vyhodom aj tie ktore niesu v adresaru themes - pokial je thema definovana
                            if((project.NewSkin) && (themeResolution.Count > 0)){
                                //cntResolution = 0;
                                int indxResol = themeResolution.FindIndex(x=>x.Name.ToLower() == cc.RuleName.ToLower());
                                if(indxResol>-1){
                                    ls.AppendValues(isValid,cp.ProjectName,cp,cp.ProjectName,true);
                                    cntOfAdded++;
                                } else {
                                    lcpDennied.Add(cp);
                                }
                            } else {
                                ls.AppendValues(isValid,cp.ProjectName,cp,cp.ProjectName,true);
                                cntOfAdded++;
                            }

                        } else {
                            lcpDennied.Add(cp);
                        }
                    }
                    //}
                }
                // pridam tie zakazane, ktore su vybrate na publish
                foreach (CombinePublish cp in lcpDennied){
                    if(cp.IsSelected){
                        ls.AppendValues(cp.IsSelected,cp.ProjectName,cp,cp.ProjectName,false);
                        cntOfAdded++;
                    }
                }

                if(cntOfAdded == 0){
                    MainClass.MainWindow.OutputConsole.WriteError(String.Format("Missing publish settings for {0}.\n",deviceName));
                }

                bool showAll = false;
                tvList.ButtonReleaseEvent += delegate(object o, ButtonReleaseEventArgs args){

                    if (args.Event.Button == 3) {
                        TreeSelection ts = tvList.Selection;
                        Gtk.TreePath[] selRow = ts.GetSelectedRows();

                        if(selRow.Length<1){
                            TreeIter tiFirst= new TreeIter();
                            ls.GetIterFirst(out tiFirst);

                            tvList.Selection.SelectIter(tiFirst);
                            selRow = ts.GetSelectedRows();
                        }
                        if(selRow.Length<1) return;

                        Gtk.TreePath tp = selRow[0];
                        TreeIter ti = new TreeIter();

                        ls.GetIter(out ti,tp);

                        CombinePublish combinePublish= (CombinePublish)ls.GetValue(ti,2);

                        if(combinePublish!=null){

                            Menu popupMenu = new Menu();
                            if(!showAll){
                                MenuItem miShowDenied = new MenuItem( MainClass.Languages.Translate("show_denied" ));
                                miShowDenied.Activated+= delegate(object sender, EventArgs e) {

                                    // odoberem zakazane, ktore sa zobrazuju kedze su zaceknute na publish
                                    List<TreeIter> lst= new List<TreeIter>();
                                    ls.Foreach((model, path, iterr) => {

                                        bool cp =(bool) ls.GetValue(iterr,4);
                                        bool selected =(bool) ls.GetValue(iterr,0);
                                        if(!cp && selected){
                                            lst.Add(iterr);
                                        }
                                        return false;
                                    });

                                    foreach(TreeIter ti2 in lst){
                                        TreeIter ti3 =ti2;
                                        ls.Remove(ref ti3);
                                    }

                                    // pridam zakazane
                                    if( (lcpDennied==null) || (lcpDennied.Count<1))
                                        return;

                                    foreach (CombinePublish cp in lcpDennied){
                                        ls.AppendValues(cp.IsSelected,cp.ProjectName,cp,cp.ProjectName,false);
                                    }
                                    showAll = true;
                                };
                                popupMenu.Append(miShowDenied);
                            } else {
                                MenuItem miHideDenied = new MenuItem( MainClass.Languages.Translate("hide_denied" ));
                                miHideDenied.Activated+= delegate(object sender, EventArgs e) {

                                    List<TreeIter> lst= new List<TreeIter>();
                                    ls.Foreach((model, path, iterr) => {

                                        bool cp =(bool) ls.GetValue(iterr,4);
                                        bool selected =(bool) ls.GetValue(iterr,0);
                                        if(!cp && !selected){
                                            lst.Add(iterr);
                                        }
                                        return false;
                                    });

                                    foreach(TreeIter ti2 in lst){
                                        TreeIter ti3 =ti2;
                                        ls.Remove(ref ti3);
                                    }

                                    showAll = false;
                                };
                                popupMenu.Append(miHideDenied);
                            }
                            popupMenu.Append(new SeparatorMenuItem());

                            MenuItem miCheckAll = new MenuItem( MainClass.Languages.Translate("check_all" ));
                            miCheckAll.Activated+= delegate(object sender, EventArgs e) {
                                if((deviceTyp == (int)DeviceType.Windows)||(deviceTyp == (int)DeviceType.MacOs)){
                                    if(!MainClass.LicencesSystem.CheckFunction("windowsandmac",this)){
                                        return;
                                    }
                                }

                                int cnt = 0;
                                ls.Foreach((model, path, iterr) => {
                                    CombinePublish cp =(CombinePublish) ls.GetValue(iterr,2);
                                    cp.IsSelected = true;
                                    ls.SetValue(iterr,0,true);
                                    cnt ++;
                                    return false;
                                });
                                nl.SetLabel (String.Format("{0} ({1})",deviceName,cnt ));

                            };
                            popupMenu.Append(miCheckAll);

                            MenuItem miUnCheckAll = new MenuItem( MainClass.Languages.Translate("uncheck_all" ));
                            miUnCheckAll.Activated+= delegate(object sender, EventArgs e) {
                                ls.Foreach((model, path, iterr) => {
                                    CombinePublish cp =(CombinePublish) ls.GetValue(iterr,2);
                                    cp.IsSelected = false;
                                    ls.SetValue(iterr,0,false);
                                    return false;
                                });
                                nl.SetLabel (String.Format("{0} ({1})",deviceName,0 ));
                            };
                            popupMenu.Append(miUnCheckAll);

                            popupMenu.Popup();
                            popupMenu.ShowAll();
                        }
                    }
                };

                tvList.Model = ls;

                if (!validDevice) tvList.Sensitive = false;

                sw.Add(tvList);
                notebook.AppendPage(sw, nl);
            }
        }
		private void updateTime(ref ListStore ls)
		{
			ls.Foreach(new TreeModelForeachFunc(delegate(TreeModel model, TreePath path, TreeIter iter) {
				long ticks = DateTime.Now.Ticks - (long)model.GetValue(iter,5);
				TimeSpan t = TimeSpan.FromTicks( ticks );
				string pt = "";
				if(t.Hours < 1){
					pt = string.Format("{0:#0}分前", t.Minutes);
				}else{
					pt = string.Format("{0:#0}時間{1:#0}分前",
						t.Hours,
						t.Minutes);
				}
				model.SetValue(iter, 3, pt);
				return false;
			}));
		}
Example #7
0
    void SetAllToggles(bool on, ListStore store)
    {
        if (null == store) return;

        store.Foreach((model, path, iter) =>
        {
            var item = model.GetValue(iter, 0) as FilterItem;
            if (null != item)
            {
                item.Enabled = on;
                model.SetValue(iter, 0, item);
            }

            return false;
        });
    }
Example #8
0
        void OnButtonPressed(object sender, Gtk.ButtonPressEventArgs args)
        {
            switch (args.Event.Button) {
                case 3: // third mouse button (right-click)
                    clickedTask = null;

                    Gtk.TreeView tv = sender as Gtk.TreeView;
                    if (tv == null)
                        return;

                    Gtk.TreeModel model = tv.Model;

                    Gtk.TreeIter iter;
                    Gtk.TreePath path;
                    Gtk.TreeViewColumn column = null;

                    if (!tv.GetPathAtPos ((int) args.Event.X,
                                    (int) args.Event.Y, out path, out column))
                        return;

                    if (!model.GetIter (out iter, path))
                        return;

                    clickedTask = model.GetValue (iter, 0) as ITask;
                    if (clickedTask == null)
                        return;

                    Menu popupMenu = new Menu ();
                    ImageMenuItem item;

                    item = new ImageMenuItem (Catalog.GetString ("_Notes..."));
                    item.Image = new Gtk.Image (noteIcon);
                    item.Activated += OnShowTaskNotes;
                    popupMenu.Add (item);

                    popupMenu.Add (new SeparatorMenuItem ());

                    item = new ImageMenuItem (Catalog.GetString ("_Delete task"));
                    item.Image = new Gtk.Image(Gtk.Stock.Delete, IconSize.Menu);
                    item.Activated += OnDeleteTask;
                    popupMenu.Add (item);

                    item = new ImageMenuItem(Catalog.GetString ("_Edit task"));
                    item.Image = new Gtk.Image(Gtk.Stock.Edit, IconSize.Menu);
                    item.Activated += OnEditTask;
                    popupMenu.Add (item);

                    /*
                     * Depending on the currently selected task's taskList, we create a context popup
                     * here in order to enable changing taskLists. The list of available taskLists
                     * is pre-filtered as to not contain the current taskList and the AllTaskList.
                     */

                    var filteredTaskLists = new ListStore (typeof (ITaskList));
                    foreach (var cat in application.BackendManager.TaskLists) {
                        if (cat != null && !(cat.ListType == TaskListType.Smart)
                        && !cat.Contains (clickedTask))
                            filteredTaskLists.AppendValues (cat);
                    }

                    // The taskLists submenu is only created in case we actually provide at least one taskList.
                    if (filteredTaskLists.GetIterFirst(out iter))
                    {
                        Menu taskListMenu = new Menu();
                        TaskListMenuItem taskListItem;

                        filteredTaskLists.Foreach(delegate(TreeModel t, TreePath p, TreeIter i) {
                            taskListItem = new TaskListMenuItem((ITaskList)t.GetValue(i, 0));
                            taskListItem.Activated += OnChangeTaskList;
                            taskListMenu.Add(taskListItem);
                            return false;
                        });

                        // TODO Needs translation.
                        item = new ImageMenuItem(Catalog.GetString("_Change list"));
                        item.Image = new Gtk.Image(Gtk.Stock.Convert, IconSize.Menu);
                        item.Submenu = taskListMenu;
                        popupMenu.Add(item);
                    }

                    popupMenu.ShowAll();
                    popupMenu.Popup ();

                    // Logger.Debug ("Right clicked on task: " + task.Name);
                    break;
            }
        }
Example #9
0
 public void save_lines()
 {
     treeview_lines_store.Foreach(treemode_foreach_func);
 }