Beispiel #1
0
    protected void OnTreeview1DragEnd(object o, DragEndArgs args)
    {
        // HACK: GTK thinks it's special and has its own model
        // instead of our own. Resync changes made to the GTK
        // model, manually.

        var newPal = appPal.Palette.Clone();

        // HACK: we don't have .Select on models
        var newList = new List <PaletteColor>();

        ls.Foreach((m, p, i) =>
        {
            var pc = GetItemFromIter(i);
            newList.Add(pc);
            return(false);            // .Foreach needs this to continue walking
        });

        // because thse are different lists, but containing the same
        // objects, do this
        if (!newPal.Colors.SequenceEqual(newList))
        {
            newPal.Colors = newList;
            appPal.SetPalette(newPal, action: "Move Colour");
        }
    }
 void OnSelectAll(object sender, EventArgs args)
 {
     games_store.Foreach(delegate(TreeModel model, TreePath path, TreeIter iter)  {
         games_store.SetValue(iter, COL_ENABLED, true);
         return(false);
     });
 }
Beispiel #3
0
 protected virtual void btnSelectAll_Click(object sender, System.EventArgs e)
 {
     this.selectedStocks.Clear();
     listStocks.Foreach((TreeModel, path, iter) =>
     {
         listStocks.SetValue(iter, 0, true);
         this.selectedStocks.Add((string)listStocks.GetValue(iter, 1));
         return(false);
     });
 }
Beispiel #4
0
    private void btnAddAssignment_Clicked(object sender, EventArgs args)
    {
        m_assignments.Foreach(new TreeModelForeachFunc(ForEachObject));

        if (!m_redefinitions.ContainsKey((int)sbtnNewValueIndex.Value))
        {
            m_assignments.AppendValues((int)sbtnNewValueIndex.Value, txtNewValue.Text);
            sbtnNewValueIndex.Value++;
            txtNewValue.Text = "";
            txtNewValue.GrabFocus();

            m_assignments.Foreach(new TreeModelForeachFunc(ForEachObject));
        }
    }
Beispiel #5
0
        TreeIter GetTreeIter(PackageSourceViewModel packageSourceViewModel)
        {
            TreeIter foundIter = TreeIter.Zero;

            packageSourcesStore.Foreach((model, path, iter) => {
                var currentViewModel = model.GetValue(iter, PackageSourceViewModelColumn) as PackageSourceViewModel;
                if (currentViewModel == packageSourceViewModel)
                {
                    foundIter = iter;
                    return(true);
                }
                return(false);
            });
            return(foundIter);
        }
Beispiel #6
0
        protected virtual void OnBtnMyTypeClicked(object sender, System.EventArgs e)
        {
            EntryDialog ed     = new EntryDialog("", MainClass.Languages.Translate("filed_typ"), this);
            int         result = ed.Run();

            if (result == (int)ResponseType.Ok)
            {
                string newTyp = ed.TextEntry;

                if (!String.IsNullOrEmpty(newTyp))
                {
                    bool isFind = false;
                    fieldTypeStore.Foreach((model, path, iterr) => {
                        string name = fieldTypeStore.GetValue(iterr, 0).ToString();

                        if (name == newTyp)
                        {
                            cbFieldType.SetActiveIter(iterr);
                            isFind = true;
                            return(true);
                        }
                        return(false);
                    });
                    if (!isFind)
                    {
                        TreeIter ti = fieldTypeStore.AppendValues(newTyp);
                        cbFieldType.SetActiveIter(ti);
                    }
                }
            }
            ed.Destroy();
        }
Beispiel #7
0
        ListStore GetCompletionModel(TreeView t)
        {
            string        prop = t.Columns[colNum].Title;
            List <string> list = new List <string>();

            store.Foreach(
                delegate(TreeModel model, TreePath path, TreeIter iter) {
                object o = model.GetValue(iter, 0);
                object p = o.GetType().InvokeMember(prop + "Completion",
                                                    BindingFlags.GetProperty, null, o, null);

                if (p != null)
                {
                    if (!list.Contains(p.ToString()))
                    {
                        list.Add(p.ToString());
                    }
                }
                return(false);
            });
            ListStore s = new ListStore(typeof(string));

            foreach (string str in list)
            {
                s.AppendValues(str);
            }
            return(s);
        }
        private void FindListItem(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                return;
            }
            TreeIter iter = TreeIter.Zero;

            _listStore.Foreach((model, path, it) =>
            {
                var item = ((BaseItem)model.GetValue(it, 0));
                if (string.Equals(item.ServerPath.ItemName, name, StringComparison.OrdinalIgnoreCase))
                {
                    iter = it;
                    return(true);
                }
                return(false);
            });
            if (iter.Equals(TreeIter.Zero))
            {
                return;
            }
            _listView.Selection.SelectIter(iter);
            var treePath = _listStore.GetPath(iter);

            _listView.ScrollToCell(treePath, _listView.Columns[0], false, 0, 0);
        }
