Cannot get form designer in Visual Studio to load a form - visual-studio

Designer error screen shot
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainWindow));
this.TC_mainControl = new System.Windows.Forms.TabControl();
this.TP_Payment = new System.Windows.Forms.TabPage();
this.TP_Manage = new System.Windows.Forms.TabPage();
this.TP_Batch = new System.Windows.Forms.TabPage();
this.TP_Report = new System.Windows.Forms.TabPage();
this.TP_COMM = new System.Windows.Forms.TabPage();
this.TP_LOG = new System.Windows.Forms.TabPage();
this.pay_sample1 = new POSLinkTest.Payment();
this.man_sample1 = new POSLinkTest.Manage();
this.batch_sample1 = new POSLinkTest.Batch();
this.report_sample1 = new POSLinkTest.Report();
this.comm_sample1 = new POSLinkTest.Commset();
this.log_sample1 = new POSLinkTest.LogSetting();
this.TC_mainControl.SuspendLayout();
this.SuspendLayout();
//
// TC_mainControl
//
this.TC_mainControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.TC_mainControl.Controls.Add(this.TP_Payment);
this.TC_mainControl.Controls.Add(this.TP_Manage);
this.TC_mainControl.Controls.Add(this.TP_Batch);
this.TC_mainControl.Controls.Add(this.TP_Report);
this.TC_mainControl.Controls.Add(this.TP_COMM);
this.TC_mainControl.Controls.Add(this.TP_LOG);
this.TC_mainControl.ItemSize = new System.Drawing.Size(148, 20);
this.TC_mainControl.Location = new System.Drawing.Point(0, 0);
this.TC_mainControl.Multiline = true;
this.TC_mainControl.Name = "TC_mainControl";
this.TC_mainControl.Padding = new System.Drawing.Point(6, 0);
this.TC_mainControl.SelectedIndex = 0;
this.TC_mainControl.Size = new System.Drawing.Size(1000, 600);
this.TC_mainControl.SizeMode = System.Windows.Forms.TabSizeMode.Fixed;
this.TC_mainControl.TabIndex = 0;
this.TC_mainControl.SelectedIndexChanged += new System.EventHandler(this.TC_mainControl_SelectedIndexChanged);
//
// TP_Payment
//
this.TP_Payment.AutoScroll = true;
The solution builds without any errors? Why will the form not load into the designer, yet it will compile?
Using Visual Studio 2015, Windows 10 64 bit
I can upload the project if necessary, it is just Sample Project.

The error message on the screenshot says that types from POSLinkTest namespace are not available. So probably add a reference to that namespace.
For future use there are some other potential problems with the designer code:
Removed parameterless constructor. Solution: add the parameterless constructor back as a privet constructor to prevent others from using it but having it available for the designer
Design time code (like OnPaint handler) that references resource not available at that time (like db connection). Solution: try not to handle that in UI related code.

Related

How do you programmatically run Static Code Analysis in Visual Studio 2017?

