Beispiel #1
0
        public void Reset()
        {
            _updating = true;
            //if (!chkFlat.Checked)
            {
                boneTree.BeginUpdate();
                boneTree.Nodes.Clear();

                PopulateBoneTree();

                boneTree.EndUpdate();
            }
            //else
            {
                lstBones.BeginUpdate();
                lstBones.Items.Clear();

                if (TargetModel != null)
                {
                    foreach (IBoneNode bone in TargetModel.BoneCache)
                    {
                        lstBones.Items.Add(bone, bone.IsRendering);
                    }
                }

                lstBones.EndUpdate();
            }
            _updating = false;
        }
        public void Attach(MDL0Node model)
        {
            lstPolygons.BeginUpdate();
            lstPolygons.Items.Clear();
            lstBones.BeginUpdate();
            lstBones.Items.Clear();
            lstTextures.BeginUpdate();
            lstTextures.Items.Clear();

            _selectedBone    = null;
            _selectedPolygon = null;
            _targetObject    = null;

            chkAllPoly.CheckState     = CheckState.Checked;
            chkAllBones.CheckState    = CheckState.Checked;
            chkAllTextures.CheckState = CheckState.Checked;

            if (model != null)
            {
                ResourceNode n;

                if ((n = model.FindChild("Polygons", false)) != null)
                {
                    foreach (MDL0PolygonNode poly in n.Children)
                    {
                        lstPolygons.Items.Add(poly, poly._render);
                    }
                }

                if ((n = model.FindChild("Bones", false)) != null)
                {
                    foreach (MDL0BoneNode bone in n.Children)
                    {
                        WrapBone(bone);
                    }
                }

                if ((n = model.FindChild("Textures", false)) != null)
                {
                    foreach (MDL0TextureNode tref in n.Children)
                    {
                        lstTextures.Items.Add(tref, tref.Enabled);
                    }
                }
            }

            lstTextures.EndUpdate();
            lstPolygons.EndUpdate();
            lstBones.EndUpdate();
        }
Beispiel #3
0
        internal void Reset()
        {
            lstBones.BeginUpdate();
            lstBones.Items.Clear();

            if (TargetModel != null)
            {
                foreach (MDL0BoneNode bone in TargetModel._linker.BoneCache)
                {
                    lstBones.Items.Add(bone, bone._render);
                }
            }

            lstBones.EndUpdate();
        }
        void CategoryListViewItemChanged(object sender, EventArgs e)
        {
            CodeGeneratorBase codeGenerator = SelectedCodeGenerator;

            if (codeGenerator == null)
            {
                return;
            }

            statusLabel.Text = StringParser.Parse(codeGenerator.Hint);
            selectionListBox.BeginUpdate();
            selectionListBox.Items.Clear();
            if (codeGenerator.Content.Count > 0)
            {
                Hashtable objs = new Hashtable();
//				selectionListBox.Sorted = codeGenerator.Content.Count > 1;
                foreach (object o in codeGenerator.Content)
                {
                    if (!objs.Contains(o.ToString()))
                    {
                        selectionListBox.Items.Add(o);
                        objs.Add(o.ToString(), "");
                    }
                }
                selectionListBox.SelectedIndex = 0;
            }
            selectionListBox.EndUpdate();
            selectionListBox.Refresh();
        }
