Related
paint shape 1, but paint shape 2 , shape 1 is clear ..
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
Ismousedown = true;
LocationXY = e.Location;
mousedownR = (int)(Math.Round(Math.Sqrt(Math.Pow(LocationXY.X - 250, 2) + Math.Pow(LocationXY.Y - 250, 2)), 2));
// label2.Text = mousedownstarAngle.ToString();
if (e.X >= 250)
{
gocanphal = (int)(270 - Math.Round(180 * -Math.Asin((e.Y - 250) / Math.Sqrt(Math.Pow(250 - e.X, 2) + Math.Pow(e.Y - 250, 2))) / Math.PI, 2));
}
if (e.X < 250)
{
gocanphal = (int)(90 + Math.Round(180 * (-Math.Asin((e.Y - 250) / Math.Sqrt(Math.Pow(250 - e.X, 2) + Math.Pow(e.Y - 250, 2)))) / Math.PI, 2));
}
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (Ismousedown == true)
{
LocationX1Y1 = e.Location;
if (e.X >= 250)
{
gocmo = (int)(270 - Math.Round(180 * -Math.Asin((LocationX1Y1.Y - 250) / Math.Sqrt(Math.Pow(250 - LocationX1Y1.X, 2) + Math.Pow(LocationX1Y1.Y - 250, 2))) / Math.PI, 2));
}
if (e.X < 250)
{
gocmo = (int)(90 + Math.Round(180 * -Math.Asin((LocationX1Y1.Y - 250) / Math.Sqrt(Math.Pow(250 - LocationX1Y1.X, 2) + Math.Pow(LocationX1Y1.Y - 250, 2))) / Math.PI, 2));
}
Refresh();
mouseupR = (int)(Math.Round(Math.Sqrt(Math.Pow(LocationX1Y1.X - 250, 2) + Math.Pow(LocationX1Y1.Y - 250, 2)), 2));
}
}
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
if (Ismousedown == true)
{
LocationX1Y1 = e.Location;
Ismousedown = false;
mouseupR = (int)(Math.Round(Math.Sqrt(Math.Pow(e.X - 250, 2) + Math.Pow(e.Y - 250, 2)), 2));
}
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawLine(penn, 250, 250, 250, 0);
var g = e.Graphics;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
var center = new Point(250, 250);
var innerR = mouseupR;// xa or gan diem dau
//var thickness = 30;// do day
var startAngle1 = gocanphal + 90;// diem bat dau
var arcLength1 = gocmo - gocanphal;// diem end
var outerR = mousedownR;
// var innerR = mousedownR - mouseupR;
var outerRect = new Rectangle
(center.X - outerR, center.Y - outerR, 2 * outerR, 2 * outerR);//center.Y - outerR
var innerRect = new Rectangle
(center.X - innerR, center.Y - innerR, 2 * innerR, 2 * innerR); // center.X - innerR
// using (var p = new GraphicsPath())
e.Graphics.FillEllipse(Brushes.White, 150, 150, 5, 5);
GraphicsPath p = new GraphicsPath();
p.AddArc(outerRect, startAngle1, arcLength1);
p.AddArc(innerRect, startAngle1 + arcLength1, -arcLength1);
p.CloseFigure();
g.DrawPath(Pens.Blue, p);
}
}
}
Want to draw more pictures and save
I have made a custom plugin to always show the tooltips since that was what I needed.
The only thing I would like to have now is a on-hover action.
const alwaysShowTooltipPlugin = {
id: 'alwaysShowTooltip',
onHover: function (evt, item, legend) {
console.log('hovered')
},
afterDraw(chart, args, options) {
const { ctx } = chart
ctx.save()
chart.data.datasets.forEach((dataset, i) => {
chart.getDatasetMeta(i).data.forEach((datapoint, index) => {
const { x, y } = datapoint.tooltipPosition();
const text = dataset.label
const textWidth = ctx.measureText(text).width
ctx.fillStyle = 'rgba(0, 0, 0, 0.8)'
ctx.fillRect(x - ((textWidth + 20) / 2), y - 40, textWidth + 20, 30)
// Triangle
ctx.beginPath()
ctx.moveTo(x, y )
ctx.lineTo(x - 5, y - 10)
ctx.lineTo(x + 5, y - 10)
ctx.fill()
ctx.restore()
// Text
ctx.font = '14px Arial'
ctx.fillStyle = 'white'
ctx.fillText(text, x - (textWidth / 2), y - 19)
ctx.restore()
})
})
},
}
How can I add a eventListener for a onClick so that I can use the data that was clicked on? The onHover I have currently does not work. It doesn't do anything at all.
I am using Nuxt by the way and Vue-ChartJS latest version.
In my IShellFolder::GetUIObjectOf with riid == IID_IDataObject, I invoke SHCreateDataObject and supply a pointer to my newly created DataObject as such:
DataObject *pDataObject = new DataObject (this->pidl_absolute, uCount, aPidl);
hr = SHCreateDataObject (this->pidl_absolute, uCount, aPidl, pDataObject, riid, ppvReturn);
DataObject::DataObject (PCIDLIST_ABSOLUTE pidlFolder, UINT cidl, LPCITEMIDLIST aPidl[]) : reference_count (0)
{
++DLL_reference_count;
return; // DEFECT: For testing.
In my DataObject::DataObject constructor, I take care not to insert any FORMATETC or STGMEDIUM. Then I start a drag-and-drop operation from an Explorer CDefView window, causing the following call sequence. The drag-loop icon is mostly the "drop-effect-none" circle/slash with small [+] for some windows. For some strange reason, my DataObject::QueryGetData and DataObject::SetData are being invoked with weird arguments (with zero values that should not be zero?). Perhaps I do not understand. How could this be happening when it occurs before I have done anything that could trigger it (I think)? I wrote code to add CFSTR_FILEDESCRIPTORW and CFSTR_FILECONTENTS to my DataObject::DataObject constructor, which did not work, which lead me to this problem.
EDIT:
After a more thorough investigation, I can conclude that my problem is not SHCreateDataObject. I only invoke this function in one place in my code:
hr = SHCreateDataObject (this->pidl_absolute, uCount, aPidl, pDataObject, riid, ppvReturn);
After invocation, there is only one format present in pDataObject: CF_SHELLIDLIST. As #SimonMourier noted, there probably should be more. I manually insert the ones I need, which, ~technically~, I should be able to do, since my NSE is virtual. I can clearly see that during the DoDragDrop() loop, Explorer is invoking my SetData with CF_HDROP with pmedium->hGlobal nullified.
The circle/slash problem no longer exists, as it was due to a bogust ReleaseStgMedium, but the nullifed hGlobal is still present.
DataObject.cpp(584) : atlTraceGeneral - DataObject::SetData : Format = Shell IDList Array // tymed == TYMED_HGLOBAL for both
DataObject.cpp(584) : atlTraceGeneral - DataObject::SetData : Format = UsingDefaultDragImage // tymed == TYMED_HGLOBAL for both
DataObject.cpp(584) : atlTraceGeneral - DataObject::SetData : Format = DragImageBits // tymed == TYMED_HGLOBAL for both
DataObject.cpp(584) : atlTraceGeneral - DataObject::SetData : Format = DragContext // tymed == TYMED_ISTREAM for both
DataObject.cpp(584) : atlTraceGeneral - DataObject::SetData : Format = DragSourceHelperFlags // tymed == TYMED_HGLOBAL for both
DataObject.cpp(584) : atlTraceGeneral - DataObject::SetData : Format = InShellDragLoop // tymed == TYMED_HGLOBAL for both
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = DragContext// tymed == TYMED_ISTREAM
DataObject.cpp(550) : atlTraceGeneral - DataObject::QueryGetData : Format = CF_HDROP // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = FileName // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = Net Resource // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = FileContents // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = FileGroupDescriptor // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = FileNameMapW // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = FileNameMapW // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC (again)
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = Shell IDList Array // tymed == TYMED_HGLOBAL, I return S_OK
DataObject.cpp(584) : atlTraceGeneral - DataObject::SetData : Format = Shell IDList Array // tymed == TYMED_HGLOBAL for both, all other fields of *pmedium are 0!
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = Shell Object Offsets // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = PrinterFriendlyName // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = Shell IDLData Private // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = HTML Format // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = FileNameW // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = FileGroupDescriptorW // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = Preferred DropEffect // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = Performed DropEffect // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = Paste Succeeded // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = UniformResourceLocator // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = InShellDragLoop // tymed == TYMED_HGLOBAL, I return S_OK
DataObject.cpp(584) : atlTraceGeneral - DataObject::SetData : Format = InShellDragLoop pformatetc->tymed == TYMED_HGLOBAL, *pmedium is ~ALL~ ZERO'S!!!, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = DragContext // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = TargetCLSID // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = Embedded Object // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = Object Descriptor // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = NotRecyclable // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = Logical Performed DropEffect // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = Briefcase File Object // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = DropEffectFolderList // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = Autoplay Enumerated IDList Array // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = UniformResourceLocator // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = UniformResourceLocatorW // cfformat == 0, tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(552) : atlTraceGeneral - DataObject::QueryGetData : Format = AsyncFlag // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
DataObject.cpp(608) : atlTraceGeneral - DataObject::EnumFormatEtc
DataObject.cpp(550) : atlTraceGeneral - DataObject::QueryGetData : Format = CF_HDROP // tymed == TYMED_HGLOBAL, I return DV_E_FORMATETC
The thread 0xfc8 has exited with code 0 (0x0).
The thread 0xfa0 has exited with code 0 (0x0).
Exception thrown at 0x000007FEFD11B87D (KernelBase.dll) in explorer.exe: 0x80010108: The object invoked has disconnected from its clients.
DataObject.cpp(461) : atlTraceGeneral - DataObject::GetData : Format = Shell IDList Array pformatetc->tymed == TYMED_HGLOBAL, *pmedium is ~ALL~ ZERO'S!!!, not sure what to do so I lie and return S_OK without doing anything.
DataObject.cpp(461) : atlTraceGeneral - DataObject::GetData : Format = IsShowingText
DataObject.cpp(461) : atlTraceGeneral - DataObject::GetData : Format = UsingDefaultDragImage
DataObject.cpp(461) : atlTraceGeneral - DataObject::GetData : Format = DragSourceHelperFlags
DataObject.cpp(461) : atlTraceGeneral - DataObject::GetData : Format = IsComputingImage
DataObject.cpp(461) : atlTraceGeneral - DataObject::GetData : Format = DisableDragText
DataObject.cpp(461) : atlTraceGeneral - DataObject::GetData : Format = IsComputingImage
DataObject.cpp(461) : atlTraceGeneral - DataObject::GetData : Format = DropDescription
DataObject.cpp(461) : atlTraceGeneral - DataObject::GetData : Format = DragContext
DataObject.cpp(461) : atlTraceGeneral - DataObject::GetData : Format = IsShowingLayered
DataObject.cpp(461) : atlTraceGeneral - DataObject::GetData : Format = UntrustedDragDrop
DataObject.cpp(584) : atlTraceGeneral - DataObject::SetData : Format = DropDescription
DataObject.cpp(584) : atlTraceGeneral - DataObject::SetData : Format = DisableDragText
DataObject.cpp(461) : atlTraceGeneral - DataObject::GetData : Format = DisableDragText
DataObject.cpp(461) : atlTraceGeneral - DataObject::GetData : Format = IsComputingImage
DataObject.cpp(461) : atlTraceGeneral - DataObject::GetData : Format = DropDescription
DataObject.cpp(461) : atlTraceGeneral - DataObject::GetData : Format = IsShowingLayered
DataObject.cpp(584) : atlTraceGeneral - DataObject::SetData : Format = IsShowingLayered
DataObject.cpp(584) : atlTraceGeneral - DataObject::SetData : Format = IsShowingText
The following code shows that SHCreateDataObject injects only one FORMATETC for a filename. My guess is that format is CF_SHELLIDLIST.
#include <ole2.h>
#include <atlbase.h>
#include <Shobjidl.h>
#include <ShlObj.h>
#include <iostream>
using namespace std;
int main()
{
OleInitialize(NULL); // clipboard needs this
CComPtr<IShellItem> item;
SHCreateItemFromParsingName(L"C:\\Windows\\write.exe", NULL, IID_PPV_ARGS(&item));
CComHeapPtr<ITEMID_CHILD> child;
CComHeapPtr<ITEMIDLIST_ABSOLUTE> pidl;
CComQIPtr<IParentAndItem>(item)->GetParentAndItem(&pidl, NULL, &child);
CComPtr<IDataObject> dao;
LPCITEMIDLIST list[1];
list[0] = child;
SHCreateDataObject(pidl, 1, list, NULL, IID_PPV_ARGS(&dao));
OleSetClipboard(dao);
IEnumFORMATETC* pEnumerator = 0;
dao->EnumFormatEtc(DATADIR_GET, &pEnumerator);
unsigned int i = 0;
FORMATETC formatec;
while (S_OK == pEnumerator->Next(1, &formatec, NULL))
++i;
cout << "The number of formats created is: " << i << endl; // ... This printed "1".
OleUninitialize();
return 0;
}
how I'm going to fix the if-statement on line 31. It just don't want to work. I'm using a source code that enables me to easy create 3D objects. Here's the code:
<script src="http://koda.nu/simple3d.js">
ambientLight("white");
var debug = false;
var player = {x: 0, y: 0, z: 500, item: box(0, 0, 500, 200, 200, 1, "red"), speed: 7};
var ball = {x: 0, y: 0, z: -200, item: sphere(0, 0, -200, 100, "yellow"), xSpeed: 0, ySpeed: 0, zSpeed: -15};
var enemy = {x: 0, y: 0, z: -700, item: box(0, 0, -700, 200, 200, 1, "red"), speed: 7};
box(450, 0, -100, 1, 875, 1200, "blue");
box(-450, 0, -100, 1, 875, 1200, "blue");
box(0, 450, -100, 875, 1, 1200, "blue");
box(0, -450, -100, 875, 1, 1200, "blue");
function update() {
if (keyboard.w && player.y < 350) {
player.item.translateY(player.speed);
player.y += player.speed;
}
if (keyboard.s && player.y > -350) {
player.item.translateY(-player.speed);
player.y -= player.speed;
}
if (keyboard.d && player.x < 350) {
player.item.translateX(player.speed);
player.x += player.speed;
}
if (keyboard.a && player.x > -350) {
player.item.translateX(-player.speed);
player.x -= player.speed;
}
/*(This line just don't want to work ---->)*/ if (ball.z == enemy.z) { ball.zSpeed *= -1; }
if (keyboard.shift && keyboard.y) {
debug = true;
}
ball.x += ball.xSpeed;
ball.item.translateX(ball.xSpeed);
ball.y += ball.ySpeed;
ball.item.translateY(ball.ySpeed);
ball.z += ball.zSpeed;
ball.item.translateZ(ball.zSpeed);
while (debug) {
if (keyboard.up) {
moveCameraZ(-player.speed);
}
if (keyboard.down) {
moveCameraZ(player.speed);
}
if (keyboard.left) {
moveCameraX(-player.speed);
}
if (keyboard.right) {
moveCameraX(player.speed);
}
if (keyboard.shift && keyboard.y) {
debug = True;
}
}
}
</script>
your code is very messy, i think it must be instead of { debug = True; } it must be { debug = False; }
I used raphael.js to draw some element's, and now I want to connect them,
how to connect raphael elements with jsplumb ?
For example, in the JSFiddle below : I'm trying to create connections between 2 circles, but I can't, because the circles have no id, my code .
i can't use this :
jsPlumb.connect({source:"id1", target:"id2"})
I finally found a solution to connect raphael elements with jsplumb, I want to thank Mr: # Simon Porritt (jsPlumb creator) for his help: the solution
jsPlumb.ready(function(){
jsPlumb.Defaults.Container = "drawing_board";
// Create a 480 x 640 canvas.
var paper = Raphael('drawing_board');
// of 90 pixels.
var circle1 = paper.circle(140, 110, 90).attr({ fill: '#3D6AA2', stroke: '#000000', 'stroke-width': 8 });
var circle2 = paper.circle(400, 180, 90).attr({ fill: '#3D6AA2', stroke: '#000000', 'stroke-width': 8 });
var rect = paper.rect(50, 280, 90, 70).attr({ fill: '#3D6AA2', stroke: '#000000', 'stroke-width': 8 });
var ellipse = paper.ellipse(300, 420, 90, 70).attr({ fill: '#3D6AA2', stroke: '#000000', 'stroke-width': 8 });
var offsetCalculators = {
"CIRCLE":function(el, parentOffset) {
var cx = parseInt(el.attr("cx"), 10),
cy = parseInt(el.attr("cy"), 10),
r = parseInt(el.attr("r"), 10);
return {
left: parentOffset.left + (cx - r),
top:parentOffset.top + (cy - r)
};
},
"ELLIPSE":function(el, parentOffset) {
var cx = parseInt(el.attr("cx"), 10),
cy = parseInt(el.attr("cy"), 10),
rx = parseInt(el.attr("rx"), 10),
ry = parseInt(el.attr("ry"), 10);
return {
left: parentOffset.left + (cx - rx),
top:parentOffset.top + (cy - ry)
};
},
"RECT":function(el, parentOffset) {
var x = parseInt(el.attr("x"), 10),
y = parseInt(el.attr("y"), 10);
return {
left: parentOffset.left + x,
top:parentOffset.top + y
};
}
};
var sizeCalculators = {
"CIRCLE":function(el) {
var r = parseInt(el.attr("r"), 10);
return [ r * 2, r * 2 ];
},
"ELLIPSE":function(el) {
var rx = parseInt(el.attr("rx"), 10),
ry = parseInt(el.attr("ry"), 10);
return [ rx * 2, ry * 2 ];
},
"RECT":function(el) {
var w = parseInt(el.attr("width"), 10),
h = parseInt(el.attr("height"), 10);
return [ w, h ];
}
};
jsPlumb.CurrentLibrary.getOffset = function(el) {
el = $(el);
var del = el[0], tn = del.tagName.toUpperCase();
if (offsetCalculators[tn]) {
var so = el.parent().offset();
return offsetCalculators[tn](el, so);
}
else
return el.offset();
};
jsPlumb.CurrentLibrary.getSize = function(el) {
el = $(el);
var del = el[0], tn = del.tagName.toUpperCase();
if (sizeCalculators[tn]) {
return sizeCalculators[tn](el);
}
else
return [ el.outerWidth(), el.outerHeight() ];
};
jsPlumb.connect({source:circle1.node, target:circle2.node, anchor:"Center", connector:"Straight"});
jsPlumb.connect({source:circle1.node, target:rect.node, anchors:["Center", "Top"], connector:"Straight"});
jsPlumb.connect({source:circle2.node, target:ellipse.node, anchor:"Center"});
//raphael draggable
var start = function () {
this.ox = this.attr("cx");
this.oy = this.attr("cy");
},
move = function (dx, dy) {
this.attr({cx: this.ox + dx, cy: this.oy + dy});
jsPlumb.repaint(this.node);
},
up = function () { };
paper.set(circle1, circle2).drag(move, start, up); });