Exemplo n.º 1
0
    public void OnCanvasDelete()
    {
        mypaint_release();

        mypaint_initWithImageSize(canvasWidth, canvasHeight);          //initialize mypaint drawing alogrithm

        mypaint_setColor(sandColor.r, sandColor.g, sandColor.b);
        OnToolChange(currentTool);

        //get image buffer
        System.IntPtr img = mypaint_getCanvas();

        const int tileSizePixel = 64;
        int       tileWidth     = Mathf.CeilToInt((float)canvasWidth / tileSizePixel);
        int       tileHeight    = Mathf.CeilToInt((float)canvasHeight / tileSizePixel);

        int tileSize   = tileSizePixel * tileSizePixel * 4;      // * sizeof(System.UInt16);
        int bufferSize = tileWidth * tileHeight * tileSize;

        if (buffer == null)
        {
            buffer = new short[bufferSize];
        }


        Marshal.Copy(img, buffer, 0, bufferSize);
        //end of getting image buffer

        //Set all alpha chanel of buffer to 0
        for (int i = 0; i < buffer.Length; i += 4)
        {
            buffer[i]     = short.MaxValue;
            buffer[i + 1] = short.MaxValue;
            buffer[i + 2] = short.MaxValue;
            buffer[i + 3] = 0;
        }
        mypaint_setCanvas(buffer.Clone() as short[]);


        //set color of unity side texture to white
        for (int i = 0; i < canvasWidth; i++)
        {
            for (int j = 0; j < canvasHeight; j++)
            {
                texture.SetPixel(i, j, new Color(1.0f, 1.0f, 1.0f, 0f));
            }
        }



        //undo,redo clear
        undoStack.Clear();
        Texture2D deepCopiedTex = Instantiate(texture) as Texture2D;

        short[] deepCopiedBuf = buffer.Clone() as short[];
        undoStack.Push(new CanvasSnapshot(deepCopiedTex, deepCopiedBuf));         //todo getcanvas
        redoStack.Clear();

        texture.Apply(false);
    }
Exemplo n.º 2
0
 public void OnAfterDeserialize()
 {
     stack.Clear();
     for (var i = values.Count - 1; i > -1; i--)
     {
         if (!stack.Contains(values[i]))
         {
             stack.Push(values[i]);
         }
     }
 }
Exemplo n.º 3
0
    public void OnCanvasUp()
    {
        mypaint_draw_end();

        //TODO limit maximum number of undo

        //Do deep copy
        Texture2D deepCopiedTex = Instantiate(texture) as Texture2D;

        short[] deepCopidedBuf = buffer.Clone() as short[];

        //push current canvas image to undo stack
        undoStack.Push(new CanvasSnapshot(deepCopiedTex, deepCopidedBuf));

        //clear redo stack
        redoStack.Clear();
    }
Exemplo n.º 4
0
        public void FirstPage()
        {
            NextPartitionKey = FirstPartitionKey;
            NextRowKey       = FirstRowKey;

            stack.Clear();
            this.NextPage();
        }
Exemplo n.º 5
0
    public void OnCanvasUp()
    {
        Debug.Log("OnCanvasUp");
        mypaint_draw_end();

        // notify the change of color to palette
        palette target = GameObject.Find("pallete").GetComponent <palette>();

        target.OnPaintAdd(currentColor);

        //TODO limit maximum number of undo

        //Do deep copy
        Texture2D deepCopiedTex = Instantiate(texture) as Texture2D;

        short[] deepCopidedBuf = buffer.Clone() as short[];

        //push current canvas image to undo stack
        undoStack.Push(new CanvasSnapshot(deepCopiedTex, deepCopidedBuf));

        //clear redo stack
        redoStack.Clear();
    }
Exemplo n.º 6
0
        private void GetAttachmentsFromConversation(MailItem mailItem)
        {
            if (mailItem == null)
            {
                return;
            }

            if (mailItem.Attachments.CountNonEmbeddedAttachments() > 0)
            {
                return;
            }

            System.Collections.Generic.Stack <MailItem> st = new System.Collections.Generic.Stack <MailItem>();

            // Determine the store of the mail item.
            Outlook.Folder folder = mailItem.Parent as Outlook.Folder;
            Outlook.Store  store  = folder.Store;
            if (store.IsConversationEnabled == true)
            {
                // Obtain a Conversation object.
                Outlook.Conversation conv = mailItem.GetConversation();
                // Check for null Conversation.
                if (conv != null)
                {
                    // Obtain Table that contains rows
                    // for each item in the conversation.
                    Outlook.Table table = conv.GetTable();
                    _logger.Debug("Conversation Items Count: " + table.GetRowCount().ToString());
                    _logger.Debug("Conversation Items from Root:");

                    // Obtain root items and enumerate the conversation.
                    Outlook.SimpleItems simpleItems = conv.GetRootItems();
                    foreach (object item in simpleItems)
                    {
                        // In this example, enumerate only MailItem type.
                        // Other types such as PostItem or MeetingItem
                        // can appear in the conversation.
                        if (item is Outlook.MailItem)
                        {
                            Outlook.MailItem mail     = item as Outlook.MailItem;
                            Outlook.Folder   inFolder = mail.Parent as Outlook.Folder;
                            string           msg      = mail.Subject + " in folder [" + inFolder.Name + "] EntryId [" + (mail.EntryID.ToString() ?? "NONE") + "]";
                            _logger.Debug(msg);
                            _logger.Debug(mail.Sender);
                            _logger.Debug(mail.ReceivedByEntryID);

                            if (mail.EntryID != null && (mail.Sender != null || mail.ReceivedByEntryID != null))
                            {
                                st.Push(mail);
                            }
                        }
                        // Call EnumerateConversation
                        // to access child nodes of root items.
                        EnumerateConversation(st, item, conv);
                    }
                }
            }

            while (st.Count > 0)
            {
                MailItem it = st.Pop();

                if (it.Attachments.CountNonEmbeddedAttachments() > 0)
                {
                    //_logger.Debug(it.Attachments.CountNonEmbeddedAttachments());

                    try
                    {
                        if (mailItem.IsMailItemSignedOrEncrypted())
                        {
                            if (MessageBox.Show(null, "Es handelt sich um eine signierte Nachricht. Soll diese für die Anhänge ohne Zertifikat dupliziert werden?", "Nachricht duplizieren?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                            {
                                mailItem.Close(OlInspectorClose.olDiscard);
                                mailItem = mailItem.Copy();
                                mailItem.Unsign();
                                mailItem.Save();
                                mailItem.Close(OlInspectorClose.olDiscard);
                                mailItem.Save();
                            }
                            else
                            {
                                st.Clear();
                                break;
                            }
                        }

                        mailItem.CopyAttachmentsFrom(it);
                        mailItem.Save();
                    }
                    catch (System.Exception ex)
                    {
                        //mailItem.Close(OlInspectorClose.olDiscard);
                        MessageBox.Show(ex.Message);
                    }

                    st.Clear();
                }
            }
            st.Clear();

            Marshal.ReleaseComObject(mailItem);
        }
Exemplo n.º 7
0
 private void NavigateClear()
 {
     _history.Clear();
     __navBack.Enabled = false;
     __navUp.Enabled   = false;
 }
Exemplo n.º 8
0
 public void Clear()
 {
     _stack.Clear();
 }