Beispiel #5
0
        private void UpdatePackets()
        {
            clbPackets.BeginUpdate();
            clbPackets.Items.Clear();

            for (int i = 0; i < m_PacketItems.Length; i++)
            {
                PacketItem pi = m_PacketItems[i];

                if (ShowAll || pi.PacketType != null)
                {
                    CheckState state = GetCheckState(pi);
                    clbPackets.Items.Add(pi, state);
                }
            }

            for (int i = 0; i < m_CommandPacketItems.Length; i++)
            {
                PacketItem pi = m_CommandPacketItems[i];

                if (ShowAll || pi.PacketType != null)
                {
                    CheckState state = GetCheckState(pi);
                    clbPackets.Items.Add(pi, state);
                }
            }

            clbPackets.EndUpdate();
        }
        /// <summary>
        /// Initializes the check list from an enumerated type.
        /// </summary>
        /// <param name="enumType">The enumerated type.</param>
        /// <param name="mgr">The <see cref="System.Resources.ResourceManager"/> that holds the display text for each enumerated value.</param>
        /// <param name="prefix">(Optional) The prefix used in front of the enumeration value to pull from the resource file. If <c>null</c>, then this value defaults to the name of the enumerated type specified by <paramref name="enumType"/>.</param>
        /// <param name="exclude">(Optional) The excluded items from the enumerated type.</param>
        public void InitializeFromEnum(Type enumType, System.Resources.ResourceManager mgr, string prefix = null, string[] exclude = null)
        {
            if (!enumType.IsEnum)
            {
                throw new ArgumentException("Specified type is not an enumeration.", nameof(enumType));
            }
            if (mgr == null)
            {
                throw new ArgumentNullException(nameof(mgr), "A valid ResourceManager instance must be provided.");
            }
            long allVal;

            checkedListBox1.BeginUpdate();
            ComboBoxExtension.InitializeFromEnum(checkedListBox1.Items, enumType, mgr, prefix, out allVal, exclude);
            if (!string.IsNullOrEmpty(CheckAllText))
            {
                checkedListBox1.Items.Insert(0, new DropDownCheckListItem(CheckAllText, allVal));
            }
            checkedListBox1.EndUpdate();
        }
Beispiel #7
0
        public static void Draw( CheckedListBox list )
        {
            list.BeginUpdate();
            list.Items.Clear();

            for (int i=0;i<m_Filters.Count;i++)
            {
                Filter f = (Filter)m_Filters[i];
                list.Items.Add( f );
                list.SetItemChecked( i, f.Enabled );
            }
            list.EndUpdate();
        }
Beispiel #8
0
    /// <summary>
    /// Overrides the method used to provide basic behaviour for selecting editor.
    /// Shows our custom control for editing the value.
    /// </summary>
    /// <param name="context">The context of the editing control</param>
    /// <param name="provider">A valid service provider</param>
    /// <param name="value">The current value of the object to edit</param>
    /// <returns>The new value of the object</returns>
    public override object EditValue( ITypeDescriptorContext context, IServiceProvider provider, object value) 
    {
      if( context != null && context.Instance != null && provider != null ) 
      {
        edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

        if( edSvc != null ) 
        {         
          // Create a CheckedListBox and populate it with all the enum values
          clb = new CheckedListBox();
          clb.BorderStyle = BorderStyle.FixedSingle;
          clb.CheckOnClick = true;
          clb.MouseDown += new MouseEventHandler(this.OnMouseDown);
          clb.MouseMove += new MouseEventHandler(this.OnMouseMoved);
          clb.DoubleClick += new EventHandler( this.OnDoubleClick );

          tooltipControl = new ToolTip();
          tooltipControl.ShowAlways = true;

          clb.BeginUpdate();

          foreach( string name in Enum.GetNames( context.PropertyDescriptor.PropertyType ) )
          {
            // Get the enum value
            object enumVal = Enum.Parse(context.PropertyDescriptor.PropertyType, name);
            // Get the int value 
            int intVal = (int) Convert.ChangeType(enumVal, typeof(int));
            
            // Get the description attribute for this field
            System.Reflection.FieldInfo fi = context.PropertyDescriptor.PropertyType.GetField(name);
            DescriptionAttribute[] attrs = ( DescriptionAttribute[] ) 
              fi.GetCustomAttributes( typeof( DescriptionAttribute ), false );
            
            BrowsableAttribute[] skipAttr = ( BrowsableAttribute[] )
              fi.GetCustomAttributes( typeof( BrowsableAttribute ), false );

            // if flag must be skip in desiner
            if( skipAttr.Length > 0 && skipAttr[0].Browsable == false ) continue;

            // Store the the description
            string tooltip = ( attrs.Length > 0 ) ? attrs[0].Description : string.Empty;

            // Get the int value of the current enum value (the one being edited)
            int intEdited = ( int )Convert.ChangeType( value, typeof( int ) );

            // show in tooltip int value of flag
            tooltip += "(value: " + intEdited.ToString() + ")";

            // Creates a clbItem that stores the name, the int value and the tooltip
            clbItem item = new clbItem(enumVal.ToString(), intVal, tooltip);

            // Get the checkstate from the value being edited
            bool checkedItem = (intEdited & intVal) > 0;

            // Add the item with the right check state
            clb.Items.Add( item, checkedItem );
          }         
          
          clb.EndUpdate();

          // Show our CheckedListbox as a DropDownControl. 
          // This methods returns only when the dropdowncontrol is closed
          edSvc.DropDownControl( clb );

          // Get the sum of all checked flags
          int result = 0;
          
          foreach( clbItem obj in clb.CheckedItems )
          {
            result += obj.Value;
          }

          // return the right enum value corresponding to the result
          return Enum.ToObject(context.PropertyDescriptor.PropertyType, result);
        }
      }

      return value;
    }
Beispiel #9
0
 private void UpdateCheckedList(CheckedListBox list)
 {
     object wasSelected = list.SelectedItem;
      list.BeginUpdate();
      for (int i = 0; i < list.Items.Count; i++)
     list.SetItemChecked(i, ((Item)list.Items[i]).IsVisible);
      list.SelectedItem = wasSelected;
      list.EndUpdate();
 }
    void InitializeCheckedListBox(CheckedListBox box, CheckableSelectableListNodeList list)
    {
      box.BeginUpdate();
      box.Items.Clear();
      for(int i=0;i<list.Count;i++)
      {
        CheckableSelectableListNode node=list[i];
      
        box.Items.Add(node, node.Checked);
        if (node.Selected)
          box.SelectedIndices.Add(i);
      }

      box.EndUpdate();
    }
Beispiel #11
0
        public void Attach(MDL0Node model)
        {
            lstPolygons.BeginUpdate();
            lstPolygons.Items.Clear();
            lstBones.BeginUpdate();
            lstBones.Items.Clear();
            lstTextures.BeginUpdate();
            lstTextures.Items.Clear();

            _selectedBone    = null;
            _selectedPolygon = null;
            _targetObject    = null;

            chkAllPoly.CheckState     = CheckState.Checked;
            chkAllBones.CheckState    = CheckState.Checked;
            chkAllTextures.CheckState = CheckState.Checked;

            if (model != null)
            {
                ResourceNode n;

                if ((n = model.FindChild("Objects", false)) != null)
                {
                    foreach (MDL0PolygonNode poly in n.Children)
                    {
                        lstPolygons.Items.Add(poly, poly._render);
                    }
                }

                if ((n = model.FindChild("Bones", false)) != null)
                {
                    foreach (MDL0BoneNode bone in n.Children)
                    {
                        WrapBone(bone);
                    }
                }

                if ((n = model.FindChild("Textures", false)) != null)
                {
                    foreach (MDL0TextureNode tref in n.Children)
                    {
                        lstTextures.Items.Add(tref, tref.Enabled);
                    }
                }
            }

            lstTextures.EndUpdate();
            lstPolygons.EndUpdate();
            lstBones.EndUpdate();

            VIS0Indices.Clear(); int i = 0;
            foreach (MDL0PolygonNode p in lstPolygons.Items)
            {
                if (p._bone != null && p._bone.BoneIndex != 0)
                {
                    if (VIS0Indices.ContainsKey(p._bone.Name))
                    {
                        if (!VIS0Indices[p._bone.Name].Contains(i))
                        {
                            VIS0Indices[p._bone.Name].Add(i);
                        }
                    }
                    else
                    {
                        VIS0Indices.Add(p._bone.Name, new List <int> {
                            i
                        });
                    }
                }
                i++;
            }
        }