I'm working on a solution to localize legacy applications. I've written a Visual studio add-in using EnvDte that automates the process of setting the "Localizable" flag for every form in the solution to true, which is a critical step for extracting resources on form designers. I am now trying to deal with any text that is set programmatically, text that trigger the Globalization (CA13##) warnings.
designer.Visible = true;
var host = (IDesignerHost)designer.Object;
var provider = TypeDescriptor.GetProvider(host.RootComponent);
var typeDescriptor = provider.GetExtendedTypeDescriptor(host.RootComponent);
if (typeDescriptor == null)
continue;
var propCollection = typeDescriptor.GetProperties();
var propDesc = propCollection["Localizable"];
if (propDesc != null && host.RootComponent != null &&
(bool?)propDesc.GetValue(host.RootComponent) != true)
{
try
{
propDesc.SetValue(host.RootComponent, true);
}
catch (Exception ex)
{
// log the error
}
// save changes
}
I've been able to run it manually from the menu using: Analyze -> Run Code Analysis -> On Solution to get a list of issues, but I would like to automate this step with another add-in that runs and extracts the results.
Are there any resources that point to accessing the build warnings or the results of the code analysis?
Are there any solutions that already do this using EnvDte or Roslyn?
Ok, I've managed to glean enough information to put together the add-in. Put simply, you use _dte.ExecuteCommand()
Initialize the command:
// nothing to see here...
_package = package ?? throw new ArgumentNullException(nameof(package));
var commandService = ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if (commandService == null)
return;
_dte = (DTE2)ServiceProvider.GetService(typeof(DTE));
var menuCommandId = new CommandID(CommandSet, CommandId);
var menuItem = new MenuCommand(MenuItemCallback, menuCommandId);
commandService.AddCommand(menuItem);
_events = _dte.Events.BuildEvents;
// since static code analysis is a sort of build you need to hook into OnBuildDone
_events.OnBuildDone += OnBuildDone;
Trigger the analysis
private void MenuItemCallback(object sender, EventArgs e)
{
_dte.ExecuteCommand("Build.RunCodeAnalysisonSolution");
}
Extract errors in the OnBuildDone event
private void OnBuildDone(vsBuildScope scope, vsBuildAction action)
{
Dispatcher.CurrentDispatcher.InvokeAsync(new Action(() =>
{
_dte.ExecuteCommand("View.ErrorList", " ");
var errors = _dte.ToolWindows.ErrorList.ErrorItems;
for (int i = 1; i <= errors.Count; i++)
{
ErrorItem error = errors.Item(i);
var code = error.Collection.Item(1);
var item = new
{
error.Column,
error.Description,
error.ErrorLevel,
error.FileName,
error.Line,
error.Project
};
error.Navigate(); // you can navigate to the error if you wanted to.
}
});
}

AVCapturePhotoSettings not accepting accept NSDictionary element

not sure what I am doing wrong, I wanna create a simple custom camera, I'm creating the AVCapturePhotoOutput attaching it to AVCaptureSession, then creating AVCapturePhotoSettings with minimum settings to make taking a picture work, see code below.
I get exception kCVPixelBufferPixelFormatTypeKey is not being define but it is indeed in the NSDictionary I am passing.
I need some light here, thanks
public void TakePicture()
{
var output = new AVCapturePhotoOutput();
_captureSession.AddOutput(output);
var settings = AVCapturePhotoSettings.Create();
var previewPixelType = settings.AvailablePreviewPhotoPixelFormatTypes.First();
var keys = new[]
{
new NSString("kCVPixelBufferPixelFormatTypeKey"),
new NSString("kCVPixelBufferWidthKey"),
new NSString("kCVPixelBufferHeightKey"),
};
var objects = new NSObject[]
{
// don't have to be strings... can be any NSObject.
previewPixelType,
new NSString("160"),
new NSString("160")
};
var dicionary = new NSDictionary<NSString, NSObject>(keys, objects);
settings.PreviewPhotoFormat = dicionary;
output.CapturePhoto(settings,this);
}
It is because kCVPixelBufferPixelFormatTypeKey is not available in Xamarin.
We should use CVPixelBuffer.PixelFormatTypeKey here . It will be convert to kCVPixelBufferPixelFormatTypeKey automatically when compiling.
The same reason for kCVPixelBufferWidthKey and kCVPixelBufferHeightKey , the api is CVPixelBuffer.WidthKey and CVPixelBuffer.HeightKey in Xamarin.iOS.

iTextSharp : Cannot attach PageEvent on a PdfSmartCopy writer

This code using ItextSharp 5.5.10:
var msOutput = new MemoryStream();
var document = new Document(PageSize.A4, 0, 0, 0, 20);
var writer = new PdfSmartCopy(document, msOutput);
writer.PageEvent = new MyHeaderFooterEvents();
Throws "Operation is not valid due to the current state of the object." when assigning the "writer.PageEvent" (also fails when doing a parameterless new Document()).
When this code works perfectly:
var outputStream = new MemoryStream();
var document = new Document(PageSize.A4, leftMargin, rightMargin, topMargin, bottomMargin);
var writer = PdfWriter.GetInstance(document, outputStream);
writer.PageEvent = new MyHeaderFooterEvents();
Any idea ?
The Pdf[Smart]Copy classes are intended for read-only usage. It's documented in the raw source code:
/// Setting page events isn't possible with Pdf(Smart)Copy.
/// Use the PageStamp class if you want to add content to copied pages.
Note to the iText development team - if XML Documentation Comments using the <summary> tag are used instead of the current style, comments will show up in Visual Studio IntelliSense.

UWP - Why is my simple animation not running

I am totally lost at the moment. What is wrong with my animation? Why is it not running? Any help would be highly appreciated! I want to develop sort of an circular progress bar which is "rolling in" as if the bar was filled up.
The following code runs inside an empty UWP app in the MainPage's Loaded Handler. Nothing else...
ArcSegment myArcSegment = new ArcSegment();
myArcSegment.Size = new Size(90, 80);
myArcSegment.SweepDirection = SweepDirection.Clockwise;
PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();
myPathSegmentCollection.Add(myArcSegment);
PathFigure myPathFigure = new PathFigure();
myPathFigure.StartPoint = new Point(100, 200);
myPathFigure.Segments = myPathSegmentCollection;
PathFigureCollection myPathFigureCollection = new PathFigureCollection();
myPathFigureCollection.Add(myPathFigure);
PathGeometry myPathGeometry = new PathGeometry();
myPathGeometry.Figures = myPathFigureCollection;
Path myPath = new Path();
myPath.Stroke = new SolidColorBrush(Colors.Aqua);
myPath.StrokeThickness = 1;
myPath.Data = myPathGeometry;
PointAnimation mySizeAnimation = new PointAnimation();
mySizeAnimation.Duration = TimeSpan.FromSeconds(2);
mySizeAnimation.From = new Point(90, 80);
mySizeAnimation.To = new Point(500, 200);
Storyboard.SetTarget(mySizeAnimation, myArcSegment);
Storyboard.SetTargetProperty(mySizeAnimation, nameof(ArcSegment.Point));
Storyboard ellipseStoryboard = new Storyboard();
ellipseStoryboard.Children.Add(mySizeAnimation);
myPath.Loaded += delegate (object o, RoutedEventArgs e)
{
ellipseStoryboard.Begin();
};
Canvas containerCanvas = new Canvas();
containerCanvas.Children.Add(myPath);
Content = containerCanvas;
Thank you for your help!
Oh my... I just read this post: http://blog.jerrynixon.com/2012/06/windows-8-animated-pie-slice.html
By accident I read about the EnableDependendAnimation Property... never heared of it, but Setting it to true just made the Animation run. I will read up on that now. Thanks anyways!

Pechkin to Tuespechkin

For a project, we are migrating to Windows Azure. I have to make sure that the HTML to PDF converter will run on a 64 bit worker role.
Since Pechkin can't run as a 64bit application I have decided to use Tuespechkin, because they should be very alike and both use wkhtmltopdf to convert the HTML to PDF.
Now, i got this all set up but the resulting PDF is kind of disappointing.
Problems:
The font is rendered differently. With Pechkin the font is always 'sharp' where tuespechkin makes it very bold.
Results here:
http://postimg.org/image/xngqxryn1/
I tried using different fonts (even browser default). All render very bold
I tried using different Object- and Globalsettings (DPI, Outline, compression, name it; it never changes much).
All contents is selectable and copyable. I would like it to be more like an image (which is default in pechkin). Any advice on this would be appreciated.
Here is the code i am using to convert the HTML to PDF:
Pechkin, old:
var documentConfig = new ObjectConfig()
.SetAllowLocalContent(true)
.SetLoadImages(true)
.SetRunJavascript(true)
.SetPrintBackground(true)
.SetRenderDelay(15000);
var globalConfig = new GlobalConfig()
.SetMargins(new Margins(50, 50, 100, 100))
.SetDocumentTitle(company.Name)
.SetPaperSize(PaperKind.A4);
var pechkin = new SynchronizedPechkin(globalConfig);
var buffer = pechkin.Convert(documentConfig, parsedHtml);
Tuespechkin:
var converter = new ThreadSafeConverter(
//new ImageToolset(
new PdfToolset(
new Win64EmbeddedDeployment(
new TempFolderDeployment()
)
)
);
var documentConfig = new ObjectSettings {
WebSettings = new WebSettings {
EnableJavascript = true,
PrintBackground = true,
PrintMediaType = true
},
LoadSettings = new LoadSettings {
BlockLocalFileAccess = false,
RenderDelay = 15000,
},
HtmlText = parsedHtml
};
var globalConfig = new GlobalSettings();
globalConfig.Margins = new MarginSettings(2.645833333333, 1.322916666667, 2.645833333333, 1.322916666667);
globalConfig.Margins.Unit = Unit.Centimeters;
globalConfig.DocumentTitle = company.Name;
globalConfig.PaperSize = PaperKind.A4;
globalConfig.UseCompression = false;
globalConfig.DPI = 1200;
var doc = new HtmlToPdfDocument {
Objects = {
documentConfig
},
GlobalSettings = globalConfig
};
var buffer = converter.Convert(doc);
Any help on either problem would be much appreciated!
As you say, I can't solve the problem.
But IIS can be set to run 32-bit applications.
as this photo:
http://i.stack.imgur.com/6l6Es.png
So you can run Pechkin in you Azure.
You can see more in this.
https://codeutil.wordpress.com/2013/09/16/convert-html-to-pdf/

Resources