Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6025491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:18:31+00:00 2026-05-23T04:18:31+00:00

So I thought that an enum would help me with States. Basically, I have

  • 0

So I thought that an enum would help me with States. Basically, I have a little Sidebar app which has 3 states:

Minimized – Where you can see a small and colored rectangular Panel indicating the app is open on the desktop.

Preview – Which indicated the app is open, and you can see the logo.

Normal – where the whole sidebar can be seen.

Now, I have setup an enum like this:

public enum CurrentState
{
    Minimized = 0,
    Preview,
    Normal
};

And I am trying to check the CurrentState and switch to another like this when the user clicks the always-visible panel:

    // If Min=Set(Preview). If Preview=Set(Normal). If Normal=Set(Min).
    if (State.HasFlag(CurrentState.Minimized))
    {
        State = CurrentState.Preview;
        this.Location = new Point(
            Screen.PrimaryScreen.WorkingArea.Right - _minimize.Size.Width - _logo.Size.Width,
            this.Location.Y
        );
    }
    else if (State.HasFlag(CurrentState.Preview))
    {
        State = CurrentState.Normal;
        this.Location = new Point(
            Screen.PrimaryScreen.WorkingArea.Right - this.Size.Width,
            this.Location.Y
        );
    }
    else
    {
        State = CurrentState.Minimized;
        this.Location = new Point(
            Screen.PrimaryScreen.WorkingArea.Right - _minimize.Size.Width,
            this.Location.Y
        );
    }

And when the application loads, I set the initial value to:

CurrentState.Minimized;, like this:

CurrentState State = CurrentState.Preview;

So, this is the expected behavior:

If form is Minimized, Move it a bit so it is in Preview mode. If it is in Preview, move it a bit so it is in Normal mode. If it is in Normal mode, set it to Minimized again.

But, upon clicking the always-visible panel the first time, it works as expected. It sets it to Preview mode and moved the form a bit.

But, that’s as far as it goes. Once it’s in Preview mode, it does not go to Normal mode upon clicking the Panel a second time, which means that it’s currently impossible to get it to normal view.

Am I doing something wrong here?

Although this may be uncommon, it is logical, and I can’t figure out where something is going wrong.

Here’s a little visual to help better clarify what I mean:

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:18:32+00:00Added an answer on May 23, 2026 at 4:18 am

    The code as you have it always enters the Minimized branch of the if/else structure.

    The code below that doesn’t use the Flags but instead compares the enums works correctly and progresses through the states as you want:

    if (State == CurrentState.Minimized)    
    {        
        State = CurrentState.Preview;                        
    }    
    else if (State == CurrentState.Preview)    
    {        
        State = CurrentState.Normal;                        
    }    
    else    
    {        
        State = CurrentState.Minimized;                        
    }
    

    One thought though, which would probably make this design a lot easier to work with is to implement the State pattern.

    As the name suggests, this design pattern deals with exactly the situation you are trying to solve.

    Essentially the logic for your three states would get split out into three seperate objects that implement something like IWindowState where IWindow state includes a method called MoveState. When MoveState is called, the state object for a Minimized window knows the next state is Preview, and the Preview object knows to go to Normal.

    For your case this might be design overkill, but as soon as you want any more complex logic like “move from minimized to preview unless the user has a setting to move directly to normal” then the pattern pays for itself in properly managing the complexity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a base class that has an enum value that I am using
I have an applet, which I was writing in Java. Recently, I thought that
I thought that it would be fun to present some classic CS problems and
I thought that to clone a List you would just call: List<int> cloneList =
I thought that compiled queries would perform the same query translation as DataContext. Yet
I thought that by default my Regex would exhibit the greedy behavior that I
I thought that calling BeginInvoke more than once on the same delegate instance would
I thought that this was easier… I have a asp:hyperlink control, with target=_blank ,
Okay, so basically I have an enum: public enum A { A, B, C,
I have an app that requires scrollbars to be enabled in one landscape orientation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.