Beispiel #12
0
        // <summary
        // ResetCategories - get categories from an ana file and display them.
        // </summary>
        private void ResetCategories()
        {
            chBxCategories.BeginUpdate();
            StreamReader reader = null;

            try
            {
                reader = new StreamReader(tbANAFile.Text);
                StringCollection analysisLines = new StringCollection();
                StringCollection categoryLines = new StringCollection();
                StringCollection categories    = new StringCollection();
                string           line          = reader.ReadLine();

                while (line != null)
                {
                    // If the line contains %0%, then skip it, as it is a failure
                    // and has no useful information in it.
                    bool failure = (line.IndexOf(String.Format("{0}0{1}", AmbiguityMarker, AmbiguityMarker)) > -1);
                    if (line.StartsWith(@"\a") &&
                        !analysisLines.Contains(line) &&
                        !failure)
                    {
                        analysisLines.Add(line);                         // Save unique \a lines.
                    }
                    else if (line.StartsWith(@"\cat") &&
                             !categoryLines.Contains(line) &&
                             !failure)
                    {
                        categoryLines.Add(line);                         // Save unique \cat lines.
                    }
                    line = reader.ReadLine();
                }
                reader.Close();
                reader = null;

                // Process \a lines.
                foreach (string aLine in analysisLines)
                {
                    // \a POS1 < N palabra >
                    // \a %2%IMP CAUS < VA pegar1 >%C CAUS < VA pegar1 >%
                    string[] tokens = aLine.Split(OpenDelimiter[0]);
                    for (int i = 1; i < tokens.Length; ++i)
                    {
                        string str = tokens[i];
                        // Find end of roots.
                        str = str.Substring(0, str.IndexOf(CloseDelimiter[0])).Trim();
                        // It can have compound roots, so get category from each root.
                        string[] roots = str.Split();
                        for (int j = 0; j < roots.Length; j = ++j + 1)
                        {
                            string category = roots[j];
                            if (!categories.Contains(category))
                            {
                                categories.Add(category);
                            }
                        }
                    }
                }

                // Process \cat lines.
                foreach (string catLine in categoryLines)
                {
                    // \cat PN -- final category only
                    // \cat %2%V%V% -- final category only
                    // \cat %5%N N%PRT PRT%N N%PRT PRT%N N% -- final category+each morpheme category
                    // \cat %5%N N%ADJ ADJ%N N%V VA/V=VA%V VA/V=VA% -- final category+each morpheme category
                    // \cat V VA/V=VA=V/V -- final category+each morpheme category
                    string[] catsMain = catLine.Substring(5).Split(AmbiguityMarker[0]);
                    for (int i = (catsMain.Length == 1) ? 0 : 2;                     // Start with 0, if it wasn't ambiguous. otherwise start at 2.
                         i < catsMain.Length;
                         ++i)
                    {
                        string[] catsInner = catsMain[i].Split();
                        for (int j = 0; j < catsInner.Length; ++j)
                        {
                            if ((j % 2) == 0)
                            {
                                // Final word-level category
                                string cat = catsInner[j];
                                if (!categories.Contains(cat))
                                {
                                    categories.Add(cat);
                                }
                            }
                            else
                            {
                                // We want the root categories, but not affix categories.
                                string[] catsInnermost = catsInner[j].Split('=');
                                foreach (string cat in catsInnermost)
                                {
                                    if (cat.IndexOf("/") == -1 && !categories.Contains(cat))
                                    {
                                        categories.Add(cat);
                                    }
                                }
                            }
                        }
                    }
                }

                // Add them to the control,and check them all.
                // TODO: Add a control to select/unselect all.
                foreach (string cat in categories)
                {
                    if (cat != string.Empty)
                    {
                        int idx = chBxCategories.Items.Add(cat);
                        chBxCategories.SetItemChecked(idx, true);
                    }
                }
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                reader = null;
                chBxCategories.EndUpdate();
            }
        }