Beispiel #9
0
    protected virtual void OnButtonSavePlayersFileClicked(object sender, System.EventArgs e)
    {
        var saveDialog = new FileChooserDialog("Save Players File", this, FileChooserAction.Save,
                                               "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept);

        SetUniqueFileName(saveDialog, Nexus.Settings.Default.PlayersFileDirectory, "players.txt");
        saveDialog.DoOverwriteConfirmation = true;

        if (saveDialog.Run() == (int)ResponseType.Accept)
        {
            using (var writer = new StreamWriter(saveDialog.Filename))
            {
                playerStore.Foreach(delegate(TreeModel model, TreePath path, TreeIter iter)
                {
                    var playerId    = Convert.ToString(playerStore.GetValue(iter, 0));
                    var playerIndex = playerIds.IndexOf(playerId);

                    writer.WriteLine(string.Format("{0} {1}", playerId, playerIndex));
                    return(false);
                });
            }

            Nexus.Settings.Default.PlayersFileDirectory = System.IO.Path.GetDirectoryName(saveDialog.Filename);
        }

        saveDialog.Destroy();
    }
Beispiel #10
0
    protected virtual void OnButtonSaveGamesFileClicked(object sender, System.EventArgs e)
    {
        var saveDialog = new FileChooserDialog("Save Games File", this, FileChooserAction.Save,
                                               "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept);

        SetUniqueFileName(saveDialog, Nexus.Settings.Default.GamesFileDirectory, "game_config.xml");
        saveDialog.DoOverwriteConfirmation = true;

        try
        {
            if (saveDialog.Run() == (int)ResponseType.Accept)
            {
                // Save games file
                using (var writer = new System.Xml.XmlTextWriter(saveDialog.Filename,
                                                                 System.Text.Encoding.UTF8))
                {
                    writer.Formatting = System.Xml.Formatting.Indented;
                    writer.WriteStartDocument();
                    writer.WriteStartElement("games");

                    gameStore.Foreach(delegate(TreeModel model, TreePath path, TreeIter iter)
                    {
                        // Save individual game info
                        var gameInfo = (IGameInfo)model.GetValue(iter, 3);

                        writer.WriteStartElement("game");
                        writer.WriteAttributeString("name", gameInfo.GameName);
                        writer.WriteAttributeString("description", gameInfo.GameDescription);

                        gameInfo.Save(writer);

                        writer.WriteEndElement();

                        return(false);
                    });

                    // games
                    writer.WriteEndElement();
                    writer.WriteEndDocument();

                    Nexus.Settings.Default.GamesFileDirectory = System.IO.Path.GetDirectoryName(saveDialog.Filename);
                }
            }
        }
        catch (Exception ex)
        {
            logger.Error("OnButtonSaveGamesFileClicked", ex);
            ShowErrorDialog(ex);
        }
        finally
        {
            saveDialog.Destroy();
        }
    }
Beispiel #11
0
        public void UpdateWrapWidth()
        {
            if (view.IsRealized && model != null)
            {
                var width = GetValueWidth();

                model.Foreach((ITreeModel m, TreePath path, TreeIter iter) => {
                    if ((Pango.EllipsizeMode)model.GetValue(iter, 3) != Pango.EllipsizeMode.End)
                    {
                        model.SetValue(iter, 5, width);
                    }
                    return(false);
                });
            }
        }
        /// <summary>
        /// Exports the mipmaps in the image.
        /// </summary>
        public void RunExport()
        {
            ItemExportListStore.Foreach(delegate(ITreeModel model, TreePath path, TreeIter iter)
            {
                bool bShouldExport = (bool)ItemExportListStore.GetValue(iter, 0);

                if (bShouldExport)
                {
                    ItemReference referenceToExport = this.ReferenceMapping[(string)ItemExportListStore.GetValue(iter, 1)];

                    string ExportPath = "";
                    if (Config.GetShouldKeepFileDirectoryStructure())
                    {
                        string parentDirectoryOfFile =
                            ExtensionMethods.ConvertPathSeparatorsToCurrentNativeSeparator(ExportTarget.ItemPath);

                        ExportPath =
                            $"{ExportDirectoryFileChooserButton.Filename}{System.IO.Path.DirectorySeparatorChar}{parentDirectoryOfFile}{System.IO.Path.DirectorySeparatorChar}{referenceToExport.GetReferencedItemName()}";
                    }
                    else
                    {
                        ExportPath = $"{ExportDirectoryFileChooserButton.Filename}{System.IO.Path.DirectorySeparatorChar}{referenceToExport.GetReferencedItemName()}";
                    }

                    System.IO.Directory.CreateDirectory(System.IO.Directory.GetParent(ExportPath).FullName);

                    byte[] fileData = referenceToExport.Extract();
                    if (fileData != null)
                    {
                        File.WriteAllBytes(ExportPath, fileData);
                    }
                }

                return(false);
            });
        }
        /// <summary>
        /// Exports the mipmaps in the image.
        /// </summary>
        public void RunExport()
        {
            string ImageFilename = System.IO.Path.GetFileNameWithoutExtension(ExtensionMethods.ConvertPathSeparatorsToCurrentNativeSeparator(ExportTarget.ItemPath));

            string ExportPath = "";

            if (Config.GetShouldKeepFileDirectoryStructure())
            {
                ExportPath =
                    $"{ExportDirectoryFileChooserButton.Filename}{System.IO.Path.DirectorySeparatorChar}{ExtensionMethods.ConvertPathSeparatorsToCurrentNativeSeparator(ExportTarget.ItemPath).Replace(".blp", "")}";
            }
            else
            {
                ExportPath = $"{ExportDirectoryFileChooserButton.Filename}{System.IO.Path.DirectorySeparatorChar}{ImageFilename}";
            }


            int i = 0;

            MipLevelListStore.Foreach(delegate(ITreeModel model, TreePath path, TreeIter iter)
            {
                bool bShouldExport = (bool)MipLevelListStore.GetValue(iter, 0);

                if (bShouldExport)
                {
                    string formatExtension = GetFileExtensionFromImageFormat((ImageFormat)ExportFormatComboBox.Active);
                    System.IO.Directory.CreateDirectory(System.IO.Directory.GetParent(ExportPath).FullName);

                    string fullExportPath = $"{ExportPath}_{i}.{formatExtension}";
                    Image.GetMipMap((uint)i).Save(fullExportPath, GetSystemImageFormatFromImageFormat((ImageFormat)ExportFormatComboBox.Active));
                }

                ++i;
                return(false);
            });
        }
Beispiel #14
0
        void SelectChange(bool setSelect)
        {
            model.Foreach((m, p, i) => {
                bool oldValue = (bool)model.GetValue(i, 0);

                if (oldValue ^ setSelect)
                {
                    model.SetValue(i, 0, setSelect);
                    selectedCount += setSelect ? 1 : -1;
                }

                return(false);
            });

            countLabel.Text = selectedCount.ToString();
        }
Beispiel #15
0
    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);
    }
