Esempio n. 1
0
        private void OpenLibrary()
        {
            OpenMapDialog.RestoreDirectory = true;
            OpenMapDialog.Filter           = "Library(*.dll)|*.dll";
            if (OpenMapDialog.ShowDialog() == DialogResult.OK)
            {
                string filename = Path.GetFileNameWithoutExtension(OpenMapDialog.FileName);
                CurrentLibLbl.Text = OpenMapDialog.FileName;
                CurrentLibrary     = Assembly.LoadFile(OpenMapDialog.FileName);
                try
                {
                    StreamReader s = new StreamReader(CurrentLibrary.GetManifestResourceStream("ImageLibrary.mf"));

                    ImageList l = new ImageList();
                    listView1.SmallImageList = l;
                    listView1.LargeImageList = l;
                    while (!s.EndOfStream)
                    {
                        //LibViewTree.Nodes.Add(s.ReadLine());
                        string[] attributes = (s.ReadLine()).Split(':');
                        string   name       = attributes[0];

                        l.Images.Add(Image.FromStream(CurrentLibrary.GetManifestResourceStream(name)));
                        listView1.Items.Add(new ListViewItem(name, l.Images.Count - 1));
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("This library is incompatible or corrupted.");
                    listView1.Items.Clear();
                }
            }
        }
Esempio n. 2
0
        protected void pTb_ButtonClicked(object sender, Infragistics.WebUI.UltraWebToolbar.ButtonEvent be)
        {
            switch (be.Button.Key.ToLower())
            {
            case "save":
                if (Shared.SessionState.User.HasCapability(Business.CapabilitiesEnum.MANAGE_RESOURCES))
                {
                    if (Shared.SessionState.User.IsReadOnly)
                    {
                        return;
                    }

                    if (txtResourceNameValue.Text == null || txtResourceNameValue.Text.Length == 0)
                    {
                        SetMessage(propertiesMsgLbl, "Resource must have a name", MessageLevel.Error);
                        break;
                    }
                    string[][] attrs = new string[1][];

                    try
                    {
                        HyperCatalog.Business.DAM.Resource newResource = CurrentLibrary.AddResource(txtResourceNameValue.Text + Path.GetExtension(txtFileBinaryValue.PostedFile.FileName), txtResourceDescriptionValue.Value, Convert.ToInt32(txtResourceTypeValue.SelectedValue), HyperCatalog.Shared.SessionState.MasterCulture.Code, txtFileBinaryValue.PostedFile.InputStream, attrs);
                        LoadGrid();
                    }
                    catch (Exception ex)
                    {
                        SetMessage(propertiesMsgLbl, "InValid file format. Please select the correct file.", MessageLevel.Error);
                        LoadGrid();
                        break;
                    }
                }
                break;
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Forces the last current library to update the image data.
 /// </summary>
 public void Update()
 {
     if (CurrentLibrary != null)
     {
         CurrentLibrary.EndLibrary(this);
     }
     CurrentLibrary = null;
 }
Esempio n. 4
0
 public void SortImages(string sortkind)
 {
     if (CurrentLibrary != null)
     {
         CurrentLibrary.SortImages(sortkind);
         ImageIndex = 0;
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public void Dispose()
 {
     if (CurrentLibrary != null)
     {
         CurrentLibrary.EndLibrary(this);                         // Asking the last used library to update the instance of TexImage with its last native data.
     }
     if (Disposed)
     {
         return;
     }
     if (DisposingLibrary != null)
     {
         DisposingLibrary.Dispose(this);                           // Asking the library which allocated the memory to free it.
     }
     Disposed = true;
 }
Esempio n. 6
0
        private void propertiesToolbar_ButtonClicked(object sender, ButtonEvent be)
        {
            switch (be.Button.Key)
            {
                #region case "CRT":
            case "CRT":
                if (CurrentResource != null && CurrentResource.Type.Name == "Template")
                {
                    Response.Redirect(CurrentResource.URI + "?CRT=1");
//            HyperCatalog.Business.DAM.Specific.HOTTemplate template = new HyperCatalog.Business.DAM.Specific.HOTTemplate(currentResource.MasterVariant.CurrentFile);
//            HyperComponents.IO.Streaming.SendStream(Response,template.CRTStream,currentResource.Name + ".pdf");
                    Response.End();
                }
                break;

                #endregion
                #region case "Del":
            case "Del":
                if (SessionState.User.HasCapability(Business.CapabilitiesEnum.MANAGE_RESOURCES) && CurrentResource != null)
                {
                    if (SessionState.User.IsReadOnly || CurrentResource.Delete())
                    {
                        SetMessage(propertiesMsgLbl, "Resource \"" + CurrentResource.Name + "\" deleted", MessageLevel.Information);
                        libraryList.SelectedItem.Text = String.Format(libraryListPattern, CurrentLibrary.Name, CurrentLibrary.ResourceCount);
                        _currentResourceId            = -1;
                        BindLibrary();
                    }
                    else
                    {
                        SetMessage(propertiesMsgLbl, "Resource \"" + CurrentResource.Name + "\" could not be deleted", MessageLevel.Error);
                    }
                }
                break;

                #endregion
                #region case "Save":
            case "Save":
                if (txtFileBinaryValue.PostedFile.ContentLength > 0)
                {
                    SetMessage(propertiesMsgLbl, "You must provide a file", MessageLevel.Warning);
                    return;
                }
                if (SessionState.User.HasCapability(Business.CapabilitiesEnum.MANAGE_RESOURCES))
                {
                    if (SessionState.User.IsReadOnly)
                    {
                        return;
                    }

                    if (resourceTypesAttributes.Items.Count > txtResourceTypeValue.SelectedIndex)
                    {
                        if (txtResourceNameValue.Text == null || txtResourceNameValue.Text.Length == 0)
                        {
                            SetMessage(propertiesMsgLbl, "Resource must have a name", MessageLevel.Error);
                            break;
                        }
                        string[][] attrs = getAttributeValues(resourceTypesAttributes.Items[txtResourceTypeValue.SelectedIndex]);

                        if (CurrentResource != null)
                        {
                            CurrentResource.Name        = txtResourceNameValue.Text;
                            CurrentResource.Description = txtResourceDescriptionValue.Value;
                            if (CurrentResource.Save())
                            {
                                SetMessage(propertiesMsgLbl, "Resource \"" + txtResourceNameValue.Text + "\" updated", MessageLevel.Information);

                                if (addVariant)
                                {
                                    bool   success  = false;
                                    string errorMsg = "Variant for \"" + txtResourceNameValue.Text + "\" could not be created";
                                    try
                                    {
                                        success = CurrentResource.AddVariant(txtVariantCultureValue.SelectedValue, txtFileBinaryValue.PostedFile.InputStream, Path.GetExtension(txtFileBinaryValue.PostedFile.FileName), attrs) != null;
                                    }
                                    catch (AlreadyExistingVariantException)
                                    {
                                        errorMsg += ": this variant already exists.";
                                    }

                                    if (success)
                                    {
                                        SetMessage(propertiesMsgLbl, "Variant for \"" + txtResourceNameValue.Text + "\" created", MessageLevel.Information);
                                    }
                                    else
                                    {
                                        SetMessage(propertiesMsgLbl, errorMsg, MessageLevel.Error);
                                    }
                                }

                                BindLibrary();
                            }
                            else
                            {
                                SetMessage(propertiesMsgLbl, "Resource \"" + txtResourceNameValue.Text + "\" could not be updated", MessageLevel.Error);
                            }
                        }
                        else
                        {
                            HyperCatalog.Business.DAM.Resource newResource = CurrentLibrary.AddResource(txtResourceNameValue.Text + Path.GetExtension(txtFileBinaryValue.PostedFile.FileName), txtResourceDescriptionValue.Value, Convert.ToInt32(txtResourceTypeValue.SelectedValue), txtVariantCultureValue.SelectedValue, txtFileBinaryValue.PostedFile.InputStream, attrs);
                            if (newResource != null)
                            {
                                SetMessage(propertiesMsgLbl, "Resource \"" + txtResourceNameValue.Text + "\" created", MessageLevel.Information);
                                libraryList.SelectedItem.Text = String.Format(libraryListPattern, CurrentLibrary.Name, CurrentLibrary.ResourceCount);
                                _currentResourceId            = newResource.Id;
                                BindLibrary();
                            }
                            else
                            {
                                SetMessage(propertiesMsgLbl, "Resource \"" + txtResourceNameValue.Text + "\" could not be created", MessageLevel.Error);
                            }
                        }
                    }
                }
                break;
                #endregion
            }
        }