Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Help with UserControl State Save and Restore

Help with UserControl State Save and Restore

Scheduled Pinned Locked Moved C#
helpquestiondata-structuresperformance
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TheBlindWatchmaker
    wrote on last edited by
    #1

    Greetings! I'm having a spot of trouble involving the saving and restoring of UserControl states on a form and was wondering if somebody could help me figure it out. Here's some background: 1. I have 11 instances of a UserControl on a form. 2. The UserControl has, among others, two boolean properties "Mute" and "Solo". 3. Everytime the Solo property of a control goes "true", all the OTHER controls are disabled and only the "soloed" control is active. The Mute property of any control other than the soloed control may not be changed while the solo is active. And here's the problem: 1. One or more UserControls may be muted at the time that a particular UserControl is soloed. 2. Upon "unsoloing" the soloed control, the previously muted controls should remain muted. Here's my approach so far and some pseudocode: 1. I have two events - a SoloHandler and a MuteHandler. 2. I'm assuming that the "state memory" code needs to go into the solo handler. 3. Pseudocode if (sender.Solo) { // save the controls that are currently muted; // execute other code that soloes the control - (already implemented) } else { // restore previous state of controls, and mute controls that were muted prior to soloing } AND FINALLY... Here's my question to you! How do you suggest I go about saving the state? Should I use an array and store references to the Controls in the collection using the GetChildIndex property? Is there another way that is more elegant and is easier to code? Thanks!

    M 1 Reply Last reply
    0
    • T TheBlindWatchmaker

      Greetings! I'm having a spot of trouble involving the saving and restoring of UserControl states on a form and was wondering if somebody could help me figure it out. Here's some background: 1. I have 11 instances of a UserControl on a form. 2. The UserControl has, among others, two boolean properties "Mute" and "Solo". 3. Everytime the Solo property of a control goes "true", all the OTHER controls are disabled and only the "soloed" control is active. The Mute property of any control other than the soloed control may not be changed while the solo is active. And here's the problem: 1. One or more UserControls may be muted at the time that a particular UserControl is soloed. 2. Upon "unsoloing" the soloed control, the previously muted controls should remain muted. Here's my approach so far and some pseudocode: 1. I have two events - a SoloHandler and a MuteHandler. 2. I'm assuming that the "state memory" code needs to go into the solo handler. 3. Pseudocode if (sender.Solo) { // save the controls that are currently muted; // execute other code that soloes the control - (already implemented) } else { // restore previous state of controls, and mute controls that were muted prior to soloing } AND FINALLY... Here's my question to you! How do you suggest I go about saving the state? Should I use an array and store references to the Controls in the collection using the GetChildIndex property? Is there another way that is more elegant and is easier to code? Thanks!

      M Offline
      M Offline
      Martin 0
      wrote on last edited by
      #2

      I hope I got everything! Here is what I would do: //Create an additional boolean Property "BlockMute" in your class "YoureUserControlClass" public bool BlockMute { get { return _blockmute; } set { if(value!=_blockmute) { _blockmute = value; } } } public bool Mute { get { return _mute; } set { if(value!=_mute) { if(Blockmute== false) { _mute = value; } } } } //SoloHandler { YoureUserControlClass actc = sender as YoureUserControlClass; foreach(object o in this.Controls) { if(o is YoureUserControlClass) { YoureUserControlClass c = o as YoureUserControlClass; if(actc.Solo == true) { if(o != sender) { c.Enabled = false; c.Solo = false; c.BlockMute =true; } else { c.Enabled = true; c.BlockMute = false; } } else { c.Enabled = false; c.BlockMute = false; } } } } All the best,:) Martin -- modified at 15:59 Wednesday 28th June, 2006

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups