Beispiel #1
0
    private PhotoEditorUI(ArrayList selectedphotos, DeskFlickrUI.ModeSelected mode)
    {
        Glade.XML gxml = new Glade.XML(null, "organizer.glade", "window2", null);
        gxml.Autoconnect(this);
        _isconflictmode = (mode == DeskFlickrUI.ModeSelected.ConflictMode);
        _isuploadmode   = (mode == DeskFlickrUI.ModeSelected.UploadMode);
        _isblogmode     = (mode == DeskFlickrUI.ModeSelected.BlogMode);
        if (mode == DeskFlickrUI.ModeSelected.BlogAndConflictMode)
        {
            _isconflictmode = true;
            _isblogmode     = true;
        }
        _tags         = new ArrayList();
        _comments     = new ArrayList();
        window2.Title = "Edit information for " + selectedphotos.Count + " photos";
        window2.SetIconFromFile(DeskFlickrUI.ICON_PATH);
        notebook1.SetTabLabelText(notebook1.CurrentPageWidget, "Information");
        notebook1.NextPage();
        notebook1.SetTabLabelText(notebook1.CurrentPageWidget, "Tags");
        notebook1.NextPage();
        notebook1.SetTabLabelText(notebook1.CurrentPageWidget, "Comments");

        tips = new Tooltips();
        SetCommentsToolBar();
        tips.Enable();
        SetCommentsTree();

        if (_isconflictmode)
        {
            notebook1.NextPage();
            notebook1.SetTabLabelText(notebook1.CurrentPageWidget, "Information at Server");
        }
        else
        {
            notebook1.RemovePage(3);
        }

        if (_isblogmode)
        {
            notebook1.NextPage();
            notebook1.SetTabLabelText(notebook1.CurrentPageWidget, "Blog Entry");
            notebook1.Page = 3;         // Default page is blog entry if editor is in Blog mode.
        }
        else
        {
            if (_isconflictmode)
            {
                notebook1.RemovePage(4);
            }
            else
            {
                notebook1.RemovePage(3);
            }
            notebook1.Page = 0;         // Default page is photo editing.
        }


        table1.SetColSpacing(0, 50);
        // Set Labels
        label6.Text = "Edit";
        label5.Text = "Title:";
        label4.Text = "Description:";
        label3.Text = "Visibility:";
        label2.Text = "License:";
        if (_isuploadmode)
        {
            label2.Sensitive = false;
        }
        // Labels for blog tab.
        label17.Text = "Title: ";
        label18.Text = "Description: ";

        // Search box
        label15.Markup  = "<span weight='bold'>Search: </span>";
        entry2.Changed += new EventHandler(OnFilterEntryChanged);

        // Revert button
        button9.Label    = "Revert Photo(s)";
        button9.Clicked += new EventHandler(OnRevertButtonClicked);

        // entry1.ModifyFont(Pango.FontDescription.FromString("FreeSerif 10"));
        SetPrivacyComboBox();
        SetLicenseComboBox();
        SetTagTreeView();

        // Make previous and next buttons insensitive. They'll become sensitive
        // only when the user ticks the 'Per Photo' checkbutton.
        button3.Sensitive     = false;
        button4.Sensitive     = false;
        checkbutton1.Toggled += new EventHandler(OnPerPageCheckToggled);
        button3.Clicked      += new EventHandler(OnPrevButtonClick);
        button4.Clicked      += new EventHandler(OnNextButtonClick);
        button5.Clicked      += new EventHandler(OnSaveButtonClick);
        button6.Clicked      += new EventHandler(OnCancelButtonClick);

        entry1.Changed           += new EventHandler(OnTitleChanged);
        textview5.Buffer.Changed += new EventHandler(OnDescChanged);

        combobox1.Changed += new EventHandler(OnPrivacyChanged);
        combobox2.Changed += new EventHandler(OnLicenseChanged);

        entry4.Changed           += new EventHandler(OnBlogTitleChanged);
        textview7.Buffer.Changed += new EventHandler(OnBlogDescChanged);

        textview3.Buffer.Changed += new EventHandler(OnTagsChanged);

        TextTag texttag = new TextTag("conflict");

        texttag.Font          = "Times Italic 10";
        texttag.WrapMode      = WrapMode.Word;
        texttag.ForegroundGdk = new Gdk.Color(0x99, 0, 0);
        textview4.Buffer.TagTable.Add(texttag);

        // Showing photos should be the last step.
        this._selectedphotos = selectedphotos;
        if (selectedphotos.Count == 1)
        {
            checkbutton1.Sensitive = false;
            ShowInformationForCurrentPhoto();
        }
        else
        {
            EmbedCommonInformation();
        }
        // Save a copy of the original photos, so that only those photos
        // which  have been edited, would have their dirty bit set. Advantage:
        // this would reduce the number of dirty photos, and hence there'll
        // be lesser photos to update when sycing with server.
        _originalphotos = new System.Collections.Generic.Dictionary <string, Photo>();
        foreach (DeskFlickrUI.SelectedPhoto sel in _selectedphotos)
        {
            Photo p = sel.photo;
            _originalphotos.Add(p.Id, new Photo(p));
        }

        eventbox5.ButtonPressEvent += OnLinkPressed;
        eventbox5.EnterNotifyEvent += MouseOnLink;
        eventbox5.LeaveNotifyEvent += MouseLeftLink;

        window2.ShowAll();
    }
