Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/23/09 15:37:05 (15 years ago)
Author:
aleitner
Message:

listview changing symbols (large images, small images, list), contextmenu only shown on click on calculating job (#585)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Server.Console/3.2/HiveServerManagementConsole.cs

    r1626 r1628  
    8888    #endregion
    8989
     90    private Guid ConvertStringToGuid(string stringGuid) {
     91      Guid guid = Guid.Empty;
     92      return (Guid)TypeDescriptor.GetConverter(guid).ConvertFrom(stringGuid);
     93    }
     94
     95
    9096    private void Init() {
    9197
     
    94100        IJobManager jobManager = ServiceLocator.GetJobManager();
    95101        if (lvJobControl.SelectedItems.Count == 1) {
    96           Guid jobID = Guid.Empty;
    97           jobID = (Guid)TypeDescriptor.GetConverter(jobID).ConvertFrom(lvJobControl.SelectedItems[0].Text);
    98           jobManager.AbortJob(jobID);
     102          jobManager.AbortJob(ConvertStringToGuid(lvJobControl.SelectedItems[0].Text));
    99103        }
    100104      };
     
    103107        IJobManager jobManager = ServiceLocator.GetJobManager();
    104108        if (lvJobControl.SelectedItems.Count == 1) {
    105           Guid jobID = Guid.Empty;
    106           jobID = (Guid)TypeDescriptor.GetConverter(jobID).ConvertFrom(lvJobControl.SelectedItems[0].Text);
    107           jobManager.RequestSnapshot(jobID);
     109          jobManager.RequestSnapshot(ConvertStringToGuid(lvJobControl.SelectedItems[0].Text));
    108110        }
    109111      };
     
    113115    private void lvJobControl_MouseUp(object sender, MouseEventArgs e) {
    114116      // If the right mouse button was clicked and released,
    115       // display the shortcut menu assigned to the TreeView.
    116       if (e.Button == MouseButtons.Right && lvJobControl.SelectedItems.Count == 1) {
    117         lvJobControl.ContextMenuStrip.Show(new Point(e.X, e.Y));
    118       }
     117      // display the shortcut menu assigned to the ListView.
     118      lvJobControl.ContextMenuStrip.Items.Clear();
     119      ListViewHitTestInfo hitTestInfo = lvJobControl.HitTest(e.Location);
     120      if (e.Button == MouseButtons.Right && hitTestInfo.Item != null && lvJobControl.SelectedItems.Count == 1) {
     121        Guid selectedJobGuid = ConvertStringToGuid(lvJobControl.SelectedItems[0].Text);
     122        Job selectedJob = jobs.List.FirstOrDefault(x => x.Id == selectedJobGuid);
     123
     124        if (selectedJob != null && selectedJob.State == State.calculating) {
     125        lvJobControl.ContextMenuStrip.Items.Add(menuItemAbortJob);
     126        lvJobControl.ContextMenuStrip.Items.Add(menuItemGetSnapshot);
     127        }
     128      }
     129       lvJobControl.ContextMenuStrip.Show(new Point(e.X, e.Y));
    119130    }
    120131
     
    287298        }
    288299      }
    289       pbClientControl.Image = ilClientControl.Images[usage];
     300      pbClientControl.Image = ilLargeImgJob.Images[usage];
    290301      lblClientName.Text = currentClient.Name;
    291302      lblLogin.Text = currentClient.Login.ToString();
     
    305316      lvSnapshots.Enabled = true;
    306317      currentJob = jobs.List[i];
    307       pbJobControl.Image = ilJobControl.Images[0];
     318      pbJobControl.Image = ilLargeImgClient.Images[0];
    308319      lblJobName.Text = currentJob.Id.ToString();
    309320      progressJob.Value = (int)(currentJob.Percentage * 100);
     
    334345      if (currentJob.State != State.offline) {
    335346        lvSnapshots.Items.Clear();
    336         if (currentJob.State == State.finished) 
     347        if (currentJob.State == State.finished)
    337348          GetSnapshotList();
    338349        lvSnapshots.Visible = true;
     
    722733    #endregion
    723734
     735    private void largeIconsToolStripMenuItem_Click(object sender, EventArgs e) {
     736      lvClientControl.View = View.LargeIcon;
     737      lvJobControl.View = View.LargeIcon;
     738      largeIconsToolStripMenuItem.CheckState = CheckState.Checked;
     739      smallIconsToolStripMenuItem.CheckState = CheckState.Unchecked;
     740      listToolStripMenuItem.CheckState = CheckState.Unchecked;
     741    }
     742
     743    private void smallIconsToolStripMenuItem_Click(object sender, EventArgs e) {
     744      lvClientControl.View = View.SmallIcon;
     745      lvJobControl.View = View.SmallIcon;
     746      largeIconsToolStripMenuItem.CheckState = CheckState.Unchecked;
     747      smallIconsToolStripMenuItem.CheckState = CheckState.Checked;
     748      listToolStripMenuItem.CheckState = CheckState.Unchecked;
     749    }
     750
     751    private void listToolStripMenuItem_Click(object sender, EventArgs e) {
     752      lvClientControl.View = View.List;
     753      lvJobControl.View = View.List;
     754      largeIconsToolStripMenuItem.CheckState = CheckState.Unchecked;
     755      smallIconsToolStripMenuItem.CheckState = CheckState.Unchecked;
     756      listToolStripMenuItem.CheckState = CheckState.Checked;
     757    }
     758
    724759
    725760
Note: See TracChangeset for help on using the changeset viewer.