Im creating a new cell = new XRTableCell();
I'll show a sample of my code.
I always ending up with the same color in my cell, even if I change it in my "If".
foreach (TaskTime tt in di.TaskTimes[i])
{
.....
TimeToAdd = ClassLibrary.Utils.GetTimeStringFromSec(tt.FromSec % 86400) + " - " + ClassLibrary.Utils.GetTimeStringFromSec(tt.UntilSec % 86400) + " (" + tt.Abbreviation+ ")";
if (taskTimeTextBox.Text.Length > 0)
taskTimeTextBox.Text += "\n";
taskTimeTextBox.Text += TimeToAdd;
if (tt.OnOtherCostDivision)
{
taskTimeTextBox.SelectionStart = taskTimeTextBox.Find(TimeToAdd);
taskTimeTextBox.SelectionFont = new Font("Calibri", 9, FontStyle.Italic);
taskTimeTextBox.SelectionColor = Color.Gray;
}
else
{
taskTimeTextBox.SelectionStart = taskTimeTextBox.Find(TimeToAdd);
taskTimeTextBox.SelectionFont = new Font("Calibri", 9, FontStyle.Italic);
taskTimeTextBox.SelectionColor = Color.Blue;
}
richTxtObject.Rtf = taskTimeTextBox.Rtf;
cell.Controls.Add(richTxtObject);
}
row.Cells.Add(cell);
Soulved it! Didn't worked when I had it this way "taskTimeTextBox.Text += xxxxxxxx ". So I made a list of string, saved my text in if it were "onOtherCostDivision". Later on I hade to loop true my list and see if the final taskTimeTextBox.Text had the text in it and in that cause I added the color.
foreach (var task in taskCostDivList)
{
if (taskTimeTextBox.Text.Contains(task))
{
taskTimeTextBox.SelectionStart = taskTimeTextBox.Find(task);
taskTimeTextBox.Font = new Font("Calibri", 9, FontStyle.Italic);
taskTimeTextBox.SelectionColor = Color.Gray;
}
else
{
taskTimeTextBox.Font = new Font("Calibri", 9, FontStyle.Regular);
taskTimeTextBox.SelectionColor = Color.Black;
}
}
Related
I've been messing around with the Camarilla Indicator and I wanted to get the main pivot values for my EA, can I use iCustom() for that? or should I just pass the code to the EA? but where exactly would I place it? I tried to place it on the onTick() but with a condition of only calculating the pivots when there is a new daily candle, but the values most of the times don't match.
void OnTick()
{
static datetime today;
if (today != iTime (Symbol(), PERIOD_D1, 0))
{
today = iTime (Symbol(), PERIOD_D1, 0);
int counted_bars=IndicatorCounted();
//---- TODO: add your code here
int cnt=720;
//---- exit if period is greater than daily charts
if(Period() > 1440)
{
Print("Error - Chart period is greater than 1 day.");
}
//---- Get new daily prices & calculate pivots
day_high=0;
day_low=0;
yesterday_open=0;
today_open=0;
cur_day=0;
prev_day=0;
while (cnt!= 0)
{
if (TimeDayOfWeek(Time[cnt]) == 0)
{
cur_day = prev_day;
}
else
{
cur_day = TimeDay(Time[cnt]- (GMTshift*3600));
}
if (prev_day != cur_day)
{
yesterday_close = Close[cnt+1];
today_open = Open[cnt];
yesterday_high = day_high;
yesterday_low = day_low;
day_high = High[cnt];
day_low = Low[cnt];
prev_day = cur_day;
}
if (High[cnt]>day_high)
{
day_high = High[cnt];
}
if (Low[cnt]<day_low)
{
day_low = Low[cnt];
}
cnt--;
}
H3 = ((yesterday_high - yesterday_low)* D3) + yesterday_close;
H4 = ((yesterday_high - yesterday_low)* D4) + yesterday_close;
L3 = yesterday_close - ((yesterday_high - yesterday_low)*(D3));
L4 = yesterday_close - ((yesterday_high - yesterday_low)*(D4));
L5 = yesterday_close - (H5 - yesterday_close);
H5 = (yesterday_high/yesterday_low)*yesterday_close;
Print ("H3: " + DoubleToStr(H3));
Print ("H4: " + DoubleToStr(H4));
Print ("H5: " + DoubleToStr(H5));
Print ("L3: " + DoubleToStr(L3));
Print ("L4: " + DoubleToStr(L4));
Print ("L5: " + DoubleToStr(L5));
}
I have a google spreadsheet that allows me to keep track of costs and item amounts. I wrote a script to update these values; however, today it just hangs on getRange or getDataRange, even while debugging. This was working fine yesterday.
<code>function onOpen() {
var menuEntries = [{name: "Update P0", functionName: "UpdateP0"}];
SpreadsheetApp.getActiveSpreadsheet().addMenu("PI Utils", menuEntries);
}
function showMsg(data, title, timeout) {
if (typeof title == 'undefined') title = "";
if (typeof timeout == 'undefined') timeout = 5;
SpreadsheetApp.getActiveSpreadsheet().toast(data, title, timeout);
}
function UpdateP0() {
showMsg("Updating...", "", -1);
var piSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('PI (Set1)');
piSheet.activate();
//SpreadsheetApp.flush();
var numPlanets = 5;
try {
var dRange = piSheet.getRange('A1:F55'); // will not execute pass this line
} catch (e) {
throw (e);
return;
}
for (var p = 1, prGroup = 1; p <= numPlanets; p++, prGroup += 11) {
var cell1, cell2, v1, v2;
// update extraction amounts
for (var r = 0; r < 3; r++) {
cell1 = dRange.getCell(prGroup + 2 + r, 3);
cell2 = dRange.getCell(prGroup + 2 + r, 4);
v1 = cell1.getValue().toString();
v2 = cell2.getValue().toString();
v1 = (v1.length == 0) ? parseFloat(0.0) : parseFloat(v1);
v2 = (v2.length == 0) ? parseFloat(0.0) : parseFloat(v2);
v2 += v1;
cell1.setValue(0);
cell2.setValue(v2);
}
// update production costs
for (var c = 2; c <= 5; c++) {
cell1 = dRange.getCell(prGroup + 9, c);
cell2 = dRange.getCell(prGroup + 8, c);
v1 = cell1.getValue().toString();
v2 = cell2.getValue().toString();
v1 = (v1.length == 0) ? parseFloat(0.0) : parseFloat(v1);
v2 = (v2.length == 0) ? parseFloat(0.0) : parseFloat(v2);
v2 += v1;
cell1.setValue(0);
cell2.setValue(v2);
}
}
SpreadsheetApp.flush();
showMsg("Completed.", "", 5);
}</code>
What I did to fix this issue (or maybe it's a coincidence) is to create a new sheet, with an adjusted name, and then cut & paste everything from the old sheet to the new one, and then finally delete the old sheet. Running the function worked on the new sheet.
I have the following code on an AdWords script:
var campanha = 'xyz';
function main() {
campanhas = AdWordsApp.campaigns().withCondition("CampaignName = '" + campanha + "'").withCondition('Status = ENABLED').get();
while(campanhas.hasNext()) {
campanha = campanhas.next();
if(campanha.getBiddingStrategyType() != 'ENHANCED_CPC') {
Logger.log('Ajuste de lance da campanha inválido: ' +campanha.getBiddingStrategyType());
continue;
}
palavras = campanha.keywords().withCondition('Status = ENABLED').forDateRange("YESTERDAY").get();
while(palavras.hasNext()) {
palavra = palavras.next();
estatisticas = palavra.getStatsFor('YESTERDAY');
lances = palavra.bidding();
estimativa_primeira = Math.max(palavra.getTopOfPageCpc(), palavra.getFirstPageCpc());
posicao = estatisticas.getAveragePosition();
if (posicao > 1) {
Logger.log(palavra.getText() +" = " +" "+palavra.getTopOfPageCpc()+" "+palavra.getFirstPageCpc());
}
//Logger.log(palavra.getText() + ' = '+lances.getCpc()+" = "+estatisticas.getAveragePosition());
}
}
I expected to retrieve the estimated first page CPC and estimated first position CPC. But the values that I received are diferente from the AdWords webinterface. For exemple, for a given keyword the script returned +xxx +yyyy = 0.12 0.05, when I look those keywords on webinterface I have the following values for 0.12 for estimated first page CPC and 0.41 for estimated first position CPC.
I want to set an Hyperlink in a table cell:
/* ADD TABLE ROW */
foreach ($entries as $entry) {
$row = $tableShape->createRow();
$row->getFill()->setFillType(Fill::FILL_SOLID)
->setStartColor(new Color('FFFFFFFF'))
->setEndColor(new Color('FFFFFFFF'));
$row->nextCell()->createTextRun(date_format($entry->getDate(), "d.m.Y"));
$row->nextCell()->createTextRun($entry->getTonality()->getName());
$row->nextCell()->createTextRun($entry->getAccountname());
$row->nextCell()->createTextRun($entry->getContent());
$row->nextCell()->createTextRun($entry->getFollower());
$row->nextCell()->createTextRun($entry->getLink());
}
This code doesn't work:
$row->nextCell()->createTextRun('Link')->setUrl($entry->getLink())
->setTooltip('Link');;
I'm doing it now by adding a shape on the right position.
/* SET HYPERLINK WITH SHAPE */
$shape = $slide->createRichTextShape();
$shape->setWidth($this->cell_link_width)
->setHeight($this->cell_height)
->setOffsetX($this->cell_link_offsetX)
>setOffsetY($this->tableOffsetY + $height);
$textLink = $shape->createTextRun('Link');
$textLink->getHyperlink()->setUrl('http://' . $entry->getLink())
>setTooltip('http://' . $entry->getLink());
I have write an algorithmus and define a variable line_height to set the link on the right position.
Here is my complete function:
public function createTableSlide($objPHPPowerPoint, $pathLogo, $user, $entries) {
$slide = $this->createTemplatedSlide($objPHPPowerPoint, $pathLogo, $user);
/* CREATE TABLE WITH COLUMNS */
$tableShape = $this->getTable($slide, 6);
$this->setTableSlideHeader($slide, 'Social Media', 'Twitter', $tableShape);
/* ADD TABLE ROW */
$i = 1;
$height = 22;
$height_tmp = 0;
$max_height = 554;
foreach ($entries as $entry) {
$height += $height_tmp;
$modulId = $entry->getModul()->getId();
/* NEW SLIDE IF TABLE HEIGHT AT END OF SLIDE */
if($height >= $max_height){
$slide = $this->createTemplatedSlide($objPHPPowerPoint, $pathLogo, $user);
/* CREATE TABLE WITH COLUMNS */
$tableShape = $this->getTable($slide, 6);
$this->setTableSlideHeader($slide, 'Social Media', 'Twitter', $tableShape);
$i = 1;
$height = 22;
$height_tmp = 0;
}
$row_in_cell = ceil(strlen($entry->getContent()) / $this->char_in_row);
if ($row_in_cell > 2) {
$height_tmp = $row_in_cell * $this->line_height + $this->line_height;
} else {
$height_tmp = $this->line_height * 3 + 0.8;
}
$row = $tableShape->createRow();
$row->setHeight($this->cell_height);
$row->getFill()->setFillType(Fill::FILL_SOLID)
->setStartColor(new Color('FFFFFFFF'))
->setEndColor(new Color('FFFFFFFF'));
$row->nextCell()->createTextRun(date_format($entry->getDate(), "d.m.Y"));
$row->nextCell()->createTextRun($entry->getTonality()->getName());
$row->nextCell()->createTextRun($entry->getAccountname());
$row->nextCell()->createTextRun($entry->getContent());
$row->nextCell()->createTextRun($entry->getFollower());
$row->nextCell()->createTextRun($modulId);
/* SET HYPERLINK WITH SHAPE */
$shape = $slide->createRichTextShape();
$shape->setWidth($this->cell_link_width)
->setHeight($this->cell_height)
->setOffsetX($this->cell_link_offsetX)
->setOffsetY($this->tableOffsetY + $height);
$textLink = $shape->createTextRun('Link');
$textLink->getHyperlink()->setUrl('http://' . $entry->getLink())
->setTooltip('http://' . $entry->getLink());
$i++;
}
}
Hope it can help you if you search for the same solution. If anyone has a better solution he can answer me :)
The issue has been fixed in the develop branch.
Link : https://github.com/PHPOffice/PHPPowerPoint/commit/43bea92220396a3c7178f649afbc961be28828c1
I am working on an extended Textarea like http://podio.github.com/jquery-mentions-input/
There you can see a transparent Textarea with an element in background simulating the highlighting.
You can see the problem there also: type some long text like "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii " (attention to space at the end)
and then type "#ke" and choose first contact.
You will see that the background breaks different than the text in the textarea.
I figured out that this is not because different sizes!
Any ideas how to avoid that?
P.S.: I dont want to you contentediable.
For testing i used chrome (test with points!) and firefox.
I think this technic is also used often for auto-calculating a textarea-hight and they must have the same problems?!
I found a different solution myself: count line-breaks manually.
I modified and improved the line-break-adder from this thread: finding "line-breaks" in textarea that is word-wrapping ARABIC text
The big difference: this function only retrieves the breaked value without applying the breaks cause it used a temporary element copy.
I think it could help someone else!
function getApplyLineBreaks(strTextAreaId)
{
var strRawValue = $('#' + strTextAreaId).val();
var measureClone = $('#' + strTextAreaId).clone();
measureClone.attr('id', 'value_break_mess_clone');
measureClone.val('');
measureClone.css('overflow', 'hidden');
measureClone.removeAttr('onchange').removeAttr('onclick').removeAttr('onkeydown').removeAttr('onkeyup').removeAttr('onblur').removeAttr('onfocus');
measureClone.height(10);
measureClone.insertAfter('#' + strTextAreaId);
var lastScrollWidth = measureClone[0].scrollWidth;
var lastScrollHeight = measureClone[0].scrollHeight;
var lastWrappingIndex = -1;
var tolerancePixels = 5; //sollte kleiner als font-size
var addedSpace = false;
var debug_c = 0;
for (var i = 0; i < strRawValue.length; i++)
{
var curChar = strRawValue.charAt(i);
if (curChar == ' ' || curChar == '-' || curChar == '+')
lastWrappingIndex = i;
measureClone.val(measureClone.val() + curChar);
addedSpace = false;
if (i != strRawValue.length - 1 && strRawValue.charAt(i + 1) != "\n")
{
measureClone.val(measureClone.val() + ' '); //this is only 90% zero-width breaker unnoticed
addedSpace = true;
}
if (((measureClone[0].scrollWidth - tolerancePixels) > lastScrollWidth) || ((measureClone[0].scrollHeight - tolerancePixels) > lastScrollHeight))
{
if (addedSpace)
measureClone.val(measureClone.val().substr(0, measureClone.val().length - 1));
var buffer = "";
if (lastWrappingIndex >= 0)
{
for (var j = lastWrappingIndex + 1; j < i; j++)
buffer += strRawValue.charAt(j);
lastWrappingIndex = -1;
}
buffer += curChar;
measureClone.val(measureClone.val().substr(0, measureClone.val().length - buffer.length));
if (curChar == "\n")
{
if (i == strRawValue.length - 1)
measureClone.val(measureClone.val() + buffer + "\n");
else
measureClone.val(measureClone.val() + buffer);
}
else
{
measureClone.val(measureClone.val() + "\n" + buffer);
}
lastScrollHeight = measureClone[0].scrollHeight;
}
else if (addedSpace)
{
measureClone.val(measureClone.val().substr(0, measureClone.val().length - 1));
}
}
var returnText = measureClone.val();
measureClone.remove();
return returnText;
}
Only thing: its slow on long texts. Ideas for optimization are welcome.