How to trigger red squigglies with UltraSpellChecker without user intervention? - infragistics

The Infragistics docs say to set Mode to AsYouType and when the user types a space the spell checker will create the squigglies.
I also see there is an AsYouTypeManager class but don't know where or how to use it either. The documentation online is not that great.
When a box is loaded with the data and it has errors, I would like to have the red squigglies appear without any user interaction. How can I do this?

The following example shows how the UltraSpellChecker must be initialized to have the red squiggles appear without any user interaction.
Form1.cs
private void Form1_Load(object sender, EventArgs e)
{
// The extender property must be set for the rich text box so that it may be spell checked.
// This can also be done through the property grid in the forms designer
this.ultraSpellChecker1.SetSpellCheckerSettings(this.rtbSpellChecked, new SpellCheckerSettings(true));
}
Form1.Designer.cs
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.rtbSpellChecked = new System.Windows.Forms.RichTextBox();
this.ultraSpellChecker1 = new Infragistics.Win.UltraWinSpellChecker.UltraSpellChecker(this.components);
((System.ComponentModel.ISupportInitialize)(this.ultraSpellChecker1)).BeginInit();
this.SuspendLayout();
//
// rtbSpellChecked
//
this.rtbSpellChecked.Dock = System.Windows.Forms.DockStyle.Fill;
this.rtbSpellChecked.Location = new System.Drawing.Point(0, 0);
this.rtbSpellChecked.Name = "rtbSpellChecked";
this.rtbSpellChecked.Size = new System.Drawing.Size(411, 266);
this.rtbSpellChecked.TabIndex = 5;
this.rtbSpellChecked.Text = "UltraSpellChecker Class\nPerforms spel cheking on one or more conrols.";
//
// ultraSpellChecker1
//
this.ultraSpellChecker1.ContainingControl = this;
this.ultraSpellChecker1.Mode = Infragistics.Win.UltraWinSpellChecker.SpellCheckingMode.AsYouType;
this.ultraSpellChecker1.ShowDialogsModal = false;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(411, 266);
this.Controls.Add(this.rtbSpellChecked);
this.Name = "Form1";
this.Text = "UltraSpellChecker";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.ultraSpellChecker1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private Infragistics.Win.UltraWinSpellChecker.UltraSpellChecker ultraSpellChecker1;
private System.Windows.Forms.RichTextBox rtbSpellChecked;
The this.ultraSpellChecker1.Mode is set to SpellCheckingMode.AsYouType as described in the Infragistics documentation and the code above shows the following form:

Related

Can't assign the landscape LayerInfo object to a landscape

I've been developing an automated system that requires me to generate the LayerInfo objects of a given Landscape. So far I've been able to generate the required LayerInfo object's, but I wasn't able to assign them, or to be more precise, when I try to assign the necessary layers in the ULandscapeInfo property they appear in the editor but are not assigned, unless I save them and restart the engine, they also appear weird in the editor, as you can see in the image. I think it's a similar problem to the one in this thread. The code bellow it's responsible for assignig the LayerInfo:
// This method creates a
// new layer info object
UWorld * currentWorld = GetWorld();
ULevel * level = currentWorld->GetLevel(0); // TODO : just for debuging
ULandscapeLayerInfoObject* layerInfo = Landscape->CreateLayerInfo(*(layerName), level);
bool isDirty = layerInfo->MarkPackageDirty();
// Get a reference for the landscape Info
ULandscapeInfo* landscapeInfo = Landscape->GetLandscapeInfo();
landscapeInfo->CreateLayerEditorSettingsFor(layerInfo);
FLandscapeInfoLayerSettings* layerSettings = &landscapeInfo->Layers[1];
landscapeInfo->Layers[0] = FLandscapeInfoLayerSettings(layerInfo, Landscape);
UEditorAssetLibrary::SaveAsset(assetName, false);
// Assign the respective values
if (!layerSettings->LayerInfoObj)
{
layerSettings->Owner = Landscape;
layerSettings->LayerInfoObj = layerInfo;
layerSettings->bValid = true;
}
Editor Screenshot

When exactly are published properties assigned at run time?

