Esempio n. 1
0
        /// <summary>
        /// Show the Selection Form
        /// </summary>
        /// <param name="map">The subset map</param>
        /// <param name="package">the opened source package</param>
        /// <param name="subsets">List of all Subsets you want to present</param>
        /// <returns>the map with all the selected Items</returns>
        public static Hashtable Execute(Hashtable map, ArrayList subsets)
        {
            SubsetSelectForm ssf = Prepare(map, subsets);

            ssf.ShowDialog();
            return(Finish(ssf));
        }
Esempio n. 2
0
        /// <summary>
        /// Add a new Selection for a Subset
        /// </summary>
        /// <param name="ssf">The for you want to add the Selection to</param>
        /// <param name="subset">The name of the Subset</param>
        /// <param name="top">the top coordinate for the Selection Panel</param>
        /// <returns>the ListView you can use to add Items to</returns>
        protected ListView AddSelection(SubsetSelectForm ssf, string subset, ref int top)
        {
            Panel pn = new Panel();

            pn.Parent  = ssf.pnselect;
            pn.Top     = top;
            pn.Left    = 8;
            pn.Width   = ssf.pnselect.Width - 16;
            pn.Height  = ImageSize.Height + 64;
            pn.Visible = false;
            pn.Anchor  = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;

            CheckBox cb = new CheckBox();

            cb.Parent          = pn;
            cb.Top             = 0;
            cb.Left            = 0;
            cb.Checked         = true;
            cb.Width           = pn.Width;
            cb.Text            = subset;
            cb.Anchor          = pn.Anchor;
            cb.FlatStyle       = FlatStyle.System;
            cb.CheckedChanged += new EventHandler(CheckedChanged);

            ListView lv = new ListView();

            lv.Parent                = pn;
            lv.Tag                   = subset;
            lv.Left                  = 8;
            lv.Top                   = cb.Height + cb.Top;
            lv.Width                 = pn.Width - lv.Left;
            lv.Height                = pn.Height - lv.Top;
            lv.Anchor                = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom;
            lv.HideSelection         = false;
            lv.MultiSelect           = false;
            lv.SelectedIndexChanged += new EventHandler(SelectedIndexChanged);
            cb.Tag                   = lv;

            ImageList il = new ImageList();

            il.ImageSize      = ImageSize;
            il.ColorDepth     = ColorDepth.Depth32Bit;
            lv.LargeImageList = il;

            top       += pn.Height + 8;
            pn.Visible = true;

            listviews.Add(lv);
            return(lv);
        }
