Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7324


Ignore:
Timestamp:
01/13/12 13:45:51 (13 years ago)
Author:
spimming
Message:

#1680:

  • Methods to add and remove Subscription in CloudManagerClient
  • AddSubscriptionDialog integrated
  • OnContentChanged implemented
Location:
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/CloudManagerClient.cs

    r7317 r7324  
    1616    }
    1717
    18     private CloudManagerClient() { }
     18    private CloudManagerClient() {
     19      subscriptions = new ItemList<Subscription>();
     20      azureProvider = new AzureProvider();
     21    }
    1922
    2023    #region Properties
     
    5962
    6063      try {
    61 
     64        IItemList<Subscription> subs = new ItemList<Subscription>(Subscriptions);
     65        // TODO ...
    6266      }
    6367      catch {
     
    7175    #endregion
    7276
     77    public void Add(Subscription subscription) {
     78      if (subscription == null) {
     79        throw new ArgumentNullException("subscription", "Subscription must not be null.");
     80      }
     81      if (Subscriptions.Contains(subscription)) {
     82        Subscriptions.Remove(subscription);
     83      }
     84      Subscriptions.Add(subscription);
     85    }
     86
     87    public void Remove(Subscription subscription) {
     88      if (subscription == null) {
     89        throw new ArgumentNullException("subscription", "Subscription must not be null.");
     90      }
     91      if (Subscriptions.Contains(subscription)) {
     92        Subscriptions.Remove(subscription);
     93      }
     94    }
     95
     96
     97
    7398
    7499  }
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/HeuristicLab.Clients.Hive.CloudManager-3.3.csproj

    r7299 r7324  
    3838  </PropertyGroup>
    3939  <ItemGroup>
     40    <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
     41    <Reference Include="HeuristicLab.Data.Views-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
     42    <Reference Include="HeuristicLab.Visualization.ChartControlsExtensions-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    4043    <Reference Include="System" />
    4144    <Reference Include="System.Core" />
    4245    <Reference Include="System.Drawing" />
    4346    <Reference Include="System.Windows.Forms" />
     47    <Reference Include="System.Windows.Forms.DataVisualization" />
    4448    <Reference Include="System.Xml.Linq" />
    4549    <Reference Include="System.Data.DataSetExtensions" />
     
    124128      <Name>HeuristicLab.MainForm-3.3</Name>
    125129    </ProjectReference>
     130    <ProjectReference Include="..\..\HeuristicLab.Optimization.Views\3.3\HeuristicLab.Optimization.Views-3.3.csproj">
     131      <Project>{662B4B15-8F4D-4AE5-B3EB-D91C215F5AF2}</Project>
     132      <Name>HeuristicLab.Optimization.Views-3.3</Name>
     133    </ProjectReference>
    126134    <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
    127135      <Project>{14AB8D24-25BC-400C-A846-4627AA945192}</Project>
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/AddSubscriptionDialog.Designer.cs

    r7281 r7324  
    117117      this.btnCancel.Text = "Cancel";
    118118      this.btnCancel.UseVisualStyleBackColor = true;
     119      this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
    119120      //
    120121      // progressBar
     
    134135      this.btnOk.Text = "OK";
    135136      this.btnOk.UseVisualStyleBackColor = true;
     137      this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
    136138      //
    137139      // AddSubscriptionDialog
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/AddSubscriptionDialog.cs

    r7281 r7324  
    2626    private void btnOk_Click(object sender, System.EventArgs e) {
    2727      this.progressBar.Visible = true;
     28      //this.progressBar.Style = ProgressBarStyle.Continuous;
    2829      worker.RunWorkerAsync();
    2930    }
     
    5657      try {
    5758        worker.ReportProgress(25, "Add Subscription");
    58         //Subscription = service.GetSubscriptionInfo(txtSubscriptionId.Text, txtCertThumbprint.Text);
     59        Subscription = CloudManagerClient.Instance.AzureProvider.GetSubscriptionInfo(txtSubscriptionId.Text, txtCertThumbprint.Text);
    5960        Subscription.SaveToConfig = cbSaveSubscription.Checked;
    6061        Subscription.DiscoverServices = cbDiscoverServices.Checked;
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/CloudResourcesView.Designer.cs

    r7317 r7324  
    2424    /// </summary>
    2525    private void InitializeComponent() {
     26      this.components = new System.ComponentModel.Container();
    2627      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CloudResourcesView));
    2728      this.splitContainer1 = new System.Windows.Forms.SplitContainer();
     
    3233      this.btnAddSubscription = new System.Windows.Forms.Button();
    3334      this.treeCloudResources = new System.Windows.Forms.TreeView();
     35      this.imageListCloudResources = new System.Windows.Forms.ImageList(this.components);
    3436      ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
    3537      this.splitContainer1.Panel1.SuspendLayout();
     
    99101      this.btnAddSubscription.TabIndex = 1;
    100102      this.btnAddSubscription.UseVisualStyleBackColor = true;
     103      this.btnAddSubscription.Click += new System.EventHandler(this.btnAddSubscription_Click);
    101104      //
    102105      // treeCloudResources
     
    105108            | System.Windows.Forms.AnchorStyles.Left)
    106109            | System.Windows.Forms.AnchorStyles.Right)));
     110      this.treeCloudResources.ImageIndex = 0;
     111      this.treeCloudResources.ImageList = this.imageListCloudResources;
    107112      this.treeCloudResources.Location = new System.Drawing.Point(3, 34);
    108113      this.treeCloudResources.Name = "treeCloudResources";
     114      this.treeCloudResources.SelectedImageIndex = 0;
    109115      this.treeCloudResources.Size = new System.Drawing.Size(243, 460);
    110116      this.treeCloudResources.TabIndex = 0;
     117      //
     118      // imageListCloudResources
     119      //
     120      this.imageListCloudResources.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
     121      this.imageListCloudResources.ImageSize = new System.Drawing.Size(16, 16);
     122      this.imageListCloudResources.TransparentColor = System.Drawing.Color.Transparent;
    111123      //
    112124      // CloudResourcesView
     
    134146    private System.Windows.Forms.Button btnAddSlaveService;
    135147    private System.Windows.Forms.Label lblRefresh;
     148    private System.Windows.Forms.ImageList imageListCloudResources;
    136149  }
    137150}
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/CloudResourcesView.cs

    r7317 r7324  
    1616    private int updateInterval = 15000;
    1717    private DateTime dueTime;
     18    private const int subscriptionImageIndex = 0;
     19    private const int serviceImageIndex = 1;
    1820
    1921    public new IItemList<Subscription> Content {
     
    2527      InitializeComponent();
    2628
     29      treeCloudResources.ImageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.NetworkCenterLarge);
     30      treeCloudResources.ImageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.MonitorLarge);
     31
     32      Content = CloudManagerClient.Instance.Subscriptions;
    2733      CloudManagerClient.Instance.Refreshing += new EventHandler(Instance_Refreshing);
    2834      CloudManagerClient.Instance.Refreshed += new EventHandler(Instance_Refreshed);
     
    4248    }
    4349
    44     void Instance_Refreshing(object sender, EventArgs e) {
     50    #region Register Content Events
     51    protected override void DeregisterContentEvents() {
     52      Content.ItemsAdded -= new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<Subscription>>(Content_ItemsAdded);
     53      Content.ItemsRemoved -= new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<Subscription>>(Content_ItemsRemoved);
     54      base.DeregisterContentEvents();
     55    }
     56    protected override void RegisterContentEvents() {
     57      base.RegisterContentEvents();
     58      Content.ItemsAdded += new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<Subscription>>(Content_ItemsAdded);
     59      Content.ItemsRemoved += new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<Subscription>>(Content_ItemsRemoved);
     60    }
     61    #endregion
     62
     63    protected override void SetEnabledStateOfControls() {
     64      base.SetEnabledStateOfControls();
     65      if (Content == null || Content.Count == 0) {
     66        btnAddSlaveService.Enabled = false;
     67        btnDelete.Enabled = false;
     68        btnSave.Enabled = false;
     69      } else {
     70        btnAddSlaveService.Enabled = true;
     71        btnDelete.Enabled = true;
     72        btnSave.Enabled = true;
     73      }
     74    }
     75
     76    protected override void OnContentChanged() {
     77      base.OnContentChanged();
     78      SetEnabledStateOfControls();
     79      if (Content == null) {
     80        //slaveView.Content = null;
     81        treeCloudResources.Nodes.Clear();
     82      } else {
     83        treeCloudResources.Nodes.Clear();
     84        foreach (Subscription sub in Content) {
     85          TreeNode tn = new TreeNode();
     86          tn.Tag = sub;
     87          tn.Text = sub.SubscriptionName;
     88          tn.ImageIndex = subscriptionImageIndex;
     89          tn.SelectedImageIndex = tn.ImageIndex;
     90          treeCloudResources.Nodes.Add(tn);
     91        }
     92      }
     93    }
     94
     95    private void Instance_Refreshing(object sender, EventArgs e) {
    4596      Debug.WriteLine("Instance_Refreshing");
    4697    }
    4798
    48     void Instance_Refreshed(object sender, EventArgs e) {
     99    private void Instance_Refreshed(object sender, EventArgs e) {
    49100      Debug.WriteLine("Instance_Refreshed");
     101    }
     102
     103    private void Content_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<Collections.IndexedItem<Subscription>> e) {
     104      OnContentChanged();
     105    }
     106
     107    private void Content_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<Collections.IndexedItem<Subscription>> e) {
     108      OnContentChanged();
    50109    }
    51110
     
    67126      }
    68127    }
     128
     129    private void btnAddSubscription_Click(object sender, EventArgs e) {
     130      using (var form = new AddSubscriptionDialog()) {
     131        form.ShowDialog();
     132        if (!form.ErrorOccured) {
     133          if (form.Subscription != null) {
     134            Subscription sub = form.Subscription;
     135            CloudManagerClient.Instance.Add(sub);
     136          }
     137        }
     138      }
     139    }
    69140  }
    70141}
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/HiveCloudManagerView.Designer.cs

    r7317 r7324  
    3333      // tabResources
    3434      //
    35       this.tabResources.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    36             | System.Windows.Forms.AnchorStyles.Left) 
     35      this.tabResources.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     36            | System.Windows.Forms.AnchorStyles.Left)
    3737            | System.Windows.Forms.AnchorStyles.Right)));
    3838      this.tabResources.Controls.Add(this.tabResource);
     
    5656      // cloudResourcesView
    5757      //
    58       this.cloudResourcesView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    59             | System.Windows.Forms.AnchorStyles.Left) 
     58      this.cloudResourcesView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     59            | System.Windows.Forms.AnchorStyles.Left)
    6060            | System.Windows.Forms.AnchorStyles.Right)));
    6161      this.cloudResourcesView.Caption = "Cloud Resources View";
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/HiveCloudManagerView.cs

    r7299 r7324  
    3838    public HiveCloudManagerView() {
    3939      InitializeComponent();
     40      cloudResourcesView.Content = CloudManagerClient.Instance.Subscriptions;
    4041    }
    4142
Note: See TracChangeset for help on using the changeset viewer.