Changeset 9915


Ignore:
Timestamp:
08/29/13 11:43:55 (6 years ago)
Author:
ascheibe
Message:

#2100 added a help button to View which opens and displays help texts if a help resource path is specified in the view attribute

Location:
trunk/sources
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/HeuristicLab.MainForm.WindowsForms-3.3.csproj

    r9079 r9915  
    138138      <DependentUpon>DefineArithmeticProgressionDialog.cs</DependentUpon>
    139139    </Compile>
     140    <Compile Include="Dialogs\InfoBox.cs">
     141      <SubType>Form</SubType>
     142    </Compile>
     143    <Compile Include="Dialogs\InfoBox.Designer.cs">
     144      <DependentUpon>InfoBox.cs</DependentUpon>
     145    </Compile>
    140146    <Compile Include="Plugin.cs" />
    141147    <Compile Include="Views\AsynchronousContentView.cs">
     
    266272    </BootstrapperPackage>
    267273  </ItemGroup>
    268   <ItemGroup />
    269274  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    270275  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/Views/View.Designer.cs

    r9456 r9915  
    4545    /// </summary>
    4646    private void InitializeComponent() {
     47      this.components = new System.ComponentModel.Container();
     48      this.helpLabel = new System.Windows.Forms.Label();
     49      this.helpToolTip = new System.Windows.Forms.ToolTip(this.components);
    4750      this.SuspendLayout();
    4851      //
    49       // ViewBase
     52      // helpLabel
    5053      //
    51       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     54      this.helpLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     55      this.helpLabel.Image = HeuristicLab.Common.Resources.VSImageLibrary.Help;
     56      this.helpLabel.Location = new System.Drawing.Point(131, 0);
     57      this.helpLabel.Name = "helpLabel";
     58      this.helpLabel.Size = new System.Drawing.Size(16, 16);
     59      this.helpLabel.TabIndex = 0;
     60      this.helpToolTip.SetToolTip(this.helpLabel, "Double Click to Show Help");
     61      this.helpLabel.Visible = false;
     62      this.helpLabel.DoubleClick += new System.EventHandler(this.helpLabel_DoubleClick);
     63      //
     64      // View
     65      //
    5266      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    53       this.Name = "ViewBase";
     67      this.Controls.Add(this.helpLabel);
     68      this.Name = "View";
    5469      this.Load += new System.EventHandler(this.View_Load);
    5570      this.ResumeLayout(false);
     
    5873
    5974    #endregion
     75
     76    protected System.Windows.Forms.Label helpLabel;
     77    protected System.Windows.Forms.ToolTip helpToolTip;
     78
    6079  }
    6180}
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/Views/View.cs

    r9456 r9915  
    3838      else
    3939        this.Caption = "View";
     40
     41      if (ViewAttribute.HasHelpResourcePath((this.GetType())))
     42        helpLabel.Visible = true;
    4043    }
    4144
     
    261264        ((Control)this).ResumeRepaint(refresh);
    262265    }
     266
     267    protected void helpLabel_DoubleClick(object sender, EventArgs e) {
     268      using (InfoBox dialog = new InfoBox("Help for " + ViewAttribute.GetViewName(this.GetType()), ViewAttribute.GetHelpResourcePath(this.GetType()), this)) {
     269        dialog.ShowDialog(this);
     270      }
     271    }
    263272  }
    264273}
  • trunk/sources/HeuristicLab.MainForm/3.3/ViewAttribute.cs

    r9456 r9915  
    2828    public ViewAttribute(string name) {
    2929      this.name = name;
     30      this.helpResourcePath = string.Empty;
     31    }
     32
     33    public ViewAttribute(string name, string helpResourcePath) {
     34      this.name = name;
     35      this.helpResourcePath = helpResourcePath;
    3036    }
    3137
     
    3440      get { return this.name; }
    3541      set { this.name = value; }
     42    }
     43
     44    private string helpResourcePath;
     45    public string HelpResourcePath {
     46      get { return this.helpResourcePath; }
     47      set { this.helpResourcePath = value; }
    3648    }
    3749
     
    4759      return viewType.Name;
    4860    }
     61
     62    public static string GetHelpResourcePath(MemberInfo viewType) {
     63      ViewAttribute[] attributes = (ViewAttribute[])viewType.GetCustomAttributes(typeof(ViewAttribute), false);
     64      if (attributes.Length == 1)
     65        return attributes[0].helpResourcePath;
     66      return string.Empty;
     67    }
     68
     69    public static bool HasHelpResourcePath(MemberInfo viewType) {
     70      ViewAttribute[] attributes = (ViewAttribute[])viewType.GetCustomAttributes(typeof(ViewAttribute), false);
     71      if (attributes.Length == 1)
     72        return attributes[0].helpResourcePath != string.Empty;
     73      return false;
     74    }
    4975  }
    5076}
Note: See TracChangeset for help on using the changeset viewer.