Esempio n. 3
0
        /// <summary>
        /// Create a new Color Options package
        /// </summary>
        /// <param name="newpkg">The Package the color Option should be added to</param>
        /// <param name="ask">if ask is true, a Dialog will be displayed that lets the
        /// user decide which Subsets to recolor</param>
        public void Create(IPackageFile newpkg)
        {
            WaitingScreen.Wait();
            try
            {
                //this.newpkg = newpkg;

                WaitingScreen.UpdateMessage("Loading available Color Options");
                Hashtable fullmap        = Scenegraph.GetMMATMap(package);
                Hashtable map            = fullmap;
                ArrayList allowedSubsets = Scenegraph.GetRecolorableSubsets(package);

                //Check if the User can select a Subset
                bool userselect = false;
                if (map.Count > 1)
                {
                    userselect = true;
                }
                else
                {
                    if (map.Count == 1)
                    {
                        foreach (string s in map.Keys)
                        {
                            Hashtable ht = (Hashtable)map[s];
                            if (ht.Count > 1)
                            {
                                userselect = true;
                            }
                        }
                    }
                }

                //let the user Select now
                if (userselect)
                {
                    map = SubsetSelectForm.Execute(map, allowedSubsets);
                }



                ProcessMmatMap(newpkg, map, fullmap);
            }
            finally
            {
                WaitingScreen.Stop();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Setup the Form
        /// </summary>
        /// <param name="map">The subset map</param>
        /// <param name="subsets">the subsets you want to present</param>
        /// <returns>Returns a New Instance of the selection Form</returns>
        public static SubsetSelectForm Prepare(Hashtable map, ArrayList subsets)
        {
            SubsetSelectForm ssf = new SubsetSelectForm();

            ssf.listviews = new ArrayList();
            ssf.txmtnames = new Hashtable();
            WaitingScreen.Wait();
            try
            {
                WaitingScreen.UpdateMessage("Show Subset Selection");
                ssf.button1.Enabled = false;

                int top = 0;
                foreach (string subset in map.Keys)
                {
                    if (!subsets.Contains(subset))
                    {
                        continue;
                    }

                    ListView  lv       = ssf.AddSelection(ssf, subset, ref top);
                    Hashtable families = (Hashtable)map[subset];
                    foreach (string family in families.Keys)
                    {
                        ArrayList mmats = (ArrayList)families[family];
                        mmats.Sort(new MmatListCompare());
                        ssf.AddItem(lv, mmats);
                    }

                    if (lv.Items.Count > 0)
                    {
                        lv.Items[0].Selected = true;
                    }
                }
            }
            finally
            {
                WaitingScreen.Stop();
            }

            return(ssf);
        }
Esempio n. 5
0
        /// <summary>
        /// Builds a new Hashtable based on the Users Selection
        /// </summary>
        /// <param name="ssf">The Form that was used</param>
        /// <returns>The new Hashtable</returns>
        public static Hashtable Finish(SubsetSelectForm ssf)
        {
            //now rebuild the Hashtable with the stored Infos
            Hashtable ret = new Hashtable();

            foreach (ListView lv in ssf.listviews)
            {
                if (!lv.Enabled)
                {
                    continue;
                }

                if (lv.SelectedItems.Count > 0)
                {
                    Hashtable sub = new Hashtable();
                    sub["user-selection"] = lv.SelectedItems[0].Tag;
                    ret[(string)lv.Tag]   = sub;
                }
            }

            return(ret);
        }
Esempio n. 6
0
        /// <summary>
        /// Create a new Color Options package
        /// </summary>
        /// <param name="newpkg">The Package the color Option should be added to</param>
        /// <param name="fkt">The function that ahs to be called wne the Selection should be displayed</param>
        public void Create(IPackageFile newpkg, CreateSelectionCallback fkt)
        {
            WaitingScreen.Wait();
            try
            {
                //this.newpkg = newpkg;

                WaitingScreen.UpdateMessage("Loading available Color Options");
                Hashtable fullmap        = Scenegraph.GetMMATMap(package);
                Hashtable map            = fullmap;
                ArrayList allowedSubsets = Scenegraph.GetRecolorableSubsets(package);

                //Check if the User can select a Subset
                bool userselect = false;
                if (map.Count > 1)
                {
                    userselect = true;
                }
                else
                {
                    if (map.Count == 1)
                    {
                        foreach (string s in map.Keys)
                        {
                            Hashtable ht = (Hashtable)map[s];
                            if (ht.Count > 1)
                            {
                                userselect = true;
                            }
                        }
                    }
                }

                SubsetSelectForm ssf = SubsetSelectForm.Prepare(map, allowedSubsets);
                fkt(ssf, userselect, fullmap);
            }
            finally
            {
                WaitingScreen.Stop();
            }
            return;

            /*string[] subsets = GetSubsets();
             *
             * //let the user Select
             * if ((subsets.Length>1) && (ask))
             * {
             *      Listing l = new Listing();
             *      subsets = l.Execute(subsets);
             * }
             *
             * WaitingScreen.Wait();
             * WaitingScreen.UpdateMessage("Getting slave Subsets");
             * SubsetItem[] subsetsi = GetSlaveSubsets(subsets);
             *
             * WaitingScreen.UpdateMessage("Getting Resource Nodes");
             * ArrayList cres = GetCresNames(subsetsi);
             *
             * WaitingScreen.UpdateMessage("Getting Material Overrides");
             * Hashtable mmats = GetMMATs(subsetsi, cres);
             * ArrayList guids = GetGUIDs();
             *
             * LoadSubSetList(mmats, guids, subsetsi);
             *
             * WaitingScreen.UpdateMessage("Load LIFO Files");
             * GetLifoFiles();
             *
             * WaitingScreen.Stop();*/
        }