Beispiel #16
0
        private TreeIter FindInCurrentFolder(Packer.Item item)
        {
            // find iter in list store of current folder
            TreeIter foundIter = TreeIter.Zero;

            folderStore.Foreach((model, path, iter) =>
            {
                Packer.Item foundItem = folderStore.GetValue(iter, 2) as Packer.Item;
                if (foundItem.FullName.CompareTo(item.FullName) == 0)
                {
                    foundIter = iter;
                    return(true);
                }
                return(false);
            });

            return(foundIter);
        }
Beispiel #17
0
        /// <summary>
        /// Saves the selected preferences to disk from the UI elements.
        /// </summary>
        public void SavePreferences()
        {
            GamePathListStore.Foreach(delegate(ITreeModel model, TreePath path, TreeIter iter)
            {
                string GamePath = (string)model.GetValue(iter, 0);
                GamePathStorage.Instance.StorePath(GamePath);

                return(false);
            });

            Config.SetViewportBackgroundColour(ViewportColourButton.Rgba);
            Config.SetDefaultExportDirectory(DefaultExportDirectoryFileChooserButton.Filename);
            Config.SetDefaultModelFormat((ModelFormat)DefaultModelExportFormatComboBox.Active);
            Config.SetDefaultImageFormat((ImageFormat)DefaultImageExportFormatComboBox.Active);
            Config.SetDefaultAudioFormat((AudioFormat)DefaultAudioExportFormatComboBox.Active);
            Config.SetKeepFileDirectoryStructure(KeepDirectoryStructureCheckButton.Active);
            Config.SetAllowSendAnonymousStats(SendStatsCheckButton.Active);
        }
