Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


6 Pages«<3456>
Options
Go to last post Go to first unread
Offline Alex M.  
#81 Posted : 09 February 2016 08:14:50(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

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

Offline Alex M.  
#82 Posted : 09 February 2016 09:45:10(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

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).
Offline Davide Carpi  
#83 Posted : 09 February 2016 11:04:01(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,647
Man
Italy
Location: Italy

Was thanked: 1329 time(s) in 875 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 Go to Quoted Post
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 Go to Quoted Post
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
Offline uni  
#84 Posted : 09 February 2016 11:12:10(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,494
Man
Russian Federation

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
thanks 2 users thanked uni for this useful post.
on 09/02/2016(UTC),  on 09/02/2016(UTC)
Offline Alex M.  
#85 Posted : 10 February 2016 08:58:30(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
Originally Posted by: uni Go to Quoted Post
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..

Offline Alex M.  
#86 Posted : 10 February 2016 09:00:52(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

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

thanks 1 user thanked Alex M. for this useful post.
on 11/02/2016(UTC)
Offline Davide Carpi  
#87 Posted : 11 February 2016 01:36:25(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,647
Man
Italy
Location: Italy

Was thanked: 1329 time(s) in 875 post(s)
Nice Good

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
Offline kilele  
#88 Posted : 11 February 2016 02:35:41(UTC)
kilele


Rank: Advanced Member

Groups: Registered
Joined: 30/03/2011(UTC)
Posts: 393

Was thanked: 132 time(s) in 113 post(s)
Hi all. Sorry if this is off-topic Good
You may have already tried these .Net components to display SVG:
https://lasithapetthawad...r-svg-graphics-in-c-net/
https://github.com/vvvv/SVG
http://www.codeproject.c...Reloaded-An-Introduction
A dirty alternative could be saving drawings in psd format and displaying them in Smath by means of a conversion process transparent to the user.
Thanks.
Offline Alex M.  
#89 Posted : 11 February 2016 05:54:03(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
Originally Posted by: kilele Go to Quoted Post
Hi all. Sorry if this is off-topic Good
You may have already tried these .Net components to display SVG:
https://lasithapetthawad...r-svg-graphics-in-c-net/
https://github.com/vvvv/SVG
http://www.codeproject.c...Reloaded-An-Introduction
A dirty alternative could be saving drawings in psd format and displaying them in Smath by means of a conversion process transparent to the user.
Thanks.


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.
Offline Alex M.  
#90 Posted : 11 February 2016 05:59:09(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
Originally Posted by: Davide Carpi Go to Quoted Post
Nice Good

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).
thanks 1 user thanked Alex M. for this useful post.
on 11/02/2016(UTC)
Offline Alex M.  
#91 Posted : 12 February 2016 06:30:28(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

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
Offline Jean Giraud  
#92 Posted : 12 February 2016 07:00:02(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Alex,

Can you rotate this image by some degree [let say 30].

Jean

Rotate Image Test Alex.sm (246kb) downloaded 39 time(s).
thanks 1 user thanked Jean Giraud for this useful post.
on 12/02/2016(UTC)
Offline Davide Carpi  
#93 Posted : 12 February 2016 10:52:46(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,647
Man
Italy
Location: Italy

Was thanked: 1329 time(s) in 875 post(s)
Originally Posted by: Alex.M Go to Quoted Post
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
thanks 1 user thanked Davide Carpi for this useful post.
on 12/02/2016(UTC)
Offline Alex M.  
#94 Posted : 12 February 2016 18:56:48(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
Alex,

Can you rotate this image by some degree [let say 30].

Jean

Rotate Image Test Alex.sm (246kb) downloaded 39 time(s).


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.
Offline Davide Carpi  
#95 Posted : 12 February 2016 19:02:16(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,647
Man
Italy
Location: Italy

Was thanked: 1329 time(s) in 875 post(s)
Originally Posted by: Alex.M Go to Quoted Post
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
Offline Alex M.  
#96 Posted : 12 February 2016 19:39:35(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
Originally Posted by: Davide Carpi Go to Quoted Post
Originally Posted by: Alex.M Go to Quoted Post
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.
Offline Alex M.  
#97 Posted : 12 February 2016 19:44:02(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
Originally Posted by: Davide Carpi Go to Quoted Post
Originally Posted by: Alex.M Go to Quoted Post
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

Offline Jean Giraud  
#98 Posted : 13 February 2016 05:58:59(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: Alex.M Go to Quoted Post
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).

Offline Jean Giraud  
#99 Posted : 13 February 2016 07:00:33(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

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).
Offline Alex M.  
#100 Posted : 13 February 2016 09:00:18(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
... 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!
Users browsing this topic
Guest
Similar Topics
Editable Image Region - Plugin Update (Extensions)
by Alex M. 14/02/2016 09:46:23(UTC)
6 Pages«<3456>
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.