I have a custom control which needs to do some things when loading at run time, based on a published property. However, I am running into a problem where, whenever I check the published property, it has not been set yet, and is always the default value.
I first attempted checking the property in the constructor, of the control, but quickly found they were not loaded yet. I know that when the control is shown on the screen the properties are set correctly, thus its not an issue with the properties not being loaded at all.
I next attempted overriding the Loaded Method but am still having the same problem, so I don't think this is exactly what I am looking for.
void __fastcall TFmSearchBar::Loaded()
{
TEdit::Loaded(); //call base class loaded
if( MyProperty )
{
//do stuff
}
}
At what point are these published properties actually getting set?
What method can/should I hook into in order to execute some logic in my control based on these properties, as soon as the properties are set correctly?
If I check the property in the constructor of the control, the property is always the default value even if I have specified otherwise in the designer.
Correct, because its design-time values have not been assigned yet.
At what point are these published properties actually getting set?
When the Owner (Form, Frame, or DataModule) is being constructed. It loads its own DFM resource and parses it, constructing stored child components and reading their property values.
For example, say you have the following DFM:
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
...
object Edit1: TEdit
Left = 136
Top = 64
Width = 121
Height = 21
TabOrder = 0
end
object Button1: TButton
Left = 263
Top = 62
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 1
end
end
The DFM streaming process roughly translates to the following equivalent code (I'm leaving a lot of internal details out for simplicity):
__fastcall TCustomForm::TCustomForm(TComponent *Owner)
: TScrollingWinControl(Owner)
{
this->FFormState << fsCreating;
try
{
// locate, load, and parse the "Form1" DFM resource ...
this->FComponentState << csLoading;
this->Parent = ...;
this->Name = L"Form1":
this->FComponentState << csReading;
this->Left = 0;
this->Top = 0;
this->Caption = L"Form1";
...
TEdit *e = new TEdit(this);
try
{
e->FComponentState << csLoading;
e->Parent = this;
e->Name = L"Edit1"; // <-- sets the derived Form's 'Edit1' member to this object
e->FComponentState << csReading;
e->Left = 136;
e->Top = 64;
e->Width = 121;
e->Height = 21;
e->TabOrder = 0;
e->FComponentState >> csReading;
}
catch (...)
{
delete e;
throw;
}
TButton *b = new TButton(this);
try
{
b->FComponentState << csLoading;
b->Parent = this;
b->Name = L"Button1"; // <-- sets the derived Form's 'Button1' member to this object
b->FComponentState << csReading;
b->Left = 263;
b->Top = 62;
b->Width = 75;
b->Height = 25;
b->Caption = L"Button1";
b->TabOrder = 1;
b->FComponentState >> csReading;
}
catch (...)
{
delete b;
throw;
}
this->FComponentState >> csReading;
...
e->Loaded();
b->Loaded();
this->Loaded();
}
__finally
{
this->FFormState >> fsCreating;
}
}
So, as you can see, a component's property values are not available yet when its constructor is called.
What method can/should I hook into in order to execute some logic in my control based on these properties, as soon as the properties are set correctly?
That depends on what the properties need to do. If they need to perform operations immediately, you can do that directly in their property setters. But if they need to wait until other properties have been loaded first (if one property is dependent on the value of another property), then override the virtual Loaded() method instead, which is automatically called after DFM streaming is finished. Property setters can check the flags of the ComponentState property to know whether or not the component is currently running in the Form Designer at design-time, whether or not a DFM is currently being streamed, etc and then act accordingly as needed.
I attempted overriding the Loaded Method but am still having the same problem
Which is what exactly? You did not explain what your actual problem is. Please edit your question to provide those details.
so I don't think this is exactly what I am looking for.
It most likely is, you probably are just not using it correctly.

How to draw on ActionBar tab when using ActionBarSherlock in Android?

I am using ActionBarSherlock to provide ActionBars for pre HoneyComb devices.
My Activity has four fragments namely 1. User 2. Chat 3. Video 4. Extra, see image
I have created actionBar using following code:-
actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setTitle("Meeting");
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowCustomEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
/* Set Custom view */
ActionBar.Tab tab = actionBar.newTab();
// tab.setText("Meeting Users");
tab.setIcon(R.drawable.users);
tab.setTabListener(this);
actionBar.addTab(tab);
tab = actionBar.newTab();
// tab.setText("Chat");
tab.setIcon(R.drawable.chat);
tab.setTabListener(this);
actionBar.addTab(tab);
tab = actionBar.newTab();
// tab.setText("Video");
tab.setIcon(R.drawable.video_call);
tab.setTabListener(this);
tab.select();
actionBar.addTab(tab);
tab = actionBar.newTab();
// tab.setText("Extra");
tab.setIcon(R.drawable.extra);
tab.setTabListener(this);
actionBar.addTab(tab);
I want to draw something on those tabs, for example draw and/OR blink on chat tab, whenever chat messages arrives and user is on some other tab.
How can I do this ? please help.
Use custom view for your tabs
ActionBar.Tab tab = getSupportActionBar().newTab();
tab.setCustomView(R.layout.custom_tab_view);
Then you can get views on your custom layout and make blinking
This is How I solved my problem, Hope it can be useful for someone else too....
First I created a CutomImageView by extending ImageView
package com.myexample.newsessionwindowsrbrdemo;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.renderscript.Font.Style;
import android.widget.ImageView;
public class CustomImageView extends ImageView {
private int notificationCount;
/**
* #param context
*/
public CustomImageView(Context context) {
super(context);
notificationCount = 0;
}
public synchronized void incrementNotification() {
notificationCount--;
this.invalidate();
}
public synchronized void decrementNotification() {
notificationCount++;
this.invalidate();
}
/**
* #return the notificationCount
*/
public synchronized int getNotificationCount() {
return notificationCount;
}
/**
* #param notificationCount
* the notificationCount to set
*/
public synchronized void setNotificationCount(int notificationCount) {
this.notificationCount = notificationCount;
this.invalidate();
}
/*
* (non-Javadoc)
*
* #see android.widget.ImageView#onDraw(android.graphics.Canvas)
*/
#Override
protected void onDraw(Canvas canvas) {
System.out.println("OnDraw is called");
super.onDraw(canvas);
Paint paint = new Paint();
paint.setColor(Color.RED);
paint.setStyle(Paint.Style.FILL);
paint.setFakeBoldText(true);
paint.setTextSize(15);
canvas.drawText(String.valueOf(notificationCount), 15, 20, paint);
}
}
Then While creating tabs, I used this image as
/* Set Custom view */
mView = new CustomImageView(this);
mView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
mView.setBackgroundResource(R.drawable.users);
ActionBar.Tab tab = actionBar.newTab();
tab.setCustomView(mView);
tab.setTabListener(this);
actionBar.addTab(tab);
Now whenever the notification changes I call increment/decrement or setter method of CustomImageView and new Notifications are displayed on the image..
Suggestions to improve this solution are really welcome...

Referencing TabControls from another Form C++/CLI

I am trying to convert this tabbed browser into C++ from visual basic.
I am trying to reference the Tab Control from Form1.h.
Here is the code on Form1.h:
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
String^ title = String::Concat("TabPage ",(tabControl1->TabCount + 1).ToString());
tab^ newtab = gcnew tab;
newtab->Show();
newtab->TopLevel = false;
newtab->Dock = System::Windows::Forms::DockStyle::Fill;
TabPage^ myTabPage = gcnew TabPage(title);
myTabPage->Controls->Add(newtab);
tabControl1->TabPages->Add(myTabPage);
}
The code on the second form that is trying to create another tab is this:
private: System::Void newTabToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
tab^ newtab = gcnew tab;
newtab->Show();
newtab->TopLevel = false;
newtab->Dock = System::Windows::Forms::DockStyle::Fill;
TabPage^ myTabPage = gcnew TabPage();
myTabPage->Controls->Add(newtab);
tabControl1->TabPages->Add(myTabPage);
}
In visual basic all that is required is to add Form1. to the beginning like so...:
//Original
tabControl1.TabPages.Add(myTabPage);
//New
Form1.tabControl1.TabPages.Add(myTabPage);
How could I do this same thing in C++?
Visual Basic provides a default instance of each class in your project. When you say Form1.tabControl1, you're actually getting a particular global instance of Form1, and accessing the tabControl1 field on that.
Add a way to send the instance of Form1 to the second form, and use that instead of Form1. Something simple like passing the instance of Form1 to the second form in its constructor will probably do the trick.

