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); } }
public void GeneratePlatformResolutions() { PlatformResolutions = new List <PlatformResolution>(); PlatformResolution prAndr16 = new PlatformResolution((int)DeviceType.Android_1_6); prAndr16.AllowResolution = new List <int>(); prAndr16.AllowResolution.Add(-1); //prAndr16.AllowResolution.Add(-2); prAndr16.AllowResolution.Add(-3); //prAndr16.AllowResolution.Add(-4); prAndr16.AllowResolution.Add(-5); prAndr16.AllowResolution.Add(-6); prAndr16.AllowResolution.Add(-7); prAndr16.AllowResolution.Add(-8); prAndr16.AllowResolution.Add(-9); prAndr16.AllowResolution.Add(-10); //prAndr16.AllowResolution.Add(-11); prAndr16.AllowResolution.Add(-12); prAndr16.AllowResolution.Add(-13); prAndr16.AllowResolution.Add(-14); prAndr16.AllowResolution.Add(-15); prAndr16.AllowResolution.Add(-16); PlatformResolutions.Add(prAndr16); PlatformResolution prAndr22 = new PlatformResolution((int)DeviceType.Android_2_2); prAndr22.AllowResolution = new List <int>(); prAndr22.AllowResolution.Add(-1); //prAndr22.AllowResolution.Add(-2); prAndr22.AllowResolution.Add(-3); //prAndr22.AllowResolution.Add(-4); prAndr22.AllowResolution.Add(-5); prAndr22.AllowResolution.Add(-6); prAndr22.AllowResolution.Add(-7); prAndr22.AllowResolution.Add(-8); prAndr22.AllowResolution.Add(-9); prAndr22.AllowResolution.Add(-10); //prAndr22.AllowResolution.Add(-11); prAndr22.AllowResolution.Add(-12); prAndr22.AllowResolution.Add(-13); prAndr22.AllowResolution.Add(-14); prAndr22.AllowResolution.Add(-15); prAndr22.AllowResolution.Add(-16); PlatformResolutions.Add(prAndr22); PlatformResolution prIos = new PlatformResolution((int)DeviceType.iOS_5_0); prIos.AllowResolution = new List <int>(); prIos.AllowResolution.Add(-1); prIos.AllowResolution.Add(-3); prIos.AllowResolution.Add(-7); prIos.AllowResolution.Add(-8); prIos.AllowResolution.Add(-15); prIos.AllowResolution.Add(-17); PlatformResolutions.Add(prIos); PlatformResolution prBada10 = new PlatformResolution((int)DeviceType.Bada_1_0); prBada10.AllowResolution = new List <int>(); prBada10.AllowResolution.Add(-1); //prBada10.AllowResolution.Add(-3); prBada10.AllowResolution.Add(-6); //prBada10.AllowResolution.Add(-11); PlatformResolutions.Add(prBada10); PlatformResolution prBada11 = new PlatformResolution((int)DeviceType.Bada_1_1); prBada11.AllowResolution = new List <int>(); prBada11.AllowResolution.Add(-1); prBada11.AllowResolution.Add(-3); //prBada11.AllowResolution.Add(-6); //prBada11.AllowResolution.Add(-11); PlatformResolutions.Add(prBada11); /*PlatformResolution prBada2 = new PlatformResolution((int)DeviceType.Bada_1_2); * prBada2.AllowResolution = new List<int>(); * prBada2.AllowResolution.Add(-1); * prBada2.AllowResolution.Add(-6); * PlatformResolutions.Add(prBada2);*/ PlatformResolution prSymbian94 = new PlatformResolution((int)DeviceType.Symbian_9_4); prSymbian94.AllowResolution = new List <int>(); prSymbian94.AllowResolution.Add(-1); //prSymbian94.AllowResolution.Add(-4); prSymbian94.AllowResolution.Add(-6); PlatformResolutions.Add(prSymbian94); /*PlatformResolution prSymbian95 = new PlatformResolution((int)DeviceType.Symbian_9_5); * prSymbian95.AllowResolution = new List<int>(); * prSymbian95.AllowResolution.Add(-1); * prSymbian95.AllowResolution.Add(-4); * prSymbian95.AllowResolution.Add(-6); * prSymbian95.AllowResolution.Add(-11); * PlatformResolutions.Add(prSymbian95);*/ /*PlatformResolution prWindowsMobile5 = new PlatformResolution((int)DeviceType.WindowsMobile_5); * prWindowsMobile5.AllowResolution = new List<int>(); * prWindowsMobile6.AllowResolution.Add(-1); * prWindowsMobile5.AllowResolution.Add(-3); * prWindowsMobile5.AllowResolution.Add(-2); * prWindowsMobile5.AllowResolution.Add(-5); * prWindowsMobile5.AllowResolution.Add(-6); * PlatformResolutions.Add(prWindowsMobile5);*/ PlatformResolution prWindowsMobile6 = new PlatformResolution((int)DeviceType.WindowsMobile_6); prWindowsMobile6.AllowResolution = new List <int>(); prWindowsMobile6.AllowResolution.Add(-1); prWindowsMobile6.AllowResolution.Add(-3); //prWindowsMobile6.AllowResolution.Add(-2); prWindowsMobile6.AllowResolution.Add(-5); prWindowsMobile6.AllowResolution.Add(-6); PlatformResolutions.Add(prWindowsMobile6); }