/// <summary> /// Initializes a new instance of the <see cref="MainWindow" /> class. /// </summary> public MainWindow() { IInfoProcessor iinfoProcessor = (IInfoProcessor)Activator.CreateInstance(Registry[languageType]); this.TheAssemblyInfo = AssemblyInfoProcessor.LoadAssemblyInfo(ProjectFolder, iinfoProcessor); if (this.TheAssemblyInfo == null) { MessageBox.Show("The assembly in " + ProjectFolder + " cannot be loaded"); Environment.Exit(1); } Rect rc = ProgramProperty.WinLocation; this.Left = rc.X; this.Top = rc.Y; this.Width = rc.Width; this.Height = rc.Height; Rect virtualScreen = new Rect(SystemParameters.VirtualScreenLeft, SystemParameters.VirtualScreenTop, SystemParameters.VirtualScreenWidth, SystemParameters.VirtualScreenHeight); if (!virtualScreen.Contains(rc)) { // The screen containing all the screens does not contain the stored coordinates. We move the rectangle inside the screen. if (this.Width < virtualScreen.Width) { double horizontalDiff = virtualScreen.Width - this.Width; this.Left = horizontalDiff / 2; } else { this.Left = 10; this.Width = virtualScreen.Width - 20; } if (this.Height < virtualScreen.Height) { double verticalDiff = virtualScreen.Height - this.Height; this.Top = verticalDiff / 2; } else { this.Top = 10; this.Height = virtualScreen.Height - 20; } } this.InitializeComponent(); this.TimeoutProgress.Visibility = ProgramProperty.CloseWinAutomatically ? Visibility.Visible : Visibility.Collapsed; this.Topmost = ProgramProperty.KeepOnTop; this.Title = "Project [" + this.TheAssemblyInfo.ProjectName + "] Current Version :" + this.TheAssemblyInfo; this.Release.Text = "CommentAssembly rel. " + Assembly.GetExecutingAssembly().GetName().Version; foreach (string line in this.TheAssemblyInfo.LastComments) { this.History.AppendText(line); this.History.AppendText(Environment.NewLine); } }
/// <summary> /// Handler called when the main windows is closing that stores the additional comments /// as well as the updated version number into the target AssemblyInfo.cs file /// </summary> /// <param name="sender">The parameter is not used.</param> /// <param name="e">The parameter is not used.</param> private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { IInfoProcessor iinfoProcessor = (IInfoProcessor)Activator.CreateInstance(Registry[languageType]); if (ThingTodo.ThingsDoneDuringThisSession.Count > 0) { foreach (var todo in ThingTodo.ThingsDoneDuringThisSession) { if (this.Comment.Text.Length > 0) { this.Comment.AppendText("\n"); } this.Comment.AppendText("Done : " + todo.Description); } } AssemblyInfoProcessor.UpdateAssemblyInfo( ProjectFolder, this.TheAssemblyInfo.CurrentVersion.Next(), this.Comment.Text, iinfoProcessor); }