What is an easy way to create a MessageBox with custom button text in Managed C++?

I would like to keep the overhead at a minimum. Right now I have:
// Launch a Message Box with advice to the user
DialogResult result = MessageBox::Show("This may take awhile, do you wish to continue?", "Warning", MessageBoxButtons::YesNo, MessageBoxIcon::Exclamation);
// The test will only be launched if the user has selected Yes on the Message Box
if(result == DialogResult::Yes)
{
// Execute code
}
Unfortunately my client would prefer "Continue" and "Cancel" in place of the default "Yes" and "No" button text. It seems like there should be an easy way to do this.
You can use "OK" and "Cancel"
By substituting MessageBoxButtons::YesNo with MessageBoxButtons::OKCancel
MessageBoxButtons Enum
Short of that you would have to create a new form, as I don't believe the Enum can be extended.
Change the message as below. This may be the simplest way I think.
DialogResult result = MessageBox::Show(
"This may take awhile, do you wish to continue?**\nClick Yes to continue.\nClick No to cancel.**",
"Warning",
MessageBoxButtons::YesNo,
MessageBoxIcon::Exclamation
);
From everything I can find it looks like Corin is right. Here is the code that I used to accomplish the original goal. I am not usually a Managed C++ programmer, so any editing would be appreciated.
CustomMessageBox.h:
using namespace System::Windows::Forms;
/// <summary>
/// A message box for the test. Used to ensure user wishes to continue before starting the test.
/// </summary>
public ref class CustomMessageBox : Form
{
private:
/// Used to determine which button is pressed, default action is Cancel
static String^ Button_ID_ = "Cancel";
// GUI Elements
Label^ warningLabel_;
Button^ continueButton_;
Button^ cancelButton_;
// Button Events
void CustomMessageBox::btnContinue_Click(System::Object^ sender, EventArgs^ e);
void CustomMessageBox::btnCancel_Click(System::Object^ sender, EventArgs^ e);
// Constructor is private. CustomMessageBox should be accessed through the public ShowBox() method
CustomMessageBox();
public:
/// <summary>
/// Displays the CustomMessageBox and returns a string value of "Continue" or "Cancel"
/// </summary>
static String^ ShowBox();
};
CustomMessageBox.cpp:
#include "StdAfx.h"
#include "CustomMessageBox.h"
using namespace System::Windows::Forms;
using namespace System::Drawing;
CustomMessageBox::CustomMessageBox()
{
this->Size = System::Drawing::Size(420, 150);
this->Text="Warning";
this->AcceptButton=continueButton_;
this->CancelButton=cancelButton_;
this->FormBorderStyle= ::FormBorderStyle::FixedDialog;
this->StartPosition= FormStartPosition::CenterScreen;
this->MaximizeBox=false;
this->MinimizeBox=false;
this->ShowInTaskbar=false;
// Warning Label
warningLabel_ = gcnew Label();
warningLabel_->Text="This may take awhile, do you wish to continue?";
warningLabel_->Location=Point(5,5);
warningLabel_->Size=System::Drawing::Size(400, 78);
Controls->Add(warningLabel_);
// Continue Button
continueButton_ = gcnew Button();
continueButton_->Text="Continue";
continueButton_->Location=Point(105,87);
continueButton_->Size=System::Drawing::Size(70,22);
continueButton_->Click += gcnew System::EventHandler(this, &CustomMessageBox::btnContinue_Click);
Controls->Add(continueButton_);
// Cancel Button
cancelButton_ = gcnew Button();
cancelButton_->Text="Cancel";
cancelButton_->Location=Point(237,87);
cancelButton_->Size=System::Drawing::Size(70,22);
cancelButton_->Click += gcnew System::EventHandler(this, &CustomMessageBox::btnCancel_Click);
Controls->Add(cancelButton_);
}
/// <summary>
/// Displays the CustomMessageBox and returns a string value of "Continue" or "Cancel", depending on the button
/// clicked.
/// </summary>
String^ CustomMessageBox::ShowBox()
{
CustomMessageBox^ box = gcnew CustomMessageBox();
box->ShowDialog();
return Button_ID_;
}
/// <summary>
/// Event handler: When the Continue button is clicked, set the Button_ID_ value and close the CustomMessageBox.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
void CustomMessageBox::btnContinue_Click(System::Object^ sender, EventArgs^ e)
{
Button_ID_ = "Continue";
this->Close();
}
/// <summary>
/// Event handler: When the Cancel button is clicked, set the Button_ID_ value and close the CustomMessageBox.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
void CustomMessageBox::btnCancel_Click(System::Object^ sender, EventArgs^ e)
{
Button_ID_ = "Cancel";
this->Close();
}
And then finally the modification to the original code:
// Launch a Message Box with advice to the user
String^ result = CustomMessageBox::ShowBox();
// The test will only be launched if the user has selected Continue on the Message Box
if(result == "Continue")
{
// Execute Code
}