Beispiel #13
0
 private void FillOutDatabaseObjectNames(string cmdName, CheckedListBox clb, DatabaseObjectType objectType)
 {
     string objectName;
     string strCmd = ConfigurationManager.AppSettings[cmdName];
     Database db = DatabaseFactory.CreateDatabase();
     Action beginUpdate = () => clb.BeginUpdate();
     clb.Invoke(beginUpdate);
     using (IDataReader reader = db.ExecuteReader(CommandType.Text, strCmd))
     {
         Action addItem;
         while (reader.Read())
         {
             objectName = reader.GetString(0);
             addItem = () => clb.Items.Add(new ListItem() { Value = objectName, Type = objectType });
             clb.Invoke(addItem);
         }
     }
     Action endUpdate = () => clb.EndUpdate();
     clb.Invoke(endUpdate);
 }
Beispiel #14
0
 private void SetAllDatabaseObjectSelected(CheckedListBox dbObjectList, CheckBox chkAll)
 {
     dbObjectList.BeginUpdate();
     for (int i = 0; i < dbObjectList.Items.Count; i++)
     {
         dbObjectList.SetItemChecked(i, chkAll.Checked);
     }
     dbObjectList.EndUpdate();
 }
Beispiel #15
0
 public override void ShowPane()
 {
     _profilesList.BeginUpdate();
     try
     {
         IEnumerable firefoxProfiles   = MozillaProfiles.GetFirefoxProfiles();
         IEnumerable firefox09Profiles = MozillaProfiles.GetFirefox09Profiles();
         IEnumerable mozillaProfiles   = MozillaProfiles.GetMozillaProfiles();
         string[]    activeProfiles    = new string[0];
         if (!IsStartupPane)
         {
             _savedProfiles = Core.SettingStore.ReadString("Favorites", "MozillaProfile");
             activeProfiles = _savedProfiles.ToLower().Split(';');
         }
         else
         {
             string activeProfile = null;
             foreach (MozillaProfile profile in firefoxProfiles)
             {
                 string name = profile.Name;
                 if (name.IndexOf("default") >= 0)
                 {
                     activeProfile = name;
                     break;
                 }
             }
             if (activeProfile == null)
             {
                 foreach (MozillaProfile profile in firefox09Profiles)
                 {
                     string name = profile.Name;
                     if (name.IndexOf("default") >= 0)
                     {
                         activeProfile = name;
                         break;
                     }
                 }
                 if (activeProfile == null)
                 {
                     foreach (MozillaProfile profile in firefoxProfiles)
                     {
                         activeProfile = profile.Name;
                         break;
                     }
                     if (activeProfile == null)
                     {
                         foreach (MozillaProfile profile in firefox09Profiles)
                         {
                             activeProfile = profile.Name;
                             break;
                         }
                         if (activeProfile == null)
                         {
                             foreach (MozillaProfile profile in mozillaProfiles)
                             {
                                 string name = profile.Name;
                                 if (name.IndexOf("default") >= 0)
                                 {
                                     activeProfile = name;
                                     break;
                                 }
                             }
                             if (activeProfile == null)
                             {
                                 foreach (MozillaProfile profile in mozillaProfiles)
                                 {
                                     activeProfile = profile.Name;
                                     break;
                                 }
                             }
                         }
                     }
                 }
             }
             if (activeProfile != null)
             {
                 activeProfiles = new string[] { activeProfile.ToLower() };
             }
         }
         UpdateProfileList(activeProfiles, firefoxProfiles);
         UpdateProfileList(activeProfiles, firefox09Profiles);
         UpdateProfileList(activeProfiles, mozillaProfiles);
         UpdateProfileList(activeProfiles, MozillaProfiles.GetAbsoluteFirefoxProfiles());
     }
     finally
     {
         _profilesList.EndUpdate();
     }
 }