Rank: Advanced Member Groups: Registered
Joined: 03/03/2014(UTC) Posts: 418 Was thanked: 125 time(s) in 96 post(s)
|
EDIT not tested, but should works: Code: MenuButton FileType = new MenuButton("File Type");
string[] extension = new string[] { "*.png", "*.svg", "*.psd", "*.pdf", "*.dxf", "*.dwg" };
for (int i = 0; i < extension.Length; i++)
{
FileType.AppendChild(extension[0], delegate(MenuButtonArgs args)
{
((ImageEdit.ImageRegion)args.CurrentRegion).GetCanvas().select_ext = extension[i];
});
if (((ImageEdit.ImageRegion)args.CurrentRegion).GetCanvas().select_ext == extension[i])
FileType.Children[i].Checked = true;
}
For some reason I could not run this line (with text "args" being highlighted as an error: Code:if (((ImageEdit.ImageRegion)args.CurrentRegion).GetCanvas().select_ext == extension[i])
I did a workaround: Code:MenuButton FileType = new MenuButton("File Type");
string[] extension = new string[] { "*.png", "*.svg", "*.psd", "*.pdf", "*.dxf", "*.dwg" };
string chck = "*.png";
for (int i = 0; i < extension.Length; i++)
{
FileType.AppendChild(extension[i], delegate(MenuButtonArgs args)
{
((ImageEdit.ImageRegion)args.CurrentRegion).GetCanvas().select_ext = extension[i];
chck = ((ImageEdit.ImageRegion)args.CurrentRegion).GetCanvas().select_ext;
});
if (chck == extension[i])
FileType.Children[i].Checked = true;
}
And it did not work - as soon as I click on one of the file extension menu items I get "Index was outside the bounds of the array". Okay, the code works now. The only hiccup is that I cannot reference any of my variables defined in Code:namespace ImageEdit
{
class ImageCanvas : RegionEvaluable
Which is an upset. I am sure I am missing something basic Ughh... So now if I click on one of the menu items, it remembers my section for the next blank region I insert. Bummer Edited by user 09 February 2016 08:48:43(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 03/03/2014(UTC) Posts: 418 Was thanked: 125 time(s) in 96 post(s)
|
Implemented in-memory image rotation. Mildly useful when you need to fit landscape image to a portrait page without altering the source file. Still cannot make checkmarks for context menu items work. ImageRegion.009.zip (75kb) downloaded 38 time(s).
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,648 Location: Italy Was thanked: 1331 time(s) in 876 post(s)
|
Sorry, previous code was made on the fly, this is tested: Code: ImageCanvas canvas = ((ImageRegion)context.CurrentRegions[0]).GetCanvas();
MenuButton FileType = new MenuButton("Blank File Type");
string[] extension = new string[] { "*.png", "*.svg", "*.psd", "*.pdf", "*.dxf", "*.dwg" };
for (int i = 0; i < extension.Length; i++)
{
FileType.AppendChild(extension[i], delegate(MenuButtonArgs args)
{
ImageCanvas c = ((ImageRegion)args.CurrentRegion).GetCanvas();
c.select_ext = (string)args.MenuButton.Data;
});
FileType.Children[i].Data = extension[i];
if (canvas.select_ext == extension[i])
FileType.Children[i].Checked = true;
}
Originally Posted by: Alex.M The workflow for image type selection is:
1. Select the extension (.png is preselected) 2. Double click empty region 3. Blank file will be created on the fly (if no file exists already)
It might make more sense to rename the button to Blank File Type. I think could be hidden (not added in MenuButton[] contextMenuItems) if an external image is already loaded Originally Posted by: Alex.M Also do you think that "open with" on double click is better than open? Sounds like extra step.. May be added as another option ("Open with...") - obviously if that code works Edited by user 10 February 2016 01:39:21(UTC)
| Reason: code updated for multiple selections |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 10/11/2010(UTC) Posts: 1,494 Was thanked: 1274 time(s) in 745 post(s)
|
Alex, ask Andrey make access to the repository. It is possible to change access permissions to plugin. You will be able to make changes and we can watch for this. |
Russia ☭ forever Viacheslav N. Mezentsev |
2 users thanked uni for this useful post.
|
on 09/02/2016(UTC), on 09/02/2016(UTC)
|
|
Rank: Advanced Member Groups: Registered
Joined: 03/03/2014(UTC) Posts: 418 Was thanked: 125 time(s) in 96 post(s)
|
Originally Posted by: uni Alex, ask Andrey make access to the repository. It is possible to change access permissions to plugin. You will be able to make changes and we can watch for this. Will do! Once Its more or less ready to go..
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 03/03/2014(UTC) Posts: 418 Was thanked: 125 time(s) in 96 post(s)
|
All done for OpenAs and disabling file type once file exists. I had to butcher up the code to get OpenAs to work (converting "create file" and "open" to two separate functions that are called by double clicking or context menu Open As...) so there might be some new bugs. ImageRegion.011.zip (79kb) downloaded 34 time(s).Edited by user 10 February 2016 20:06:56(UTC)
| Reason: Not specified
|
1 user thanked Alex M. for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,648 Location: Italy Was thanked: 1331 time(s) in 876 post(s)
|
Nice I think the text of "Open as..." would be better as "Open with..." I noticed also that the end of the resize logic should be improved; maybe something like this: Code: private bool IsResizing;
// ...
public override void OnMouseDown(MouseEventArgs e)
{
if (this.GetCursorType(e) != CursorType.Arrow)
{
this.IsResizing = true;
// ...
}
// ...
}
public override void OnMouseUp(MouseEventArgs e)
{
if (this.IsResizing)
{
this.IsResizing = false;
// Update logic
// ...
this.Invalidate();
}
// ...
}
Edited by user 11 February 2016 01:38:18(UTC)
| Reason: Not specified |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 30/03/2011(UTC) Posts: 393
Was thanked: 132 time(s) in 113 post(s)
|
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 03/03/2014(UTC) Posts: 418 Was thanked: 125 time(s) in 96 post(s)
|
Originally Posted by: kilele Not offtopic at all :-) Original image region uses "SharpVectors" library, which seems not to be able to support document scaling for svg files that contain width/height parameters. I use "SVG" library, which scales great, but has its own documented bug. You cannot render bitmaps larger than ~100 kB that are included in SVG file. Which is OK, considering SVG is for vector graphics.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 03/03/2014(UTC) Posts: 418 Was thanked: 125 time(s) in 96 post(s)
|
Originally Posted by: Davide Carpi Nice I think the text of "Open as..." would be better as "Open with..." I noticed also that the end of the resize logic should be improved; maybe something like this: Code: private bool IsResizing;
// ...
public override void OnMouseDown(MouseEventArgs e)
{
if (this.GetCursorType(e) != CursorType.Arrow)
{
this.IsResizing = true;
// ...
}
// ...
}
public override void OnMouseUp(MouseEventArgs e)
{
if (this.IsResizing)
{
this.IsResizing = false;
// Update logic
// ...
this.Invalidate();
}
// ...
}
I incorporated your suggestion and than some :-) Now scaling / rotation works as expected. BTW I have also somewhat documented / cleaned up my code. Please take a look - this is how it will go to the SVN (after I disable/comment out pdf/dxf/dwg support). ImageRegion.012.zip (76kb) downloaded 32 time(s).
|
1 user thanked Alex M. for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 03/03/2014(UTC) Posts: 418 Was thanked: 125 time(s) in 96 post(s)
|
Davide, is there a way to get indicate to Smath that image has changed (rotated) and workbook must be saved before closing? Right know if you rotate the image and close the workbook no prompt comes up to save the .sm file
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
|
1 user thanked Jean Giraud for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,648 Location: Italy Was thanked: 1331 time(s) in 876 post(s)
|
Originally Posted by: Alex.M Davide, is there a way to get indicate to Smath that image has changed (rotated) and workbook must be saved before closing? Right know if you rotate the image and close the workbook no prompt comes up to save the .sm file Hello Alex, sure, you have to implement your own HistoryStep class that extends the built-in HistoryStepBase; Look for example the NumericUpDownRegion- The core: NumericUpDownHistoryStep.cs- In the region holder: Code: // ...
public override HistoryStepBase GetHistoryStep()
{
return new NumericUpDownHistoryStep(this);
}
// ...
- After you change a property: Code:this.CreateHistoryStep("...");
Edited by user 12 February 2016 15:42:07(UTC)
| Reason: Not specified |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
1 user thanked Davide Carpi for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 03/03/2014(UTC) Posts: 418 Was thanked: 125 time(s) in 96 post(s)
|
Originally Posted by: Jean Giraud Jean, image region will not rotate the image in the exposed to the user matrix manipulation way. It rotates the image using built in .NET command, and can only do it in 90 degree increments.
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,648 Location: Italy Was thanked: 1331 time(s) in 876 post(s)
|
Originally Posted by: Alex.M Jean, image region will not rotate the image in the exposed to the user matrix manipulation way. It rotates the image using built in .NET command, and can only do it in 90 degree increments. You can use the built-in RotateTransform (look at the accepted answer here); as for the context menu, can be handled like "line spacing" for WriterRegions - and if you want you can keep the old code for the existing values) Edited by user 12 February 2016 19:05:24(UTC)
| Reason: Not specified |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 03/03/2014(UTC) Posts: 418 Was thanked: 125 time(s) in 96 post(s)
|
Originally Posted by: Davide Carpi Originally Posted by: Alex.M Davide, is there a way to get indicate to Smath that image has changed (rotated) and workbook must be saved before closing? Right know if you rotate the image and close the workbook no prompt comes up to save the .sm file Hello Alex, sure, you have to implement your own HistoryStep class that extends the built-in HistoryStepBase; Look for example the NumericUpDownRegion- The core: NumericUpDownHistoryStep.cs- In the region holder: Code: // ...
public override HistoryStepBase GetHistoryStep()
{
return new NumericUpDownHistoryStep(this);
}
// ...
- After you change a property: Code:this.CreateHistoryStep("...");
Thank you Davide, I take I should reference the .is file you provided before using this code.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 03/03/2014(UTC) Posts: 418 Was thanked: 125 time(s) in 96 post(s)
|
Originally Posted by: Davide Carpi Originally Posted by: Alex.M Jean, image region will not rotate the image in the exposed to the user matrix manipulation way. It rotates the image using built in .NET command, and can only do it in 90 degree increments. You can use the built-in RotateTransform (look at the accepted answer here); as for the context menu, can be handled like "line spacing" for WriterRegions - and if you want you can keep the old code for the existing values) Davide, I did come across a few options on how to rotate the image by X degrees. I did, however, decide that this functionality would be outside of the scope for the goal I was trying to achieve. The intended functionality of the rotation is to fit landscape image on a portrait page without rotating it in the editor. Everything else can be done in the editor. Edited by user 12 February 2016 19:45:52(UTC)
| Reason: Not specified
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
Originally Posted by: Alex.M Originally Posted by: Davide Carpi [/url]Originally Posted by: Alex.M Jean, image region will not rotate the image in the exposed to the user matrix manipulation way. It rotates the image using built in .NET command, and can only do it in 90 degree increments. You can use the built-in RotateTransform (look at the accepted answer [url=http://stackoverflow.com/questions/14184700/how-to-rotate-image-x-degrees-in-c]here); as for the context menu, can be handled like "line spacing" for WriterRegions - and if you want you can keep the old code for the existing values) ___________________________ Thanks Alex. I have the Smath simple coding to rotate ± 90 and -180 [mirror} For the degree rotation the coding you give in reference is above my competence. In lieu, I have the Mathcad bilinear working perfect gray, RGB in Mathcad . The very last part Mathcad "on error" is problem in Smath. I have attempted many coding, not to avail. Attached the two sheets, the first to comfort the working code is "sanity" Next work sheet is then in limbo. Cheers Collabs. Jean Rotate Image Sanity.sm (297kb) downloaded 33 time(s). Rotate Image.sm (431kb) downloaded 32 time(s).
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
... forgot to attach rot ± 90, -180 [mirror] & inverse grayscale jean Rotate Image Test Alex.sm (271kb) downloaded 42 time(s).
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 03/03/2014(UTC) Posts: 418 Was thanked: 125 time(s) in 96 post(s)
|
Originally Posted by: Jean Giraud ... forgot to attach rot ± 90, -180 [mirror] & inverse grayscale jean Rotate Image Test Alex.sm (271kb) downloaded 42 time(s). It is pretty impressive what you can achieve with matrix manipulations, Jean. Keep it up!
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.