Beispiel #18
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);
        });
    }
        public void LoadTodoItem(Activity task)
        {
            if (task == null)
            {
                return;
            }

            _categories.Foreach(delegate(ITreeModel model, TreePath path, TreeIter iter)
            {
                var category = (Category)model.GetValue(iter, 0);
                if (category.Id == task.Category)
                {
                    _categoryBox.SetActiveIter(iter);
                }
                return(false);
            });

            _nameEntry.Text       = task.Name;
            _descView.Buffer.Text = task.Description;
            _startEntry.Text      = task.StartDate.ToString(CultureInfo.CurrentCulture);
            _endEntry.Text        = task.DueDate.ToString(CultureInfo.CurrentCulture);
        }
        public virtual void RefreshConstraints()
        {
            ColumnSchema sc;

            storeColumns.Foreach(delegate(TreeModel model, TreePath path, TreeIter iter) {
                ColumnSchema col = (ColumnSchema)model.GetValue(iter, colObjIndex);
                model.SetValue(iter, colPKIndex, false);
                foreach (ConstraintSchema cons in constraints)
                {
                    if (cons is PrimaryKeyConstraintSchema)
                    {
                        foreach (ColumnSchema colConstraint in cons.Columns)
                        {
                            if (colConstraint.Name == col.Name)
                            {
                                model.SetValue(iter, colPKIndex, true);
                            }
                        }
                    }
                }
                return(false);
            });
        }
        public void LoadPlugin(ProxyFrame proxy)
        {
            if (proxy == null)
            {
                return;
            }

            var od = new Gtk.FileChooserDialog(null, "Load Plugin", null, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);

            foreach (var filter in GetFileFilters())
            {
                od.AddFilter(filter);
            }

            if (od.Run() == (int)ResponseType.Accept)
            {
                PluginInfo plugin = new PluginInfo();
                plugin.Path = od.Filename;
                bool found = false;
                Store.Foreach((model, path, iter) =>
                {
                    var item = model.GetValue(iter, 0) as PluginInfo;
                    if (null != item && item.Path == plugin.Path)
                    {
                        return(found = true);
                    }

                    return(false);
                });

                if (!found && LoadAssembly(plugin, proxy))
                {
                    Store.AppendValues(plugin);
                }
            }
            od.Destroy();
        }
Beispiel #22
0
        //D:\Work\test\MoscrifSDK-Windows\framework
        void btnFavoriteClick(object sender, EventArgs e)
        {
            string txt = cbeNavigation.ActiveText;

            if (!CheckFavorites(txt))
            {
                //IList<RecentFile> lRecentProjects;
                switch (this.navigationType)
                {
                case NavigationType.favorites:
                    MainClass.Settings.RecentFiles.AddFavorite(txt, txt);
                    break;

                case NavigationType.libs:
                    MainClass.Settings.FavoriteFiles.AddLibsFavorite(txt, txt);
                    break;

                case NavigationType.publish:
                    MainClass.Settings.FavoriteFiles.AddPublishFavorite(txt, txt);
                    break;

                case NavigationType.emulator:
                    MainClass.Settings.FavoriteFiles.AddEmulatorFavorite(txt, txt);
                    break;
                }
                //this.recentFiles.AddFavorite(txt,txt);

                //MainClass.Settings.RecentFiles.AddFavorite(txt,txt);
                btnFavorite.Image = new Gtk.Image(pixbufYes);
                navigationStore.AppendValues(txt);
            }
            else
            {
                //this.recentFiles.NotifyFileRemoved(txt);
                switch (this.navigationType)
                {
                case NavigationType.favorites:
                    MainClass.Settings.RecentFiles.NotifyFileRemoved(txt);
                    break;

                case NavigationType.libs:
                    MainClass.Settings.FavoriteFiles.NotifyFileRemoved(txt);
                    break;

                case NavigationType.publish:
                    MainClass.Settings.FavoriteFiles.NotifyFileRemoved(txt);
                    break;

                case NavigationType.emulator:
                    MainClass.Settings.FavoriteFiles.NotifyFileRemoved(txt);
                    break;
                }

                btnFavorite.Image = new Gtk.Image(pixbufNo);

                //bool isFind = false;
                TreeIter ti = new TreeIter();
                navigationStore.Foreach((model, path, iterr) => {
                    string pathProject = navigationStore.GetValue(iterr, 0).ToString();

                    if (pathProject.ToUpper() == txt.ToUpper())
                    {
                        ti = iterr;
                        //isFind = true;
                        return(true);
                    }
                    return(false);
                });

                navigationStore.Remove(ref ti);
            }
        }