Beispiel #2
0
    /// <summary>
    /// path,快速设置值。
    /// </summary>
    /// <param name="instance">对象</param>
    /// <param name="path">操作路径。字典key:"aa";数组索引:[0];组合使用:"data.items[0].name"。</param>
    /// <param name="value">要设置的值</param>
    /// <returns>返回是否操作成功。</returns>
    public static bool Path(object instance, string path, object value)
    {
        if (instance == null)
        {
            return(false);
        }
        if (string.IsNullOrEmpty(path))
        {
            return(false);
        }
        try {
            string[]           paths         = path.Split('.');
            object             parent        = null;
            object             lastTarget    = instance;
            string             lastKey       = null;
            bool               lastAllowNull = false;
            PathSetValueAction setMethod     = null;

            for (int i = 0; i < paths.Length; i++)
            {
                lastAllowNull = false;
                string p = paths[i];
                if (string.IsNullOrEmpty(p))
                {
                    return(false);
                }
                int    p10 = p.IndexOf('[');
                string p11 = null;
                if (p10 > -1)
                {
                    p11 = p.Substring(p10 + 1, p.Length - 2 - p10);
                    p   = p.Substring(0, p10);
                }
                //JsonObject j;
                if (!string.IsNullOrEmpty(p))
                {
                    if (System.Text.RegularExpressions.Regex.IsMatch(p, "^[0-9a-zA-Z]+$"))
                    {
                        System.Collections.Generic.IList <object> list = lastTarget as System.Collections.Generic.IList <object>;
                        if (list != null)
                        {
                            parent = lastTarget;
                            try {
                                if (string.Equals("add", p, System.StringComparison.OrdinalIgnoreCase) ||
                                    string.Equals("push", p, System.StringComparison.OrdinalIgnoreCase))
                                {
                                    lastTarget = null;
                                }
                                else
                                {
                                    lastTarget = list[TypeExtensions.Convert <int>(p, 0)];
                                }
                            } catch { lastTarget = null; }
                            lastKey       = p;
                            lastAllowNull = true;
                            setMethod     = (p1, p2, p3, p4) => {
                                //((System.Collections.Generic.IList<object>)p1)[TypeExtensions.Convert<int>(p3, 0)] = p4;
                                System.Collections.Generic.IList <object> p10_list = (System.Collections.Generic.IList <object>)p1;
                                if (string.Equals("add", p3, System.StringComparison.OrdinalIgnoreCase) ||
                                    string.Equals("push", p3, System.StringComparison.OrdinalIgnoreCase))
                                {
                                    p10_list.Add(p4);
                                    return;
                                }
                                int p11_list = TypeExtensions.Convert <int>(p3, 0);
                                if ((p10_list.Count - 1) < p11_list)
                                {
                                    p10_list.Add(p4);
                                    return;
                                }
                                p10_list[p11_list] = p4;
                            };
                            goto lb_Index;
                        }
                    }
                    {
                        System.Collections.Generic.IDictionary <string, object> dic = lastTarget as System.Collections.Generic.IDictionary <string, object>;
                        if (dic != null)
                        {
                            parent = lastTarget;
                            if (!dic.TryGetValue(p, out lastTarget))
                            {
                                lastTarget = null;
                            }
                            //lastTarget = dic[p];
                            lastKey       = p;
                            lastAllowNull = true;
                            setMethod     = (p1, p2, p3, p4) => {
                                //((System.Collections.Generic.IDictionary<string, object>)p1)[(string)p3] = p4;
                                System.Collections.Generic.IDictionary <string, object> p10_list = (System.Collections.Generic.IDictionary <string, object>)p1;
                                object p11_v;
                                if (p10_list.TryGetValue(p3, out p11_v))
                                {
                                    p10_list[p3] = p4;
                                }
                                else
                                {
                                    p10_list.Add(p3, p4);
                                }
                            };
                            goto lb_Index;
                        }
                    }
                    {
                        System.Collections.IDictionary dic = lastTarget as System.Collections.IDictionary;
                        if (dic != null)
                        {
                            parent = lastTarget;
                            try {
                                lastTarget = dic[p];
                            } catch { lastTarget = null; }
                            lastKey       = p;
                            lastAllowNull = true;
                            setMethod     = (p1, p2, p3, p4) => {
                                System.Collections.IDictionary p10_list = (System.Collections.IDictionary)p1;
                                if (p10_list.Contains(p3))
                                {
                                    p10_list[p3] = p4;
                                }
                                else
                                {
                                    p10_list.Add(p3, p4);
                                }
                                //((System.Collections.IDictionary)p1)[(string)p3] = p4;
                            };
                            goto lb_Index;
                        }
                    }
                    {
                        if (string.Equals(p, "length", System.StringComparison.OrdinalIgnoreCase))
                        {
                            setMethod = null;
                            lastKey   = null;
                            try {
                                parent     = lastTarget;
                                lastTarget = TypeExtensions.Get(lastTarget, p);
                            } catch {
                                parent     = lastTarget;
                                lastTarget = TypeExtensions.Get(lastTarget, p == "length" ? "Length" : "length");
                            }
                        }
                        else
                        {
                            lastTarget    = TypeExtensions.Get(lastTarget, p);
                            lastKey       = p;
                            lastAllowNull = true;
                            setMethod     = (p1, p2, p3, p4) => TypeExtensions.Set(p1, (string)p3, p4);
                        }
                        goto lb_Index;
                    }
                }
lb_Index:
                if (lastTarget == null && !lastAllowNull)
                {
                    return(false);
                }
                if (string.IsNullOrEmpty(p11))
                {
                    continue;
                }
                if (p11.StartsWith("\""))
                {
                    p11 = p11.Substring(1, p11.Length - 2);
                    {
                        System.Collections.Generic.IDictionary <string, object> dic = lastTarget as System.Collections.Generic.IDictionary <string, object>;
                        if (dic != null)
                        {
                            parent = lastTarget;
                            if (!dic.TryGetValue(p11, out lastTarget))
                            {
                                lastTarget = null;
                            }
                            //lastTarget = dic[p11];
                            lastKey       = p11;
                            lastAllowNull = true;
                            setMethod     = (p1, p2, p3, p4) => {
                                //((System.Collections.Generic.IDictionary<string, object>)p1)[(string)p3] = p4;
                                System.Collections.Generic.IDictionary <string, object> p10_list = (System.Collections.Generic.IDictionary <string, object>)p1;
                                object p11_v;
                                if (p10_list.TryGetValue(p3, out p11_v))
                                {
                                    p10_list[p3] = p4;
                                }
                                else
                                {
                                    p10_list.Add(p3, p4);
                                }
                            };
                            continue;
                        }
                    }
                    {
                        System.Collections.IDictionary dic = lastTarget as System.Collections.IDictionary;
                        if (dic != null)
                        {
                            parent = lastTarget;
                            try {
                                lastTarget = dic[p11];
                            } catch { lastTarget = null; }
                            lastKey       = p11;
                            lastAllowNull = true;
                            setMethod     = (p1, p2, p3, p4) => {
                                System.Collections.IDictionary p10_list = (System.Collections.IDictionary)p1;
                                if (p10_list.Contains(p3))
                                {
                                    p10_list[p3] = p4;
                                }
                                else
                                {
                                    p10_list.Add(p3, p4);
                                }
                                //((System.Collections.IDictionary)p1)[(string)p3] = p4;
                            };
                            continue;
                        }
                    }
                    {
                        parent        = lastTarget;
                        lastTarget    = TypeExtensions.Get(lastTarget, p11);
                        lastKey       = p11;
                        lastAllowNull = true;
                        setMethod     = (p1, p2, p3, p4) => TypeExtensions.Set(p1, (string)p3, p4);
                        continue;
                    }
                }
                else
                {
                    {
                        System.Collections.Generic.IList <object> list = lastTarget as System.Collections.Generic.IList <object>;
                        if (list != null)
                        {
                            parent = lastTarget;
                            try {
                                lastTarget = list[TypeExtensions.Convert <int>(p11, 0)];
                            } catch { lastTarget = null; }
                            lastKey       = p11;
                            lastAllowNull = true;
                            setMethod     = (p1, p2, p3, p4) => {
                                //((System.Collections.Generic.IList<object>)p1)[TypeExtensions.Convert<int>(p3, 0)] = p4;
                                System.Collections.Generic.IList <object> p10_list = (System.Collections.Generic.IList <object>)p1;
                                if (string.Equals("add", p3, System.StringComparison.OrdinalIgnoreCase) ||
                                    string.Equals("push", p3, System.StringComparison.OrdinalIgnoreCase))
                                {
                                    p10_list.Add(p4);
                                    return;
                                }
                                int p11_list = TypeExtensions.Convert <int>(p3, 0);
                                if ((p10_list.Count - 1) < p11_list)
                                {
                                    p10_list.Add(p4);
                                    return;
                                }
                                p10_list[p11_list] = p4;
                            };
                            continue;
                        }
                    }
                    {
                        System.Collections.IList list = lastTarget as System.Collections.IList;
                        if (list != null)
                        {
                            parent = lastTarget;
                            try {
                                lastTarget = list[TypeExtensions.Convert <int>(p11, 0)];
                            } catch { lastTarget = null; }
                            lastKey       = p11;
                            lastAllowNull = true;
                            setMethod     = (p1, p2, p3, p4) => {
                                System.Collections.IList p10_list = (System.Collections.IList)p1;
                                if (string.Equals("add", p3, System.StringComparison.OrdinalIgnoreCase) ||
                                    string.Equals("push", p3, System.StringComparison.OrdinalIgnoreCase))
                                {
                                    p10_list.Add(p4);
                                    return;
                                }
                                int p11_list = TypeExtensions.Convert <int>(p3, 0);
                                if ((p10_list.Count - 1) < p11_list)
                                {
                                    p10_list.Add(p4);
                                    return;
                                }
                                p10_list[p11_list] = p4;
                                //((System.Collections.IList)p1)[TypeExtensions.Convert<int>(p3, 0)] = p4;
                            };
                            continue;
                        }
                    }
                    {
                        System.Array list = lastTarget as System.Array;
                        if (list != null)
                        {
                            parent        = lastTarget;
                            lastTarget    = list.GetValue(TypeExtensions.Convert <int>(p11, 0));
                            lastKey       = p11;
                            lastAllowNull = true;
                            setMethod     = (p1, p2, p3, p4) => ((System.Array)p1).SetValue(p4, TypeExtensions.Convert <int>(p3, 0));
                            continue;
                        }
                    }
                }
                continue;
            }
            if (setMethod != null)
            {
                setMethod(parent, lastTarget, lastKey, value);
                return(true);
            }
            return(false);
        } catch {
            return(false);
        }
    }