Beispiel #23
0
        public IGameInfo GetGameInfo()
        {
            IGameInfo gameInfo = null;

            switch (comboBoxGame.Active)
            {
            case 1:
                var pixelInfo = new PixelGameInfo()
                {
                    MaxSize      = spinButtonPixelMaxSize.ValueAsInt,
                    InitialState = comboBoxPixelInitialState.ActiveText,
                    PlayerSort   = comboBoxPixelPlayerSort.ActiveText
                };

                foreach (var point in pixelGrid.EnabledPixels)
                {
                    if ((point.X < pixelInfo.MaxSize) &&
                        (point.Y < pixelInfo.MaxSize))
                    {
                        pixelInfo.FixedPixels.Add(point);
                    }
                }

                gameInfo = pixelInfo;
                break;

            case 2:
                var flatlandInfo = new FlatlandGameInfo()
                {
                    Tiles = checkBoxFlatlandCustomBoardSize.Active ?
                            spinButtonFlatlandBoardSize.ValueAsInt : (int?)null,

                    CollisionBehavior = comboBoxFlatlandCollisionBehavior.ActiveText,
                    GameType          = comboBoxFlatlandGameType.ActiveText
                };

                // Add teams
                flatlandTeamStore.Foreach(delegate(TreeModel model, TreePath path, TreeIter iter)
                {
                    flatlandInfo.Teams.Add(new FlatlandTeamInfo()
                    {
                        TeamIndex       = (int)model.GetValue(iter, 0),
                        ThemeName       = (string)model.GetValue(iter, 1),
                        Kind            = (string)model.GetValue(iter, 2),
                        MoveSeconds     = (int)model.GetValue(iter, 3),
                        WrappedMovement = (bool)model.GetValue(iter, 4),
                        ScoringSystem   = (string)model.GetValue(iter, 5)
                    });

                    return(false);
                });

                flatlandInfo.FixedTiles.AddRange(flatlandFixedTiles);

                gameInfo = flatlandInfo;
                break;

            case 3:
                gameInfo = new GroupSumGameInfo()
                {
                    FirstRoundSeconds     = spinButtonGroupSumFirstRoundSeconds.ValueAsInt,
                    RoundSeconds          = spinButtonGroupSumRoundSeconds.ValueAsInt,
                    RangeStart            = spinButtonGroupSumRangeStart.ValueAsInt,
                    RangeEnd              = spinButtonGroupSumRangeEnd.ValueAsInt,
                    ShowNumericFeedback   = checkButtonGroupSumNumericFeedback.Active,
                    UsePreviousRoundInput = checkbuttonGroupSumPreviousInput.Active
                };
                break;

            case 4:
                var foragerInfo = new ForagerGameInfo()
                {
                    Plots       = spinButtonForagerPlots.ValueAsInt,
                    TravelTime  = spinButtonForagerTravelTime.ValueAsInt,
                    FoodRate    = spinButtonForagerFoodRate.ValueAsInt,
                    GameSeconds = spinButtonForagerGameMinutes.ValueAsInt * 60,
                };

                foreach (var plotProbabilities in foragerProbabilities)
                {
                    foragerInfo.PlotProbabilities.Add(plotProbabilities.ToList());
                }

                foragerInfo.ProbabilityShiftTimes.AddRange(foragerProbabilityShiftTimes.ToList());

                gameInfo = foragerInfo;
                break;
            }

            if (gameInfo != null)
            {
                gameInfo.GameDescription = entryGameDescription.Text;
            }

            return(gameInfo);
        }
Beispiel #24
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);
            }
        }
Beispiel #25
0
 void RemovePanels()
 {
     prefsStore.Foreach((model, path, iter) => prefsStore.Remove(ref iter));
 }